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, CompareImageCommand,
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) AutoGammaImageChannel(*image,channel);
803 if (LocaleCompare("auto-level",option+1) == 0)
806 Perfectly Normalize (max/min stretch) the image
808 (void) SyncImageSettings(mogrify_info,*image);
809 (void) AutoLevelImageChannel(*image,channel);
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]);
983 if (LocaleCompare("charcoal",option+1) == 0)
988 (void) SyncImageSettings(mogrify_info,*image);
989 flags=ParseGeometry(argv[i+1],&geometry_info);
990 if ((flags & SigmaValue) == 0)
991 geometry_info.sigma=1.0;
992 mogrify_image=CharcoalImage(*image,geometry_info.rho,
993 geometry_info.sigma,exception);
996 if (LocaleCompare("chop",option+1) == 0)
1001 (void) SyncImageSettings(mogrify_info,*image);
1002 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1003 mogrify_image=ChopImage(*image,&geometry,exception);
1006 if (LocaleCompare("clamp",option+1) == 0)
1011 (void) SyncImageSettings(mogrify_info,*image);
1012 (void) ClampImageChannel(*image,channel);
1013 InheritException(exception,&(*image)->exception);
1016 if (LocaleCompare("clip",option+1) == 0)
1018 (void) SyncImageSettings(mogrify_info,*image);
1021 (void) SetImageClipMask(*image,(Image *) NULL);
1022 InheritException(exception,&(*image)->exception);
1025 (void) ClipImage(*image);
1026 InheritException(exception,&(*image)->exception);
1029 if (LocaleCompare("clip-mask",option+1) == 0)
1046 (void) SyncImageSettings(mogrify_info,*image);
1052 (void) SetImageMask(*image,(Image *) NULL);
1053 InheritException(exception,&(*image)->exception);
1058 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1060 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1061 if (mask_image == (Image *) NULL)
1063 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1064 return(MagickFalse);
1065 mask_view=AcquireCacheView(mask_image);
1066 for (y=0; y < (ssize_t) mask_image->rows; y++)
1068 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1070 if (q == (const Quantum *) NULL)
1072 for (x=0; x < (ssize_t) mask_image->columns; x++)
1074 if (mask_image->matte == MagickFalse)
1075 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1076 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1077 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1078 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1079 q+=GetPixelChannels(mask_image);
1081 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1084 mask_view=DestroyCacheView(mask_view);
1085 mask_image->matte=MagickTrue;
1086 (void) SetImageClipMask(*image,mask_image);
1087 mask_image=DestroyImage(mask_image);
1088 InheritException(exception,&(*image)->exception);
1091 if (LocaleCompare("clip-path",option+1) == 0)
1093 (void) SyncImageSettings(mogrify_info,*image);
1094 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1096 InheritException(exception,&(*image)->exception);
1099 if (LocaleCompare("colorize",option+1) == 0)
1104 (void) SyncImageSettings(mogrify_info,*image);
1105 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1109 if (LocaleCompare("color-matrix",option+1) == 0)
1114 (void) SyncImageSettings(mogrify_info,*image);
1115 kernel=AcquireKernelInfo(argv[i+1]);
1116 if (kernel == (KernelInfo *) NULL)
1118 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1119 kernel=DestroyKernelInfo(kernel);
1122 if (LocaleCompare("colors",option+1) == 0)
1125 Reduce the number of colors in the image.
1127 (void) SyncImageSettings(mogrify_info,*image);
1128 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1129 if (quantize_info->number_colors == 0)
1131 if (((*image)->storage_class == DirectClass) ||
1132 (*image)->colors > quantize_info->number_colors)
1133 (void) QuantizeImage(quantize_info,*image);
1135 (void) CompressImageColormap(*image);
1136 InheritException(exception,&(*image)->exception);
1139 if (LocaleCompare("colorspace",option+1) == 0)
1144 (void) SyncImageSettings(mogrify_info,*image);
1147 (void) TransformImageColorspace(*image,RGBColorspace);
1148 InheritException(exception,&(*image)->exception);
1151 colorspace=(ColorspaceType) ParseCommandOption(
1152 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1153 (void) TransformImageColorspace(*image,colorspace);
1154 InheritException(exception,&(*image)->exception);
1157 if (LocaleCompare("contrast",option+1) == 0)
1159 (void) SyncImageSettings(mogrify_info,*image);
1160 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1162 InheritException(exception,&(*image)->exception);
1165 if (LocaleCompare("contrast-stretch",option+1) == 0)
1175 Contrast stretch image.
1177 (void) SyncImageSettings(mogrify_info,*image);
1178 flags=ParseGeometry(argv[i+1],&geometry_info);
1179 black_point=geometry_info.rho;
1180 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1182 if ((flags & PercentValue) != 0)
1184 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1185 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1187 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1189 (void) ContrastStretchImageChannel(*image,channel,black_point,
1191 InheritException(exception,&(*image)->exception);
1194 if (LocaleCompare("convolve",option+1) == 0)
1205 (void) SyncImageSettings(mogrify_info,*image);
1206 kernel=AcquireKernelInfo(argv[i+1]);
1207 if (kernel == (KernelInfo *) NULL)
1210 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1211 gamma+=kernel->values[j];
1212 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1213 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1214 kernel->values[j]*=gamma;
1215 mogrify_image=FilterImageChannel(*image,channel,kernel,exception);
1216 kernel=DestroyKernelInfo(kernel);
1219 if (LocaleCompare("crop",option+1) == 0)
1222 Crop a image to a smaller size
1224 (void) SyncImageSettings(mogrify_info,*image);
1226 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1227 if (((geometry.width != 0) || (geometry.height != 0)) &&
1228 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1232 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1233 mogrify_image->next = mogrify_image->previous = (Image *)NULL;
1234 (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL);
1235 InheritException(exception,&mogrify_image->exception);
1237 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1241 if (LocaleCompare("cycle",option+1) == 0)
1244 Cycle an image colormap.
1246 (void) SyncImageSettings(mogrify_info,*image);
1247 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1248 InheritException(exception,&(*image)->exception);
1255 if (LocaleCompare("decipher",option+1) == 0)
1263 (void) SyncImageSettings(mogrify_info,*image);
1264 passkey=FileToStringInfo(argv[i+1],~0,exception);
1265 if (passkey != (StringInfo *) NULL)
1267 (void) PasskeyDecipherImage(*image,passkey,exception);
1268 passkey=DestroyStringInfo(passkey);
1272 if (LocaleCompare("density",option+1) == 0)
1277 (void) CloneString(&draw_info->density,argv[i+1]);
1280 if (LocaleCompare("depth",option+1) == 0)
1282 (void) SyncImageSettings(mogrify_info,*image);
1285 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1288 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1291 if (LocaleCompare("deskew",option+1) == 0)
1297 Straighten the image.
1299 (void) SyncImageSettings(mogrify_info,*image);
1301 threshold=40.0*QuantumRange/100.0;
1303 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1304 mogrify_image=DeskewImage(*image,threshold,exception);
1307 if (LocaleCompare("despeckle",option+1) == 0)
1310 Reduce the speckles within an image.
1312 (void) SyncImageSettings(mogrify_info,*image);
1313 mogrify_image=DespeckleImage(*image,exception);
1316 if (LocaleCompare("display",option+1) == 0)
1318 (void) CloneString(&draw_info->server_name,argv[i+1]);
1321 if (LocaleCompare("distort",option+1) == 0)
1325 token[MaxTextExtent];
1345 (void) SyncImageSettings(mogrify_info,*image);
1346 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1347 MagickFalse,argv[i+1]);
1348 if ( method == ResizeDistortion )
1350 /* Special Case - Argument is actually a resize geometry!
1351 ** Convert that to an appropriate distortion argument array.
1355 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1357 resize_args[0]=(double)geometry.width;
1358 resize_args[1]=(double)geometry.height;
1359 mogrify_image=DistortImage(*image,method,(size_t)2,
1360 resize_args,MagickTrue,exception);
1363 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1364 InheritException(exception,&(*image)->exception);
1365 if (args == (char *) NULL)
1368 for (x=0; *p != '\0'; x++)
1370 GetMagickToken(p,&p,token);
1372 GetMagickToken(p,&p,token);
1374 number_arguments=(size_t) x;
1375 arguments=(double *) AcquireQuantumMemory(number_arguments,
1376 sizeof(*arguments));
1377 if (arguments == (double *) NULL)
1378 ThrowWandFatalException(ResourceLimitFatalError,
1379 "MemoryAllocationFailed",(*image)->filename);
1380 (void) ResetMagickMemory(arguments,0,number_arguments*
1381 sizeof(*arguments));
1383 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1385 GetMagickToken(p,&p,token);
1387 GetMagickToken(p,&p,token);
1388 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1390 args=DestroyString(args);
1391 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1392 (*option == '+') ? MagickTrue : MagickFalse,exception);
1393 arguments=(double *) RelinquishMagickMemory(arguments);
1396 if (LocaleCompare("dither",option+1) == 0)
1400 quantize_info->dither=MagickFalse;
1403 quantize_info->dither=MagickTrue;
1404 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1405 MagickDitherOptions,MagickFalse,argv[i+1]);
1406 if (quantize_info->dither_method == NoDitherMethod)
1407 quantize_info->dither=MagickFalse;
1410 if (LocaleCompare("draw",option+1) == 0)
1415 (void) SyncImageSettings(mogrify_info,*image);
1416 (void) CloneString(&draw_info->primitive,argv[i+1]);
1417 (void) DrawImage(*image,draw_info);
1418 InheritException(exception,&(*image)->exception);
1425 if (LocaleCompare("edge",option+1) == 0)
1428 Enhance edges in the image.
1430 (void) SyncImageSettings(mogrify_info,*image);
1431 flags=ParseGeometry(argv[i+1],&geometry_info);
1432 if ((flags & SigmaValue) == 0)
1433 geometry_info.sigma=1.0;
1434 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1437 if (LocaleCompare("emboss",option+1) == 0)
1440 Gaussian embossen image.
1442 (void) SyncImageSettings(mogrify_info,*image);
1443 flags=ParseGeometry(argv[i+1],&geometry_info);
1444 if ((flags & SigmaValue) == 0)
1445 geometry_info.sigma=1.0;
1446 mogrify_image=EmbossImage(*image,geometry_info.rho,
1447 geometry_info.sigma,exception);
1450 if (LocaleCompare("encipher",option+1) == 0)
1458 (void) SyncImageSettings(mogrify_info,*image);
1459 passkey=FileToStringInfo(argv[i+1],~0,exception);
1460 if (passkey != (StringInfo *) NULL)
1462 (void) PasskeyEncipherImage(*image,passkey,exception);
1463 passkey=DestroyStringInfo(passkey);
1467 if (LocaleCompare("encoding",option+1) == 0)
1469 (void) CloneString(&draw_info->encoding,argv[i+1]);
1472 if (LocaleCompare("enhance",option+1) == 0)
1477 (void) SyncImageSettings(mogrify_info,*image);
1478 mogrify_image=EnhanceImage(*image,exception);
1481 if (LocaleCompare("equalize",option+1) == 0)
1486 (void) SyncImageSettings(mogrify_info,*image);
1487 (void) EqualizeImageChannel(*image,channel);
1488 InheritException(exception,&(*image)->exception);
1491 if (LocaleCompare("evaluate",option+1) == 0)
1496 MagickEvaluateOperator
1499 (void) SyncImageSettings(mogrify_info,*image);
1500 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
1501 MagickFalse,argv[i+1]);
1502 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1503 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1506 if (LocaleCompare("extent",option+1) == 0)
1509 Set the image extent.
1511 (void) SyncImageSettings(mogrify_info,*image);
1512 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1513 if (geometry.width == 0)
1514 geometry.width=(*image)->columns;
1515 if (geometry.height == 0)
1516 geometry.height=(*image)->rows;
1517 mogrify_image=ExtentImage(*image,&geometry,exception);
1524 if (LocaleCompare("family",option+1) == 0)
1528 if (draw_info->family != (char *) NULL)
1529 draw_info->family=DestroyString(draw_info->family);
1532 (void) CloneString(&draw_info->family,argv[i+1]);
1535 if (LocaleCompare("features",option+1) == 0)
1539 (void) DeleteImageArtifact(*image,"identify:features");
1542 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1545 if (LocaleCompare("fill",option+1) == 0)
1550 GetPixelInfo(*image,&fill);
1553 (void) QueryMagickColor("none",&fill,exception);
1554 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1555 if (draw_info->fill_pattern != (Image *) NULL)
1556 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1559 sans=AcquireExceptionInfo();
1560 (void) QueryMagickColor(argv[i+1],&fill,sans);
1561 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1562 sans=DestroyExceptionInfo(sans);
1563 if (status == MagickFalse)
1564 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1568 if (LocaleCompare("flip",option+1) == 0)
1571 Flip image scanlines.
1573 (void) SyncImageSettings(mogrify_info,*image);
1574 mogrify_image=FlipImage(*image,exception);
1577 if (LocaleCompare("floodfill",option+1) == 0)
1585 (void) SyncImageSettings(mogrify_info,*image);
1586 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1587 (void) QueryMagickColor(argv[i+2],&target,exception);
1588 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1589 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1590 InheritException(exception,&(*image)->exception);
1593 if (LocaleCompare("flop",option+1) == 0)
1596 Flop image scanlines.
1598 (void) SyncImageSettings(mogrify_info,*image);
1599 mogrify_image=FlopImage(*image,exception);
1602 if (LocaleCompare("font",option+1) == 0)
1606 if (draw_info->font != (char *) NULL)
1607 draw_info->font=DestroyString(draw_info->font);
1610 (void) CloneString(&draw_info->font,argv[i+1]);
1613 if (LocaleCompare("format",option+1) == 0)
1618 if (LocaleCompare("frame",option+1) == 0)
1624 Surround image with an ornamental border.
1626 (void) SyncImageSettings(mogrify_info,*image);
1627 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1628 frame_info.width=geometry.width;
1629 frame_info.height=geometry.height;
1630 if ((flags & HeightValue) == 0)
1631 frame_info.height=geometry.width;
1632 frame_info.outer_bevel=geometry.x;
1633 frame_info.inner_bevel=geometry.y;
1634 frame_info.x=(ssize_t) frame_info.width;
1635 frame_info.y=(ssize_t) frame_info.height;
1636 frame_info.width=(*image)->columns+2*frame_info.width;
1637 frame_info.height=(*image)->rows+2*frame_info.height;
1638 mogrify_image=FrameImage(*image,&frame_info,exception);
1641 if (LocaleCompare("function",option+1) == 0)
1645 token[MaxTextExtent];
1663 Function Modify Image Values
1665 (void) SyncImageSettings(mogrify_info,*image);
1666 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1667 MagickFalse,argv[i+1]);
1668 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1669 InheritException(exception,&(*image)->exception);
1670 if (arguments == (char *) NULL)
1672 p=(char *) arguments;
1673 for (x=0; *p != '\0'; x++)
1675 GetMagickToken(p,&p,token);
1677 GetMagickToken(p,&p,token);
1679 number_parameters=(size_t) x;
1680 parameters=(double *) AcquireQuantumMemory(number_parameters,
1681 sizeof(*parameters));
1682 if (parameters == (double *) NULL)
1683 ThrowWandFatalException(ResourceLimitFatalError,
1684 "MemoryAllocationFailed",(*image)->filename);
1685 (void) ResetMagickMemory(parameters,0,number_parameters*
1686 sizeof(*parameters));
1687 p=(char *) arguments;
1688 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1690 GetMagickToken(p,&p,token);
1692 GetMagickToken(p,&p,token);
1693 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1695 arguments=DestroyString(arguments);
1696 (void) FunctionImageChannel(*image,channel,function,
1697 number_parameters,parameters,exception);
1698 parameters=(double *) RelinquishMagickMemory(parameters);
1705 if (LocaleCompare("gamma",option+1) == 0)
1710 (void) SyncImageSettings(mogrify_info,*image);
1712 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1715 if (strchr(argv[i+1],',') != (char *) NULL)
1716 (void) GammaImage(*image,argv[i+1]);
1718 (void) GammaImageChannel(*image,channel,
1719 InterpretLocaleValue(argv[i+1],(char **) NULL));
1720 InheritException(exception,&(*image)->exception);
1724 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1725 (LocaleCompare("gaussian",option+1) == 0))
1728 Gaussian blur image.
1730 (void) SyncImageSettings(mogrify_info,*image);
1731 flags=ParseGeometry(argv[i+1],&geometry_info);
1732 if ((flags & SigmaValue) == 0)
1733 geometry_info.sigma=1.0;
1734 mogrify_image=GaussianBlurImageChannel(*image,channel,
1735 geometry_info.rho,geometry_info.sigma,exception);
1738 if (LocaleCompare("geometry",option+1) == 0)
1741 Record Image offset, Resize last image.
1743 (void) SyncImageSettings(mogrify_info,*image);
1746 if ((*image)->geometry != (char *) NULL)
1747 (*image)->geometry=DestroyString((*image)->geometry);
1750 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1751 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1752 (void) CloneString(&(*image)->geometry,argv[i+1]);
1754 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1755 (*image)->filter,(*image)->blur,exception);
1758 if (LocaleCompare("gravity",option+1) == 0)
1762 draw_info->gravity=UndefinedGravity;
1765 draw_info->gravity=(GravityType) ParseCommandOption(
1766 MagickGravityOptions,MagickFalse,argv[i+1]);
1773 if (LocaleCompare("highlight-color",option+1) == 0)
1775 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1782 if (LocaleCompare("identify",option+1) == 0)
1787 (void) SyncImageSettings(mogrify_info,*image);
1788 if (format == (char *) NULL)
1790 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1791 InheritException(exception,&(*image)->exception);
1794 text=InterpretImageProperties(mogrify_info,*image,format);
1795 InheritException(exception,&(*image)->exception);
1796 if (text == (char *) NULL)
1798 (void) fputs(text,stdout);
1799 (void) fputc('\n',stdout);
1800 text=DestroyString(text);
1803 if (LocaleCompare("implode",option+1) == 0)
1808 (void) SyncImageSettings(mogrify_info,*image);
1809 (void) ParseGeometry(argv[i+1],&geometry_info);
1810 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1813 if (LocaleCompare("interline-spacing",option+1) == 0)
1816 (void) ParseGeometry("0",&geometry_info);
1818 (void) ParseGeometry(argv[i+1],&geometry_info);
1819 draw_info->interline_spacing=geometry_info.rho;
1822 if (LocaleCompare("interword-spacing",option+1) == 0)
1825 (void) ParseGeometry("0",&geometry_info);
1827 (void) ParseGeometry(argv[i+1],&geometry_info);
1828 draw_info->interword_spacing=geometry_info.rho;
1835 if (LocaleCompare("kerning",option+1) == 0)
1838 (void) ParseGeometry("0",&geometry_info);
1840 (void) ParseGeometry(argv[i+1],&geometry_info);
1841 draw_info->kerning=geometry_info.rho;
1848 if (LocaleCompare("lat",option+1) == 0)
1851 Local adaptive threshold image.
1853 (void) SyncImageSettings(mogrify_info,*image);
1854 flags=ParseGeometry(argv[i+1],&geometry_info);
1855 if ((flags & PercentValue) != 0)
1856 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1857 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1858 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1859 geometry_info.xi,exception);
1862 if (LocaleCompare("level",option+1) == 0)
1875 (void) SyncImageSettings(mogrify_info,*image);
1876 flags=ParseGeometry(argv[i+1],&geometry_info);
1877 black_point=geometry_info.rho;
1878 white_point=(MagickRealType) QuantumRange;
1879 if ((flags & SigmaValue) != 0)
1880 white_point=geometry_info.sigma;
1882 if ((flags & XiValue) != 0)
1883 gamma=geometry_info.xi;
1884 if ((flags & PercentValue) != 0)
1886 black_point*=(MagickRealType) (QuantumRange/100.0);
1887 white_point*=(MagickRealType) (QuantumRange/100.0);
1889 if ((flags & SigmaValue) == 0)
1890 white_point=(MagickRealType) QuantumRange-black_point;
1891 if ((*option == '+') || ((flags & AspectValue) != 0))
1892 (void) LevelizeImageChannel(*image,channel,black_point,
1895 (void) LevelImageChannel(*image,channel,black_point,white_point,
1897 InheritException(exception,&(*image)->exception);
1900 if (LocaleCompare("level-colors",option+1) == 0)
1903 token[MaxTextExtent];
1912 p=(const char *) argv[i+1];
1913 GetMagickToken(p,&p,token); /* get black point color */
1914 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1915 (void) QueryMagickColor(token,&black_point,exception);
1917 (void) QueryMagickColor("#000000",&black_point,exception);
1918 if (isalpha((int) token[0]) || (token[0] == '#'))
1919 GetMagickToken(p,&p,token);
1921 white_point=black_point; /* set everything to that color */
1924 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1925 GetMagickToken(p,&p,token); /* Get white point color. */
1926 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1927 (void) QueryMagickColor(token,&white_point,exception);
1929 (void) QueryMagickColor("#ffffff",&white_point,exception);
1931 (void) LevelColorsImageChannel(*image,channel,&black_point,
1932 &white_point,*option == '+' ? MagickTrue : MagickFalse);
1935 if (LocaleCompare("linear-stretch",option+1) == 0)
1944 (void) SyncImageSettings(mogrify_info,*image);
1945 flags=ParseGeometry(argv[i+1],&geometry_info);
1946 black_point=geometry_info.rho;
1947 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1948 if ((flags & SigmaValue) != 0)
1949 white_point=geometry_info.sigma;
1950 if ((flags & PercentValue) != 0)
1952 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1953 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1955 if ((flags & SigmaValue) == 0)
1956 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1958 (void) LinearStretchImage(*image,black_point,white_point);
1959 InheritException(exception,&(*image)->exception);
1962 if (LocaleCompare("linewidth",option+1) == 0)
1964 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1968 if (LocaleCompare("liquid-rescale",option+1) == 0)
1971 Liquid rescale image.
1973 (void) SyncImageSettings(mogrify_info,*image);
1974 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1975 if ((flags & XValue) == 0)
1977 if ((flags & YValue) == 0)
1979 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1980 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1983 if (LocaleCompare("lowlight-color",option+1) == 0)
1985 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1992 if (LocaleCompare("map",option+1) == 0)
1998 Transform image colors to match this set of colors.
2000 (void) SyncImageSettings(mogrify_info,*image);
2003 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2004 if (remap_image == (Image *) NULL)
2006 (void) RemapImage(quantize_info,*image,remap_image);
2007 InheritException(exception,&(*image)->exception);
2008 remap_image=DestroyImage(remap_image);
2011 if (LocaleCompare("mask",option+1) == 0)
2016 (void) SyncImageSettings(mogrify_info,*image);
2022 (void) SetImageMask(*image,(Image *) NULL);
2023 InheritException(exception,&(*image)->exception);
2029 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2030 if (mask == (Image *) NULL)
2032 (void) SetImageMask(*image,mask);
2033 mask=DestroyImage(mask);
2034 InheritException(exception,&(*image)->exception);
2037 if (LocaleCompare("matte",option+1) == 0)
2039 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2040 SetAlphaChannel : DeactivateAlphaChannel );
2041 InheritException(exception,&(*image)->exception);
2044 if (LocaleCompare("median",option+1) == 0)
2047 Median filter image.
2049 (void) SyncImageSettings(mogrify_info,*image);
2050 (void) ParseGeometry(argv[i+1],&geometry_info);
2051 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2052 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2055 if (LocaleCompare("mode",option+1) == 0)
2060 (void) SyncImageSettings(mogrify_info,*image);
2061 (void) ParseGeometry(argv[i+1],&geometry_info);
2062 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2063 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2066 if (LocaleCompare("modulate",option+1) == 0)
2068 (void) SyncImageSettings(mogrify_info,*image);
2069 (void) ModulateImage(*image,argv[i+1]);
2070 InheritException(exception,&(*image)->exception);
2073 if (LocaleCompare("monitor",option+1) == 0)
2077 (void) SetImageProgressMonitor(*image,
2078 (MagickProgressMonitor) NULL,(void *) NULL);
2081 (void) SetImageProgressMonitor(*image,MonitorProgress,
2085 if (LocaleCompare("monochrome",option+1) == 0)
2087 (void) SyncImageSettings(mogrify_info,*image);
2088 (void) SetImageType(*image,BilevelType);
2089 InheritException(exception,&(*image)->exception);
2092 if (LocaleCompare("morphology",option+1) == 0)
2095 token[MaxTextExtent];
2110 Morphological Image Operation
2112 (void) SyncImageSettings(mogrify_info,*image);
2114 GetMagickToken(p,&p,token);
2115 method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions,
2118 GetMagickToken(p,&p,token);
2119 if ((*p == ':') || (*p == ','))
2120 GetMagickToken(p,&p,token);
2122 iterations=(ssize_t) StringToLong(p);
2123 kernel=AcquireKernelInfo(argv[i+2]);
2124 if (kernel == (KernelInfo *) NULL)
2126 (void) ThrowMagickException(exception,GetMagickModule(),
2127 OptionError,"UnabletoParseKernel","morphology");
2131 mogrify_image=MorphologyImageChannel(*image,channel,method,
2132 iterations,kernel,exception);
2133 kernel=DestroyKernelInfo(kernel);
2136 if (LocaleCompare("motion-blur",option+1) == 0)
2141 (void) SyncImageSettings(mogrify_info,*image);
2142 flags=ParseGeometry(argv[i+1],&geometry_info);
2143 if ((flags & SigmaValue) == 0)
2144 geometry_info.sigma=1.0;
2145 mogrify_image=MotionBlurImageChannel(*image,channel,
2146 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2153 if (LocaleCompare("negate",option+1) == 0)
2155 (void) SyncImageSettings(mogrify_info,*image);
2156 (void) NegateImageChannel(*image,channel,*option == '+' ?
2157 MagickTrue : MagickFalse);
2158 InheritException(exception,&(*image)->exception);
2161 if (LocaleCompare("noise",option+1) == 0)
2163 (void) SyncImageSettings(mogrify_info,*image);
2166 (void) ParseGeometry(argv[i+1],&geometry_info);
2167 mogrify_image=StatisticImageChannel(*image,channel,
2168 NonpeakStatistic,(size_t) geometry_info.rho,(size_t)
2169 geometry_info.rho,exception);
2176 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2177 MagickFalse,argv[i+1]);
2178 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2183 if (LocaleCompare("normalize",option+1) == 0)
2185 (void) SyncImageSettings(mogrify_info,*image);
2186 (void) NormalizeImageChannel(*image,channel);
2187 InheritException(exception,&(*image)->exception);
2194 if (LocaleCompare("opaque",option+1) == 0)
2199 (void) SyncImageSettings(mogrify_info,*image);
2200 (void) QueryMagickColor(argv[i+1],&target,exception);
2201 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2202 *option == '-' ? MagickFalse : MagickTrue);
2205 if (LocaleCompare("ordered-dither",option+1) == 0)
2207 (void) SyncImageSettings(mogrify_info,*image);
2208 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2216 if (LocaleCompare("paint",option+1) == 0)
2218 (void) SyncImageSettings(mogrify_info,*image);
2219 (void) ParseGeometry(argv[i+1],&geometry_info);
2220 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2223 if (LocaleCompare("pen",option+1) == 0)
2227 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2230 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2233 if (LocaleCompare("pointsize",option+1) == 0)
2236 (void) ParseGeometry("12",&geometry_info);
2238 (void) ParseGeometry(argv[i+1],&geometry_info);
2239 draw_info->pointsize=geometry_info.rho;
2242 if (LocaleCompare("polaroid",option+1) == 0)
2251 Simulate a Polaroid picture.
2253 (void) SyncImageSettings(mogrify_info,*image);
2254 random_info=AcquireRandomInfo();
2255 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2256 random_info=DestroyRandomInfo(random_info);
2259 SetGeometryInfo(&geometry_info);
2260 flags=ParseGeometry(argv[i+1],&geometry_info);
2261 angle=geometry_info.rho;
2263 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2266 if (LocaleCompare("posterize",option+1) == 0)
2271 (void) SyncImageSettings(mogrify_info,*image);
2272 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2273 quantize_info->dither);
2274 InheritException(exception,&(*image)->exception);
2277 if (LocaleCompare("preview",option+1) == 0)
2285 (void) SyncImageSettings(mogrify_info,*image);
2287 preview_type=UndefinedPreview;
2289 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
2290 MagickFalse,argv[i+1]);
2291 mogrify_image=PreviewImage(*image,preview_type,exception);
2294 if (LocaleCompare("profile",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image);
2312 Remove a profile from the image.
2314 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2316 InheritException(exception,&(*image)->exception);
2320 Associate a profile with the image.
2322 profile_info=CloneImageInfo(mogrify_info);
2323 profile=GetImageProfile(*image,"iptc");
2324 if (profile != (StringInfo *) NULL)
2325 profile_info->profile=(void *) CloneStringInfo(profile);
2326 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2327 profile_info=DestroyImageInfo(profile_info);
2328 if (profile_image == (Image *) NULL)
2333 profile_info=CloneImageInfo(mogrify_info);
2334 (void) CopyMagickString(profile_info->filename,argv[i+1],
2336 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2337 if (profile != (StringInfo *) NULL)
2339 (void) ProfileImage(*image,profile_info->magick,
2340 GetStringInfoDatum(profile),(size_t)
2341 GetStringInfoLength(profile),MagickFalse);
2342 profile=DestroyStringInfo(profile);
2344 profile_info=DestroyImageInfo(profile_info);
2347 ResetImageProfileIterator(profile_image);
2348 name=GetNextImageProfile(profile_image);
2349 while (name != (const char *) NULL)
2351 profile=GetImageProfile(profile_image,name);
2352 if (profile != (StringInfo *) NULL)
2353 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2354 (size_t) GetStringInfoLength(profile),MagickFalse);
2355 name=GetNextImageProfile(profile_image);
2357 profile_image=DestroyImage(profile_image);
2364 if (LocaleCompare("quantize",option+1) == 0)
2368 quantize_info->colorspace=UndefinedColorspace;
2371 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2372 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2379 if (LocaleCompare("radial-blur",option+1) == 0)
2384 (void) SyncImageSettings(mogrify_info,*image);
2385 mogrify_image=RadialBlurImageChannel(*image,channel,
2386 InterpretLocaleValue(argv[i+1],(char **) NULL),exception);
2389 if (LocaleCompare("raise",option+1) == 0)
2392 Surround image with a raise of solid color.
2394 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2395 if ((flags & SigmaValue) == 0)
2396 geometry.height=geometry.width;
2397 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2399 InheritException(exception,&(*image)->exception);
2402 if (LocaleCompare("random-threshold",option+1) == 0)
2407 (void) SyncImageSettings(mogrify_info,*image);
2408 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2412 if (LocaleCompare("recolor",option+1) == 0)
2417 (void) SyncImageSettings(mogrify_info,*image);
2418 kernel=AcquireKernelInfo(argv[i+1]);
2419 if (kernel == (KernelInfo *) NULL)
2421 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2422 kernel=DestroyKernelInfo(kernel);
2425 if (LocaleCompare("region",option+1) == 0)
2427 (void) SyncImageSettings(mogrify_info,*image);
2428 if (region_image != (Image *) NULL)
2433 (void) CompositeImage(region_image,region_image->matte !=
2434 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2435 region_geometry.x,region_geometry.y);
2436 InheritException(exception,®ion_image->exception);
2437 *image=DestroyImage(*image);
2438 *image=region_image;
2439 region_image = (Image *) NULL;
2444 Apply transformations to a selected region of the image.
2446 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2448 mogrify_image=CropImage(*image,®ion_geometry,exception);
2449 if (mogrify_image == (Image *) NULL)
2451 region_image=(*image);
2452 *image=mogrify_image;
2453 mogrify_image=(Image *) NULL;
2456 if (LocaleCompare("render",option+1) == 0)
2458 (void) SyncImageSettings(mogrify_info,*image);
2459 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2462 if (LocaleCompare("remap",option+1) == 0)
2468 Transform image colors to match this set of colors.
2470 (void) SyncImageSettings(mogrify_info,*image);
2473 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2474 if (remap_image == (Image *) NULL)
2476 (void) RemapImage(quantize_info,*image,remap_image);
2477 InheritException(exception,&(*image)->exception);
2478 remap_image=DestroyImage(remap_image);
2481 if (LocaleCompare("repage",option+1) == 0)
2485 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2488 (void) ResetImagePage(*image,argv[i+1]);
2489 InheritException(exception,&(*image)->exception);
2492 if (LocaleCompare("resample",option+1) == 0)
2497 (void) SyncImageSettings(mogrify_info,*image);
2498 flags=ParseGeometry(argv[i+1],&geometry_info);
2499 if ((flags & SigmaValue) == 0)
2500 geometry_info.sigma=geometry_info.rho;
2501 mogrify_image=ResampleImage(*image,geometry_info.rho,
2502 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2505 if (LocaleCompare("resize",option+1) == 0)
2510 (void) SyncImageSettings(mogrify_info,*image);
2511 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2512 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2513 (*image)->filter,(*image)->blur,exception);
2516 if (LocaleCompare("roll",option+1) == 0)
2521 (void) SyncImageSettings(mogrify_info,*image);
2522 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2523 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2526 if (LocaleCompare("rotate",option+1) == 0)
2532 Check for conditional image rotation.
2534 (void) SyncImageSettings(mogrify_info,*image);
2535 if (strchr(argv[i+1],'>') != (char *) NULL)
2536 if ((*image)->columns <= (*image)->rows)
2538 if (strchr(argv[i+1],'<') != (char *) NULL)
2539 if ((*image)->columns >= (*image)->rows)
2544 geometry=ConstantString(argv[i+1]);
2545 (void) SubstituteString(&geometry,">","");
2546 (void) SubstituteString(&geometry,"<","");
2547 (void) ParseGeometry(geometry,&geometry_info);
2548 geometry=DestroyString(geometry);
2549 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2556 if (LocaleCompare("sample",option+1) == 0)
2559 Sample image with pixel replication.
2561 (void) SyncImageSettings(mogrify_info,*image);
2562 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2563 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2567 if (LocaleCompare("scale",option+1) == 0)
2572 (void) SyncImageSettings(mogrify_info,*image);
2573 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2574 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2578 if (LocaleCompare("selective-blur",option+1) == 0)
2581 Selectively blur pixels within a contrast threshold.
2583 (void) SyncImageSettings(mogrify_info,*image);
2584 flags=ParseGeometry(argv[i+1],&geometry_info);
2585 if ((flags & PercentValue) != 0)
2586 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2587 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2588 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2591 if (LocaleCompare("separate",option+1) == 0)
2594 Break channels into separate images.
2595 WARNING: This can generate multiple images!
2597 (void) SyncImageSettings(mogrify_info,*image);
2598 mogrify_image=SeparateImages(*image,channel,exception);
2601 if (LocaleCompare("sepia-tone",option+1) == 0)
2609 (void) SyncImageSettings(mogrify_info,*image);
2610 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2611 mogrify_image=SepiaToneImage(*image,threshold,exception);
2614 if (LocaleCompare("segment",option+1) == 0)
2619 (void) SyncImageSettings(mogrify_info,*image);
2620 flags=ParseGeometry(argv[i+1],&geometry_info);
2621 if ((flags & SigmaValue) == 0)
2622 geometry_info.sigma=1.0;
2623 (void) SegmentImage(*image,(*image)->colorspace,
2624 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2625 InheritException(exception,&(*image)->exception);
2628 if (LocaleCompare("set",option+1) == 0)
2638 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2639 (void) DeleteImageRegistry(argv[i+1]+9);
2641 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2643 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2644 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2647 (void) DeleteImageProperty(*image,argv[i+1]);
2650 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2651 if (value == (char *) NULL)
2653 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2654 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2657 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2659 (void) SetImageOption(image_info,argv[i+1]+7,value);
2660 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2661 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2664 (void) SetImageProperty(*image,argv[i+1],value);
2665 value=DestroyString(value);
2668 if (LocaleCompare("shade",option+1) == 0)
2673 (void) SyncImageSettings(mogrify_info,*image);
2674 flags=ParseGeometry(argv[i+1],&geometry_info);
2675 if ((flags & SigmaValue) == 0)
2676 geometry_info.sigma=1.0;
2677 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2678 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2681 if (LocaleCompare("shadow",option+1) == 0)
2686 (void) SyncImageSettings(mogrify_info,*image);
2687 flags=ParseGeometry(argv[i+1],&geometry_info);
2688 if ((flags & SigmaValue) == 0)
2689 geometry_info.sigma=1.0;
2690 if ((flags & XiValue) == 0)
2691 geometry_info.xi=4.0;
2692 if ((flags & PsiValue) == 0)
2693 geometry_info.psi=4.0;
2694 mogrify_image=ShadowImage(*image,geometry_info.rho,
2695 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2696 ceil(geometry_info.psi-0.5),exception);
2699 if (LocaleCompare("sharpen",option+1) == 0)
2704 (void) SyncImageSettings(mogrify_info,*image);
2705 flags=ParseGeometry(argv[i+1],&geometry_info);
2706 if ((flags & SigmaValue) == 0)
2707 geometry_info.sigma=1.0;
2708 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2709 geometry_info.sigma,exception);
2712 if (LocaleCompare("shave",option+1) == 0)
2715 Shave the image edges.
2717 (void) SyncImageSettings(mogrify_info,*image);
2718 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2719 mogrify_image=ShaveImage(*image,&geometry,exception);
2722 if (LocaleCompare("shear",option+1) == 0)
2727 (void) SyncImageSettings(mogrify_info,*image);
2728 flags=ParseGeometry(argv[i+1],&geometry_info);
2729 if ((flags & SigmaValue) == 0)
2730 geometry_info.sigma=geometry_info.rho;
2731 mogrify_image=ShearImage(*image,geometry_info.rho,
2732 geometry_info.sigma,exception);
2735 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2738 Sigmoidal non-linearity contrast control.
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 flags=ParseGeometry(argv[i+1],&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=(double) QuantumRange/2.0;
2744 if ((flags & PercentValue) != 0)
2745 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2747 (void) SigmoidalContrastImageChannel(*image,channel,
2748 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
2749 geometry_info.sigma);
2750 InheritException(exception,&(*image)->exception);
2753 if (LocaleCompare("sketch",option+1) == 0)
2758 (void) SyncImageSettings(mogrify_info,*image);
2759 flags=ParseGeometry(argv[i+1],&geometry_info);
2760 if ((flags & SigmaValue) == 0)
2761 geometry_info.sigma=1.0;
2762 mogrify_image=SketchImage(*image,geometry_info.rho,
2763 geometry_info.sigma,geometry_info.xi,exception);
2766 if (LocaleCompare("solarize",option+1) == 0)
2771 (void) SyncImageSettings(mogrify_info,*image);
2772 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2773 (void) SolarizeImage(*image,threshold);
2774 InheritException(exception,&(*image)->exception);
2777 if (LocaleCompare("sparse-color",option+1) == 0)
2786 Sparse Color Interpolated Gradient
2788 (void) SyncImageSettings(mogrify_info,*image);
2789 method=(SparseColorMethod) ParseCommandOption(
2790 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2791 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2792 InheritException(exception,&(*image)->exception);
2793 if (arguments == (char *) NULL)
2795 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2796 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2797 arguments=DestroyString(arguments);
2800 if (LocaleCompare("splice",option+1) == 0)
2803 Splice a solid color into the image.
2805 (void) SyncImageSettings(mogrify_info,*image);
2806 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2807 mogrify_image=SpliceImage(*image,&geometry,exception);
2810 if (LocaleCompare("spread",option+1) == 0)
2815 (void) SyncImageSettings(mogrify_info,*image);
2816 (void) ParseGeometry(argv[i+1],&geometry_info);
2817 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2820 if (LocaleCompare("statistic",option+1) == 0)
2825 (void) SyncImageSettings(mogrify_info,*image);
2826 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2827 MagickFalse,argv[i+1]);
2828 (void) ParseGeometry(argv[i+2],&geometry_info);
2829 mogrify_image=StatisticImageChannel(*image,channel,type,(size_t)
2830 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2833 if (LocaleCompare("stretch",option+1) == 0)
2837 draw_info->stretch=UndefinedStretch;
2840 draw_info->stretch=(StretchType) ParseCommandOption(
2841 MagickStretchOptions,MagickFalse,argv[i+1]);
2844 if (LocaleCompare("strip",option+1) == 0)
2847 Strip image of profiles and comments.
2849 (void) SyncImageSettings(mogrify_info,*image);
2850 (void) StripImage(*image);
2851 InheritException(exception,&(*image)->exception);
2854 if (LocaleCompare("stroke",option+1) == 0)
2861 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2862 if (draw_info->stroke_pattern != (Image *) NULL)
2863 draw_info->stroke_pattern=DestroyImage(
2864 draw_info->stroke_pattern);
2867 sans=AcquireExceptionInfo();
2868 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2869 sans=DestroyExceptionInfo(sans);
2870 if (status == MagickFalse)
2871 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2875 if (LocaleCompare("strokewidth",option+1) == 0)
2877 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2881 if (LocaleCompare("style",option+1) == 0)
2885 draw_info->style=UndefinedStyle;
2888 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2889 MagickFalse,argv[i+1]);
2892 if (LocaleCompare("swirl",option+1) == 0)
2897 (void) SyncImageSettings(mogrify_info,*image);
2898 (void) ParseGeometry(argv[i+1],&geometry_info);
2899 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
2906 if (LocaleCompare("threshold",option+1) == 0)
2914 (void) SyncImageSettings(mogrify_info,*image);
2916 threshold=(double) QuantumRange/2;
2918 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2919 (void) BilevelImageChannel(*image,channel,threshold);
2920 InheritException(exception,&(*image)->exception);
2923 if (LocaleCompare("thumbnail",option+1) == 0)
2928 (void) SyncImageSettings(mogrify_info,*image);
2929 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2930 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2934 if (LocaleCompare("tile",option+1) == 0)
2938 if (draw_info->fill_pattern != (Image *) NULL)
2939 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2942 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2946 if (LocaleCompare("tint",option+1) == 0)
2951 (void) SyncImageSettings(mogrify_info,*image);
2952 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
2955 if (LocaleCompare("transform",option+1) == 0)
2958 Affine transform image.
2960 (void) SyncImageSettings(mogrify_info,*image);
2961 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2965 if (LocaleCompare("transparent",option+1) == 0)
2970 (void) SyncImageSettings(mogrify_info,*image);
2971 (void) QueryMagickColor(argv[i+1],&target,exception);
2972 (void) TransparentPaintImage(*image,&target,(Quantum)
2973 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue);
2974 InheritException(exception,&(*image)->exception);
2977 if (LocaleCompare("transpose",option+1) == 0)
2980 Transpose image scanlines.
2982 (void) SyncImageSettings(mogrify_info,*image);
2983 mogrify_image=TransposeImage(*image,exception);
2986 if (LocaleCompare("transverse",option+1) == 0)
2989 Transverse image scanlines.
2991 (void) SyncImageSettings(mogrify_info,*image);
2992 mogrify_image=TransverseImage(*image,exception);
2995 if (LocaleCompare("treedepth",option+1) == 0)
2997 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3000 if (LocaleCompare("trim",option+1) == 0)
3005 (void) SyncImageSettings(mogrify_info,*image);
3006 mogrify_image=TrimImage(*image,exception);
3009 if (LocaleCompare("type",option+1) == 0)
3014 (void) SyncImageSettings(mogrify_info,*image);
3018 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3020 (*image)->type=UndefinedType;
3021 (void) SetImageType(*image,type);
3022 InheritException(exception,&(*image)->exception);
3029 if (LocaleCompare("undercolor",option+1) == 0)
3031 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3035 if (LocaleCompare("unique",option+1) == 0)
3039 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3042 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3043 (void) SetImageArtifact(*image,"verbose","true");
3046 if (LocaleCompare("unique-colors",option+1) == 0)
3049 Unique image colors.
3051 (void) SyncImageSettings(mogrify_info,*image);
3052 mogrify_image=UniqueImageColors(*image,exception);
3055 if (LocaleCompare("unsharp",option+1) == 0)
3060 (void) SyncImageSettings(mogrify_info,*image);
3061 flags=ParseGeometry(argv[i+1],&geometry_info);
3062 if ((flags & SigmaValue) == 0)
3063 geometry_info.sigma=1.0;
3064 if ((flags & XiValue) == 0)
3065 geometry_info.xi=1.0;
3066 if ((flags & PsiValue) == 0)
3067 geometry_info.psi=0.05;
3068 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3069 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3070 geometry_info.psi,exception);
3077 if (LocaleCompare("verbose",option+1) == 0)
3079 (void) SetImageArtifact(*image,option+1,
3080 *option == '+' ? "false" : "true");
3083 if (LocaleCompare("vignette",option+1) == 0)
3088 (void) SyncImageSettings(mogrify_info,*image);
3089 flags=ParseGeometry(argv[i+1],&geometry_info);
3090 if ((flags & SigmaValue) == 0)
3091 geometry_info.sigma=1.0;
3092 if ((flags & XiValue) == 0)
3093 geometry_info.xi=0.1*(*image)->columns;
3094 if ((flags & PsiValue) == 0)
3095 geometry_info.psi=0.1*(*image)->rows;
3096 mogrify_image=VignetteImage(*image,geometry_info.rho,
3097 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3098 ceil(geometry_info.psi-0.5),exception);
3101 if (LocaleCompare("virtual-pixel",option+1) == 0)
3105 (void) SetImageVirtualPixelMethod(*image,
3106 UndefinedVirtualPixelMethod);
3109 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3110 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3118 if (LocaleCompare("wave",option+1) == 0)
3123 (void) SyncImageSettings(mogrify_info,*image);
3124 flags=ParseGeometry(argv[i+1],&geometry_info);
3125 if ((flags & SigmaValue) == 0)
3126 geometry_info.sigma=1.0;
3127 mogrify_image=WaveImage(*image,geometry_info.rho,
3128 geometry_info.sigma,exception);
3131 if (LocaleCompare("weight",option+1) == 0)
3133 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3134 if (LocaleCompare(argv[i+1],"all") == 0)
3135 draw_info->weight=0;
3136 if (LocaleCompare(argv[i+1],"bold") == 0)
3137 draw_info->weight=700;
3138 if (LocaleCompare(argv[i+1],"bolder") == 0)
3139 if (draw_info->weight <= 800)
3140 draw_info->weight+=100;
3141 if (LocaleCompare(argv[i+1],"lighter") == 0)
3142 if (draw_info->weight >= 100)
3143 draw_info->weight-=100;
3144 if (LocaleCompare(argv[i+1],"normal") == 0)
3145 draw_info->weight=400;
3148 if (LocaleCompare("white-threshold",option+1) == 0)
3151 White threshold image.
3153 (void) SyncImageSettings(mogrify_info,*image);
3154 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3156 InheritException(exception,&(*image)->exception);
3165 Replace current image with any image that was generated
3167 if (mogrify_image != (Image *) NULL)
3168 ReplaceImageInListReturnLast(image,mogrify_image);
3171 if (region_image != (Image *) NULL)
3174 Composite transformed region onto image.
3176 (void) SyncImageSettings(mogrify_info,*image);
3177 (void) CompositeImage(region_image,region_image->matte !=
3178 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3179 region_geometry.x,region_geometry.y);
3180 InheritException(exception,®ion_image->exception);
3181 *image=DestroyImage(*image);
3182 *image=region_image;
3183 region_image = (Image *) NULL;
3188 quantize_info=DestroyQuantizeInfo(quantize_info);
3189 draw_info=DestroyDrawInfo(draw_info);
3190 mogrify_info=DestroyImageInfo(mogrify_info);
3191 status=(MagickStatusType) ((*image)->exception.severity ==
3192 UndefinedException ? 1 : 0);
3193 return(status == 0 ? MagickFalse : MagickTrue);
3197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3201 + M o g r i f y I m a g e C o m m a n d %
3205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3207 % MogrifyImageCommand() transforms an image or a sequence of images. These
3208 % transforms include image scaling, image rotation, color reduction, and
3209 % others. The transmogrified image overwrites the original image.
3211 % The format of the MogrifyImageCommand method is:
3213 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3214 % const char **argv,char **metadata,ExceptionInfo *exception)
3216 % A description of each parameter follows:
3218 % o image_info: the image info.
3220 % o argc: the number of elements in the argument vector.
3222 % o argv: A text array containing the command line arguments.
3224 % o metadata: any metadata is returned here.
3226 % o exception: return any errors or warnings in this structure.
3230 static MagickBooleanType MogrifyUsage(void)
3235 "-debug events display copious debugging information",
3236 "-help print program options",
3237 "-list type print a list of supported option arguments",
3238 "-log format format of debugging information",
3239 "-version print version information",
3244 "-adaptive-blur geometry",
3245 " adaptively blur pixels; decrease effect near edges",
3246 "-adaptive-resize geometry",
3247 " adaptively resize image using 'mesh' interpolation",
3248 "-adaptive-sharpen geometry",
3249 " adaptively sharpen pixels; increase effect near edges",
3250 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3251 " transparent, extract, background, or shape",
3252 "-annotate geometry text",
3253 " annotate the image with text",
3254 "-auto-gamma automagically adjust gamma level of image",
3255 "-auto-level automagically adjust color levels of image",
3256 "-auto-orient automagically orient (rotate) image",
3257 "-bench iterations measure performance",
3258 "-black-threshold value",
3259 " force all pixels below the threshold into black",
3260 "-blue-shift simulate a scene at nighttime in the moonlight",
3261 "-blur geometry reduce image noise and reduce detail levels",
3262 "-border geometry surround image with a border of color",
3263 "-bordercolor color border color",
3264 "-brightness-contrast geometry",
3265 " improve brightness / contrast of the image",
3266 "-cdl filename color correct with a color decision list",
3267 "-charcoal radius simulate a charcoal drawing",
3268 "-chop geometry remove pixels from the image interior",
3269 "-clamp restrict pixel range from 0 to the quantum depth",
3270 "-clip clip along the first path from the 8BIM profile",
3271 "-clip-mask filename associate a clip mask with the image",
3272 "-clip-path id clip along a named path from the 8BIM profile",
3273 "-colorize value colorize the image with the fill color",
3274 "-color-matrix matrix apply color correction to the image",
3275 "-contrast enhance or reduce the image contrast",
3276 "-contrast-stretch geometry",
3277 " improve contrast by `stretching' the intensity range",
3278 "-convolve coefficients",
3279 " apply a convolution kernel to the image",
3280 "-cycle amount cycle the image colormap",
3281 "-decipher filename convert cipher pixels to plain pixels",
3282 "-deskew threshold straighten an image",
3283 "-despeckle reduce the speckles within an image",
3284 "-distort method args",
3285 " distort images according to given method ad args",
3286 "-draw string annotate the image with a graphic primitive",
3287 "-edge radius apply a filter to detect edges in the image",
3288 "-encipher filename convert plain pixels to cipher pixels",
3289 "-emboss radius emboss an image",
3290 "-enhance apply a digital filter to enhance a noisy image",
3291 "-equalize perform histogram equalization to an image",
3292 "-evaluate operator value",
3293 " evaluate an arithmetic, relational, or logical expression",
3294 "-extent geometry set the image size",
3295 "-extract geometry extract area from image",
3296 "-fft implements the discrete Fourier transform (DFT)",
3297 "-flip flip image vertically",
3298 "-floodfill geometry color",
3299 " floodfill the image with color",
3300 "-flop flop image horizontally",
3301 "-frame geometry surround image with an ornamental border",
3302 "-function name parameters",
3303 " apply function over image values",
3304 "-gamma value level of gamma correction",
3305 "-gaussian-blur geometry",
3306 " reduce image noise and reduce detail levels",
3307 "-geometry geometry preferred size or location of the image",
3308 "-identify identify the format and characteristics of the image",
3309 "-ift implements the inverse discrete Fourier transform (DFT)",
3310 "-implode amount implode image pixels about the center",
3311 "-lat geometry local adaptive thresholding",
3312 "-layers method optimize, merge, or compare image layers",
3313 "-level value adjust the level of image contrast",
3314 "-level-colors color,color",
3315 " level image with the given colors",
3316 "-linear-stretch geometry",
3317 " improve contrast by `stretching with saturation'",
3318 "-liquid-rescale geometry",
3319 " rescale image with seam-carving",
3320 "-median geometry apply a median filter to the image",
3321 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3322 "-modulate value vary the brightness, saturation, and hue",
3323 "-monochrome transform image to black and white",
3324 "-morphology method kernel",
3325 " apply a morphology method to the image",
3326 "-motion-blur geometry",
3327 " simulate motion blur",
3328 "-negate replace every pixel with its complementary color ",
3329 "-noise geometry add or reduce noise in an image",
3330 "-normalize transform image to span the full range of colors",
3331 "-opaque color change this color to the fill color",
3332 "-ordered-dither NxN",
3333 " add a noise pattern to the image with specific",
3335 "-paint radius simulate an oil painting",
3336 "-polaroid angle simulate a Polaroid picture",
3337 "-posterize levels reduce the image to a limited number of color levels",
3338 "-profile filename add, delete, or apply an image profile",
3339 "-quantize colorspace reduce colors in this colorspace",
3340 "-radial-blur angle radial blur the image",
3341 "-raise value lighten/darken image edges to create a 3-D effect",
3342 "-random-threshold low,high",
3343 " random threshold the image",
3344 "-region geometry apply options to a portion of the image",
3345 "-render render vector graphics",
3346 "-repage geometry size and location of an image canvas",
3347 "-resample geometry change the resolution of an image",
3348 "-resize geometry resize the image",
3349 "-roll geometry roll an image vertically or horizontally",
3350 "-rotate degrees apply Paeth rotation to the image",
3351 "-sample geometry scale image with pixel sampling",
3352 "-scale geometry scale the image",
3353 "-segment values segment an image",
3354 "-selective-blur geometry",
3355 " selectively blur pixels within a contrast threshold",
3356 "-sepia-tone threshold",
3357 " simulate a sepia-toned photo",
3358 "-set property value set an image property",
3359 "-shade degrees shade the image using a distant light source",
3360 "-shadow geometry simulate an image shadow",
3361 "-sharpen geometry sharpen the image",
3362 "-shave geometry shave pixels from the image edges",
3363 "-shear geometry slide one edge of the image along the X or Y axis",
3364 "-sigmoidal-contrast geometry",
3365 " increase the contrast without saturating highlights or shadows",
3366 "-sketch geometry simulate a pencil sketch",
3367 "-solarize threshold negate all pixels above the threshold level",
3368 "-sparse-color method args",
3369 " fill in a image based on a few color points",
3370 "-splice geometry splice the background color into the image",
3371 "-spread radius displace image pixels by a random amount",
3372 "-statistic type radius",
3373 " replace each pixel with corresponding statistic from the neighborhood",
3374 "-strip strip image of all profiles and comments",
3375 "-swirl degrees swirl image pixels about the center",
3376 "-threshold value threshold the image",
3377 "-thumbnail geometry create a thumbnail of the image",
3378 "-tile filename tile image when filling a graphic primitive",
3379 "-tint value tint the image with the fill color",
3380 "-transform affine transform image",
3381 "-transparent color make this color transparent within the image",
3382 "-transpose flip image vertically and rotate 90 degrees",
3383 "-transverse flop image horizontally and rotate 270 degrees",
3384 "-trim trim image edges",
3385 "-type type image type",
3386 "-unique-colors discard all but one of any pixel color",
3387 "-unsharp geometry sharpen the image",
3388 "-vignette geometry soften the edges of the image in vignette style",
3389 "-wave geometry alter an image along a sine wave",
3390 "-white-threshold value",
3391 " force all pixels above the threshold into white",
3394 *sequence_operators[]=
3396 "-append append an image sequence",
3397 "-clut apply a color lookup table to the image",
3398 "-coalesce merge a sequence of images",
3399 "-combine combine a sequence of images",
3400 "-composite composite image",
3401 "-crop geometry cut out a rectangular region of the image",
3402 "-deconstruct break down an image sequence into constituent parts",
3403 "-evaluate-sequence operator",
3404 " evaluate an arithmetic, relational, or logical expression",
3405 "-flatten flatten a sequence of images",
3406 "-fx expression apply mathematical expression to an image channel(s)",
3407 "-hald-clut apply a Hald color lookup table to the image",
3408 "-morph value morph an image sequence",
3409 "-mosaic create a mosaic from an image sequence",
3410 "-print string interpret string and print to console",
3411 "-process arguments process the image with a custom image filter",
3412 "-separate separate an image channel into a grayscale image",
3413 "-smush geometry smush an image sequence together",
3414 "-write filename write images to this file",
3419 "-adjoin join images into a single multi-image file",
3420 "-affine matrix affine transform matrix",
3421 "-alpha option activate, deactivate, reset, or set the alpha channel",
3422 "-antialias remove pixel-aliasing",
3423 "-authenticate password",
3424 " decipher image with this password",
3425 "-attenuate value lessen (or intensify) when adding noise to an image",
3426 "-background color background color",
3427 "-bias value add bias when convolving an image",
3428 "-black-point-compensation",
3429 " use black point compensation",
3430 "-blue-primary point chromaticity blue primary point",
3431 "-bordercolor color border color",
3432 "-caption string assign a caption to an image",
3433 "-channel type apply option to select image channels",
3434 "-colors value preferred number of colors in the image",
3435 "-colorspace type alternate image colorspace",
3436 "-comment string annotate image with comment",
3437 "-compose operator set image composite operator",
3438 "-compress type type of pixel compression when writing the image",
3439 "-define format:option",
3440 " define one or more image format options",
3441 "-delay value display the next image after pausing",
3442 "-density geometry horizontal and vertical density of the image",
3443 "-depth value image depth",
3444 "-direction type render text right-to-left or left-to-right",
3445 "-display server get image or font from this X server",
3446 "-dispose method layer disposal method",
3447 "-dither method apply error diffusion to image",
3448 "-encoding type text encoding type",
3449 "-endian type endianness (MSB or LSB) of the image",
3450 "-family name render text with this font family",
3451 "-fill color color to use when filling a graphic primitive",
3452 "-filter type use this filter when resizing an image",
3453 "-font name render text with this font",
3454 "-format \"string\" output formatted image characteristics",
3455 "-fuzz distance colors within this distance are considered equal",
3456 "-gravity type horizontal and vertical text placement",
3457 "-green-primary point chromaticity green primary point",
3458 "-intent type type of rendering intent when managing the image color",
3459 "-interlace type type of image interlacing scheme",
3460 "-interline-spacing value",
3461 " set the space between two text lines",
3462 "-interpolate method pixel color interpolation method",
3463 "-interword-spacing value",
3464 " set the space between two words",
3465 "-kerning value set the space between two letters",
3466 "-label string assign a label to an image",
3467 "-limit type value pixel cache resource limit",
3468 "-loop iterations add Netscape loop extension to your GIF animation",
3469 "-mask filename associate a mask with the image",
3470 "-mattecolor color frame color",
3471 "-monitor monitor progress",
3472 "-orient type image orientation",
3473 "-page geometry size and location of an image canvas (setting)",
3474 "-ping efficiently determine image attributes",
3475 "-pointsize value font point size",
3476 "-precision value maximum number of significant digits to print",
3477 "-preview type image preview type",
3478 "-quality value JPEG/MIFF/PNG compression level",
3479 "-quiet suppress all warning messages",
3480 "-red-primary point chromaticity red primary point",
3481 "-regard-warnings pay attention to warning messages",
3482 "-remap filename transform image colors to match this set of colors",
3483 "-respect-parentheses settings remain in effect until parenthesis boundary",
3484 "-sampling-factor geometry",
3485 " horizontal and vertical sampling factor",
3486 "-scene value image scene number",
3487 "-seed value seed a new sequence of pseudo-random numbers",
3488 "-size geometry width and height of image",
3489 "-stretch type render text with this font stretch",
3490 "-stroke color graphic primitive stroke color",
3491 "-strokewidth value graphic primitive stroke width",
3492 "-style type render text with this font style",
3493 "-synchronize synchronize image to storage device",
3494 "-taint declare the image as modified",
3495 "-texture filename name of texture to tile onto the image background",
3496 "-tile-offset geometry",
3498 "-treedepth value color tree depth",
3499 "-transparent-color color",
3500 " transparent color",
3501 "-undercolor color annotation bounding box color",
3502 "-units type the units of image resolution",
3503 "-verbose print detailed information about the image",
3504 "-view FlashPix viewing transforms",
3505 "-virtual-pixel method",
3506 " virtual pixel access method",
3507 "-weight type render text with this font weight",
3508 "-white-point point chromaticity white point",
3513 "-delete indexes delete the image from the image sequence",
3514 "-duplicate count,indexes",
3515 " duplicate an image one or more times",
3516 "-insert index insert last image into the image sequence",
3517 "-reverse reverse image sequence",
3518 "-swap indexes swap two images in the image sequence",
3525 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3526 (void) printf("Copyright: %s\n",GetMagickCopyright());
3527 (void) printf("Features: %s\n\n",GetMagickFeatures());
3528 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3530 (void) printf("\nImage Settings:\n");
3531 for (p=settings; *p != (char *) NULL; p++)
3532 (void) printf(" %s\n",*p);
3533 (void) printf("\nImage Operators:\n");
3534 for (p=operators; *p != (char *) NULL; p++)
3535 (void) printf(" %s\n",*p);
3536 (void) printf("\nImage Sequence Operators:\n");
3537 for (p=sequence_operators; *p != (char *) NULL; p++)
3538 (void) printf(" %s\n",*p);
3539 (void) printf("\nImage Stack Operators:\n");
3540 for (p=stack_operators; *p != (char *) NULL; p++)
3541 (void) printf(" %s\n",*p);
3542 (void) printf("\nMiscellaneous Options:\n");
3543 for (p=miscellaneous; *p != (char *) NULL; p++)
3544 (void) printf(" %s\n",*p);
3546 "\nBy default, the image format of `file' is determined by its magic\n");
3548 "number. To specify a particular image format, precede the filename\n");
3550 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3552 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3553 (void) printf("'-' for standard input or output.\n");
3554 return(MagickFalse);
3557 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3558 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3560 #define DestroyMogrify() \
3562 if (format != (char *) NULL) \
3563 format=DestroyString(format); \
3564 if (path != (char *) NULL) \
3565 path=DestroyString(path); \
3566 DestroyImageStack(); \
3567 for (i=0; i < (ssize_t) argc; i++) \
3568 argv[i]=DestroyString(argv[i]); \
3569 argv=(char **) RelinquishMagickMemory(argv); \
3571 #define ThrowMogrifyException(asperity,tag,option) \
3573 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3576 return(MagickFalse); \
3578 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3580 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3581 "InvalidArgument","`%s': %s",argument,option); \
3583 return(MagickFalse); \
3595 image_stack[MaxImageStackDepth+1];
3603 respect_parenthesis;
3618 assert(image_info != (ImageInfo *) NULL);
3619 assert(image_info->signature == MagickSignature);
3620 if (image_info->debug != MagickFalse)
3621 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3622 assert(exception != (ExceptionInfo *) NULL);
3626 if ((LocaleCompare("version",option+1) == 0) ||
3627 (LocaleCompare("-version",option+1) == 0))
3629 (void) FormatLocaleFile(stdout,"Version: %s\n",
3630 GetMagickVersion((size_t *) NULL));
3631 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3632 GetMagickCopyright());
3633 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3634 GetMagickFeatures());
3635 return(MagickFalse);
3639 return(MogrifyUsage());
3640 format=(char *) NULL;
3642 global_colormap=MagickFalse;
3646 option=(char *) NULL;
3648 respect_parenthesis=MagickFalse;
3653 ReadCommandlLine(argc,&argv);
3654 status=ExpandFilenames(&argc,&argv);
3655 if (status == MagickFalse)
3656 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3657 GetExceptionMessage(errno));
3658 for (i=1; i < (ssize_t) argc; i++)
3661 if (LocaleCompare(option,"(") == 0)
3663 FireImageStack(MagickFalse,MagickTrue,pend);
3664 if (k == MaxImageStackDepth)
3665 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3670 if (LocaleCompare(option,")") == 0)
3672 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3674 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3678 if (IsCommandOption(option) == MagickFalse)
3681 backup_filename[MaxTextExtent],
3688 Option is a file name: begin by reading image from specified file.
3690 FireImageStack(MagickFalse,MagickFalse,pend);
3692 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3694 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3695 images=ReadImages(image_info,exception);
3696 status&=(images != (Image *) NULL) &&
3697 (exception->severity < ErrorException);
3698 if (images == (Image *) NULL)
3700 if (format != (char *) NULL)
3701 (void) CopyMagickString(images->filename,images->magick_filename,
3703 if (path != (char *) NULL)
3705 GetPathComponent(option,TailPath,filename);
3706 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3707 path,*DirectorySeparator,filename);
3709 if (format != (char *) NULL)
3710 AppendImageFormat(format,images->filename);
3711 AppendImageStack(images);
3712 FinalizeImageSettings(image_info,image,MagickFalse);
3713 if (global_colormap != MagickFalse)
3718 quantize_info=AcquireQuantizeInfo(image_info);
3719 (void) RemapImages(quantize_info,images,(Image *) NULL);
3720 quantize_info=DestroyQuantizeInfo(quantize_info);
3722 *backup_filename='\0';
3723 if ((LocaleCompare(image->filename,"-") != 0) &&
3724 (IsPathWritable(image->filename) != MagickFalse))
3730 Rename image file as backup.
3732 (void) CopyMagickString(backup_filename,image->filename,
3734 for (i=0; i < 6; i++)
3736 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3737 if (IsPathAccessible(backup_filename) == MagickFalse)
3740 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3741 (rename(image->filename,backup_filename) != 0))
3742 *backup_filename='\0';
3745 Write transmogrified image to disk.
3747 image_info->synchronize=MagickTrue;
3748 status&=WriteImages(image_info,image,image->filename,exception);
3749 if ((status == MagickFalse) && (*backup_filename != '\0'))
3750 (void) remove(backup_filename);
3751 RemoveAllImageStack();
3754 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3755 switch (*(option+1))
3759 if (LocaleCompare("adaptive-blur",option+1) == 0)
3762 if (i == (ssize_t) argc)
3763 ThrowMogrifyException(OptionError,"MissingArgument",option);
3764 if (IsGeometry(argv[i]) == MagickFalse)
3765 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3768 if (LocaleCompare("adaptive-resize",option+1) == 0)
3771 if (i == (ssize_t) argc)
3772 ThrowMogrifyException(OptionError,"MissingArgument",option);
3773 if (IsGeometry(argv[i]) == MagickFalse)
3774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3777 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3780 if (i == (ssize_t) argc)
3781 ThrowMogrifyException(OptionError,"MissingArgument",option);
3782 if (IsGeometry(argv[i]) == MagickFalse)
3783 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3786 if (LocaleCompare("affine",option+1) == 0)
3791 if (i == (ssize_t) argc)
3792 ThrowMogrifyException(OptionError,"MissingArgument",option);
3795 if (LocaleCompare("alpha",option+1) == 0)
3803 if (i == (ssize_t) argc)
3804 ThrowMogrifyException(OptionError,"MissingArgument",option);
3805 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3807 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3811 if (LocaleCompare("annotate",option+1) == 0)
3816 if (i == (ssize_t) argc)
3817 ThrowMogrifyException(OptionError,"MissingArgument",option);
3818 if (IsGeometry(argv[i]) == MagickFalse)
3819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3820 if (i == (ssize_t) argc)
3821 ThrowMogrifyException(OptionError,"MissingArgument",option);
3825 if (LocaleCompare("antialias",option+1) == 0)
3827 if (LocaleCompare("append",option+1) == 0)
3829 if (LocaleCompare("attenuate",option+1) == 0)
3834 if (i == (ssize_t) (argc-1))
3835 ThrowMogrifyException(OptionError,"MissingArgument",option);
3836 if (IsGeometry(argv[i]) == MagickFalse)
3837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3840 if (LocaleCompare("authenticate",option+1) == 0)
3845 if (i == (ssize_t) argc)
3846 ThrowMogrifyException(OptionError,"MissingArgument",option);
3849 if (LocaleCompare("auto-gamma",option+1) == 0)
3851 if (LocaleCompare("auto-level",option+1) == 0)
3853 if (LocaleCompare("auto-orient",option+1) == 0)
3855 if (LocaleCompare("average",option+1) == 0)
3857 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3861 if (LocaleCompare("background",option+1) == 0)
3866 if (i == (ssize_t) argc)
3867 ThrowMogrifyException(OptionError,"MissingArgument",option);
3870 if (LocaleCompare("bias",option+1) == 0)
3875 if (i == (ssize_t) (argc-1))
3876 ThrowMogrifyException(OptionError,"MissingArgument",option);
3877 if (IsGeometry(argv[i]) == MagickFalse)
3878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3881 if (LocaleCompare("black-point-compensation",option+1) == 0)
3883 if (LocaleCompare("black-threshold",option+1) == 0)
3888 if (i == (ssize_t) argc)
3889 ThrowMogrifyException(OptionError,"MissingArgument",option);
3890 if (IsGeometry(argv[i]) == MagickFalse)
3891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3894 if (LocaleCompare("blue-primary",option+1) == 0)
3899 if (i == (ssize_t) argc)
3900 ThrowMogrifyException(OptionError,"MissingArgument",option);
3901 if (IsGeometry(argv[i]) == MagickFalse)
3902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3905 if (LocaleCompare("blue-shift",option+1) == 0)
3908 if (i == (ssize_t) argc)
3909 ThrowMogrifyException(OptionError,"MissingArgument",option);
3910 if (IsGeometry(argv[i]) == MagickFalse)
3911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3914 if (LocaleCompare("blur",option+1) == 0)
3917 if (i == (ssize_t) argc)
3918 ThrowMogrifyException(OptionError,"MissingArgument",option);
3919 if (IsGeometry(argv[i]) == MagickFalse)
3920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3923 if (LocaleCompare("border",option+1) == 0)
3928 if (i == (ssize_t) argc)
3929 ThrowMogrifyException(OptionError,"MissingArgument",option);
3930 if (IsGeometry(argv[i]) == MagickFalse)
3931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 if (LocaleCompare("bordercolor",option+1) == 0)
3939 if (i == (ssize_t) argc)
3940 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (LocaleCompare("box",option+1) == 0)
3948 if (i == (ssize_t) argc)
3949 ThrowMogrifyException(OptionError,"MissingArgument",option);
3952 if (LocaleCompare("brightness-contrast",option+1) == 0)
3955 if (i == (ssize_t) argc)
3956 ThrowMogrifyException(OptionError,"MissingArgument",option);
3957 if (IsGeometry(argv[i]) == MagickFalse)
3958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3961 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3965 if (LocaleCompare("cache",option+1) == 0)
3970 if (i == (ssize_t) argc)
3971 ThrowMogrifyException(OptionError,"MissingArgument",option);
3972 if (IsGeometry(argv[i]) == MagickFalse)
3973 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3976 if (LocaleCompare("caption",option+1) == 0)
3981 if (i == (ssize_t) argc)
3982 ThrowMogrifyException(OptionError,"MissingArgument",option);
3985 if (LocaleCompare("channel",option+1) == 0)
3993 if (i == (ssize_t) (argc-1))
3994 ThrowMogrifyException(OptionError,"MissingArgument",option);
3995 channel=ParseChannelOption(argv[i]);
3997 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4001 if (LocaleCompare("cdl",option+1) == 0)
4006 if (i == (ssize_t) (argc-1))
4007 ThrowMogrifyException(OptionError,"MissingArgument",option);
4010 if (LocaleCompare("charcoal",option+1) == 0)
4015 if (i == (ssize_t) argc)
4016 ThrowMogrifyException(OptionError,"MissingArgument",option);
4017 if (IsGeometry(argv[i]) == MagickFalse)
4018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4021 if (LocaleCompare("chop",option+1) == 0)
4026 if (i == (ssize_t) argc)
4027 ThrowMogrifyException(OptionError,"MissingArgument",option);
4028 if (IsGeometry(argv[i]) == MagickFalse)
4029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4032 if (LocaleCompare("clamp",option+1) == 0)
4034 if (LocaleCompare("clip",option+1) == 0)
4036 if (LocaleCompare("clip-mask",option+1) == 0)
4041 if (i == (ssize_t) argc)
4042 ThrowMogrifyException(OptionError,"MissingArgument",option);
4045 if (LocaleCompare("clut",option+1) == 0)
4047 if (LocaleCompare("coalesce",option+1) == 0)
4049 if (LocaleCompare("colorize",option+1) == 0)
4054 if (i == (ssize_t) argc)
4055 ThrowMogrifyException(OptionError,"MissingArgument",option);
4056 if (IsGeometry(argv[i]) == MagickFalse)
4057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4060 if (LocaleCompare("color-matrix",option+1) == 0)
4068 if (i == (ssize_t) (argc-1))
4069 ThrowMogrifyException(OptionError,"MissingArgument",option);
4070 kernel_info=AcquireKernelInfo(argv[i]);
4071 if (kernel_info == (KernelInfo *) NULL)
4072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4073 kernel_info=DestroyKernelInfo(kernel_info);
4076 if (LocaleCompare("colors",option+1) == 0)
4081 if (i == (ssize_t) argc)
4082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4083 if (IsGeometry(argv[i]) == MagickFalse)
4084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4087 if (LocaleCompare("colorspace",option+1) == 0)
4095 if (i == (ssize_t) argc)
4096 ThrowMogrifyException(OptionError,"MissingArgument",option);
4097 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4100 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4104 if (LocaleCompare("combine",option+1) == 0)
4106 if (LocaleCompare("comment",option+1) == 0)
4111 if (i == (ssize_t) argc)
4112 ThrowMogrifyException(OptionError,"MissingArgument",option);
4115 if (LocaleCompare("composite",option+1) == 0)
4117 if (LocaleCompare("compress",option+1) == 0)
4125 if (i == (ssize_t) argc)
4126 ThrowMogrifyException(OptionError,"MissingArgument",option);
4127 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4130 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4134 if (LocaleCompare("concurrent",option+1) == 0)
4136 if (LocaleCompare("contrast",option+1) == 0)
4138 if (LocaleCompare("contrast-stretch",option+1) == 0)
4141 if (i == (ssize_t) argc)
4142 ThrowMogrifyException(OptionError,"MissingArgument",option);
4143 if (IsGeometry(argv[i]) == MagickFalse)
4144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4147 if (LocaleCompare("convolve",option+1) == 0)
4155 if (i == (ssize_t) argc)
4156 ThrowMogrifyException(OptionError,"MissingArgument",option);
4157 kernel_info=AcquireKernelInfo(argv[i]);
4158 if (kernel_info == (KernelInfo *) NULL)
4159 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4160 kernel_info=DestroyKernelInfo(kernel_info);
4163 if (LocaleCompare("crop",option+1) == 0)
4168 if (i == (ssize_t) argc)
4169 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (IsGeometry(argv[i]) == MagickFalse)
4171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4174 if (LocaleCompare("cycle",option+1) == 0)
4179 if (i == (ssize_t) argc)
4180 ThrowMogrifyException(OptionError,"MissingArgument",option);
4181 if (IsGeometry(argv[i]) == MagickFalse)
4182 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4185 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4189 if (LocaleCompare("decipher",option+1) == 0)
4194 if (i == (ssize_t) (argc-1))
4195 ThrowMogrifyException(OptionError,"MissingArgument",option);
4198 if (LocaleCompare("deconstruct",option+1) == 0)
4200 if (LocaleCompare("debug",option+1) == 0)
4208 if (i == (ssize_t) argc)
4209 ThrowMogrifyException(OptionError,"MissingArgument",option);
4210 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4212 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4214 (void) SetLogEventMask(argv[i]);
4217 if (LocaleCompare("define",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4227 define=GetImageOption(image_info,argv[i]);
4228 if (define == (const char *) NULL)
4229 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4234 if (LocaleCompare("delay",option+1) == 0)
4239 if (i == (ssize_t) argc)
4240 ThrowMogrifyException(OptionError,"MissingArgument",option);
4241 if (IsGeometry(argv[i]) == MagickFalse)
4242 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4245 if (LocaleCompare("delete",option+1) == 0)
4250 if (i == (ssize_t) (argc-1))
4251 ThrowMogrifyException(OptionError,"MissingArgument",option);
4252 if (IsGeometry(argv[i]) == MagickFalse)
4253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4256 if (LocaleCompare("density",option+1) == 0)
4261 if (i == (ssize_t) argc)
4262 ThrowMogrifyException(OptionError,"MissingArgument",option);
4263 if (IsGeometry(argv[i]) == MagickFalse)
4264 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4267 if (LocaleCompare("depth",option+1) == 0)
4272 if (i == (ssize_t) argc)
4273 ThrowMogrifyException(OptionError,"MissingArgument",option);
4274 if (IsGeometry(argv[i]) == MagickFalse)
4275 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4278 if (LocaleCompare("deskew",option+1) == 0)
4283 if (i == (ssize_t) argc)
4284 ThrowMogrifyException(OptionError,"MissingArgument",option);
4285 if (IsGeometry(argv[i]) == MagickFalse)
4286 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4289 if (LocaleCompare("despeckle",option+1) == 0)
4291 if (LocaleCompare("dft",option+1) == 0)
4293 if (LocaleCompare("direction",option+1) == 0)
4301 if (i == (ssize_t) argc)
4302 ThrowMogrifyException(OptionError,"MissingArgument",option);
4303 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4306 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4310 if (LocaleCompare("display",option+1) == 0)
4315 if (i == (ssize_t) argc)
4316 ThrowMogrifyException(OptionError,"MissingArgument",option);
4319 if (LocaleCompare("dispose",option+1) == 0)
4327 if (i == (ssize_t) argc)
4328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4329 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4331 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4335 if (LocaleCompare("distort",option+1) == 0)
4341 if (i == (ssize_t) argc)
4342 ThrowMogrifyException(OptionError,"MissingArgument",option);
4343 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4345 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4348 if (i == (ssize_t) (argc-1))
4349 ThrowMogrifyException(OptionError,"MissingArgument",option);
4352 if (LocaleCompare("dither",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4362 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4364 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4368 if (LocaleCompare("draw",option+1) == 0)
4373 if (i == (ssize_t) argc)
4374 ThrowMogrifyException(OptionError,"MissingArgument",option);
4377 if (LocaleCompare("duplicate",option+1) == 0)
4382 if (i == (ssize_t) (argc-1))
4383 ThrowMogrifyException(OptionError,"MissingArgument",option);
4384 if (IsGeometry(argv[i]) == MagickFalse)
4385 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4388 if (LocaleCompare("duration",option+1) == 0)
4393 if (i == (ssize_t) (argc-1))
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4395 if (IsGeometry(argv[i]) == MagickFalse)
4396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4399 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4403 if (LocaleCompare("edge",option+1) == 0)
4408 if (i == (ssize_t) argc)
4409 ThrowMogrifyException(OptionError,"MissingArgument",option);
4410 if (IsGeometry(argv[i]) == MagickFalse)
4411 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4414 if (LocaleCompare("emboss",option+1) == 0)
4419 if (i == (ssize_t) argc)
4420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4421 if (IsGeometry(argv[i]) == MagickFalse)
4422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4425 if (LocaleCompare("encipher",option+1) == 0)
4430 if (i == (ssize_t) argc)
4431 ThrowMogrifyException(OptionError,"MissingArgument",option);
4434 if (LocaleCompare("encoding",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4443 if (LocaleCompare("endian",option+1) == 0)
4451 if (i == (ssize_t) argc)
4452 ThrowMogrifyException(OptionError,"MissingArgument",option);
4453 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4455 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4459 if (LocaleCompare("enhance",option+1) == 0)
4461 if (LocaleCompare("equalize",option+1) == 0)
4463 if (LocaleCompare("evaluate",option+1) == 0)
4471 if (i == (ssize_t) argc)
4472 ThrowMogrifyException(OptionError,"MissingArgument",option);
4473 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4475 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4478 if (i == (ssize_t) (argc-1))
4479 ThrowMogrifyException(OptionError,"MissingArgument",option);
4480 if (IsGeometry(argv[i]) == MagickFalse)
4481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4484 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4492 if (i == (ssize_t) argc)
4493 ThrowMogrifyException(OptionError,"MissingArgument",option);
4494 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4496 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4500 if (LocaleCompare("extent",option+1) == 0)
4505 if (i == (ssize_t) argc)
4506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4507 if (IsGeometry(argv[i]) == MagickFalse)
4508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4511 if (LocaleCompare("extract",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4518 if (IsGeometry(argv[i]) == MagickFalse)
4519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4522 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4526 if (LocaleCompare("family",option+1) == 0)
4531 if (i == (ssize_t) (argc-1))
4532 ThrowMogrifyException(OptionError,"MissingArgument",option);
4535 if (LocaleCompare("fill",option+1) == 0)
4540 if (i == (ssize_t) argc)
4541 ThrowMogrifyException(OptionError,"MissingArgument",option);
4544 if (LocaleCompare("filter",option+1) == 0)
4552 if (i == (ssize_t) argc)
4553 ThrowMogrifyException(OptionError,"MissingArgument",option);
4554 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4556 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4560 if (LocaleCompare("flatten",option+1) == 0)
4562 if (LocaleCompare("flip",option+1) == 0)
4564 if (LocaleCompare("flop",option+1) == 0)
4566 if (LocaleCompare("floodfill",option+1) == 0)
4571 if (i == (ssize_t) argc)
4572 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 if (IsGeometry(argv[i]) == MagickFalse)
4574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4576 if (i == (ssize_t) argc)
4577 ThrowMogrifyException(OptionError,"MissingArgument",option);
4580 if (LocaleCompare("font",option+1) == 0)
4585 if (i == (ssize_t) argc)
4586 ThrowMogrifyException(OptionError,"MissingArgument",option);
4589 if (LocaleCompare("format",option+1) == 0)
4591 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4592 (void) CloneString(&format,(char *) NULL);
4596 if (i == (ssize_t) argc)
4597 ThrowMogrifyException(OptionError,"MissingArgument",option);
4598 (void) CloneString(&format,argv[i]);
4599 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4600 (void) ConcatenateMagickString(image_info->filename,":",
4602 (void) SetImageInfo(image_info,0,exception);
4603 if (*image_info->magick == '\0')
4604 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4608 if (LocaleCompare("frame",option+1) == 0)
4613 if (i == (ssize_t) argc)
4614 ThrowMogrifyException(OptionError,"MissingArgument",option);
4615 if (IsGeometry(argv[i]) == MagickFalse)
4616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4619 if (LocaleCompare("function",option+1) == 0)
4627 if (i == (ssize_t) argc)
4628 ThrowMogrifyException(OptionError,"MissingArgument",option);
4629 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4631 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4633 if (i == (ssize_t) (argc-1))
4634 ThrowMogrifyException(OptionError,"MissingArgument",option);
4637 if (LocaleCompare("fuzz",option+1) == 0)
4642 if (i == (ssize_t) argc)
4643 ThrowMogrifyException(OptionError,"MissingArgument",option);
4644 if (IsGeometry(argv[i]) == MagickFalse)
4645 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4648 if (LocaleCompare("fx",option+1) == 0)
4653 if (i == (ssize_t) (argc-1))
4654 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4661 if (LocaleCompare("gamma",option+1) == 0)
4664 if (i == (ssize_t) argc)
4665 ThrowMogrifyException(OptionError,"MissingArgument",option);
4666 if (IsGeometry(argv[i]) == MagickFalse)
4667 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4670 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4671 (LocaleCompare("gaussian",option+1) == 0))
4674 if (i == (ssize_t) argc)
4675 ThrowMogrifyException(OptionError,"MissingArgument",option);
4676 if (IsGeometry(argv[i]) == MagickFalse)
4677 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4680 if (LocaleCompare("geometry",option+1) == 0)
4685 if (i == (ssize_t) argc)
4686 ThrowMogrifyException(OptionError,"MissingArgument",option);
4687 if (IsGeometry(argv[i]) == MagickFalse)
4688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4691 if (LocaleCompare("gravity",option+1) == 0)
4699 if (i == (ssize_t) argc)
4700 ThrowMogrifyException(OptionError,"MissingArgument",option);
4701 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4703 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4707 if (LocaleCompare("green-primary",option+1) == 0)
4712 if (i == (ssize_t) argc)
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 if (IsGeometry(argv[i]) == MagickFalse)
4715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4718 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4722 if (LocaleCompare("hald-clut",option+1) == 0)
4724 if ((LocaleCompare("help",option+1) == 0) ||
4725 (LocaleCompare("-help",option+1) == 0))
4726 return(MogrifyUsage());
4727 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4731 if (LocaleCompare("identify",option+1) == 0)
4733 if (LocaleCompare("idft",option+1) == 0)
4735 if (LocaleCompare("implode",option+1) == 0)
4740 if (i == (ssize_t) argc)
4741 ThrowMogrifyException(OptionError,"MissingArgument",option);
4742 if (IsGeometry(argv[i]) == MagickFalse)
4743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4746 if (LocaleCompare("intent",option+1) == 0)
4754 if (i == (ssize_t) (argc-1))
4755 ThrowMogrifyException(OptionError,"MissingArgument",option);
4756 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4758 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4762 if (LocaleCompare("interlace",option+1) == 0)
4770 if (i == (ssize_t) argc)
4771 ThrowMogrifyException(OptionError,"MissingArgument",option);
4772 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4775 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4779 if (LocaleCompare("interline-spacing",option+1) == 0)
4784 if (i == (ssize_t) (argc-1))
4785 ThrowMogrifyException(OptionError,"MissingArgument",option);
4786 if (IsGeometry(argv[i]) == MagickFalse)
4787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4790 if (LocaleCompare("interpolate",option+1) == 0)
4798 if (i == (ssize_t) argc)
4799 ThrowMogrifyException(OptionError,"MissingArgument",option);
4800 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4802 if (interpolate < 0)
4803 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4807 if (LocaleCompare("interword-spacing",option+1) == 0)
4812 if (i == (ssize_t) (argc-1))
4813 ThrowMogrifyException(OptionError,"MissingArgument",option);
4814 if (IsGeometry(argv[i]) == MagickFalse)
4815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4818 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4822 if (LocaleCompare("kerning",option+1) == 0)
4827 if (i == (ssize_t) (argc-1))
4828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4829 if (IsGeometry(argv[i]) == MagickFalse)
4830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4833 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4837 if (LocaleCompare("label",option+1) == 0)
4842 if (i == (ssize_t) argc)
4843 ThrowMogrifyException(OptionError,"MissingArgument",option);
4846 if (LocaleCompare("lat",option+1) == 0)
4851 if (i == (ssize_t) argc)
4852 ThrowMogrifyException(OptionError,"MissingArgument",option);
4853 if (IsGeometry(argv[i]) == MagickFalse)
4854 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4856 if (LocaleCompare("layers",option+1) == 0)
4864 if (i == (ssize_t) (argc-1))
4865 ThrowMogrifyException(OptionError,"MissingArgument",option);
4866 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4868 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4872 if (LocaleCompare("level",option+1) == 0)
4875 if (i == (ssize_t) argc)
4876 ThrowMogrifyException(OptionError,"MissingArgument",option);
4877 if (IsGeometry(argv[i]) == MagickFalse)
4878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4881 if (LocaleCompare("level-colors",option+1) == 0)
4884 if (i == (ssize_t) argc)
4885 ThrowMogrifyException(OptionError,"MissingArgument",option);
4888 if (LocaleCompare("linewidth",option+1) == 0)
4893 if (i == (ssize_t) argc)
4894 ThrowMogrifyException(OptionError,"MissingArgument",option);
4895 if (IsGeometry(argv[i]) == MagickFalse)
4896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4899 if (LocaleCompare("limit",option+1) == 0)
4913 if (i == (ssize_t) argc)
4914 ThrowMogrifyException(OptionError,"MissingArgument",option);
4915 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4918 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,"MissingArgument",option);
4923 value=InterpretLocaleValue(argv[i],&p);
4925 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4926 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4929 if (LocaleCompare("liquid-rescale",option+1) == 0)
4932 if (i == (ssize_t) argc)
4933 ThrowMogrifyException(OptionError,"MissingArgument",option);
4934 if (IsGeometry(argv[i]) == MagickFalse)
4935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4938 if (LocaleCompare("list",option+1) == 0)
4946 if (i == (ssize_t) argc)
4947 ThrowMogrifyException(OptionError,"MissingArgument",option);
4948 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4950 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4951 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4953 return(status != 0 ? MagickFalse : MagickTrue);
4955 if (LocaleCompare("log",option+1) == 0)
4960 if ((i == (ssize_t) argc) ||
4961 (strchr(argv[i],'%') == (char *) NULL))
4962 ThrowMogrifyException(OptionError,"MissingArgument",option);
4965 if (LocaleCompare("loop",option+1) == 0)
4970 if (i == (ssize_t) argc)
4971 ThrowMogrifyException(OptionError,"MissingArgument",option);
4972 if (IsGeometry(argv[i]) == MagickFalse)
4973 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4976 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4980 if (LocaleCompare("map",option+1) == 0)
4982 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4986 if (i == (ssize_t) argc)
4987 ThrowMogrifyException(OptionError,"MissingArgument",option);
4990 if (LocaleCompare("mask",option+1) == 0)
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4999 if (LocaleCompare("matte",option+1) == 0)
5001 if (LocaleCompare("mattecolor",option+1) == 0)
5006 if (i == (ssize_t) argc)
5007 ThrowMogrifyException(OptionError,"MissingArgument",option);
5010 if (LocaleCompare("maximum",option+1) == 0)
5012 if (LocaleCompare("minimum",option+1) == 0)
5014 if (LocaleCompare("modulate",option+1) == 0)
5019 if (i == (ssize_t) argc)
5020 ThrowMogrifyException(OptionError,"MissingArgument",option);
5021 if (IsGeometry(argv[i]) == MagickFalse)
5022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5025 if (LocaleCompare("median",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,"MissingArgument",option);
5032 if (IsGeometry(argv[i]) == MagickFalse)
5033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5036 if (LocaleCompare("mode",option+1) == 0)
5041 if (i == (ssize_t) argc)
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5043 if (IsGeometry(argv[i]) == MagickFalse)
5044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5047 if (LocaleCompare("monitor",option+1) == 0)
5049 if (LocaleCompare("monochrome",option+1) == 0)
5051 if (LocaleCompare("morph",option+1) == 0)
5056 if (i == (ssize_t) (argc-1))
5057 ThrowMogrifyException(OptionError,"MissingArgument",option);
5058 if (IsGeometry(argv[i]) == MagickFalse)
5059 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5062 if (LocaleCompare("morphology",option+1) == 0)
5065 token[MaxTextExtent];
5074 if (i == (ssize_t) argc)
5075 ThrowMogrifyException(OptionError,"MissingArgument",option);
5076 GetMagickToken(argv[i],NULL,token);
5077 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5079 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5082 if (i == (ssize_t) (argc-1))
5083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5084 kernel_info=AcquireKernelInfo(argv[i]);
5085 if (kernel_info == (KernelInfo *) NULL)
5086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5087 kernel_info=DestroyKernelInfo(kernel_info);
5090 if (LocaleCompare("mosaic",option+1) == 0)
5092 if (LocaleCompare("motion-blur",option+1) == 0)
5097 if (i == (ssize_t) argc)
5098 ThrowMogrifyException(OptionError,"MissingArgument",option);
5099 if (IsGeometry(argv[i]) == MagickFalse)
5100 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5103 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5107 if (LocaleCompare("negate",option+1) == 0)
5109 if (LocaleCompare("noise",option+1) == 0)
5112 if (i == (ssize_t) argc)
5113 ThrowMogrifyException(OptionError,"MissingArgument",option);
5119 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5121 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5125 if (IsGeometry(argv[i]) == MagickFalse)
5126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5129 if (LocaleCompare("noop",option+1) == 0)
5131 if (LocaleCompare("normalize",option+1) == 0)
5133 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5137 if (LocaleCompare("opaque",option+1) == 0)
5140 if (i == (ssize_t) argc)
5141 ThrowMogrifyException(OptionError,"MissingArgument",option);
5144 if (LocaleCompare("ordered-dither",option+1) == 0)
5149 if (i == (ssize_t) argc)
5150 ThrowMogrifyException(OptionError,"MissingArgument",option);
5153 if (LocaleCompare("orient",option+1) == 0)
5158 orientation=UndefinedOrientation;
5162 if (i == (ssize_t) (argc-1))
5163 ThrowMogrifyException(OptionError,"MissingArgument",option);
5164 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5166 if (orientation < 0)
5167 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5171 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5175 if (LocaleCompare("page",option+1) == 0)
5180 if (i == (ssize_t) argc)
5181 ThrowMogrifyException(OptionError,"MissingArgument",option);
5184 if (LocaleCompare("paint",option+1) == 0)
5189 if (i == (ssize_t) argc)
5190 ThrowMogrifyException(OptionError,"MissingArgument",option);
5191 if (IsGeometry(argv[i]) == MagickFalse)
5192 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5195 if (LocaleCompare("path",option+1) == 0)
5197 (void) CloneString(&path,(char *) NULL);
5201 if (i == (ssize_t) argc)
5202 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 (void) CloneString(&path,argv[i]);
5206 if (LocaleCompare("pointsize",option+1) == 0)
5211 if (i == (ssize_t) argc)
5212 ThrowMogrifyException(OptionError,"MissingArgument",option);
5213 if (IsGeometry(argv[i]) == MagickFalse)
5214 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5217 if (LocaleCompare("polaroid",option+1) == 0)
5222 if (i == (ssize_t) argc)
5223 ThrowMogrifyException(OptionError,"MissingArgument",option);
5224 if (IsGeometry(argv[i]) == MagickFalse)
5225 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5228 if (LocaleCompare("posterize",option+1) == 0)
5233 if (i == (ssize_t) argc)
5234 ThrowMogrifyException(OptionError,"MissingArgument",option);
5235 if (IsGeometry(argv[i]) == MagickFalse)
5236 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5239 if (LocaleCompare("precision",option+1) == 0)
5244 if (i == (ssize_t) argc)
5245 ThrowMogrifyException(OptionError,"MissingArgument",option);
5246 if (IsGeometry(argv[i]) == MagickFalse)
5247 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5250 if (LocaleCompare("print",option+1) == 0)
5255 if (i == (ssize_t) argc)
5256 ThrowMogrifyException(OptionError,"MissingArgument",option);
5259 if (LocaleCompare("process",option+1) == 0)
5264 if (i == (ssize_t) (argc-1))
5265 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 if (LocaleCompare("profile",option+1) == 0)
5271 if (i == (ssize_t) argc)
5272 ThrowMogrifyException(OptionError,"MissingArgument",option);
5275 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5279 if (LocaleCompare("quality",option+1) == 0)
5284 if (i == (ssize_t) argc)
5285 ThrowMogrifyException(OptionError,"MissingArgument",option);
5286 if (IsGeometry(argv[i]) == MagickFalse)
5287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5290 if (LocaleCompare("quantize",option+1) == 0)
5298 if (i == (ssize_t) (argc-1))
5299 ThrowMogrifyException(OptionError,"MissingArgument",option);
5300 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5303 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5307 if (LocaleCompare("quiet",option+1) == 0)
5309 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5313 if (LocaleCompare("radial-blur",option+1) == 0)
5316 if (i == (ssize_t) argc)
5317 ThrowMogrifyException(OptionError,"MissingArgument",option);
5318 if (IsGeometry(argv[i]) == MagickFalse)
5319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5322 if (LocaleCompare("raise",option+1) == 0)
5325 if (i == (ssize_t) argc)
5326 ThrowMogrifyException(OptionError,"MissingArgument",option);
5327 if (IsGeometry(argv[i]) == MagickFalse)
5328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5331 if (LocaleCompare("random-threshold",option+1) == 0)
5336 if (i == (ssize_t) argc)
5337 ThrowMogrifyException(OptionError,"MissingArgument",option);
5338 if (IsGeometry(argv[i]) == MagickFalse)
5339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5342 if (LocaleCompare("recolor",option+1) == 0)
5347 if (i == (ssize_t) (argc-1))
5348 ThrowMogrifyException(OptionError,"MissingArgument",option);
5349 if (IsGeometry(argv[i]) == MagickFalse)
5350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5353 if (LocaleCompare("red-primary",option+1) == 0)
5358 if (i == (ssize_t) argc)
5359 ThrowMogrifyException(OptionError,"MissingArgument",option);
5360 if (IsGeometry(argv[i]) == MagickFalse)
5361 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5363 if (LocaleCompare("regard-warnings",option+1) == 0)
5365 if (LocaleCompare("region",option+1) == 0)
5370 if (i == (ssize_t) argc)
5371 ThrowMogrifyException(OptionError,"MissingArgument",option);
5372 if (IsGeometry(argv[i]) == MagickFalse)
5373 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5376 if (LocaleCompare("remap",option+1) == 0)
5381 if (i == (ssize_t) (argc-1))
5382 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (LocaleCompare("render",option+1) == 0)
5387 if (LocaleCompare("repage",option+1) == 0)
5392 if (i == (ssize_t) argc)
5393 ThrowMogrifyException(OptionError,"MissingArgument",option);
5394 if (IsGeometry(argv[i]) == MagickFalse)
5395 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5398 if (LocaleCompare("resample",option+1) == 0)
5403 if (i == (ssize_t) argc)
5404 ThrowMogrifyException(OptionError,"MissingArgument",option);
5405 if (IsGeometry(argv[i]) == MagickFalse)
5406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5409 if (LocaleCompare("resize",option+1) == 0)
5414 if (i == (ssize_t) argc)
5415 ThrowMogrifyException(OptionError,"MissingArgument",option);
5416 if (IsGeometry(argv[i]) == MagickFalse)
5417 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5420 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5422 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5425 if (LocaleCompare("reverse",option+1) == 0)
5427 if (LocaleCompare("roll",option+1) == 0)
5432 if (i == (ssize_t) argc)
5433 ThrowMogrifyException(OptionError,"MissingArgument",option);
5434 if (IsGeometry(argv[i]) == MagickFalse)
5435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5438 if (LocaleCompare("rotate",option+1) == 0)
5441 if (i == (ssize_t) argc)
5442 ThrowMogrifyException(OptionError,"MissingArgument",option);
5443 if (IsGeometry(argv[i]) == MagickFalse)
5444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5447 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5451 if (LocaleCompare("sample",option+1) == 0)
5456 if (i == (ssize_t) argc)
5457 ThrowMogrifyException(OptionError,"MissingArgument",option);
5458 if (IsGeometry(argv[i]) == MagickFalse)
5459 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5462 if (LocaleCompare("sampling-factor",option+1) == 0)
5467 if (i == (ssize_t) argc)
5468 ThrowMogrifyException(OptionError,"MissingArgument",option);
5469 if (IsGeometry(argv[i]) == MagickFalse)
5470 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5473 if (LocaleCompare("scale",option+1) == 0)
5478 if (i == (ssize_t) argc)
5479 ThrowMogrifyException(OptionError,"MissingArgument",option);
5480 if (IsGeometry(argv[i]) == MagickFalse)
5481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 if (LocaleCompare("scene",option+1) == 0)
5489 if (i == (ssize_t) argc)
5490 ThrowMogrifyException(OptionError,"MissingArgument",option);
5491 if (IsGeometry(argv[i]) == MagickFalse)
5492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5495 if (LocaleCompare("seed",option+1) == 0)
5500 if (i == (ssize_t) argc)
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5502 if (IsGeometry(argv[i]) == MagickFalse)
5503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5506 if (LocaleCompare("segment",option+1) == 0)
5511 if (i == (ssize_t) argc)
5512 ThrowMogrifyException(OptionError,"MissingArgument",option);
5513 if (IsGeometry(argv[i]) == MagickFalse)
5514 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5517 if (LocaleCompare("selective-blur",option+1) == 0)
5520 if (i == (ssize_t) argc)
5521 ThrowMogrifyException(OptionError,"MissingArgument",option);
5522 if (IsGeometry(argv[i]) == MagickFalse)
5523 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5526 if (LocaleCompare("separate",option+1) == 0)
5528 if (LocaleCompare("sepia-tone",option+1) == 0)
5533 if (i == (ssize_t) argc)
5534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5539 if (LocaleCompare("set",option+1) == 0)
5542 if (i == (ssize_t) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5547 if (i == (ssize_t) argc)
5548 ThrowMogrifyException(OptionError,"MissingArgument",option);
5551 if (LocaleCompare("shade",option+1) == 0)
5554 if (i == (ssize_t) argc)
5555 ThrowMogrifyException(OptionError,"MissingArgument",option);
5556 if (IsGeometry(argv[i]) == MagickFalse)
5557 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5560 if (LocaleCompare("shadow",option+1) == 0)
5565 if (i == (ssize_t) argc)
5566 ThrowMogrifyException(OptionError,"MissingArgument",option);
5567 if (IsGeometry(argv[i]) == MagickFalse)
5568 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5571 if (LocaleCompare("sharpen",option+1) == 0)
5574 if (i == (ssize_t) argc)
5575 ThrowMogrifyException(OptionError,"MissingArgument",option);
5576 if (IsGeometry(argv[i]) == MagickFalse)
5577 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5580 if (LocaleCompare("shave",option+1) == 0)
5585 if (i == (ssize_t) argc)
5586 ThrowMogrifyException(OptionError,"MissingArgument",option);
5587 if (IsGeometry(argv[i]) == MagickFalse)
5588 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5591 if (LocaleCompare("shear",option+1) == 0)
5594 if (i == (ssize_t) argc)
5595 ThrowMogrifyException(OptionError,"MissingArgument",option);
5596 if (IsGeometry(argv[i]) == MagickFalse)
5597 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5600 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5603 if (i == (ssize_t) (argc-1))
5604 ThrowMogrifyException(OptionError,"MissingArgument",option);
5605 if (IsGeometry(argv[i]) == MagickFalse)
5606 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5609 if (LocaleCompare("size",option+1) == 0)
5614 if (i == (ssize_t) argc)
5615 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 if (IsGeometry(argv[i]) == MagickFalse)
5617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620 if (LocaleCompare("sketch",option+1) == 0)
5625 if (i == (ssize_t) argc)
5626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 if (IsGeometry(argv[i]) == MagickFalse)
5628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 if (LocaleCompare("smush",option+1) == 0)
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,"MissingArgument",option);
5636 if (IsGeometry(argv[i]) == MagickFalse)
5637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5641 if (LocaleCompare("solarize",option+1) == 0)
5646 if (i == (ssize_t) argc)
5647 ThrowMogrifyException(OptionError,"MissingArgument",option);
5648 if (IsGeometry(argv[i]) == MagickFalse)
5649 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5652 if (LocaleCompare("sparse-color",option+1) == 0)
5658 if (i == (ssize_t) argc)
5659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5662 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5665 if (i == (ssize_t) (argc-1))
5666 ThrowMogrifyException(OptionError,"MissingArgument",option);
5669 if (LocaleCompare("spread",option+1) == 0)
5674 if (i == (ssize_t) argc)
5675 ThrowMogrifyException(OptionError,"MissingArgument",option);
5676 if (IsGeometry(argv[i]) == MagickFalse)
5677 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5680 if (LocaleCompare("statistic",option+1) == 0)
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5690 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5692 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5695 if (i == (ssize_t) (argc-1))
5696 ThrowMogrifyException(OptionError,"MissingArgument",option);
5697 if (IsGeometry(argv[i]) == MagickFalse)
5698 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5701 if (LocaleCompare("stretch",option+1) == 0)
5709 if (i == (ssize_t) (argc-1))
5710 ThrowMogrifyException(OptionError,"MissingArgument",option);
5711 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5713 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5717 if (LocaleCompare("strip",option+1) == 0)
5719 if (LocaleCompare("stroke",option+1) == 0)
5724 if (i == (ssize_t) argc)
5725 ThrowMogrifyException(OptionError,"MissingArgument",option);
5728 if (LocaleCompare("strokewidth",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5735 if (IsGeometry(argv[i]) == MagickFalse)
5736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5739 if (LocaleCompare("style",option+1) == 0)
5747 if (i == (ssize_t) (argc-1))
5748 ThrowMogrifyException(OptionError,"MissingArgument",option);
5749 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5751 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5755 if (LocaleCompare("swap",option+1) == 0)
5760 if (i == (ssize_t) (argc-1))
5761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5766 if (LocaleCompare("swirl",option+1) == 0)
5771 if (i == (ssize_t) argc)
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 if (LocaleCompare("synchronize",option+1) == 0)
5779 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5783 if (LocaleCompare("taint",option+1) == 0)
5785 if (LocaleCompare("texture",option+1) == 0)
5790 if (i == (ssize_t) argc)
5791 ThrowMogrifyException(OptionError,"MissingArgument",option);
5794 if (LocaleCompare("tile",option+1) == 0)
5799 if (i == (ssize_t) (argc-1))
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5803 if (LocaleCompare("tile-offset",option+1) == 0)
5808 if (i == (ssize_t) argc)
5809 ThrowMogrifyException(OptionError,"MissingArgument",option);
5810 if (IsGeometry(argv[i]) == MagickFalse)
5811 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5814 if (LocaleCompare("tint",option+1) == 0)
5819 if (i == (ssize_t) (argc-1))
5820 ThrowMogrifyException(OptionError,"MissingArgument",option);
5821 if (IsGeometry(argv[i]) == MagickFalse)
5822 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5825 if (LocaleCompare("transform",option+1) == 0)
5827 if (LocaleCompare("transpose",option+1) == 0)
5829 if (LocaleCompare("transverse",option+1) == 0)
5831 if (LocaleCompare("threshold",option+1) == 0)
5836 if (i == (ssize_t) argc)
5837 ThrowMogrifyException(OptionError,"MissingArgument",option);
5838 if (IsGeometry(argv[i]) == MagickFalse)
5839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5842 if (LocaleCompare("thumbnail",option+1) == 0)
5847 if (i == (ssize_t) argc)
5848 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 if (LocaleCompare("transparent",option+1) == 0)
5856 if (i == (ssize_t) argc)
5857 ThrowMogrifyException(OptionError,"MissingArgument",option);
5860 if (LocaleCompare("transparent-color",option+1) == 0)
5865 if (i == (ssize_t) (argc-1))
5866 ThrowMogrifyException(OptionError,"MissingArgument",option);
5869 if (LocaleCompare("treedepth",option+1) == 0)
5874 if (i == (ssize_t) argc)
5875 ThrowMogrifyException(OptionError,"MissingArgument",option);
5876 if (IsGeometry(argv[i]) == MagickFalse)
5877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5880 if (LocaleCompare("trim",option+1) == 0)
5882 if (LocaleCompare("type",option+1) == 0)
5890 if (i == (ssize_t) argc)
5891 ThrowMogrifyException(OptionError,"MissingArgument",option);
5892 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5894 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5898 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5902 if (LocaleCompare("undercolor",option+1) == 0)
5907 if (i == (ssize_t) argc)
5908 ThrowMogrifyException(OptionError,"MissingArgument",option);
5911 if (LocaleCompare("unique-colors",option+1) == 0)
5913 if (LocaleCompare("units",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5926 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5930 if (LocaleCompare("unsharp",option+1) == 0)
5933 if (i == (ssize_t) argc)
5934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 if (IsGeometry(argv[i]) == MagickFalse)
5936 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5943 if (LocaleCompare("verbose",option+1) == 0)
5945 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5948 if ((LocaleCompare("version",option+1) == 0) ||
5949 (LocaleCompare("-version",option+1) == 0))
5951 (void) FormatLocaleFile(stdout,"Version: %s\n",
5952 GetMagickVersion((size_t *) NULL));
5953 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5954 GetMagickCopyright());
5955 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5956 GetMagickFeatures());
5959 if (LocaleCompare("view",option+1) == 0)
5964 if (i == (ssize_t) argc)
5965 ThrowMogrifyException(OptionError,"MissingArgument",option);
5968 if (LocaleCompare("vignette",option+1) == 0)
5973 if (i == (ssize_t) argc)
5974 ThrowMogrifyException(OptionError,"MissingArgument",option);
5975 if (IsGeometry(argv[i]) == MagickFalse)
5976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5979 if (LocaleCompare("virtual-pixel",option+1) == 0)
5987 if (i == (ssize_t) argc)
5988 ThrowMogrifyException(OptionError,"MissingArgument",option);
5989 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5992 ThrowMogrifyException(OptionError,
5993 "UnrecognizedVirtualPixelMethod",argv[i]);
5996 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6000 if (LocaleCompare("wave",option+1) == 0)
6003 if (i == (ssize_t) argc)
6004 ThrowMogrifyException(OptionError,"MissingArgument",option);
6005 if (IsGeometry(argv[i]) == MagickFalse)
6006 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6009 if (LocaleCompare("weight",option+1) == 0)
6014 if (i == (ssize_t) (argc-1))
6015 ThrowMogrifyException(OptionError,"MissingArgument",option);
6018 if (LocaleCompare("white-point",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6025 if (IsGeometry(argv[i]) == MagickFalse)
6026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6029 if (LocaleCompare("white-threshold",option+1) == 0)
6034 if (i == (ssize_t) argc)
6035 ThrowMogrifyException(OptionError,"MissingArgument",option);
6036 if (IsGeometry(argv[i]) == MagickFalse)
6037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6040 if (LocaleCompare("write",option+1) == 0)
6043 if (i == (ssize_t) (argc-1))
6044 ThrowMogrifyException(OptionError,"MissingArgument",option);
6047 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6052 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6054 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6055 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6056 if (fire != MagickFalse)
6057 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6060 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6061 if (i != (ssize_t) argc)
6062 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6064 return(status != 0 ? MagickTrue : MagickFalse);
6068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6072 + M o g r i f y I m a g e I n f o %
6076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6078 % MogrifyImageInfo() applies image processing settings to the image as
6079 % prescribed by command line options.
6081 % The format of the MogrifyImageInfo method is:
6083 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6084 % const char **argv,ExceptionInfo *exception)
6086 % A description of each parameter follows:
6088 % o image_info: the image info..
6090 % o argc: Specifies a pointer to an integer describing the number of
6091 % elements in the argument vector.
6093 % o argv: Specifies a pointer to a text array containing the command line
6096 % o exception: return any errors or warnings in this structure.
6099 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6100 const int argc,const char **argv,ExceptionInfo *exception)
6115 Initialize method variables.
6117 assert(image_info != (ImageInfo *) NULL);
6118 assert(image_info->signature == MagickSignature);
6119 if (image_info->debug != MagickFalse)
6120 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6121 image_info->filename);
6125 Set the image settings.
6127 for (i=0; i < (ssize_t) argc; i++)
6130 if (IsCommandOption(option) == MagickFalse)
6132 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6133 count=MagickMax(count,0L);
6134 if ((i+count) >= (ssize_t) argc)
6136 switch (*(option+1))
6140 if (LocaleCompare("adjoin",option+1) == 0)
6142 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6145 if (LocaleCompare("antialias",option+1) == 0)
6147 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6150 if (LocaleCompare("attenuate",option+1) == 0)
6154 (void) DeleteImageOption(image_info,option+1);
6157 (void) SetImageOption(image_info,option+1,argv[i+1]);
6160 if (LocaleCompare("authenticate",option+1) == 0)
6163 (void) CloneString(&image_info->authenticate,(char *) NULL);
6165 (void) CloneString(&image_info->authenticate,argv[i+1]);
6172 if (LocaleCompare("background",option+1) == 0)
6176 (void) DeleteImageOption(image_info,option+1);
6177 (void) QueryColorDatabase(BackgroundColor,
6178 &image_info->background_color,exception);
6181 (void) SetImageOption(image_info,option+1,argv[i+1]);
6182 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6186 if (LocaleCompare("bias",option+1) == 0)
6190 (void) SetImageOption(image_info,option+1,"0.0");
6193 (void) SetImageOption(image_info,option+1,argv[i+1]);
6196 if (LocaleCompare("black-point-compensation",option+1) == 0)
6200 (void) SetImageOption(image_info,option+1,"false");
6203 (void) SetImageOption(image_info,option+1,"true");
6206 if (LocaleCompare("blue-primary",option+1) == 0)
6210 (void) SetImageOption(image_info,option+1,"0.0");
6213 (void) SetImageOption(image_info,option+1,argv[i+1]);
6216 if (LocaleCompare("bordercolor",option+1) == 0)
6220 (void) DeleteImageOption(image_info,option+1);
6221 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6225 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6227 (void) SetImageOption(image_info,option+1,argv[i+1]);
6230 if (LocaleCompare("box",option+1) == 0)
6234 (void) SetImageOption(image_info,"undercolor","none");
6237 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6244 if (LocaleCompare("cache",option+1) == 0)
6249 limit=MagickResourceInfinity;
6250 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6251 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6252 (void) SetMagickResourceLimit(MemoryResource,limit);
6253 (void) SetMagickResourceLimit(MapResource,2*limit);
6256 if (LocaleCompare("caption",option+1) == 0)
6260 (void) DeleteImageOption(image_info,option+1);
6263 (void) SetImageOption(image_info,option+1,argv[i+1]);
6266 if (LocaleCompare("channel",option+1) == 0)
6270 image_info->channel=DefaultChannels;
6273 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6276 if (LocaleCompare("colors",option+1) == 0)
6278 image_info->colors=StringToUnsignedLong(argv[i+1]);
6281 if (LocaleCompare("colorspace",option+1) == 0)
6285 image_info->colorspace=UndefinedColorspace;
6286 (void) SetImageOption(image_info,option+1,"undefined");
6289 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6290 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6291 (void) SetImageOption(image_info,option+1,argv[i+1]);
6294 if (LocaleCompare("comment",option+1) == 0)
6298 (void) DeleteImageOption(image_info,option+1);
6301 (void) SetImageOption(image_info,option+1,argv[i+1]);
6304 if (LocaleCompare("compose",option+1) == 0)
6308 (void) SetImageOption(image_info,option+1,"undefined");
6311 (void) SetImageOption(image_info,option+1,argv[i+1]);
6314 if (LocaleCompare("compress",option+1) == 0)
6318 image_info->compression=UndefinedCompression;
6319 (void) SetImageOption(image_info,option+1,"undefined");
6322 image_info->compression=(CompressionType) ParseCommandOption(
6323 MagickCompressOptions,MagickFalse,argv[i+1]);
6324 (void) SetImageOption(image_info,option+1,argv[i+1]);
6331 if (LocaleCompare("debug",option+1) == 0)
6334 (void) SetLogEventMask("none");
6336 (void) SetLogEventMask(argv[i+1]);
6337 image_info->debug=IsEventLogging();
6340 if (LocaleCompare("define",option+1) == 0)
6344 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6345 (void) DeleteImageRegistry(argv[i+1]+9);
6347 (void) DeleteImageOption(image_info,argv[i+1]);
6350 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6352 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6356 (void) DefineImageOption(image_info,argv[i+1]);
6359 if (LocaleCompare("delay",option+1) == 0)
6363 (void) SetImageOption(image_info,option+1,"0");
6366 (void) SetImageOption(image_info,option+1,argv[i+1]);
6369 if (LocaleCompare("density",option+1) == 0)
6376 if (image_info->density != (char *) NULL)
6377 image_info->density=DestroyString(image_info->density);
6378 (void) SetImageOption(image_info,option+1,"72");
6381 (void) CloneString(&image_info->density,argv[i+1]);
6382 (void) SetImageOption(image_info,option+1,argv[i+1]);
6385 if (LocaleCompare("depth",option+1) == 0)
6389 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6392 image_info->depth=StringToUnsignedLong(argv[i+1]);
6395 if (LocaleCompare("direction",option+1) == 0)
6399 (void) SetImageOption(image_info,option+1,"undefined");
6402 (void) SetImageOption(image_info,option+1,argv[i+1]);
6405 if (LocaleCompare("display",option+1) == 0)
6409 if (image_info->server_name != (char *) NULL)
6410 image_info->server_name=DestroyString(
6411 image_info->server_name);
6414 (void) CloneString(&image_info->server_name,argv[i+1]);
6417 if (LocaleCompare("dispose",option+1) == 0)
6421 (void) SetImageOption(image_info,option+1,"undefined");
6424 (void) SetImageOption(image_info,option+1,argv[i+1]);
6427 if (LocaleCompare("dither",option+1) == 0)
6431 image_info->dither=MagickFalse;
6432 (void) SetImageOption(image_info,option+1,"none");
6435 (void) SetImageOption(image_info,option+1,argv[i+1]);
6436 image_info->dither=MagickTrue;
6443 if (LocaleCompare("encoding",option+1) == 0)
6447 (void) SetImageOption(image_info,option+1,"undefined");
6450 (void) SetImageOption(image_info,option+1,argv[i+1]);
6453 if (LocaleCompare("endian",option+1) == 0)
6457 image_info->endian=UndefinedEndian;
6458 (void) SetImageOption(image_info,option+1,"undefined");
6461 image_info->endian=(EndianType) ParseCommandOption(
6462 MagickEndianOptions,MagickFalse,argv[i+1]);
6463 (void) SetImageOption(image_info,option+1,argv[i+1]);
6466 if (LocaleCompare("extract",option+1) == 0)
6469 Set image extract geometry.
6473 if (image_info->extract != (char *) NULL)
6474 image_info->extract=DestroyString(image_info->extract);
6477 (void) CloneString(&image_info->extract,argv[i+1]);
6484 if (LocaleCompare("fill",option+1) == 0)
6488 (void) SetImageOption(image_info,option+1,"none");
6491 (void) SetImageOption(image_info,option+1,argv[i+1]);
6494 if (LocaleCompare("filter",option+1) == 0)
6498 (void) SetImageOption(image_info,option+1,"undefined");
6501 (void) SetImageOption(image_info,option+1,argv[i+1]);
6504 if (LocaleCompare("font",option+1) == 0)
6508 if (image_info->font != (char *) NULL)
6509 image_info->font=DestroyString(image_info->font);
6512 (void) CloneString(&image_info->font,argv[i+1]);
6515 if (LocaleCompare("format",option+1) == 0)
6520 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6521 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6522 image_info->ping=MagickFalse;
6523 (void) SetImageOption(image_info,option+1,argv[i+1]);
6526 if (LocaleCompare("fuzz",option+1) == 0)
6530 image_info->fuzz=0.0;
6531 (void) SetImageOption(image_info,option+1,"0");
6534 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6536 (void) SetImageOption(image_info,option+1,argv[i+1]);
6543 if (LocaleCompare("gravity",option+1) == 0)
6547 (void) SetImageOption(image_info,option+1,"undefined");
6550 (void) SetImageOption(image_info,option+1,argv[i+1]);
6553 if (LocaleCompare("green-primary",option+1) == 0)
6557 (void) SetImageOption(image_info,option+1,"0.0");
6560 (void) SetImageOption(image_info,option+1,argv[i+1]);
6567 if (LocaleCompare("intent",option+1) == 0)
6571 (void) SetImageOption(image_info,option+1,"undefined");
6574 (void) SetImageOption(image_info,option+1,argv[i+1]);
6577 if (LocaleCompare("interlace",option+1) == 0)
6581 image_info->interlace=UndefinedInterlace;
6582 (void) SetImageOption(image_info,option+1,"undefined");
6585 image_info->interlace=(InterlaceType) ParseCommandOption(
6586 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6587 (void) SetImageOption(image_info,option+1,argv[i+1]);
6590 if (LocaleCompare("interline-spacing",option+1) == 0)
6594 (void) SetImageOption(image_info,option+1,"undefined");
6597 (void) SetImageOption(image_info,option+1,argv[i+1]);
6600 if (LocaleCompare("interpolate",option+1) == 0)
6604 (void) SetImageOption(image_info,option+1,"undefined");
6607 (void) SetImageOption(image_info,option+1,argv[i+1]);
6610 if (LocaleCompare("interword-spacing",option+1) == 0)
6614 (void) SetImageOption(image_info,option+1,"undefined");
6617 (void) SetImageOption(image_info,option+1,argv[i+1]);
6624 if (LocaleCompare("kerning",option+1) == 0)
6628 (void) SetImageOption(image_info,option+1,"undefined");
6631 (void) SetImageOption(image_info,option+1,argv[i+1]);
6638 if (LocaleCompare("label",option+1) == 0)
6642 (void) DeleteImageOption(image_info,option+1);
6645 (void) SetImageOption(image_info,option+1,argv[i+1]);
6648 if (LocaleCompare("limit",option+1) == 0)
6658 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6659 MagickFalse,argv[i+1]);
6660 limit=MagickResourceInfinity;
6661 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6662 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6663 (void) SetMagickResourceLimit(type,limit);
6666 if (LocaleCompare("list",option+1) == 0)
6672 Display configuration list.
6674 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6677 case MagickCoderOptions:
6679 (void) ListCoderInfo((FILE *) NULL,exception);
6682 case MagickColorOptions:
6684 (void) ListColorInfo((FILE *) NULL,exception);
6687 case MagickConfigureOptions:
6689 (void) ListConfigureInfo((FILE *) NULL,exception);
6692 case MagickDelegateOptions:
6694 (void) ListDelegateInfo((FILE *) NULL,exception);
6697 case MagickFontOptions:
6699 (void) ListTypeInfo((FILE *) NULL,exception);
6702 case MagickFormatOptions:
6704 (void) ListMagickInfo((FILE *) NULL,exception);
6707 case MagickLocaleOptions:
6709 (void) ListLocaleInfo((FILE *) NULL,exception);
6712 case MagickLogOptions:
6714 (void) ListLogInfo((FILE *) NULL,exception);
6717 case MagickMagicOptions:
6719 (void) ListMagicInfo((FILE *) NULL,exception);
6722 case MagickMimeOptions:
6724 (void) ListMimeInfo((FILE *) NULL,exception);
6727 case MagickModuleOptions:
6729 (void) ListModuleInfo((FILE *) NULL,exception);
6732 case MagickPolicyOptions:
6734 (void) ListPolicyInfo((FILE *) NULL,exception);
6737 case MagickResourceOptions:
6739 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6742 case MagickThresholdOptions:
6744 (void) ListThresholdMaps((FILE *) NULL,exception);
6749 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6756 if (LocaleCompare("log",option+1) == 0)
6760 (void) SetLogFormat(argv[i+1]);
6763 if (LocaleCompare("loop",option+1) == 0)
6767 (void) SetImageOption(image_info,option+1,"0");
6770 (void) SetImageOption(image_info,option+1,argv[i+1]);
6777 if (LocaleCompare("matte",option+1) == 0)
6781 (void) SetImageOption(image_info,option+1,"false");
6784 (void) SetImageOption(image_info,option+1,"true");
6787 if (LocaleCompare("mattecolor",option+1) == 0)
6791 (void) SetImageOption(image_info,option+1,argv[i+1]);
6792 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
6796 (void) SetImageOption(image_info,option+1,argv[i+1]);
6797 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6801 if (LocaleCompare("monitor",option+1) == 0)
6803 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6807 if (LocaleCompare("monochrome",option+1) == 0)
6809 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6816 if (LocaleCompare("orient",option+1) == 0)
6820 image_info->orientation=UndefinedOrientation;
6821 (void) SetImageOption(image_info,option+1,"undefined");
6824 image_info->orientation=(OrientationType) ParseCommandOption(
6825 MagickOrientationOptions,MagickFalse,argv[i+1]);
6826 (void) SetImageOption(image_info,option+1,argv[i+1]);
6832 if (LocaleCompare("page",option+1) == 0)
6836 page[MaxTextExtent];
6849 (void) DeleteImageOption(image_info,option+1);
6850 (void) CloneString(&image_info->page,(char *) NULL);
6853 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6854 image_option=GetImageOption(image_info,"page");
6855 if (image_option != (const char *) NULL)
6856 flags=ParseAbsoluteGeometry(image_option,&geometry);
6857 canonical_page=GetPageGeometry(argv[i+1]);
6858 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6859 canonical_page=DestroyString(canonical_page);
6860 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6861 (unsigned long) geometry.width,(unsigned long) geometry.height);
6862 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6863 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6864 (unsigned long) geometry.width,(unsigned long) geometry.height,
6865 (long) geometry.x,(long) geometry.y);
6866 (void) SetImageOption(image_info,option+1,page);
6867 (void) CloneString(&image_info->page,page);
6870 if (LocaleCompare("pen",option+1) == 0)
6874 (void) SetImageOption(image_info,option+1,"none");
6877 (void) SetImageOption(image_info,option+1,argv[i+1]);
6880 if (LocaleCompare("ping",option+1) == 0)
6882 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6885 if (LocaleCompare("pointsize",option+1) == 0)
6888 geometry_info.rho=0.0;
6890 (void) ParseGeometry(argv[i+1],&geometry_info);
6891 image_info->pointsize=geometry_info.rho;
6894 if (LocaleCompare("precision",option+1) == 0)
6896 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6899 if (LocaleCompare("preview",option+1) == 0)
6906 image_info->preview_type=UndefinedPreview;
6909 image_info->preview_type=(PreviewType) ParseCommandOption(
6910 MagickPreviewOptions,MagickFalse,argv[i+1]);
6917 if (LocaleCompare("quality",option+1) == 0)
6920 Set image compression quality.
6924 image_info->quality=UndefinedCompressionQuality;
6925 (void) SetImageOption(image_info,option+1,"0");
6928 image_info->quality=StringToUnsignedLong(argv[i+1]);
6929 (void) SetImageOption(image_info,option+1,argv[i+1]);
6932 if (LocaleCompare("quiet",option+1) == 0)
6934 static WarningHandler
6935 warning_handler = (WarningHandler) NULL;
6940 Restore error or warning messages.
6942 warning_handler=SetWarningHandler(warning_handler);
6946 Suppress error or warning messages.
6948 warning_handler=SetWarningHandler((WarningHandler) NULL);
6955 if (LocaleCompare("red-primary",option+1) == 0)
6959 (void) SetImageOption(image_info,option+1,"0.0");
6962 (void) SetImageOption(image_info,option+1,argv[i+1]);
6969 if (LocaleCompare("sampling-factor",option+1) == 0)
6972 Set image sampling factor.
6976 if (image_info->sampling_factor != (char *) NULL)
6977 image_info->sampling_factor=DestroyString(
6978 image_info->sampling_factor);
6981 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6984 if (LocaleCompare("scene",option+1) == 0)
6991 image_info->scene=0;
6992 (void) SetImageOption(image_info,option+1,"0");
6995 image_info->scene=StringToUnsignedLong(argv[i+1]);
6996 (void) SetImageOption(image_info,option+1,argv[i+1]);
6999 if (LocaleCompare("seed",option+1) == 0)
7006 seed=(size_t) time((time_t *) NULL);
7007 SeedPseudoRandomGenerator(seed);
7010 seed=StringToUnsignedLong(argv[i+1]);
7011 SeedPseudoRandomGenerator(seed);
7014 if (LocaleCompare("size",option+1) == 0)
7018 if (image_info->size != (char *) NULL)
7019 image_info->size=DestroyString(image_info->size);
7022 (void) CloneString(&image_info->size,argv[i+1]);
7025 if (LocaleCompare("stroke",option+1) == 0)
7029 (void) SetImageOption(image_info,option+1,"none");
7032 (void) SetImageOption(image_info,option+1,argv[i+1]);
7035 if (LocaleCompare("strokewidth",option+1) == 0)
7039 (void) SetImageOption(image_info,option+1,"0");
7042 (void) SetImageOption(image_info,option+1,argv[i+1]);
7045 if (LocaleCompare("synchronize",option+1) == 0)
7049 image_info->synchronize=MagickFalse;
7052 image_info->synchronize=MagickTrue;
7059 if (LocaleCompare("taint",option+1) == 0)
7063 (void) SetImageOption(image_info,option+1,"false");
7066 (void) SetImageOption(image_info,option+1,"true");
7069 if (LocaleCompare("texture",option+1) == 0)
7073 if (image_info->texture != (char *) NULL)
7074 image_info->texture=DestroyString(image_info->texture);
7077 (void) CloneString(&image_info->texture,argv[i+1]);
7080 if (LocaleCompare("tile-offset",option+1) == 0)
7084 (void) SetImageOption(image_info,option+1,"0");
7087 (void) SetImageOption(image_info,option+1,argv[i+1]);
7090 if (LocaleCompare("transparent-color",option+1) == 0)
7094 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7095 (void) SetImageOption(image_info,option+1,"none");
7098 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7100 (void) SetImageOption(image_info,option+1,argv[i+1]);
7103 if (LocaleCompare("type",option+1) == 0)
7107 image_info->type=UndefinedType;
7108 (void) SetImageOption(image_info,option+1,"undefined");
7111 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7112 MagickFalse,argv[i+1]);
7113 (void) SetImageOption(image_info,option+1,argv[i+1]);
7120 if (LocaleCompare("undercolor",option+1) == 0)
7124 (void) DeleteImageOption(image_info,option+1);
7127 (void) SetImageOption(image_info,option+1,argv[i+1]);
7130 if (LocaleCompare("units",option+1) == 0)
7134 image_info->units=UndefinedResolution;
7135 (void) SetImageOption(image_info,option+1,"undefined");
7138 image_info->units=(ResolutionType) ParseCommandOption(
7139 MagickResolutionOptions,MagickFalse,argv[i+1]);
7140 (void) SetImageOption(image_info,option+1,argv[i+1]);
7147 if (LocaleCompare("verbose",option+1) == 0)
7151 image_info->verbose=MagickFalse;
7154 image_info->verbose=MagickTrue;
7155 image_info->ping=MagickFalse;
7158 if (LocaleCompare("view",option+1) == 0)
7162 if (image_info->view != (char *) NULL)
7163 image_info->view=DestroyString(image_info->view);
7166 (void) CloneString(&image_info->view,argv[i+1]);
7169 if (LocaleCompare("virtual-pixel",option+1) == 0)
7173 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7174 (void) SetImageOption(image_info,option+1,"undefined");
7177 image_info->virtual_pixel_method=(VirtualPixelMethod)
7178 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7180 (void) SetImageOption(image_info,option+1,argv[i+1]);
7187 if (LocaleCompare("white-point",option+1) == 0)
7191 (void) SetImageOption(image_info,option+1,"0.0");
7194 (void) SetImageOption(image_info,option+1,argv[i+1]);
7208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7212 + M o g r i f y I m a g e L i s t %
7216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7218 % MogrifyImageList() applies any command line options that might affect the
7219 % entire image list (e.g. -append, -coalesce, etc.).
7221 % The format of the MogrifyImage method is:
7223 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7224 % const char **argv,Image **images,ExceptionInfo *exception)
7226 % A description of each parameter follows:
7228 % o image_info: the image info..
7230 % o argc: Specifies a pointer to an integer describing the number of
7231 % elements in the argument vector.
7233 % o argv: Specifies a pointer to a text array containing the command line
7236 % o images: pointer to pointer of the first image in image list.
7238 % o exception: return any errors or warnings in this structure.
7241 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7242 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7267 Apply options to the image list.
7269 assert(image_info != (ImageInfo *) NULL);
7270 assert(image_info->signature == MagickSignature);
7271 assert(images != (Image **) NULL);
7272 assert((*images)->previous == (Image *) NULL);
7273 assert((*images)->signature == MagickSignature);
7274 if ((*images)->debug != MagickFalse)
7275 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7276 (*images)->filename);
7277 if ((argc <= 0) || (*argv == (char *) NULL))
7279 mogrify_info=CloneImageInfo(image_info);
7280 quantize_info=AcquireQuantizeInfo(mogrify_info);
7281 channel=mogrify_info->channel;
7283 for (i=0; i < (ssize_t) argc; i++)
7285 if (*images == (Image *) NULL)
7288 if (IsCommandOption(option) == MagickFalse)
7290 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7291 count=MagickMax(count,0L);
7292 if ((i+count) >= (ssize_t) argc)
7294 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7295 switch (*(option+1))
7299 if (LocaleCompare("affinity",option+1) == 0)
7301 (void) SyncImagesSettings(mogrify_info,*images);
7304 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7305 InheritException(exception,&(*images)->exception);
7311 if (LocaleCompare("append",option+1) == 0)
7316 (void) SyncImagesSettings(mogrify_info,*images);
7317 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7318 MagickFalse,exception);
7319 if (append_image == (Image *) NULL)
7324 *images=DestroyImageList(*images);
7325 *images=append_image;
7328 if (LocaleCompare("average",option+1) == 0)
7334 Average an image sequence (deprecated).
7336 (void) SyncImagesSettings(mogrify_info,*images);
7337 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7339 if (average_image == (Image *) NULL)
7344 *images=DestroyImageList(*images);
7345 *images=average_image;
7352 if (LocaleCompare("channel",option+1) == 0)
7356 channel=DefaultChannels;
7359 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7362 if (LocaleCompare("clut",option+1) == 0)
7368 (void) SyncImagesSettings(mogrify_info,*images);
7369 image=RemoveFirstImageFromList(images);
7370 clut_image=RemoveFirstImageFromList(images);
7371 if (clut_image == (Image *) NULL)
7376 (void) ClutImageChannel(image,channel,clut_image);
7377 clut_image=DestroyImage(clut_image);
7378 InheritException(exception,&image->exception);
7379 *images=DestroyImageList(*images);
7383 if (LocaleCompare("coalesce",option+1) == 0)
7388 (void) SyncImagesSettings(mogrify_info,*images);
7389 coalesce_image=CoalesceImages(*images,exception);
7390 if (coalesce_image == (Image *) NULL)
7395 *images=DestroyImageList(*images);
7396 *images=coalesce_image;
7399 if (LocaleCompare("combine",option+1) == 0)
7404 (void) SyncImagesSettings(mogrify_info,*images);
7405 combine_image=CombineImages(*images,channel,exception);
7406 if (combine_image == (Image *) NULL)
7411 *images=DestroyImageList(*images);
7412 *images=combine_image;
7415 if (LocaleCompare("composite",option+1) == 0)
7425 (void) SyncImagesSettings(mogrify_info,*images);
7426 image=RemoveFirstImageFromList(images);
7427 composite_image=RemoveFirstImageFromList(images);
7428 if (composite_image == (Image *) NULL)
7433 (void) TransformImage(&composite_image,(char *) NULL,
7434 composite_image->geometry);
7435 SetGeometry(composite_image,&geometry);
7436 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7437 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7439 mask_image=RemoveFirstImageFromList(images);
7440 if (mask_image != (Image *) NULL)
7442 if ((image->compose == DisplaceCompositeOp) ||
7443 (image->compose == DistortCompositeOp))
7446 Merge Y displacement into X displacement image.
7448 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7450 mask_image=DestroyImage(mask_image);
7455 Set a blending mask for the composition.
7457 /* POSIBLE ERROR; what if image->mask already set */
7458 image->mask=mask_image;
7459 (void) NegateImage(image->mask,MagickFalse);
7462 (void) CompositeImageChannel(image,channel,image->compose,
7463 composite_image,geometry.x,geometry.y);
7464 if (mask_image != (Image *) NULL)
7465 mask_image=image->mask=DestroyImage(image->mask);
7466 composite_image=DestroyImage(composite_image);
7467 InheritException(exception,&image->exception);
7468 *images=DestroyImageList(*images);
7473 This has been merged completely into MogrifyImage()
7474 if (LocaleCompare("crop",option+1) == 0)
7485 (void) SyncImagesSettings(mogrify_info,*images);
7486 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7487 if (((geometry.width == 0) && (geometry.height == 0)) ||
7488 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7490 (void) TransformImages(images,argv[i+1],(char *) NULL);
7491 InheritException(exception,&(*images)->exception);
7499 if (LocaleCompare("deconstruct",option+1) == 0)
7504 (void) SyncImagesSettings(mogrify_info,*images);
7505 deconstruct_image=CompareImageLayers(*images,CompareAnyLayer,
7507 if (deconstruct_image == (Image *) NULL)
7512 *images=DestroyImageList(*images);
7513 *images=deconstruct_image;
7516 if (LocaleCompare("delete",option+1) == 0)
7519 DeleteImages(images,"-1",exception);
7521 DeleteImages(images,argv[i+1],exception);
7524 if (LocaleCompare("dither",option+1) == 0)
7528 quantize_info->dither=MagickFalse;
7531 quantize_info->dither=MagickTrue;
7532 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7533 MagickDitherOptions,MagickFalse,argv[i+1]);
7536 if (LocaleCompare("duplicate",option+1) == 0)
7542 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7551 number_duplicates=(size_t) StringToLong(argv[i+1]);
7552 p=strchr(argv[i+1],',');
7553 if (p == (const char *) NULL)
7554 duplicate_images=DuplicateImages(*images,number_duplicates,
7557 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7560 AppendImageToList(images, duplicate_images);
7561 (void) SyncImagesSettings(mogrify_info,*images);
7568 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7573 MagickEvaluateOperator
7576 (void) SyncImageSettings(mogrify_info,*images);
7577 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
7578 MagickFalse,argv[i+1]);
7579 evaluate_image=EvaluateImages(*images,op,exception);
7580 if (evaluate_image == (Image *) NULL)
7585 *images=DestroyImageList(*images);
7586 *images=evaluate_image;
7593 if (LocaleCompare("fft",option+1) == 0)
7599 Implements the discrete Fourier transform (DFT).
7601 (void) SyncImageSettings(mogrify_info,*images);
7602 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7603 MagickTrue : MagickFalse,exception);
7604 if (fourier_image == (Image *) NULL)
7606 *images=DestroyImage(*images);
7607 *images=fourier_image;
7610 if (LocaleCompare("flatten",option+1) == 0)
7615 (void) SyncImagesSettings(mogrify_info,*images);
7616 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7617 if (flatten_image == (Image *) NULL)
7619 *images=DestroyImageList(*images);
7620 *images=flatten_image;
7623 if (LocaleCompare("fx",option+1) == 0)
7628 (void) SyncImagesSettings(mogrify_info,*images);
7629 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7630 if (fx_image == (Image *) NULL)
7635 *images=DestroyImageList(*images);
7643 if (LocaleCompare("hald-clut",option+1) == 0)
7649 (void) SyncImagesSettings(mogrify_info,*images);
7650 image=RemoveFirstImageFromList(images);
7651 hald_image=RemoveFirstImageFromList(images);
7652 if (hald_image == (Image *) NULL)
7657 (void) HaldClutImageChannel(image,channel,hald_image);
7658 hald_image=DestroyImage(hald_image);
7659 InheritException(exception,&image->exception);
7660 if (*images != (Image *) NULL)
7661 *images=DestroyImageList(*images);
7669 if (LocaleCompare("ift",option+1) == 0)
7677 Implements the inverse fourier discrete Fourier transform (DFT).
7679 (void) SyncImagesSettings(mogrify_info,*images);
7680 magnitude_image=RemoveFirstImageFromList(images);
7681 phase_image=RemoveFirstImageFromList(images);
7682 if (phase_image == (Image *) NULL)
7687 fourier_image=InverseFourierTransformImage(magnitude_image,
7688 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7689 if (fourier_image == (Image *) NULL)
7691 if (*images != (Image *) NULL)
7692 *images=DestroyImage(*images);
7693 *images=fourier_image;
7696 if (LocaleCompare("insert",option+1) == 0)
7704 index=(ssize_t) StringToLong(argv[i+1]);
7705 p=RemoveLastImageFromList(images);
7706 if (p == (Image *) NULL)
7708 (void) ThrowMagickException(exception,GetMagickModule(),
7709 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7715 PrependImageToList(images,q);
7717 if (index == (ssize_t) GetImageListLength(*images))
7718 AppendImageToList(images,q);
7721 q=GetImageFromList(*images,index-1);
7722 if (q == (Image *) NULL)
7724 (void) ThrowMagickException(exception,GetMagickModule(),
7725 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7729 InsertImageInList(&q,p);
7731 *images=GetFirstImageInList(q);
7738 if (LocaleCompare("layers",option+1) == 0)
7746 (void) SyncImagesSettings(mogrify_info,*images);
7747 layers=(Image *) NULL;
7748 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7749 MagickFalse,argv[i+1]);
7754 layers=CoalesceImages(*images,exception);
7757 case CompareAnyLayer:
7758 case CompareClearLayer:
7759 case CompareOverlayLayer:
7762 layers=CompareImageLayers(*images,method,exception);
7768 case TrimBoundsLayer:
7770 layers=MergeImageLayers(*images,method,exception);
7775 layers=DisposeImages(*images,exception);
7778 case OptimizeImageLayer:
7780 layers=OptimizeImageLayers(*images,exception);
7783 case OptimizePlusLayer:
7785 layers=OptimizePlusImageLayers(*images,exception);
7788 case OptimizeTransLayer:
7790 OptimizeImageTransparency(*images,exception);
7793 case RemoveDupsLayer:
7795 RemoveDuplicateLayers(images,exception);
7798 case RemoveZeroLayer:
7800 RemoveZeroDelayLayers(images,exception);
7806 General Purpose, GIF Animation Optimizer.
7808 layers=CoalesceImages(*images,exception);
7809 if (layers == (Image *) NULL)
7814 InheritException(exception,&layers->exception);
7815 *images=DestroyImageList(*images);
7817 layers=OptimizeImageLayers(*images,exception);
7818 if (layers == (Image *) NULL)
7823 InheritException(exception,&layers->exception);
7824 *images=DestroyImageList(*images);
7826 layers=(Image *) NULL;
7827 OptimizeImageTransparency(*images,exception);
7828 InheritException(exception,&(*images)->exception);
7829 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7832 case CompositeLayer:
7844 Split image sequence at the first 'NULL:' image.
7847 while (source != (Image *) NULL)
7849 source=GetNextImageInList(source);
7850 if ((source != (Image *) NULL) &&
7851 (LocaleCompare(source->magick,"NULL") == 0))
7854 if (source != (Image *) NULL)
7856 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7857 (GetNextImageInList(source) == (Image *) NULL))
7858 source=(Image *) NULL;
7862 Separate the two lists, junk the null: image.
7864 source=SplitImageList(source->previous);
7865 DeleteImageFromList(&source);
7868 if (source == (Image *) NULL)
7870 (void) ThrowMagickException(exception,GetMagickModule(),
7871 OptionError,"MissingNullSeparator","layers Composite");
7876 Adjust offset with gravity and virtual canvas.
7878 SetGeometry(*images,&geometry);
7879 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7880 geometry.width=source->page.width != 0 ?
7881 source->page.width : source->columns;
7882 geometry.height=source->page.height != 0 ?
7883 source->page.height : source->rows;
7884 GravityAdjustGeometry((*images)->page.width != 0 ?
7885 (*images)->page.width : (*images)->columns,
7886 (*images)->page.height != 0 ? (*images)->page.height :
7887 (*images)->rows,(*images)->gravity,&geometry);
7888 compose=OverCompositeOp;
7889 option=GetImageOption(mogrify_info,"compose");
7890 if (option != (const char *) NULL)
7891 compose=(CompositeOperator) ParseCommandOption(
7892 MagickComposeOptions,MagickFalse,option);
7893 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7895 source=DestroyImageList(source);
7899 if (layers == (Image *) NULL)
7901 InheritException(exception,&layers->exception);
7902 *images=DestroyImageList(*images);
7910 if (LocaleCompare("map",option+1) == 0)
7912 (void) SyncImagesSettings(mogrify_info,*images);
7915 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7916 InheritException(exception,&(*images)->exception);
7922 if (LocaleCompare("maximum",option+1) == 0)
7928 Maximum image sequence (deprecated).
7930 (void) SyncImagesSettings(mogrify_info,*images);
7931 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7932 if (maximum_image == (Image *) NULL)
7937 *images=DestroyImageList(*images);
7938 *images=maximum_image;
7941 if (LocaleCompare("minimum",option+1) == 0)
7947 Minimum image sequence (deprecated).
7949 (void) SyncImagesSettings(mogrify_info,*images);
7950 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7951 if (minimum_image == (Image *) NULL)
7956 *images=DestroyImageList(*images);
7957 *images=minimum_image;
7960 if (LocaleCompare("morph",option+1) == 0)
7965 (void) SyncImagesSettings(mogrify_info,*images);
7966 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7968 if (morph_image == (Image *) NULL)
7973 *images=DestroyImageList(*images);
7974 *images=morph_image;
7977 if (LocaleCompare("mosaic",option+1) == 0)
7982 (void) SyncImagesSettings(mogrify_info,*images);
7983 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7984 if (mosaic_image == (Image *) NULL)
7989 *images=DestroyImageList(*images);
7990 *images=mosaic_image;
7997 if (LocaleCompare("print",option+1) == 0)
8002 (void) SyncImagesSettings(mogrify_info,*images);
8003 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8004 if (string == (char *) NULL)
8006 InheritException(exception,&(*images)->exception);
8007 (void) FormatLocaleFile(stdout,"%s",string);
8008 string=DestroyString(string);
8010 if (LocaleCompare("process",option+1) == 0)
8019 (void) SyncImagesSettings(mogrify_info,*images);
8020 arguments=StringToArgv(argv[i+1],&number_arguments);
8021 if (arguments == (char **) NULL)
8023 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8044 Support old style syntax, filter="-option arg".
8046 length=strlen(argv[i+1]);
8047 token=(char *) NULL;
8048 if (~length >= (MaxTextExtent-1))
8049 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8051 if (token == (char *) NULL)
8054 arguments=argv[i+1];
8055 token_info=AcquireTokenInfo();
8056 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8057 "\"",'\0',&breaker,&next,"e);
8058 token_info=DestroyTokenInfo(token_info);
8064 argv=(&(arguments[next]));
8065 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8068 token=DestroyString(token);
8071 (void) SubstituteString(&arguments[1],"-","");
8072 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8073 number_arguments-2,(const char **) arguments+2,exception);
8074 for (j=0; j < number_arguments; j++)
8075 arguments[j]=DestroyString(arguments[j]);
8076 arguments=(char **) RelinquishMagickMemory(arguments);
8083 if (LocaleCompare("reverse",option+1) == 0)
8085 ReverseImageList(images);
8086 InheritException(exception,&(*images)->exception);
8093 if (LocaleCompare("smush",option+1) == 0)
8101 (void) SyncImagesSettings(mogrify_info,*images);
8102 offset=(ssize_t) StringToLong(argv[i+1]);
8103 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8104 MagickFalse,offset,exception);
8105 if (smush_image == (Image *) NULL)
8110 *images=DestroyImageList(*images);
8111 *images=smush_image;
8114 if (LocaleCompare("swap",option+1) == 0)
8135 flags=ParseGeometry(argv[i+1],&geometry_info);
8136 index=(ssize_t) geometry_info.rho;
8137 if ((flags & SigmaValue) != 0)
8138 swap_index=(ssize_t) geometry_info.sigma;
8140 p=GetImageFromList(*images,index);
8141 q=GetImageFromList(*images,swap_index);
8142 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8144 (void) ThrowMagickException(exception,GetMagickModule(),
8145 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8151 swap=CloneImage(p,0,0,MagickTrue,exception);
8152 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8153 ReplaceImageInList(&q,swap);
8154 *images=GetFirstImageInList(q);
8161 if (LocaleCompare("write",option+1) == 0)
8172 (void) SyncImagesSettings(mogrify_info,*images);
8173 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8174 (void) DeleteImageRegistry(key);
8175 write_images=(*images);
8177 write_images=CloneImageList(*images,exception);
8178 write_info=CloneImageInfo(mogrify_info);
8179 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8180 write_info=DestroyImageInfo(write_info);
8182 write_images=DestroyImageList(write_images);
8192 quantize_info=DestroyQuantizeInfo(quantize_info);
8193 mogrify_info=DestroyImageInfo(mogrify_info);
8194 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8195 return(status != 0 ? MagickTrue : MagickFalse);
8199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8203 + M o g r i f y I m a g e s %
8207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8209 % MogrifyImages() applies image processing options to a sequence of images as
8210 % prescribed by command line options.
8212 % The format of the MogrifyImage method is:
8214 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8215 % const MagickBooleanType post,const int argc,const char **argv,
8216 % Image **images,Exceptioninfo *exception)
8218 % A description of each parameter follows:
8220 % o image_info: the image info..
8222 % o post: If true, post process image list operators otherwise pre-process.
8224 % o argc: Specifies a pointer to an integer describing the number of
8225 % elements in the argument vector.
8227 % o argv: Specifies a pointer to a text array containing the command line
8230 % o images: pointer to a pointer of the first image in image list.
8232 % o exception: return any errors or warnings in this structure.
8235 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8236 const MagickBooleanType post,const int argc,const char **argv,
8237 Image **images,ExceptionInfo *exception)
8239 #define MogrifyImageTag "Mogrify/Image"
8253 assert(image_info != (ImageInfo *) NULL);
8254 assert(image_info->signature == MagickSignature);
8255 if (images == (Image **) NULL)
8256 return(MogrifyImage(image_info,argc,argv,images,exception));
8257 assert((*images)->previous == (Image *) NULL);
8258 assert((*images)->signature == MagickSignature);
8259 if ((*images)->debug != MagickFalse)
8260 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8261 (*images)->filename);
8262 if ((argc <= 0) || (*argv == (char *) NULL))
8264 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8269 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8274 Pre-process multi-image sequence operators
8276 if (post == MagickFalse)
8277 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8279 For each image, process simple single image operators
8282 n=GetImageListLength(*images);
8286 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8287 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8289 status&=MogrifyImage(image_info,argc,argv,images,exception);
8290 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8291 if (proceed == MagickFalse)
8293 if ( (*images)->next == (Image *) NULL )
8295 *images=(*images)->next;
8298 assert( *images != (Image *) NULL );
8300 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8301 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8305 Post-process, multi-image sequence operators
8307 *images=GetFirstImageInList(*images);
8308 if (post != MagickFalse)
8309 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8310 return(status != 0 ? MagickTrue : MagickFalse);