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,
388 const SparseColorMethod method,const char *arguments,
389 const MagickBooleanType color_from_image,ExceptionInfo *exception)
392 token[MaxTextExtent];
416 assert(image != (Image *) NULL);
417 assert(image->signature == MagickSignature);
418 if (image->debug != MagickFalse)
419 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
420 assert(exception != (ExceptionInfo *) NULL);
421 assert(exception->signature == MagickSignature);
423 Limit channels according to image - and add up number of color channel.
426 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
428 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
430 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
432 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
433 (image->colorspace == CMYKColorspace))
435 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
436 (image->matte != MagickFalse))
440 Read string, to determine number of arguments needed,
446 GetMagickToken(p,&p,token);
447 if ( token[0] == ',' ) continue;
448 if ( isalpha((int) token[0]) || token[0] == '#' ) {
449 if ( color_from_image ) {
450 (void) ThrowMagickException(exception,GetMagickModule(),
451 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
452 "Color arg given, when colors are coming from image");
453 return( (Image *)NULL);
455 x += number_colors; /* color argument */
458 x++; /* floating point argument */
462 if ( color_from_image ) {
463 /* just the control points are being given */
464 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
465 number_arguments=(x/2)*(2+number_colors);
468 /* control points and color values */
469 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
473 (void) ThrowMagickException(exception,GetMagickModule(),
474 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
475 "Invalid number of Arguments");
476 return( (Image *)NULL);
479 /* Allocate and fill in the floating point arguments */
480 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
481 sizeof(*sparse_arguments));
482 if (sparse_arguments == (double *) NULL) {
483 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
484 "MemoryAllocationFailed","%s","SparseColorOption");
485 return( (Image *)NULL);
487 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
488 sizeof(*sparse_arguments));
491 while( *p != '\0' && x < number_arguments ) {
493 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
494 if ( token[0] == '\0' ) break;
495 if ( isalpha((int) token[0]) || token[0] == '#' ) {
496 (void) ThrowMagickException(exception,GetMagickModule(),
497 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
498 "Color found, instead of X-coord");
502 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
504 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
505 if ( token[0] == '\0' ) break;
506 if ( isalpha((int) token[0]) || token[0] == '#' ) {
507 (void) ThrowMagickException(exception,GetMagickModule(),
508 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
509 "Color found, instead of Y-coord");
513 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
514 /* color values for this control point */
516 if ( (color_from_image ) {
517 /* get color from image */
523 /* color name or function given in string argument */
524 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
525 if ( token[0] == '\0' ) break;
526 if ( isalpha((int) token[0]) || token[0] == '#' ) {
527 /* Color string given */
528 (void) QueryMagickColor(token,&color,exception);
529 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
530 sparse_arguments[x++] = QuantumScale*color.red;
531 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
532 sparse_arguments[x++] = QuantumScale*color.green;
533 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
534 sparse_arguments[x++] = QuantumScale*color.blue;
535 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
536 (image->colorspace == CMYKColorspace))
537 sparse_arguments[x++] = QuantumScale*color.black;
538 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
539 (image->matte != MagickFalse))
540 sparse_arguments[x++] = QuantumScale*color.alpha;
543 /* Colors given as a set of floating point values - experimental */
544 /* NB: token contains the first floating point value to use! */
545 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
547 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
548 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
550 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
551 token[0] = ','; /* used this token - get another */
553 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
555 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
556 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
558 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
559 token[0] = ','; /* used this token - get another */
561 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
563 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
564 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
566 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
567 token[0] = ','; /* used this token - get another */
569 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
570 (image->colorspace == CMYKColorspace))
572 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
573 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
575 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
576 token[0] = ','; /* used this token - get another */
578 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
579 (image->matte != MagickFalse))
581 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
582 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
584 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
585 token[0] = ','; /* used this token - get another */
590 if ( number_arguments != x && !error ) {
591 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
592 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
593 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
594 return( (Image *)NULL);
597 return( (Image *)NULL);
599 /* Call the Interpolation function with the parsed arguments */
600 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( sparse_image );
606 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
607 const char **argv,Image **image,ExceptionInfo *exception)
648 Initialize method variables.
650 assert(image_info != (const ImageInfo *) NULL);
651 assert(image_info->signature == MagickSignature);
652 assert(image != (Image **) NULL);
653 assert((*image)->signature == MagickSignature);
654 if ((*image)->debug != MagickFalse)
655 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
658 mogrify_info=CloneImageInfo(image_info);
659 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
660 quantize_info=AcquireQuantizeInfo(mogrify_info);
661 SetGeometryInfo(&geometry_info);
662 GetPixelInfo(*image,&fill);
663 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
664 channel=mogrify_info->channel;
665 format=GetImageOption(mogrify_info,"format");
666 SetGeometry(*image,®ion_geometry);
667 region_image=NewImageList();
669 Transmogrify the image.
671 for (i=0; i < (ssize_t) argc; i++)
680 if (IsCommandOption(option) == MagickFalse)
682 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
684 if ((i+count) >= (ssize_t) argc)
686 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
687 mogrify_image=(Image *)NULL;
692 if (LocaleCompare("adaptive-blur",option+1) == 0)
697 (void) SyncImageSettings(mogrify_info,*image);
698 flags=ParseGeometry(argv[i+1],&geometry_info);
699 if ((flags & SigmaValue) == 0)
700 geometry_info.sigma=1.0;
701 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
702 geometry_info.sigma,exception);
705 if (LocaleCompare("adaptive-resize",option+1) == 0)
708 Adaptive resize image.
710 (void) SyncImageSettings(mogrify_info,*image);
711 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
712 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
713 geometry.height,exception);
716 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
719 Adaptive sharpen image.
721 (void) SyncImageSettings(mogrify_info,*image);
722 flags=ParseGeometry(argv[i+1],&geometry_info);
723 if ((flags & SigmaValue) == 0)
724 geometry_info.sigma=1.0;
725 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
726 geometry_info.sigma,exception);
729 if (LocaleCompare("affine",option+1) == 0)
736 GetAffineMatrix(&draw_info->affine);
739 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
742 if (LocaleCompare("alpha",option+1) == 0)
747 (void) SyncImageSettings(mogrify_info,*image);
748 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
749 MagickFalse,argv[i+1]);
750 (void) SetImageAlphaChannel(*image,alpha_type);
751 InheritException(exception,&(*image)->exception);
754 if (LocaleCompare("annotate",option+1) == 0)
758 geometry[MaxTextExtent];
763 (void) SyncImageSettings(mogrify_info,*image);
764 SetGeometryInfo(&geometry_info);
765 flags=ParseGeometry(argv[i+1],&geometry_info);
766 if ((flags & SigmaValue) == 0)
767 geometry_info.sigma=geometry_info.rho;
768 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
769 InheritException(exception,&(*image)->exception);
770 if (text == (char *) NULL)
772 (void) CloneString(&draw_info->text,text);
773 text=DestroyString(text);
774 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
775 geometry_info.xi,geometry_info.psi);
776 (void) CloneString(&draw_info->geometry,geometry);
777 draw_info->affine.sx=cos(DegreesToRadians(
778 fmod(geometry_info.rho,360.0)));
779 draw_info->affine.rx=sin(DegreesToRadians(
780 fmod(geometry_info.rho,360.0)));
781 draw_info->affine.ry=(-sin(DegreesToRadians(
782 fmod(geometry_info.sigma,360.0))));
783 draw_info->affine.sy=cos(DegreesToRadians(
784 fmod(geometry_info.sigma,360.0)));
785 (void) AnnotateImage(*image,draw_info);
786 InheritException(exception,&(*image)->exception);
789 if (LocaleCompare("antialias",option+1) == 0)
791 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
793 draw_info->text_antialias=(*option == '-') ? MagickTrue :
797 if (LocaleCompare("auto-gamma",option+1) == 0)
800 Auto Adjust Gamma of image based on its mean
802 (void) SyncImageSettings(mogrify_info,*image);
803 (void) AutoGammaImage(*image);
806 if (LocaleCompare("auto-level",option+1) == 0)
809 Perfectly Normalize (max/min stretch) the image
811 (void) SyncImageSettings(mogrify_info,*image);
812 (void) AutoLevelImage(*image);
815 if (LocaleCompare("auto-orient",option+1) == 0)
817 (void) SyncImageSettings(mogrify_info,*image);
818 switch ((*image)->orientation)
820 case TopRightOrientation:
822 mogrify_image=FlopImage(*image,exception);
825 case BottomRightOrientation:
827 mogrify_image=RotateImage(*image,180.0,exception);
830 case BottomLeftOrientation:
832 mogrify_image=FlipImage(*image,exception);
835 case LeftTopOrientation:
837 mogrify_image=TransposeImage(*image,exception);
840 case RightTopOrientation:
842 mogrify_image=RotateImage(*image,90.0,exception);
845 case RightBottomOrientation:
847 mogrify_image=TransverseImage(*image,exception);
850 case LeftBottomOrientation:
852 mogrify_image=RotateImage(*image,270.0,exception);
858 if (mogrify_image != (Image *) NULL)
859 mogrify_image->orientation=TopLeftOrientation;
866 if (LocaleCompare("black-threshold",option+1) == 0)
869 Black threshold image.
871 (void) SyncImageSettings(mogrify_info,*image);
872 (void) BlackThresholdImage(*image,argv[i+1],exception);
873 InheritException(exception,&(*image)->exception);
876 if (LocaleCompare("blue-shift",option+1) == 0)
881 (void) SyncImageSettings(mogrify_info,*image);
882 geometry_info.rho=1.5;
884 flags=ParseGeometry(argv[i+1],&geometry_info);
885 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
888 if (LocaleCompare("blur",option+1) == 0)
893 (void) SyncImageSettings(mogrify_info,*image);
894 flags=ParseGeometry(argv[i+1],&geometry_info);
895 if ((flags & SigmaValue) == 0)
896 geometry_info.sigma=1.0;
897 mogrify_image=BlurImage(*image,geometry_info.rho,
898 geometry_info.sigma,exception);
901 if (LocaleCompare("border",option+1) == 0)
904 Surround image with a border of solid color.
906 (void) SyncImageSettings(mogrify_info,*image);
907 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
908 if ((flags & SigmaValue) == 0)
909 geometry.height=geometry.width;
910 mogrify_image=BorderImage(*image,&geometry,exception);
913 if (LocaleCompare("bordercolor",option+1) == 0)
917 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
921 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
925 if (LocaleCompare("box",option+1) == 0)
927 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
931 if (LocaleCompare("brightness-contrast",option+1) == 0)
944 Brightness / contrast image.
946 (void) SyncImageSettings(mogrify_info,*image);
947 flags=ParseGeometry(argv[i+1],&geometry_info);
948 brightness=geometry_info.rho;
950 if ((flags & SigmaValue) != 0)
951 contrast=geometry_info.sigma;
952 (void) BrightnessContrastImage(*image,brightness,contrast);
953 InheritException(exception,&(*image)->exception);
960 if (LocaleCompare("cdl",option+1) == 0)
963 *color_correction_collection;
966 Color correct with a color decision list.
968 (void) SyncImageSettings(mogrify_info,*image);
969 color_correction_collection=FileToString(argv[i+1],~0,exception);
970 if (color_correction_collection == (char *) NULL)
972 (void) ColorDecisionListImage(*image,color_correction_collection);
973 InheritException(exception,&(*image)->exception);
976 if (LocaleCompare("channel",option+1) == 0)
979 channel=DefaultChannels;
981 channel=(ChannelType) ParseChannelOption(argv[i+1]);
982 SetPixelComponentMap(*image,channel);
985 if (LocaleCompare("charcoal",option+1) == 0)
990 (void) SyncImageSettings(mogrify_info,*image);
991 flags=ParseGeometry(argv[i+1],&geometry_info);
992 if ((flags & SigmaValue) == 0)
993 geometry_info.sigma=1.0;
994 mogrify_image=CharcoalImage(*image,geometry_info.rho,
995 geometry_info.sigma,exception);
998 if (LocaleCompare("chop",option+1) == 0)
1003 (void) SyncImageSettings(mogrify_info,*image);
1004 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1005 mogrify_image=ChopImage(*image,&geometry,exception);
1008 if (LocaleCompare("clamp",option+1) == 0)
1013 (void) SyncImageSettings(mogrify_info,*image);
1014 (void) ClampImage(*image);
1015 InheritException(exception,&(*image)->exception);
1018 if (LocaleCompare("clip",option+1) == 0)
1020 (void) SyncImageSettings(mogrify_info,*image);
1023 (void) SetImageClipMask(*image,(Image *) NULL);
1024 InheritException(exception,&(*image)->exception);
1027 (void) ClipImage(*image);
1028 InheritException(exception,&(*image)->exception);
1031 if (LocaleCompare("clip-mask",option+1) == 0)
1048 (void) SyncImageSettings(mogrify_info,*image);
1054 (void) SetImageMask(*image,(Image *) NULL);
1055 InheritException(exception,&(*image)->exception);
1060 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1062 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1063 if (mask_image == (Image *) NULL)
1065 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1066 return(MagickFalse);
1067 mask_view=AcquireCacheView(mask_image);
1068 for (y=0; y < (ssize_t) mask_image->rows; y++)
1070 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1072 if (q == (const Quantum *) NULL)
1074 for (x=0; x < (ssize_t) mask_image->columns; x++)
1076 if (mask_image->matte == MagickFalse)
1077 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1078 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1079 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1080 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1081 q+=GetPixelComponents(mask_image);
1083 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1086 mask_view=DestroyCacheView(mask_view);
1087 mask_image->matte=MagickTrue;
1088 (void) SetImageClipMask(*image,mask_image);
1089 mask_image=DestroyImage(mask_image);
1090 InheritException(exception,&(*image)->exception);
1093 if (LocaleCompare("clip-path",option+1) == 0)
1095 (void) SyncImageSettings(mogrify_info,*image);
1096 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1098 InheritException(exception,&(*image)->exception);
1101 if (LocaleCompare("colorize",option+1) == 0)
1106 (void) SyncImageSettings(mogrify_info,*image);
1107 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1111 if (LocaleCompare("color-matrix",option+1) == 0)
1116 (void) SyncImageSettings(mogrify_info,*image);
1117 kernel=AcquireKernelInfo(argv[i+1]);
1118 if (kernel == (KernelInfo *) NULL)
1120 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1121 kernel=DestroyKernelInfo(kernel);
1124 if (LocaleCompare("colors",option+1) == 0)
1127 Reduce the number of colors in the image.
1129 (void) SyncImageSettings(mogrify_info,*image);
1130 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1131 if (quantize_info->number_colors == 0)
1133 if (((*image)->storage_class == DirectClass) ||
1134 (*image)->colors > quantize_info->number_colors)
1135 (void) QuantizeImage(quantize_info,*image);
1137 (void) CompressImageColormap(*image);
1138 InheritException(exception,&(*image)->exception);
1141 if (LocaleCompare("colorspace",option+1) == 0)
1146 (void) SyncImageSettings(mogrify_info,*image);
1149 (void) TransformImageColorspace(*image,RGBColorspace);
1150 InheritException(exception,&(*image)->exception);
1153 colorspace=(ColorspaceType) ParseCommandOption(
1154 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1155 (void) TransformImageColorspace(*image,colorspace);
1156 InheritException(exception,&(*image)->exception);
1159 if (LocaleCompare("contrast",option+1) == 0)
1161 (void) SyncImageSettings(mogrify_info,*image);
1162 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1164 InheritException(exception,&(*image)->exception);
1167 if (LocaleCompare("contrast-stretch",option+1) == 0)
1177 Contrast stretch image.
1179 (void) SyncImageSettings(mogrify_info,*image);
1180 flags=ParseGeometry(argv[i+1],&geometry_info);
1181 black_point=geometry_info.rho;
1182 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1184 if ((flags & PercentValue) != 0)
1186 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1187 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1189 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1191 (void) ContrastStretchImage(*image,black_point,white_point);
1192 InheritException(exception,&(*image)->exception);
1195 if (LocaleCompare("convolve",option+1) == 0)
1206 (void) SyncImageSettings(mogrify_info,*image);
1207 kernel=AcquireKernelInfo(argv[i+1]);
1208 if (kernel == (KernelInfo *) NULL)
1211 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1212 gamma+=kernel->values[j];
1213 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1214 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1215 kernel->values[j]*=gamma;
1216 mogrify_image=FilterImage(*image,kernel,exception);
1217 kernel=DestroyKernelInfo(kernel);
1220 if (LocaleCompare("crop",option+1) == 0)
1223 Crop a image to a smaller size
1225 (void) SyncImageSettings(mogrify_info,*image);
1227 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1228 if (((geometry.width != 0) || (geometry.height != 0)) &&
1229 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1233 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1234 mogrify_image->next = mogrify_image->previous = (Image *)NULL;
1235 (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL);
1236 InheritException(exception,&mogrify_image->exception);
1238 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1242 if (LocaleCompare("cycle",option+1) == 0)
1245 Cycle an image colormap.
1247 (void) SyncImageSettings(mogrify_info,*image);
1248 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1249 InheritException(exception,&(*image)->exception);
1256 if (LocaleCompare("decipher",option+1) == 0)
1264 (void) SyncImageSettings(mogrify_info,*image);
1265 passkey=FileToStringInfo(argv[i+1],~0,exception);
1266 if (passkey != (StringInfo *) NULL)
1268 (void) PasskeyDecipherImage(*image,passkey,exception);
1269 passkey=DestroyStringInfo(passkey);
1273 if (LocaleCompare("density",option+1) == 0)
1278 (void) CloneString(&draw_info->density,argv[i+1]);
1281 if (LocaleCompare("depth",option+1) == 0)
1283 (void) SyncImageSettings(mogrify_info,*image);
1286 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1289 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1292 if (LocaleCompare("deskew",option+1) == 0)
1298 Straighten the image.
1300 (void) SyncImageSettings(mogrify_info,*image);
1302 threshold=40.0*QuantumRange/100.0;
1304 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1305 mogrify_image=DeskewImage(*image,threshold,exception);
1308 if (LocaleCompare("despeckle",option+1) == 0)
1311 Reduce the speckles within an image.
1313 (void) SyncImageSettings(mogrify_info,*image);
1314 mogrify_image=DespeckleImage(*image,exception);
1317 if (LocaleCompare("display",option+1) == 0)
1319 (void) CloneString(&draw_info->server_name,argv[i+1]);
1322 if (LocaleCompare("distort",option+1) == 0)
1326 token[MaxTextExtent];
1346 (void) SyncImageSettings(mogrify_info,*image);
1347 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1348 MagickFalse,argv[i+1]);
1349 if ( method == ResizeDistortion )
1351 /* Special Case - Argument is actually a resize geometry!
1352 ** Convert that to an appropriate distortion argument array.
1356 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1358 resize_args[0]=(double)geometry.width;
1359 resize_args[1]=(double)geometry.height;
1360 mogrify_image=DistortImage(*image,method,(size_t)2,
1361 resize_args,MagickTrue,exception);
1364 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1365 InheritException(exception,&(*image)->exception);
1366 if (args == (char *) NULL)
1369 for (x=0; *p != '\0'; x++)
1371 GetMagickToken(p,&p,token);
1373 GetMagickToken(p,&p,token);
1375 number_arguments=(size_t) x;
1376 arguments=(double *) AcquireQuantumMemory(number_arguments,
1377 sizeof(*arguments));
1378 if (arguments == (double *) NULL)
1379 ThrowWandFatalException(ResourceLimitFatalError,
1380 "MemoryAllocationFailed",(*image)->filename);
1381 (void) ResetMagickMemory(arguments,0,number_arguments*
1382 sizeof(*arguments));
1384 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1386 GetMagickToken(p,&p,token);
1388 GetMagickToken(p,&p,token);
1389 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1391 args=DestroyString(args);
1392 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1393 (*option == '+') ? MagickTrue : MagickFalse,exception);
1394 arguments=(double *) RelinquishMagickMemory(arguments);
1397 if (LocaleCompare("dither",option+1) == 0)
1401 quantize_info->dither=MagickFalse;
1404 quantize_info->dither=MagickTrue;
1405 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1406 MagickDitherOptions,MagickFalse,argv[i+1]);
1407 if (quantize_info->dither_method == NoDitherMethod)
1408 quantize_info->dither=MagickFalse;
1411 if (LocaleCompare("draw",option+1) == 0)
1416 (void) SyncImageSettings(mogrify_info,*image);
1417 (void) CloneString(&draw_info->primitive,argv[i+1]);
1418 (void) DrawImage(*image,draw_info);
1419 InheritException(exception,&(*image)->exception);
1426 if (LocaleCompare("edge",option+1) == 0)
1429 Enhance edges in the image.
1431 (void) SyncImageSettings(mogrify_info,*image);
1432 flags=ParseGeometry(argv[i+1],&geometry_info);
1433 if ((flags & SigmaValue) == 0)
1434 geometry_info.sigma=1.0;
1435 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1438 if (LocaleCompare("emboss",option+1) == 0)
1441 Gaussian embossen image.
1443 (void) SyncImageSettings(mogrify_info,*image);
1444 flags=ParseGeometry(argv[i+1],&geometry_info);
1445 if ((flags & SigmaValue) == 0)
1446 geometry_info.sigma=1.0;
1447 mogrify_image=EmbossImage(*image,geometry_info.rho,
1448 geometry_info.sigma,exception);
1451 if (LocaleCompare("encipher",option+1) == 0)
1459 (void) SyncImageSettings(mogrify_info,*image);
1460 passkey=FileToStringInfo(argv[i+1],~0,exception);
1461 if (passkey != (StringInfo *) NULL)
1463 (void) PasskeyEncipherImage(*image,passkey,exception);
1464 passkey=DestroyStringInfo(passkey);
1468 if (LocaleCompare("encoding",option+1) == 0)
1470 (void) CloneString(&draw_info->encoding,argv[i+1]);
1473 if (LocaleCompare("enhance",option+1) == 0)
1478 (void) SyncImageSettings(mogrify_info,*image);
1479 mogrify_image=EnhanceImage(*image,exception);
1482 if (LocaleCompare("equalize",option+1) == 0)
1487 (void) SyncImageSettings(mogrify_info,*image);
1488 (void) EqualizeImage(*image);
1489 InheritException(exception,&(*image)->exception);
1492 if (LocaleCompare("evaluate",option+1) == 0)
1497 MagickEvaluateOperator
1500 (void) SyncImageSettings(mogrify_info,*image);
1501 op=(MagickEvaluateOperator) ParseCommandOption(
1502 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1503 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1504 (void) EvaluateImage(*image,op,constant,exception);
1507 if (LocaleCompare("extent",option+1) == 0)
1510 Set the image extent.
1512 (void) SyncImageSettings(mogrify_info,*image);
1513 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1514 if (geometry.width == 0)
1515 geometry.width=(*image)->columns;
1516 if (geometry.height == 0)
1517 geometry.height=(*image)->rows;
1518 mogrify_image=ExtentImage(*image,&geometry,exception);
1525 if (LocaleCompare("family",option+1) == 0)
1529 if (draw_info->family != (char *) NULL)
1530 draw_info->family=DestroyString(draw_info->family);
1533 (void) CloneString(&draw_info->family,argv[i+1]);
1536 if (LocaleCompare("features",option+1) == 0)
1540 (void) DeleteImageArtifact(*image,"identify:features");
1543 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1546 if (LocaleCompare("fill",option+1) == 0)
1551 GetPixelInfo(*image,&fill);
1554 (void) QueryMagickColor("none",&fill,exception);
1555 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1556 if (draw_info->fill_pattern != (Image *) NULL)
1557 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1560 sans=AcquireExceptionInfo();
1561 (void) QueryMagickColor(argv[i+1],&fill,sans);
1562 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1563 sans=DestroyExceptionInfo(sans);
1564 if (status == MagickFalse)
1565 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1569 if (LocaleCompare("flip",option+1) == 0)
1572 Flip image scanlines.
1574 (void) SyncImageSettings(mogrify_info,*image);
1575 mogrify_image=FlipImage(*image,exception);
1578 if (LocaleCompare("floodfill",option+1) == 0)
1586 (void) SyncImageSettings(mogrify_info,*image);
1587 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1588 (void) QueryMagickColor(argv[i+2],&target,exception);
1589 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1590 geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1591 InheritException(exception,&(*image)->exception);
1594 if (LocaleCompare("flop",option+1) == 0)
1597 Flop image scanlines.
1599 (void) SyncImageSettings(mogrify_info,*image);
1600 mogrify_image=FlopImage(*image,exception);
1603 if (LocaleCompare("font",option+1) == 0)
1607 if (draw_info->font != (char *) NULL)
1608 draw_info->font=DestroyString(draw_info->font);
1611 (void) CloneString(&draw_info->font,argv[i+1]);
1614 if (LocaleCompare("format",option+1) == 0)
1619 if (LocaleCompare("frame",option+1) == 0)
1625 Surround image with an ornamental border.
1627 (void) SyncImageSettings(mogrify_info,*image);
1628 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1629 frame_info.width=geometry.width;
1630 frame_info.height=geometry.height;
1631 if ((flags & HeightValue) == 0)
1632 frame_info.height=geometry.width;
1633 frame_info.outer_bevel=geometry.x;
1634 frame_info.inner_bevel=geometry.y;
1635 frame_info.x=(ssize_t) frame_info.width;
1636 frame_info.y=(ssize_t) frame_info.height;
1637 frame_info.width=(*image)->columns+2*frame_info.width;
1638 frame_info.height=(*image)->rows+2*frame_info.height;
1639 mogrify_image=FrameImage(*image,&frame_info,exception);
1642 if (LocaleCompare("function",option+1) == 0)
1646 token[MaxTextExtent];
1664 Function Modify Image Values
1666 (void) SyncImageSettings(mogrify_info,*image);
1667 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1668 MagickFalse,argv[i+1]);
1669 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1670 InheritException(exception,&(*image)->exception);
1671 if (arguments == (char *) NULL)
1673 p=(char *) arguments;
1674 for (x=0; *p != '\0'; x++)
1676 GetMagickToken(p,&p,token);
1678 GetMagickToken(p,&p,token);
1680 number_parameters=(size_t) x;
1681 parameters=(double *) AcquireQuantumMemory(number_parameters,
1682 sizeof(*parameters));
1683 if (parameters == (double *) NULL)
1684 ThrowWandFatalException(ResourceLimitFatalError,
1685 "MemoryAllocationFailed",(*image)->filename);
1686 (void) ResetMagickMemory(parameters,0,number_parameters*
1687 sizeof(*parameters));
1688 p=(char *) arguments;
1689 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1691 GetMagickToken(p,&p,token);
1693 GetMagickToken(p,&p,token);
1694 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1696 arguments=DestroyString(arguments);
1697 (void) FunctionImage(*image,function,number_parameters,parameters,
1699 parameters=(double *) RelinquishMagickMemory(parameters);
1706 if (LocaleCompare("gamma",option+1) == 0)
1711 (void) SyncImageSettings(mogrify_info,*image);
1713 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1716 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1718 InheritException(exception,&(*image)->exception);
1722 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1723 (LocaleCompare("gaussian",option+1) == 0))
1726 Gaussian blur image.
1728 (void) SyncImageSettings(mogrify_info,*image);
1729 flags=ParseGeometry(argv[i+1],&geometry_info);
1730 if ((flags & SigmaValue) == 0)
1731 geometry_info.sigma=1.0;
1732 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1733 geometry_info.sigma,exception);
1736 if (LocaleCompare("geometry",option+1) == 0)
1739 Record Image offset, Resize last image.
1741 (void) SyncImageSettings(mogrify_info,*image);
1744 if ((*image)->geometry != (char *) NULL)
1745 (*image)->geometry=DestroyString((*image)->geometry);
1748 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1749 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1750 (void) CloneString(&(*image)->geometry,argv[i+1]);
1752 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1753 (*image)->filter,(*image)->blur,exception);
1756 if (LocaleCompare("gravity",option+1) == 0)
1760 draw_info->gravity=UndefinedGravity;
1763 draw_info->gravity=(GravityType) ParseCommandOption(
1764 MagickGravityOptions,MagickFalse,argv[i+1]);
1771 if (LocaleCompare("highlight-color",option+1) == 0)
1773 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1780 if (LocaleCompare("identify",option+1) == 0)
1785 (void) SyncImageSettings(mogrify_info,*image);
1786 if (format == (char *) NULL)
1788 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1789 InheritException(exception,&(*image)->exception);
1792 text=InterpretImageProperties(mogrify_info,*image,format);
1793 InheritException(exception,&(*image)->exception);
1794 if (text == (char *) NULL)
1796 (void) fputs(text,stdout);
1797 (void) fputc('\n',stdout);
1798 text=DestroyString(text);
1801 if (LocaleCompare("implode",option+1) == 0)
1806 (void) SyncImageSettings(mogrify_info,*image);
1807 (void) ParseGeometry(argv[i+1],&geometry_info);
1808 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1811 if (LocaleCompare("interline-spacing",option+1) == 0)
1814 (void) ParseGeometry("0",&geometry_info);
1816 (void) ParseGeometry(argv[i+1],&geometry_info);
1817 draw_info->interline_spacing=geometry_info.rho;
1820 if (LocaleCompare("interword-spacing",option+1) == 0)
1823 (void) ParseGeometry("0",&geometry_info);
1825 (void) ParseGeometry(argv[i+1],&geometry_info);
1826 draw_info->interword_spacing=geometry_info.rho;
1833 if (LocaleCompare("kerning",option+1) == 0)
1836 (void) ParseGeometry("0",&geometry_info);
1838 (void) ParseGeometry(argv[i+1],&geometry_info);
1839 draw_info->kerning=geometry_info.rho;
1846 if (LocaleCompare("lat",option+1) == 0)
1849 Local adaptive threshold image.
1851 (void) SyncImageSettings(mogrify_info,*image);
1852 flags=ParseGeometry(argv[i+1],&geometry_info);
1853 if ((flags & PercentValue) != 0)
1854 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1855 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1856 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1857 geometry_info.xi,exception);
1860 if (LocaleCompare("level",option+1) == 0)
1873 (void) SyncImageSettings(mogrify_info,*image);
1874 flags=ParseGeometry(argv[i+1],&geometry_info);
1875 black_point=geometry_info.rho;
1876 white_point=(MagickRealType) QuantumRange;
1877 if ((flags & SigmaValue) != 0)
1878 white_point=geometry_info.sigma;
1880 if ((flags & XiValue) != 0)
1881 gamma=geometry_info.xi;
1882 if ((flags & PercentValue) != 0)
1884 black_point*=(MagickRealType) (QuantumRange/100.0);
1885 white_point*=(MagickRealType) (QuantumRange/100.0);
1887 if ((flags & SigmaValue) == 0)
1888 white_point=(MagickRealType) QuantumRange-black_point;
1889 if ((*option == '+') || ((flags & AspectValue) != 0))
1890 (void) LevelizeImage(*image,black_point,white_point,gamma);
1892 (void) LevelImage(*image,black_point,white_point,gamma);
1893 InheritException(exception,&(*image)->exception);
1896 if (LocaleCompare("level-colors",option+1) == 0)
1899 token[MaxTextExtent];
1908 p=(const char *) argv[i+1];
1909 GetMagickToken(p,&p,token); /* get black point color */
1910 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1911 (void) QueryMagickColor(token,&black_point,exception);
1913 (void) QueryMagickColor("#000000",&black_point,exception);
1914 if (isalpha((int) token[0]) || (token[0] == '#'))
1915 GetMagickToken(p,&p,token);
1917 white_point=black_point; /* set everything to that color */
1920 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1921 GetMagickToken(p,&p,token); /* Get white point color. */
1922 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1923 (void) QueryMagickColor(token,&white_point,exception);
1925 (void) QueryMagickColor("#ffffff",&white_point,exception);
1927 (void) LevelImageColors(*image,&black_point,&white_point,
1928 *option == '+' ? MagickTrue : MagickFalse);
1931 if (LocaleCompare("linear-stretch",option+1) == 0)
1940 (void) SyncImageSettings(mogrify_info,*image);
1941 flags=ParseGeometry(argv[i+1],&geometry_info);
1942 black_point=geometry_info.rho;
1943 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1944 if ((flags & SigmaValue) != 0)
1945 white_point=geometry_info.sigma;
1946 if ((flags & PercentValue) != 0)
1948 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1949 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1951 if ((flags & SigmaValue) == 0)
1952 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1954 (void) LinearStretchImage(*image,black_point,white_point);
1955 InheritException(exception,&(*image)->exception);
1958 if (LocaleCompare("linewidth",option+1) == 0)
1960 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1964 if (LocaleCompare("liquid-rescale",option+1) == 0)
1967 Liquid rescale image.
1969 (void) SyncImageSettings(mogrify_info,*image);
1970 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1971 if ((flags & XValue) == 0)
1973 if ((flags & YValue) == 0)
1975 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1976 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1979 if (LocaleCompare("lowlight-color",option+1) == 0)
1981 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1988 if (LocaleCompare("map",option+1) == 0)
1994 Transform image colors to match this set of colors.
1996 (void) SyncImageSettings(mogrify_info,*image);
1999 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2000 if (remap_image == (Image *) NULL)
2002 (void) RemapImage(quantize_info,*image,remap_image);
2003 InheritException(exception,&(*image)->exception);
2004 remap_image=DestroyImage(remap_image);
2007 if (LocaleCompare("mask",option+1) == 0)
2012 (void) SyncImageSettings(mogrify_info,*image);
2018 (void) SetImageMask(*image,(Image *) NULL);
2019 InheritException(exception,&(*image)->exception);
2025 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2026 if (mask == (Image *) NULL)
2028 (void) SetImageMask(*image,mask);
2029 mask=DestroyImage(mask);
2030 InheritException(exception,&(*image)->exception);
2033 if (LocaleCompare("matte",option+1) == 0)
2035 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2036 SetAlphaChannel : DeactivateAlphaChannel );
2037 InheritException(exception,&(*image)->exception);
2040 if (LocaleCompare("median",option+1) == 0)
2043 Median filter image.
2045 (void) SyncImageSettings(mogrify_info,*image);
2046 (void) ParseGeometry(argv[i+1],&geometry_info);
2047 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2048 geometry_info.rho,(size_t) geometry_info.rho,exception);
2051 if (LocaleCompare("mode",option+1) == 0)
2056 (void) SyncImageSettings(mogrify_info,*image);
2057 (void) ParseGeometry(argv[i+1],&geometry_info);
2058 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2059 geometry_info.rho,(size_t) geometry_info.rho,exception);
2062 if (LocaleCompare("modulate",option+1) == 0)
2064 (void) SyncImageSettings(mogrify_info,*image);
2065 (void) ModulateImage(*image,argv[i+1]);
2066 InheritException(exception,&(*image)->exception);
2069 if (LocaleCompare("monitor",option+1) == 0)
2073 (void) SetImageProgressMonitor(*image,
2074 (MagickProgressMonitor) NULL,(void *) NULL);
2077 (void) SetImageProgressMonitor(*image,MonitorProgress,
2081 if (LocaleCompare("monochrome",option+1) == 0)
2083 (void) SyncImageSettings(mogrify_info,*image);
2084 (void) SetImageType(*image,BilevelType);
2085 InheritException(exception,&(*image)->exception);
2088 if (LocaleCompare("morphology",option+1) == 0)
2091 token[MaxTextExtent];
2106 Morphological Image Operation
2108 (void) SyncImageSettings(mogrify_info,*image);
2110 GetMagickToken(p,&p,token);
2111 method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions,
2114 GetMagickToken(p,&p,token);
2115 if ((*p == ':') || (*p == ','))
2116 GetMagickToken(p,&p,token);
2118 iterations=(ssize_t) StringToLong(p);
2119 kernel=AcquireKernelInfo(argv[i+2]);
2120 if (kernel == (KernelInfo *) NULL)
2122 (void) ThrowMagickException(exception,GetMagickModule(),
2123 OptionError,"UnabletoParseKernel","morphology");
2127 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2129 kernel=DestroyKernelInfo(kernel);
2132 if (LocaleCompare("motion-blur",option+1) == 0)
2137 (void) SyncImageSettings(mogrify_info,*image);
2138 flags=ParseGeometry(argv[i+1],&geometry_info);
2139 if ((flags & SigmaValue) == 0)
2140 geometry_info.sigma=1.0;
2141 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2142 geometry_info.sigma,geometry_info.xi,exception);
2149 if (LocaleCompare("negate",option+1) == 0)
2151 (void) SyncImageSettings(mogrify_info,*image);
2152 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2154 InheritException(exception,&(*image)->exception);
2157 if (LocaleCompare("noise",option+1) == 0)
2159 (void) SyncImageSettings(mogrify_info,*image);
2162 (void) ParseGeometry(argv[i+1],&geometry_info);
2163 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2164 geometry_info.rho,(size_t) geometry_info.rho,exception);
2171 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2172 MagickFalse,argv[i+1]);
2173 mogrify_image=AddNoiseImage(*image,noise,exception);
2177 if (LocaleCompare("normalize",option+1) == 0)
2179 (void) SyncImageSettings(mogrify_info,*image);
2180 (void) NormalizeImage(*image);
2181 InheritException(exception,&(*image)->exception);
2188 if (LocaleCompare("opaque",option+1) == 0)
2193 (void) SyncImageSettings(mogrify_info,*image);
2194 (void) QueryMagickColor(argv[i+1],&target,exception);
2195 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2196 MagickFalse : MagickTrue);
2199 if (LocaleCompare("ordered-dither",option+1) == 0)
2201 (void) SyncImageSettings(mogrify_info,*image);
2202 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2209 if (LocaleCompare("paint",option+1) == 0)
2211 (void) SyncImageSettings(mogrify_info,*image);
2212 (void) ParseGeometry(argv[i+1],&geometry_info);
2213 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2216 if (LocaleCompare("pen",option+1) == 0)
2220 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2223 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2226 if (LocaleCompare("pointsize",option+1) == 0)
2229 (void) ParseGeometry("12",&geometry_info);
2231 (void) ParseGeometry(argv[i+1],&geometry_info);
2232 draw_info->pointsize=geometry_info.rho;
2235 if (LocaleCompare("polaroid",option+1) == 0)
2244 Simulate a Polaroid picture.
2246 (void) SyncImageSettings(mogrify_info,*image);
2247 random_info=AcquireRandomInfo();
2248 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2249 random_info=DestroyRandomInfo(random_info);
2252 SetGeometryInfo(&geometry_info);
2253 flags=ParseGeometry(argv[i+1],&geometry_info);
2254 angle=geometry_info.rho;
2256 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2259 if (LocaleCompare("posterize",option+1) == 0)
2264 (void) SyncImageSettings(mogrify_info,*image);
2265 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2266 quantize_info->dither);
2267 InheritException(exception,&(*image)->exception);
2270 if (LocaleCompare("preview",option+1) == 0)
2278 (void) SyncImageSettings(mogrify_info,*image);
2280 preview_type=UndefinedPreview;
2282 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
2283 MagickFalse,argv[i+1]);
2284 mogrify_image=PreviewImage(*image,preview_type,exception);
2287 if (LocaleCompare("profile",option+1) == 0)
2301 (void) SyncImageSettings(mogrify_info,*image);
2305 Remove a profile from the image.
2307 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2309 InheritException(exception,&(*image)->exception);
2313 Associate a profile with the image.
2315 profile_info=CloneImageInfo(mogrify_info);
2316 profile=GetImageProfile(*image,"iptc");
2317 if (profile != (StringInfo *) NULL)
2318 profile_info->profile=(void *) CloneStringInfo(profile);
2319 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2320 profile_info=DestroyImageInfo(profile_info);
2321 if (profile_image == (Image *) NULL)
2326 profile_info=CloneImageInfo(mogrify_info);
2327 (void) CopyMagickString(profile_info->filename,argv[i+1],
2329 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2330 if (profile != (StringInfo *) NULL)
2332 (void) ProfileImage(*image,profile_info->magick,
2333 GetStringInfoDatum(profile),(size_t)
2334 GetStringInfoLength(profile),MagickFalse);
2335 profile=DestroyStringInfo(profile);
2337 profile_info=DestroyImageInfo(profile_info);
2340 ResetImageProfileIterator(profile_image);
2341 name=GetNextImageProfile(profile_image);
2342 while (name != (const char *) NULL)
2344 profile=GetImageProfile(profile_image,name);
2345 if (profile != (StringInfo *) NULL)
2346 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2347 (size_t) GetStringInfoLength(profile),MagickFalse);
2348 name=GetNextImageProfile(profile_image);
2350 profile_image=DestroyImage(profile_image);
2357 if (LocaleCompare("quantize",option+1) == 0)
2361 quantize_info->colorspace=UndefinedColorspace;
2364 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2365 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2372 if (LocaleCompare("radial-blur",option+1) == 0)
2377 (void) SyncImageSettings(mogrify_info,*image);
2378 mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1],
2379 (char **) NULL),exception);
2382 if (LocaleCompare("raise",option+1) == 0)
2385 Surround image with a raise of solid color.
2387 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2388 if ((flags & SigmaValue) == 0)
2389 geometry.height=geometry.width;
2390 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2392 InheritException(exception,&(*image)->exception);
2395 if (LocaleCompare("random-threshold",option+1) == 0)
2400 (void) SyncImageSettings(mogrify_info,*image);
2401 (void) RandomThresholdImage(*image,argv[i+1],exception);
2404 if (LocaleCompare("recolor",option+1) == 0)
2409 (void) SyncImageSettings(mogrify_info,*image);
2410 kernel=AcquireKernelInfo(argv[i+1]);
2411 if (kernel == (KernelInfo *) NULL)
2413 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2414 kernel=DestroyKernelInfo(kernel);
2417 if (LocaleCompare("region",option+1) == 0)
2419 (void) SyncImageSettings(mogrify_info,*image);
2420 if (region_image != (Image *) NULL)
2425 (void) CompositeImage(region_image,region_image->matte !=
2426 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2427 region_geometry.x,region_geometry.y);
2428 InheritException(exception,®ion_image->exception);
2429 *image=DestroyImage(*image);
2430 *image=region_image;
2431 region_image = (Image *) NULL;
2436 Apply transformations to a selected region of the image.
2438 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2440 mogrify_image=CropImage(*image,®ion_geometry,exception);
2441 if (mogrify_image == (Image *) NULL)
2443 region_image=(*image);
2444 *image=mogrify_image;
2445 mogrify_image=(Image *) NULL;
2448 if (LocaleCompare("render",option+1) == 0)
2450 (void) SyncImageSettings(mogrify_info,*image);
2451 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2454 if (LocaleCompare("remap",option+1) == 0)
2460 Transform image colors to match this set of colors.
2462 (void) SyncImageSettings(mogrify_info,*image);
2465 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2466 if (remap_image == (Image *) NULL)
2468 (void) RemapImage(quantize_info,*image,remap_image);
2469 InheritException(exception,&(*image)->exception);
2470 remap_image=DestroyImage(remap_image);
2473 if (LocaleCompare("repage",option+1) == 0)
2477 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2480 (void) ResetImagePage(*image,argv[i+1]);
2481 InheritException(exception,&(*image)->exception);
2484 if (LocaleCompare("resample",option+1) == 0)
2489 (void) SyncImageSettings(mogrify_info,*image);
2490 flags=ParseGeometry(argv[i+1],&geometry_info);
2491 if ((flags & SigmaValue) == 0)
2492 geometry_info.sigma=geometry_info.rho;
2493 mogrify_image=ResampleImage(*image,geometry_info.rho,
2494 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2497 if (LocaleCompare("resize",option+1) == 0)
2502 (void) SyncImageSettings(mogrify_info,*image);
2503 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2504 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2505 (*image)->filter,(*image)->blur,exception);
2508 if (LocaleCompare("roll",option+1) == 0)
2513 (void) SyncImageSettings(mogrify_info,*image);
2514 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2515 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2518 if (LocaleCompare("rotate",option+1) == 0)
2524 Check for conditional image rotation.
2526 (void) SyncImageSettings(mogrify_info,*image);
2527 if (strchr(argv[i+1],'>') != (char *) NULL)
2528 if ((*image)->columns <= (*image)->rows)
2530 if (strchr(argv[i+1],'<') != (char *) NULL)
2531 if ((*image)->columns >= (*image)->rows)
2536 geometry=ConstantString(argv[i+1]);
2537 (void) SubstituteString(&geometry,">","");
2538 (void) SubstituteString(&geometry,"<","");
2539 (void) ParseGeometry(geometry,&geometry_info);
2540 geometry=DestroyString(geometry);
2541 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2548 if (LocaleCompare("sample",option+1) == 0)
2551 Sample image with pixel replication.
2553 (void) SyncImageSettings(mogrify_info,*image);
2554 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2555 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2559 if (LocaleCompare("scale",option+1) == 0)
2564 (void) SyncImageSettings(mogrify_info,*image);
2565 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2566 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2570 if (LocaleCompare("selective-blur",option+1) == 0)
2573 Selectively blur pixels within a contrast threshold.
2575 (void) SyncImageSettings(mogrify_info,*image);
2576 flags=ParseGeometry(argv[i+1],&geometry_info);
2577 if ((flags & PercentValue) != 0)
2578 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2579 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2580 geometry_info.sigma,geometry_info.xi,exception);
2583 if (LocaleCompare("separate",option+1) == 0)
2586 Break channels into separate images.
2588 (void) SyncImageSettings(mogrify_info,*image);
2589 mogrify_image=SeparateImages(*image,exception);
2592 if (LocaleCompare("sepia-tone",option+1) == 0)
2600 (void) SyncImageSettings(mogrify_info,*image);
2601 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2602 mogrify_image=SepiaToneImage(*image,threshold,exception);
2605 if (LocaleCompare("segment",option+1) == 0)
2610 (void) SyncImageSettings(mogrify_info,*image);
2611 flags=ParseGeometry(argv[i+1],&geometry_info);
2612 if ((flags & SigmaValue) == 0)
2613 geometry_info.sigma=1.0;
2614 (void) SegmentImage(*image,(*image)->colorspace,
2615 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2616 InheritException(exception,&(*image)->exception);
2619 if (LocaleCompare("set",option+1) == 0)
2629 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2630 (void) DeleteImageRegistry(argv[i+1]+9);
2632 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2634 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2635 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2638 (void) DeleteImageProperty(*image,argv[i+1]);
2641 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2642 if (value == (char *) NULL)
2644 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2645 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2648 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2650 (void) SetImageOption(image_info,argv[i+1]+7,value);
2651 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2652 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2655 (void) SetImageProperty(*image,argv[i+1],value);
2656 value=DestroyString(value);
2659 if (LocaleCompare("shade",option+1) == 0)
2664 (void) SyncImageSettings(mogrify_info,*image);
2665 flags=ParseGeometry(argv[i+1],&geometry_info);
2666 if ((flags & SigmaValue) == 0)
2667 geometry_info.sigma=1.0;
2668 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2669 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2672 if (LocaleCompare("shadow",option+1) == 0)
2677 (void) SyncImageSettings(mogrify_info,*image);
2678 flags=ParseGeometry(argv[i+1],&geometry_info);
2679 if ((flags & SigmaValue) == 0)
2680 geometry_info.sigma=1.0;
2681 if ((flags & XiValue) == 0)
2682 geometry_info.xi=4.0;
2683 if ((flags & PsiValue) == 0)
2684 geometry_info.psi=4.0;
2685 mogrify_image=ShadowImage(*image,geometry_info.rho,
2686 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2687 ceil(geometry_info.psi-0.5),exception);
2690 if (LocaleCompare("sharpen",option+1) == 0)
2695 (void) SyncImageSettings(mogrify_info,*image);
2696 flags=ParseGeometry(argv[i+1],&geometry_info);
2697 if ((flags & SigmaValue) == 0)
2698 geometry_info.sigma=1.0;
2699 mogrify_image=SharpenImage(*image,geometry_info.rho,
2700 geometry_info.sigma,exception);
2703 if (LocaleCompare("shave",option+1) == 0)
2706 Shave the image edges.
2708 (void) SyncImageSettings(mogrify_info,*image);
2709 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2710 mogrify_image=ShaveImage(*image,&geometry,exception);
2713 if (LocaleCompare("shear",option+1) == 0)
2718 (void) SyncImageSettings(mogrify_info,*image);
2719 flags=ParseGeometry(argv[i+1],&geometry_info);
2720 if ((flags & SigmaValue) == 0)
2721 geometry_info.sigma=geometry_info.rho;
2722 mogrify_image=ShearImage(*image,geometry_info.rho,
2723 geometry_info.sigma,exception);
2726 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2729 Sigmoidal non-linearity contrast control.
2731 (void) SyncImageSettings(mogrify_info,*image);
2732 flags=ParseGeometry(argv[i+1],&geometry_info);
2733 if ((flags & SigmaValue) == 0)
2734 geometry_info.sigma=(double) QuantumRange/2.0;
2735 if ((flags & PercentValue) != 0)
2736 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2738 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2739 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma);
2740 InheritException(exception,&(*image)->exception);
2743 if (LocaleCompare("sketch",option+1) == 0)
2748 (void) SyncImageSettings(mogrify_info,*image);
2749 flags=ParseGeometry(argv[i+1],&geometry_info);
2750 if ((flags & SigmaValue) == 0)
2751 geometry_info.sigma=1.0;
2752 mogrify_image=SketchImage(*image,geometry_info.rho,
2753 geometry_info.sigma,geometry_info.xi,exception);
2756 if (LocaleCompare("solarize",option+1) == 0)
2761 (void) SyncImageSettings(mogrify_info,*image);
2762 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2763 (void) SolarizeImage(*image,threshold);
2764 InheritException(exception,&(*image)->exception);
2767 if (LocaleCompare("sparse-color",option+1) == 0)
2776 Sparse Color Interpolated Gradient
2778 (void) SyncImageSettings(mogrify_info,*image);
2779 method=(SparseColorMethod) ParseCommandOption(
2780 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2781 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2782 InheritException(exception,&(*image)->exception);
2783 if (arguments == (char *) NULL)
2785 mogrify_image=SparseColorOption(*image,method,arguments,
2786 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2787 arguments=DestroyString(arguments);
2790 if (LocaleCompare("splice",option+1) == 0)
2793 Splice a solid color into the image.
2795 (void) SyncImageSettings(mogrify_info,*image);
2796 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2797 mogrify_image=SpliceImage(*image,&geometry,exception);
2800 if (LocaleCompare("spread",option+1) == 0)
2805 (void) SyncImageSettings(mogrify_info,*image);
2806 (void) ParseGeometry(argv[i+1],&geometry_info);
2807 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2810 if (LocaleCompare("statistic",option+1) == 0)
2815 (void) SyncImageSettings(mogrify_info,*image);
2816 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2817 MagickFalse,argv[i+1]);
2818 (void) ParseGeometry(argv[i+2],&geometry_info);
2819 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2820 (size_t) geometry_info.sigma,exception);
2823 if (LocaleCompare("stretch",option+1) == 0)
2827 draw_info->stretch=UndefinedStretch;
2830 draw_info->stretch=(StretchType) ParseCommandOption(
2831 MagickStretchOptions,MagickFalse,argv[i+1]);
2834 if (LocaleCompare("strip",option+1) == 0)
2837 Strip image of profiles and comments.
2839 (void) SyncImageSettings(mogrify_info,*image);
2840 (void) StripImage(*image);
2841 InheritException(exception,&(*image)->exception);
2844 if (LocaleCompare("stroke",option+1) == 0)
2851 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2852 if (draw_info->stroke_pattern != (Image *) NULL)
2853 draw_info->stroke_pattern=DestroyImage(
2854 draw_info->stroke_pattern);
2857 sans=AcquireExceptionInfo();
2858 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2859 sans=DestroyExceptionInfo(sans);
2860 if (status == MagickFalse)
2861 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2865 if (LocaleCompare("strokewidth",option+1) == 0)
2867 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2871 if (LocaleCompare("style",option+1) == 0)
2875 draw_info->style=UndefinedStyle;
2878 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2879 MagickFalse,argv[i+1]);
2882 if (LocaleCompare("swirl",option+1) == 0)
2887 (void) SyncImageSettings(mogrify_info,*image);
2888 (void) ParseGeometry(argv[i+1],&geometry_info);
2889 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
2896 if (LocaleCompare("threshold",option+1) == 0)
2904 (void) SyncImageSettings(mogrify_info,*image);
2906 threshold=(double) QuantumRange/2;
2908 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2909 (void) BilevelImage(*image,threshold);
2910 InheritException(exception,&(*image)->exception);
2913 if (LocaleCompare("thumbnail",option+1) == 0)
2918 (void) SyncImageSettings(mogrify_info,*image);
2919 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2920 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2924 if (LocaleCompare("tile",option+1) == 0)
2928 if (draw_info->fill_pattern != (Image *) NULL)
2929 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2932 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2936 if (LocaleCompare("tint",option+1) == 0)
2941 (void) SyncImageSettings(mogrify_info,*image);
2942 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
2945 if (LocaleCompare("transform",option+1) == 0)
2948 Affine transform image.
2950 (void) SyncImageSettings(mogrify_info,*image);
2951 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2955 if (LocaleCompare("transparent",option+1) == 0)
2960 (void) SyncImageSettings(mogrify_info,*image);
2961 (void) QueryMagickColor(argv[i+1],&target,exception);
2962 (void) TransparentPaintImage(*image,&target,(Quantum)
2963 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue);
2964 InheritException(exception,&(*image)->exception);
2967 if (LocaleCompare("transpose",option+1) == 0)
2970 Transpose image scanlines.
2972 (void) SyncImageSettings(mogrify_info,*image);
2973 mogrify_image=TransposeImage(*image,exception);
2976 if (LocaleCompare("transverse",option+1) == 0)
2979 Transverse image scanlines.
2981 (void) SyncImageSettings(mogrify_info,*image);
2982 mogrify_image=TransverseImage(*image,exception);
2985 if (LocaleCompare("treedepth",option+1) == 0)
2987 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
2990 if (LocaleCompare("trim",option+1) == 0)
2995 (void) SyncImageSettings(mogrify_info,*image);
2996 mogrify_image=TrimImage(*image,exception);
2999 if (LocaleCompare("type",option+1) == 0)
3004 (void) SyncImageSettings(mogrify_info,*image);
3008 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3010 (*image)->type=UndefinedType;
3011 (void) SetImageType(*image,type);
3012 InheritException(exception,&(*image)->exception);
3019 if (LocaleCompare("undercolor",option+1) == 0)
3021 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3025 if (LocaleCompare("unique",option+1) == 0)
3029 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3032 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3033 (void) SetImageArtifact(*image,"verbose","true");
3036 if (LocaleCompare("unique-colors",option+1) == 0)
3039 Unique image colors.
3041 (void) SyncImageSettings(mogrify_info,*image);
3042 mogrify_image=UniqueImageColors(*image,exception);
3045 if (LocaleCompare("unsharp",option+1) == 0)
3050 (void) SyncImageSettings(mogrify_info,*image);
3051 flags=ParseGeometry(argv[i+1],&geometry_info);
3052 if ((flags & SigmaValue) == 0)
3053 geometry_info.sigma=1.0;
3054 if ((flags & XiValue) == 0)
3055 geometry_info.xi=1.0;
3056 if ((flags & PsiValue) == 0)
3057 geometry_info.psi=0.05;
3058 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3059 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3066 if (LocaleCompare("verbose",option+1) == 0)
3068 (void) SetImageArtifact(*image,option+1,
3069 *option == '+' ? "false" : "true");
3072 if (LocaleCompare("vignette",option+1) == 0)
3077 (void) SyncImageSettings(mogrify_info,*image);
3078 flags=ParseGeometry(argv[i+1],&geometry_info);
3079 if ((flags & SigmaValue) == 0)
3080 geometry_info.sigma=1.0;
3081 if ((flags & XiValue) == 0)
3082 geometry_info.xi=0.1*(*image)->columns;
3083 if ((flags & PsiValue) == 0)
3084 geometry_info.psi=0.1*(*image)->rows;
3085 mogrify_image=VignetteImage(*image,geometry_info.rho,
3086 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3087 ceil(geometry_info.psi-0.5),exception);
3090 if (LocaleCompare("virtual-pixel",option+1) == 0)
3094 (void) SetImageVirtualPixelMethod(*image,
3095 UndefinedVirtualPixelMethod);
3098 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3099 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3107 if (LocaleCompare("wave",option+1) == 0)
3112 (void) SyncImageSettings(mogrify_info,*image);
3113 flags=ParseGeometry(argv[i+1],&geometry_info);
3114 if ((flags & SigmaValue) == 0)
3115 geometry_info.sigma=1.0;
3116 mogrify_image=WaveImage(*image,geometry_info.rho,
3117 geometry_info.sigma,exception);
3120 if (LocaleCompare("weight",option+1) == 0)
3122 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3123 if (LocaleCompare(argv[i+1],"all") == 0)
3124 draw_info->weight=0;
3125 if (LocaleCompare(argv[i+1],"bold") == 0)
3126 draw_info->weight=700;
3127 if (LocaleCompare(argv[i+1],"bolder") == 0)
3128 if (draw_info->weight <= 800)
3129 draw_info->weight+=100;
3130 if (LocaleCompare(argv[i+1],"lighter") == 0)
3131 if (draw_info->weight >= 100)
3132 draw_info->weight-=100;
3133 if (LocaleCompare(argv[i+1],"normal") == 0)
3134 draw_info->weight=400;
3137 if (LocaleCompare("white-threshold",option+1) == 0)
3140 White threshold image.
3142 (void) SyncImageSettings(mogrify_info,*image);
3143 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3144 InheritException(exception,&(*image)->exception);
3153 Replace current image with any image that was generated
3155 if (mogrify_image != (Image *) NULL)
3156 ReplaceImageInListReturnLast(image,mogrify_image);
3159 if (region_image != (Image *) NULL)
3162 Composite transformed region onto image.
3164 (void) SyncImageSettings(mogrify_info,*image);
3165 (void) CompositeImage(region_image,region_image->matte !=
3166 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3167 region_geometry.x,region_geometry.y);
3168 InheritException(exception,®ion_image->exception);
3169 *image=DestroyImage(*image);
3170 *image=region_image;
3171 region_image = (Image *) NULL;
3176 quantize_info=DestroyQuantizeInfo(quantize_info);
3177 draw_info=DestroyDrawInfo(draw_info);
3178 mogrify_info=DestroyImageInfo(mogrify_info);
3179 status=(MagickStatusType) ((*image)->exception.severity ==
3180 UndefinedException ? 1 : 0);
3181 return(status == 0 ? MagickFalse : MagickTrue);
3185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3189 + M o g r i f y I m a g e C o m m a n d %
3193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3195 % MogrifyImageCommand() transforms an image or a sequence of images. These
3196 % transforms include image scaling, image rotation, color reduction, and
3197 % others. The transmogrified image overwrites the original image.
3199 % The format of the MogrifyImageCommand method is:
3201 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3202 % const char **argv,char **metadata,ExceptionInfo *exception)
3204 % A description of each parameter follows:
3206 % o image_info: the image info.
3208 % o argc: the number of elements in the argument vector.
3210 % o argv: A text array containing the command line arguments.
3212 % o metadata: any metadata is returned here.
3214 % o exception: return any errors or warnings in this structure.
3218 static MagickBooleanType MogrifyUsage(void)
3223 "-debug events display copious debugging information",
3224 "-help print program options",
3225 "-list type print a list of supported option arguments",
3226 "-log format format of debugging information",
3227 "-version print version information",
3232 "-adaptive-blur geometry",
3233 " adaptively blur pixels; decrease effect near edges",
3234 "-adaptive-resize geometry",
3235 " adaptively resize image using 'mesh' interpolation",
3236 "-adaptive-sharpen geometry",
3237 " adaptively sharpen pixels; increase effect near edges",
3238 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3239 " transparent, extract, background, or shape",
3240 "-annotate geometry text",
3241 " annotate the image with text",
3242 "-auto-gamma automagically adjust gamma level of image",
3243 "-auto-level automagically adjust color levels of image",
3244 "-auto-orient automagically orient (rotate) image",
3245 "-bench iterations measure performance",
3246 "-black-threshold value",
3247 " force all pixels below the threshold into black",
3248 "-blue-shift simulate a scene at nighttime in the moonlight",
3249 "-blur geometry reduce image noise and reduce detail levels",
3250 "-border geometry surround image with a border of color",
3251 "-bordercolor color border color",
3252 "-brightness-contrast geometry",
3253 " improve brightness / contrast of the image",
3254 "-cdl filename color correct with a color decision list",
3255 "-charcoal radius simulate a charcoal drawing",
3256 "-chop geometry remove pixels from the image interior",
3257 "-clamp restrict pixel range from 0 to the quantum depth",
3258 "-clip clip along the first path from the 8BIM profile",
3259 "-clip-mask filename associate a clip mask with the image",
3260 "-clip-path id clip along a named path from the 8BIM profile",
3261 "-colorize value colorize the image with the fill color",
3262 "-color-matrix matrix apply color correction to the image",
3263 "-contrast enhance or reduce the image contrast",
3264 "-contrast-stretch geometry",
3265 " improve contrast by `stretching' the intensity range",
3266 "-convolve coefficients",
3267 " apply a convolution kernel to the image",
3268 "-cycle amount cycle the image colormap",
3269 "-decipher filename convert cipher pixels to plain pixels",
3270 "-deskew threshold straighten an image",
3271 "-despeckle reduce the speckles within an image",
3272 "-distort method args",
3273 " distort images according to given method ad args",
3274 "-draw string annotate the image with a graphic primitive",
3275 "-edge radius apply a filter to detect edges in the image",
3276 "-encipher filename convert plain pixels to cipher pixels",
3277 "-emboss radius emboss an image",
3278 "-enhance apply a digital filter to enhance a noisy image",
3279 "-equalize perform histogram equalization to an image",
3280 "-evaluate operator value",
3281 " evaluate an arithmetic, relational, or logical expression",
3282 "-extent geometry set the image size",
3283 "-extract geometry extract area from image",
3284 "-fft implements the discrete Fourier transform (DFT)",
3285 "-flip flip image vertically",
3286 "-floodfill geometry color",
3287 " floodfill the image with color",
3288 "-flop flop image horizontally",
3289 "-frame geometry surround image with an ornamental border",
3290 "-function name parameters",
3291 " apply function over image values",
3292 "-gamma value level of gamma correction",
3293 "-gaussian-blur geometry",
3294 " reduce image noise and reduce detail levels",
3295 "-geometry geometry preferred size or location of the image",
3296 "-identify identify the format and characteristics of the image",
3297 "-ift implements the inverse discrete Fourier transform (DFT)",
3298 "-implode amount implode image pixels about the center",
3299 "-lat geometry local adaptive thresholding",
3300 "-layers method optimize, merge, or compare image layers",
3301 "-level value adjust the level of image contrast",
3302 "-level-colors color,color",
3303 " level image with the given colors",
3304 "-linear-stretch geometry",
3305 " improve contrast by `stretching with saturation'",
3306 "-liquid-rescale geometry",
3307 " rescale image with seam-carving",
3308 "-median geometry apply a median filter to the image",
3309 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3310 "-modulate value vary the brightness, saturation, and hue",
3311 "-monochrome transform image to black and white",
3312 "-morphology method kernel",
3313 " apply a morphology method to the image",
3314 "-motion-blur geometry",
3315 " simulate motion blur",
3316 "-negate replace every pixel with its complementary color ",
3317 "-noise geometry add or reduce noise in an image",
3318 "-normalize transform image to span the full range of colors",
3319 "-opaque color change this color to the fill color",
3320 "-ordered-dither NxN",
3321 " add a noise pattern to the image with specific",
3323 "-paint radius simulate an oil painting",
3324 "-polaroid angle simulate a Polaroid picture",
3325 "-posterize levels reduce the image to a limited number of color levels",
3326 "-profile filename add, delete, or apply an image profile",
3327 "-quantize colorspace reduce colors in this colorspace",
3328 "-radial-blur angle radial blur the image",
3329 "-raise value lighten/darken image edges to create a 3-D effect",
3330 "-random-threshold low,high",
3331 " random threshold the image",
3332 "-region geometry apply options to a portion of the image",
3333 "-render render vector graphics",
3334 "-repage geometry size and location of an image canvas",
3335 "-resample geometry change the resolution of an image",
3336 "-resize geometry resize the image",
3337 "-roll geometry roll an image vertically or horizontally",
3338 "-rotate degrees apply Paeth rotation to the image",
3339 "-sample geometry scale image with pixel sampling",
3340 "-scale geometry scale the image",
3341 "-segment values segment an image",
3342 "-selective-blur geometry",
3343 " selectively blur pixels within a contrast threshold",
3344 "-sepia-tone threshold",
3345 " simulate a sepia-toned photo",
3346 "-set property value set an image property",
3347 "-shade degrees shade the image using a distant light source",
3348 "-shadow geometry simulate an image shadow",
3349 "-sharpen geometry sharpen the image",
3350 "-shave geometry shave pixels from the image edges",
3351 "-shear geometry slide one edge of the image along the X or Y axis",
3352 "-sigmoidal-contrast geometry",
3353 " increase the contrast without saturating highlights or shadows",
3354 "-sketch geometry simulate a pencil sketch",
3355 "-solarize threshold negate all pixels above the threshold level",
3356 "-sparse-color method args",
3357 " fill in a image based on a few color points",
3358 "-splice geometry splice the background color into the image",
3359 "-spread radius displace image pixels by a random amount",
3360 "-statistic type radius",
3361 " replace each pixel with corresponding statistic from the neighborhood",
3362 "-strip strip image of all profiles and comments",
3363 "-swirl degrees swirl image pixels about the center",
3364 "-threshold value threshold the image",
3365 "-thumbnail geometry create a thumbnail of the image",
3366 "-tile filename tile image when filling a graphic primitive",
3367 "-tint value tint the image with the fill color",
3368 "-transform affine transform image",
3369 "-transparent color make this color transparent within the image",
3370 "-transpose flip image vertically and rotate 90 degrees",
3371 "-transverse flop image horizontally and rotate 270 degrees",
3372 "-trim trim image edges",
3373 "-type type image type",
3374 "-unique-colors discard all but one of any pixel color",
3375 "-unsharp geometry sharpen the image",
3376 "-vignette geometry soften the edges of the image in vignette style",
3377 "-wave geometry alter an image along a sine wave",
3378 "-white-threshold value",
3379 " force all pixels above the threshold into white",
3382 *sequence_operators[]=
3384 "-append append an image sequence",
3385 "-clut apply a color lookup table to the image",
3386 "-coalesce merge a sequence of images",
3387 "-combine combine a sequence of images",
3388 "-composite composite image",
3389 "-crop geometry cut out a rectangular region of the image",
3390 "-deconstruct break down an image sequence into constituent parts",
3391 "-evaluate-sequence operator",
3392 " evaluate an arithmetic, relational, or logical expression",
3393 "-flatten flatten a sequence of images",
3394 "-fx expression apply mathematical expression to an image channel(s)",
3395 "-hald-clut apply a Hald color lookup table to the image",
3396 "-morph value morph an image sequence",
3397 "-mosaic create a mosaic from an image sequence",
3398 "-print string interpret string and print to console",
3399 "-process arguments process the image with a custom image filter",
3400 "-separate separate an image channel into a grayscale image",
3401 "-smush geometry smush an image sequence together",
3402 "-write filename write images to this file",
3407 "-adjoin join images into a single multi-image file",
3408 "-affine matrix affine transform matrix",
3409 "-alpha option activate, deactivate, reset, or set the alpha channel",
3410 "-antialias remove pixel-aliasing",
3411 "-authenticate password",
3412 " decipher image with this password",
3413 "-attenuate value lessen (or intensify) when adding noise to an image",
3414 "-background color background color",
3415 "-bias value add bias when convolving an image",
3416 "-black-point-compensation",
3417 " use black point compensation",
3418 "-blue-primary point chromaticity blue primary point",
3419 "-bordercolor color border color",
3420 "-caption string assign a caption to an image",
3421 "-channel type apply option to select image channels",
3422 "-colors value preferred number of colors in the image",
3423 "-colorspace type alternate image colorspace",
3424 "-comment string annotate image with comment",
3425 "-compose operator set image composite operator",
3426 "-compress type type of pixel compression when writing the image",
3427 "-define format:option",
3428 " define one or more image format options",
3429 "-delay value display the next image after pausing",
3430 "-density geometry horizontal and vertical density of the image",
3431 "-depth value image depth",
3432 "-direction type render text right-to-left or left-to-right",
3433 "-display server get image or font from this X server",
3434 "-dispose method layer disposal method",
3435 "-dither method apply error diffusion to image",
3436 "-encoding type text encoding type",
3437 "-endian type endianness (MSB or LSB) of the image",
3438 "-family name render text with this font family",
3439 "-fill color color to use when filling a graphic primitive",
3440 "-filter type use this filter when resizing an image",
3441 "-font name render text with this font",
3442 "-format \"string\" output formatted image characteristics",
3443 "-fuzz distance colors within this distance are considered equal",
3444 "-gravity type horizontal and vertical text placement",
3445 "-green-primary point chromaticity green primary point",
3446 "-intent type type of rendering intent when managing the image color",
3447 "-interlace type type of image interlacing scheme",
3448 "-interline-spacing value",
3449 " set the space between two text lines",
3450 "-interpolate method pixel color interpolation method",
3451 "-interword-spacing value",
3452 " set the space between two words",
3453 "-kerning value set the space between two letters",
3454 "-label string assign a label to an image",
3455 "-limit type value pixel cache resource limit",
3456 "-loop iterations add Netscape loop extension to your GIF animation",
3457 "-mask filename associate a mask with the image",
3458 "-mattecolor color frame color",
3459 "-monitor monitor progress",
3460 "-orient type image orientation",
3461 "-page geometry size and location of an image canvas (setting)",
3462 "-ping efficiently determine image attributes",
3463 "-pointsize value font point size",
3464 "-precision value maximum number of significant digits to print",
3465 "-preview type image preview type",
3466 "-quality value JPEG/MIFF/PNG compression level",
3467 "-quiet suppress all warning messages",
3468 "-red-primary point chromaticity red primary point",
3469 "-regard-warnings pay attention to warning messages",
3470 "-remap filename transform image colors to match this set of colors",
3471 "-respect-parentheses settings remain in effect until parenthesis boundary",
3472 "-sampling-factor geometry",
3473 " horizontal and vertical sampling factor",
3474 "-scene value image scene number",
3475 "-seed value seed a new sequence of pseudo-random numbers",
3476 "-size geometry width and height of image",
3477 "-stretch type render text with this font stretch",
3478 "-stroke color graphic primitive stroke color",
3479 "-strokewidth value graphic primitive stroke width",
3480 "-style type render text with this font style",
3481 "-synchronize synchronize image to storage device",
3482 "-taint declare the image as modified",
3483 "-texture filename name of texture to tile onto the image background",
3484 "-tile-offset geometry",
3486 "-treedepth value color tree depth",
3487 "-transparent-color color",
3488 " transparent color",
3489 "-undercolor color annotation bounding box color",
3490 "-units type the units of image resolution",
3491 "-verbose print detailed information about the image",
3492 "-view FlashPix viewing transforms",
3493 "-virtual-pixel method",
3494 " virtual pixel access method",
3495 "-weight type render text with this font weight",
3496 "-white-point point chromaticity white point",
3501 "-delete indexes delete the image from the image sequence",
3502 "-duplicate count,indexes",
3503 " duplicate an image one or more times",
3504 "-insert index insert last image into the image sequence",
3505 "-reverse reverse image sequence",
3506 "-swap indexes swap two images in the image sequence",
3513 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3514 (void) printf("Copyright: %s\n",GetMagickCopyright());
3515 (void) printf("Features: %s\n\n",GetMagickFeatures());
3516 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3518 (void) printf("\nImage Settings:\n");
3519 for (p=settings; *p != (char *) NULL; p++)
3520 (void) printf(" %s\n",*p);
3521 (void) printf("\nImage Operators:\n");
3522 for (p=operators; *p != (char *) NULL; p++)
3523 (void) printf(" %s\n",*p);
3524 (void) printf("\nImage Sequence Operators:\n");
3525 for (p=sequence_operators; *p != (char *) NULL; p++)
3526 (void) printf(" %s\n",*p);
3527 (void) printf("\nImage Stack Operators:\n");
3528 for (p=stack_operators; *p != (char *) NULL; p++)
3529 (void) printf(" %s\n",*p);
3530 (void) printf("\nMiscellaneous Options:\n");
3531 for (p=miscellaneous; *p != (char *) NULL; p++)
3532 (void) printf(" %s\n",*p);
3534 "\nBy default, the image format of `file' is determined by its magic\n");
3536 "number. To specify a particular image format, precede the filename\n");
3538 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3540 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3541 (void) printf("'-' for standard input or output.\n");
3542 return(MagickFalse);
3545 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3546 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3548 #define DestroyMogrify() \
3550 if (format != (char *) NULL) \
3551 format=DestroyString(format); \
3552 if (path != (char *) NULL) \
3553 path=DestroyString(path); \
3554 DestroyImageStack(); \
3555 for (i=0; i < (ssize_t) argc; i++) \
3556 argv[i]=DestroyString(argv[i]); \
3557 argv=(char **) RelinquishMagickMemory(argv); \
3559 #define ThrowMogrifyException(asperity,tag,option) \
3561 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3564 return(MagickFalse); \
3566 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3568 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3569 "InvalidArgument","`%s': %s",argument,option); \
3571 return(MagickFalse); \
3583 image_stack[MaxImageStackDepth+1];
3591 respect_parenthesis;
3606 assert(image_info != (ImageInfo *) NULL);
3607 assert(image_info->signature == MagickSignature);
3608 if (image_info->debug != MagickFalse)
3609 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3610 assert(exception != (ExceptionInfo *) NULL);
3614 if ((LocaleCompare("version",option+1) == 0) ||
3615 (LocaleCompare("-version",option+1) == 0))
3617 (void) FormatLocaleFile(stdout,"Version: %s\n",
3618 GetMagickVersion((size_t *) NULL));
3619 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3620 GetMagickCopyright());
3621 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3622 GetMagickFeatures());
3623 return(MagickFalse);
3627 return(MogrifyUsage());
3628 format=(char *) NULL;
3630 global_colormap=MagickFalse;
3634 option=(char *) NULL;
3636 respect_parenthesis=MagickFalse;
3641 ReadCommandlLine(argc,&argv);
3642 status=ExpandFilenames(&argc,&argv);
3643 if (status == MagickFalse)
3644 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3645 GetExceptionMessage(errno));
3646 for (i=1; i < (ssize_t) argc; i++)
3649 if (LocaleCompare(option,"(") == 0)
3651 FireImageStack(MagickFalse,MagickTrue,pend);
3652 if (k == MaxImageStackDepth)
3653 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3658 if (LocaleCompare(option,")") == 0)
3660 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3662 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3666 if (IsCommandOption(option) == MagickFalse)
3669 backup_filename[MaxTextExtent],
3676 Option is a file name: begin by reading image from specified file.
3678 FireImageStack(MagickFalse,MagickFalse,pend);
3680 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3682 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3683 images=ReadImages(image_info,exception);
3684 status&=(images != (Image *) NULL) &&
3685 (exception->severity < ErrorException);
3686 if (images == (Image *) NULL)
3688 if (format != (char *) NULL)
3689 (void) CopyMagickString(images->filename,images->magick_filename,
3691 if (path != (char *) NULL)
3693 GetPathComponent(option,TailPath,filename);
3694 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3695 path,*DirectorySeparator,filename);
3697 if (format != (char *) NULL)
3698 AppendImageFormat(format,images->filename);
3699 AppendImageStack(images);
3700 FinalizeImageSettings(image_info,image,MagickFalse);
3701 if (global_colormap != MagickFalse)
3706 quantize_info=AcquireQuantizeInfo(image_info);
3707 (void) RemapImages(quantize_info,images,(Image *) NULL);
3708 quantize_info=DestroyQuantizeInfo(quantize_info);
3710 *backup_filename='\0';
3711 if ((LocaleCompare(image->filename,"-") != 0) &&
3712 (IsPathWritable(image->filename) != MagickFalse))
3718 Rename image file as backup.
3720 (void) CopyMagickString(backup_filename,image->filename,
3722 for (i=0; i < 6; i++)
3724 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3725 if (IsPathAccessible(backup_filename) == MagickFalse)
3728 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3729 (rename(image->filename,backup_filename) != 0))
3730 *backup_filename='\0';
3733 Write transmogrified image to disk.
3735 image_info->synchronize=MagickTrue;
3736 status&=WriteImages(image_info,image,image->filename,exception);
3737 if ((status == MagickFalse) && (*backup_filename != '\0'))
3738 (void) remove(backup_filename);
3739 RemoveAllImageStack();
3742 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3743 switch (*(option+1))
3747 if (LocaleCompare("adaptive-blur",option+1) == 0)
3750 if (i == (ssize_t) argc)
3751 ThrowMogrifyException(OptionError,"MissingArgument",option);
3752 if (IsGeometry(argv[i]) == MagickFalse)
3753 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3756 if (LocaleCompare("adaptive-resize",option+1) == 0)
3759 if (i == (ssize_t) argc)
3760 ThrowMogrifyException(OptionError,"MissingArgument",option);
3761 if (IsGeometry(argv[i]) == MagickFalse)
3762 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3765 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3768 if (i == (ssize_t) argc)
3769 ThrowMogrifyException(OptionError,"MissingArgument",option);
3770 if (IsGeometry(argv[i]) == MagickFalse)
3771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3774 if (LocaleCompare("affine",option+1) == 0)
3779 if (i == (ssize_t) argc)
3780 ThrowMogrifyException(OptionError,"MissingArgument",option);
3783 if (LocaleCompare("alpha",option+1) == 0)
3791 if (i == (ssize_t) argc)
3792 ThrowMogrifyException(OptionError,"MissingArgument",option);
3793 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3795 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3799 if (LocaleCompare("annotate",option+1) == 0)
3804 if (i == (ssize_t) argc)
3805 ThrowMogrifyException(OptionError,"MissingArgument",option);
3806 if (IsGeometry(argv[i]) == MagickFalse)
3807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3808 if (i == (ssize_t) argc)
3809 ThrowMogrifyException(OptionError,"MissingArgument",option);
3813 if (LocaleCompare("antialias",option+1) == 0)
3815 if (LocaleCompare("append",option+1) == 0)
3817 if (LocaleCompare("attenuate",option+1) == 0)
3822 if (i == (ssize_t) (argc-1))
3823 ThrowMogrifyException(OptionError,"MissingArgument",option);
3824 if (IsGeometry(argv[i]) == MagickFalse)
3825 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3828 if (LocaleCompare("authenticate",option+1) == 0)
3833 if (i == (ssize_t) argc)
3834 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (LocaleCompare("auto-gamma",option+1) == 0)
3839 if (LocaleCompare("auto-level",option+1) == 0)
3841 if (LocaleCompare("auto-orient",option+1) == 0)
3843 if (LocaleCompare("average",option+1) == 0)
3845 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3849 if (LocaleCompare("background",option+1) == 0)
3854 if (i == (ssize_t) argc)
3855 ThrowMogrifyException(OptionError,"MissingArgument",option);
3858 if (LocaleCompare("bias",option+1) == 0)
3863 if (i == (ssize_t) (argc-1))
3864 ThrowMogrifyException(OptionError,"MissingArgument",option);
3865 if (IsGeometry(argv[i]) == MagickFalse)
3866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3869 if (LocaleCompare("black-point-compensation",option+1) == 0)
3871 if (LocaleCompare("black-threshold",option+1) == 0)
3876 if (i == (ssize_t) argc)
3877 ThrowMogrifyException(OptionError,"MissingArgument",option);
3878 if (IsGeometry(argv[i]) == MagickFalse)
3879 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3882 if (LocaleCompare("blue-primary",option+1) == 0)
3887 if (i == (ssize_t) argc)
3888 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 if (IsGeometry(argv[i]) == MagickFalse)
3890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3893 if (LocaleCompare("blue-shift",option+1) == 0)
3896 if (i == (ssize_t) argc)
3897 ThrowMogrifyException(OptionError,"MissingArgument",option);
3898 if (IsGeometry(argv[i]) == MagickFalse)
3899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3902 if (LocaleCompare("blur",option+1) == 0)
3905 if (i == (ssize_t) argc)
3906 ThrowMogrifyException(OptionError,"MissingArgument",option);
3907 if (IsGeometry(argv[i]) == MagickFalse)
3908 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3911 if (LocaleCompare("border",option+1) == 0)
3916 if (i == (ssize_t) argc)
3917 ThrowMogrifyException(OptionError,"MissingArgument",option);
3918 if (IsGeometry(argv[i]) == MagickFalse)
3919 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3922 if (LocaleCompare("bordercolor",option+1) == 0)
3927 if (i == (ssize_t) argc)
3928 ThrowMogrifyException(OptionError,"MissingArgument",option);
3931 if (LocaleCompare("box",option+1) == 0)
3936 if (i == (ssize_t) argc)
3937 ThrowMogrifyException(OptionError,"MissingArgument",option);
3940 if (LocaleCompare("brightness-contrast",option+1) == 0)
3943 if (i == (ssize_t) argc)
3944 ThrowMogrifyException(OptionError,"MissingArgument",option);
3945 if (IsGeometry(argv[i]) == MagickFalse)
3946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3949 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3953 if (LocaleCompare("cache",option+1) == 0)
3958 if (i == (ssize_t) argc)
3959 ThrowMogrifyException(OptionError,"MissingArgument",option);
3960 if (IsGeometry(argv[i]) == MagickFalse)
3961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3964 if (LocaleCompare("caption",option+1) == 0)
3969 if (i == (ssize_t) argc)
3970 ThrowMogrifyException(OptionError,"MissingArgument",option);
3973 if (LocaleCompare("channel",option+1) == 0)
3981 if (i == (ssize_t) (argc-1))
3982 ThrowMogrifyException(OptionError,"MissingArgument",option);
3983 channel=ParseChannelOption(argv[i]);
3985 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
3989 if (LocaleCompare("cdl",option+1) == 0)
3994 if (i == (ssize_t) (argc-1))
3995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3998 if (LocaleCompare("charcoal",option+1) == 0)
4003 if (i == (ssize_t) argc)
4004 ThrowMogrifyException(OptionError,"MissingArgument",option);
4005 if (IsGeometry(argv[i]) == MagickFalse)
4006 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4009 if (LocaleCompare("chop",option+1) == 0)
4014 if (i == (ssize_t) argc)
4015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4016 if (IsGeometry(argv[i]) == MagickFalse)
4017 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4020 if (LocaleCompare("clamp",option+1) == 0)
4022 if (LocaleCompare("clip",option+1) == 0)
4024 if (LocaleCompare("clip-mask",option+1) == 0)
4029 if (i == (ssize_t) argc)
4030 ThrowMogrifyException(OptionError,"MissingArgument",option);
4033 if (LocaleCompare("clut",option+1) == 0)
4035 if (LocaleCompare("coalesce",option+1) == 0)
4037 if (LocaleCompare("colorize",option+1) == 0)
4042 if (i == (ssize_t) argc)
4043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4044 if (IsGeometry(argv[i]) == MagickFalse)
4045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4048 if (LocaleCompare("color-matrix",option+1) == 0)
4056 if (i == (ssize_t) (argc-1))
4057 ThrowMogrifyException(OptionError,"MissingArgument",option);
4058 kernel_info=AcquireKernelInfo(argv[i]);
4059 if (kernel_info == (KernelInfo *) NULL)
4060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4061 kernel_info=DestroyKernelInfo(kernel_info);
4064 if (LocaleCompare("colors",option+1) == 0)
4069 if (i == (ssize_t) argc)
4070 ThrowMogrifyException(OptionError,"MissingArgument",option);
4071 if (IsGeometry(argv[i]) == MagickFalse)
4072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4075 if (LocaleCompare("colorspace",option+1) == 0)
4083 if (i == (ssize_t) argc)
4084 ThrowMogrifyException(OptionError,"MissingArgument",option);
4085 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4088 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4092 if (LocaleCompare("combine",option+1) == 0)
4094 if (LocaleCompare("comment",option+1) == 0)
4099 if (i == (ssize_t) argc)
4100 ThrowMogrifyException(OptionError,"MissingArgument",option);
4103 if (LocaleCompare("composite",option+1) == 0)
4105 if (LocaleCompare("compress",option+1) == 0)
4113 if (i == (ssize_t) argc)
4114 ThrowMogrifyException(OptionError,"MissingArgument",option);
4115 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4118 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4122 if (LocaleCompare("concurrent",option+1) == 0)
4124 if (LocaleCompare("contrast",option+1) == 0)
4126 if (LocaleCompare("contrast-stretch",option+1) == 0)
4129 if (i == (ssize_t) argc)
4130 ThrowMogrifyException(OptionError,"MissingArgument",option);
4131 if (IsGeometry(argv[i]) == MagickFalse)
4132 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4135 if (LocaleCompare("convolve",option+1) == 0)
4143 if (i == (ssize_t) argc)
4144 ThrowMogrifyException(OptionError,"MissingArgument",option);
4145 kernel_info=AcquireKernelInfo(argv[i]);
4146 if (kernel_info == (KernelInfo *) NULL)
4147 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4148 kernel_info=DestroyKernelInfo(kernel_info);
4151 if (LocaleCompare("crop",option+1) == 0)
4156 if (i == (ssize_t) argc)
4157 ThrowMogrifyException(OptionError,"MissingArgument",option);
4158 if (IsGeometry(argv[i]) == MagickFalse)
4159 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4162 if (LocaleCompare("cycle",option+1) == 0)
4167 if (i == (ssize_t) argc)
4168 ThrowMogrifyException(OptionError,"MissingArgument",option);
4169 if (IsGeometry(argv[i]) == MagickFalse)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4173 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4177 if (LocaleCompare("decipher",option+1) == 0)
4182 if (i == (ssize_t) (argc-1))
4183 ThrowMogrifyException(OptionError,"MissingArgument",option);
4186 if (LocaleCompare("deconstruct",option+1) == 0)
4188 if (LocaleCompare("debug",option+1) == 0)
4196 if (i == (ssize_t) argc)
4197 ThrowMogrifyException(OptionError,"MissingArgument",option);
4198 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4200 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4202 (void) SetLogEventMask(argv[i]);
4205 if (LocaleCompare("define",option+1) == 0)
4208 if (i == (ssize_t) argc)
4209 ThrowMogrifyException(OptionError,"MissingArgument",option);
4215 define=GetImageOption(image_info,argv[i]);
4216 if (define == (const char *) NULL)
4217 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4222 if (LocaleCompare("delay",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4229 if (IsGeometry(argv[i]) == MagickFalse)
4230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4233 if (LocaleCompare("delete",option+1) == 0)
4238 if (i == (ssize_t) (argc-1))
4239 ThrowMogrifyException(OptionError,"MissingArgument",option);
4240 if (IsGeometry(argv[i]) == MagickFalse)
4241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4244 if (LocaleCompare("density",option+1) == 0)
4249 if (i == (ssize_t) argc)
4250 ThrowMogrifyException(OptionError,"MissingArgument",option);
4251 if (IsGeometry(argv[i]) == MagickFalse)
4252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4255 if (LocaleCompare("depth",option+1) == 0)
4260 if (i == (ssize_t) argc)
4261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4262 if (IsGeometry(argv[i]) == MagickFalse)
4263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4266 if (LocaleCompare("deskew",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,"MissingArgument",option);
4273 if (IsGeometry(argv[i]) == MagickFalse)
4274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4277 if (LocaleCompare("despeckle",option+1) == 0)
4279 if (LocaleCompare("dft",option+1) == 0)
4281 if (LocaleCompare("direction",option+1) == 0)
4289 if (i == (ssize_t) argc)
4290 ThrowMogrifyException(OptionError,"MissingArgument",option);
4291 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4294 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4298 if (LocaleCompare("display",option+1) == 0)
4303 if (i == (ssize_t) argc)
4304 ThrowMogrifyException(OptionError,"MissingArgument",option);
4307 if (LocaleCompare("dispose",option+1) == 0)
4315 if (i == (ssize_t) argc)
4316 ThrowMogrifyException(OptionError,"MissingArgument",option);
4317 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4319 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4323 if (LocaleCompare("distort",option+1) == 0)
4329 if (i == (ssize_t) argc)
4330 ThrowMogrifyException(OptionError,"MissingArgument",option);
4331 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4333 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4336 if (i == (ssize_t) (argc-1))
4337 ThrowMogrifyException(OptionError,"MissingArgument",option);
4340 if (LocaleCompare("dither",option+1) == 0)
4348 if (i == (ssize_t) argc)
4349 ThrowMogrifyException(OptionError,"MissingArgument",option);
4350 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4352 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4356 if (LocaleCompare("draw",option+1) == 0)
4361 if (i == (ssize_t) argc)
4362 ThrowMogrifyException(OptionError,"MissingArgument",option);
4365 if (LocaleCompare("duplicate",option+1) == 0)
4370 if (i == (ssize_t) (argc-1))
4371 ThrowMogrifyException(OptionError,"MissingArgument",option);
4372 if (IsGeometry(argv[i]) == MagickFalse)
4373 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4376 if (LocaleCompare("duration",option+1) == 0)
4381 if (i == (ssize_t) (argc-1))
4382 ThrowMogrifyException(OptionError,"MissingArgument",option);
4383 if (IsGeometry(argv[i]) == MagickFalse)
4384 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4387 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4391 if (LocaleCompare("edge",option+1) == 0)
4396 if (i == (ssize_t) argc)
4397 ThrowMogrifyException(OptionError,"MissingArgument",option);
4398 if (IsGeometry(argv[i]) == MagickFalse)
4399 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4402 if (LocaleCompare("emboss",option+1) == 0)
4407 if (i == (ssize_t) argc)
4408 ThrowMogrifyException(OptionError,"MissingArgument",option);
4409 if (IsGeometry(argv[i]) == MagickFalse)
4410 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4413 if (LocaleCompare("encipher",option+1) == 0)
4418 if (i == (ssize_t) argc)
4419 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (LocaleCompare("encoding",option+1) == 0)
4427 if (i == (ssize_t) argc)
4428 ThrowMogrifyException(OptionError,"MissingArgument",option);
4431 if (LocaleCompare("endian",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4441 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4443 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4447 if (LocaleCompare("enhance",option+1) == 0)
4449 if (LocaleCompare("equalize",option+1) == 0)
4451 if (LocaleCompare("evaluate",option+1) == 0)
4459 if (i == (ssize_t) argc)
4460 ThrowMogrifyException(OptionError,"MissingArgument",option);
4461 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4463 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4466 if (i == (ssize_t) (argc-1))
4467 ThrowMogrifyException(OptionError,"MissingArgument",option);
4468 if (IsGeometry(argv[i]) == MagickFalse)
4469 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4472 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4480 if (i == (ssize_t) argc)
4481 ThrowMogrifyException(OptionError,"MissingArgument",option);
4482 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4484 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4488 if (LocaleCompare("extent",option+1) == 0)
4493 if (i == (ssize_t) argc)
4494 ThrowMogrifyException(OptionError,"MissingArgument",option);
4495 if (IsGeometry(argv[i]) == MagickFalse)
4496 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4499 if (LocaleCompare("extract",option+1) == 0)
4504 if (i == (ssize_t) argc)
4505 ThrowMogrifyException(OptionError,"MissingArgument",option);
4506 if (IsGeometry(argv[i]) == MagickFalse)
4507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4510 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4514 if (LocaleCompare("family",option+1) == 0)
4519 if (i == (ssize_t) (argc-1))
4520 ThrowMogrifyException(OptionError,"MissingArgument",option);
4523 if (LocaleCompare("fill",option+1) == 0)
4528 if (i == (ssize_t) argc)
4529 ThrowMogrifyException(OptionError,"MissingArgument",option);
4532 if (LocaleCompare("filter",option+1) == 0)
4540 if (i == (ssize_t) argc)
4541 ThrowMogrifyException(OptionError,"MissingArgument",option);
4542 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4544 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4548 if (LocaleCompare("flatten",option+1) == 0)
4550 if (LocaleCompare("flip",option+1) == 0)
4552 if (LocaleCompare("flop",option+1) == 0)
4554 if (LocaleCompare("floodfill",option+1) == 0)
4559 if (i == (ssize_t) argc)
4560 ThrowMogrifyException(OptionError,"MissingArgument",option);
4561 if (IsGeometry(argv[i]) == MagickFalse)
4562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4564 if (i == (ssize_t) argc)
4565 ThrowMogrifyException(OptionError,"MissingArgument",option);
4568 if (LocaleCompare("font",option+1) == 0)
4573 if (i == (ssize_t) argc)
4574 ThrowMogrifyException(OptionError,"MissingArgument",option);
4577 if (LocaleCompare("format",option+1) == 0)
4579 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4580 (void) CloneString(&format,(char *) NULL);
4584 if (i == (ssize_t) argc)
4585 ThrowMogrifyException(OptionError,"MissingArgument",option);
4586 (void) CloneString(&format,argv[i]);
4587 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4588 (void) ConcatenateMagickString(image_info->filename,":",
4590 (void) SetImageInfo(image_info,0,exception);
4591 if (*image_info->magick == '\0')
4592 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4596 if (LocaleCompare("frame",option+1) == 0)
4601 if (i == (ssize_t) argc)
4602 ThrowMogrifyException(OptionError,"MissingArgument",option);
4603 if (IsGeometry(argv[i]) == MagickFalse)
4604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4607 if (LocaleCompare("function",option+1) == 0)
4615 if (i == (ssize_t) argc)
4616 ThrowMogrifyException(OptionError,"MissingArgument",option);
4617 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4619 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4621 if (i == (ssize_t) (argc-1))
4622 ThrowMogrifyException(OptionError,"MissingArgument",option);
4625 if (LocaleCompare("fuzz",option+1) == 0)
4630 if (i == (ssize_t) argc)
4631 ThrowMogrifyException(OptionError,"MissingArgument",option);
4632 if (IsGeometry(argv[i]) == MagickFalse)
4633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4636 if (LocaleCompare("fx",option+1) == 0)
4641 if (i == (ssize_t) (argc-1))
4642 ThrowMogrifyException(OptionError,"MissingArgument",option);
4645 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4649 if (LocaleCompare("gamma",option+1) == 0)
4652 if (i == (ssize_t) argc)
4653 ThrowMogrifyException(OptionError,"MissingArgument",option);
4654 if (IsGeometry(argv[i]) == MagickFalse)
4655 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4658 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4659 (LocaleCompare("gaussian",option+1) == 0))
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4664 if (IsGeometry(argv[i]) == MagickFalse)
4665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4668 if (LocaleCompare("geometry",option+1) == 0)
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,"MissingArgument",option);
4675 if (IsGeometry(argv[i]) == MagickFalse)
4676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4679 if (LocaleCompare("gravity",option+1) == 0)
4687 if (i == (ssize_t) argc)
4688 ThrowMogrifyException(OptionError,"MissingArgument",option);
4689 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4691 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4695 if (LocaleCompare("green-primary",option+1) == 0)
4700 if (i == (ssize_t) argc)
4701 ThrowMogrifyException(OptionError,"MissingArgument",option);
4702 if (IsGeometry(argv[i]) == MagickFalse)
4703 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4706 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4710 if (LocaleCompare("hald-clut",option+1) == 0)
4712 if ((LocaleCompare("help",option+1) == 0) ||
4713 (LocaleCompare("-help",option+1) == 0))
4714 return(MogrifyUsage());
4715 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4719 if (LocaleCompare("identify",option+1) == 0)
4721 if (LocaleCompare("idft",option+1) == 0)
4723 if (LocaleCompare("implode",option+1) == 0)
4728 if (i == (ssize_t) argc)
4729 ThrowMogrifyException(OptionError,"MissingArgument",option);
4730 if (IsGeometry(argv[i]) == MagickFalse)
4731 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4734 if (LocaleCompare("intent",option+1) == 0)
4742 if (i == (ssize_t) (argc-1))
4743 ThrowMogrifyException(OptionError,"MissingArgument",option);
4744 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4746 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4750 if (LocaleCompare("interlace",option+1) == 0)
4758 if (i == (ssize_t) argc)
4759 ThrowMogrifyException(OptionError,"MissingArgument",option);
4760 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4763 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4767 if (LocaleCompare("interline-spacing",option+1) == 0)
4772 if (i == (ssize_t) (argc-1))
4773 ThrowMogrifyException(OptionError,"MissingArgument",option);
4774 if (IsGeometry(argv[i]) == MagickFalse)
4775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4778 if (LocaleCompare("interpolate",option+1) == 0)
4786 if (i == (ssize_t) argc)
4787 ThrowMogrifyException(OptionError,"MissingArgument",option);
4788 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4790 if (interpolate < 0)
4791 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4795 if (LocaleCompare("interword-spacing",option+1) == 0)
4800 if (i == (ssize_t) (argc-1))
4801 ThrowMogrifyException(OptionError,"MissingArgument",option);
4802 if (IsGeometry(argv[i]) == MagickFalse)
4803 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4806 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4810 if (LocaleCompare("kerning",option+1) == 0)
4815 if (i == (ssize_t) (argc-1))
4816 ThrowMogrifyException(OptionError,"MissingArgument",option);
4817 if (IsGeometry(argv[i]) == MagickFalse)
4818 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4821 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4825 if (LocaleCompare("label",option+1) == 0)
4830 if (i == (ssize_t) argc)
4831 ThrowMogrifyException(OptionError,"MissingArgument",option);
4834 if (LocaleCompare("lat",option+1) == 0)
4839 if (i == (ssize_t) argc)
4840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4844 if (LocaleCompare("layers",option+1) == 0)
4852 if (i == (ssize_t) (argc-1))
4853 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4856 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4860 if (LocaleCompare("level",option+1) == 0)
4863 if (i == (ssize_t) argc)
4864 ThrowMogrifyException(OptionError,"MissingArgument",option);
4865 if (IsGeometry(argv[i]) == MagickFalse)
4866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4869 if (LocaleCompare("level-colors",option+1) == 0)
4872 if (i == (ssize_t) argc)
4873 ThrowMogrifyException(OptionError,"MissingArgument",option);
4876 if (LocaleCompare("linewidth",option+1) == 0)
4881 if (i == (ssize_t) argc)
4882 ThrowMogrifyException(OptionError,"MissingArgument",option);
4883 if (IsGeometry(argv[i]) == MagickFalse)
4884 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4887 if (LocaleCompare("limit",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4903 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4906 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4909 if (i == (ssize_t) argc)
4910 ThrowMogrifyException(OptionError,"MissingArgument",option);
4911 value=InterpretLocaleValue(argv[i],&p);
4913 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4914 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4917 if (LocaleCompare("liquid-rescale",option+1) == 0)
4920 if (i == (ssize_t) argc)
4921 ThrowMogrifyException(OptionError,"MissingArgument",option);
4922 if (IsGeometry(argv[i]) == MagickFalse)
4923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4926 if (LocaleCompare("list",option+1) == 0)
4934 if (i == (ssize_t) argc)
4935 ThrowMogrifyException(OptionError,"MissingArgument",option);
4936 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4938 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4939 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4941 return(status != 0 ? MagickFalse : MagickTrue);
4943 if (LocaleCompare("log",option+1) == 0)
4948 if ((i == (ssize_t) argc) ||
4949 (strchr(argv[i],'%') == (char *) NULL))
4950 ThrowMogrifyException(OptionError,"MissingArgument",option);
4953 if (LocaleCompare("loop",option+1) == 0)
4958 if (i == (ssize_t) argc)
4959 ThrowMogrifyException(OptionError,"MissingArgument",option);
4960 if (IsGeometry(argv[i]) == MagickFalse)
4961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4964 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4968 if (LocaleCompare("map",option+1) == 0)
4970 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4974 if (i == (ssize_t) argc)
4975 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 if (LocaleCompare("mask",option+1) == 0)
4983 if (i == (ssize_t) argc)
4984 ThrowMogrifyException(OptionError,"MissingArgument",option);
4987 if (LocaleCompare("matte",option+1) == 0)
4989 if (LocaleCompare("mattecolor",option+1) == 0)
4994 if (i == (ssize_t) argc)
4995 ThrowMogrifyException(OptionError,"MissingArgument",option);
4998 if (LocaleCompare("maximum",option+1) == 0)
5000 if (LocaleCompare("minimum",option+1) == 0)
5002 if (LocaleCompare("modulate",option+1) == 0)
5007 if (i == (ssize_t) argc)
5008 ThrowMogrifyException(OptionError,"MissingArgument",option);
5009 if (IsGeometry(argv[i]) == MagickFalse)
5010 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5013 if (LocaleCompare("median",option+1) == 0)
5018 if (i == (ssize_t) argc)
5019 ThrowMogrifyException(OptionError,"MissingArgument",option);
5020 if (IsGeometry(argv[i]) == MagickFalse)
5021 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5024 if (LocaleCompare("mode",option+1) == 0)
5029 if (i == (ssize_t) argc)
5030 ThrowMogrifyException(OptionError,"MissingArgument",option);
5031 if (IsGeometry(argv[i]) == MagickFalse)
5032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5035 if (LocaleCompare("monitor",option+1) == 0)
5037 if (LocaleCompare("monochrome",option+1) == 0)
5039 if (LocaleCompare("morph",option+1) == 0)
5044 if (i == (ssize_t) (argc-1))
5045 ThrowMogrifyException(OptionError,"MissingArgument",option);
5046 if (IsGeometry(argv[i]) == MagickFalse)
5047 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5050 if (LocaleCompare("morphology",option+1) == 0)
5053 token[MaxTextExtent];
5062 if (i == (ssize_t) argc)
5063 ThrowMogrifyException(OptionError,"MissingArgument",option);
5064 GetMagickToken(argv[i],NULL,token);
5065 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5067 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5070 if (i == (ssize_t) (argc-1))
5071 ThrowMogrifyException(OptionError,"MissingArgument",option);
5072 kernel_info=AcquireKernelInfo(argv[i]);
5073 if (kernel_info == (KernelInfo *) NULL)
5074 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5075 kernel_info=DestroyKernelInfo(kernel_info);
5078 if (LocaleCompare("mosaic",option+1) == 0)
5080 if (LocaleCompare("motion-blur",option+1) == 0)
5085 if (i == (ssize_t) argc)
5086 ThrowMogrifyException(OptionError,"MissingArgument",option);
5087 if (IsGeometry(argv[i]) == MagickFalse)
5088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5091 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5095 if (LocaleCompare("negate",option+1) == 0)
5097 if (LocaleCompare("noise",option+1) == 0)
5100 if (i == (ssize_t) argc)
5101 ThrowMogrifyException(OptionError,"MissingArgument",option);
5107 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5109 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5113 if (IsGeometry(argv[i]) == MagickFalse)
5114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5117 if (LocaleCompare("noop",option+1) == 0)
5119 if (LocaleCompare("normalize",option+1) == 0)
5121 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5125 if (LocaleCompare("opaque",option+1) == 0)
5128 if (i == (ssize_t) argc)
5129 ThrowMogrifyException(OptionError,"MissingArgument",option);
5132 if (LocaleCompare("ordered-dither",option+1) == 0)
5137 if (i == (ssize_t) argc)
5138 ThrowMogrifyException(OptionError,"MissingArgument",option);
5141 if (LocaleCompare("orient",option+1) == 0)
5146 orientation=UndefinedOrientation;
5150 if (i == (ssize_t) (argc-1))
5151 ThrowMogrifyException(OptionError,"MissingArgument",option);
5152 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5154 if (orientation < 0)
5155 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5159 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5163 if (LocaleCompare("page",option+1) == 0)
5168 if (i == (ssize_t) argc)
5169 ThrowMogrifyException(OptionError,"MissingArgument",option);
5172 if (LocaleCompare("paint",option+1) == 0)
5177 if (i == (ssize_t) argc)
5178 ThrowMogrifyException(OptionError,"MissingArgument",option);
5179 if (IsGeometry(argv[i]) == MagickFalse)
5180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5183 if (LocaleCompare("path",option+1) == 0)
5185 (void) CloneString(&path,(char *) NULL);
5189 if (i == (ssize_t) argc)
5190 ThrowMogrifyException(OptionError,"MissingArgument",option);
5191 (void) CloneString(&path,argv[i]);
5194 if (LocaleCompare("pointsize",option+1) == 0)
5199 if (i == (ssize_t) argc)
5200 ThrowMogrifyException(OptionError,"MissingArgument",option);
5201 if (IsGeometry(argv[i]) == MagickFalse)
5202 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5205 if (LocaleCompare("polaroid",option+1) == 0)
5210 if (i == (ssize_t) argc)
5211 ThrowMogrifyException(OptionError,"MissingArgument",option);
5212 if (IsGeometry(argv[i]) == MagickFalse)
5213 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5216 if (LocaleCompare("posterize",option+1) == 0)
5221 if (i == (ssize_t) argc)
5222 ThrowMogrifyException(OptionError,"MissingArgument",option);
5223 if (IsGeometry(argv[i]) == MagickFalse)
5224 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5227 if (LocaleCompare("precision",option+1) == 0)
5232 if (i == (ssize_t) argc)
5233 ThrowMogrifyException(OptionError,"MissingArgument",option);
5234 if (IsGeometry(argv[i]) == MagickFalse)
5235 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5238 if (LocaleCompare("print",option+1) == 0)
5243 if (i == (ssize_t) argc)
5244 ThrowMogrifyException(OptionError,"MissingArgument",option);
5247 if (LocaleCompare("process",option+1) == 0)
5252 if (i == (ssize_t) (argc-1))
5253 ThrowMogrifyException(OptionError,"MissingArgument",option);
5256 if (LocaleCompare("profile",option+1) == 0)
5259 if (i == (ssize_t) argc)
5260 ThrowMogrifyException(OptionError,"MissingArgument",option);
5263 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5267 if (LocaleCompare("quality",option+1) == 0)
5272 if (i == (ssize_t) argc)
5273 ThrowMogrifyException(OptionError,"MissingArgument",option);
5274 if (IsGeometry(argv[i]) == MagickFalse)
5275 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5278 if (LocaleCompare("quantize",option+1) == 0)
5286 if (i == (ssize_t) (argc-1))
5287 ThrowMogrifyException(OptionError,"MissingArgument",option);
5288 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5291 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5295 if (LocaleCompare("quiet",option+1) == 0)
5297 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5301 if (LocaleCompare("radial-blur",option+1) == 0)
5304 if (i == (ssize_t) argc)
5305 ThrowMogrifyException(OptionError,"MissingArgument",option);
5306 if (IsGeometry(argv[i]) == MagickFalse)
5307 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5310 if (LocaleCompare("raise",option+1) == 0)
5313 if (i == (ssize_t) argc)
5314 ThrowMogrifyException(OptionError,"MissingArgument",option);
5315 if (IsGeometry(argv[i]) == MagickFalse)
5316 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5319 if (LocaleCompare("random-threshold",option+1) == 0)
5324 if (i == (ssize_t) argc)
5325 ThrowMogrifyException(OptionError,"MissingArgument",option);
5326 if (IsGeometry(argv[i]) == MagickFalse)
5327 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5330 if (LocaleCompare("recolor",option+1) == 0)
5335 if (i == (ssize_t) (argc-1))
5336 ThrowMogrifyException(OptionError,"MissingArgument",option);
5337 if (IsGeometry(argv[i]) == MagickFalse)
5338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5341 if (LocaleCompare("red-primary",option+1) == 0)
5346 if (i == (ssize_t) argc)
5347 ThrowMogrifyException(OptionError,"MissingArgument",option);
5348 if (IsGeometry(argv[i]) == MagickFalse)
5349 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351 if (LocaleCompare("regard-warnings",option+1) == 0)
5353 if (LocaleCompare("region",option+1) == 0)
5358 if (i == (ssize_t) argc)
5359 ThrowMogrifyException(OptionError,"MissingArgument",option);
5360 if (IsGeometry(argv[i]) == MagickFalse)
5361 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5364 if (LocaleCompare("remap",option+1) == 0)
5369 if (i == (ssize_t) (argc-1))
5370 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (LocaleCompare("render",option+1) == 0)
5375 if (LocaleCompare("repage",option+1) == 0)
5380 if (i == (ssize_t) argc)
5381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5382 if (IsGeometry(argv[i]) == MagickFalse)
5383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5386 if (LocaleCompare("resample",option+1) == 0)
5391 if (i == (ssize_t) argc)
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5397 if (LocaleCompare("resize",option+1) == 0)
5402 if (i == (ssize_t) argc)
5403 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 if (IsGeometry(argv[i]) == MagickFalse)
5405 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5408 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5410 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5413 if (LocaleCompare("reverse",option+1) == 0)
5415 if (LocaleCompare("roll",option+1) == 0)
5420 if (i == (ssize_t) argc)
5421 ThrowMogrifyException(OptionError,"MissingArgument",option);
5422 if (IsGeometry(argv[i]) == MagickFalse)
5423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5426 if (LocaleCompare("rotate",option+1) == 0)
5429 if (i == (ssize_t) argc)
5430 ThrowMogrifyException(OptionError,"MissingArgument",option);
5431 if (IsGeometry(argv[i]) == MagickFalse)
5432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5435 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5439 if (LocaleCompare("sample",option+1) == 0)
5444 if (i == (ssize_t) argc)
5445 ThrowMogrifyException(OptionError,"MissingArgument",option);
5446 if (IsGeometry(argv[i]) == MagickFalse)
5447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5450 if (LocaleCompare("sampling-factor",option+1) == 0)
5455 if (i == (ssize_t) argc)
5456 ThrowMogrifyException(OptionError,"MissingArgument",option);
5457 if (IsGeometry(argv[i]) == MagickFalse)
5458 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5461 if (LocaleCompare("scale",option+1) == 0)
5466 if (i == (ssize_t) argc)
5467 ThrowMogrifyException(OptionError,"MissingArgument",option);
5468 if (IsGeometry(argv[i]) == MagickFalse)
5469 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5472 if (LocaleCompare("scene",option+1) == 0)
5477 if (i == (ssize_t) argc)
5478 ThrowMogrifyException(OptionError,"MissingArgument",option);
5479 if (IsGeometry(argv[i]) == MagickFalse)
5480 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5483 if (LocaleCompare("seed",option+1) == 0)
5488 if (i == (ssize_t) argc)
5489 ThrowMogrifyException(OptionError,"MissingArgument",option);
5490 if (IsGeometry(argv[i]) == MagickFalse)
5491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5494 if (LocaleCompare("segment",option+1) == 0)
5499 if (i == (ssize_t) argc)
5500 ThrowMogrifyException(OptionError,"MissingArgument",option);
5501 if (IsGeometry(argv[i]) == MagickFalse)
5502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5505 if (LocaleCompare("selective-blur",option+1) == 0)
5508 if (i == (ssize_t) argc)
5509 ThrowMogrifyException(OptionError,"MissingArgument",option);
5510 if (IsGeometry(argv[i]) == MagickFalse)
5511 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5514 if (LocaleCompare("separate",option+1) == 0)
5516 if (LocaleCompare("sepia-tone",option+1) == 0)
5521 if (i == (ssize_t) argc)
5522 ThrowMogrifyException(OptionError,"MissingArgument",option);
5523 if (IsGeometry(argv[i]) == MagickFalse)
5524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5527 if (LocaleCompare("set",option+1) == 0)
5530 if (i == (ssize_t) argc)
5531 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (i == (ssize_t) argc)
5536 ThrowMogrifyException(OptionError,"MissingArgument",option);
5539 if (LocaleCompare("shade",option+1) == 0)
5542 if (i == (ssize_t) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5544 if (IsGeometry(argv[i]) == MagickFalse)
5545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5548 if (LocaleCompare("shadow",option+1) == 0)
5553 if (i == (ssize_t) argc)
5554 ThrowMogrifyException(OptionError,"MissingArgument",option);
5555 if (IsGeometry(argv[i]) == MagickFalse)
5556 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5559 if (LocaleCompare("sharpen",option+1) == 0)
5562 if (i == (ssize_t) argc)
5563 ThrowMogrifyException(OptionError,"MissingArgument",option);
5564 if (IsGeometry(argv[i]) == MagickFalse)
5565 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5568 if (LocaleCompare("shave",option+1) == 0)
5573 if (i == (ssize_t) argc)
5574 ThrowMogrifyException(OptionError,"MissingArgument",option);
5575 if (IsGeometry(argv[i]) == MagickFalse)
5576 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5579 if (LocaleCompare("shear",option+1) == 0)
5582 if (i == (ssize_t) argc)
5583 ThrowMogrifyException(OptionError,"MissingArgument",option);
5584 if (IsGeometry(argv[i]) == MagickFalse)
5585 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5588 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5591 if (i == (ssize_t) (argc-1))
5592 ThrowMogrifyException(OptionError,"MissingArgument",option);
5593 if (IsGeometry(argv[i]) == MagickFalse)
5594 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5597 if (LocaleCompare("size",option+1) == 0)
5602 if (i == (ssize_t) argc)
5603 ThrowMogrifyException(OptionError,"MissingArgument",option);
5604 if (IsGeometry(argv[i]) == MagickFalse)
5605 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5608 if (LocaleCompare("sketch",option+1) == 0)
5613 if (i == (ssize_t) argc)
5614 ThrowMogrifyException(OptionError,"MissingArgument",option);
5615 if (IsGeometry(argv[i]) == MagickFalse)
5616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5619 if (LocaleCompare("smush",option+1) == 0)
5622 if (i == (ssize_t) argc)
5623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5624 if (IsGeometry(argv[i]) == MagickFalse)
5625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5629 if (LocaleCompare("solarize",option+1) == 0)
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,"MissingArgument",option);
5636 if (IsGeometry(argv[i]) == MagickFalse)
5637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5640 if (LocaleCompare("sparse-color",option+1) == 0)
5646 if (i == (ssize_t) argc)
5647 ThrowMogrifyException(OptionError,"MissingArgument",option);
5648 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5650 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5653 if (i == (ssize_t) (argc-1))
5654 ThrowMogrifyException(OptionError,"MissingArgument",option);
5657 if (LocaleCompare("spread",option+1) == 0)
5662 if (i == (ssize_t) argc)
5663 ThrowMogrifyException(OptionError,"MissingArgument",option);
5664 if (IsGeometry(argv[i]) == MagickFalse)
5665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5668 if (LocaleCompare("statistic",option+1) == 0)
5676 if (i == (ssize_t) argc)
5677 ThrowMogrifyException(OptionError,"MissingArgument",option);
5678 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5680 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5683 if (i == (ssize_t) (argc-1))
5684 ThrowMogrifyException(OptionError,"MissingArgument",option);
5685 if (IsGeometry(argv[i]) == MagickFalse)
5686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5689 if (LocaleCompare("stretch",option+1) == 0)
5697 if (i == (ssize_t) (argc-1))
5698 ThrowMogrifyException(OptionError,"MissingArgument",option);
5699 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5701 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5705 if (LocaleCompare("strip",option+1) == 0)
5707 if (LocaleCompare("stroke",option+1) == 0)
5712 if (i == (ssize_t) argc)
5713 ThrowMogrifyException(OptionError,"MissingArgument",option);
5716 if (LocaleCompare("strokewidth",option+1) == 0)
5721 if (i == (ssize_t) argc)
5722 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 if (IsGeometry(argv[i]) == MagickFalse)
5724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5727 if (LocaleCompare("style",option+1) == 0)
5735 if (i == (ssize_t) (argc-1))
5736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5739 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5743 if (LocaleCompare("swap",option+1) == 0)
5748 if (i == (ssize_t) (argc-1))
5749 ThrowMogrifyException(OptionError,"MissingArgument",option);
5750 if (IsGeometry(argv[i]) == MagickFalse)
5751 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5754 if (LocaleCompare("swirl",option+1) == 0)
5759 if (i == (ssize_t) argc)
5760 ThrowMogrifyException(OptionError,"MissingArgument",option);
5761 if (IsGeometry(argv[i]) == MagickFalse)
5762 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5765 if (LocaleCompare("synchronize",option+1) == 0)
5767 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5771 if (LocaleCompare("taint",option+1) == 0)
5773 if (LocaleCompare("texture",option+1) == 0)
5778 if (i == (ssize_t) argc)
5779 ThrowMogrifyException(OptionError,"MissingArgument",option);
5782 if (LocaleCompare("tile",option+1) == 0)
5787 if (i == (ssize_t) (argc-1))
5788 ThrowMogrifyException(OptionError,"MissingArgument",option);
5791 if (LocaleCompare("tile-offset",option+1) == 0)
5796 if (i == (ssize_t) argc)
5797 ThrowMogrifyException(OptionError,"MissingArgument",option);
5798 if (IsGeometry(argv[i]) == MagickFalse)
5799 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5802 if (LocaleCompare("tint",option+1) == 0)
5807 if (i == (ssize_t) (argc-1))
5808 ThrowMogrifyException(OptionError,"MissingArgument",option);
5809 if (IsGeometry(argv[i]) == MagickFalse)
5810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5813 if (LocaleCompare("transform",option+1) == 0)
5815 if (LocaleCompare("transpose",option+1) == 0)
5817 if (LocaleCompare("transverse",option+1) == 0)
5819 if (LocaleCompare("threshold",option+1) == 0)
5824 if (i == (ssize_t) argc)
5825 ThrowMogrifyException(OptionError,"MissingArgument",option);
5826 if (IsGeometry(argv[i]) == MagickFalse)
5827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5830 if (LocaleCompare("thumbnail",option+1) == 0)
5835 if (i == (ssize_t) argc)
5836 ThrowMogrifyException(OptionError,"MissingArgument",option);
5837 if (IsGeometry(argv[i]) == MagickFalse)
5838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5841 if (LocaleCompare("transparent",option+1) == 0)
5844 if (i == (ssize_t) argc)
5845 ThrowMogrifyException(OptionError,"MissingArgument",option);
5848 if (LocaleCompare("transparent-color",option+1) == 0)
5853 if (i == (ssize_t) (argc-1))
5854 ThrowMogrifyException(OptionError,"MissingArgument",option);
5857 if (LocaleCompare("treedepth",option+1) == 0)
5862 if (i == (ssize_t) argc)
5863 ThrowMogrifyException(OptionError,"MissingArgument",option);
5864 if (IsGeometry(argv[i]) == MagickFalse)
5865 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5868 if (LocaleCompare("trim",option+1) == 0)
5870 if (LocaleCompare("type",option+1) == 0)
5878 if (i == (ssize_t) argc)
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5882 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5886 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5890 if (LocaleCompare("undercolor",option+1) == 0)
5895 if (i == (ssize_t) argc)
5896 ThrowMogrifyException(OptionError,"MissingArgument",option);
5899 if (LocaleCompare("unique-colors",option+1) == 0)
5901 if (LocaleCompare("units",option+1) == 0)
5909 if (i == (ssize_t) argc)
5910 ThrowMogrifyException(OptionError,"MissingArgument",option);
5911 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5914 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5918 if (LocaleCompare("unsharp",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5931 if (LocaleCompare("verbose",option+1) == 0)
5933 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5936 if ((LocaleCompare("version",option+1) == 0) ||
5937 (LocaleCompare("-version",option+1) == 0))
5939 (void) FormatLocaleFile(stdout,"Version: %s\n",
5940 GetMagickVersion((size_t *) NULL));
5941 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5942 GetMagickCopyright());
5943 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5944 GetMagickFeatures());
5947 if (LocaleCompare("view",option+1) == 0)
5952 if (i == (ssize_t) argc)
5953 ThrowMogrifyException(OptionError,"MissingArgument",option);
5956 if (LocaleCompare("vignette",option+1) == 0)
5961 if (i == (ssize_t) argc)
5962 ThrowMogrifyException(OptionError,"MissingArgument",option);
5963 if (IsGeometry(argv[i]) == MagickFalse)
5964 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5967 if (LocaleCompare("virtual-pixel",option+1) == 0)
5975 if (i == (ssize_t) argc)
5976 ThrowMogrifyException(OptionError,"MissingArgument",option);
5977 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5980 ThrowMogrifyException(OptionError,
5981 "UnrecognizedVirtualPixelMethod",argv[i]);
5984 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5988 if (LocaleCompare("wave",option+1) == 0)
5991 if (i == (ssize_t) argc)
5992 ThrowMogrifyException(OptionError,"MissingArgument",option);
5993 if (IsGeometry(argv[i]) == MagickFalse)
5994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5997 if (LocaleCompare("weight",option+1) == 0)
6002 if (i == (ssize_t) (argc-1))
6003 ThrowMogrifyException(OptionError,"MissingArgument",option);
6006 if (LocaleCompare("white-point",option+1) == 0)
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6013 if (IsGeometry(argv[i]) == MagickFalse)
6014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6017 if (LocaleCompare("white-threshold",option+1) == 0)
6022 if (i == (ssize_t) argc)
6023 ThrowMogrifyException(OptionError,"MissingArgument",option);
6024 if (IsGeometry(argv[i]) == MagickFalse)
6025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6028 if (LocaleCompare("write",option+1) == 0)
6031 if (i == (ssize_t) (argc-1))
6032 ThrowMogrifyException(OptionError,"MissingArgument",option);
6035 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6040 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6042 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6043 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6044 if (fire != MagickFalse)
6045 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6048 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6049 if (i != (ssize_t) argc)
6050 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6052 return(status != 0 ? MagickTrue : MagickFalse);
6056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6060 + M o g r i f y I m a g e I n f o %
6064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6066 % MogrifyImageInfo() applies image processing settings to the image as
6067 % prescribed by command line options.
6069 % The format of the MogrifyImageInfo method is:
6071 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6072 % const char **argv,ExceptionInfo *exception)
6074 % A description of each parameter follows:
6076 % o image_info: the image info..
6078 % o argc: Specifies a pointer to an integer describing the number of
6079 % elements in the argument vector.
6081 % o argv: Specifies a pointer to a text array containing the command line
6084 % o exception: return any errors or warnings in this structure.
6087 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6088 const int argc,const char **argv,ExceptionInfo *exception)
6103 Initialize method variables.
6105 assert(image_info != (ImageInfo *) NULL);
6106 assert(image_info->signature == MagickSignature);
6107 if (image_info->debug != MagickFalse)
6108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6109 image_info->filename);
6113 Set the image settings.
6115 for (i=0; i < (ssize_t) argc; i++)
6118 if (IsCommandOption(option) == MagickFalse)
6120 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6121 count=MagickMax(count,0L);
6122 if ((i+count) >= (ssize_t) argc)
6124 switch (*(option+1))
6128 if (LocaleCompare("adjoin",option+1) == 0)
6130 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6133 if (LocaleCompare("antialias",option+1) == 0)
6135 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6138 if (LocaleCompare("attenuate",option+1) == 0)
6142 (void) DeleteImageOption(image_info,option+1);
6145 (void) SetImageOption(image_info,option+1,argv[i+1]);
6148 if (LocaleCompare("authenticate",option+1) == 0)
6151 (void) CloneString(&image_info->authenticate,(char *) NULL);
6153 (void) CloneString(&image_info->authenticate,argv[i+1]);
6160 if (LocaleCompare("background",option+1) == 0)
6164 (void) DeleteImageOption(image_info,option+1);
6165 (void) QueryColorDatabase(BackgroundColor,
6166 &image_info->background_color,exception);
6169 (void) SetImageOption(image_info,option+1,argv[i+1]);
6170 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6174 if (LocaleCompare("bias",option+1) == 0)
6178 (void) SetImageOption(image_info,option+1,"0.0");
6181 (void) SetImageOption(image_info,option+1,argv[i+1]);
6184 if (LocaleCompare("black-point-compensation",option+1) == 0)
6188 (void) SetImageOption(image_info,option+1,"false");
6191 (void) SetImageOption(image_info,option+1,"true");
6194 if (LocaleCompare("blue-primary",option+1) == 0)
6198 (void) SetImageOption(image_info,option+1,"0.0");
6201 (void) SetImageOption(image_info,option+1,argv[i+1]);
6204 if (LocaleCompare("bordercolor",option+1) == 0)
6208 (void) DeleteImageOption(image_info,option+1);
6209 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6213 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6215 (void) SetImageOption(image_info,option+1,argv[i+1]);
6218 if (LocaleCompare("box",option+1) == 0)
6222 (void) SetImageOption(image_info,"undercolor","none");
6225 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6232 if (LocaleCompare("cache",option+1) == 0)
6237 limit=MagickResourceInfinity;
6238 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6239 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6240 (void) SetMagickResourceLimit(MemoryResource,limit);
6241 (void) SetMagickResourceLimit(MapResource,2*limit);
6244 if (LocaleCompare("caption",option+1) == 0)
6248 (void) DeleteImageOption(image_info,option+1);
6251 (void) SetImageOption(image_info,option+1,argv[i+1]);
6254 if (LocaleCompare("channel",option+1) == 0)
6258 image_info->channel=DefaultChannels;
6261 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6264 if (LocaleCompare("colors",option+1) == 0)
6266 image_info->colors=StringToUnsignedLong(argv[i+1]);
6269 if (LocaleCompare("colorspace",option+1) == 0)
6273 image_info->colorspace=UndefinedColorspace;
6274 (void) SetImageOption(image_info,option+1,"undefined");
6277 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6278 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6279 (void) SetImageOption(image_info,option+1,argv[i+1]);
6282 if (LocaleCompare("comment",option+1) == 0)
6286 (void) DeleteImageOption(image_info,option+1);
6289 (void) SetImageOption(image_info,option+1,argv[i+1]);
6292 if (LocaleCompare("compose",option+1) == 0)
6296 (void) SetImageOption(image_info,option+1,"undefined");
6299 (void) SetImageOption(image_info,option+1,argv[i+1]);
6302 if (LocaleCompare("compress",option+1) == 0)
6306 image_info->compression=UndefinedCompression;
6307 (void) SetImageOption(image_info,option+1,"undefined");
6310 image_info->compression=(CompressionType) ParseCommandOption(
6311 MagickCompressOptions,MagickFalse,argv[i+1]);
6312 (void) SetImageOption(image_info,option+1,argv[i+1]);
6319 if (LocaleCompare("debug",option+1) == 0)
6322 (void) SetLogEventMask("none");
6324 (void) SetLogEventMask(argv[i+1]);
6325 image_info->debug=IsEventLogging();
6328 if (LocaleCompare("define",option+1) == 0)
6332 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6333 (void) DeleteImageRegistry(argv[i+1]+9);
6335 (void) DeleteImageOption(image_info,argv[i+1]);
6338 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6340 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6344 (void) DefineImageOption(image_info,argv[i+1]);
6347 if (LocaleCompare("delay",option+1) == 0)
6351 (void) SetImageOption(image_info,option+1,"0");
6354 (void) SetImageOption(image_info,option+1,argv[i+1]);
6357 if (LocaleCompare("density",option+1) == 0)
6364 if (image_info->density != (char *) NULL)
6365 image_info->density=DestroyString(image_info->density);
6366 (void) SetImageOption(image_info,option+1,"72");
6369 (void) CloneString(&image_info->density,argv[i+1]);
6370 (void) SetImageOption(image_info,option+1,argv[i+1]);
6373 if (LocaleCompare("depth",option+1) == 0)
6377 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6380 image_info->depth=StringToUnsignedLong(argv[i+1]);
6383 if (LocaleCompare("direction",option+1) == 0)
6387 (void) SetImageOption(image_info,option+1,"undefined");
6390 (void) SetImageOption(image_info,option+1,argv[i+1]);
6393 if (LocaleCompare("display",option+1) == 0)
6397 if (image_info->server_name != (char *) NULL)
6398 image_info->server_name=DestroyString(
6399 image_info->server_name);
6402 (void) CloneString(&image_info->server_name,argv[i+1]);
6405 if (LocaleCompare("dispose",option+1) == 0)
6409 (void) SetImageOption(image_info,option+1,"undefined");
6412 (void) SetImageOption(image_info,option+1,argv[i+1]);
6415 if (LocaleCompare("dither",option+1) == 0)
6419 image_info->dither=MagickFalse;
6420 (void) SetImageOption(image_info,option+1,"none");
6423 (void) SetImageOption(image_info,option+1,argv[i+1]);
6424 image_info->dither=MagickTrue;
6431 if (LocaleCompare("encoding",option+1) == 0)
6435 (void) SetImageOption(image_info,option+1,"undefined");
6438 (void) SetImageOption(image_info,option+1,argv[i+1]);
6441 if (LocaleCompare("endian",option+1) == 0)
6445 image_info->endian=UndefinedEndian;
6446 (void) SetImageOption(image_info,option+1,"undefined");
6449 image_info->endian=(EndianType) ParseCommandOption(
6450 MagickEndianOptions,MagickFalse,argv[i+1]);
6451 (void) SetImageOption(image_info,option+1,argv[i+1]);
6454 if (LocaleCompare("extract",option+1) == 0)
6457 Set image extract geometry.
6461 if (image_info->extract != (char *) NULL)
6462 image_info->extract=DestroyString(image_info->extract);
6465 (void) CloneString(&image_info->extract,argv[i+1]);
6472 if (LocaleCompare("fill",option+1) == 0)
6476 (void) SetImageOption(image_info,option+1,"none");
6479 (void) SetImageOption(image_info,option+1,argv[i+1]);
6482 if (LocaleCompare("filter",option+1) == 0)
6486 (void) SetImageOption(image_info,option+1,"undefined");
6489 (void) SetImageOption(image_info,option+1,argv[i+1]);
6492 if (LocaleCompare("font",option+1) == 0)
6496 if (image_info->font != (char *) NULL)
6497 image_info->font=DestroyString(image_info->font);
6500 (void) CloneString(&image_info->font,argv[i+1]);
6503 if (LocaleCompare("format",option+1) == 0)
6508 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6509 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6510 image_info->ping=MagickFalse;
6511 (void) SetImageOption(image_info,option+1,argv[i+1]);
6514 if (LocaleCompare("fuzz",option+1) == 0)
6518 image_info->fuzz=0.0;
6519 (void) SetImageOption(image_info,option+1,"0");
6522 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6524 (void) SetImageOption(image_info,option+1,argv[i+1]);
6531 if (LocaleCompare("gravity",option+1) == 0)
6535 (void) SetImageOption(image_info,option+1,"undefined");
6538 (void) SetImageOption(image_info,option+1,argv[i+1]);
6541 if (LocaleCompare("green-primary",option+1) == 0)
6545 (void) SetImageOption(image_info,option+1,"0.0");
6548 (void) SetImageOption(image_info,option+1,argv[i+1]);
6555 if (LocaleCompare("intent",option+1) == 0)
6559 (void) SetImageOption(image_info,option+1,"undefined");
6562 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 if (LocaleCompare("interlace",option+1) == 0)
6569 image_info->interlace=UndefinedInterlace;
6570 (void) SetImageOption(image_info,option+1,"undefined");
6573 image_info->interlace=(InterlaceType) ParseCommandOption(
6574 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6575 (void) SetImageOption(image_info,option+1,argv[i+1]);
6578 if (LocaleCompare("interline-spacing",option+1) == 0)
6582 (void) SetImageOption(image_info,option+1,"undefined");
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 if (LocaleCompare("interpolate",option+1) == 0)
6592 (void) SetImageOption(image_info,option+1,"undefined");
6595 (void) SetImageOption(image_info,option+1,argv[i+1]);
6598 if (LocaleCompare("interword-spacing",option+1) == 0)
6602 (void) SetImageOption(image_info,option+1,"undefined");
6605 (void) SetImageOption(image_info,option+1,argv[i+1]);
6612 if (LocaleCompare("kerning",option+1) == 0)
6616 (void) SetImageOption(image_info,option+1,"undefined");
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6626 if (LocaleCompare("label",option+1) == 0)
6630 (void) DeleteImageOption(image_info,option+1);
6633 (void) SetImageOption(image_info,option+1,argv[i+1]);
6636 if (LocaleCompare("limit",option+1) == 0)
6646 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6647 MagickFalse,argv[i+1]);
6648 limit=MagickResourceInfinity;
6649 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6650 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6651 (void) SetMagickResourceLimit(type,limit);
6654 if (LocaleCompare("list",option+1) == 0)
6660 Display configuration list.
6662 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6665 case MagickCoderOptions:
6667 (void) ListCoderInfo((FILE *) NULL,exception);
6670 case MagickColorOptions:
6672 (void) ListColorInfo((FILE *) NULL,exception);
6675 case MagickConfigureOptions:
6677 (void) ListConfigureInfo((FILE *) NULL,exception);
6680 case MagickDelegateOptions:
6682 (void) ListDelegateInfo((FILE *) NULL,exception);
6685 case MagickFontOptions:
6687 (void) ListTypeInfo((FILE *) NULL,exception);
6690 case MagickFormatOptions:
6692 (void) ListMagickInfo((FILE *) NULL,exception);
6695 case MagickLocaleOptions:
6697 (void) ListLocaleInfo((FILE *) NULL,exception);
6700 case MagickLogOptions:
6702 (void) ListLogInfo((FILE *) NULL,exception);
6705 case MagickMagicOptions:
6707 (void) ListMagicInfo((FILE *) NULL,exception);
6710 case MagickMimeOptions:
6712 (void) ListMimeInfo((FILE *) NULL,exception);
6715 case MagickModuleOptions:
6717 (void) ListModuleInfo((FILE *) NULL,exception);
6720 case MagickPolicyOptions:
6722 (void) ListPolicyInfo((FILE *) NULL,exception);
6725 case MagickResourceOptions:
6727 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6730 case MagickThresholdOptions:
6732 (void) ListThresholdMaps((FILE *) NULL,exception);
6737 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6744 if (LocaleCompare("log",option+1) == 0)
6748 (void) SetLogFormat(argv[i+1]);
6751 if (LocaleCompare("loop",option+1) == 0)
6755 (void) SetImageOption(image_info,option+1,"0");
6758 (void) SetImageOption(image_info,option+1,argv[i+1]);
6765 if (LocaleCompare("matte",option+1) == 0)
6769 (void) SetImageOption(image_info,option+1,"false");
6772 (void) SetImageOption(image_info,option+1,"true");
6775 if (LocaleCompare("mattecolor",option+1) == 0)
6779 (void) SetImageOption(image_info,option+1,argv[i+1]);
6780 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
6784 (void) SetImageOption(image_info,option+1,argv[i+1]);
6785 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6789 if (LocaleCompare("monitor",option+1) == 0)
6791 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6795 if (LocaleCompare("monochrome",option+1) == 0)
6797 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6804 if (LocaleCompare("orient",option+1) == 0)
6808 image_info->orientation=UndefinedOrientation;
6809 (void) SetImageOption(image_info,option+1,"undefined");
6812 image_info->orientation=(OrientationType) ParseCommandOption(
6813 MagickOrientationOptions,MagickFalse,argv[i+1]);
6814 (void) SetImageOption(image_info,option+1,argv[i+1]);
6820 if (LocaleCompare("page",option+1) == 0)
6824 page[MaxTextExtent];
6837 (void) DeleteImageOption(image_info,option+1);
6838 (void) CloneString(&image_info->page,(char *) NULL);
6841 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6842 image_option=GetImageOption(image_info,"page");
6843 if (image_option != (const char *) NULL)
6844 flags=ParseAbsoluteGeometry(image_option,&geometry);
6845 canonical_page=GetPageGeometry(argv[i+1]);
6846 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6847 canonical_page=DestroyString(canonical_page);
6848 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6849 (unsigned long) geometry.width,(unsigned long) geometry.height);
6850 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6851 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6852 (unsigned long) geometry.width,(unsigned long) geometry.height,
6853 (long) geometry.x,(long) geometry.y);
6854 (void) SetImageOption(image_info,option+1,page);
6855 (void) CloneString(&image_info->page,page);
6858 if (LocaleCompare("pen",option+1) == 0)
6862 (void) SetImageOption(image_info,option+1,"none");
6865 (void) SetImageOption(image_info,option+1,argv[i+1]);
6868 if (LocaleCompare("ping",option+1) == 0)
6870 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6873 if (LocaleCompare("pointsize",option+1) == 0)
6876 geometry_info.rho=0.0;
6878 (void) ParseGeometry(argv[i+1],&geometry_info);
6879 image_info->pointsize=geometry_info.rho;
6882 if (LocaleCompare("precision",option+1) == 0)
6884 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6887 if (LocaleCompare("preview",option+1) == 0)
6894 image_info->preview_type=UndefinedPreview;
6897 image_info->preview_type=(PreviewType) ParseCommandOption(
6898 MagickPreviewOptions,MagickFalse,argv[i+1]);
6905 if (LocaleCompare("quality",option+1) == 0)
6908 Set image compression quality.
6912 image_info->quality=UndefinedCompressionQuality;
6913 (void) SetImageOption(image_info,option+1,"0");
6916 image_info->quality=StringToUnsignedLong(argv[i+1]);
6917 (void) SetImageOption(image_info,option+1,argv[i+1]);
6920 if (LocaleCompare("quiet",option+1) == 0)
6922 static WarningHandler
6923 warning_handler = (WarningHandler) NULL;
6928 Restore error or warning messages.
6930 warning_handler=SetWarningHandler(warning_handler);
6934 Suppress error or warning messages.
6936 warning_handler=SetWarningHandler((WarningHandler) NULL);
6943 if (LocaleCompare("red-primary",option+1) == 0)
6947 (void) SetImageOption(image_info,option+1,"0.0");
6950 (void) SetImageOption(image_info,option+1,argv[i+1]);
6957 if (LocaleCompare("sampling-factor",option+1) == 0)
6960 Set image sampling factor.
6964 if (image_info->sampling_factor != (char *) NULL)
6965 image_info->sampling_factor=DestroyString(
6966 image_info->sampling_factor);
6969 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6972 if (LocaleCompare("scene",option+1) == 0)
6979 image_info->scene=0;
6980 (void) SetImageOption(image_info,option+1,"0");
6983 image_info->scene=StringToUnsignedLong(argv[i+1]);
6984 (void) SetImageOption(image_info,option+1,argv[i+1]);
6987 if (LocaleCompare("seed",option+1) == 0)
6994 seed=(size_t) time((time_t *) NULL);
6995 SeedPseudoRandomGenerator(seed);
6998 seed=StringToUnsignedLong(argv[i+1]);
6999 SeedPseudoRandomGenerator(seed);
7002 if (LocaleCompare("size",option+1) == 0)
7006 if (image_info->size != (char *) NULL)
7007 image_info->size=DestroyString(image_info->size);
7010 (void) CloneString(&image_info->size,argv[i+1]);
7013 if (LocaleCompare("stroke",option+1) == 0)
7017 (void) SetImageOption(image_info,option+1,"none");
7020 (void) SetImageOption(image_info,option+1,argv[i+1]);
7023 if (LocaleCompare("strokewidth",option+1) == 0)
7027 (void) SetImageOption(image_info,option+1,"0");
7030 (void) SetImageOption(image_info,option+1,argv[i+1]);
7033 if (LocaleCompare("synchronize",option+1) == 0)
7037 image_info->synchronize=MagickFalse;
7040 image_info->synchronize=MagickTrue;
7047 if (LocaleCompare("taint",option+1) == 0)
7051 (void) SetImageOption(image_info,option+1,"false");
7054 (void) SetImageOption(image_info,option+1,"true");
7057 if (LocaleCompare("texture",option+1) == 0)
7061 if (image_info->texture != (char *) NULL)
7062 image_info->texture=DestroyString(image_info->texture);
7065 (void) CloneString(&image_info->texture,argv[i+1]);
7068 if (LocaleCompare("tile-offset",option+1) == 0)
7072 (void) SetImageOption(image_info,option+1,"0");
7075 (void) SetImageOption(image_info,option+1,argv[i+1]);
7078 if (LocaleCompare("transparent-color",option+1) == 0)
7082 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7083 (void) SetImageOption(image_info,option+1,"none");
7086 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7088 (void) SetImageOption(image_info,option+1,argv[i+1]);
7091 if (LocaleCompare("type",option+1) == 0)
7095 image_info->type=UndefinedType;
7096 (void) SetImageOption(image_info,option+1,"undefined");
7099 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7100 MagickFalse,argv[i+1]);
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7108 if (LocaleCompare("undercolor",option+1) == 0)
7112 (void) DeleteImageOption(image_info,option+1);
7115 (void) SetImageOption(image_info,option+1,argv[i+1]);
7118 if (LocaleCompare("units",option+1) == 0)
7122 image_info->units=UndefinedResolution;
7123 (void) SetImageOption(image_info,option+1,"undefined");
7126 image_info->units=(ResolutionType) ParseCommandOption(
7127 MagickResolutionOptions,MagickFalse,argv[i+1]);
7128 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 if (LocaleCompare("verbose",option+1) == 0)
7139 image_info->verbose=MagickFalse;
7142 image_info->verbose=MagickTrue;
7143 image_info->ping=MagickFalse;
7146 if (LocaleCompare("view",option+1) == 0)
7150 if (image_info->view != (char *) NULL)
7151 image_info->view=DestroyString(image_info->view);
7154 (void) CloneString(&image_info->view,argv[i+1]);
7157 if (LocaleCompare("virtual-pixel",option+1) == 0)
7161 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7162 (void) SetImageOption(image_info,option+1,"undefined");
7165 image_info->virtual_pixel_method=(VirtualPixelMethod)
7166 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7168 (void) SetImageOption(image_info,option+1,argv[i+1]);
7175 if (LocaleCompare("white-point",option+1) == 0)
7179 (void) SetImageOption(image_info,option+1,"0.0");
7182 (void) SetImageOption(image_info,option+1,argv[i+1]);
7196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7200 + M o g r i f y I m a g e L i s t %
7204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7206 % MogrifyImageList() applies any command line options that might affect the
7207 % entire image list (e.g. -append, -coalesce, etc.).
7209 % The format of the MogrifyImage method is:
7211 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7212 % const char **argv,Image **images,ExceptionInfo *exception)
7214 % A description of each parameter follows:
7216 % o image_info: the image info..
7218 % o argc: Specifies a pointer to an integer describing the number of
7219 % elements in the argument vector.
7221 % o argv: Specifies a pointer to a text array containing the command line
7224 % o images: pointer to pointer of the first image in image list.
7226 % o exception: return any errors or warnings in this structure.
7229 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7230 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7252 Apply options to the image list.
7254 assert(image_info != (ImageInfo *) NULL);
7255 assert(image_info->signature == MagickSignature);
7256 assert(images != (Image **) NULL);
7257 assert((*images)->previous == (Image *) NULL);
7258 assert((*images)->signature == MagickSignature);
7259 if ((*images)->debug != MagickFalse)
7260 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7261 (*images)->filename);
7262 if ((argc <= 0) || (*argv == (char *) NULL))
7264 mogrify_info=CloneImageInfo(image_info);
7265 quantize_info=AcquireQuantizeInfo(mogrify_info);
7267 for (i=0; i < (ssize_t) argc; i++)
7269 if (*images == (Image *) NULL)
7272 if (IsCommandOption(option) == MagickFalse)
7274 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7275 count=MagickMax(count,0L);
7276 if ((i+count) >= (ssize_t) argc)
7278 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7279 switch (*(option+1))
7283 if (LocaleCompare("affinity",option+1) == 0)
7285 (void) SyncImagesSettings(mogrify_info,*images);
7288 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7289 InheritException(exception,&(*images)->exception);
7295 if (LocaleCompare("append",option+1) == 0)
7300 (void) SyncImagesSettings(mogrify_info,*images);
7301 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7302 MagickFalse,exception);
7303 if (append_image == (Image *) NULL)
7308 *images=DestroyImageList(*images);
7309 *images=append_image;
7312 if (LocaleCompare("average",option+1) == 0)
7318 Average an image sequence (deprecated).
7320 (void) SyncImagesSettings(mogrify_info,*images);
7321 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7323 if (average_image == (Image *) NULL)
7328 *images=DestroyImageList(*images);
7329 *images=average_image;
7336 if (LocaleCompare("channel",option+1) == 0)
7343 channel=DefaultChannels;
7346 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7347 SetPixelComponentMap(*images,channel);
7350 if (LocaleCompare("clut",option+1) == 0)
7356 (void) SyncImagesSettings(mogrify_info,*images);
7357 image=RemoveFirstImageFromList(images);
7358 clut_image=RemoveFirstImageFromList(images);
7359 if (clut_image == (Image *) NULL)
7364 (void) ClutImage(image,clut_image);
7365 clut_image=DestroyImage(clut_image);
7366 InheritException(exception,&image->exception);
7367 *images=DestroyImageList(*images);
7371 if (LocaleCompare("coalesce",option+1) == 0)
7376 (void) SyncImagesSettings(mogrify_info,*images);
7377 coalesce_image=CoalesceImages(*images,exception);
7378 if (coalesce_image == (Image *) NULL)
7383 *images=DestroyImageList(*images);
7384 *images=coalesce_image;
7387 if (LocaleCompare("combine",option+1) == 0)
7392 (void) SyncImagesSettings(mogrify_info,*images);
7393 combine_image=CombineImages(*images,exception);
7394 if (combine_image == (Image *) NULL)
7399 *images=DestroyImageList(*images);
7400 *images=combine_image;
7403 if (LocaleCompare("composite",option+1) == 0)
7413 (void) SyncImagesSettings(mogrify_info,*images);
7414 image=RemoveFirstImageFromList(images);
7415 composite_image=RemoveFirstImageFromList(images);
7416 if (composite_image == (Image *) NULL)
7421 (void) TransformImage(&composite_image,(char *) NULL,
7422 composite_image->geometry);
7423 SetGeometry(composite_image,&geometry);
7424 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7425 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7427 mask_image=RemoveFirstImageFromList(images);
7428 if (mask_image != (Image *) NULL)
7430 if ((image->compose == DisplaceCompositeOp) ||
7431 (image->compose == DistortCompositeOp))
7434 Merge Y displacement into X displacement image.
7436 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7438 mask_image=DestroyImage(mask_image);
7443 Set a blending mask for the composition.
7445 /* POSIBLE ERROR; what if image->mask already set */
7446 image->mask=mask_image;
7447 (void) NegateImage(image->mask,MagickFalse);
7450 (void) CompositeImage(image,image->compose,composite_image,
7451 geometry.x,geometry.y);
7452 if (mask_image != (Image *) NULL)
7453 mask_image=image->mask=DestroyImage(image->mask);
7454 composite_image=DestroyImage(composite_image);
7455 InheritException(exception,&image->exception);
7456 *images=DestroyImageList(*images);
7461 This has been merged completely into MogrifyImage()
7462 if (LocaleCompare("crop",option+1) == 0)
7473 (void) SyncImagesSettings(mogrify_info,*images);
7474 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7475 if (((geometry.width == 0) && (geometry.height == 0)) ||
7476 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7478 (void) TransformImages(images,argv[i+1],(char *) NULL);
7479 InheritException(exception,&(*images)->exception);
7487 if (LocaleCompare("deconstruct",option+1) == 0)
7492 (void) SyncImagesSettings(mogrify_info,*images);
7493 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7495 if (deconstruct_image == (Image *) NULL)
7500 *images=DestroyImageList(*images);
7501 *images=deconstruct_image;
7504 if (LocaleCompare("delete",option+1) == 0)
7507 DeleteImages(images,"-1",exception);
7509 DeleteImages(images,argv[i+1],exception);
7512 if (LocaleCompare("dither",option+1) == 0)
7516 quantize_info->dither=MagickFalse;
7519 quantize_info->dither=MagickTrue;
7520 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7521 MagickDitherOptions,MagickFalse,argv[i+1]);
7524 if (LocaleCompare("duplicate",option+1) == 0)
7530 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7539 number_duplicates=(size_t) StringToLong(argv[i+1]);
7540 p=strchr(argv[i+1],',');
7541 if (p == (const char *) NULL)
7542 duplicate_images=DuplicateImages(*images,number_duplicates,
7545 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7548 AppendImageToList(images, duplicate_images);
7549 (void) SyncImagesSettings(mogrify_info,*images);
7556 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7561 MagickEvaluateOperator
7564 (void) SyncImageSettings(mogrify_info,*images);
7565 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
7566 MagickFalse,argv[i+1]);
7567 evaluate_image=EvaluateImages(*images,op,exception);
7568 if (evaluate_image == (Image *) NULL)
7573 *images=DestroyImageList(*images);
7574 *images=evaluate_image;
7581 if (LocaleCompare("fft",option+1) == 0)
7587 Implements the discrete Fourier transform (DFT).
7589 (void) SyncImageSettings(mogrify_info,*images);
7590 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7591 MagickTrue : MagickFalse,exception);
7592 if (fourier_image == (Image *) NULL)
7594 *images=DestroyImage(*images);
7595 *images=fourier_image;
7598 if (LocaleCompare("flatten",option+1) == 0)
7603 (void) SyncImagesSettings(mogrify_info,*images);
7604 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7605 if (flatten_image == (Image *) NULL)
7607 *images=DestroyImageList(*images);
7608 *images=flatten_image;
7611 if (LocaleCompare("fx",option+1) == 0)
7616 (void) SyncImagesSettings(mogrify_info,*images);
7617 fx_image=FxImage(*images,argv[i+1],exception);
7618 if (fx_image == (Image *) NULL)
7623 *images=DestroyImageList(*images);
7631 if (LocaleCompare("hald-clut",option+1) == 0)
7637 (void) SyncImagesSettings(mogrify_info,*images);
7638 image=RemoveFirstImageFromList(images);
7639 hald_image=RemoveFirstImageFromList(images);
7640 if (hald_image == (Image *) NULL)
7645 (void) HaldClutImage(image,hald_image);
7646 hald_image=DestroyImage(hald_image);
7647 InheritException(exception,&image->exception);
7648 if (*images != (Image *) NULL)
7649 *images=DestroyImageList(*images);
7657 if (LocaleCompare("ift",option+1) == 0)
7665 Implements the inverse fourier discrete Fourier transform (DFT).
7667 (void) SyncImagesSettings(mogrify_info,*images);
7668 magnitude_image=RemoveFirstImageFromList(images);
7669 phase_image=RemoveFirstImageFromList(images);
7670 if (phase_image == (Image *) NULL)
7675 fourier_image=InverseFourierTransformImage(magnitude_image,
7676 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7677 if (fourier_image == (Image *) NULL)
7679 if (*images != (Image *) NULL)
7680 *images=DestroyImage(*images);
7681 *images=fourier_image;
7684 if (LocaleCompare("insert",option+1) == 0)
7692 index=(ssize_t) StringToLong(argv[i+1]);
7693 p=RemoveLastImageFromList(images);
7694 if (p == (Image *) NULL)
7696 (void) ThrowMagickException(exception,GetMagickModule(),
7697 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7703 PrependImageToList(images,q);
7705 if (index == (ssize_t) GetImageListLength(*images))
7706 AppendImageToList(images,q);
7709 q=GetImageFromList(*images,index-1);
7710 if (q == (Image *) NULL)
7712 (void) ThrowMagickException(exception,GetMagickModule(),
7713 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7717 InsertImageInList(&q,p);
7719 *images=GetFirstImageInList(q);
7726 if (LocaleCompare("layers",option+1) == 0)
7734 (void) SyncImagesSettings(mogrify_info,*images);
7735 layers=(Image *) NULL;
7736 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7737 MagickFalse,argv[i+1]);
7742 layers=CoalesceImages(*images,exception);
7745 case CompareAnyLayer:
7746 case CompareClearLayer:
7747 case CompareOverlayLayer:
7750 layers=CompareImagesLayers(*images,method,exception);
7756 case TrimBoundsLayer:
7758 layers=MergeImageLayers(*images,method,exception);
7763 layers=DisposeImages(*images,exception);
7766 case OptimizeImageLayer:
7768 layers=OptimizeImageLayers(*images,exception);
7771 case OptimizePlusLayer:
7773 layers=OptimizePlusImageLayers(*images,exception);
7776 case OptimizeTransLayer:
7778 OptimizeImageTransparency(*images,exception);
7781 case RemoveDupsLayer:
7783 RemoveDuplicateLayers(images,exception);
7786 case RemoveZeroLayer:
7788 RemoveZeroDelayLayers(images,exception);
7794 General Purpose, GIF Animation Optimizer.
7796 layers=CoalesceImages(*images,exception);
7797 if (layers == (Image *) NULL)
7802 InheritException(exception,&layers->exception);
7803 *images=DestroyImageList(*images);
7805 layers=OptimizeImageLayers(*images,exception);
7806 if (layers == (Image *) NULL)
7811 InheritException(exception,&layers->exception);
7812 *images=DestroyImageList(*images);
7814 layers=(Image *) NULL;
7815 OptimizeImageTransparency(*images,exception);
7816 InheritException(exception,&(*images)->exception);
7817 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7820 case CompositeLayer:
7832 Split image sequence at the first 'NULL:' image.
7835 while (source != (Image *) NULL)
7837 source=GetNextImageInList(source);
7838 if ((source != (Image *) NULL) &&
7839 (LocaleCompare(source->magick,"NULL") == 0))
7842 if (source != (Image *) NULL)
7844 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7845 (GetNextImageInList(source) == (Image *) NULL))
7846 source=(Image *) NULL;
7850 Separate the two lists, junk the null: image.
7852 source=SplitImageList(source->previous);
7853 DeleteImageFromList(&source);
7856 if (source == (Image *) NULL)
7858 (void) ThrowMagickException(exception,GetMagickModule(),
7859 OptionError,"MissingNullSeparator","layers Composite");
7864 Adjust offset with gravity and virtual canvas.
7866 SetGeometry(*images,&geometry);
7867 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7868 geometry.width=source->page.width != 0 ?
7869 source->page.width : source->columns;
7870 geometry.height=source->page.height != 0 ?
7871 source->page.height : source->rows;
7872 GravityAdjustGeometry((*images)->page.width != 0 ?
7873 (*images)->page.width : (*images)->columns,
7874 (*images)->page.height != 0 ? (*images)->page.height :
7875 (*images)->rows,(*images)->gravity,&geometry);
7876 compose=OverCompositeOp;
7877 option=GetImageOption(mogrify_info,"compose");
7878 if (option != (const char *) NULL)
7879 compose=(CompositeOperator) ParseCommandOption(
7880 MagickComposeOptions,MagickFalse,option);
7881 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7883 source=DestroyImageList(source);
7887 if (layers == (Image *) NULL)
7889 InheritException(exception,&layers->exception);
7890 *images=DestroyImageList(*images);
7898 if (LocaleCompare("map",option+1) == 0)
7900 (void) SyncImagesSettings(mogrify_info,*images);
7903 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7904 InheritException(exception,&(*images)->exception);
7910 if (LocaleCompare("maximum",option+1) == 0)
7916 Maximum image sequence (deprecated).
7918 (void) SyncImagesSettings(mogrify_info,*images);
7919 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7920 if (maximum_image == (Image *) NULL)
7925 *images=DestroyImageList(*images);
7926 *images=maximum_image;
7929 if (LocaleCompare("minimum",option+1) == 0)
7935 Minimum image sequence (deprecated).
7937 (void) SyncImagesSettings(mogrify_info,*images);
7938 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7939 if (minimum_image == (Image *) NULL)
7944 *images=DestroyImageList(*images);
7945 *images=minimum_image;
7948 if (LocaleCompare("morph",option+1) == 0)
7953 (void) SyncImagesSettings(mogrify_info,*images);
7954 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7956 if (morph_image == (Image *) NULL)
7961 *images=DestroyImageList(*images);
7962 *images=morph_image;
7965 if (LocaleCompare("mosaic",option+1) == 0)
7970 (void) SyncImagesSettings(mogrify_info,*images);
7971 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7972 if (mosaic_image == (Image *) NULL)
7977 *images=DestroyImageList(*images);
7978 *images=mosaic_image;
7985 if (LocaleCompare("print",option+1) == 0)
7990 (void) SyncImagesSettings(mogrify_info,*images);
7991 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
7992 if (string == (char *) NULL)
7994 InheritException(exception,&(*images)->exception);
7995 (void) FormatLocaleFile(stdout,"%s",string);
7996 string=DestroyString(string);
7998 if (LocaleCompare("process",option+1) == 0)
8007 (void) SyncImagesSettings(mogrify_info,*images);
8008 arguments=StringToArgv(argv[i+1],&number_arguments);
8009 if (arguments == (char **) NULL)
8011 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8032 Support old style syntax, filter="-option arg".
8034 length=strlen(argv[i+1]);
8035 token=(char *) NULL;
8036 if (~length >= (MaxTextExtent-1))
8037 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8039 if (token == (char *) NULL)
8042 arguments=argv[i+1];
8043 token_info=AcquireTokenInfo();
8044 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8045 "\"",'\0',&breaker,&next,"e);
8046 token_info=DestroyTokenInfo(token_info);
8052 argv=(&(arguments[next]));
8053 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8056 token=DestroyString(token);
8059 (void) SubstituteString(&arguments[1],"-","");
8060 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8061 number_arguments-2,(const char **) arguments+2,exception);
8062 for (j=0; j < number_arguments; j++)
8063 arguments[j]=DestroyString(arguments[j]);
8064 arguments=(char **) RelinquishMagickMemory(arguments);
8071 if (LocaleCompare("reverse",option+1) == 0)
8073 ReverseImageList(images);
8074 InheritException(exception,&(*images)->exception);
8081 if (LocaleCompare("smush",option+1) == 0)
8089 (void) SyncImagesSettings(mogrify_info,*images);
8090 offset=(ssize_t) StringToLong(argv[i+1]);
8091 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8092 MagickFalse,offset,exception);
8093 if (smush_image == (Image *) NULL)
8098 *images=DestroyImageList(*images);
8099 *images=smush_image;
8102 if (LocaleCompare("swap",option+1) == 0)
8123 flags=ParseGeometry(argv[i+1],&geometry_info);
8124 index=(ssize_t) geometry_info.rho;
8125 if ((flags & SigmaValue) != 0)
8126 swap_index=(ssize_t) geometry_info.sigma;
8128 p=GetImageFromList(*images,index);
8129 q=GetImageFromList(*images,swap_index);
8130 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8132 (void) ThrowMagickException(exception,GetMagickModule(),
8133 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8139 swap=CloneImage(p,0,0,MagickTrue,exception);
8140 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8141 ReplaceImageInList(&q,swap);
8142 *images=GetFirstImageInList(q);
8149 if (LocaleCompare("write",option+1) == 0)
8160 (void) SyncImagesSettings(mogrify_info,*images);
8161 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8162 (void) DeleteImageRegistry(key);
8163 write_images=(*images);
8165 write_images=CloneImageList(*images,exception);
8166 write_info=CloneImageInfo(mogrify_info);
8167 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8168 write_info=DestroyImageInfo(write_info);
8170 write_images=DestroyImageList(write_images);
8180 quantize_info=DestroyQuantizeInfo(quantize_info);
8181 mogrify_info=DestroyImageInfo(mogrify_info);
8182 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8183 return(status != 0 ? MagickTrue : MagickFalse);
8187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8191 + M o g r i f y I m a g e s %
8195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8197 % MogrifyImages() applies image processing options to a sequence of images as
8198 % prescribed by command line options.
8200 % The format of the MogrifyImage method is:
8202 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8203 % const MagickBooleanType post,const int argc,const char **argv,
8204 % Image **images,Exceptioninfo *exception)
8206 % A description of each parameter follows:
8208 % o image_info: the image info..
8210 % o post: If true, post process image list operators otherwise pre-process.
8212 % o argc: Specifies a pointer to an integer describing the number of
8213 % elements in the argument vector.
8215 % o argv: Specifies a pointer to a text array containing the command line
8218 % o images: pointer to a pointer of the first image in image list.
8220 % o exception: return any errors or warnings in this structure.
8223 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8224 const MagickBooleanType post,const int argc,const char **argv,
8225 Image **images,ExceptionInfo *exception)
8227 #define MogrifyImageTag "Mogrify/Image"
8241 assert(image_info != (ImageInfo *) NULL);
8242 assert(image_info->signature == MagickSignature);
8243 if (images == (Image **) NULL)
8244 return(MogrifyImage(image_info,argc,argv,images,exception));
8245 assert((*images)->previous == (Image *) NULL);
8246 assert((*images)->signature == MagickSignature);
8247 if ((*images)->debug != MagickFalse)
8248 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8249 (*images)->filename);
8250 if ((argc <= 0) || (*argv == (char *) NULL))
8252 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8257 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8262 Pre-process multi-image sequence operators
8264 if (post == MagickFalse)
8265 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8267 For each image, process simple single image operators
8270 n=GetImageListLength(*images);
8274 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8275 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8277 status&=MogrifyImage(image_info,argc,argv,images,exception);
8278 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8279 if (proceed == MagickFalse)
8281 if ( (*images)->next == (Image *) NULL )
8283 *images=(*images)->next;
8286 assert( *images != (Image *) NULL );
8288 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8289 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8293 Post-process, multi-image sequence operators
8295 *images=GetFirstImageInList(*images);
8296 if (post != MagickFalse)
8297 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8298 return(status != 0 ? MagickTrue : MagickFalse);