2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
13 % MagickWand Module Methods %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/string-private.h"
60 #define UndefinedCompressionQuality 0UL
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % M a g i c k C o m m a n d G e n e s i s %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % MagickCommandGenesis() applies image processing options to an image as
74 % prescribed by command line options.
76 % The format of the MagickCommandGenesis method is:
78 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
79 % MagickCommand command,int argc,char **argv,char **metadata,
80 % ExceptionInfo *exception)
82 % A description of each parameter follows:
84 % o image_info: the image info.
86 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
87 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
88 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
89 % DisplayImageCommand, or AnimateImageCommand.
91 % o argc: Specifies a pointer to an integer describing the number of
92 % elements in the argument vector.
94 % o argv: Specifies a pointer to a text array containing the command line
97 % o metadata: any metadata is returned here.
99 % o exception: return any errors or warnings in this structure.
102 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
103 MagickCommand command,int argc,char **argv,char **metadata,
104 ExceptionInfo *exception)
128 (void) setlocale(LC_ALL,"");
129 (void) setlocale(LC_NUMERIC,"C");
130 concurrent=MagickFalse;
134 regard_warnings=MagickFalse;
135 for (i=1; i < (ssize_t) (argc-1); i++)
138 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
140 if (LocaleCompare("bench",option+1) == 0)
141 iterations=StringToUnsignedLong(argv[++i]);
142 if (LocaleCompare("concurrent",option+1) == 0)
143 concurrent=MagickTrue;
144 if (LocaleCompare("debug",option+1) == 0)
145 (void) SetLogEventMask(argv[++i]);
146 if (LocaleCompare("duration",option+1) == 0)
147 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
148 if (LocaleCompare("regard-warnings",option+1) == 0)
149 regard_warnings=MagickTrue;
151 timer=AcquireTimerInfo();
152 if (concurrent == MagickFalse)
154 for (i=0; i < (ssize_t) iterations; i++)
156 if (status != MagickFalse)
160 if (GetElapsedTime(timer) > duration)
162 (void) ContinueTimer(timer);
164 status=command(image_info,argc,argv,metadata,exception);
165 if (exception->severity != UndefinedException)
167 if ((exception->severity > ErrorException) ||
168 (regard_warnings != MagickFalse))
170 CatchException(exception);
172 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
174 (void) fputs(*metadata,stdout);
175 (void) fputc('\n',stdout);
176 *metadata=DestroyString(*metadata);
183 #if defined(MAGICKCORE_OPENMP_SUPPORT)
184 # pragma omp parallel for shared(status)
186 for (i=0; i < (ssize_t) iterations; i++)
188 if (status != MagickFalse)
192 if (GetElapsedTime(timer) > duration)
194 (void) ContinueTimer(timer);
196 status=command(image_info,argc,argv,metadata,exception);
197 #if defined(MAGICKCORE_OPENMP_SUPPORT)
198 # pragma omp critical (MagickCore_CommandGenesis)
201 if (exception->severity != UndefinedException)
203 if ((exception->severity > ErrorException) ||
204 (regard_warnings != MagickFalse))
206 CatchException(exception);
208 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
210 (void) fputs(*metadata,stdout);
211 (void) fputc('\n',stdout);
212 *metadata=DestroyString(*metadata);
219 elapsed_time=GetElapsedTime(timer);
220 user_time=GetUserTime(timer);
221 (void) FormatLocaleFile(stderr,
222 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
223 iterations,1.0*iterations/elapsed_time,user_time,(double)
224 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
225 (1000.0*(elapsed_time-floor(elapsed_time))));
226 (void) fflush(stderr);
228 timer=DestroyTimerInfo(timer);
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 + M o g r i f y I m a g e %
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % MogrifyImage() applies simple single image processing options to a single
244 % image that may be part of a large list, but also handles any 'region'
247 % The image in the list may be modified in three different ways...
249 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
250 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
251 % * replace by a list of images (only the -separate option!)
253 % In each case the result is returned into the list, and a pointer to the
254 % modified image (last image added if replaced by a list of images) is
257 % ASIDE: The -crop is present but restricted to non-tile single image crops
259 % This means if all the images are being processed (such as by
260 % MogrifyImages(), next image to be processed will be as per the pointer
261 % (*image)->next. Also the image list may grow as a result of some specific
262 % operations but as images are never merged or deleted, it will never shrink
263 % in length. Typically the list will remain the same length.
265 % WARNING: As the image pointed to may be replaced, the first image in the
266 % list may also change. GetFirstImageInList() should be used by caller if
267 % they wish return the Image pointer to the first image in list.
270 % The format of the MogrifyImage method is:
272 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
273 % const char **argv,Image **image)
275 % A description of each parameter follows:
277 % o image_info: the image info..
279 % o argc: Specifies a pointer to an integer describing the number of
280 % elements in the argument vector.
282 % o argv: Specifies a pointer to a text array containing the command line
285 % o image: the image.
287 % o exception: return any errors or warnings in this structure.
292 ** GetImageCache() will read an image into a image cache if not already
293 ** present then return the image that is in the cache under that filename.
295 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
296 ExceptionInfo *exception)
310 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
311 sans_exception=AcquireExceptionInfo();
312 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
313 sans_exception=DestroyExceptionInfo(sans_exception);
314 if (image != (Image *) NULL)
316 read_info=CloneImageInfo(image_info);
317 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
318 image=ReadImage(read_info,exception);
319 read_info=DestroyImageInfo(read_info);
320 if (image != (Image *) NULL)
321 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
325 static MagickBooleanType IsPathWritable(const char *path)
327 if (IsPathAccessible(path) == MagickFalse)
329 if (access(path,W_OK) != 0)
334 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
341 static MagickBooleanType MonitorProgress(const char *text,
342 const MagickOffsetType offset,const MagickSizeType extent,
343 void *wand_unused(client_data))
346 message[MaxTextExtent],
357 (void) CopyMagickMemory(tag,text,MaxTextExtent);
359 if (p != (char *) NULL)
361 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
362 locale_message=GetLocaleMessage(message);
363 if (locale_message == message)
365 if (p == (char *) NULL)
366 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
367 locale_message,(long) offset,(unsigned long) extent,(long)
368 (100L*offset/(extent-1)));
370 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
371 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
372 (100L*offset/(extent-1)));
373 if (offset == (MagickOffsetType) (extent-1))
374 (void) FormatLocaleFile(stderr,"\n");
375 (void) fflush(stderr);
380 ** SparseColorOption() parses the complex -sparse-color argument into an
381 ** an array of floating point values then calls SparseColorImage().
382 ** Argument is a complex mix of floating-point pixel coodinates, and color
383 ** specifications (or direct floating point numbers). The number of floats
384 ** needed to represent a color varies depending on the current channel
387 static Image *SparseColorOption(const Image *image,const ChannelType channel,
388 const SparseColorMethod method,const char *arguments,
389 const MagickBooleanType color_from_image,ExceptionInfo *exception)
395 token[MaxTextExtent];
419 assert(image != (Image *) NULL);
420 assert(image->signature == MagickSignature);
421 if (image->debug != MagickFalse)
422 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
423 assert(exception != (ExceptionInfo *) NULL);
424 assert(exception->signature == MagickSignature);
426 Limit channels according to image - and add up number of color channel.
429 if (image->colorspace != CMYKColorspace)
430 channels=(ChannelType) (channels & ~BlackChannel); /* no black channel */
431 if (image->matte == MagickFalse)
432 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
434 if ((channels & RedChannel) != 0)
436 if ((channels & GreenChannel) != 0)
438 if ((channels & BlueChannel) != 0)
440 if ((channels & BlackChannel) != 0)
442 if ((channels & OpacityChannel) != 0)
446 Read string, to determine number of arguments needed,
452 GetMagickToken(p,&p,token);
453 if ( token[0] == ',' ) continue;
454 if ( isalpha((int) token[0]) || token[0] == '#' ) {
455 if ( color_from_image ) {
456 (void) ThrowMagickException(exception,GetMagickModule(),
457 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
458 "Color arg given, when colors are coming from image");
459 return( (Image *)NULL);
461 x += number_colors; /* color argument */
464 x++; /* floating point argument */
468 if ( color_from_image ) {
469 /* just the control points are being given */
470 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
471 number_arguments=(x/2)*(2+number_colors);
474 /* control points and color values */
475 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
479 (void) ThrowMagickException(exception,GetMagickModule(),
480 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
481 "Invalid number of Arguments");
482 return( (Image *)NULL);
485 /* Allocate and fill in the floating point arguments */
486 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
487 sizeof(*sparse_arguments));
488 if (sparse_arguments == (double *) NULL) {
489 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
490 "MemoryAllocationFailed","%s","SparseColorOption");
491 return( (Image *)NULL);
493 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
494 sizeof(*sparse_arguments));
497 while( *p != '\0' && x < number_arguments ) {
499 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
500 if ( token[0] == '\0' ) break;
501 if ( isalpha((int) token[0]) || token[0] == '#' ) {
502 (void) ThrowMagickException(exception,GetMagickModule(),
503 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
504 "Color found, instead of X-coord");
508 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
510 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
511 if ( token[0] == '\0' ) break;
512 if ( isalpha((int) token[0]) || token[0] == '#' ) {
513 (void) ThrowMagickException(exception,GetMagickModule(),
514 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
515 "Color found, instead of Y-coord");
519 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
520 /* color values for this control point */
522 if ( (color_from_image ) {
523 /* get color from image */
529 /* color name or function given in string argument */
530 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
531 if ( token[0] == '\0' ) break;
532 if ( isalpha((int) token[0]) || token[0] == '#' ) {
533 /* Color string given */
534 (void) QueryMagickColor(token,&color,exception);
535 if (channels & RedChannel)
536 sparse_arguments[x++] = QuantumScale*color.red;
537 if (channels & GreenChannel)
538 sparse_arguments[x++] = QuantumScale*color.green;
539 if (channels & BlueChannel)
540 sparse_arguments[x++] = QuantumScale*color.blue;
541 if (channels & BlackChannel)
542 sparse_arguments[x++] = QuantumScale*color.black;
543 if (channels & OpacityChannel)
544 sparse_arguments[x++] = QuantumScale*color.alpha;
547 /* Colors given as a set of floating point values - experimental */
548 /* NB: token contains the first floating point value to use! */
549 if ( channels & RedChannel ) {
550 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
551 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
553 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
554 token[0] = ','; /* used this token - get another */
556 if ( channels & GreenChannel ) {
557 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
558 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
560 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
561 token[0] = ','; /* used this token - get another */
563 if ( channels & BlueChannel ) {
564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
568 token[0] = ','; /* used this token - get another */
570 if (channels & BlackChannel) {
571 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
572 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
574 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
575 token[0] = ','; /* used this token - get another */
577 if ( channels & OpacityChannel ) {
578 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
579 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
581 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
582 token[0] = ','; /* used this token - get another */
587 if ( number_arguments != x && !error ) {
588 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
589 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
590 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
591 return( (Image *)NULL);
594 return( (Image *)NULL);
596 /* Call the Interpolation function with the parsed arguments */
597 sparse_image=SparseColorImage(image,channels,method,number_arguments,
598 sparse_arguments,exception);
599 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
600 return( sparse_image );
603 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
604 const char **argv,Image **image,ExceptionInfo *exception)
645 Initialize method variables.
647 assert(image_info != (const ImageInfo *) NULL);
648 assert(image_info->signature == MagickSignature);
649 assert(image != (Image **) NULL);
650 assert((*image)->signature == MagickSignature);
651 if ((*image)->debug != MagickFalse)
652 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
655 mogrify_info=CloneImageInfo(image_info);
656 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
657 quantize_info=AcquireQuantizeInfo(mogrify_info);
658 SetGeometryInfo(&geometry_info);
659 GetPixelInfo(*image,&fill);
660 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
661 channel=mogrify_info->channel;
662 format=GetImageOption(mogrify_info,"format");
663 SetGeometry(*image,®ion_geometry);
664 region_image=NewImageList();
666 Transmogrify the image.
668 for (i=0; i < (ssize_t) argc; i++)
677 if (IsCommandOption(option) == MagickFalse)
679 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
681 if ((i+count) >= (ssize_t) argc)
683 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
684 mogrify_image=(Image *)NULL;
689 if (LocaleCompare("adaptive-blur",option+1) == 0)
694 (void) SyncImageSettings(mogrify_info,*image);
695 flags=ParseGeometry(argv[i+1],&geometry_info);
696 if ((flags & SigmaValue) == 0)
697 geometry_info.sigma=1.0;
698 mogrify_image=AdaptiveBlurImageChannel(*image,channel,
699 geometry_info.rho,geometry_info.sigma,exception);
702 if (LocaleCompare("adaptive-resize",option+1) == 0)
705 Adaptive resize image.
707 (void) SyncImageSettings(mogrify_info,*image);
708 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
709 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
710 geometry.height,exception);
713 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
716 Adaptive sharpen image.
718 (void) SyncImageSettings(mogrify_info,*image);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
722 mogrify_image=AdaptiveSharpenImageChannel(*image,channel,
723 geometry_info.rho,geometry_info.sigma,exception);
726 if (LocaleCompare("affine",option+1) == 0)
733 GetAffineMatrix(&draw_info->affine);
736 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
739 if (LocaleCompare("alpha",option+1) == 0)
744 (void) SyncImageSettings(mogrify_info,*image);
745 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
746 MagickFalse,argv[i+1]);
747 (void) SetImageAlphaChannel(*image,alpha_type);
748 InheritException(exception,&(*image)->exception);
751 if (LocaleCompare("annotate",option+1) == 0)
755 geometry[MaxTextExtent];
760 (void) SyncImageSettings(mogrify_info,*image);
761 SetGeometryInfo(&geometry_info);
762 flags=ParseGeometry(argv[i+1],&geometry_info);
763 if ((flags & SigmaValue) == 0)
764 geometry_info.sigma=geometry_info.rho;
765 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
766 InheritException(exception,&(*image)->exception);
767 if (text == (char *) NULL)
769 (void) CloneString(&draw_info->text,text);
770 text=DestroyString(text);
771 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
772 geometry_info.xi,geometry_info.psi);
773 (void) CloneString(&draw_info->geometry,geometry);
774 draw_info->affine.sx=cos(DegreesToRadians(
775 fmod(geometry_info.rho,360.0)));
776 draw_info->affine.rx=sin(DegreesToRadians(
777 fmod(geometry_info.rho,360.0)));
778 draw_info->affine.ry=(-sin(DegreesToRadians(
779 fmod(geometry_info.sigma,360.0))));
780 draw_info->affine.sy=cos(DegreesToRadians(
781 fmod(geometry_info.sigma,360.0)));
782 (void) AnnotateImage(*image,draw_info);
783 InheritException(exception,&(*image)->exception);
786 if (LocaleCompare("antialias",option+1) == 0)
788 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
790 draw_info->text_antialias=(*option == '-') ? MagickTrue :
794 if (LocaleCompare("auto-gamma",option+1) == 0)
797 Auto Adjust Gamma of image based on its mean
799 (void) SyncImageSettings(mogrify_info,*image);
800 (void) AutoGammaImage(*image);
803 if (LocaleCompare("auto-level",option+1) == 0)
806 Perfectly Normalize (max/min stretch) the image
808 (void) SyncImageSettings(mogrify_info,*image);
809 (void) AutoLevelImage(*image);
812 if (LocaleCompare("auto-orient",option+1) == 0)
814 (void) SyncImageSettings(mogrify_info,*image);
815 switch ((*image)->orientation)
817 case TopRightOrientation:
819 mogrify_image=FlopImage(*image,exception);
822 case BottomRightOrientation:
824 mogrify_image=RotateImage(*image,180.0,exception);
827 case BottomLeftOrientation:
829 mogrify_image=FlipImage(*image,exception);
832 case LeftTopOrientation:
834 mogrify_image=TransposeImage(*image,exception);
837 case RightTopOrientation:
839 mogrify_image=RotateImage(*image,90.0,exception);
842 case RightBottomOrientation:
844 mogrify_image=TransverseImage(*image,exception);
847 case LeftBottomOrientation:
849 mogrify_image=RotateImage(*image,270.0,exception);
855 if (mogrify_image != (Image *) NULL)
856 mogrify_image->orientation=TopLeftOrientation;
863 if (LocaleCompare("black-threshold",option+1) == 0)
866 Black threshold image.
868 (void) SyncImageSettings(mogrify_info,*image);
869 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
871 InheritException(exception,&(*image)->exception);
874 if (LocaleCompare("blue-shift",option+1) == 0)
879 (void) SyncImageSettings(mogrify_info,*image);
880 geometry_info.rho=1.5;
882 flags=ParseGeometry(argv[i+1],&geometry_info);
883 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
886 if (LocaleCompare("blur",option+1) == 0)
891 (void) SyncImageSettings(mogrify_info,*image);
892 flags=ParseGeometry(argv[i+1],&geometry_info);
893 if ((flags & SigmaValue) == 0)
894 geometry_info.sigma=1.0;
895 mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho,
896 geometry_info.sigma,exception);
899 if (LocaleCompare("border",option+1) == 0)
902 Surround image with a border of solid color.
904 (void) SyncImageSettings(mogrify_info,*image);
905 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
906 if ((flags & SigmaValue) == 0)
907 geometry.height=geometry.width;
908 mogrify_image=BorderImage(*image,&geometry,exception);
911 if (LocaleCompare("bordercolor",option+1) == 0)
915 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
919 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
923 if (LocaleCompare("box",option+1) == 0)
925 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
929 if (LocaleCompare("brightness-contrast",option+1) == 0)
942 Brightness / contrast image.
944 (void) SyncImageSettings(mogrify_info,*image);
945 flags=ParseGeometry(argv[i+1],&geometry_info);
946 brightness=geometry_info.rho;
948 if ((flags & SigmaValue) != 0)
949 contrast=geometry_info.sigma;
950 (void) BrightnessContrastImageChannel(*image,channel,brightness,
952 InheritException(exception,&(*image)->exception);
959 if (LocaleCompare("cdl",option+1) == 0)
962 *color_correction_collection;
965 Color correct with a color decision list.
967 (void) SyncImageSettings(mogrify_info,*image);
968 color_correction_collection=FileToString(argv[i+1],~0,exception);
969 if (color_correction_collection == (char *) NULL)
971 (void) ColorDecisionListImage(*image,color_correction_collection);
972 InheritException(exception,&(*image)->exception);
975 if (LocaleCompare("channel",option+1) == 0)
978 channel=DefaultChannels;
980 channel=(ChannelType) ParseChannelOption(argv[i+1]);
981 SetPixelComponentMap(*image,channel);
984 if (LocaleCompare("charcoal",option+1) == 0)
989 (void) SyncImageSettings(mogrify_info,*image);
990 flags=ParseGeometry(argv[i+1],&geometry_info);
991 if ((flags & SigmaValue) == 0)
992 geometry_info.sigma=1.0;
993 mogrify_image=CharcoalImage(*image,geometry_info.rho,
994 geometry_info.sigma,exception);
997 if (LocaleCompare("chop",option+1) == 0)
1002 (void) SyncImageSettings(mogrify_info,*image);
1003 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1004 mogrify_image=ChopImage(*image,&geometry,exception);
1007 if (LocaleCompare("clamp",option+1) == 0)
1012 (void) SyncImageSettings(mogrify_info,*image);
1013 (void) ClampImageChannel(*image,channel);
1014 InheritException(exception,&(*image)->exception);
1017 if (LocaleCompare("clip",option+1) == 0)
1019 (void) SyncImageSettings(mogrify_info,*image);
1022 (void) SetImageClipMask(*image,(Image *) NULL);
1023 InheritException(exception,&(*image)->exception);
1026 (void) ClipImage(*image);
1027 InheritException(exception,&(*image)->exception);
1030 if (LocaleCompare("clip-mask",option+1) == 0)
1047 (void) SyncImageSettings(mogrify_info,*image);
1053 (void) SetImageMask(*image,(Image *) NULL);
1054 InheritException(exception,&(*image)->exception);
1059 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1061 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1062 if (mask_image == (Image *) NULL)
1064 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1065 return(MagickFalse);
1066 mask_view=AcquireCacheView(mask_image);
1067 for (y=0; y < (ssize_t) mask_image->rows; y++)
1069 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1071 if (q == (const Quantum *) NULL)
1073 for (x=0; x < (ssize_t) mask_image->columns; x++)
1075 if (mask_image->matte == MagickFalse)
1076 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1077 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1078 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1079 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1080 q+=GetPixelChannels(mask_image);
1082 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1085 mask_view=DestroyCacheView(mask_view);
1086 mask_image->matte=MagickTrue;
1087 (void) SetImageClipMask(*image,mask_image);
1088 mask_image=DestroyImage(mask_image);
1089 InheritException(exception,&(*image)->exception);
1092 if (LocaleCompare("clip-path",option+1) == 0)
1094 (void) SyncImageSettings(mogrify_info,*image);
1095 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1097 InheritException(exception,&(*image)->exception);
1100 if (LocaleCompare("colorize",option+1) == 0)
1105 (void) SyncImageSettings(mogrify_info,*image);
1106 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1110 if (LocaleCompare("color-matrix",option+1) == 0)
1115 (void) SyncImageSettings(mogrify_info,*image);
1116 kernel=AcquireKernelInfo(argv[i+1]);
1117 if (kernel == (KernelInfo *) NULL)
1119 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1120 kernel=DestroyKernelInfo(kernel);
1123 if (LocaleCompare("colors",option+1) == 0)
1126 Reduce the number of colors in the image.
1128 (void) SyncImageSettings(mogrify_info,*image);
1129 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1130 if (quantize_info->number_colors == 0)
1132 if (((*image)->storage_class == DirectClass) ||
1133 (*image)->colors > quantize_info->number_colors)
1134 (void) QuantizeImage(quantize_info,*image);
1136 (void) CompressImageColormap(*image);
1137 InheritException(exception,&(*image)->exception);
1140 if (LocaleCompare("colorspace",option+1) == 0)
1145 (void) SyncImageSettings(mogrify_info,*image);
1148 (void) TransformImageColorspace(*image,RGBColorspace);
1149 InheritException(exception,&(*image)->exception);
1152 colorspace=(ColorspaceType) ParseCommandOption(
1153 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1154 (void) TransformImageColorspace(*image,colorspace);
1155 InheritException(exception,&(*image)->exception);
1158 if (LocaleCompare("contrast",option+1) == 0)
1160 (void) SyncImageSettings(mogrify_info,*image);
1161 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1163 InheritException(exception,&(*image)->exception);
1166 if (LocaleCompare("contrast-stretch",option+1) == 0)
1176 Contrast stretch image.
1178 (void) SyncImageSettings(mogrify_info,*image);
1179 flags=ParseGeometry(argv[i+1],&geometry_info);
1180 black_point=geometry_info.rho;
1181 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1183 if ((flags & PercentValue) != 0)
1185 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1186 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1188 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1190 (void) ContrastStretchImageChannel(*image,channel,black_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=FilterImageChannel(*image,channel,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) EqualizeImageChannel(*image,channel);
1489 InheritException(exception,&(*image)->exception);
1492 if (LocaleCompare("evaluate",option+1) == 0)
1497 MagickEvaluateOperator
1500 (void) SyncImageSettings(mogrify_info,*image);
1501 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
1502 MagickFalse,argv[i+1]);
1503 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1504 (void) EvaluateImageChannel(*image,channel,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,channel,draw_info,&target,
1590 geometry.x,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) FunctionImageChannel(*image,channel,function,
1698 number_parameters,parameters,exception);
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 if (strchr(argv[i+1],',') != (char *) NULL)
1717 (void) GammaImage(*image,argv[i+1]);
1719 (void) GammaImageChannel(*image,channel,
1720 InterpretLocaleValue(argv[i+1],(char **) NULL));
1721 InheritException(exception,&(*image)->exception);
1725 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1726 (LocaleCompare("gaussian",option+1) == 0))
1729 Gaussian blur image.
1731 (void) SyncImageSettings(mogrify_info,*image);
1732 flags=ParseGeometry(argv[i+1],&geometry_info);
1733 if ((flags & SigmaValue) == 0)
1734 geometry_info.sigma=1.0;
1735 mogrify_image=GaussianBlurImageChannel(*image,channel,
1736 geometry_info.rho,geometry_info.sigma,exception);
1739 if (LocaleCompare("geometry",option+1) == 0)
1742 Record Image offset, Resize last image.
1744 (void) SyncImageSettings(mogrify_info,*image);
1747 if ((*image)->geometry != (char *) NULL)
1748 (*image)->geometry=DestroyString((*image)->geometry);
1751 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1752 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1753 (void) CloneString(&(*image)->geometry,argv[i+1]);
1755 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1756 (*image)->filter,(*image)->blur,exception);
1759 if (LocaleCompare("gravity",option+1) == 0)
1763 draw_info->gravity=UndefinedGravity;
1766 draw_info->gravity=(GravityType) ParseCommandOption(
1767 MagickGravityOptions,MagickFalse,argv[i+1]);
1774 if (LocaleCompare("highlight-color",option+1) == 0)
1776 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1783 if (LocaleCompare("identify",option+1) == 0)
1788 (void) SyncImageSettings(mogrify_info,*image);
1789 if (format == (char *) NULL)
1791 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1792 InheritException(exception,&(*image)->exception);
1795 text=InterpretImageProperties(mogrify_info,*image,format);
1796 InheritException(exception,&(*image)->exception);
1797 if (text == (char *) NULL)
1799 (void) fputs(text,stdout);
1800 (void) fputc('\n',stdout);
1801 text=DestroyString(text);
1804 if (LocaleCompare("implode",option+1) == 0)
1809 (void) SyncImageSettings(mogrify_info,*image);
1810 (void) ParseGeometry(argv[i+1],&geometry_info);
1811 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1814 if (LocaleCompare("interline-spacing",option+1) == 0)
1817 (void) ParseGeometry("0",&geometry_info);
1819 (void) ParseGeometry(argv[i+1],&geometry_info);
1820 draw_info->interline_spacing=geometry_info.rho;
1823 if (LocaleCompare("interword-spacing",option+1) == 0)
1826 (void) ParseGeometry("0",&geometry_info);
1828 (void) ParseGeometry(argv[i+1],&geometry_info);
1829 draw_info->interword_spacing=geometry_info.rho;
1836 if (LocaleCompare("kerning",option+1) == 0)
1839 (void) ParseGeometry("0",&geometry_info);
1841 (void) ParseGeometry(argv[i+1],&geometry_info);
1842 draw_info->kerning=geometry_info.rho;
1849 if (LocaleCompare("lat",option+1) == 0)
1852 Local adaptive threshold image.
1854 (void) SyncImageSettings(mogrify_info,*image);
1855 flags=ParseGeometry(argv[i+1],&geometry_info);
1856 if ((flags & PercentValue) != 0)
1857 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1858 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1859 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1860 geometry_info.xi,exception);
1863 if (LocaleCompare("level",option+1) == 0)
1876 (void) SyncImageSettings(mogrify_info,*image);
1877 flags=ParseGeometry(argv[i+1],&geometry_info);
1878 black_point=geometry_info.rho;
1879 white_point=(MagickRealType) QuantumRange;
1880 if ((flags & SigmaValue) != 0)
1881 white_point=geometry_info.sigma;
1883 if ((flags & XiValue) != 0)
1884 gamma=geometry_info.xi;
1885 if ((flags & PercentValue) != 0)
1887 black_point*=(MagickRealType) (QuantumRange/100.0);
1888 white_point*=(MagickRealType) (QuantumRange/100.0);
1890 if ((flags & SigmaValue) == 0)
1891 white_point=(MagickRealType) QuantumRange-black_point;
1892 if ((*option == '+') || ((flags & AspectValue) != 0))
1893 (void) LevelizeImageChannel(*image,channel,black_point,
1896 (void) LevelImageChannel(*image,channel,black_point,white_point,
1898 InheritException(exception,&(*image)->exception);
1901 if (LocaleCompare("level-colors",option+1) == 0)
1904 token[MaxTextExtent];
1913 p=(const char *) argv[i+1];
1914 GetMagickToken(p,&p,token); /* get black point color */
1915 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1916 (void) QueryMagickColor(token,&black_point,exception);
1918 (void) QueryMagickColor("#000000",&black_point,exception);
1919 if (isalpha((int) token[0]) || (token[0] == '#'))
1920 GetMagickToken(p,&p,token);
1922 white_point=black_point; /* set everything to that color */
1925 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1926 GetMagickToken(p,&p,token); /* Get white point color. */
1927 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1928 (void) QueryMagickColor(token,&white_point,exception);
1930 (void) QueryMagickColor("#ffffff",&white_point,exception);
1932 (void) LevelColorsImageChannel(*image,channel,&black_point,
1933 &white_point,*option == '+' ? MagickTrue : MagickFalse);
1936 if (LocaleCompare("linear-stretch",option+1) == 0)
1945 (void) SyncImageSettings(mogrify_info,*image);
1946 flags=ParseGeometry(argv[i+1],&geometry_info);
1947 black_point=geometry_info.rho;
1948 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1949 if ((flags & SigmaValue) != 0)
1950 white_point=geometry_info.sigma;
1951 if ((flags & PercentValue) != 0)
1953 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1954 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1956 if ((flags & SigmaValue) == 0)
1957 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1959 (void) LinearStretchImage(*image,black_point,white_point);
1960 InheritException(exception,&(*image)->exception);
1963 if (LocaleCompare("linewidth",option+1) == 0)
1965 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1969 if (LocaleCompare("liquid-rescale",option+1) == 0)
1972 Liquid rescale image.
1974 (void) SyncImageSettings(mogrify_info,*image);
1975 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1976 if ((flags & XValue) == 0)
1978 if ((flags & YValue) == 0)
1980 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1981 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1984 if (LocaleCompare("lowlight-color",option+1) == 0)
1986 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1993 if (LocaleCompare("map",option+1) == 0)
1999 Transform image colors to match this set of colors.
2001 (void) SyncImageSettings(mogrify_info,*image);
2004 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2005 if (remap_image == (Image *) NULL)
2007 (void) RemapImage(quantize_info,*image,remap_image);
2008 InheritException(exception,&(*image)->exception);
2009 remap_image=DestroyImage(remap_image);
2012 if (LocaleCompare("mask",option+1) == 0)
2017 (void) SyncImageSettings(mogrify_info,*image);
2023 (void) SetImageMask(*image,(Image *) NULL);
2024 InheritException(exception,&(*image)->exception);
2030 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2031 if (mask == (Image *) NULL)
2033 (void) SetImageMask(*image,mask);
2034 mask=DestroyImage(mask);
2035 InheritException(exception,&(*image)->exception);
2038 if (LocaleCompare("matte",option+1) == 0)
2040 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2041 SetAlphaChannel : DeactivateAlphaChannel );
2042 InheritException(exception,&(*image)->exception);
2045 if (LocaleCompare("median",option+1) == 0)
2048 Median filter image.
2050 (void) SyncImageSettings(mogrify_info,*image);
2051 (void) ParseGeometry(argv[i+1],&geometry_info);
2052 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2053 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2056 if (LocaleCompare("mode",option+1) == 0)
2061 (void) SyncImageSettings(mogrify_info,*image);
2062 (void) ParseGeometry(argv[i+1],&geometry_info);
2063 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2064 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2067 if (LocaleCompare("modulate",option+1) == 0)
2069 (void) SyncImageSettings(mogrify_info,*image);
2070 (void) ModulateImage(*image,argv[i+1]);
2071 InheritException(exception,&(*image)->exception);
2074 if (LocaleCompare("monitor",option+1) == 0)
2078 (void) SetImageProgressMonitor(*image,
2079 (MagickProgressMonitor) NULL,(void *) NULL);
2082 (void) SetImageProgressMonitor(*image,MonitorProgress,
2086 if (LocaleCompare("monochrome",option+1) == 0)
2088 (void) SyncImageSettings(mogrify_info,*image);
2089 (void) SetImageType(*image,BilevelType);
2090 InheritException(exception,&(*image)->exception);
2093 if (LocaleCompare("morphology",option+1) == 0)
2096 token[MaxTextExtent];
2111 Morphological Image Operation
2113 (void) SyncImageSettings(mogrify_info,*image);
2115 GetMagickToken(p,&p,token);
2116 method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions,
2119 GetMagickToken(p,&p,token);
2120 if ((*p == ':') || (*p == ','))
2121 GetMagickToken(p,&p,token);
2123 iterations=(ssize_t) StringToLong(p);
2124 kernel=AcquireKernelInfo(argv[i+2]);
2125 if (kernel == (KernelInfo *) NULL)
2127 (void) ThrowMagickException(exception,GetMagickModule(),
2128 OptionError,"UnabletoParseKernel","morphology");
2132 mogrify_image=MorphologyImageChannel(*image,channel,method,
2133 iterations,kernel,exception);
2134 kernel=DestroyKernelInfo(kernel);
2137 if (LocaleCompare("motion-blur",option+1) == 0)
2142 (void) SyncImageSettings(mogrify_info,*image);
2143 flags=ParseGeometry(argv[i+1],&geometry_info);
2144 if ((flags & SigmaValue) == 0)
2145 geometry_info.sigma=1.0;
2146 mogrify_image=MotionBlurImageChannel(*image,channel,
2147 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2154 if (LocaleCompare("negate",option+1) == 0)
2156 (void) SyncImageSettings(mogrify_info,*image);
2157 (void) NegateImageChannel(*image,channel,*option == '+' ?
2158 MagickTrue : MagickFalse);
2159 InheritException(exception,&(*image)->exception);
2162 if (LocaleCompare("noise",option+1) == 0)
2164 (void) SyncImageSettings(mogrify_info,*image);
2167 (void) ParseGeometry(argv[i+1],&geometry_info);
2168 mogrify_image=StatisticImageChannel(*image,channel,
2169 NonpeakStatistic,(size_t) geometry_info.rho,(size_t)
2170 geometry_info.rho,exception);
2177 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2178 MagickFalse,argv[i+1]);
2179 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2184 if (LocaleCompare("normalize",option+1) == 0)
2186 (void) SyncImageSettings(mogrify_info,*image);
2187 (void) NormalizeImageChannel(*image,channel);
2188 InheritException(exception,&(*image)->exception);
2195 if (LocaleCompare("opaque",option+1) == 0)
2200 (void) SyncImageSettings(mogrify_info,*image);
2201 (void) QueryMagickColor(argv[i+1],&target,exception);
2202 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2203 *option == '-' ? MagickFalse : MagickTrue);
2206 if (LocaleCompare("ordered-dither",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image);
2209 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2217 if (LocaleCompare("paint",option+1) == 0)
2219 (void) SyncImageSettings(mogrify_info,*image);
2220 (void) ParseGeometry(argv[i+1],&geometry_info);
2221 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2224 if (LocaleCompare("pen",option+1) == 0)
2228 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2231 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2234 if (LocaleCompare("pointsize",option+1) == 0)
2237 (void) ParseGeometry("12",&geometry_info);
2239 (void) ParseGeometry(argv[i+1],&geometry_info);
2240 draw_info->pointsize=geometry_info.rho;
2243 if (LocaleCompare("polaroid",option+1) == 0)
2252 Simulate a Polaroid picture.
2254 (void) SyncImageSettings(mogrify_info,*image);
2255 random_info=AcquireRandomInfo();
2256 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2257 random_info=DestroyRandomInfo(random_info);
2260 SetGeometryInfo(&geometry_info);
2261 flags=ParseGeometry(argv[i+1],&geometry_info);
2262 angle=geometry_info.rho;
2264 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2267 if (LocaleCompare("posterize",option+1) == 0)
2272 (void) SyncImageSettings(mogrify_info,*image);
2273 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2274 quantize_info->dither);
2275 InheritException(exception,&(*image)->exception);
2278 if (LocaleCompare("preview",option+1) == 0)
2286 (void) SyncImageSettings(mogrify_info,*image);
2288 preview_type=UndefinedPreview;
2290 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
2291 MagickFalse,argv[i+1]);
2292 mogrify_image=PreviewImage(*image,preview_type,exception);
2295 if (LocaleCompare("profile",option+1) == 0)
2309 (void) SyncImageSettings(mogrify_info,*image);
2313 Remove a profile from the image.
2315 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2317 InheritException(exception,&(*image)->exception);
2321 Associate a profile with the image.
2323 profile_info=CloneImageInfo(mogrify_info);
2324 profile=GetImageProfile(*image,"iptc");
2325 if (profile != (StringInfo *) NULL)
2326 profile_info->profile=(void *) CloneStringInfo(profile);
2327 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2328 profile_info=DestroyImageInfo(profile_info);
2329 if (profile_image == (Image *) NULL)
2334 profile_info=CloneImageInfo(mogrify_info);
2335 (void) CopyMagickString(profile_info->filename,argv[i+1],
2337 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2338 if (profile != (StringInfo *) NULL)
2340 (void) ProfileImage(*image,profile_info->magick,
2341 GetStringInfoDatum(profile),(size_t)
2342 GetStringInfoLength(profile),MagickFalse);
2343 profile=DestroyStringInfo(profile);
2345 profile_info=DestroyImageInfo(profile_info);
2348 ResetImageProfileIterator(profile_image);
2349 name=GetNextImageProfile(profile_image);
2350 while (name != (const char *) NULL)
2352 profile=GetImageProfile(profile_image,name);
2353 if (profile != (StringInfo *) NULL)
2354 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2355 (size_t) GetStringInfoLength(profile),MagickFalse);
2356 name=GetNextImageProfile(profile_image);
2358 profile_image=DestroyImage(profile_image);
2365 if (LocaleCompare("quantize",option+1) == 0)
2369 quantize_info->colorspace=UndefinedColorspace;
2372 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2373 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2380 if (LocaleCompare("radial-blur",option+1) == 0)
2385 (void) SyncImageSettings(mogrify_info,*image);
2386 mogrify_image=RadialBlurImageChannel(*image,channel,
2387 InterpretLocaleValue(argv[i+1],(char **) NULL),exception);
2390 if (LocaleCompare("raise",option+1) == 0)
2393 Surround image with a raise of solid color.
2395 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2396 if ((flags & SigmaValue) == 0)
2397 geometry.height=geometry.width;
2398 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2400 InheritException(exception,&(*image)->exception);
2403 if (LocaleCompare("random-threshold",option+1) == 0)
2408 (void) SyncImageSettings(mogrify_info,*image);
2409 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2413 if (LocaleCompare("recolor",option+1) == 0)
2418 (void) SyncImageSettings(mogrify_info,*image);
2419 kernel=AcquireKernelInfo(argv[i+1]);
2420 if (kernel == (KernelInfo *) NULL)
2422 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2423 kernel=DestroyKernelInfo(kernel);
2426 if (LocaleCompare("region",option+1) == 0)
2428 (void) SyncImageSettings(mogrify_info,*image);
2429 if (region_image != (Image *) NULL)
2434 (void) CompositeImage(region_image,region_image->matte !=
2435 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2436 region_geometry.x,region_geometry.y);
2437 InheritException(exception,®ion_image->exception);
2438 *image=DestroyImage(*image);
2439 *image=region_image;
2440 region_image = (Image *) NULL;
2445 Apply transformations to a selected region of the image.
2447 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2449 mogrify_image=CropImage(*image,®ion_geometry,exception);
2450 if (mogrify_image == (Image *) NULL)
2452 region_image=(*image);
2453 *image=mogrify_image;
2454 mogrify_image=(Image *) NULL;
2457 if (LocaleCompare("render",option+1) == 0)
2459 (void) SyncImageSettings(mogrify_info,*image);
2460 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2463 if (LocaleCompare("remap",option+1) == 0)
2469 Transform image colors to match this set of colors.
2471 (void) SyncImageSettings(mogrify_info,*image);
2474 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2475 if (remap_image == (Image *) NULL)
2477 (void) RemapImage(quantize_info,*image,remap_image);
2478 InheritException(exception,&(*image)->exception);
2479 remap_image=DestroyImage(remap_image);
2482 if (LocaleCompare("repage",option+1) == 0)
2486 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2489 (void) ResetImagePage(*image,argv[i+1]);
2490 InheritException(exception,&(*image)->exception);
2493 if (LocaleCompare("resample",option+1) == 0)
2498 (void) SyncImageSettings(mogrify_info,*image);
2499 flags=ParseGeometry(argv[i+1],&geometry_info);
2500 if ((flags & SigmaValue) == 0)
2501 geometry_info.sigma=geometry_info.rho;
2502 mogrify_image=ResampleImage(*image,geometry_info.rho,
2503 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2506 if (LocaleCompare("resize",option+1) == 0)
2511 (void) SyncImageSettings(mogrify_info,*image);
2512 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2513 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2514 (*image)->filter,(*image)->blur,exception);
2517 if (LocaleCompare("roll",option+1) == 0)
2522 (void) SyncImageSettings(mogrify_info,*image);
2523 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2524 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2527 if (LocaleCompare("rotate",option+1) == 0)
2533 Check for conditional image rotation.
2535 (void) SyncImageSettings(mogrify_info,*image);
2536 if (strchr(argv[i+1],'>') != (char *) NULL)
2537 if ((*image)->columns <= (*image)->rows)
2539 if (strchr(argv[i+1],'<') != (char *) NULL)
2540 if ((*image)->columns >= (*image)->rows)
2545 geometry=ConstantString(argv[i+1]);
2546 (void) SubstituteString(&geometry,">","");
2547 (void) SubstituteString(&geometry,"<","");
2548 (void) ParseGeometry(geometry,&geometry_info);
2549 geometry=DestroyString(geometry);
2550 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2557 if (LocaleCompare("sample",option+1) == 0)
2560 Sample image with pixel replication.
2562 (void) SyncImageSettings(mogrify_info,*image);
2563 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2564 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2568 if (LocaleCompare("scale",option+1) == 0)
2573 (void) SyncImageSettings(mogrify_info,*image);
2574 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2575 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2579 if (LocaleCompare("selective-blur",option+1) == 0)
2582 Selectively blur pixels within a contrast threshold.
2584 (void) SyncImageSettings(mogrify_info,*image);
2585 flags=ParseGeometry(argv[i+1],&geometry_info);
2586 if ((flags & PercentValue) != 0)
2587 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2588 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2589 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2592 if (LocaleCompare("separate",option+1) == 0)
2595 Break channels into separate images.
2596 WARNING: This can generate multiple images!
2598 (void) SyncImageSettings(mogrify_info,*image);
2599 mogrify_image=SeparateImages(*image,channel,exception);
2602 if (LocaleCompare("sepia-tone",option+1) == 0)
2610 (void) SyncImageSettings(mogrify_info,*image);
2611 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2612 mogrify_image=SepiaToneImage(*image,threshold,exception);
2615 if (LocaleCompare("segment",option+1) == 0)
2620 (void) SyncImageSettings(mogrify_info,*image);
2621 flags=ParseGeometry(argv[i+1],&geometry_info);
2622 if ((flags & SigmaValue) == 0)
2623 geometry_info.sigma=1.0;
2624 (void) SegmentImage(*image,(*image)->colorspace,
2625 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2626 InheritException(exception,&(*image)->exception);
2629 if (LocaleCompare("set",option+1) == 0)
2639 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2640 (void) DeleteImageRegistry(argv[i+1]+9);
2642 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2644 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2645 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2648 (void) DeleteImageProperty(*image,argv[i+1]);
2651 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2652 if (value == (char *) NULL)
2654 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2655 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2658 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2660 (void) SetImageOption(image_info,argv[i+1]+7,value);
2661 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2662 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2665 (void) SetImageProperty(*image,argv[i+1],value);
2666 value=DestroyString(value);
2669 if (LocaleCompare("shade",option+1) == 0)
2674 (void) SyncImageSettings(mogrify_info,*image);
2675 flags=ParseGeometry(argv[i+1],&geometry_info);
2676 if ((flags & SigmaValue) == 0)
2677 geometry_info.sigma=1.0;
2678 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2679 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2682 if (LocaleCompare("shadow",option+1) == 0)
2687 (void) SyncImageSettings(mogrify_info,*image);
2688 flags=ParseGeometry(argv[i+1],&geometry_info);
2689 if ((flags & SigmaValue) == 0)
2690 geometry_info.sigma=1.0;
2691 if ((flags & XiValue) == 0)
2692 geometry_info.xi=4.0;
2693 if ((flags & PsiValue) == 0)
2694 geometry_info.psi=4.0;
2695 mogrify_image=ShadowImage(*image,geometry_info.rho,
2696 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2697 ceil(geometry_info.psi-0.5),exception);
2700 if (LocaleCompare("sharpen",option+1) == 0)
2705 (void) SyncImageSettings(mogrify_info,*image);
2706 flags=ParseGeometry(argv[i+1],&geometry_info);
2707 if ((flags & SigmaValue) == 0)
2708 geometry_info.sigma=1.0;
2709 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2710 geometry_info.sigma,exception);
2713 if (LocaleCompare("shave",option+1) == 0)
2716 Shave the image edges.
2718 (void) SyncImageSettings(mogrify_info,*image);
2719 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2720 mogrify_image=ShaveImage(*image,&geometry,exception);
2723 if (LocaleCompare("shear",option+1) == 0)
2728 (void) SyncImageSettings(mogrify_info,*image);
2729 flags=ParseGeometry(argv[i+1],&geometry_info);
2730 if ((flags & SigmaValue) == 0)
2731 geometry_info.sigma=geometry_info.rho;
2732 mogrify_image=ShearImage(*image,geometry_info.rho,
2733 geometry_info.sigma,exception);
2736 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2739 Sigmoidal non-linearity contrast control.
2741 (void) SyncImageSettings(mogrify_info,*image);
2742 flags=ParseGeometry(argv[i+1],&geometry_info);
2743 if ((flags & SigmaValue) == 0)
2744 geometry_info.sigma=(double) QuantumRange/2.0;
2745 if ((flags & PercentValue) != 0)
2746 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2748 (void) SigmoidalContrastImageChannel(*image,channel,
2749 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
2750 geometry_info.sigma);
2751 InheritException(exception,&(*image)->exception);
2754 if (LocaleCompare("sketch",option+1) == 0)
2759 (void) SyncImageSettings(mogrify_info,*image);
2760 flags=ParseGeometry(argv[i+1],&geometry_info);
2761 if ((flags & SigmaValue) == 0)
2762 geometry_info.sigma=1.0;
2763 mogrify_image=SketchImage(*image,geometry_info.rho,
2764 geometry_info.sigma,geometry_info.xi,exception);
2767 if (LocaleCompare("solarize",option+1) == 0)
2772 (void) SyncImageSettings(mogrify_info,*image);
2773 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2774 (void) SolarizeImage(*image,threshold);
2775 InheritException(exception,&(*image)->exception);
2778 if (LocaleCompare("sparse-color",option+1) == 0)
2787 Sparse Color Interpolated Gradient
2789 (void) SyncImageSettings(mogrify_info,*image);
2790 method=(SparseColorMethod) ParseCommandOption(
2791 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2792 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2793 InheritException(exception,&(*image)->exception);
2794 if (arguments == (char *) NULL)
2796 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2797 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2798 arguments=DestroyString(arguments);
2801 if (LocaleCompare("splice",option+1) == 0)
2804 Splice a solid color into the image.
2806 (void) SyncImageSettings(mogrify_info,*image);
2807 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2808 mogrify_image=SpliceImage(*image,&geometry,exception);
2811 if (LocaleCompare("spread",option+1) == 0)
2816 (void) SyncImageSettings(mogrify_info,*image);
2817 (void) ParseGeometry(argv[i+1],&geometry_info);
2818 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2821 if (LocaleCompare("statistic",option+1) == 0)
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2828 MagickFalse,argv[i+1]);
2829 (void) ParseGeometry(argv[i+2],&geometry_info);
2830 mogrify_image=StatisticImageChannel(*image,channel,type,(size_t)
2831 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2834 if (LocaleCompare("stretch",option+1) == 0)
2838 draw_info->stretch=UndefinedStretch;
2841 draw_info->stretch=(StretchType) ParseCommandOption(
2842 MagickStretchOptions,MagickFalse,argv[i+1]);
2845 if (LocaleCompare("strip",option+1) == 0)
2848 Strip image of profiles and comments.
2850 (void) SyncImageSettings(mogrify_info,*image);
2851 (void) StripImage(*image);
2852 InheritException(exception,&(*image)->exception);
2855 if (LocaleCompare("stroke",option+1) == 0)
2862 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2863 if (draw_info->stroke_pattern != (Image *) NULL)
2864 draw_info->stroke_pattern=DestroyImage(
2865 draw_info->stroke_pattern);
2868 sans=AcquireExceptionInfo();
2869 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2870 sans=DestroyExceptionInfo(sans);
2871 if (status == MagickFalse)
2872 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2876 if (LocaleCompare("strokewidth",option+1) == 0)
2878 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2882 if (LocaleCompare("style",option+1) == 0)
2886 draw_info->style=UndefinedStyle;
2889 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2890 MagickFalse,argv[i+1]);
2893 if (LocaleCompare("swirl",option+1) == 0)
2898 (void) SyncImageSettings(mogrify_info,*image);
2899 (void) ParseGeometry(argv[i+1],&geometry_info);
2900 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
2907 if (LocaleCompare("threshold",option+1) == 0)
2915 (void) SyncImageSettings(mogrify_info,*image);
2917 threshold=(double) QuantumRange/2;
2919 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2920 (void) BilevelImageChannel(*image,channel,threshold);
2921 InheritException(exception,&(*image)->exception);
2924 if (LocaleCompare("thumbnail",option+1) == 0)
2929 (void) SyncImageSettings(mogrify_info,*image);
2930 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2931 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2935 if (LocaleCompare("tile",option+1) == 0)
2939 if (draw_info->fill_pattern != (Image *) NULL)
2940 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2943 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2947 if (LocaleCompare("tint",option+1) == 0)
2952 (void) SyncImageSettings(mogrify_info,*image);
2953 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
2956 if (LocaleCompare("transform",option+1) == 0)
2959 Affine transform image.
2961 (void) SyncImageSettings(mogrify_info,*image);
2962 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2966 if (LocaleCompare("transparent",option+1) == 0)
2971 (void) SyncImageSettings(mogrify_info,*image);
2972 (void) QueryMagickColor(argv[i+1],&target,exception);
2973 (void) TransparentPaintImage(*image,&target,(Quantum)
2974 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue);
2975 InheritException(exception,&(*image)->exception);
2978 if (LocaleCompare("transpose",option+1) == 0)
2981 Transpose image scanlines.
2983 (void) SyncImageSettings(mogrify_info,*image);
2984 mogrify_image=TransposeImage(*image,exception);
2987 if (LocaleCompare("transverse",option+1) == 0)
2990 Transverse image scanlines.
2992 (void) SyncImageSettings(mogrify_info,*image);
2993 mogrify_image=TransverseImage(*image,exception);
2996 if (LocaleCompare("treedepth",option+1) == 0)
2998 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3001 if (LocaleCompare("trim",option+1) == 0)
3006 (void) SyncImageSettings(mogrify_info,*image);
3007 mogrify_image=TrimImage(*image,exception);
3010 if (LocaleCompare("type",option+1) == 0)
3015 (void) SyncImageSettings(mogrify_info,*image);
3019 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3021 (*image)->type=UndefinedType;
3022 (void) SetImageType(*image,type);
3023 InheritException(exception,&(*image)->exception);
3030 if (LocaleCompare("undercolor",option+1) == 0)
3032 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3036 if (LocaleCompare("unique",option+1) == 0)
3040 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3043 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3044 (void) SetImageArtifact(*image,"verbose","true");
3047 if (LocaleCompare("unique-colors",option+1) == 0)
3050 Unique image colors.
3052 (void) SyncImageSettings(mogrify_info,*image);
3053 mogrify_image=UniqueImageColors(*image,exception);
3056 if (LocaleCompare("unsharp",option+1) == 0)
3061 (void) SyncImageSettings(mogrify_info,*image);
3062 flags=ParseGeometry(argv[i+1],&geometry_info);
3063 if ((flags & SigmaValue) == 0)
3064 geometry_info.sigma=1.0;
3065 if ((flags & XiValue) == 0)
3066 geometry_info.xi=1.0;
3067 if ((flags & PsiValue) == 0)
3068 geometry_info.psi=0.05;
3069 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3070 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3071 geometry_info.psi,exception);
3078 if (LocaleCompare("verbose",option+1) == 0)
3080 (void) SetImageArtifact(*image,option+1,
3081 *option == '+' ? "false" : "true");
3084 if (LocaleCompare("vignette",option+1) == 0)
3089 (void) SyncImageSettings(mogrify_info,*image);
3090 flags=ParseGeometry(argv[i+1],&geometry_info);
3091 if ((flags & SigmaValue) == 0)
3092 geometry_info.sigma=1.0;
3093 if ((flags & XiValue) == 0)
3094 geometry_info.xi=0.1*(*image)->columns;
3095 if ((flags & PsiValue) == 0)
3096 geometry_info.psi=0.1*(*image)->rows;
3097 mogrify_image=VignetteImage(*image,geometry_info.rho,
3098 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3099 ceil(geometry_info.psi-0.5),exception);
3102 if (LocaleCompare("virtual-pixel",option+1) == 0)
3106 (void) SetImageVirtualPixelMethod(*image,
3107 UndefinedVirtualPixelMethod);
3110 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3111 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3119 if (LocaleCompare("wave",option+1) == 0)
3124 (void) SyncImageSettings(mogrify_info,*image);
3125 flags=ParseGeometry(argv[i+1],&geometry_info);
3126 if ((flags & SigmaValue) == 0)
3127 geometry_info.sigma=1.0;
3128 mogrify_image=WaveImage(*image,geometry_info.rho,
3129 geometry_info.sigma,exception);
3132 if (LocaleCompare("weight",option+1) == 0)
3134 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3135 if (LocaleCompare(argv[i+1],"all") == 0)
3136 draw_info->weight=0;
3137 if (LocaleCompare(argv[i+1],"bold") == 0)
3138 draw_info->weight=700;
3139 if (LocaleCompare(argv[i+1],"bolder") == 0)
3140 if (draw_info->weight <= 800)
3141 draw_info->weight+=100;
3142 if (LocaleCompare(argv[i+1],"lighter") == 0)
3143 if (draw_info->weight >= 100)
3144 draw_info->weight-=100;
3145 if (LocaleCompare(argv[i+1],"normal") == 0)
3146 draw_info->weight=400;
3149 if (LocaleCompare("white-threshold",option+1) == 0)
3152 White threshold image.
3154 (void) SyncImageSettings(mogrify_info,*image);
3155 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3157 InheritException(exception,&(*image)->exception);
3166 Replace current image with any image that was generated
3168 if (mogrify_image != (Image *) NULL)
3169 ReplaceImageInListReturnLast(image,mogrify_image);
3172 if (region_image != (Image *) NULL)
3175 Composite transformed region onto image.
3177 (void) SyncImageSettings(mogrify_info,*image);
3178 (void) CompositeImage(region_image,region_image->matte !=
3179 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3180 region_geometry.x,region_geometry.y);
3181 InheritException(exception,®ion_image->exception);
3182 *image=DestroyImage(*image);
3183 *image=region_image;
3184 region_image = (Image *) NULL;
3189 quantize_info=DestroyQuantizeInfo(quantize_info);
3190 draw_info=DestroyDrawInfo(draw_info);
3191 mogrify_info=DestroyImageInfo(mogrify_info);
3192 status=(MagickStatusType) ((*image)->exception.severity ==
3193 UndefinedException ? 1 : 0);
3194 return(status == 0 ? MagickFalse : MagickTrue);
3198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3202 + M o g r i f y I m a g e C o m m a n d %
3206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3208 % MogrifyImageCommand() transforms an image or a sequence of images. These
3209 % transforms include image scaling, image rotation, color reduction, and
3210 % others. The transmogrified image overwrites the original image.
3212 % The format of the MogrifyImageCommand method is:
3214 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3215 % const char **argv,char **metadata,ExceptionInfo *exception)
3217 % A description of each parameter follows:
3219 % o image_info: the image info.
3221 % o argc: the number of elements in the argument vector.
3223 % o argv: A text array containing the command line arguments.
3225 % o metadata: any metadata is returned here.
3227 % o exception: return any errors or warnings in this structure.
3231 static MagickBooleanType MogrifyUsage(void)
3236 "-debug events display copious debugging information",
3237 "-help print program options",
3238 "-list type print a list of supported option arguments",
3239 "-log format format of debugging information",
3240 "-version print version information",
3245 "-adaptive-blur geometry",
3246 " adaptively blur pixels; decrease effect near edges",
3247 "-adaptive-resize geometry",
3248 " adaptively resize image using 'mesh' interpolation",
3249 "-adaptive-sharpen geometry",
3250 " adaptively sharpen pixels; increase effect near edges",
3251 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3252 " transparent, extract, background, or shape",
3253 "-annotate geometry text",
3254 " annotate the image with text",
3255 "-auto-gamma automagically adjust gamma level of image",
3256 "-auto-level automagically adjust color levels of image",
3257 "-auto-orient automagically orient (rotate) image",
3258 "-bench iterations measure performance",
3259 "-black-threshold value",
3260 " force all pixels below the threshold into black",
3261 "-blue-shift simulate a scene at nighttime in the moonlight",
3262 "-blur geometry reduce image noise and reduce detail levels",
3263 "-border geometry surround image with a border of color",
3264 "-bordercolor color border color",
3265 "-brightness-contrast geometry",
3266 " improve brightness / contrast of the image",
3267 "-cdl filename color correct with a color decision list",
3268 "-charcoal radius simulate a charcoal drawing",
3269 "-chop geometry remove pixels from the image interior",
3270 "-clamp restrict pixel range from 0 to the quantum depth",
3271 "-clip clip along the first path from the 8BIM profile",
3272 "-clip-mask filename associate a clip mask with the image",
3273 "-clip-path id clip along a named path from the 8BIM profile",
3274 "-colorize value colorize the image with the fill color",
3275 "-color-matrix matrix apply color correction to the image",
3276 "-contrast enhance or reduce the image contrast",
3277 "-contrast-stretch geometry",
3278 " improve contrast by `stretching' the intensity range",
3279 "-convolve coefficients",
3280 " apply a convolution kernel to the image",
3281 "-cycle amount cycle the image colormap",
3282 "-decipher filename convert cipher pixels to plain pixels",
3283 "-deskew threshold straighten an image",
3284 "-despeckle reduce the speckles within an image",
3285 "-distort method args",
3286 " distort images according to given method ad args",
3287 "-draw string annotate the image with a graphic primitive",
3288 "-edge radius apply a filter to detect edges in the image",
3289 "-encipher filename convert plain pixels to cipher pixels",
3290 "-emboss radius emboss an image",
3291 "-enhance apply a digital filter to enhance a noisy image",
3292 "-equalize perform histogram equalization to an image",
3293 "-evaluate operator value",
3294 " evaluate an arithmetic, relational, or logical expression",
3295 "-extent geometry set the image size",
3296 "-extract geometry extract area from image",
3297 "-fft implements the discrete Fourier transform (DFT)",
3298 "-flip flip image vertically",
3299 "-floodfill geometry color",
3300 " floodfill the image with color",
3301 "-flop flop image horizontally",
3302 "-frame geometry surround image with an ornamental border",
3303 "-function name parameters",
3304 " apply function over image values",
3305 "-gamma value level of gamma correction",
3306 "-gaussian-blur geometry",
3307 " reduce image noise and reduce detail levels",
3308 "-geometry geometry preferred size or location of the image",
3309 "-identify identify the format and characteristics of the image",
3310 "-ift implements the inverse discrete Fourier transform (DFT)",
3311 "-implode amount implode image pixels about the center",
3312 "-lat geometry local adaptive thresholding",
3313 "-layers method optimize, merge, or compare image layers",
3314 "-level value adjust the level of image contrast",
3315 "-level-colors color,color",
3316 " level image with the given colors",
3317 "-linear-stretch geometry",
3318 " improve contrast by `stretching with saturation'",
3319 "-liquid-rescale geometry",
3320 " rescale image with seam-carving",
3321 "-median geometry apply a median filter to the image",
3322 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3323 "-modulate value vary the brightness, saturation, and hue",
3324 "-monochrome transform image to black and white",
3325 "-morphology method kernel",
3326 " apply a morphology method to the image",
3327 "-motion-blur geometry",
3328 " simulate motion blur",
3329 "-negate replace every pixel with its complementary color ",
3330 "-noise geometry add or reduce noise in an image",
3331 "-normalize transform image to span the full range of colors",
3332 "-opaque color change this color to the fill color",
3333 "-ordered-dither NxN",
3334 " add a noise pattern to the image with specific",
3336 "-paint radius simulate an oil painting",
3337 "-polaroid angle simulate a Polaroid picture",
3338 "-posterize levels reduce the image to a limited number of color levels",
3339 "-profile filename add, delete, or apply an image profile",
3340 "-quantize colorspace reduce colors in this colorspace",
3341 "-radial-blur angle radial blur the image",
3342 "-raise value lighten/darken image edges to create a 3-D effect",
3343 "-random-threshold low,high",
3344 " random threshold the image",
3345 "-region geometry apply options to a portion of the image",
3346 "-render render vector graphics",
3347 "-repage geometry size and location of an image canvas",
3348 "-resample geometry change the resolution of an image",
3349 "-resize geometry resize the image",
3350 "-roll geometry roll an image vertically or horizontally",
3351 "-rotate degrees apply Paeth rotation to the image",
3352 "-sample geometry scale image with pixel sampling",
3353 "-scale geometry scale the image",
3354 "-segment values segment an image",
3355 "-selective-blur geometry",
3356 " selectively blur pixels within a contrast threshold",
3357 "-sepia-tone threshold",
3358 " simulate a sepia-toned photo",
3359 "-set property value set an image property",
3360 "-shade degrees shade the image using a distant light source",
3361 "-shadow geometry simulate an image shadow",
3362 "-sharpen geometry sharpen the image",
3363 "-shave geometry shave pixels from the image edges",
3364 "-shear geometry slide one edge of the image along the X or Y axis",
3365 "-sigmoidal-contrast geometry",
3366 " increase the contrast without saturating highlights or shadows",
3367 "-sketch geometry simulate a pencil sketch",
3368 "-solarize threshold negate all pixels above the threshold level",
3369 "-sparse-color method args",
3370 " fill in a image based on a few color points",
3371 "-splice geometry splice the background color into the image",
3372 "-spread radius displace image pixels by a random amount",
3373 "-statistic type radius",
3374 " replace each pixel with corresponding statistic from the neighborhood",
3375 "-strip strip image of all profiles and comments",
3376 "-swirl degrees swirl image pixels about the center",
3377 "-threshold value threshold the image",
3378 "-thumbnail geometry create a thumbnail of the image",
3379 "-tile filename tile image when filling a graphic primitive",
3380 "-tint value tint the image with the fill color",
3381 "-transform affine transform image",
3382 "-transparent color make this color transparent within the image",
3383 "-transpose flip image vertically and rotate 90 degrees",
3384 "-transverse flop image horizontally and rotate 270 degrees",
3385 "-trim trim image edges",
3386 "-type type image type",
3387 "-unique-colors discard all but one of any pixel color",
3388 "-unsharp geometry sharpen the image",
3389 "-vignette geometry soften the edges of the image in vignette style",
3390 "-wave geometry alter an image along a sine wave",
3391 "-white-threshold value",
3392 " force all pixels above the threshold into white",
3395 *sequence_operators[]=
3397 "-append append an image sequence",
3398 "-clut apply a color lookup table to the image",
3399 "-coalesce merge a sequence of images",
3400 "-combine combine a sequence of images",
3401 "-composite composite image",
3402 "-crop geometry cut out a rectangular region of the image",
3403 "-deconstruct break down an image sequence into constituent parts",
3404 "-evaluate-sequence operator",
3405 " evaluate an arithmetic, relational, or logical expression",
3406 "-flatten flatten a sequence of images",
3407 "-fx expression apply mathematical expression to an image channel(s)",
3408 "-hald-clut apply a Hald color lookup table to the image",
3409 "-morph value morph an image sequence",
3410 "-mosaic create a mosaic from an image sequence",
3411 "-print string interpret string and print to console",
3412 "-process arguments process the image with a custom image filter",
3413 "-separate separate an image channel into a grayscale image",
3414 "-smush geometry smush an image sequence together",
3415 "-write filename write images to this file",
3420 "-adjoin join images into a single multi-image file",
3421 "-affine matrix affine transform matrix",
3422 "-alpha option activate, deactivate, reset, or set the alpha channel",
3423 "-antialias remove pixel-aliasing",
3424 "-authenticate password",
3425 " decipher image with this password",
3426 "-attenuate value lessen (or intensify) when adding noise to an image",
3427 "-background color background color",
3428 "-bias value add bias when convolving an image",
3429 "-black-point-compensation",
3430 " use black point compensation",
3431 "-blue-primary point chromaticity blue primary point",
3432 "-bordercolor color border color",
3433 "-caption string assign a caption to an image",
3434 "-channel type apply option to select image channels",
3435 "-colors value preferred number of colors in the image",
3436 "-colorspace type alternate image colorspace",
3437 "-comment string annotate image with comment",
3438 "-compose operator set image composite operator",
3439 "-compress type type of pixel compression when writing the image",
3440 "-define format:option",
3441 " define one or more image format options",
3442 "-delay value display the next image after pausing",
3443 "-density geometry horizontal and vertical density of the image",
3444 "-depth value image depth",
3445 "-direction type render text right-to-left or left-to-right",
3446 "-display server get image or font from this X server",
3447 "-dispose method layer disposal method",
3448 "-dither method apply error diffusion to image",
3449 "-encoding type text encoding type",
3450 "-endian type endianness (MSB or LSB) of the image",
3451 "-family name render text with this font family",
3452 "-fill color color to use when filling a graphic primitive",
3453 "-filter type use this filter when resizing an image",
3454 "-font name render text with this font",
3455 "-format \"string\" output formatted image characteristics",
3456 "-fuzz distance colors within this distance are considered equal",
3457 "-gravity type horizontal and vertical text placement",
3458 "-green-primary point chromaticity green primary point",
3459 "-intent type type of rendering intent when managing the image color",
3460 "-interlace type type of image interlacing scheme",
3461 "-interline-spacing value",
3462 " set the space between two text lines",
3463 "-interpolate method pixel color interpolation method",
3464 "-interword-spacing value",
3465 " set the space between two words",
3466 "-kerning value set the space between two letters",
3467 "-label string assign a label to an image",
3468 "-limit type value pixel cache resource limit",
3469 "-loop iterations add Netscape loop extension to your GIF animation",
3470 "-mask filename associate a mask with the image",
3471 "-mattecolor color frame color",
3472 "-monitor monitor progress",
3473 "-orient type image orientation",
3474 "-page geometry size and location of an image canvas (setting)",
3475 "-ping efficiently determine image attributes",
3476 "-pointsize value font point size",
3477 "-precision value maximum number of significant digits to print",
3478 "-preview type image preview type",
3479 "-quality value JPEG/MIFF/PNG compression level",
3480 "-quiet suppress all warning messages",
3481 "-red-primary point chromaticity red primary point",
3482 "-regard-warnings pay attention to warning messages",
3483 "-remap filename transform image colors to match this set of colors",
3484 "-respect-parentheses settings remain in effect until parenthesis boundary",
3485 "-sampling-factor geometry",
3486 " horizontal and vertical sampling factor",
3487 "-scene value image scene number",
3488 "-seed value seed a new sequence of pseudo-random numbers",
3489 "-size geometry width and height of image",
3490 "-stretch type render text with this font stretch",
3491 "-stroke color graphic primitive stroke color",
3492 "-strokewidth value graphic primitive stroke width",
3493 "-style type render text with this font style",
3494 "-synchronize synchronize image to storage device",
3495 "-taint declare the image as modified",
3496 "-texture filename name of texture to tile onto the image background",
3497 "-tile-offset geometry",
3499 "-treedepth value color tree depth",
3500 "-transparent-color color",
3501 " transparent color",
3502 "-undercolor color annotation bounding box color",
3503 "-units type the units of image resolution",
3504 "-verbose print detailed information about the image",
3505 "-view FlashPix viewing transforms",
3506 "-virtual-pixel method",
3507 " virtual pixel access method",
3508 "-weight type render text with this font weight",
3509 "-white-point point chromaticity white point",
3514 "-delete indexes delete the image from the image sequence",
3515 "-duplicate count,indexes",
3516 " duplicate an image one or more times",
3517 "-insert index insert last image into the image sequence",
3518 "-reverse reverse image sequence",
3519 "-swap indexes swap two images in the image sequence",
3526 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3527 (void) printf("Copyright: %s\n",GetMagickCopyright());
3528 (void) printf("Features: %s\n\n",GetMagickFeatures());
3529 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3531 (void) printf("\nImage Settings:\n");
3532 for (p=settings; *p != (char *) NULL; p++)
3533 (void) printf(" %s\n",*p);
3534 (void) printf("\nImage Operators:\n");
3535 for (p=operators; *p != (char *) NULL; p++)
3536 (void) printf(" %s\n",*p);
3537 (void) printf("\nImage Sequence Operators:\n");
3538 for (p=sequence_operators; *p != (char *) NULL; p++)
3539 (void) printf(" %s\n",*p);
3540 (void) printf("\nImage Stack Operators:\n");
3541 for (p=stack_operators; *p != (char *) NULL; p++)
3542 (void) printf(" %s\n",*p);
3543 (void) printf("\nMiscellaneous Options:\n");
3544 for (p=miscellaneous; *p != (char *) NULL; p++)
3545 (void) printf(" %s\n",*p);
3547 "\nBy default, the image format of `file' is determined by its magic\n");
3549 "number. To specify a particular image format, precede the filename\n");
3551 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3553 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3554 (void) printf("'-' for standard input or output.\n");
3555 return(MagickFalse);
3558 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3559 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3561 #define DestroyMogrify() \
3563 if (format != (char *) NULL) \
3564 format=DestroyString(format); \
3565 if (path != (char *) NULL) \
3566 path=DestroyString(path); \
3567 DestroyImageStack(); \
3568 for (i=0; i < (ssize_t) argc; i++) \
3569 argv[i]=DestroyString(argv[i]); \
3570 argv=(char **) RelinquishMagickMemory(argv); \
3572 #define ThrowMogrifyException(asperity,tag,option) \
3574 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3577 return(MagickFalse); \
3579 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3581 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3582 "InvalidArgument","`%s': %s",argument,option); \
3584 return(MagickFalse); \
3596 image_stack[MaxImageStackDepth+1];
3604 respect_parenthesis;
3619 assert(image_info != (ImageInfo *) NULL);
3620 assert(image_info->signature == MagickSignature);
3621 if (image_info->debug != MagickFalse)
3622 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3623 assert(exception != (ExceptionInfo *) NULL);
3627 if ((LocaleCompare("version",option+1) == 0) ||
3628 (LocaleCompare("-version",option+1) == 0))
3630 (void) FormatLocaleFile(stdout,"Version: %s\n",
3631 GetMagickVersion((size_t *) NULL));
3632 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3633 GetMagickCopyright());
3634 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3635 GetMagickFeatures());
3636 return(MagickFalse);
3640 return(MogrifyUsage());
3641 format=(char *) NULL;
3643 global_colormap=MagickFalse;
3647 option=(char *) NULL;
3649 respect_parenthesis=MagickFalse;
3654 ReadCommandlLine(argc,&argv);
3655 status=ExpandFilenames(&argc,&argv);
3656 if (status == MagickFalse)
3657 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3658 GetExceptionMessage(errno));
3659 for (i=1; i < (ssize_t) argc; i++)
3662 if (LocaleCompare(option,"(") == 0)
3664 FireImageStack(MagickFalse,MagickTrue,pend);
3665 if (k == MaxImageStackDepth)
3666 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3671 if (LocaleCompare(option,")") == 0)
3673 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3675 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3679 if (IsCommandOption(option) == MagickFalse)
3682 backup_filename[MaxTextExtent],
3689 Option is a file name: begin by reading image from specified file.
3691 FireImageStack(MagickFalse,MagickFalse,pend);
3693 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3695 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3696 images=ReadImages(image_info,exception);
3697 status&=(images != (Image *) NULL) &&
3698 (exception->severity < ErrorException);
3699 if (images == (Image *) NULL)
3701 if (format != (char *) NULL)
3702 (void) CopyMagickString(images->filename,images->magick_filename,
3704 if (path != (char *) NULL)
3706 GetPathComponent(option,TailPath,filename);
3707 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3708 path,*DirectorySeparator,filename);
3710 if (format != (char *) NULL)
3711 AppendImageFormat(format,images->filename);
3712 AppendImageStack(images);
3713 FinalizeImageSettings(image_info,image,MagickFalse);
3714 if (global_colormap != MagickFalse)
3719 quantize_info=AcquireQuantizeInfo(image_info);
3720 (void) RemapImages(quantize_info,images,(Image *) NULL);
3721 quantize_info=DestroyQuantizeInfo(quantize_info);
3723 *backup_filename='\0';
3724 if ((LocaleCompare(image->filename,"-") != 0) &&
3725 (IsPathWritable(image->filename) != MagickFalse))
3731 Rename image file as backup.
3733 (void) CopyMagickString(backup_filename,image->filename,
3735 for (i=0; i < 6; i++)
3737 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3738 if (IsPathAccessible(backup_filename) == MagickFalse)
3741 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3742 (rename(image->filename,backup_filename) != 0))
3743 *backup_filename='\0';
3746 Write transmogrified image to disk.
3748 image_info->synchronize=MagickTrue;
3749 status&=WriteImages(image_info,image,image->filename,exception);
3750 if ((status == MagickFalse) && (*backup_filename != '\0'))
3751 (void) remove(backup_filename);
3752 RemoveAllImageStack();
3755 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3756 switch (*(option+1))
3760 if (LocaleCompare("adaptive-blur",option+1) == 0)
3763 if (i == (ssize_t) argc)
3764 ThrowMogrifyException(OptionError,"MissingArgument",option);
3765 if (IsGeometry(argv[i]) == MagickFalse)
3766 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3769 if (LocaleCompare("adaptive-resize",option+1) == 0)
3772 if (i == (ssize_t) argc)
3773 ThrowMogrifyException(OptionError,"MissingArgument",option);
3774 if (IsGeometry(argv[i]) == MagickFalse)
3775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3778 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3781 if (i == (ssize_t) argc)
3782 ThrowMogrifyException(OptionError,"MissingArgument",option);
3783 if (IsGeometry(argv[i]) == MagickFalse)
3784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3787 if (LocaleCompare("affine",option+1) == 0)
3792 if (i == (ssize_t) argc)
3793 ThrowMogrifyException(OptionError,"MissingArgument",option);
3796 if (LocaleCompare("alpha",option+1) == 0)
3804 if (i == (ssize_t) argc)
3805 ThrowMogrifyException(OptionError,"MissingArgument",option);
3806 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3808 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3812 if (LocaleCompare("annotate",option+1) == 0)
3817 if (i == (ssize_t) argc)
3818 ThrowMogrifyException(OptionError,"MissingArgument",option);
3819 if (IsGeometry(argv[i]) == MagickFalse)
3820 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3821 if (i == (ssize_t) argc)
3822 ThrowMogrifyException(OptionError,"MissingArgument",option);
3826 if (LocaleCompare("antialias",option+1) == 0)
3828 if (LocaleCompare("append",option+1) == 0)
3830 if (LocaleCompare("attenuate",option+1) == 0)
3835 if (i == (ssize_t) (argc-1))
3836 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (IsGeometry(argv[i]) == MagickFalse)
3838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3841 if (LocaleCompare("authenticate",option+1) == 0)
3846 if (i == (ssize_t) argc)
3847 ThrowMogrifyException(OptionError,"MissingArgument",option);
3850 if (LocaleCompare("auto-gamma",option+1) == 0)
3852 if (LocaleCompare("auto-level",option+1) == 0)
3854 if (LocaleCompare("auto-orient",option+1) == 0)
3856 if (LocaleCompare("average",option+1) == 0)
3858 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3862 if (LocaleCompare("background",option+1) == 0)
3867 if (i == (ssize_t) argc)
3868 ThrowMogrifyException(OptionError,"MissingArgument",option);
3871 if (LocaleCompare("bias",option+1) == 0)
3876 if (i == (ssize_t) (argc-1))
3877 ThrowMogrifyException(OptionError,"MissingArgument",option);
3878 if (IsGeometry(argv[i]) == MagickFalse)
3879 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3882 if (LocaleCompare("black-point-compensation",option+1) == 0)
3884 if (LocaleCompare("black-threshold",option+1) == 0)
3889 if (i == (ssize_t) argc)
3890 ThrowMogrifyException(OptionError,"MissingArgument",option);
3891 if (IsGeometry(argv[i]) == MagickFalse)
3892 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3895 if (LocaleCompare("blue-primary",option+1) == 0)
3900 if (i == (ssize_t) argc)
3901 ThrowMogrifyException(OptionError,"MissingArgument",option);
3902 if (IsGeometry(argv[i]) == MagickFalse)
3903 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3906 if (LocaleCompare("blue-shift",option+1) == 0)
3909 if (i == (ssize_t) argc)
3910 ThrowMogrifyException(OptionError,"MissingArgument",option);
3911 if (IsGeometry(argv[i]) == MagickFalse)
3912 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3915 if (LocaleCompare("blur",option+1) == 0)
3918 if (i == (ssize_t) argc)
3919 ThrowMogrifyException(OptionError,"MissingArgument",option);
3920 if (IsGeometry(argv[i]) == MagickFalse)
3921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3924 if (LocaleCompare("border",option+1) == 0)
3929 if (i == (ssize_t) argc)
3930 ThrowMogrifyException(OptionError,"MissingArgument",option);
3931 if (IsGeometry(argv[i]) == MagickFalse)
3932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3935 if (LocaleCompare("bordercolor",option+1) == 0)
3940 if (i == (ssize_t) argc)
3941 ThrowMogrifyException(OptionError,"MissingArgument",option);
3944 if (LocaleCompare("box",option+1) == 0)
3949 if (i == (ssize_t) argc)
3950 ThrowMogrifyException(OptionError,"MissingArgument",option);
3953 if (LocaleCompare("brightness-contrast",option+1) == 0)
3956 if (i == (ssize_t) argc)
3957 ThrowMogrifyException(OptionError,"MissingArgument",option);
3958 if (IsGeometry(argv[i]) == MagickFalse)
3959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3962 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3966 if (LocaleCompare("cache",option+1) == 0)
3971 if (i == (ssize_t) argc)
3972 ThrowMogrifyException(OptionError,"MissingArgument",option);
3973 if (IsGeometry(argv[i]) == MagickFalse)
3974 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3977 if (LocaleCompare("caption",option+1) == 0)
3982 if (i == (ssize_t) argc)
3983 ThrowMogrifyException(OptionError,"MissingArgument",option);
3986 if (LocaleCompare("channel",option+1) == 0)
3994 if (i == (ssize_t) (argc-1))
3995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3996 channel=ParseChannelOption(argv[i]);
3998 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4002 if (LocaleCompare("cdl",option+1) == 0)
4007 if (i == (ssize_t) (argc-1))
4008 ThrowMogrifyException(OptionError,"MissingArgument",option);
4011 if (LocaleCompare("charcoal",option+1) == 0)
4016 if (i == (ssize_t) argc)
4017 ThrowMogrifyException(OptionError,"MissingArgument",option);
4018 if (IsGeometry(argv[i]) == MagickFalse)
4019 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4022 if (LocaleCompare("chop",option+1) == 0)
4027 if (i == (ssize_t) argc)
4028 ThrowMogrifyException(OptionError,"MissingArgument",option);
4029 if (IsGeometry(argv[i]) == MagickFalse)
4030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4033 if (LocaleCompare("clamp",option+1) == 0)
4035 if (LocaleCompare("clip",option+1) == 0)
4037 if (LocaleCompare("clip-mask",option+1) == 0)
4042 if (i == (ssize_t) argc)
4043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4046 if (LocaleCompare("clut",option+1) == 0)
4048 if (LocaleCompare("coalesce",option+1) == 0)
4050 if (LocaleCompare("colorize",option+1) == 0)
4055 if (i == (ssize_t) argc)
4056 ThrowMogrifyException(OptionError,"MissingArgument",option);
4057 if (IsGeometry(argv[i]) == MagickFalse)
4058 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4061 if (LocaleCompare("color-matrix",option+1) == 0)
4069 if (i == (ssize_t) (argc-1))
4070 ThrowMogrifyException(OptionError,"MissingArgument",option);
4071 kernel_info=AcquireKernelInfo(argv[i]);
4072 if (kernel_info == (KernelInfo *) NULL)
4073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4074 kernel_info=DestroyKernelInfo(kernel_info);
4077 if (LocaleCompare("colors",option+1) == 0)
4082 if (i == (ssize_t) argc)
4083 ThrowMogrifyException(OptionError,"MissingArgument",option);
4084 if (IsGeometry(argv[i]) == MagickFalse)
4085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4088 if (LocaleCompare("colorspace",option+1) == 0)
4096 if (i == (ssize_t) argc)
4097 ThrowMogrifyException(OptionError,"MissingArgument",option);
4098 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4101 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4105 if (LocaleCompare("combine",option+1) == 0)
4107 if (LocaleCompare("comment",option+1) == 0)
4112 if (i == (ssize_t) argc)
4113 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 if (LocaleCompare("composite",option+1) == 0)
4118 if (LocaleCompare("compress",option+1) == 0)
4126 if (i == (ssize_t) argc)
4127 ThrowMogrifyException(OptionError,"MissingArgument",option);
4128 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4131 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4135 if (LocaleCompare("concurrent",option+1) == 0)
4137 if (LocaleCompare("contrast",option+1) == 0)
4139 if (LocaleCompare("contrast-stretch",option+1) == 0)
4142 if (i == (ssize_t) argc)
4143 ThrowMogrifyException(OptionError,"MissingArgument",option);
4144 if (IsGeometry(argv[i]) == MagickFalse)
4145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4148 if (LocaleCompare("convolve",option+1) == 0)
4156 if (i == (ssize_t) argc)
4157 ThrowMogrifyException(OptionError,"MissingArgument",option);
4158 kernel_info=AcquireKernelInfo(argv[i]);
4159 if (kernel_info == (KernelInfo *) NULL)
4160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4161 kernel_info=DestroyKernelInfo(kernel_info);
4164 if (LocaleCompare("crop",option+1) == 0)
4169 if (i == (ssize_t) argc)
4170 ThrowMogrifyException(OptionError,"MissingArgument",option);
4171 if (IsGeometry(argv[i]) == MagickFalse)
4172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4175 if (LocaleCompare("cycle",option+1) == 0)
4180 if (i == (ssize_t) argc)
4181 ThrowMogrifyException(OptionError,"MissingArgument",option);
4182 if (IsGeometry(argv[i]) == MagickFalse)
4183 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4186 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4190 if (LocaleCompare("decipher",option+1) == 0)
4195 if (i == (ssize_t) (argc-1))
4196 ThrowMogrifyException(OptionError,"MissingArgument",option);
4199 if (LocaleCompare("deconstruct",option+1) == 0)
4201 if (LocaleCompare("debug",option+1) == 0)
4209 if (i == (ssize_t) argc)
4210 ThrowMogrifyException(OptionError,"MissingArgument",option);
4211 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4213 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4215 (void) SetLogEventMask(argv[i]);
4218 if (LocaleCompare("define",option+1) == 0)
4221 if (i == (ssize_t) argc)
4222 ThrowMogrifyException(OptionError,"MissingArgument",option);
4228 define=GetImageOption(image_info,argv[i]);
4229 if (define == (const char *) NULL)
4230 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4235 if (LocaleCompare("delay",option+1) == 0)
4240 if (i == (ssize_t) argc)
4241 ThrowMogrifyException(OptionError,"MissingArgument",option);
4242 if (IsGeometry(argv[i]) == MagickFalse)
4243 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4246 if (LocaleCompare("delete",option+1) == 0)
4251 if (i == (ssize_t) (argc-1))
4252 ThrowMogrifyException(OptionError,"MissingArgument",option);
4253 if (IsGeometry(argv[i]) == MagickFalse)
4254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4257 if (LocaleCompare("density",option+1) == 0)
4262 if (i == (ssize_t) argc)
4263 ThrowMogrifyException(OptionError,"MissingArgument",option);
4264 if (IsGeometry(argv[i]) == MagickFalse)
4265 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4268 if (LocaleCompare("depth",option+1) == 0)
4273 if (i == (ssize_t) argc)
4274 ThrowMogrifyException(OptionError,"MissingArgument",option);
4275 if (IsGeometry(argv[i]) == MagickFalse)
4276 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4279 if (LocaleCompare("deskew",option+1) == 0)
4284 if (i == (ssize_t) argc)
4285 ThrowMogrifyException(OptionError,"MissingArgument",option);
4286 if (IsGeometry(argv[i]) == MagickFalse)
4287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4290 if (LocaleCompare("despeckle",option+1) == 0)
4292 if (LocaleCompare("dft",option+1) == 0)
4294 if (LocaleCompare("direction",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4307 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4311 if (LocaleCompare("display",option+1) == 0)
4316 if (i == (ssize_t) argc)
4317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4320 if (LocaleCompare("dispose",option+1) == 0)
4328 if (i == (ssize_t) argc)
4329 ThrowMogrifyException(OptionError,"MissingArgument",option);
4330 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4332 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4336 if (LocaleCompare("distort",option+1) == 0)
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4344 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4346 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4349 if (i == (ssize_t) (argc-1))
4350 ThrowMogrifyException(OptionError,"MissingArgument",option);
4353 if (LocaleCompare("dither",option+1) == 0)
4361 if (i == (ssize_t) argc)
4362 ThrowMogrifyException(OptionError,"MissingArgument",option);
4363 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4365 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4369 if (LocaleCompare("draw",option+1) == 0)
4374 if (i == (ssize_t) argc)
4375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4378 if (LocaleCompare("duplicate",option+1) == 0)
4383 if (i == (ssize_t) (argc-1))
4384 ThrowMogrifyException(OptionError,"MissingArgument",option);
4385 if (IsGeometry(argv[i]) == MagickFalse)
4386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4389 if (LocaleCompare("duration",option+1) == 0)
4394 if (i == (ssize_t) (argc-1))
4395 ThrowMogrifyException(OptionError,"MissingArgument",option);
4396 if (IsGeometry(argv[i]) == MagickFalse)
4397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4400 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4404 if (LocaleCompare("edge",option+1) == 0)
4409 if (i == (ssize_t) argc)
4410 ThrowMogrifyException(OptionError,"MissingArgument",option);
4411 if (IsGeometry(argv[i]) == MagickFalse)
4412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4415 if (LocaleCompare("emboss",option+1) == 0)
4420 if (i == (ssize_t) argc)
4421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (IsGeometry(argv[i]) == MagickFalse)
4423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4426 if (LocaleCompare("encipher",option+1) == 0)
4431 if (i == (ssize_t) argc)
4432 ThrowMogrifyException(OptionError,"MissingArgument",option);
4435 if (LocaleCompare("encoding",option+1) == 0)
4440 if (i == (ssize_t) argc)
4441 ThrowMogrifyException(OptionError,"MissingArgument",option);
4444 if (LocaleCompare("endian",option+1) == 0)
4452 if (i == (ssize_t) argc)
4453 ThrowMogrifyException(OptionError,"MissingArgument",option);
4454 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4456 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4460 if (LocaleCompare("enhance",option+1) == 0)
4462 if (LocaleCompare("equalize",option+1) == 0)
4464 if (LocaleCompare("evaluate",option+1) == 0)
4472 if (i == (ssize_t) argc)
4473 ThrowMogrifyException(OptionError,"MissingArgument",option);
4474 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4476 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4479 if (i == (ssize_t) (argc-1))
4480 ThrowMogrifyException(OptionError,"MissingArgument",option);
4481 if (IsGeometry(argv[i]) == MagickFalse)
4482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4485 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4493 if (i == (ssize_t) argc)
4494 ThrowMogrifyException(OptionError,"MissingArgument",option);
4495 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4497 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4501 if (LocaleCompare("extent",option+1) == 0)
4506 if (i == (ssize_t) argc)
4507 ThrowMogrifyException(OptionError,"MissingArgument",option);
4508 if (IsGeometry(argv[i]) == MagickFalse)
4509 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4512 if (LocaleCompare("extract",option+1) == 0)
4517 if (i == (ssize_t) argc)
4518 ThrowMogrifyException(OptionError,"MissingArgument",option);
4519 if (IsGeometry(argv[i]) == MagickFalse)
4520 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4523 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4527 if (LocaleCompare("family",option+1) == 0)
4532 if (i == (ssize_t) (argc-1))
4533 ThrowMogrifyException(OptionError,"MissingArgument",option);
4536 if (LocaleCompare("fill",option+1) == 0)
4541 if (i == (ssize_t) argc)
4542 ThrowMogrifyException(OptionError,"MissingArgument",option);
4545 if (LocaleCompare("filter",option+1) == 0)
4553 if (i == (ssize_t) argc)
4554 ThrowMogrifyException(OptionError,"MissingArgument",option);
4555 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4557 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4561 if (LocaleCompare("flatten",option+1) == 0)
4563 if (LocaleCompare("flip",option+1) == 0)
4565 if (LocaleCompare("flop",option+1) == 0)
4567 if (LocaleCompare("floodfill",option+1) == 0)
4572 if (i == (ssize_t) argc)
4573 ThrowMogrifyException(OptionError,"MissingArgument",option);
4574 if (IsGeometry(argv[i]) == MagickFalse)
4575 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4577 if (i == (ssize_t) argc)
4578 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (LocaleCompare("font",option+1) == 0)
4586 if (i == (ssize_t) argc)
4587 ThrowMogrifyException(OptionError,"MissingArgument",option);
4590 if (LocaleCompare("format",option+1) == 0)
4592 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4593 (void) CloneString(&format,(char *) NULL);
4597 if (i == (ssize_t) argc)
4598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 (void) CloneString(&format,argv[i]);
4600 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4601 (void) ConcatenateMagickString(image_info->filename,":",
4603 (void) SetImageInfo(image_info,0,exception);
4604 if (*image_info->magick == '\0')
4605 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4609 if (LocaleCompare("frame",option+1) == 0)
4614 if (i == (ssize_t) argc)
4615 ThrowMogrifyException(OptionError,"MissingArgument",option);
4616 if (IsGeometry(argv[i]) == MagickFalse)
4617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4620 if (LocaleCompare("function",option+1) == 0)
4628 if (i == (ssize_t) argc)
4629 ThrowMogrifyException(OptionError,"MissingArgument",option);
4630 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4632 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4634 if (i == (ssize_t) (argc-1))
4635 ThrowMogrifyException(OptionError,"MissingArgument",option);
4638 if (LocaleCompare("fuzz",option+1) == 0)
4643 if (i == (ssize_t) argc)
4644 ThrowMogrifyException(OptionError,"MissingArgument",option);
4645 if (IsGeometry(argv[i]) == MagickFalse)
4646 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4649 if (LocaleCompare("fx",option+1) == 0)
4654 if (i == (ssize_t) (argc-1))
4655 ThrowMogrifyException(OptionError,"MissingArgument",option);
4658 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4662 if (LocaleCompare("gamma",option+1) == 0)
4665 if (i == (ssize_t) argc)
4666 ThrowMogrifyException(OptionError,"MissingArgument",option);
4667 if (IsGeometry(argv[i]) == MagickFalse)
4668 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4671 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4672 (LocaleCompare("gaussian",option+1) == 0))
4675 if (i == (ssize_t) argc)
4676 ThrowMogrifyException(OptionError,"MissingArgument",option);
4677 if (IsGeometry(argv[i]) == MagickFalse)
4678 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4681 if (LocaleCompare("geometry",option+1) == 0)
4686 if (i == (ssize_t) argc)
4687 ThrowMogrifyException(OptionError,"MissingArgument",option);
4688 if (IsGeometry(argv[i]) == MagickFalse)
4689 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4692 if (LocaleCompare("gravity",option+1) == 0)
4700 if (i == (ssize_t) argc)
4701 ThrowMogrifyException(OptionError,"MissingArgument",option);
4702 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4704 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4708 if (LocaleCompare("green-primary",option+1) == 0)
4713 if (i == (ssize_t) argc)
4714 ThrowMogrifyException(OptionError,"MissingArgument",option);
4715 if (IsGeometry(argv[i]) == MagickFalse)
4716 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4719 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4723 if (LocaleCompare("hald-clut",option+1) == 0)
4725 if ((LocaleCompare("help",option+1) == 0) ||
4726 (LocaleCompare("-help",option+1) == 0))
4727 return(MogrifyUsage());
4728 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4732 if (LocaleCompare("identify",option+1) == 0)
4734 if (LocaleCompare("idft",option+1) == 0)
4736 if (LocaleCompare("implode",option+1) == 0)
4741 if (i == (ssize_t) argc)
4742 ThrowMogrifyException(OptionError,"MissingArgument",option);
4743 if (IsGeometry(argv[i]) == MagickFalse)
4744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4747 if (LocaleCompare("intent",option+1) == 0)
4755 if (i == (ssize_t) (argc-1))
4756 ThrowMogrifyException(OptionError,"MissingArgument",option);
4757 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4759 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4763 if (LocaleCompare("interlace",option+1) == 0)
4771 if (i == (ssize_t) argc)
4772 ThrowMogrifyException(OptionError,"MissingArgument",option);
4773 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4776 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4780 if (LocaleCompare("interline-spacing",option+1) == 0)
4785 if (i == (ssize_t) (argc-1))
4786 ThrowMogrifyException(OptionError,"MissingArgument",option);
4787 if (IsGeometry(argv[i]) == MagickFalse)
4788 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4791 if (LocaleCompare("interpolate",option+1) == 0)
4799 if (i == (ssize_t) argc)
4800 ThrowMogrifyException(OptionError,"MissingArgument",option);
4801 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4803 if (interpolate < 0)
4804 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4808 if (LocaleCompare("interword-spacing",option+1) == 0)
4813 if (i == (ssize_t) (argc-1))
4814 ThrowMogrifyException(OptionError,"MissingArgument",option);
4815 if (IsGeometry(argv[i]) == MagickFalse)
4816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4819 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4823 if (LocaleCompare("kerning",option+1) == 0)
4828 if (i == (ssize_t) (argc-1))
4829 ThrowMogrifyException(OptionError,"MissingArgument",option);
4830 if (IsGeometry(argv[i]) == MagickFalse)
4831 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4834 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4838 if (LocaleCompare("label",option+1) == 0)
4843 if (i == (ssize_t) argc)
4844 ThrowMogrifyException(OptionError,"MissingArgument",option);
4847 if (LocaleCompare("lat",option+1) == 0)
4852 if (i == (ssize_t) argc)
4853 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 if (IsGeometry(argv[i]) == MagickFalse)
4855 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4857 if (LocaleCompare("layers",option+1) == 0)
4865 if (i == (ssize_t) (argc-1))
4866 ThrowMogrifyException(OptionError,"MissingArgument",option);
4867 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4869 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4873 if (LocaleCompare("level",option+1) == 0)
4876 if (i == (ssize_t) argc)
4877 ThrowMogrifyException(OptionError,"MissingArgument",option);
4878 if (IsGeometry(argv[i]) == MagickFalse)
4879 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4882 if (LocaleCompare("level-colors",option+1) == 0)
4885 if (i == (ssize_t) argc)
4886 ThrowMogrifyException(OptionError,"MissingArgument",option);
4889 if (LocaleCompare("linewidth",option+1) == 0)
4894 if (i == (ssize_t) argc)
4895 ThrowMogrifyException(OptionError,"MissingArgument",option);
4896 if (IsGeometry(argv[i]) == MagickFalse)
4897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4900 if (LocaleCompare("limit",option+1) == 0)
4914 if (i == (ssize_t) argc)
4915 ThrowMogrifyException(OptionError,"MissingArgument",option);
4916 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4919 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,"MissingArgument",option);
4924 value=InterpretLocaleValue(argv[i],&p);
4926 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4930 if (LocaleCompare("liquid-rescale",option+1) == 0)
4933 if (i == (ssize_t) argc)
4934 ThrowMogrifyException(OptionError,"MissingArgument",option);
4935 if (IsGeometry(argv[i]) == MagickFalse)
4936 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4939 if (LocaleCompare("list",option+1) == 0)
4947 if (i == (ssize_t) argc)
4948 ThrowMogrifyException(OptionError,"MissingArgument",option);
4949 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4951 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4952 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4954 return(status != 0 ? MagickFalse : MagickTrue);
4956 if (LocaleCompare("log",option+1) == 0)
4961 if ((i == (ssize_t) argc) ||
4962 (strchr(argv[i],'%') == (char *) NULL))
4963 ThrowMogrifyException(OptionError,"MissingArgument",option);
4966 if (LocaleCompare("loop",option+1) == 0)
4971 if (i == (ssize_t) argc)
4972 ThrowMogrifyException(OptionError,"MissingArgument",option);
4973 if (IsGeometry(argv[i]) == MagickFalse)
4974 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4977 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4981 if (LocaleCompare("map",option+1) == 0)
4983 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4987 if (i == (ssize_t) argc)
4988 ThrowMogrifyException(OptionError,"MissingArgument",option);
4991 if (LocaleCompare("mask",option+1) == 0)
4996 if (i == (ssize_t) argc)
4997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5000 if (LocaleCompare("matte",option+1) == 0)
5002 if (LocaleCompare("mattecolor",option+1) == 0)
5007 if (i == (ssize_t) argc)
5008 ThrowMogrifyException(OptionError,"MissingArgument",option);
5011 if (LocaleCompare("maximum",option+1) == 0)
5013 if (LocaleCompare("minimum",option+1) == 0)
5015 if (LocaleCompare("modulate",option+1) == 0)
5020 if (i == (ssize_t) argc)
5021 ThrowMogrifyException(OptionError,"MissingArgument",option);
5022 if (IsGeometry(argv[i]) == MagickFalse)
5023 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5026 if (LocaleCompare("median",option+1) == 0)
5031 if (i == (ssize_t) argc)
5032 ThrowMogrifyException(OptionError,"MissingArgument",option);
5033 if (IsGeometry(argv[i]) == MagickFalse)
5034 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5037 if (LocaleCompare("mode",option+1) == 0)
5042 if (i == (ssize_t) argc)
5043 ThrowMogrifyException(OptionError,"MissingArgument",option);
5044 if (IsGeometry(argv[i]) == MagickFalse)
5045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5048 if (LocaleCompare("monitor",option+1) == 0)
5050 if (LocaleCompare("monochrome",option+1) == 0)
5052 if (LocaleCompare("morph",option+1) == 0)
5057 if (i == (ssize_t) (argc-1))
5058 ThrowMogrifyException(OptionError,"MissingArgument",option);
5059 if (IsGeometry(argv[i]) == MagickFalse)
5060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5063 if (LocaleCompare("morphology",option+1) == 0)
5066 token[MaxTextExtent];
5075 if (i == (ssize_t) argc)
5076 ThrowMogrifyException(OptionError,"MissingArgument",option);
5077 GetMagickToken(argv[i],NULL,token);
5078 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5080 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5083 if (i == (ssize_t) (argc-1))
5084 ThrowMogrifyException(OptionError,"MissingArgument",option);
5085 kernel_info=AcquireKernelInfo(argv[i]);
5086 if (kernel_info == (KernelInfo *) NULL)
5087 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5088 kernel_info=DestroyKernelInfo(kernel_info);
5091 if (LocaleCompare("mosaic",option+1) == 0)
5093 if (LocaleCompare("motion-blur",option+1) == 0)
5098 if (i == (ssize_t) argc)
5099 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 if (IsGeometry(argv[i]) == MagickFalse)
5101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5104 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5108 if (LocaleCompare("negate",option+1) == 0)
5110 if (LocaleCompare("noise",option+1) == 0)
5113 if (i == (ssize_t) argc)
5114 ThrowMogrifyException(OptionError,"MissingArgument",option);
5120 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5122 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5126 if (IsGeometry(argv[i]) == MagickFalse)
5127 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5130 if (LocaleCompare("noop",option+1) == 0)
5132 if (LocaleCompare("normalize",option+1) == 0)
5134 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5138 if (LocaleCompare("opaque",option+1) == 0)
5141 if (i == (ssize_t) argc)
5142 ThrowMogrifyException(OptionError,"MissingArgument",option);
5145 if (LocaleCompare("ordered-dither",option+1) == 0)
5150 if (i == (ssize_t) argc)
5151 ThrowMogrifyException(OptionError,"MissingArgument",option);
5154 if (LocaleCompare("orient",option+1) == 0)
5159 orientation=UndefinedOrientation;
5163 if (i == (ssize_t) (argc-1))
5164 ThrowMogrifyException(OptionError,"MissingArgument",option);
5165 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5167 if (orientation < 0)
5168 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5172 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5176 if (LocaleCompare("page",option+1) == 0)
5181 if (i == (ssize_t) argc)
5182 ThrowMogrifyException(OptionError,"MissingArgument",option);
5185 if (LocaleCompare("paint",option+1) == 0)
5190 if (i == (ssize_t) argc)
5191 ThrowMogrifyException(OptionError,"MissingArgument",option);
5192 if (IsGeometry(argv[i]) == MagickFalse)
5193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5196 if (LocaleCompare("path",option+1) == 0)
5198 (void) CloneString(&path,(char *) NULL);
5202 if (i == (ssize_t) argc)
5203 ThrowMogrifyException(OptionError,"MissingArgument",option);
5204 (void) CloneString(&path,argv[i]);
5207 if (LocaleCompare("pointsize",option+1) == 0)
5212 if (i == (ssize_t) argc)
5213 ThrowMogrifyException(OptionError,"MissingArgument",option);
5214 if (IsGeometry(argv[i]) == MagickFalse)
5215 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5218 if (LocaleCompare("polaroid",option+1) == 0)
5223 if (i == (ssize_t) argc)
5224 ThrowMogrifyException(OptionError,"MissingArgument",option);
5225 if (IsGeometry(argv[i]) == MagickFalse)
5226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5229 if (LocaleCompare("posterize",option+1) == 0)
5234 if (i == (ssize_t) argc)
5235 ThrowMogrifyException(OptionError,"MissingArgument",option);
5236 if (IsGeometry(argv[i]) == MagickFalse)
5237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5240 if (LocaleCompare("precision",option+1) == 0)
5245 if (i == (ssize_t) argc)
5246 ThrowMogrifyException(OptionError,"MissingArgument",option);
5247 if (IsGeometry(argv[i]) == MagickFalse)
5248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5251 if (LocaleCompare("print",option+1) == 0)
5256 if (i == (ssize_t) argc)
5257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5260 if (LocaleCompare("process",option+1) == 0)
5265 if (i == (ssize_t) (argc-1))
5266 ThrowMogrifyException(OptionError,"MissingArgument",option);
5269 if (LocaleCompare("profile",option+1) == 0)
5272 if (i == (ssize_t) argc)
5273 ThrowMogrifyException(OptionError,"MissingArgument",option);
5276 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5280 if (LocaleCompare("quality",option+1) == 0)
5285 if (i == (ssize_t) argc)
5286 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 if (IsGeometry(argv[i]) == MagickFalse)
5288 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5291 if (LocaleCompare("quantize",option+1) == 0)
5299 if (i == (ssize_t) (argc-1))
5300 ThrowMogrifyException(OptionError,"MissingArgument",option);
5301 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5304 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5308 if (LocaleCompare("quiet",option+1) == 0)
5310 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5314 if (LocaleCompare("radial-blur",option+1) == 0)
5317 if (i == (ssize_t) argc)
5318 ThrowMogrifyException(OptionError,"MissingArgument",option);
5319 if (IsGeometry(argv[i]) == MagickFalse)
5320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5323 if (LocaleCompare("raise",option+1) == 0)
5326 if (i == (ssize_t) argc)
5327 ThrowMogrifyException(OptionError,"MissingArgument",option);
5328 if (IsGeometry(argv[i]) == MagickFalse)
5329 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5332 if (LocaleCompare("random-threshold",option+1) == 0)
5337 if (i == (ssize_t) argc)
5338 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 if (IsGeometry(argv[i]) == MagickFalse)
5340 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5343 if (LocaleCompare("recolor",option+1) == 0)
5348 if (i == (ssize_t) (argc-1))
5349 ThrowMogrifyException(OptionError,"MissingArgument",option);
5350 if (IsGeometry(argv[i]) == MagickFalse)
5351 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5354 if (LocaleCompare("red-primary",option+1) == 0)
5359 if (i == (ssize_t) argc)
5360 ThrowMogrifyException(OptionError,"MissingArgument",option);
5361 if (IsGeometry(argv[i]) == MagickFalse)
5362 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5364 if (LocaleCompare("regard-warnings",option+1) == 0)
5366 if (LocaleCompare("region",option+1) == 0)
5371 if (i == (ssize_t) argc)
5372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5377 if (LocaleCompare("remap",option+1) == 0)
5382 if (i == (ssize_t) (argc-1))
5383 ThrowMogrifyException(OptionError,"MissingArgument",option);
5386 if (LocaleCompare("render",option+1) == 0)
5388 if (LocaleCompare("repage",option+1) == 0)
5393 if (i == (ssize_t) argc)
5394 ThrowMogrifyException(OptionError,"MissingArgument",option);
5395 if (IsGeometry(argv[i]) == MagickFalse)
5396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5399 if (LocaleCompare("resample",option+1) == 0)
5404 if (i == (ssize_t) argc)
5405 ThrowMogrifyException(OptionError,"MissingArgument",option);
5406 if (IsGeometry(argv[i]) == MagickFalse)
5407 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5410 if (LocaleCompare("resize",option+1) == 0)
5415 if (i == (ssize_t) argc)
5416 ThrowMogrifyException(OptionError,"MissingArgument",option);
5417 if (IsGeometry(argv[i]) == MagickFalse)
5418 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5421 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5423 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5426 if (LocaleCompare("reverse",option+1) == 0)
5428 if (LocaleCompare("roll",option+1) == 0)
5433 if (i == (ssize_t) argc)
5434 ThrowMogrifyException(OptionError,"MissingArgument",option);
5435 if (IsGeometry(argv[i]) == MagickFalse)
5436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5439 if (LocaleCompare("rotate",option+1) == 0)
5442 if (i == (ssize_t) argc)
5443 ThrowMogrifyException(OptionError,"MissingArgument",option);
5444 if (IsGeometry(argv[i]) == MagickFalse)
5445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5448 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5452 if (LocaleCompare("sample",option+1) == 0)
5457 if (i == (ssize_t) argc)
5458 ThrowMogrifyException(OptionError,"MissingArgument",option);
5459 if (IsGeometry(argv[i]) == MagickFalse)
5460 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5463 if (LocaleCompare("sampling-factor",option+1) == 0)
5468 if (i == (ssize_t) argc)
5469 ThrowMogrifyException(OptionError,"MissingArgument",option);
5470 if (IsGeometry(argv[i]) == MagickFalse)
5471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5474 if (LocaleCompare("scale",option+1) == 0)
5479 if (i == (ssize_t) argc)
5480 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (IsGeometry(argv[i]) == MagickFalse)
5482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5485 if (LocaleCompare("scene",option+1) == 0)
5490 if (i == (ssize_t) argc)
5491 ThrowMogrifyException(OptionError,"MissingArgument",option);
5492 if (IsGeometry(argv[i]) == MagickFalse)
5493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5496 if (LocaleCompare("seed",option+1) == 0)
5501 if (i == (ssize_t) argc)
5502 ThrowMogrifyException(OptionError,"MissingArgument",option);
5503 if (IsGeometry(argv[i]) == MagickFalse)
5504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5507 if (LocaleCompare("segment",option+1) == 0)
5512 if (i == (ssize_t) argc)
5513 ThrowMogrifyException(OptionError,"MissingArgument",option);
5514 if (IsGeometry(argv[i]) == MagickFalse)
5515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5518 if (LocaleCompare("selective-blur",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("separate",option+1) == 0)
5529 if (LocaleCompare("sepia-tone",option+1) == 0)
5534 if (i == (ssize_t) argc)
5535 ThrowMogrifyException(OptionError,"MissingArgument",option);
5536 if (IsGeometry(argv[i]) == MagickFalse)
5537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5540 if (LocaleCompare("set",option+1) == 0)
5543 if (i == (ssize_t) argc)
5544 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 if (i == (ssize_t) argc)
5549 ThrowMogrifyException(OptionError,"MissingArgument",option);
5552 if (LocaleCompare("shade",option+1) == 0)
5555 if (i == (ssize_t) argc)
5556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 if (IsGeometry(argv[i]) == MagickFalse)
5558 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5561 if (LocaleCompare("shadow",option+1) == 0)
5566 if (i == (ssize_t) argc)
5567 ThrowMogrifyException(OptionError,"MissingArgument",option);
5568 if (IsGeometry(argv[i]) == MagickFalse)
5569 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5572 if (LocaleCompare("sharpen",option+1) == 0)
5575 if (i == (ssize_t) argc)
5576 ThrowMogrifyException(OptionError,"MissingArgument",option);
5577 if (IsGeometry(argv[i]) == MagickFalse)
5578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5581 if (LocaleCompare("shave",option+1) == 0)
5586 if (i == (ssize_t) argc)
5587 ThrowMogrifyException(OptionError,"MissingArgument",option);
5588 if (IsGeometry(argv[i]) == MagickFalse)
5589 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5592 if (LocaleCompare("shear",option+1) == 0)
5595 if (i == (ssize_t) argc)
5596 ThrowMogrifyException(OptionError,"MissingArgument",option);
5597 if (IsGeometry(argv[i]) == MagickFalse)
5598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5601 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5604 if (i == (ssize_t) (argc-1))
5605 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 if (IsGeometry(argv[i]) == MagickFalse)
5607 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5610 if (LocaleCompare("size",option+1) == 0)
5615 if (i == (ssize_t) argc)
5616 ThrowMogrifyException(OptionError,"MissingArgument",option);
5617 if (IsGeometry(argv[i]) == MagickFalse)
5618 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5621 if (LocaleCompare("sketch",option+1) == 0)
5626 if (i == (ssize_t) argc)
5627 ThrowMogrifyException(OptionError,"MissingArgument",option);
5628 if (IsGeometry(argv[i]) == MagickFalse)
5629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5632 if (LocaleCompare("smush",option+1) == 0)
5635 if (i == (ssize_t) argc)
5636 ThrowMogrifyException(OptionError,"MissingArgument",option);
5637 if (IsGeometry(argv[i]) == MagickFalse)
5638 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleCompare("solarize",option+1) == 0)
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 if (LocaleCompare("sparse-color",option+1) == 0)
5659 if (i == (ssize_t) argc)
5660 ThrowMogrifyException(OptionError,"MissingArgument",option);
5661 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5663 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5666 if (i == (ssize_t) (argc-1))
5667 ThrowMogrifyException(OptionError,"MissingArgument",option);
5670 if (LocaleCompare("spread",option+1) == 0)
5675 if (i == (ssize_t) argc)
5676 ThrowMogrifyException(OptionError,"MissingArgument",option);
5677 if (IsGeometry(argv[i]) == MagickFalse)
5678 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5681 if (LocaleCompare("statistic",option+1) == 0)
5689 if (i == (ssize_t) argc)
5690 ThrowMogrifyException(OptionError,"MissingArgument",option);
5691 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5693 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5696 if (i == (ssize_t) (argc-1))
5697 ThrowMogrifyException(OptionError,"MissingArgument",option);
5698 if (IsGeometry(argv[i]) == MagickFalse)
5699 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5702 if (LocaleCompare("stretch",option+1) == 0)
5710 if (i == (ssize_t) (argc-1))
5711 ThrowMogrifyException(OptionError,"MissingArgument",option);
5712 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5714 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5718 if (LocaleCompare("strip",option+1) == 0)
5720 if (LocaleCompare("stroke",option+1) == 0)
5725 if (i == (ssize_t) argc)
5726 ThrowMogrifyException(OptionError,"MissingArgument",option);
5729 if (LocaleCompare("strokewidth",option+1) == 0)
5734 if (i == (ssize_t) argc)
5735 ThrowMogrifyException(OptionError,"MissingArgument",option);
5736 if (IsGeometry(argv[i]) == MagickFalse)
5737 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5740 if (LocaleCompare("style",option+1) == 0)
5748 if (i == (ssize_t) (argc-1))
5749 ThrowMogrifyException(OptionError,"MissingArgument",option);
5750 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5752 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5756 if (LocaleCompare("swap",option+1) == 0)
5761 if (i == (ssize_t) (argc-1))
5762 ThrowMogrifyException(OptionError,"MissingArgument",option);
5763 if (IsGeometry(argv[i]) == MagickFalse)
5764 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5767 if (LocaleCompare("swirl",option+1) == 0)
5772 if (i == (ssize_t) argc)
5773 ThrowMogrifyException(OptionError,"MissingArgument",option);
5774 if (IsGeometry(argv[i]) == MagickFalse)
5775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5778 if (LocaleCompare("synchronize",option+1) == 0)
5780 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5784 if (LocaleCompare("taint",option+1) == 0)
5786 if (LocaleCompare("texture",option+1) == 0)
5791 if (i == (ssize_t) argc)
5792 ThrowMogrifyException(OptionError,"MissingArgument",option);
5795 if (LocaleCompare("tile",option+1) == 0)
5800 if (i == (ssize_t) (argc-1))
5801 ThrowMogrifyException(OptionError,"MissingArgument",option);
5804 if (LocaleCompare("tile-offset",option+1) == 0)
5809 if (i == (ssize_t) argc)
5810 ThrowMogrifyException(OptionError,"MissingArgument",option);
5811 if (IsGeometry(argv[i]) == MagickFalse)
5812 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5815 if (LocaleCompare("tint",option+1) == 0)
5820 if (i == (ssize_t) (argc-1))
5821 ThrowMogrifyException(OptionError,"MissingArgument",option);
5822 if (IsGeometry(argv[i]) == MagickFalse)
5823 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 if (LocaleCompare("transform",option+1) == 0)
5828 if (LocaleCompare("transpose",option+1) == 0)
5830 if (LocaleCompare("transverse",option+1) == 0)
5832 if (LocaleCompare("threshold",option+1) == 0)
5837 if (i == (ssize_t) argc)
5838 ThrowMogrifyException(OptionError,"MissingArgument",option);
5839 if (IsGeometry(argv[i]) == MagickFalse)
5840 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5843 if (LocaleCompare("thumbnail",option+1) == 0)
5848 if (i == (ssize_t) argc)
5849 ThrowMogrifyException(OptionError,"MissingArgument",option);
5850 if (IsGeometry(argv[i]) == MagickFalse)
5851 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5854 if (LocaleCompare("transparent",option+1) == 0)
5857 if (i == (ssize_t) argc)
5858 ThrowMogrifyException(OptionError,"MissingArgument",option);
5861 if (LocaleCompare("transparent-color",option+1) == 0)
5866 if (i == (ssize_t) (argc-1))
5867 ThrowMogrifyException(OptionError,"MissingArgument",option);
5870 if (LocaleCompare("treedepth",option+1) == 0)
5875 if (i == (ssize_t) argc)
5876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5877 if (IsGeometry(argv[i]) == MagickFalse)
5878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5881 if (LocaleCompare("trim",option+1) == 0)
5883 if (LocaleCompare("type",option+1) == 0)
5891 if (i == (ssize_t) argc)
5892 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5895 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5899 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5903 if (LocaleCompare("undercolor",option+1) == 0)
5908 if (i == (ssize_t) argc)
5909 ThrowMogrifyException(OptionError,"MissingArgument",option);
5912 if (LocaleCompare("unique-colors",option+1) == 0)
5914 if (LocaleCompare("units",option+1) == 0)
5922 if (i == (ssize_t) argc)
5923 ThrowMogrifyException(OptionError,"MissingArgument",option);
5924 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5927 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5931 if (LocaleCompare("unsharp",option+1) == 0)
5934 if (i == (ssize_t) argc)
5935 ThrowMogrifyException(OptionError,"MissingArgument",option);
5936 if (IsGeometry(argv[i]) == MagickFalse)
5937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5940 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5944 if (LocaleCompare("verbose",option+1) == 0)
5946 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5949 if ((LocaleCompare("version",option+1) == 0) ||
5950 (LocaleCompare("-version",option+1) == 0))
5952 (void) FormatLocaleFile(stdout,"Version: %s\n",
5953 GetMagickVersion((size_t *) NULL));
5954 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5955 GetMagickCopyright());
5956 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5957 GetMagickFeatures());
5960 if (LocaleCompare("view",option+1) == 0)
5965 if (i == (ssize_t) argc)
5966 ThrowMogrifyException(OptionError,"MissingArgument",option);
5969 if (LocaleCompare("vignette",option+1) == 0)
5974 if (i == (ssize_t) argc)
5975 ThrowMogrifyException(OptionError,"MissingArgument",option);
5976 if (IsGeometry(argv[i]) == MagickFalse)
5977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5980 if (LocaleCompare("virtual-pixel",option+1) == 0)
5988 if (i == (ssize_t) argc)
5989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5990 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5993 ThrowMogrifyException(OptionError,
5994 "UnrecognizedVirtualPixelMethod",argv[i]);
5997 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6001 if (LocaleCompare("wave",option+1) == 0)
6004 if (i == (ssize_t) argc)
6005 ThrowMogrifyException(OptionError,"MissingArgument",option);
6006 if (IsGeometry(argv[i]) == MagickFalse)
6007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6010 if (LocaleCompare("weight",option+1) == 0)
6015 if (i == (ssize_t) (argc-1))
6016 ThrowMogrifyException(OptionError,"MissingArgument",option);
6019 if (LocaleCompare("white-point",option+1) == 0)
6024 if (i == (ssize_t) argc)
6025 ThrowMogrifyException(OptionError,"MissingArgument",option);
6026 if (IsGeometry(argv[i]) == MagickFalse)
6027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6030 if (LocaleCompare("white-threshold",option+1) == 0)
6035 if (i == (ssize_t) argc)
6036 ThrowMogrifyException(OptionError,"MissingArgument",option);
6037 if (IsGeometry(argv[i]) == MagickFalse)
6038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6041 if (LocaleCompare("write",option+1) == 0)
6044 if (i == (ssize_t) (argc-1))
6045 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6053 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6055 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6056 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6057 if (fire != MagickFalse)
6058 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6061 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6062 if (i != (ssize_t) argc)
6063 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6065 return(status != 0 ? MagickTrue : MagickFalse);
6069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6073 + M o g r i f y I m a g e I n f o %
6077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6079 % MogrifyImageInfo() applies image processing settings to the image as
6080 % prescribed by command line options.
6082 % The format of the MogrifyImageInfo method is:
6084 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6085 % const char **argv,ExceptionInfo *exception)
6087 % A description of each parameter follows:
6089 % o image_info: the image info..
6091 % o argc: Specifies a pointer to an integer describing the number of
6092 % elements in the argument vector.
6094 % o argv: Specifies a pointer to a text array containing the command line
6097 % o exception: return any errors or warnings in this structure.
6100 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6101 const int argc,const char **argv,ExceptionInfo *exception)
6116 Initialize method variables.
6118 assert(image_info != (ImageInfo *) NULL);
6119 assert(image_info->signature == MagickSignature);
6120 if (image_info->debug != MagickFalse)
6121 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6122 image_info->filename);
6126 Set the image settings.
6128 for (i=0; i < (ssize_t) argc; i++)
6131 if (IsCommandOption(option) == MagickFalse)
6133 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6134 count=MagickMax(count,0L);
6135 if ((i+count) >= (ssize_t) argc)
6137 switch (*(option+1))
6141 if (LocaleCompare("adjoin",option+1) == 0)
6143 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6146 if (LocaleCompare("antialias",option+1) == 0)
6148 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6151 if (LocaleCompare("attenuate",option+1) == 0)
6155 (void) DeleteImageOption(image_info,option+1);
6158 (void) SetImageOption(image_info,option+1,argv[i+1]);
6161 if (LocaleCompare("authenticate",option+1) == 0)
6164 (void) CloneString(&image_info->authenticate,(char *) NULL);
6166 (void) CloneString(&image_info->authenticate,argv[i+1]);
6173 if (LocaleCompare("background",option+1) == 0)
6177 (void) DeleteImageOption(image_info,option+1);
6178 (void) QueryColorDatabase(BackgroundColor,
6179 &image_info->background_color,exception);
6182 (void) SetImageOption(image_info,option+1,argv[i+1]);
6183 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6187 if (LocaleCompare("bias",option+1) == 0)
6191 (void) SetImageOption(image_info,option+1,"0.0");
6194 (void) SetImageOption(image_info,option+1,argv[i+1]);
6197 if (LocaleCompare("black-point-compensation",option+1) == 0)
6201 (void) SetImageOption(image_info,option+1,"false");
6204 (void) SetImageOption(image_info,option+1,"true");
6207 if (LocaleCompare("blue-primary",option+1) == 0)
6211 (void) SetImageOption(image_info,option+1,"0.0");
6214 (void) SetImageOption(image_info,option+1,argv[i+1]);
6217 if (LocaleCompare("bordercolor",option+1) == 0)
6221 (void) DeleteImageOption(image_info,option+1);
6222 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6226 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6228 (void) SetImageOption(image_info,option+1,argv[i+1]);
6231 if (LocaleCompare("box",option+1) == 0)
6235 (void) SetImageOption(image_info,"undercolor","none");
6238 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6245 if (LocaleCompare("cache",option+1) == 0)
6250 limit=MagickResourceInfinity;
6251 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6252 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6253 (void) SetMagickResourceLimit(MemoryResource,limit);
6254 (void) SetMagickResourceLimit(MapResource,2*limit);
6257 if (LocaleCompare("caption",option+1) == 0)
6261 (void) DeleteImageOption(image_info,option+1);
6264 (void) SetImageOption(image_info,option+1,argv[i+1]);
6267 if (LocaleCompare("channel",option+1) == 0)
6271 image_info->channel=DefaultChannels;
6274 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6277 if (LocaleCompare("colors",option+1) == 0)
6279 image_info->colors=StringToUnsignedLong(argv[i+1]);
6282 if (LocaleCompare("colorspace",option+1) == 0)
6286 image_info->colorspace=UndefinedColorspace;
6287 (void) SetImageOption(image_info,option+1,"undefined");
6290 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6291 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6292 (void) SetImageOption(image_info,option+1,argv[i+1]);
6295 if (LocaleCompare("comment",option+1) == 0)
6299 (void) DeleteImageOption(image_info,option+1);
6302 (void) SetImageOption(image_info,option+1,argv[i+1]);
6305 if (LocaleCompare("compose",option+1) == 0)
6309 (void) SetImageOption(image_info,option+1,"undefined");
6312 (void) SetImageOption(image_info,option+1,argv[i+1]);
6315 if (LocaleCompare("compress",option+1) == 0)
6319 image_info->compression=UndefinedCompression;
6320 (void) SetImageOption(image_info,option+1,"undefined");
6323 image_info->compression=(CompressionType) ParseCommandOption(
6324 MagickCompressOptions,MagickFalse,argv[i+1]);
6325 (void) SetImageOption(image_info,option+1,argv[i+1]);
6332 if (LocaleCompare("debug",option+1) == 0)
6335 (void) SetLogEventMask("none");
6337 (void) SetLogEventMask(argv[i+1]);
6338 image_info->debug=IsEventLogging();
6341 if (LocaleCompare("define",option+1) == 0)
6345 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6346 (void) DeleteImageRegistry(argv[i+1]+9);
6348 (void) DeleteImageOption(image_info,argv[i+1]);
6351 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6353 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6357 (void) DefineImageOption(image_info,argv[i+1]);
6360 if (LocaleCompare("delay",option+1) == 0)
6364 (void) SetImageOption(image_info,option+1,"0");
6367 (void) SetImageOption(image_info,option+1,argv[i+1]);
6370 if (LocaleCompare("density",option+1) == 0)
6377 if (image_info->density != (char *) NULL)
6378 image_info->density=DestroyString(image_info->density);
6379 (void) SetImageOption(image_info,option+1,"72");
6382 (void) CloneString(&image_info->density,argv[i+1]);
6383 (void) SetImageOption(image_info,option+1,argv[i+1]);
6386 if (LocaleCompare("depth",option+1) == 0)
6390 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6393 image_info->depth=StringToUnsignedLong(argv[i+1]);
6396 if (LocaleCompare("direction",option+1) == 0)
6400 (void) SetImageOption(image_info,option+1,"undefined");
6403 (void) SetImageOption(image_info,option+1,argv[i+1]);
6406 if (LocaleCompare("display",option+1) == 0)
6410 if (image_info->server_name != (char *) NULL)
6411 image_info->server_name=DestroyString(
6412 image_info->server_name);
6415 (void) CloneString(&image_info->server_name,argv[i+1]);
6418 if (LocaleCompare("dispose",option+1) == 0)
6422 (void) SetImageOption(image_info,option+1,"undefined");
6425 (void) SetImageOption(image_info,option+1,argv[i+1]);
6428 if (LocaleCompare("dither",option+1) == 0)
6432 image_info->dither=MagickFalse;
6433 (void) SetImageOption(image_info,option+1,"none");
6436 (void) SetImageOption(image_info,option+1,argv[i+1]);
6437 image_info->dither=MagickTrue;
6444 if (LocaleCompare("encoding",option+1) == 0)
6448 (void) SetImageOption(image_info,option+1,"undefined");
6451 (void) SetImageOption(image_info,option+1,argv[i+1]);
6454 if (LocaleCompare("endian",option+1) == 0)
6458 image_info->endian=UndefinedEndian;
6459 (void) SetImageOption(image_info,option+1,"undefined");
6462 image_info->endian=(EndianType) ParseCommandOption(
6463 MagickEndianOptions,MagickFalse,argv[i+1]);
6464 (void) SetImageOption(image_info,option+1,argv[i+1]);
6467 if (LocaleCompare("extract",option+1) == 0)
6470 Set image extract geometry.
6474 if (image_info->extract != (char *) NULL)
6475 image_info->extract=DestroyString(image_info->extract);
6478 (void) CloneString(&image_info->extract,argv[i+1]);
6485 if (LocaleCompare("fill",option+1) == 0)
6489 (void) SetImageOption(image_info,option+1,"none");
6492 (void) SetImageOption(image_info,option+1,argv[i+1]);
6495 if (LocaleCompare("filter",option+1) == 0)
6499 (void) SetImageOption(image_info,option+1,"undefined");
6502 (void) SetImageOption(image_info,option+1,argv[i+1]);
6505 if (LocaleCompare("font",option+1) == 0)
6509 if (image_info->font != (char *) NULL)
6510 image_info->font=DestroyString(image_info->font);
6513 (void) CloneString(&image_info->font,argv[i+1]);
6516 if (LocaleCompare("format",option+1) == 0)
6521 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6522 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6523 image_info->ping=MagickFalse;
6524 (void) SetImageOption(image_info,option+1,argv[i+1]);
6527 if (LocaleCompare("fuzz",option+1) == 0)
6531 image_info->fuzz=0.0;
6532 (void) SetImageOption(image_info,option+1,"0");
6535 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6537 (void) SetImageOption(image_info,option+1,argv[i+1]);
6544 if (LocaleCompare("gravity",option+1) == 0)
6548 (void) SetImageOption(image_info,option+1,"undefined");
6551 (void) SetImageOption(image_info,option+1,argv[i+1]);
6554 if (LocaleCompare("green-primary",option+1) == 0)
6558 (void) SetImageOption(image_info,option+1,"0.0");
6561 (void) SetImageOption(image_info,option+1,argv[i+1]);
6568 if (LocaleCompare("intent",option+1) == 0)
6572 (void) SetImageOption(image_info,option+1,"undefined");
6575 (void) SetImageOption(image_info,option+1,argv[i+1]);
6578 if (LocaleCompare("interlace",option+1) == 0)
6582 image_info->interlace=UndefinedInterlace;
6583 (void) SetImageOption(image_info,option+1,"undefined");
6586 image_info->interlace=(InterlaceType) ParseCommandOption(
6587 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6588 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 if (LocaleCompare("interline-spacing",option+1) == 0)
6595 (void) SetImageOption(image_info,option+1,"undefined");
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("interpolate",option+1) == 0)
6605 (void) SetImageOption(image_info,option+1,"undefined");
6608 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 if (LocaleCompare("interword-spacing",option+1) == 0)
6615 (void) SetImageOption(image_info,option+1,"undefined");
6618 (void) SetImageOption(image_info,option+1,argv[i+1]);
6625 if (LocaleCompare("kerning",option+1) == 0)
6629 (void) SetImageOption(image_info,option+1,"undefined");
6632 (void) SetImageOption(image_info,option+1,argv[i+1]);
6639 if (LocaleCompare("label",option+1) == 0)
6643 (void) DeleteImageOption(image_info,option+1);
6646 (void) SetImageOption(image_info,option+1,argv[i+1]);
6649 if (LocaleCompare("limit",option+1) == 0)
6659 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6660 MagickFalse,argv[i+1]);
6661 limit=MagickResourceInfinity;
6662 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6663 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6664 (void) SetMagickResourceLimit(type,limit);
6667 if (LocaleCompare("list",option+1) == 0)
6673 Display configuration list.
6675 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6678 case MagickCoderOptions:
6680 (void) ListCoderInfo((FILE *) NULL,exception);
6683 case MagickColorOptions:
6685 (void) ListColorInfo((FILE *) NULL,exception);
6688 case MagickConfigureOptions:
6690 (void) ListConfigureInfo((FILE *) NULL,exception);
6693 case MagickDelegateOptions:
6695 (void) ListDelegateInfo((FILE *) NULL,exception);
6698 case MagickFontOptions:
6700 (void) ListTypeInfo((FILE *) NULL,exception);
6703 case MagickFormatOptions:
6705 (void) ListMagickInfo((FILE *) NULL,exception);
6708 case MagickLocaleOptions:
6710 (void) ListLocaleInfo((FILE *) NULL,exception);
6713 case MagickLogOptions:
6715 (void) ListLogInfo((FILE *) NULL,exception);
6718 case MagickMagicOptions:
6720 (void) ListMagicInfo((FILE *) NULL,exception);
6723 case MagickMimeOptions:
6725 (void) ListMimeInfo((FILE *) NULL,exception);
6728 case MagickModuleOptions:
6730 (void) ListModuleInfo((FILE *) NULL,exception);
6733 case MagickPolicyOptions:
6735 (void) ListPolicyInfo((FILE *) NULL,exception);
6738 case MagickResourceOptions:
6740 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6743 case MagickThresholdOptions:
6745 (void) ListThresholdMaps((FILE *) NULL,exception);
6750 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6757 if (LocaleCompare("log",option+1) == 0)
6761 (void) SetLogFormat(argv[i+1]);
6764 if (LocaleCompare("loop",option+1) == 0)
6768 (void) SetImageOption(image_info,option+1,"0");
6771 (void) SetImageOption(image_info,option+1,argv[i+1]);
6778 if (LocaleCompare("matte",option+1) == 0)
6782 (void) SetImageOption(image_info,option+1,"false");
6785 (void) SetImageOption(image_info,option+1,"true");
6788 if (LocaleCompare("mattecolor",option+1) == 0)
6792 (void) SetImageOption(image_info,option+1,argv[i+1]);
6793 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
6797 (void) SetImageOption(image_info,option+1,argv[i+1]);
6798 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6802 if (LocaleCompare("monitor",option+1) == 0)
6804 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6808 if (LocaleCompare("monochrome",option+1) == 0)
6810 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6817 if (LocaleCompare("orient",option+1) == 0)
6821 image_info->orientation=UndefinedOrientation;
6822 (void) SetImageOption(image_info,option+1,"undefined");
6825 image_info->orientation=(OrientationType) ParseCommandOption(
6826 MagickOrientationOptions,MagickFalse,argv[i+1]);
6827 (void) SetImageOption(image_info,option+1,argv[i+1]);
6833 if (LocaleCompare("page",option+1) == 0)
6837 page[MaxTextExtent];
6850 (void) DeleteImageOption(image_info,option+1);
6851 (void) CloneString(&image_info->page,(char *) NULL);
6854 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6855 image_option=GetImageOption(image_info,"page");
6856 if (image_option != (const char *) NULL)
6857 flags=ParseAbsoluteGeometry(image_option,&geometry);
6858 canonical_page=GetPageGeometry(argv[i+1]);
6859 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6860 canonical_page=DestroyString(canonical_page);
6861 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6862 (unsigned long) geometry.width,(unsigned long) geometry.height);
6863 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6864 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6865 (unsigned long) geometry.width,(unsigned long) geometry.height,
6866 (long) geometry.x,(long) geometry.y);
6867 (void) SetImageOption(image_info,option+1,page);
6868 (void) CloneString(&image_info->page,page);
6871 if (LocaleCompare("pen",option+1) == 0)
6875 (void) SetImageOption(image_info,option+1,"none");
6878 (void) SetImageOption(image_info,option+1,argv[i+1]);
6881 if (LocaleCompare("ping",option+1) == 0)
6883 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6886 if (LocaleCompare("pointsize",option+1) == 0)
6889 geometry_info.rho=0.0;
6891 (void) ParseGeometry(argv[i+1],&geometry_info);
6892 image_info->pointsize=geometry_info.rho;
6895 if (LocaleCompare("precision",option+1) == 0)
6897 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6900 if (LocaleCompare("preview",option+1) == 0)
6907 image_info->preview_type=UndefinedPreview;
6910 image_info->preview_type=(PreviewType) ParseCommandOption(
6911 MagickPreviewOptions,MagickFalse,argv[i+1]);
6918 if (LocaleCompare("quality",option+1) == 0)
6921 Set image compression quality.
6925 image_info->quality=UndefinedCompressionQuality;
6926 (void) SetImageOption(image_info,option+1,"0");
6929 image_info->quality=StringToUnsignedLong(argv[i+1]);
6930 (void) SetImageOption(image_info,option+1,argv[i+1]);
6933 if (LocaleCompare("quiet",option+1) == 0)
6935 static WarningHandler
6936 warning_handler = (WarningHandler) NULL;
6941 Restore error or warning messages.
6943 warning_handler=SetWarningHandler(warning_handler);
6947 Suppress error or warning messages.
6949 warning_handler=SetWarningHandler((WarningHandler) NULL);
6956 if (LocaleCompare("red-primary",option+1) == 0)
6960 (void) SetImageOption(image_info,option+1,"0.0");
6963 (void) SetImageOption(image_info,option+1,argv[i+1]);
6970 if (LocaleCompare("sampling-factor",option+1) == 0)
6973 Set image sampling factor.
6977 if (image_info->sampling_factor != (char *) NULL)
6978 image_info->sampling_factor=DestroyString(
6979 image_info->sampling_factor);
6982 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6985 if (LocaleCompare("scene",option+1) == 0)
6992 image_info->scene=0;
6993 (void) SetImageOption(image_info,option+1,"0");
6996 image_info->scene=StringToUnsignedLong(argv[i+1]);
6997 (void) SetImageOption(image_info,option+1,argv[i+1]);
7000 if (LocaleCompare("seed",option+1) == 0)
7007 seed=(size_t) time((time_t *) NULL);
7008 SeedPseudoRandomGenerator(seed);
7011 seed=StringToUnsignedLong(argv[i+1]);
7012 SeedPseudoRandomGenerator(seed);
7015 if (LocaleCompare("size",option+1) == 0)
7019 if (image_info->size != (char *) NULL)
7020 image_info->size=DestroyString(image_info->size);
7023 (void) CloneString(&image_info->size,argv[i+1]);
7026 if (LocaleCompare("stroke",option+1) == 0)
7030 (void) SetImageOption(image_info,option+1,"none");
7033 (void) SetImageOption(image_info,option+1,argv[i+1]);
7036 if (LocaleCompare("strokewidth",option+1) == 0)
7040 (void) SetImageOption(image_info,option+1,"0");
7043 (void) SetImageOption(image_info,option+1,argv[i+1]);
7046 if (LocaleCompare("synchronize",option+1) == 0)
7050 image_info->synchronize=MagickFalse;
7053 image_info->synchronize=MagickTrue;
7060 if (LocaleCompare("taint",option+1) == 0)
7064 (void) SetImageOption(image_info,option+1,"false");
7067 (void) SetImageOption(image_info,option+1,"true");
7070 if (LocaleCompare("texture",option+1) == 0)
7074 if (image_info->texture != (char *) NULL)
7075 image_info->texture=DestroyString(image_info->texture);
7078 (void) CloneString(&image_info->texture,argv[i+1]);
7081 if (LocaleCompare("tile-offset",option+1) == 0)
7085 (void) SetImageOption(image_info,option+1,"0");
7088 (void) SetImageOption(image_info,option+1,argv[i+1]);
7091 if (LocaleCompare("transparent-color",option+1) == 0)
7095 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7096 (void) SetImageOption(image_info,option+1,"none");
7099 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7104 if (LocaleCompare("type",option+1) == 0)
7108 image_info->type=UndefinedType;
7109 (void) SetImageOption(image_info,option+1,"undefined");
7112 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7113 MagickFalse,argv[i+1]);
7114 (void) SetImageOption(image_info,option+1,argv[i+1]);
7121 if (LocaleCompare("undercolor",option+1) == 0)
7125 (void) DeleteImageOption(image_info,option+1);
7128 (void) SetImageOption(image_info,option+1,argv[i+1]);
7131 if (LocaleCompare("units",option+1) == 0)
7135 image_info->units=UndefinedResolution;
7136 (void) SetImageOption(image_info,option+1,"undefined");
7139 image_info->units=(ResolutionType) ParseCommandOption(
7140 MagickResolutionOptions,MagickFalse,argv[i+1]);
7141 (void) SetImageOption(image_info,option+1,argv[i+1]);
7148 if (LocaleCompare("verbose",option+1) == 0)
7152 image_info->verbose=MagickFalse;
7155 image_info->verbose=MagickTrue;
7156 image_info->ping=MagickFalse;
7159 if (LocaleCompare("view",option+1) == 0)
7163 if (image_info->view != (char *) NULL)
7164 image_info->view=DestroyString(image_info->view);
7167 (void) CloneString(&image_info->view,argv[i+1]);
7170 if (LocaleCompare("virtual-pixel",option+1) == 0)
7174 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7175 (void) SetImageOption(image_info,option+1,"undefined");
7178 image_info->virtual_pixel_method=(VirtualPixelMethod)
7179 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7181 (void) SetImageOption(image_info,option+1,argv[i+1]);
7188 if (LocaleCompare("white-point",option+1) == 0)
7192 (void) SetImageOption(image_info,option+1,"0.0");
7195 (void) SetImageOption(image_info,option+1,argv[i+1]);
7209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7213 + M o g r i f y I m a g e L i s t %
7217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7219 % MogrifyImageList() applies any command line options that might affect the
7220 % entire image list (e.g. -append, -coalesce, etc.).
7222 % The format of the MogrifyImage method is:
7224 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7225 % const char **argv,Image **images,ExceptionInfo *exception)
7227 % A description of each parameter follows:
7229 % o image_info: the image info..
7231 % o argc: Specifies a pointer to an integer describing the number of
7232 % elements in the argument vector.
7234 % o argv: Specifies a pointer to a text array containing the command line
7237 % o images: pointer to pointer of the first image in image list.
7239 % o exception: return any errors or warnings in this structure.
7242 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7243 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7268 Apply options to the image list.
7270 assert(image_info != (ImageInfo *) NULL);
7271 assert(image_info->signature == MagickSignature);
7272 assert(images != (Image **) NULL);
7273 assert((*images)->previous == (Image *) NULL);
7274 assert((*images)->signature == MagickSignature);
7275 if ((*images)->debug != MagickFalse)
7276 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7277 (*images)->filename);
7278 if ((argc <= 0) || (*argv == (char *) NULL))
7280 mogrify_info=CloneImageInfo(image_info);
7281 quantize_info=AcquireQuantizeInfo(mogrify_info);
7282 channel=mogrify_info->channel;
7284 for (i=0; i < (ssize_t) argc; i++)
7286 if (*images == (Image *) NULL)
7289 if (IsCommandOption(option) == MagickFalse)
7291 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7292 count=MagickMax(count,0L);
7293 if ((i+count) >= (ssize_t) argc)
7295 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7296 switch (*(option+1))
7300 if (LocaleCompare("affinity",option+1) == 0)
7302 (void) SyncImagesSettings(mogrify_info,*images);
7305 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7306 InheritException(exception,&(*images)->exception);
7312 if (LocaleCompare("append",option+1) == 0)
7317 (void) SyncImagesSettings(mogrify_info,*images);
7318 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7319 MagickFalse,exception);
7320 if (append_image == (Image *) NULL)
7325 *images=DestroyImageList(*images);
7326 *images=append_image;
7329 if (LocaleCompare("average",option+1) == 0)
7335 Average an image sequence (deprecated).
7337 (void) SyncImagesSettings(mogrify_info,*images);
7338 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7340 if (average_image == (Image *) NULL)
7345 *images=DestroyImageList(*images);
7346 *images=average_image;
7353 if (LocaleCompare("channel",option+1) == 0)
7357 channel=DefaultChannels;
7360 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7363 if (LocaleCompare("clut",option+1) == 0)
7369 (void) SyncImagesSettings(mogrify_info,*images);
7370 image=RemoveFirstImageFromList(images);
7371 clut_image=RemoveFirstImageFromList(images);
7372 if (clut_image == (Image *) NULL)
7377 (void) ClutImageChannel(image,channel,clut_image);
7378 clut_image=DestroyImage(clut_image);
7379 InheritException(exception,&image->exception);
7380 *images=DestroyImageList(*images);
7384 if (LocaleCompare("coalesce",option+1) == 0)
7389 (void) SyncImagesSettings(mogrify_info,*images);
7390 coalesce_image=CoalesceImages(*images,exception);
7391 if (coalesce_image == (Image *) NULL)
7396 *images=DestroyImageList(*images);
7397 *images=coalesce_image;
7400 if (LocaleCompare("combine",option+1) == 0)
7405 (void) SyncImagesSettings(mogrify_info,*images);
7406 combine_image=CombineImages(*images,channel,exception);
7407 if (combine_image == (Image *) NULL)
7412 *images=DestroyImageList(*images);
7413 *images=combine_image;
7416 if (LocaleCompare("composite",option+1) == 0)
7426 (void) SyncImagesSettings(mogrify_info,*images);
7427 image=RemoveFirstImageFromList(images);
7428 composite_image=RemoveFirstImageFromList(images);
7429 if (composite_image == (Image *) NULL)
7434 (void) TransformImage(&composite_image,(char *) NULL,
7435 composite_image->geometry);
7436 SetGeometry(composite_image,&geometry);
7437 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7438 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7440 mask_image=RemoveFirstImageFromList(images);
7441 if (mask_image != (Image *) NULL)
7443 if ((image->compose == DisplaceCompositeOp) ||
7444 (image->compose == DistortCompositeOp))
7447 Merge Y displacement into X displacement image.
7449 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7451 mask_image=DestroyImage(mask_image);
7456 Set a blending mask for the composition.
7458 /* POSIBLE ERROR; what if image->mask already set */
7459 image->mask=mask_image;
7460 (void) NegateImage(image->mask,MagickFalse);
7463 (void) CompositeImageChannel(image,channel,image->compose,
7464 composite_image,geometry.x,geometry.y);
7465 if (mask_image != (Image *) NULL)
7466 mask_image=image->mask=DestroyImage(image->mask);
7467 composite_image=DestroyImage(composite_image);
7468 InheritException(exception,&image->exception);
7469 *images=DestroyImageList(*images);
7474 This has been merged completely into MogrifyImage()
7475 if (LocaleCompare("crop",option+1) == 0)
7486 (void) SyncImagesSettings(mogrify_info,*images);
7487 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7488 if (((geometry.width == 0) && (geometry.height == 0)) ||
7489 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7491 (void) TransformImages(images,argv[i+1],(char *) NULL);
7492 InheritException(exception,&(*images)->exception);
7500 if (LocaleCompare("deconstruct",option+1) == 0)
7505 (void) SyncImagesSettings(mogrify_info,*images);
7506 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7508 if (deconstruct_image == (Image *) NULL)
7513 *images=DestroyImageList(*images);
7514 *images=deconstruct_image;
7517 if (LocaleCompare("delete",option+1) == 0)
7520 DeleteImages(images,"-1",exception);
7522 DeleteImages(images,argv[i+1],exception);
7525 if (LocaleCompare("dither",option+1) == 0)
7529 quantize_info->dither=MagickFalse;
7532 quantize_info->dither=MagickTrue;
7533 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7534 MagickDitherOptions,MagickFalse,argv[i+1]);
7537 if (LocaleCompare("duplicate",option+1) == 0)
7543 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7552 number_duplicates=(size_t) StringToLong(argv[i+1]);
7553 p=strchr(argv[i+1],',');
7554 if (p == (const char *) NULL)
7555 duplicate_images=DuplicateImages(*images,number_duplicates,
7558 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7561 AppendImageToList(images, duplicate_images);
7562 (void) SyncImagesSettings(mogrify_info,*images);
7569 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7574 MagickEvaluateOperator
7577 (void) SyncImageSettings(mogrify_info,*images);
7578 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
7579 MagickFalse,argv[i+1]);
7580 evaluate_image=EvaluateImages(*images,op,exception);
7581 if (evaluate_image == (Image *) NULL)
7586 *images=DestroyImageList(*images);
7587 *images=evaluate_image;
7594 if (LocaleCompare("fft",option+1) == 0)
7600 Implements the discrete Fourier transform (DFT).
7602 (void) SyncImageSettings(mogrify_info,*images);
7603 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7604 MagickTrue : MagickFalse,exception);
7605 if (fourier_image == (Image *) NULL)
7607 *images=DestroyImage(*images);
7608 *images=fourier_image;
7611 if (LocaleCompare("flatten",option+1) == 0)
7616 (void) SyncImagesSettings(mogrify_info,*images);
7617 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7618 if (flatten_image == (Image *) NULL)
7620 *images=DestroyImageList(*images);
7621 *images=flatten_image;
7624 if (LocaleCompare("fx",option+1) == 0)
7629 (void) SyncImagesSettings(mogrify_info,*images);
7630 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7631 if (fx_image == (Image *) NULL)
7636 *images=DestroyImageList(*images);
7644 if (LocaleCompare("hald-clut",option+1) == 0)
7650 (void) SyncImagesSettings(mogrify_info,*images);
7651 image=RemoveFirstImageFromList(images);
7652 hald_image=RemoveFirstImageFromList(images);
7653 if (hald_image == (Image *) NULL)
7658 (void) HaldClutImageChannel(image,channel,hald_image);
7659 hald_image=DestroyImage(hald_image);
7660 InheritException(exception,&image->exception);
7661 if (*images != (Image *) NULL)
7662 *images=DestroyImageList(*images);
7670 if (LocaleCompare("ift",option+1) == 0)
7678 Implements the inverse fourier discrete Fourier transform (DFT).
7680 (void) SyncImagesSettings(mogrify_info,*images);
7681 magnitude_image=RemoveFirstImageFromList(images);
7682 phase_image=RemoveFirstImageFromList(images);
7683 if (phase_image == (Image *) NULL)
7688 fourier_image=InverseFourierTransformImage(magnitude_image,
7689 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7690 if (fourier_image == (Image *) NULL)
7692 if (*images != (Image *) NULL)
7693 *images=DestroyImage(*images);
7694 *images=fourier_image;
7697 if (LocaleCompare("insert",option+1) == 0)
7705 index=(ssize_t) StringToLong(argv[i+1]);
7706 p=RemoveLastImageFromList(images);
7707 if (p == (Image *) NULL)
7709 (void) ThrowMagickException(exception,GetMagickModule(),
7710 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7716 PrependImageToList(images,q);
7718 if (index == (ssize_t) GetImageListLength(*images))
7719 AppendImageToList(images,q);
7722 q=GetImageFromList(*images,index-1);
7723 if (q == (Image *) NULL)
7725 (void) ThrowMagickException(exception,GetMagickModule(),
7726 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7730 InsertImageInList(&q,p);
7732 *images=GetFirstImageInList(q);
7739 if (LocaleCompare("layers",option+1) == 0)
7747 (void) SyncImagesSettings(mogrify_info,*images);
7748 layers=(Image *) NULL;
7749 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7750 MagickFalse,argv[i+1]);
7755 layers=CoalesceImages(*images,exception);
7758 case CompareAnyLayer:
7759 case CompareClearLayer:
7760 case CompareOverlayLayer:
7763 layers=CompareImagesLayers(*images,method,exception);
7769 case TrimBoundsLayer:
7771 layers=MergeImageLayers(*images,method,exception);
7776 layers=DisposeImages(*images,exception);
7779 case OptimizeImageLayer:
7781 layers=OptimizeImageLayers(*images,exception);
7784 case OptimizePlusLayer:
7786 layers=OptimizePlusImageLayers(*images,exception);
7789 case OptimizeTransLayer:
7791 OptimizeImageTransparency(*images,exception);
7794 case RemoveDupsLayer:
7796 RemoveDuplicateLayers(images,exception);
7799 case RemoveZeroLayer:
7801 RemoveZeroDelayLayers(images,exception);
7807 General Purpose, GIF Animation Optimizer.
7809 layers=CoalesceImages(*images,exception);
7810 if (layers == (Image *) NULL)
7815 InheritException(exception,&layers->exception);
7816 *images=DestroyImageList(*images);
7818 layers=OptimizeImageLayers(*images,exception);
7819 if (layers == (Image *) NULL)
7824 InheritException(exception,&layers->exception);
7825 *images=DestroyImageList(*images);
7827 layers=(Image *) NULL;
7828 OptimizeImageTransparency(*images,exception);
7829 InheritException(exception,&(*images)->exception);
7830 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7833 case CompositeLayer:
7845 Split image sequence at the first 'NULL:' image.
7848 while (source != (Image *) NULL)
7850 source=GetNextImageInList(source);
7851 if ((source != (Image *) NULL) &&
7852 (LocaleCompare(source->magick,"NULL") == 0))
7855 if (source != (Image *) NULL)
7857 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7858 (GetNextImageInList(source) == (Image *) NULL))
7859 source=(Image *) NULL;
7863 Separate the two lists, junk the null: image.
7865 source=SplitImageList(source->previous);
7866 DeleteImageFromList(&source);
7869 if (source == (Image *) NULL)
7871 (void) ThrowMagickException(exception,GetMagickModule(),
7872 OptionError,"MissingNullSeparator","layers Composite");
7877 Adjust offset with gravity and virtual canvas.
7879 SetGeometry(*images,&geometry);
7880 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7881 geometry.width=source->page.width != 0 ?
7882 source->page.width : source->columns;
7883 geometry.height=source->page.height != 0 ?
7884 source->page.height : source->rows;
7885 GravityAdjustGeometry((*images)->page.width != 0 ?
7886 (*images)->page.width : (*images)->columns,
7887 (*images)->page.height != 0 ? (*images)->page.height :
7888 (*images)->rows,(*images)->gravity,&geometry);
7889 compose=OverCompositeOp;
7890 option=GetImageOption(mogrify_info,"compose");
7891 if (option != (const char *) NULL)
7892 compose=(CompositeOperator) ParseCommandOption(
7893 MagickComposeOptions,MagickFalse,option);
7894 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7896 source=DestroyImageList(source);
7900 if (layers == (Image *) NULL)
7902 InheritException(exception,&layers->exception);
7903 *images=DestroyImageList(*images);
7911 if (LocaleCompare("map",option+1) == 0)
7913 (void) SyncImagesSettings(mogrify_info,*images);
7916 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7917 InheritException(exception,&(*images)->exception);
7923 if (LocaleCompare("maximum",option+1) == 0)
7929 Maximum image sequence (deprecated).
7931 (void) SyncImagesSettings(mogrify_info,*images);
7932 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7933 if (maximum_image == (Image *) NULL)
7938 *images=DestroyImageList(*images);
7939 *images=maximum_image;
7942 if (LocaleCompare("minimum",option+1) == 0)
7948 Minimum image sequence (deprecated).
7950 (void) SyncImagesSettings(mogrify_info,*images);
7951 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7952 if (minimum_image == (Image *) NULL)
7957 *images=DestroyImageList(*images);
7958 *images=minimum_image;
7961 if (LocaleCompare("morph",option+1) == 0)
7966 (void) SyncImagesSettings(mogrify_info,*images);
7967 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7969 if (morph_image == (Image *) NULL)
7974 *images=DestroyImageList(*images);
7975 *images=morph_image;
7978 if (LocaleCompare("mosaic",option+1) == 0)
7983 (void) SyncImagesSettings(mogrify_info,*images);
7984 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7985 if (mosaic_image == (Image *) NULL)
7990 *images=DestroyImageList(*images);
7991 *images=mosaic_image;
7998 if (LocaleCompare("print",option+1) == 0)
8003 (void) SyncImagesSettings(mogrify_info,*images);
8004 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8005 if (string == (char *) NULL)
8007 InheritException(exception,&(*images)->exception);
8008 (void) FormatLocaleFile(stdout,"%s",string);
8009 string=DestroyString(string);
8011 if (LocaleCompare("process",option+1) == 0)
8020 (void) SyncImagesSettings(mogrify_info,*images);
8021 arguments=StringToArgv(argv[i+1],&number_arguments);
8022 if (arguments == (char **) NULL)
8024 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8045 Support old style syntax, filter="-option arg".
8047 length=strlen(argv[i+1]);
8048 token=(char *) NULL;
8049 if (~length >= (MaxTextExtent-1))
8050 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8052 if (token == (char *) NULL)
8055 arguments=argv[i+1];
8056 token_info=AcquireTokenInfo();
8057 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8058 "\"",'\0',&breaker,&next,"e);
8059 token_info=DestroyTokenInfo(token_info);
8065 argv=(&(arguments[next]));
8066 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8069 token=DestroyString(token);
8072 (void) SubstituteString(&arguments[1],"-","");
8073 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8074 number_arguments-2,(const char **) arguments+2,exception);
8075 for (j=0; j < number_arguments; j++)
8076 arguments[j]=DestroyString(arguments[j]);
8077 arguments=(char **) RelinquishMagickMemory(arguments);
8084 if (LocaleCompare("reverse",option+1) == 0)
8086 ReverseImageList(images);
8087 InheritException(exception,&(*images)->exception);
8094 if (LocaleCompare("smush",option+1) == 0)
8102 (void) SyncImagesSettings(mogrify_info,*images);
8103 offset=(ssize_t) StringToLong(argv[i+1]);
8104 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8105 MagickFalse,offset,exception);
8106 if (smush_image == (Image *) NULL)
8111 *images=DestroyImageList(*images);
8112 *images=smush_image;
8115 if (LocaleCompare("swap",option+1) == 0)
8136 flags=ParseGeometry(argv[i+1],&geometry_info);
8137 index=(ssize_t) geometry_info.rho;
8138 if ((flags & SigmaValue) != 0)
8139 swap_index=(ssize_t) geometry_info.sigma;
8141 p=GetImageFromList(*images,index);
8142 q=GetImageFromList(*images,swap_index);
8143 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8145 (void) ThrowMagickException(exception,GetMagickModule(),
8146 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8152 swap=CloneImage(p,0,0,MagickTrue,exception);
8153 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8154 ReplaceImageInList(&q,swap);
8155 *images=GetFirstImageInList(q);
8162 if (LocaleCompare("write",option+1) == 0)
8173 (void) SyncImagesSettings(mogrify_info,*images);
8174 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8175 (void) DeleteImageRegistry(key);
8176 write_images=(*images);
8178 write_images=CloneImageList(*images,exception);
8179 write_info=CloneImageInfo(mogrify_info);
8180 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8181 write_info=DestroyImageInfo(write_info);
8183 write_images=DestroyImageList(write_images);
8193 quantize_info=DestroyQuantizeInfo(quantize_info);
8194 mogrify_info=DestroyImageInfo(mogrify_info);
8195 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8196 return(status != 0 ? MagickTrue : MagickFalse);
8200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8204 + M o g r i f y I m a g e s %
8208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8210 % MogrifyImages() applies image processing options to a sequence of images as
8211 % prescribed by command line options.
8213 % The format of the MogrifyImage method is:
8215 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8216 % const MagickBooleanType post,const int argc,const char **argv,
8217 % Image **images,Exceptioninfo *exception)
8219 % A description of each parameter follows:
8221 % o image_info: the image info..
8223 % o post: If true, post process image list operators otherwise pre-process.
8225 % o argc: Specifies a pointer to an integer describing the number of
8226 % elements in the argument vector.
8228 % o argv: Specifies a pointer to a text array containing the command line
8231 % o images: pointer to a pointer of the first image in image list.
8233 % o exception: return any errors or warnings in this structure.
8236 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8237 const MagickBooleanType post,const int argc,const char **argv,
8238 Image **images,ExceptionInfo *exception)
8240 #define MogrifyImageTag "Mogrify/Image"
8254 assert(image_info != (ImageInfo *) NULL);
8255 assert(image_info->signature == MagickSignature);
8256 if (images == (Image **) NULL)
8257 return(MogrifyImage(image_info,argc,argv,images,exception));
8258 assert((*images)->previous == (Image *) NULL);
8259 assert((*images)->signature == MagickSignature);
8260 if ((*images)->debug != MagickFalse)
8261 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8262 (*images)->filename);
8263 if ((argc <= 0) || (*argv == (char *) NULL))
8265 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8270 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8275 Pre-process multi-image sequence operators
8277 if (post == MagickFalse)
8278 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8280 For each image, process simple single image operators
8283 n=GetImageListLength(*images);
8287 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8288 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8290 status&=MogrifyImage(image_info,argc,argv,images,exception);
8291 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8292 if (proceed == MagickFalse)
8294 if ( (*images)->next == (Image *) NULL )
8296 *images=(*images)->next;
8299 assert( *images != (Image *) NULL );
8301 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8302 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8306 Post-process, multi-image sequence operators
8308 *images=GetFirstImageInList(*images);
8309 if (post != MagickFalse)
8310 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8311 return(status != 0 ? MagickTrue : MagickFalse);