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-2010 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 "wand/studio.h"
48 #include "wand/MagickWand.h"
49 #include "wand/mogrify-private.h"
50 #include "magick/monitor-private.h"
51 #include "magick/thread-private.h"
52 #include "magick/string-private.h"
57 #define UndefinedCompressionQuality 0UL
63 BackgroundColor[] = "#fff", /* white */
64 BorderColor[] = "#dfdfdf", /* gray */
65 MatteColor[] = "#bdbdbd"; /* gray */
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 + M a g i c k C o m m a n d G e n e s i s %
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 % MagickCommandGenesis() applies image processing options to an image as
79 % prescribed by command line options.
81 % The format of the MagickCommandGenesis method is:
83 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
84 % MagickCommand command,const int argc,const char **argv,Image **image)
86 % A description of each parameter follows:
88 % o image_info: the image info.
90 % o command: the magick command.
92 % o argc: Specifies a pointer to an integer describing the number of
93 % elements in the argument vector.
95 % o argv: Specifies a pointer to a text array containing the command line
100 % o exception: return any errors or warnings in this structure.
103 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
104 MagickCommand command,int argc,char **argv,char **metadata,
105 ExceptionInfo *exception)
129 (void) setlocale(LC_ALL,"");
130 (void) setlocale(LC_NUMERIC,"C");
131 concurrent=MagickFalse;
135 regard_warnings=MagickFalse;
136 for (i=1; i < (ssize_t) (argc-1); i++)
139 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
141 if (LocaleCompare("bench",option+1) == 0)
142 iterations=StringToUnsignedLong(argv[++i]);
143 if (LocaleCompare("concurrent",option+1) == 0)
144 concurrent=MagickTrue;
145 if (LocaleCompare("debug",option+1) == 0)
146 (void) SetLogEventMask(argv[++i]);
147 if (LocaleCompare("duration",option+1) == 0)
148 duration=StringToDouble(argv[++i]);
149 if (LocaleCompare("regard-warnings",option+1) == 0)
150 regard_warnings=MagickTrue;
152 timer=AcquireTimerInfo();
153 if (concurrent == MagickFalse)
155 for (i=0; i < (ssize_t) iterations; i++)
157 if (status != MagickFalse)
161 if (GetElapsedTime(timer) > duration)
163 (void) ContinueTimer(timer);
165 status=command(image_info,argc,argv,metadata,exception);
166 if (exception->severity != UndefinedException)
168 if ((exception->severity > ErrorException) ||
169 (regard_warnings != MagickFalse))
171 CatchException(exception);
173 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
175 (void) fputs(*metadata,stdout);
176 (void) fputc('\n',stdout);
177 *metadata=DestroyString(*metadata);
184 #if defined(MAGICKCORE_OPENMP_SUPPORT)
185 # pragma omp parallel for shared(status)
187 for (i=0; i < (ssize_t) iterations; i++)
189 if (status != MagickFalse)
193 if (GetElapsedTime(timer) > duration)
195 (void) ContinueTimer(timer);
197 status=command(image_info,argc,argv,metadata,exception);
198 #if defined(MAGICKCORE_OPENMP_SUPPORT)
199 # pragma omp critical (MagickCore_CommandGenesis)
202 if (exception->severity != UndefinedException)
204 if ((exception->severity > ErrorException) ||
205 (regard_warnings != MagickFalse))
207 CatchException(exception);
209 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
211 (void) fputs(*metadata,stdout);
212 (void) fputc('\n',stdout);
213 *metadata=DestroyString(*metadata);
220 elapsed_time=GetElapsedTime(timer);
221 user_time=GetUserTime(timer);
222 (void) fprintf(stderr,
223 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
224 iterations,1.0*iterations/elapsed_time,user_time,(double)
225 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
226 (1000.0*(elapsed_time-floor(elapsed_time))));
227 (void) fflush(stderr);
229 timer=DestroyTimerInfo(timer);
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 + M o g r i f y I m a g e %
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 % MogrifyImage() applies image processing options to an image as prescribed
245 % by command line options.
247 % The format of the MogrifyImage method is:
249 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
250 % const char **argv,Image **image)
252 % A description of each parameter follows:
254 % o image_info: the image info..
256 % o argc: Specifies a pointer to an integer describing the number of
257 % elements in the argument vector.
259 % o argv: Specifies a pointer to a text array containing the command line
262 % o image: the image.
264 % o exception: return any errors or warnings in this structure.
268 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
269 ExceptionInfo *exception)
283 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
284 sans_exception=AcquireExceptionInfo();
285 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
286 sans_exception=DestroyExceptionInfo(sans_exception);
287 if (image != (Image *) NULL)
289 read_info=CloneImageInfo(image_info);
290 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
291 image=ReadImage(read_info,exception);
292 read_info=DestroyImageInfo(read_info);
293 if (image != (Image *) NULL)
294 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
298 static MagickBooleanType IsPathWritable(const char *path)
300 if (IsPathAccessible(path) == MagickFalse)
302 if (access(path,W_OK) != 0)
307 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
314 static MagickBooleanType MonitorProgress(const char *text,
315 const MagickOffsetType offset,const MagickSizeType extent,
316 void *wand_unused(client_data))
319 message[MaxTextExtent],
330 (void) CopyMagickMemory(tag,text,MaxTextExtent);
332 if (p != (char *) NULL)
334 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
335 locale_message=GetLocaleMessage(message);
336 if (locale_message == message)
338 if (p == (char *) NULL)
339 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
340 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
342 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
343 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
344 (100L*offset/(extent-1)));
345 if (offset == (MagickOffsetType) (extent-1))
346 (void) fprintf(stderr,"\n");
347 (void) fflush(stderr);
351 static Image *SparseColorOption(const Image *image,const ChannelType channel,
352 const SparseColorMethod method,const char *arguments,
353 const MagickBooleanType color_from_image,ExceptionInfo *exception)
359 token[MaxTextExtent];
385 assert(image != (Image *) NULL);
386 assert(image->signature == MagickSignature);
387 if (image->debug != MagickFalse)
388 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
389 assert(exception != (ExceptionInfo *) NULL);
390 assert(exception->signature == MagickSignature);
392 Limit channels according to image - and add up number of color channel.
395 if (image->colorspace != CMYKColorspace)
396 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
397 if (image->matte == MagickFalse)
398 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
400 if ((channels & RedChannel) != 0)
402 if ((channels & GreenChannel) != 0)
404 if ((channels & BlueChannel) != 0)
406 if ((channels & IndexChannel) != 0)
408 if ((channels & OpacityChannel) != 0)
411 Read string, to determine number of arguments needed,
417 GetMagickToken(p,&p,token);
418 if ( token[0] == ',' ) continue;
419 if ( isalpha((int) token[0]) || token[0] == '#' ) {
420 if ( color_from_image ) {
421 (void) ThrowMagickException(exception,GetMagickModule(),
422 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
423 "Color arg given, when colors are coming from image");
424 return( (Image *)NULL);
426 x += number_colors; /* color argument */
429 x++; /* floating point argument */
433 if ( color_from_image ) {
434 /* just the control points are being given */
435 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
436 number_arguments=(x/2)*(2+number_colors);
439 /* control points and color values */
440 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
444 (void) ThrowMagickException(exception,GetMagickModule(),
445 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
446 "Invalid number of Arguments");
447 return( (Image *)NULL);
450 /* Allocate and fill in the floating point arguments */
451 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
452 sizeof(*sparse_arguments));
453 if (sparse_arguments == (double *) NULL) {
454 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
455 "MemoryAllocationFailed","%s","SparseColorOption");
456 return( (Image *)NULL);
458 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
459 sizeof(*sparse_arguments));
462 while( *p != '\0' && x < number_arguments ) {
464 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
465 if ( token[0] == '\0' ) break;
466 if ( isalpha((int) token[0]) || token[0] == '#' ) {
467 (void) ThrowMagickException(exception,GetMagickModule(),
468 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
469 "Color found, instead of X-coord");
473 sparse_arguments[x++]=StringToDouble(token);
475 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
476 if ( token[0] == '\0' ) break;
477 if ( isalpha((int) token[0]) || token[0] == '#' ) {
478 (void) ThrowMagickException(exception,GetMagickModule(),
479 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
480 "Color found, instead of Y-coord");
484 sparse_arguments[x++]=StringToDouble(token);
485 /* color values for this control point */
487 if ( (color_from_image ) {
488 /* get color from image */
494 /* color name or function given in string argument */
495 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
496 if ( token[0] == '\0' ) break;
497 if ( isalpha((int) token[0]) || token[0] == '#' ) {
498 /* Color string given */
499 (void) QueryMagickColor(token,&color,exception);
500 if ( channels & RedChannel )
501 sparse_arguments[x++] = QuantumScale*color.red;
502 if ( channels & GreenChannel )
503 sparse_arguments[x++] = QuantumScale*color.green;
504 if ( channels & BlueChannel )
505 sparse_arguments[x++] = QuantumScale*color.blue;
506 if ( channels & IndexChannel )
507 sparse_arguments[x++] = QuantumScale*color.index;
508 if ( channels & OpacityChannel )
509 sparse_arguments[x++] = QuantumScale*color.opacity;
513 /* the color name/function/value was not found - error */
516 /* Colors given as a set of floating point values - experimental */
517 /* NB: token contains the first floating point value to use! */
518 if ( channels & RedChannel ) {
519 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
520 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
522 sparse_arguments[x++]=StringToDouble(token);
523 token[0] = ','; /* used this token - get another */
525 if ( channels & GreenChannel ) {
526 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
527 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
529 sparse_arguments[x++]=StringToDouble(token);
530 token[0] = ','; /* used this token - get another */
532 if ( channels & BlueChannel ) {
533 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
534 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
536 sparse_arguments[x++]=StringToDouble(token);
537 token[0] = ','; /* used this token - get another */
539 if ( channels & IndexChannel ) {
540 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
541 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
543 sparse_arguments[x++]=StringToDouble(token);
544 token[0] = ','; /* used this token - get another */
546 if ( channels & OpacityChannel ) {
547 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
548 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
550 sparse_arguments[x++]=StringToDouble(token);
551 token[0] = ','; /* used this token - get another */
557 if ( number_arguments != x && !error ) {
558 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
559 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
560 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
561 return( (Image *)NULL);
564 return( (Image *)NULL);
566 /* Call the Interpolation function with the parsed arguments */
567 sparse_image=SparseColorImage(image,channels,method,number_arguments,
568 sparse_arguments,exception);
569 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
570 return( sparse_image );
573 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
574 const char **argv,Image **image,ExceptionInfo *exception)
618 Initialize method variables.
620 assert(image_info != (const ImageInfo *) NULL);
621 assert(image_info->signature == MagickSignature);
622 assert(image != (Image **) NULL);
623 assert((*image)->signature == MagickSignature);
624 if ((*image)->debug != MagickFalse)
625 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
628 mogrify_info=CloneImageInfo(image_info);
629 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
630 quantize_info=AcquireQuantizeInfo(mogrify_info);
631 SetGeometryInfo(&geometry_info);
632 GetMagickPixelPacket(*image,&fill);
633 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
635 channel=mogrify_info->channel;
636 format=GetImageOption(mogrify_info,"format");
637 SetGeometry(*image,®ion_geometry);
638 region_image=NewImageList();
640 Transmogrify the image.
642 for (i=0; i < (ssize_t) argc; i++)
645 if (IsMagickOption(option) == MagickFalse)
647 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
649 if ((i+count) >= (ssize_t) argc)
651 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
656 if (LocaleCompare("adaptive-blur",option+1) == 0)
664 (void) SyncImageSettings(mogrify_info,*image);
665 flags=ParseGeometry(argv[i+1],&geometry_info);
666 if ((flags & SigmaValue) == 0)
667 geometry_info.sigma=1.0;
668 blur_image=AdaptiveBlurImageChannel(*image,channel,
669 geometry_info.rho,geometry_info.sigma,exception);
670 if (blur_image == (Image *) NULL)
672 *image=DestroyImage(*image);
676 if (LocaleCompare("adaptive-resize",option+1) == 0)
682 Adaptive resize image.
684 (void) SyncImageSettings(mogrify_info,*image);
685 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
686 resize_image=AdaptiveResizeImage(*image,geometry.width,
687 geometry.height,exception);
688 if (resize_image == (Image *) NULL)
690 *image=DestroyImage(*image);
694 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
700 Adaptive sharpen image.
702 (void) SyncImageSettings(mogrify_info,*image);
703 flags=ParseGeometry(argv[i+1],&geometry_info);
704 if ((flags & SigmaValue) == 0)
705 geometry_info.sigma=1.0;
706 sharp_image=AdaptiveSharpenImageChannel(*image,channel,
707 geometry_info.rho,geometry_info.sigma,exception);
708 if (sharp_image == (Image *) NULL)
710 *image=DestroyImage(*image);
714 if (LocaleCompare("affine",option+1) == 0)
721 GetAffineMatrix(&draw_info->affine);
724 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
727 if (LocaleCompare("alpha",option+1) == 0)
732 (void) SyncImageSettings(mogrify_info,*image);
733 alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
734 MagickFalse,argv[i+1]);
735 (void) SetImageAlphaChannel(*image,alpha_type);
736 InheritException(exception,&(*image)->exception);
739 if (LocaleCompare("annotate",option+1) == 0)
743 geometry[MaxTextExtent];
748 (void) SyncImageSettings(mogrify_info,*image);
749 SetGeometryInfo(&geometry_info);
750 flags=ParseGeometry(argv[i+1],&geometry_info);
751 if ((flags & SigmaValue) == 0)
752 geometry_info.sigma=geometry_info.rho;
753 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
754 InheritException(exception,&(*image)->exception);
755 if (text == (char *) NULL)
757 (void) CloneString(&draw_info->text,text);
758 text=DestroyString(text);
759 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
760 geometry_info.xi,geometry_info.psi);
761 (void) CloneString(&draw_info->geometry,geometry);
762 draw_info->affine.sx=cos(DegreesToRadians(
763 fmod(geometry_info.rho,360.0)));
764 draw_info->affine.rx=sin(DegreesToRadians(
765 fmod(geometry_info.rho,360.0)));
766 draw_info->affine.ry=(-sin(DegreesToRadians(
767 fmod(geometry_info.sigma,360.0))));
768 draw_info->affine.sy=cos(DegreesToRadians(
769 fmod(geometry_info.sigma,360.0)));
770 (void) AnnotateImage(*image,draw_info);
771 InheritException(exception,&(*image)->exception);
774 if (LocaleCompare("antialias",option+1) == 0)
776 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
778 draw_info->text_antialias=(*option == '-') ? MagickTrue :
782 if (LocaleCompare("auto-gamma",option+1) == 0)
785 Auto Adjust Gamma of image based on its mean
787 (void) SyncImageSettings(mogrify_info,*image);
788 (void) AutoGammaImageChannel(*image,channel);
791 if (LocaleCompare("auto-level",option+1) == 0)
794 Perfectly Normalize (max/min stretch) the image
796 (void) SyncImageSettings(mogrify_info,*image);
797 (void) AutoLevelImageChannel(*image,channel);
800 if (LocaleCompare("auto-orient",option+1) == 0)
805 (void) SyncImageSettings(mogrify_info,*image);
806 orient_image=NewImageList();
807 switch ((*image)->orientation)
809 case TopRightOrientation:
811 orient_image=FlopImage(*image,exception);
814 case BottomRightOrientation:
816 orient_image=RotateImage(*image,180.0,exception);
819 case BottomLeftOrientation:
821 orient_image=FlipImage(*image,exception);
824 case LeftTopOrientation:
826 orient_image=TransposeImage(*image,exception);
829 case RightTopOrientation:
831 orient_image=RotateImage(*image,90.0,exception);
834 case RightBottomOrientation:
836 orient_image=TransverseImage(*image,exception);
839 case LeftBottomOrientation:
841 orient_image=RotateImage(*image,270.0,exception);
847 if (orient_image == (Image *) NULL)
849 orient_image->orientation=TopLeftOrientation;
850 *image=DestroyImage(*image);
858 if (LocaleCompare("black-threshold",option+1) == 0)
861 Black threshold image.
863 (void) SyncImageSettings(mogrify_info,*image);
864 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
866 InheritException(exception,&(*image)->exception);
869 if (LocaleCompare("blue-shift",option+1) == 0)
877 (void) SyncImageSettings(mogrify_info,*image);
878 geometry_info.rho=1.5;
880 flags=ParseGeometry(argv[i+1],&geometry_info);
881 shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
882 if (shift_image == (Image *) NULL)
884 *image=DestroyImage(*image);
888 if (LocaleCompare("blur",option+1) == 0)
896 (void) SyncImageSettings(mogrify_info,*image);
897 flags=ParseGeometry(argv[i+1],&geometry_info);
898 if ((flags & SigmaValue) == 0)
899 geometry_info.sigma=1.0;
900 blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
901 geometry_info.sigma,exception);
902 if (blur_image == (Image *) NULL)
904 *image=DestroyImage(*image);
908 if (LocaleCompare("border",option+1) == 0)
914 Surround image with a border of solid color.
916 (void) SyncImageSettings(mogrify_info,*image);
917 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
918 if ((flags & SigmaValue) == 0)
919 geometry.height=geometry.width;
920 border_image=BorderImage(*image,&geometry,exception);
921 if (border_image == (Image *) NULL)
923 *image=DestroyImage(*image);
927 if (LocaleCompare("bordercolor",option+1) == 0)
931 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
935 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
939 if (LocaleCompare("box",option+1) == 0)
941 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
945 if (LocaleCompare("brightness-contrast",option+1) == 0)
958 Brightness / contrast image.
960 (void) SyncImageSettings(mogrify_info,*image);
961 flags=ParseGeometry(argv[i+1],&geometry_info);
962 brightness=geometry_info.rho;
964 if ((flags & SigmaValue) != 0)
965 contrast=geometry_info.sigma;
966 (void) BrightnessContrastImageChannel(*image,channel,brightness,
968 InheritException(exception,&(*image)->exception);
975 if (LocaleCompare("cdl",option+1) == 0)
978 *color_correction_collection;
981 Color correct with a color decision list.
983 (void) SyncImageSettings(mogrify_info,*image);
984 color_correction_collection=FileToString(argv[i+1],~0,exception);
985 if (color_correction_collection == (char *) NULL)
987 (void) ColorDecisionListImage(*image,color_correction_collection);
988 InheritException(exception,&(*image)->exception);
991 if (LocaleCompare("channel",option+1) == 0)
995 channel=DefaultChannels;
998 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1001 if (LocaleCompare("charcoal",option+1) == 0)
1009 (void) SyncImageSettings(mogrify_info,*image);
1010 flags=ParseGeometry(argv[i+1],&geometry_info);
1011 if ((flags & SigmaValue) == 0)
1012 geometry_info.sigma=1.0;
1013 charcoal_image=CharcoalImage(*image,geometry_info.rho,
1014 geometry_info.sigma,exception);
1015 if (charcoal_image == (Image *) NULL)
1017 *image=DestroyImage(*image);
1018 *image=charcoal_image;
1021 if (LocaleCompare("chop",option+1) == 0)
1029 (void) SyncImageSettings(mogrify_info,*image);
1030 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1031 chop_image=ChopImage(*image,&geometry,exception);
1032 if (chop_image == (Image *) NULL)
1034 *image=DestroyImage(*image);
1038 if (LocaleCompare("clamp",option+1) == 0)
1043 (void) SyncImageSettings(mogrify_info,*image);
1044 (void) ClampImageChannel(*image,channel);
1045 InheritException(exception,&(*image)->exception);
1048 if (LocaleCompare("clip",option+1) == 0)
1050 (void) SyncImageSettings(mogrify_info,*image);
1053 (void) SetImageClipMask(*image,(Image *) NULL);
1054 InheritException(exception,&(*image)->exception);
1057 (void) ClipImage(*image);
1058 InheritException(exception,&(*image)->exception);
1061 if (LocaleCompare("clip-mask",option+1) == 0)
1072 register PixelPacket
1075 (void) SyncImageSettings(mogrify_info,*image);
1081 (void) SetImageMask(*image,(Image *) NULL);
1082 InheritException(exception,&(*image)->exception);
1088 mask=GetImageCache(mogrify_info,argv[i+1],exception);
1089 if (mask == (Image *) NULL)
1091 for (y=0; y < (ssize_t) mask->rows; y++)
1093 q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception);
1094 if (q == (PixelPacket *) NULL)
1096 for (x=0; x < (ssize_t) mask->columns; x++)
1098 if (mask->matte == MagickFalse)
1099 q->opacity=PixelIntensityToQuantum(q);
1101 q->green=q->opacity;
1105 if (SyncAuthenticPixels(mask,exception) == MagickFalse)
1108 if (SetImageStorageClass(mask,DirectClass) == MagickFalse)
1109 return(MagickFalse);
1110 mask->matte=MagickTrue;
1111 (void) SetImageClipMask(*image,mask);
1112 mask=DestroyImage(mask);
1113 InheritException(exception,&(*image)->exception);
1116 if (LocaleCompare("clip-path",option+1) == 0)
1118 (void) SyncImageSettings(mogrify_info,*image);
1119 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1121 InheritException(exception,&(*image)->exception);
1124 if (LocaleCompare("colorize",option+1) == 0)
1132 (void) SyncImageSettings(mogrify_info,*image);
1133 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1135 if (colorize_image == (Image *) NULL)
1137 *image=DestroyImage(*image);
1138 *image=colorize_image;
1141 if (LocaleCompare("color-matrix",option+1) == 0)
1149 (void) SyncImageSettings(mogrify_info,*image);
1150 kernel=AcquireKernelInfo(argv[i+1]);
1151 if (kernel == (KernelInfo *) NULL)
1153 color_image=ColorMatrixImage(*image,kernel,exception);
1154 kernel=DestroyKernelInfo(kernel);
1155 if (color_image == (Image *) NULL)
1157 *image=DestroyImage(*image);
1161 if (LocaleCompare("colors",option+1) == 0)
1164 Reduce the number of colors in the image.
1166 (void) SyncImageSettings(mogrify_info,*image);
1167 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1168 if (quantize_info->number_colors == 0)
1170 if (((*image)->storage_class == DirectClass) ||
1171 (*image)->colors > quantize_info->number_colors)
1172 (void) QuantizeImage(quantize_info,*image);
1174 (void) CompressImageColormap(*image);
1175 InheritException(exception,&(*image)->exception);
1178 if (LocaleCompare("colorspace",option+1) == 0)
1183 (void) SyncImageSettings(mogrify_info,*image);
1186 (void) TransformImageColorspace(*image,RGBColorspace);
1187 InheritException(exception,&(*image)->exception);
1190 colorspace=(ColorspaceType) ParseMagickOption(
1191 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1192 (void) TransformImageColorspace(*image,colorspace);
1193 InheritException(exception,&(*image)->exception);
1196 if (LocaleCompare("contrast",option+1) == 0)
1198 (void) SyncImageSettings(mogrify_info,*image);
1199 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1201 InheritException(exception,&(*image)->exception);
1204 if (LocaleCompare("contrast-stretch",option+1) == 0)
1214 Contrast stretch image.
1216 (void) SyncImageSettings(mogrify_info,*image);
1217 flags=ParseGeometry(argv[i+1],&geometry_info);
1218 black_point=geometry_info.rho;
1219 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1221 if ((flags & PercentValue) != 0)
1223 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1224 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1226 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1228 (void) ContrastStretchImageChannel(*image,channel,black_point,
1230 InheritException(exception,&(*image)->exception);
1233 if (LocaleCompare("convolve",option+1) == 0)
1247 (void) SyncImageSettings(mogrify_info,*image);
1248 kernel=AcquireKernelInfo(argv[i+1]);
1249 if (kernel == (KernelInfo *) NULL)
1252 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1253 gamma+=kernel->values[j];
1254 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1255 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1256 kernel->values[j]*=gamma;
1257 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
1258 kernel=DestroyKernelInfo(kernel);
1259 if (convolve_image == (Image *) NULL)
1261 *image=DestroyImage(*image);
1262 *image=convolve_image;
1265 if (LocaleCompare("crop",option+1) == 0)
1267 (void) SyncImageSettings(mogrify_info,*image);
1268 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1269 if (((geometry.width != 0) || (geometry.height != 0)) &&
1270 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1272 (void) TransformImage(image,argv[i+1],(char *) NULL);
1273 InheritException(exception,&(*image)->exception);
1276 if (LocaleCompare("cycle",option+1) == 0)
1279 Cycle an image colormap.
1281 (void) SyncImageSettings(mogrify_info,*image);
1282 (void) CycleColormapImage(*image,StringToLong(argv[i+1]));
1283 InheritException(exception,&(*image)->exception);
1290 if (LocaleCompare("decipher",option+1) == 0)
1298 (void) SyncImageSettings(mogrify_info,*image);
1299 passkey=FileToStringInfo(argv[i+1],~0,exception);
1300 if (passkey != (StringInfo *) NULL)
1302 (void) PasskeyDecipherImage(*image,passkey,exception);
1303 passkey=DestroyStringInfo(passkey);
1307 if (LocaleCompare("density",option+1) == 0)
1312 (void) CloneString(&draw_info->density,argv[i+1]);
1315 if (LocaleCompare("depth",option+1) == 0)
1317 (void) SyncImageSettings(mogrify_info,*image);
1320 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1323 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1326 if (LocaleCompare("deskew",option+1) == 0)
1335 Straighten the image.
1337 (void) SyncImageSettings(mogrify_info,*image);
1339 threshold=40.0*QuantumRange/100.0;
1341 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1342 deskew_image=DeskewImage(*image,threshold,exception);
1343 if (deskew_image == (Image *) NULL)
1345 *image=DestroyImage(*image);
1346 *image=deskew_image;
1349 if (LocaleCompare("despeckle",option+1) == 0)
1355 Reduce the speckles within an image.
1357 (void) SyncImageSettings(mogrify_info,*image);
1358 despeckle_image=DespeckleImage(*image,exception);
1359 if (despeckle_image == (Image *) NULL)
1361 *image=DestroyImage(*image);
1362 *image=despeckle_image;
1365 if (LocaleCompare("display",option+1) == 0)
1367 (void) CloneString(&draw_info->server_name,argv[i+1]);
1370 if (LocaleCompare("distort",option+1) == 0)
1374 token[MaxTextExtent];
1397 (void) SyncImageSettings(mogrify_info,*image);
1398 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1399 MagickFalse,argv[i+1]);
1400 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1401 InheritException(exception,&(*image)->exception);
1402 if (args == (char *) NULL)
1405 for (x=0; *p != '\0'; x++)
1407 GetMagickToken(p,&p,token);
1409 GetMagickToken(p,&p,token);
1411 number_arguments=(size_t) x;
1412 arguments=(double *) AcquireQuantumMemory(number_arguments,
1413 sizeof(*arguments));
1414 if (arguments == (double *) NULL)
1415 ThrowWandFatalException(ResourceLimitFatalError,
1416 "MemoryAllocationFailed",(*image)->filename);
1417 (void) ResetMagickMemory(arguments,0,number_arguments*
1418 sizeof(*arguments));
1420 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1422 GetMagickToken(p,&p,token);
1424 GetMagickToken(p,&p,token);
1425 arguments[x]=StringToDouble(token);
1427 args=DestroyString(args);
1428 distort_image=DistortImage(*image,method,number_arguments,arguments,
1429 (*option == '+') ? MagickTrue : MagickFalse,exception);
1430 arguments=(double *) RelinquishMagickMemory(arguments);
1431 if (distort_image == (Image *) NULL)
1433 *image=DestroyImage(*image);
1434 *image=distort_image;
1437 if (LocaleCompare("dither",option+1) == 0)
1441 quantize_info->dither=MagickFalse;
1444 quantize_info->dither=MagickTrue;
1445 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
1446 MagickDitherOptions,MagickFalse,argv[i+1]);
1447 if (quantize_info->dither_method == NoDitherMethod)
1448 quantize_info->dither=MagickFalse;
1451 if (LocaleCompare("draw",option+1) == 0)
1456 (void) SyncImageSettings(mogrify_info,*image);
1457 (void) CloneString(&draw_info->primitive,argv[i+1]);
1458 (void) DrawImage(*image,draw_info);
1459 InheritException(exception,&(*image)->exception);
1466 if (LocaleCompare("edge",option+1) == 0)
1472 Enhance edges in the image.
1474 (void) SyncImageSettings(mogrify_info,*image);
1475 flags=ParseGeometry(argv[i+1],&geometry_info);
1476 if ((flags & SigmaValue) == 0)
1477 geometry_info.sigma=1.0;
1478 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1479 if (edge_image == (Image *) NULL)
1481 *image=DestroyImage(*image);
1485 if (LocaleCompare("emboss",option+1) == 0)
1491 Gaussian embossen image.
1493 (void) SyncImageSettings(mogrify_info,*image);
1494 flags=ParseGeometry(argv[i+1],&geometry_info);
1495 if ((flags & SigmaValue) == 0)
1496 geometry_info.sigma=1.0;
1497 emboss_image=EmbossImage(*image,geometry_info.rho,
1498 geometry_info.sigma,exception);
1499 if (emboss_image == (Image *) NULL)
1501 *image=DestroyImage(*image);
1502 *image=emboss_image;
1505 if (LocaleCompare("encipher",option+1) == 0)
1513 (void) SyncImageSettings(mogrify_info,*image);
1514 passkey=FileToStringInfo(argv[i+1],~0,exception);
1515 if (passkey != (StringInfo *) NULL)
1517 (void) PasskeyEncipherImage(*image,passkey,exception);
1518 passkey=DestroyStringInfo(passkey);
1522 if (LocaleCompare("encoding",option+1) == 0)
1524 (void) CloneString(&draw_info->encoding,argv[i+1]);
1527 if (LocaleCompare("enhance",option+1) == 0)
1535 (void) SyncImageSettings(mogrify_info,*image);
1536 enhance_image=EnhanceImage(*image,exception);
1537 if (enhance_image == (Image *) NULL)
1539 *image=DestroyImage(*image);
1540 *image=enhance_image;
1543 if (LocaleCompare("equalize",option+1) == 0)
1548 (void) SyncImageSettings(mogrify_info,*image);
1549 (void) EqualizeImageChannel(*image,channel);
1550 InheritException(exception,&(*image)->exception);
1553 if (LocaleCompare("evaluate",option+1) == 0)
1558 MagickEvaluateOperator
1561 (void) SyncImageSettings(mogrify_info,*image);
1562 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1563 MagickFalse,argv[i+1]);
1564 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1565 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1568 if (LocaleCompare("extent",option+1) == 0)
1574 Set the image extent.
1576 (void) SyncImageSettings(mogrify_info,*image);
1577 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1578 if (geometry.width == 0)
1579 geometry.width=(*image)->columns;
1580 if (geometry.height == 0)
1581 geometry.height=(*image)->rows;
1582 geometry.x=(-geometry.x);
1583 geometry.y=(-geometry.y);
1584 extent_image=ExtentImage(*image,&geometry,exception);
1585 if (extent_image == (Image *) NULL)
1587 *image=DestroyImage(*image);
1588 *image=extent_image;
1595 if (LocaleCompare("family",option+1) == 0)
1599 if (draw_info->family != (char *) NULL)
1600 draw_info->family=DestroyString(draw_info->family);
1603 (void) CloneString(&draw_info->family,argv[i+1]);
1606 if (LocaleCompare("features",option+1) == 0)
1610 (void) DeleteImageArtifact(*image,"identify:features");
1613 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1616 if (LocaleCompare("fill",option+1) == 0)
1621 GetMagickPixelPacket(*image,&fill);
1624 (void) QueryMagickColor("none",&fill,exception);
1625 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1626 if (draw_info->fill_pattern != (Image *) NULL)
1627 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1630 sans=AcquireExceptionInfo();
1631 (void) QueryMagickColor(argv[i+1],&fill,sans);
1632 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1633 sans=DestroyExceptionInfo(sans);
1634 if (status == MagickFalse)
1635 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1639 if (LocaleCompare("flip",option+1) == 0)
1645 Flip image scanlines.
1647 (void) SyncImageSettings(mogrify_info,*image);
1648 flip_image=FlipImage(*image,exception);
1649 if (flip_image == (Image *) NULL)
1651 *image=DestroyImage(*image);
1655 if (LocaleCompare("flop",option+1) == 0)
1661 Flop image scanlines.
1663 (void) SyncImageSettings(mogrify_info,*image);
1664 flop_image=FlopImage(*image,exception);
1665 if (flop_image == (Image *) NULL)
1667 *image=DestroyImage(*image);
1671 if (LocaleCompare("floodfill",option+1) == 0)
1679 (void) SyncImageSettings(mogrify_info,*image);
1680 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1681 (void) QueryMagickColor(argv[i+2],&target,exception);
1682 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1683 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1684 InheritException(exception,&(*image)->exception);
1687 if (LocaleCompare("font",option+1) == 0)
1691 if (draw_info->font != (char *) NULL)
1692 draw_info->font=DestroyString(draw_info->font);
1695 (void) CloneString(&draw_info->font,argv[i+1]);
1698 if (LocaleCompare("format",option+1) == 0)
1703 if (LocaleCompare("frame",option+1) == 0)
1712 Surround image with an ornamental border.
1714 (void) SyncImageSettings(mogrify_info,*image);
1715 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1716 frame_info.width=geometry.width;
1717 frame_info.height=geometry.height;
1718 if ((flags & HeightValue) == 0)
1719 frame_info.height=geometry.width;
1720 frame_info.outer_bevel=geometry.x;
1721 frame_info.inner_bevel=geometry.y;
1722 frame_info.x=(ssize_t) frame_info.width;
1723 frame_info.y=(ssize_t) frame_info.height;
1724 frame_info.width=(*image)->columns+2*frame_info.width;
1725 frame_info.height=(*image)->rows+2*frame_info.height;
1726 frame_image=FrameImage(*image,&frame_info,exception);
1727 if (frame_image == (Image *) NULL)
1729 *image=DestroyImage(*image);
1733 if (LocaleCompare("function",option+1) == 0)
1737 token[MaxTextExtent];
1755 Function Modify Image Values
1757 (void) SyncImageSettings(mogrify_info,*image);
1758 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1759 MagickFalse,argv[i+1]);
1760 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1761 InheritException(exception,&(*image)->exception);
1762 if (arguments == (char *) NULL)
1764 p=(char *) arguments;
1765 for (x=0; *p != '\0'; x++)
1767 GetMagickToken(p,&p,token);
1769 GetMagickToken(p,&p,token);
1771 number_parameters=(size_t) x;
1772 parameters=(double *) AcquireQuantumMemory(number_parameters,
1773 sizeof(*parameters));
1774 if (parameters == (double *) NULL)
1775 ThrowWandFatalException(ResourceLimitFatalError,
1776 "MemoryAllocationFailed",(*image)->filename);
1777 (void) ResetMagickMemory(parameters,0,number_parameters*
1778 sizeof(*parameters));
1779 p=(char *) arguments;
1780 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1782 GetMagickToken(p,&p,token);
1784 GetMagickToken(p,&p,token);
1785 parameters[x]=StringToDouble(token);
1787 arguments=DestroyString(arguments);
1788 (void) FunctionImageChannel(*image,channel,function,
1789 number_parameters,parameters,exception);
1790 parameters=(double *) RelinquishMagickMemory(parameters);
1797 if (LocaleCompare("gamma",option+1) == 0)
1802 (void) SyncImageSettings(mogrify_info,*image);
1804 (*image)->gamma=StringToDouble(argv[i+1]);
1807 if (strchr(argv[i+1],',') != (char *) NULL)
1808 (void) GammaImage(*image,argv[i+1]);
1810 (void) GammaImageChannel(*image,channel,
1811 StringToDouble(argv[i+1]));
1812 InheritException(exception,&(*image)->exception);
1816 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1817 (LocaleCompare("gaussian",option+1) == 0))
1823 Gaussian blur image.
1825 (void) SyncImageSettings(mogrify_info,*image);
1826 flags=ParseGeometry(argv[i+1],&geometry_info);
1827 if ((flags & SigmaValue) == 0)
1828 geometry_info.sigma=1.0;
1829 gaussian_image=GaussianBlurImageChannel(*image,channel,
1830 geometry_info.rho,geometry_info.sigma,exception);
1831 if (gaussian_image == (Image *) NULL)
1833 *image=DestroyImage(*image);
1834 *image=gaussian_image;
1837 if (LocaleCompare("geometry",option+1) == 0)
1839 (void) SyncImageSettings(mogrify_info,*image);
1842 if ((*image)->geometry != (char *) NULL)
1843 (*image)->geometry=DestroyString((*image)->geometry);
1846 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1847 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1848 (void) CloneString(&(*image)->geometry,argv[i+1]);
1857 zoom_image=ZoomImage(*image,geometry.width,geometry.height,
1859 if (zoom_image == (Image *) NULL)
1861 *image=DestroyImage(*image);
1866 if (LocaleCompare("gravity",option+1) == 0)
1870 draw_info->gravity=UndefinedGravity;
1873 draw_info->gravity=(GravityType) ParseMagickOption(
1874 MagickGravityOptions,MagickFalse,argv[i+1]);
1881 if (LocaleCompare("highlight-color",option+1) == 0)
1883 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1890 if (LocaleCompare("identify",option+1) == 0)
1895 (void) SyncImageSettings(mogrify_info,*image);
1896 if (format == (char *) NULL)
1898 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1899 InheritException(exception,&(*image)->exception);
1902 text=InterpretImageProperties(mogrify_info,*image,format);
1903 InheritException(exception,&(*image)->exception);
1904 if (text == (char *) NULL)
1906 (void) fputs(text,stdout);
1907 (void) fputc('\n',stdout);
1908 text=DestroyString(text);
1911 if (LocaleCompare("implode",option+1) == 0)
1919 (void) SyncImageSettings(mogrify_info,*image);
1920 (void) ParseGeometry(argv[i+1],&geometry_info);
1921 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1922 if (implode_image == (Image *) NULL)
1924 *image=DestroyImage(*image);
1925 *image=implode_image;
1928 if (LocaleCompare("interline-spacing",option+1) == 0)
1931 (void) ParseGeometry("0",&geometry_info);
1933 (void) ParseGeometry(argv[i+1],&geometry_info);
1934 draw_info->interline_spacing=geometry_info.rho;
1937 if (LocaleCompare("interword-spacing",option+1) == 0)
1940 (void) ParseGeometry("0",&geometry_info);
1942 (void) ParseGeometry(argv[i+1],&geometry_info);
1943 draw_info->interword_spacing=geometry_info.rho;
1950 if (LocaleCompare("kerning",option+1) == 0)
1953 (void) ParseGeometry("0",&geometry_info);
1955 (void) ParseGeometry(argv[i+1],&geometry_info);
1956 draw_info->kerning=geometry_info.rho;
1963 if (LocaleCompare("lat",option+1) == 0)
1969 Local adaptive threshold image.
1971 (void) SyncImageSettings(mogrify_info,*image);
1972 flags=ParseGeometry(argv[i+1],&geometry_info);
1973 if ((flags & PercentValue) != 0)
1974 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1975 threshold_image=AdaptiveThresholdImage(*image,(size_t)
1976 geometry_info.rho,(size_t) geometry_info.sigma,
1977 (ssize_t) geometry_info.xi,exception);
1978 if (threshold_image == (Image *) NULL)
1980 *image=DestroyImage(*image);
1981 *image=threshold_image;
1984 if (LocaleCompare("level",option+1) == 0)
1997 (void) SyncImageSettings(mogrify_info,*image);
1998 flags=ParseGeometry(argv[i+1],&geometry_info);
1999 black_point=geometry_info.rho;
2000 white_point=(MagickRealType) QuantumRange;
2001 if ((flags & SigmaValue) != 0)
2002 white_point=geometry_info.sigma;
2004 if ((flags & XiValue) != 0)
2005 gamma=geometry_info.xi;
2006 if ((flags & PercentValue) != 0)
2008 black_point*=(MagickRealType) (QuantumRange/100.0);
2009 white_point*=(MagickRealType) (QuantumRange/100.0);
2011 if ((flags & SigmaValue) == 0)
2012 white_point=(MagickRealType) QuantumRange-black_point;
2013 if ((*option == '+') || ((flags & AspectValue) != 0))
2014 (void) LevelizeImageChannel(*image,channel,black_point,
2017 (void) LevelImageChannel(*image,channel,black_point,white_point,
2019 InheritException(exception,&(*image)->exception);
2022 if (LocaleCompare("level-colors",option+1) == 0)
2025 token[MaxTextExtent];
2034 p=(const char *) argv[i+1];
2035 GetMagickToken(p,&p,token); /* get black point color */
2036 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2037 (void) QueryMagickColor(token,&black_point,exception);
2039 (void) QueryMagickColor("#000000",&black_point,exception);
2040 if (isalpha((int) token[0]) || (token[0] == '#'))
2041 GetMagickToken(p,&p,token);
2043 white_point=black_point; /* set everything to that color */
2047 Get white point color.
2049 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2050 GetMagickToken(p,&p,token);
2051 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2052 (void) QueryMagickColor(token,&white_point,exception);
2054 (void) QueryMagickColor("#ffffff",&white_point,exception);
2056 (void) LevelColorsImageChannel(*image,channel,&black_point,
2057 &white_point,*option == '+' ? MagickTrue : MagickFalse);
2060 if (LocaleCompare("linear-stretch",option+1) == 0)
2069 (void) SyncImageSettings(mogrify_info,*image);
2070 flags=ParseGeometry(argv[i+1],&geometry_info);
2071 black_point=geometry_info.rho;
2072 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2073 if ((flags & SigmaValue) != 0)
2074 white_point=geometry_info.sigma;
2075 if ((flags & PercentValue) != 0)
2077 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2078 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2080 if ((flags & SigmaValue) == 0)
2081 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2083 (void) LinearStretchImage(*image,black_point,white_point);
2084 InheritException(exception,&(*image)->exception);
2087 if (LocaleCompare("linewidth",option+1) == 0)
2089 draw_info->stroke_width=StringToDouble(argv[i+1]);
2092 if (LocaleCompare("liquid-rescale",option+1) == 0)
2098 Liquid rescale image.
2100 (void) SyncImageSettings(mogrify_info,*image);
2101 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2102 if ((flags & XValue) == 0)
2104 if ((flags & YValue) == 0)
2106 resize_image=LiquidRescaleImage(*image,geometry.width,
2107 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2108 if (resize_image == (Image *) NULL)
2110 *image=DestroyImage(*image);
2111 *image=resize_image;
2114 if (LocaleCompare("lowlight-color",option+1) == 0)
2116 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2123 if (LocaleCompare("map",option+1) == 0)
2129 Transform image colors to match this set of colors.
2131 (void) SyncImageSettings(mogrify_info,*image);
2134 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2135 if (remap_image == (Image *) NULL)
2137 (void) RemapImage(quantize_info,*image,remap_image);
2138 InheritException(exception,&(*image)->exception);
2139 remap_image=DestroyImage(remap_image);
2142 if (LocaleCompare("mask",option+1) == 0)
2147 (void) SyncImageSettings(mogrify_info,*image);
2153 (void) SetImageMask(*image,(Image *) NULL);
2154 InheritException(exception,&(*image)->exception);
2160 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2161 if (mask == (Image *) NULL)
2163 (void) SetImageMask(*image,mask);
2164 mask=DestroyImage(mask);
2165 InheritException(exception,&(*image)->exception);
2168 if (LocaleCompare("matte",option+1) == 0)
2170 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2171 SetAlphaChannel : DeactivateAlphaChannel );
2172 InheritException(exception,&(*image)->exception);
2175 if (LocaleCompare("median",option+1) == 0)
2181 Median filter image.
2183 (void) SyncImageSettings(mogrify_info,*image);
2184 (void) ParseGeometry(argv[i+1],&geometry_info);
2185 median_image=MedianFilterImage(*image,geometry_info.rho,exception);
2186 if (median_image == (Image *) NULL)
2188 *image=DestroyImage(*image);
2189 *image=median_image;
2192 if (LocaleCompare("modulate",option+1) == 0)
2194 (void) SyncImageSettings(mogrify_info,*image);
2195 (void) ModulateImage(*image,argv[i+1]);
2196 InheritException(exception,&(*image)->exception);
2199 if (LocaleCompare("monitor",option+1) == 0)
2203 (void) SetImageProgressMonitor(*image,
2204 (MagickProgressMonitor) NULL,(void *) NULL);
2207 (void) SetImageProgressMonitor(*image,MonitorProgress,
2211 if (LocaleCompare("monochrome",option+1) == 0)
2213 (void) SyncImageSettings(mogrify_info,*image);
2214 (void) SetImageType(*image,BilevelType);
2215 InheritException(exception,&(*image)->exception);
2218 if (LocaleCompare("morphology",option+1) == 0)
2221 token[MaxTextExtent];
2239 Morphological Image Operation
2241 (void) SyncImageSettings(mogrify_info,*image);
2243 GetMagickToken(p,&p,token);
2244 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
2247 GetMagickToken(p,&p,token);
2248 if ((*p == ':') || (*p == ','))
2249 GetMagickToken(p,&p,token);
2251 iterations=StringToLong(p);
2252 kernel=AcquireKernelInfo(argv[i+2]);
2253 if (kernel == (KernelInfo *) NULL)
2255 (void) ThrowMagickException(exception,GetMagickModule(),
2256 OptionError,"UnabletoParseKernel","morphology");
2260 morphology_image=MorphologyImageChannel(*image,channel,method,
2261 iterations,kernel,exception);
2262 kernel=DestroyKernelInfo(kernel);
2263 if (morphology_image == (Image *) NULL)
2265 *image=DestroyImage(*image);
2266 *image=morphology_image;
2269 if (LocaleCompare("motion-blur",option+1) == 0)
2277 (void) SyncImageSettings(mogrify_info,*image);
2278 flags=ParseGeometry(argv[i+1],&geometry_info);
2279 if ((flags & SigmaValue) == 0)
2280 geometry_info.sigma=1.0;
2281 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2282 geometry_info.sigma,geometry_info.xi,exception);
2283 if (blur_image == (Image *) NULL)
2285 *image=DestroyImage(*image);
2293 if (LocaleCompare("negate",option+1) == 0)
2295 (void) SyncImageSettings(mogrify_info,*image);
2296 (void) NegateImageChannel(*image,channel,*option == '+' ?
2297 MagickTrue : MagickFalse);
2298 InheritException(exception,&(*image)->exception);
2301 if (LocaleCompare("noise",option+1) == 0)
2306 (void) SyncImageSettings(mogrify_info,*image);
2309 (void) ParseGeometry(argv[i+1],&geometry_info);
2310 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
2318 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2319 MagickFalse,argv[i+1]);
2320 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2323 if (noisy_image == (Image *) NULL)
2325 *image=DestroyImage(*image);
2329 if (LocaleCompare("normalize",option+1) == 0)
2331 (void) SyncImageSettings(mogrify_info,*image);
2332 (void) NormalizeImageChannel(*image,channel);
2333 InheritException(exception,&(*image)->exception);
2340 if (LocaleCompare("opaque",option+1) == 0)
2345 (void) SyncImageSettings(mogrify_info,*image);
2346 (void) QueryMagickColor(argv[i+1],&target,exception);
2347 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2348 *option == '-' ? MagickFalse : MagickTrue);
2351 if (LocaleCompare("ordered-dither",option+1) == 0)
2353 (void) SyncImageSettings(mogrify_info,*image);
2354 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2362 if (LocaleCompare("paint",option+1) == 0)
2370 (void) SyncImageSettings(mogrify_info,*image);
2371 (void) ParseGeometry(argv[i+1],&geometry_info);
2372 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2373 if (paint_image == (Image *) NULL)
2375 *image=DestroyImage(*image);
2379 if (LocaleCompare("pen",option+1) == 0)
2383 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2386 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2389 if (LocaleCompare("pointsize",option+1) == 0)
2392 (void) ParseGeometry("12",&geometry_info);
2394 (void) ParseGeometry(argv[i+1],&geometry_info);
2395 draw_info->pointsize=geometry_info.rho;
2398 if (LocaleCompare("polaroid",option+1) == 0)
2410 Simulate a Polaroid picture.
2412 (void) SyncImageSettings(mogrify_info,*image);
2413 random_info=AcquireRandomInfo();
2414 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2415 random_info=DestroyRandomInfo(random_info);
2418 SetGeometryInfo(&geometry_info);
2419 flags=ParseGeometry(argv[i+1],&geometry_info);
2420 angle=geometry_info.rho;
2422 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2423 if (polaroid_image == (Image *) NULL)
2425 *image=DestroyImage(*image);
2426 *image=polaroid_image;
2429 if (LocaleCompare("posterize",option+1) == 0)
2434 (void) SyncImageSettings(mogrify_info,*image);
2435 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2436 quantize_info->dither);
2437 InheritException(exception,&(*image)->exception);
2440 if (LocaleCompare("preview",option+1) == 0)
2451 (void) SyncImageSettings(mogrify_info,*image);
2453 preview_type=UndefinedPreview;
2455 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2456 MagickFalse,argv[i+1]);
2457 preview_image=PreviewImage(*image,preview_type,exception);
2458 if (preview_image == (Image *) NULL)
2460 *image=DestroyImage(*image);
2461 *image=preview_image;
2464 if (LocaleCompare("profile",option+1) == 0)
2478 (void) SyncImageSettings(mogrify_info,*image);
2482 Remove a profile from the image.
2484 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2486 InheritException(exception,&(*image)->exception);
2490 Associate a profile with the image.
2492 profile_info=CloneImageInfo(mogrify_info);
2493 profile=GetImageProfile(*image,"iptc");
2494 if (profile != (StringInfo *) NULL)
2495 profile_info->profile=(void *) CloneStringInfo(profile);
2496 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2497 profile_info=DestroyImageInfo(profile_info);
2498 if (profile_image == (Image *) NULL)
2503 profile_info=CloneImageInfo(mogrify_info);
2504 (void) CopyMagickString(profile_info->filename,argv[i+1],
2506 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2507 if (profile != (StringInfo *) NULL)
2509 (void) ProfileImage(*image,profile_info->magick,
2510 GetStringInfoDatum(profile),(size_t)
2511 GetStringInfoLength(profile),MagickFalse);
2512 profile=DestroyStringInfo(profile);
2514 profile_info=DestroyImageInfo(profile_info);
2517 ResetImageProfileIterator(profile_image);
2518 name=GetNextImageProfile(profile_image);
2519 while (name != (const char *) NULL)
2521 profile=GetImageProfile(profile_image,name);
2522 if (profile != (StringInfo *) NULL)
2523 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2524 (size_t) GetStringInfoLength(profile),MagickFalse);
2525 name=GetNextImageProfile(profile_image);
2527 profile_image=DestroyImage(profile_image);
2534 if (LocaleCompare("quantize",option+1) == 0)
2538 quantize_info->colorspace=UndefinedColorspace;
2541 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2542 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2549 if (LocaleCompare("radial-blur",option+1) == 0)
2557 (void) SyncImageSettings(mogrify_info,*image);
2558 blur_image=RadialBlurImageChannel(*image,channel,
2559 StringToDouble(argv[i+1]),exception);
2560 if (blur_image == (Image *) NULL)
2562 *image=DestroyImage(*image);
2566 if (LocaleCompare("raise",option+1) == 0)
2569 Surround image with a raise of solid color.
2571 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2572 if ((flags & SigmaValue) == 0)
2573 geometry.height=geometry.width;
2574 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2576 InheritException(exception,&(*image)->exception);
2579 if (LocaleCompare("random-threshold",option+1) == 0)
2584 (void) SyncImageSettings(mogrify_info,*image);
2585 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2589 if (LocaleCompare("recolor",option+1) == 0)
2597 (void) SyncImageSettings(mogrify_info,*image);
2598 kernel=AcquireKernelInfo(argv[i+1]);
2599 if (kernel == (KernelInfo *) NULL)
2601 color_image=ColorMatrixImage(*image,kernel,exception);
2602 kernel=DestroyKernelInfo(kernel);
2603 if (color_image == (Image *) NULL)
2605 *image=DestroyImage(*image);
2609 if (LocaleCompare("region",option+1) == 0)
2614 (void) SyncImageSettings(mogrify_info,*image);
2615 if (region_image != (Image *) NULL)
2620 (void) CompositeImage(region_image,(*image)->matte !=
2621 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2622 region_geometry.x,region_geometry.y);
2623 InheritException(exception,®ion_image->exception);
2624 *image=DestroyImage(*image);
2625 *image=region_image;
2629 if (region_image != (Image *) NULL)
2630 region_image=DestroyImage(region_image);
2634 Apply transformations to a selected region of the image.
2636 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2638 crop_image=CropImage(*image,®ion_geometry,exception);
2639 if (crop_image == (Image *) NULL)
2641 region_image=(*image);
2645 if (LocaleCompare("render",option+1) == 0)
2647 (void) SyncImageSettings(mogrify_info,*image);
2648 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2651 if (LocaleCompare("remap",option+1) == 0)
2657 Transform image colors to match this set of colors.
2659 (void) SyncImageSettings(mogrify_info,*image);
2662 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2663 if (remap_image == (Image *) NULL)
2665 (void) RemapImage(quantize_info,*image,remap_image);
2666 InheritException(exception,&(*image)->exception);
2667 remap_image=DestroyImage(remap_image);
2670 if (LocaleCompare("repage",option+1) == 0)
2674 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2677 (void) ResetImagePage(*image,argv[i+1]);
2678 InheritException(exception,&(*image)->exception);
2681 if (LocaleCompare("resample",option+1) == 0)
2689 (void) SyncImageSettings(mogrify_info,*image);
2690 flags=ParseGeometry(argv[i+1],&geometry_info);
2691 if ((flags & SigmaValue) == 0)
2692 geometry_info.sigma=geometry_info.rho;
2693 resample_image=ResampleImage(*image,geometry_info.rho,
2694 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2695 if (resample_image == (Image *) NULL)
2697 *image=DestroyImage(*image);
2698 *image=resample_image;
2701 if (LocaleCompare("resize",option+1) == 0)
2709 (void) SyncImageSettings(mogrify_info,*image);
2710 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2711 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2712 (*image)->filter,(*image)->blur,exception);
2713 if (resize_image == (Image *) NULL)
2715 *image=DestroyImage(*image);
2716 *image=resize_image;
2719 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2721 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2724 if (LocaleCompare("roll",option+1) == 0)
2732 (void) SyncImageSettings(mogrify_info,*image);
2733 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2734 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2735 if (roll_image == (Image *) NULL)
2737 *image=DestroyImage(*image);
2741 if (LocaleCompare("rotate",option+1) == 0)
2750 Check for conditional image rotation.
2752 (void) SyncImageSettings(mogrify_info,*image);
2753 if (strchr(argv[i+1],'>') != (char *) NULL)
2754 if ((*image)->columns <= (*image)->rows)
2756 if (strchr(argv[i+1],'<') != (char *) NULL)
2757 if ((*image)->columns >= (*image)->rows)
2762 geometry=ConstantString(argv[i+1]);
2763 (void) SubstituteString(&geometry,">","");
2764 (void) SubstituteString(&geometry,"<","");
2765 (void) ParseGeometry(geometry,&geometry_info);
2766 geometry=DestroyString(geometry);
2767 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2768 if (rotate_image == (Image *) NULL)
2770 *image=DestroyImage(*image);
2771 *image=rotate_image;
2778 if (LocaleCompare("sample",option+1) == 0)
2784 Sample image with pixel replication.
2786 (void) SyncImageSettings(mogrify_info,*image);
2787 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2788 sample_image=SampleImage(*image,geometry.width,geometry.height,
2790 if (sample_image == (Image *) NULL)
2792 *image=DestroyImage(*image);
2793 *image=sample_image;
2796 if (LocaleCompare("scale",option+1) == 0)
2804 (void) SyncImageSettings(mogrify_info,*image);
2805 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2806 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2808 if (scale_image == (Image *) NULL)
2810 *image=DestroyImage(*image);
2814 if (LocaleCompare("selective-blur",option+1) == 0)
2820 Selectively blur pixels within a contrast threshold.
2822 (void) SyncImageSettings(mogrify_info,*image);
2823 flags=ParseGeometry(argv[i+1],&geometry_info);
2824 if ((flags & PercentValue) != 0)
2825 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2826 blur_image=SelectiveBlurImageChannel(*image,channel,
2827 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2828 if (blur_image == (Image *) NULL)
2830 *image=DestroyImage(*image);
2834 if (LocaleCompare("separate",option+1) == 0)
2840 Break channels into separate images.
2842 (void) SyncImageSettings(mogrify_info,*image);
2843 separate_images=SeparateImages(*image,channel,exception);
2844 if (separate_images == (Image *) NULL)
2846 *image=DestroyImage(*image);
2847 *image=separate_images;
2850 if (LocaleCompare("sepia-tone",option+1) == 0)
2861 (void) SyncImageSettings(mogrify_info,*image);
2862 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2863 sepia_image=SepiaToneImage(*image,threshold,exception);
2864 if (sepia_image == (Image *) NULL)
2866 *image=DestroyImage(*image);
2870 if (LocaleCompare("segment",option+1) == 0)
2875 (void) SyncImageSettings(mogrify_info,*image);
2876 flags=ParseGeometry(argv[i+1],&geometry_info);
2877 if ((flags & SigmaValue) == 0)
2878 geometry_info.sigma=1.0;
2879 (void) SegmentImage(*image,(*image)->colorspace,
2880 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2881 InheritException(exception,&(*image)->exception);
2884 if (LocaleCompare("set",option+1) == 0)
2894 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2895 (void) DeleteImageRegistry(argv[i+1]+9);
2897 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2899 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2900 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2903 (void) DeleteImageProperty(*image,argv[i+1]);
2906 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2907 if (value == (char *) NULL)
2909 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2910 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2913 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2915 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2916 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2919 (void) SetImageProperty(*image,argv[i+1],value);
2920 value=DestroyString(value);
2923 if (LocaleCompare("shade",option+1) == 0)
2931 (void) SyncImageSettings(mogrify_info,*image);
2932 flags=ParseGeometry(argv[i+1],&geometry_info);
2933 if ((flags & SigmaValue) == 0)
2934 geometry_info.sigma=1.0;
2935 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2936 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2937 if (shade_image == (Image *) NULL)
2939 *image=DestroyImage(*image);
2943 if (LocaleCompare("shadow",option+1) == 0)
2951 (void) SyncImageSettings(mogrify_info,*image);
2952 flags=ParseGeometry(argv[i+1],&geometry_info);
2953 if ((flags & SigmaValue) == 0)
2954 geometry_info.sigma=1.0;
2955 if ((flags & XiValue) == 0)
2956 geometry_info.xi=4.0;
2957 if ((flags & PsiValue) == 0)
2958 geometry_info.psi=4.0;
2959 shadow_image=ShadowImage(*image,geometry_info.rho,
2960 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2961 ceil(geometry_info.psi-0.5),exception);
2962 if (shadow_image == (Image *) NULL)
2964 *image=DestroyImage(*image);
2965 *image=shadow_image;
2968 if (LocaleCompare("sharpen",option+1) == 0)
2976 (void) SyncImageSettings(mogrify_info,*image);
2977 flags=ParseGeometry(argv[i+1],&geometry_info);
2978 if ((flags & SigmaValue) == 0)
2979 geometry_info.sigma=1.0;
2980 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2981 geometry_info.sigma,exception);
2982 if (sharp_image == (Image *) NULL)
2984 *image=DestroyImage(*image);
2988 if (LocaleCompare("shave",option+1) == 0)
2994 Shave the image edges.
2996 (void) SyncImageSettings(mogrify_info,*image);
2997 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2998 shave_image=ShaveImage(*image,&geometry,exception);
2999 if (shave_image == (Image *) NULL)
3001 *image=DestroyImage(*image);
3005 if (LocaleCompare("shear",option+1) == 0)
3013 (void) SyncImageSettings(mogrify_info,*image);
3014 flags=ParseGeometry(argv[i+1],&geometry_info);
3015 if ((flags & SigmaValue) == 0)
3016 geometry_info.sigma=geometry_info.rho;
3017 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3019 if (shear_image == (Image *) NULL)
3021 *image=DestroyImage(*image);
3025 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3028 Sigmoidal non-linearity contrast control.
3030 (void) SyncImageSettings(mogrify_info,*image);
3031 flags=ParseGeometry(argv[i+1],&geometry_info);
3032 if ((flags & SigmaValue) == 0)
3033 geometry_info.sigma=(double) QuantumRange/2.0;
3034 if ((flags & PercentValue) != 0)
3035 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3037 (void) SigmoidalContrastImageChannel(*image,channel,
3038 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3039 geometry_info.sigma);
3040 InheritException(exception,&(*image)->exception);
3043 if (LocaleCompare("sketch",option+1) == 0)
3051 (void) SyncImageSettings(mogrify_info,*image);
3052 flags=ParseGeometry(argv[i+1],&geometry_info);
3053 if ((flags & SigmaValue) == 0)
3054 geometry_info.sigma=1.0;
3055 sketch_image=SketchImage(*image,geometry_info.rho,
3056 geometry_info.sigma,geometry_info.xi,exception);
3057 if (sketch_image == (Image *) NULL)
3059 *image=DestroyImage(*image);
3060 *image=sketch_image;
3063 if (LocaleCompare("solarize",option+1) == 0)
3068 (void) SyncImageSettings(mogrify_info,*image);
3069 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3070 (void) SolarizeImage(*image,threshold);
3071 InheritException(exception,&(*image)->exception);
3074 if (LocaleCompare("sparse-color",option+1) == 0)
3086 Sparse Color Interpolated Gradient
3088 (void) SyncImageSettings(mogrify_info,*image);
3089 method=(SparseColorMethod) ParseMagickOption(
3090 MagickSparseColorOptions,MagickFalse,argv[i+1]);
3091 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
3092 InheritException(exception,&(*image)->exception);
3093 if (arguments == (char *) NULL)
3095 sparse_image=SparseColorOption(*image,channel,method,arguments,
3096 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3097 arguments=DestroyString(arguments);
3098 if (sparse_image == (Image *) NULL)
3100 *image=DestroyImage(*image);
3101 *image=sparse_image;
3104 if (LocaleCompare("splice",option+1) == 0)
3110 Splice a solid color into the image.
3112 (void) SyncImageSettings(mogrify_info,*image);
3113 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3114 splice_image=SpliceImage(*image,&geometry,exception);
3115 if (splice_image == (Image *) NULL)
3117 *image=DestroyImage(*image);
3118 *image=splice_image;
3121 if (LocaleCompare("spread",option+1) == 0)
3129 (void) SyncImageSettings(mogrify_info,*image);
3130 (void) ParseGeometry(argv[i+1],&geometry_info);
3131 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3132 if (spread_image == (Image *) NULL)
3134 *image=DestroyImage(*image);
3135 *image=spread_image;
3138 if (LocaleCompare("stretch",option+1) == 0)
3142 draw_info->stretch=UndefinedStretch;
3145 draw_info->stretch=(StretchType) ParseMagickOption(
3146 MagickStretchOptions,MagickFalse,argv[i+1]);
3149 if (LocaleCompare("strip",option+1) == 0)
3152 Strip image of profiles and comments.
3154 (void) SyncImageSettings(mogrify_info,*image);
3155 (void) StripImage(*image);
3156 InheritException(exception,&(*image)->exception);
3159 if (LocaleCompare("stroke",option+1) == 0)
3166 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3167 if (draw_info->stroke_pattern != (Image *) NULL)
3168 draw_info->stroke_pattern=DestroyImage(
3169 draw_info->stroke_pattern);
3172 sans=AcquireExceptionInfo();
3173 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3174 sans=DestroyExceptionInfo(sans);
3175 if (status == MagickFalse)
3176 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3180 if (LocaleCompare("strokewidth",option+1) == 0)
3182 draw_info->stroke_width=StringToDouble(argv[i+1]);
3185 if (LocaleCompare("style",option+1) == 0)
3189 draw_info->style=UndefinedStyle;
3192 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3193 MagickFalse,argv[i+1]);
3196 if (LocaleCompare("swirl",option+1) == 0)
3204 (void) SyncImageSettings(mogrify_info,*image);
3205 (void) ParseGeometry(argv[i+1],&geometry_info);
3206 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3207 if (swirl_image == (Image *) NULL)
3209 *image=DestroyImage(*image);
3217 if (LocaleCompare("threshold",option+1) == 0)
3225 (void) SyncImageSettings(mogrify_info,*image);
3227 threshold=(double) QuantumRange/2.5;
3229 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3230 (void) BilevelImageChannel(*image,channel,threshold);
3231 InheritException(exception,&(*image)->exception);
3234 if (LocaleCompare("thumbnail",option+1) == 0)
3242 (void) SyncImageSettings(mogrify_info,*image);
3243 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3244 thumbnail_image=ThumbnailImage(*image,geometry.width,
3245 geometry.height,exception);
3246 if (thumbnail_image == (Image *) NULL)
3248 *image=DestroyImage(*image);
3249 *image=thumbnail_image;
3252 if (LocaleCompare("tile",option+1) == 0)
3256 if (draw_info->fill_pattern != (Image *) NULL)
3257 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3260 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3264 if (LocaleCompare("tint",option+1) == 0)
3272 (void) SyncImageSettings(mogrify_info,*image);
3273 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3274 if (tint_image == (Image *) NULL)
3276 *image=DestroyImage(*image);
3280 if (LocaleCompare("transform",option+1) == 0)
3286 Affine transform image.
3288 (void) SyncImageSettings(mogrify_info,*image);
3289 transform_image=AffineTransformImage(*image,&draw_info->affine,
3291 if (transform_image == (Image *) NULL)
3293 *image=DestroyImage(*image);
3294 *image=transform_image;
3297 if (LocaleCompare("transparent",option+1) == 0)
3302 (void) SyncImageSettings(mogrify_info,*image);
3303 (void) QueryMagickColor(argv[i+1],&target,exception);
3304 (void) TransparentPaintImage(*image,&target,(Quantum)
3305 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3306 InheritException(exception,&(*image)->exception);
3309 if (LocaleCompare("transpose",option+1) == 0)
3315 Transpose image scanlines.
3317 (void) SyncImageSettings(mogrify_info,*image);
3318 transpose_image=TransposeImage(*image,exception);
3319 if (transpose_image == (Image *) NULL)
3321 *image=DestroyImage(*image);
3322 *image=transpose_image;
3325 if (LocaleCompare("transverse",option+1) == 0)
3331 Transverse image scanlines.
3333 (void) SyncImageSettings(mogrify_info,*image);
3334 transverse_image=TransverseImage(*image,exception);
3335 if (transverse_image == (Image *) NULL)
3337 *image=DestroyImage(*image);
3338 *image=transverse_image;
3341 if (LocaleCompare("treedepth",option+1) == 0)
3343 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3346 if (LocaleCompare("trim",option+1) == 0)
3354 (void) SyncImageSettings(mogrify_info,*image);
3355 trim_image=TrimImage(*image,exception);
3356 if (trim_image == (Image *) NULL)
3358 *image=DestroyImage(*image);
3362 if (LocaleCompare("type",option+1) == 0)
3367 (void) SyncImageSettings(mogrify_info,*image);
3371 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3373 (*image)->type=UndefinedType;
3374 (void) SetImageType(*image,type);
3375 InheritException(exception,&(*image)->exception);
3382 if (LocaleCompare("undercolor",option+1) == 0)
3384 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3388 if (LocaleCompare("unique",option+1) == 0)
3392 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3395 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3396 (void) SetImageArtifact(*image,"identify:verbose","true");
3399 if (LocaleCompare("unique-colors",option+1) == 0)
3405 Unique image colors.
3407 (void) SyncImageSettings(mogrify_info,*image);
3408 unique_image=UniqueImageColors(*image,exception);
3409 if (unique_image == (Image *) NULL)
3411 *image=DestroyImage(*image);
3412 *image=unique_image;
3415 if (LocaleCompare("unsharp",option+1) == 0)
3423 (void) SyncImageSettings(mogrify_info,*image);
3424 flags=ParseGeometry(argv[i+1],&geometry_info);
3425 if ((flags & SigmaValue) == 0)
3426 geometry_info.sigma=1.0;
3427 if ((flags & XiValue) == 0)
3428 geometry_info.xi=1.0;
3429 if ((flags & PsiValue) == 0)
3430 geometry_info.psi=0.05;
3431 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3432 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3433 geometry_info.psi,exception);
3434 if (unsharp_image == (Image *) NULL)
3436 *image=DestroyImage(*image);
3437 *image=unsharp_image;
3444 if (LocaleCompare("verbose",option+1) == 0)
3446 (void) SetImageArtifact(*image,option+1,
3447 *option == '+' ? "false" : "true");
3450 if (LocaleCompare("vignette",option+1) == 0)
3458 (void) SyncImageSettings(mogrify_info,*image);
3459 flags=ParseGeometry(argv[i+1],&geometry_info);
3460 if ((flags & SigmaValue) == 0)
3461 geometry_info.sigma=1.0;
3462 if ((flags & XiValue) == 0)
3463 geometry_info.xi=0.1*(*image)->columns;
3464 if ((flags & PsiValue) == 0)
3465 geometry_info.psi=0.1*(*image)->rows;
3466 vignette_image=VignetteImage(*image,geometry_info.rho,
3467 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3468 ceil(geometry_info.psi-0.5),exception);
3469 if (vignette_image == (Image *) NULL)
3471 *image=DestroyImage(*image);
3472 *image=vignette_image;
3475 if (LocaleCompare("virtual-pixel",option+1) == 0)
3479 (void) SetImageVirtualPixelMethod(*image,
3480 UndefinedVirtualPixelMethod);
3483 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3484 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3492 if (LocaleCompare("wave",option+1) == 0)
3500 (void) SyncImageSettings(mogrify_info,*image);
3501 flags=ParseGeometry(argv[i+1],&geometry_info);
3502 if ((flags & SigmaValue) == 0)
3503 geometry_info.sigma=1.0;
3504 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3506 if (wave_image == (Image *) NULL)
3508 *image=DestroyImage(*image);
3512 if (LocaleCompare("weight",option+1) == 0)
3514 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3515 if (LocaleCompare(argv[i+1],"all") == 0)
3516 draw_info->weight=0;
3517 if (LocaleCompare(argv[i+1],"bold") == 0)
3518 draw_info->weight=700;
3519 if (LocaleCompare(argv[i+1],"bolder") == 0)
3520 if (draw_info->weight <= 800)
3521 draw_info->weight+=100;
3522 if (LocaleCompare(argv[i+1],"lighter") == 0)
3523 if (draw_info->weight >= 100)
3524 draw_info->weight-=100;
3525 if (LocaleCompare(argv[i+1],"normal") == 0)
3526 draw_info->weight=400;
3529 if (LocaleCompare("white-threshold",option+1) == 0)
3532 White threshold image.
3534 (void) SyncImageSettings(mogrify_info,*image);
3535 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3537 InheritException(exception,&(*image)->exception);
3547 if (region_image != (Image *) NULL)
3550 Composite transformed region onto image.
3552 (void) SyncImageSettings(mogrify_info,*image);
3553 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3554 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3556 InheritException(exception,®ion_image->exception);
3557 *image=DestroyImage(*image);
3558 *image=region_image;
3563 quantize_info=DestroyQuantizeInfo(quantize_info);
3564 draw_info=DestroyDrawInfo(draw_info);
3565 mogrify_info=DestroyImageInfo(mogrify_info);
3566 status=(*image)->exception.severity == UndefinedException ? MagickTrue :
3572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3576 % M o g r i f y I m a g e C o m m a n d %
3580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3582 % MogrifyImageCommand() transforms an image or a sequence of images. These
3583 % transforms include image scaling, image rotation, color reduction, and
3584 % others. The transmogrified image overwrites the original image.
3586 % The format of the MogrifyImageCommand method is:
3588 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3589 % const char **argv,char **metadata,ExceptionInfo *exception)
3591 % A description of each parameter follows:
3593 % o image_info: the image info.
3595 % o argc: the number of elements in the argument vector.
3597 % o argv: A text array containing the command line arguments.
3599 % o metadata: any metadata is returned here.
3601 % o exception: return any errors or warnings in this structure.
3605 static MagickBooleanType MogrifyUsage(void)
3610 "-debug events display copious debugging information",
3611 "-help print program options",
3612 "-list type print a list of supported option arguments",
3613 "-log format format of debugging information",
3614 "-version print version information",
3619 "-adaptive-blur geometry",
3620 " adaptively blur pixels; decrease effect near edges",
3621 "-adaptive-resize geometry",
3622 " adaptively resize image using 'mesh' interpolation",
3623 "-adaptive-sharpen geometry",
3624 " adaptively sharpen pixels; increase effect near edges",
3625 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3626 " transparent, extract, background, or shape",
3627 "-annotate geometry text",
3628 " annotate the image with text",
3629 "-auto-gamma automagically adjust gamma level of image",
3630 "-auto-level automagically adjust color levels of image",
3631 "-auto-orient automagically orient (rotate) image",
3632 "-bench iterations measure performance",
3633 "-black-threshold value",
3634 " force all pixels below the threshold into black",
3635 "-blue-shift simulate a scene at nighttime in the moonlight",
3636 "-blur geometry reduce image noise and reduce detail levels",
3637 "-border geometry surround image with a border of color",
3638 "-bordercolor color border color",
3639 "-brightness-contrast geometry",
3640 " improve brightness / contrast of the image",
3641 "-cdl filename color correct with a color decision list",
3642 "-charcoal radius simulate a charcoal drawing",
3643 "-chop geometry remove pixels from the image interior",
3644 "-clamp restrict pixel range from 0 to the quantum depth",
3645 "-clip clip along the first path from the 8BIM profile",
3646 "-clip-mask filename associate a clip mask with the image",
3647 "-clip-path id clip along a named path from the 8BIM profile",
3648 "-colorize value colorize the image with the fill color",
3649 "-color-matrix matrix apply color correction to the image",
3650 "-contrast enhance or reduce the image contrast",
3651 "-contrast-stretch geometry",
3652 " improve contrast by `stretching' the intensity range",
3653 "-convolve coefficients",
3654 " apply a convolution kernel to the image",
3655 "-cycle amount cycle the image colormap",
3656 "-decipher filename convert cipher pixels to plain pixels",
3657 "-deskew threshold straighten an image",
3658 "-despeckle reduce the speckles within an image",
3659 "-distort method args",
3660 " distort images according to given method ad args",
3661 "-draw string annotate the image with a graphic primitive",
3662 "-edge radius apply a filter to detect edges in the image",
3663 "-encipher filename convert plain pixels to cipher pixels",
3664 "-emboss radius emboss an image",
3665 "-enhance apply a digital filter to enhance a noisy image",
3666 "-equalize perform histogram equalization to an image",
3667 "-evaluate operator value",
3668 " evaluate an arithmetic, relational, or logical expression",
3669 "-extent geometry set the image size",
3670 "-extract geometry extract area from image",
3671 "-fft implements the discrete Fourier transform (DFT)",
3672 "-flip flip image vertically",
3673 "-floodfill geometry color",
3674 " floodfill the image with color",
3675 "-flop flop image horizontally",
3676 "-frame geometry surround image with an ornamental border",
3677 "-function name parameters",
3678 " apply function over image values",
3679 "-gamma value level of gamma correction",
3680 "-gaussian-blur geometry",
3681 " reduce image noise and reduce detail levels",
3682 "-geometry geometry preferred size or location of the image",
3683 "-identify identify the format and characteristics of the image",
3684 "-ift implements the inverse discrete Fourier transform (DFT)",
3685 "-implode amount implode image pixels about the center",
3686 "-lat geometry local adaptive thresholding",
3687 "-layers method optimize, merge, or compare image layers",
3688 "-level value adjust the level of image contrast",
3689 "-level-colors color,color",
3690 " level image with the given colors",
3691 "-linear-stretch geometry",
3692 " improve contrast by `stretching with saturation'",
3693 "-liquid-rescale geometry",
3694 " rescale image with seam-carving",
3695 "-median radius apply a median filter to the image",
3696 "-modulate value vary the brightness, saturation, and hue",
3697 "-monochrome transform image to black and white",
3698 "-morphology method kernel",
3699 " apply a morphology method to the image",
3700 "-motion-blur geometry",
3701 " simulate motion blur",
3702 "-negate replace every pixel with its complementary color ",
3703 "-noise radius add or reduce noise in an image",
3704 "-normalize transform image to span the full range of colors",
3705 "-opaque color change this color to the fill color",
3706 "-ordered-dither NxN",
3707 " add a noise pattern to the image with specific",
3709 "-paint radius simulate an oil painting",
3710 "-polaroid angle simulate a Polaroid picture",
3711 "-posterize levels reduce the image to a limited number of color levels",
3712 "-profile filename add, delete, or apply an image profile",
3713 "-quantize colorspace reduce colors in this colorspace",
3714 "-radial-blur angle radial blur the image",
3715 "-raise value lighten/darken image edges to create a 3-D effect",
3716 "-random-threshold low,high",
3717 " random threshold the image",
3718 "-region geometry apply options to a portion of the image",
3719 "-render render vector graphics",
3720 "-repage geometry size and location of an image canvas",
3721 "-resample geometry change the resolution of an image",
3722 "-resize geometry resize the image",
3723 "-roll geometry roll an image vertically or horizontally",
3724 "-rotate degrees apply Paeth rotation to the image",
3725 "-sample geometry scale image with pixel sampling",
3726 "-scale geometry scale the image",
3727 "-segment values segment an image",
3728 "-selective-blur geometry",
3729 " selectively blur pixels within a contrast threshold",
3730 "-sepia-tone threshold",
3731 " simulate a sepia-toned photo",
3732 "-set property value set an image property",
3733 "-shade degrees shade the image using a distant light source",
3734 "-shadow geometry simulate an image shadow",
3735 "-sharpen geometry sharpen the image",
3736 "-shave geometry shave pixels from the image edges",
3737 "-shear geometry slide one edge of the image along the X or Y axis",
3738 "-sigmoidal-contrast geometry",
3739 " increase the contrast without saturating highlights or shadows",
3740 "-sketch geometry simulate a pencil sketch",
3741 "-solarize threshold negate all pixels above the threshold level",
3742 "-sparse-color method args",
3743 " fill in a image based on a few color points",
3744 "-splice geometry splice the background color into the image",
3745 "-spread radius displace image pixels by a random amount",
3746 "-strip strip image of all profiles and comments",
3747 "-swirl degrees swirl image pixels about the center",
3748 "-threshold value threshold the image",
3749 "-thumbnail geometry create a thumbnail of the image",
3750 "-tile filename tile image when filling a graphic primitive",
3751 "-tint value tint the image with the fill color",
3752 "-transform affine transform image",
3753 "-transparent color make this color transparent within the image",
3754 "-transpose flip image vertically and rotate 90 degrees",
3755 "-transverse flop image horizontally and rotate 270 degrees",
3756 "-trim trim image edges",
3757 "-type type image type",
3758 "-unique-colors discard all but one of any pixel color",
3759 "-unsharp geometry sharpen the image",
3760 "-vignette geometry soften the edges of the image in vignette style",
3761 "-wave geometry alter an image along a sine wave",
3762 "-white-threshold value",
3763 " force all pixels above the threshold into white",
3766 *sequence_operators[]=
3768 "-append append an image sequence",
3769 "-clut apply a color lookup table to the image",
3770 "-coalesce merge a sequence of images",
3771 "-combine combine a sequence of images",
3772 "-composite composite image",
3773 "-crop geometry cut out a rectangular region of the image",
3774 "-deconstruct break down an image sequence into constituent parts",
3775 "-evaluate-sequence operator",
3776 " evaluate an arithmetic, relational, or logical expression",
3777 "-flatten flatten a sequence of images",
3778 "-fx expression apply mathematical expression to an image channel(s)",
3779 "-hald-clut apply a Hald color lookup table to the image",
3780 "-morph value morph an image sequence",
3781 "-mosaic create a mosaic from an image sequence",
3782 "-print string interpret string and print to console",
3783 "-process arguments process the image with a custom image filter",
3784 "-reverse reverse image sequence",
3785 "-separate separate an image channel into a grayscale image",
3786 "-write filename write images to this file",
3791 "-adjoin join images into a single multi-image file",
3792 "-affine matrix affine transform matrix",
3793 "-alpha option activate, deactivate, reset, or set the alpha channel",
3794 "-antialias remove pixel-aliasing",
3795 "-authenticate password",
3796 " decipher image with this password",
3797 "-attenuate value lessen (or intensify) when adding noise to an image",
3798 "-background color background color",
3799 "-bias value add bias when convolving an image",
3800 "-black-point-compensation",
3801 " use black point compensation",
3802 "-blue-primary point chromaticity blue primary point",
3803 "-bordercolor color border color",
3804 "-caption string assign a caption to an image",
3805 "-channel type apply option to select image channels",
3806 "-colors value preferred number of colors in the image",
3807 "-colorspace type alternate image colorspace",
3808 "-comment string annotate image with comment",
3809 "-compose operator set image composite operator",
3810 "-compress type type of pixel compression when writing the image",
3811 "-define format:option",
3812 " define one or more image format options",
3813 "-delay value display the next image after pausing",
3814 "-density geometry horizontal and vertical density of the image",
3815 "-depth value image depth",
3816 "-direction type render text right-to-left or left-to-right",
3817 "-display server get image or font from this X server",
3818 "-dispose method layer disposal method",
3819 "-dither method apply error diffusion to image",
3820 "-encoding type text encoding type",
3821 "-endian type endianness (MSB or LSB) of the image",
3822 "-family name render text with this font family",
3823 "-fill color color to use when filling a graphic primitive",
3824 "-filter type use this filter when resizing an image",
3825 "-font name render text with this font",
3826 "-format \"string\" output formatted image characteristics",
3827 "-fuzz distance colors within this distance are considered equal",
3828 "-gravity type horizontal and vertical text placement",
3829 "-green-primary point chromaticity green primary point",
3830 "-intent type type of rendering intent when managing the image color",
3831 "-interlace type type of image interlacing scheme",
3832 "-interline-spacing value",
3833 " set the space between two text lines",
3834 "-interpolate method pixel color interpolation method",
3835 "-interword-spacing value",
3836 " set the space between two words",
3837 "-kerning value set the space between two letters",
3838 "-label string assign a label to an image",
3839 "-limit type value pixel cache resource limit",
3840 "-loop iterations add Netscape loop extension to your GIF animation",
3841 "-mask filename associate a mask with the image",
3842 "-mattecolor color frame color",
3843 "-monitor monitor progress",
3844 "-orient type image orientation",
3845 "-page geometry size and location of an image canvas (setting)",
3846 "-ping efficiently determine image attributes",
3847 "-pointsize value font point size",
3848 "-precision value maximum number of significant digits to print",
3849 "-preview type image preview type",
3850 "-quality value JPEG/MIFF/PNG compression level",
3851 "-quiet suppress all warning messages",
3852 "-red-primary point chromaticity red primary point",
3853 "-regard-warnings pay attention to warning messages",
3854 "-remap filename transform image colors to match this set of colors",
3855 "-respect-parentheses settings remain in effect until parenthesis boundary",
3856 "-sampling-factor geometry",
3857 " horizontal and vertical sampling factor",
3858 "-scene value image scene number",
3859 "-seed value seed a new sequence of pseudo-random numbers",
3860 "-size geometry width and height of image",
3861 "-stretch type render text with this font stretch",
3862 "-stroke color graphic primitive stroke color",
3863 "-strokewidth value graphic primitive stroke width",
3864 "-style type render text with this font style",
3865 "-taint image as ineligible for bi-modal delegate",
3866 "-texture filename name of texture to tile onto the image background",
3867 "-tile-offset geometry",
3869 "-treedepth value color tree depth",
3870 "-transparent-color color",
3871 " transparent color",
3872 "-undercolor color annotation bounding box color",
3873 "-units type the units of image resolution",
3874 "-verbose print detailed information about the image",
3875 "-view FlashPix viewing transforms",
3876 "-virtual-pixel method",
3877 " virtual pixel access method",
3878 "-weight type render text with this font weight",
3879 "-white-point point chromaticity white point",
3884 "-clone index clone an image",
3885 "-delete index delete the image from the image sequence",
3886 "-insert index insert last image into the image sequence",
3887 "-swap indexes swap two images in the image sequence",
3894 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3895 (void) printf("Copyright: %s\n",GetMagickCopyright());
3896 (void) printf("Features: %s\n\n",GetMagickFeatures());
3897 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3899 (void) printf("\nImage Settings:\n");
3900 for (p=settings; *p != (char *) NULL; p++)
3901 (void) printf(" %s\n",*p);
3902 (void) printf("\nImage Operators:\n");
3903 for (p=operators; *p != (char *) NULL; p++)
3904 (void) printf(" %s\n",*p);
3905 (void) printf("\nImage Sequence Operators:\n");
3906 for (p=sequence_operators; *p != (char *) NULL; p++)
3907 (void) printf(" %s\n",*p);
3908 (void) printf("\nImage Stack Operators:\n");
3909 for (p=stack_operators; *p != (char *) NULL; p++)
3910 (void) printf(" %s\n",*p);
3911 (void) printf("\nMiscellaneous Options:\n");
3912 for (p=miscellaneous; *p != (char *) NULL; p++)
3913 (void) printf(" %s\n",*p);
3915 "\nBy default, the image format of `file' is determined by its magic\n");
3917 "number. To specify a particular image format, precede the filename\n");
3919 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3921 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3922 (void) printf("'-' for standard input or output.\n");
3923 return(MagickFalse);
3926 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3927 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3929 #define DestroyMogrify() \
3931 if (format != (char *) NULL) \
3932 format=DestroyString(format); \
3933 if (path != (char *) NULL) \
3934 path=DestroyString(path); \
3935 DestroyImageStack(); \
3936 for (i=0; i < (ssize_t) argc; i++) \
3937 argv[i]=DestroyString(argv[i]); \
3938 argv=(char **) RelinquishMagickMemory(argv); \
3940 #define ThrowMogrifyException(asperity,tag,option) \
3942 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3945 return(MagickFalse); \
3947 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3949 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3950 "InvalidArgument","`%s': %s",argument,option); \
3952 return(MagickFalse); \
3964 image_stack[MaxImageStackDepth+1];
3986 assert(image_info != (ImageInfo *) NULL);
3987 assert(image_info->signature == MagickSignature);
3988 if (image_info->debug != MagickFalse)
3989 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3990 assert(exception != (ExceptionInfo *) NULL);
3994 if ((LocaleCompare("version",option+1) == 0) ||
3995 (LocaleCompare("-version",option+1) == 0))
3997 (void) fprintf(stdout,"Version: %s\n",
3998 GetMagickVersion((size_t *) NULL));
3999 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
4000 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
4001 return(MagickFalse);
4005 return(MogrifyUsage());
4006 format=(char *) NULL;
4008 global_colormap=MagickFalse;
4012 option=(char *) NULL;
4018 ReadCommandlLine(argc,&argv);
4019 status=ExpandFilenames(&argc,&argv);
4020 if (status == MagickFalse)
4021 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4022 GetExceptionMessage(errno));
4023 for (i=1; i < (ssize_t) argc; i++)
4026 if (LocaleCompare(option,"(") == 0)
4028 FireImageStack(MagickFalse,MagickTrue,pend);
4029 if (k == MaxImageStackDepth)
4030 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4035 if (LocaleCompare(option,")") == 0)
4037 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4039 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4043 if (IsMagickOption(option) == MagickFalse)
4046 backup_filename[MaxTextExtent],
4053 Option is a file name: begin by reading image from specified file.
4055 FireImageStack(MagickFalse,MagickFalse,pend);
4057 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
4059 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4060 images=ReadImages(image_info,exception);
4061 status&=(images != (Image *) NULL) &&
4062 (exception->severity < ErrorException);
4063 if (images == (Image *) NULL)
4065 if (format != (char *) NULL)
4066 (void) CopyMagickString(images->filename,images->magick_filename,
4068 if (path != (char *) NULL)
4070 GetPathComponent(option,TailPath,filename);
4071 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4072 path,*DirectorySeparator,filename);
4074 if (format != (char *) NULL)
4075 AppendImageFormat(format,images->filename);
4076 AppendImageStack(images);
4077 FinalizeImageSettings(image_info,image,MagickFalse);
4078 if (global_colormap != MagickFalse)
4083 quantize_info=AcquireQuantizeInfo(image_info);
4084 (void) RemapImages(quantize_info,images,(Image *) NULL);
4085 quantize_info=DestroyQuantizeInfo(quantize_info);
4087 *backup_filename='\0';
4088 if ((LocaleCompare(image->filename,"-") != 0) &&
4089 (IsPathWritable(image->filename) != MagickFalse))
4095 Rename image file as backup.
4097 (void) CopyMagickString(backup_filename,image->filename,
4099 for (i=0; i < 6; i++)
4101 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4102 if (IsPathAccessible(backup_filename) == MagickFalse)
4105 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4106 (rename(image->filename,backup_filename) != 0))
4107 *backup_filename='\0';
4110 Write transmogrified image to disk.
4112 image_info->synchronize=MagickTrue;
4113 status&=WriteImages(image_info,image,image->filename,exception);
4114 if ((status == MagickFalse) && (*backup_filename != '\0'))
4115 (void) remove(backup_filename);
4116 RemoveAllImageStack();
4119 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4120 switch (*(option+1))
4124 if (LocaleCompare("adaptive-blur",option+1) == 0)
4127 if (i == (ssize_t) argc)
4128 ThrowMogrifyException(OptionError,"MissingArgument",option);
4129 if (IsGeometry(argv[i]) == MagickFalse)
4130 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4133 if (LocaleCompare("adaptive-resize",option+1) == 0)
4136 if (i == (ssize_t) argc)
4137 ThrowMogrifyException(OptionError,"MissingArgument",option);
4138 if (IsGeometry(argv[i]) == MagickFalse)
4139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4142 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4145 if (i == (ssize_t) argc)
4146 ThrowMogrifyException(OptionError,"MissingArgument",option);
4147 if (IsGeometry(argv[i]) == MagickFalse)
4148 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4151 if (LocaleCompare("affine",option+1) == 0)
4159 if (i == (ssize_t) argc)
4160 ThrowMogrifyException(OptionError,"MissingArgument",option);
4161 kernel_info=AcquireKernelInfo(argv[i]);
4162 if (kernel_info == (KernelInfo *) NULL)
4163 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4164 kernel_info=DestroyKernelInfo(kernel_info);
4167 if (LocaleCompare("alpha",option+1) == 0)
4175 if (i == (ssize_t) argc)
4176 ThrowMogrifyException(OptionError,"MissingArgument",option);
4177 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4179 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4183 if (LocaleCompare("annotate",option+1) == 0)
4188 if (i == (ssize_t) argc)
4189 ThrowMogrifyException(OptionError,"MissingArgument",option);
4190 if (IsGeometry(argv[i]) == MagickFalse)
4191 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4192 if (i == (ssize_t) argc)
4193 ThrowMogrifyException(OptionError,"MissingArgument",option);
4197 if (LocaleCompare("antialias",option+1) == 0)
4199 if (LocaleCompare("append",option+1) == 0)
4201 if (LocaleCompare("attenuate",option+1) == 0)
4206 if (i == (ssize_t) (argc-1))
4207 ThrowMogrifyException(OptionError,"MissingArgument",option);
4208 if (IsGeometry(argv[i]) == MagickFalse)
4209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4212 if (LocaleCompare("authenticate",option+1) == 0)
4217 if (i == (ssize_t) argc)
4218 ThrowMogrifyException(OptionError,"MissingArgument",option);
4221 if (LocaleCompare("auto-gamma",option+1) == 0)
4223 if (LocaleCompare("auto-level",option+1) == 0)
4225 if (LocaleCompare("auto-orient",option+1) == 0)
4227 if (LocaleCompare("average",option+1) == 0)
4229 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4233 if (LocaleCompare("background",option+1) == 0)
4238 if (i == (ssize_t) argc)
4239 ThrowMogrifyException(OptionError,"MissingArgument",option);
4242 if (LocaleCompare("bias",option+1) == 0)
4247 if (i == (ssize_t) (argc-1))
4248 ThrowMogrifyException(OptionError,"MissingArgument",option);
4249 if (IsGeometry(argv[i]) == MagickFalse)
4250 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4253 if (LocaleCompare("black-point-compensation",option+1) == 0)
4255 if (LocaleCompare("black-threshold",option+1) == 0)
4260 if (i == (ssize_t) argc)
4261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4262 if (IsGeometry(argv[i]) == MagickFalse)
4263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4266 if (LocaleCompare("blue-primary",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,"MissingArgument",option);
4273 if (IsGeometry(argv[i]) == MagickFalse)
4274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4277 if (LocaleCompare("blue-shift",option+1) == 0)
4280 if (i == (ssize_t) argc)
4281 ThrowMogrifyException(OptionError,"MissingArgument",option);
4282 if (IsGeometry(argv[i]) == MagickFalse)
4283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4286 if (LocaleCompare("blur",option+1) == 0)
4289 if (i == (ssize_t) argc)
4290 ThrowMogrifyException(OptionError,"MissingArgument",option);
4291 if (IsGeometry(argv[i]) == MagickFalse)
4292 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4295 if (LocaleCompare("border",option+1) == 0)
4300 if (i == (ssize_t) argc)
4301 ThrowMogrifyException(OptionError,"MissingArgument",option);
4302 if (IsGeometry(argv[i]) == MagickFalse)
4303 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4306 if (LocaleCompare("bordercolor",option+1) == 0)
4311 if (i == (ssize_t) argc)
4312 ThrowMogrifyException(OptionError,"MissingArgument",option);
4315 if (LocaleCompare("box",option+1) == 0)
4320 if (i == (ssize_t) argc)
4321 ThrowMogrifyException(OptionError,"MissingArgument",option);
4324 if (LocaleCompare("brightness-contrast",option+1) == 0)
4327 if (i == (ssize_t) argc)
4328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4329 if (IsGeometry(argv[i]) == MagickFalse)
4330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4333 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4337 if (LocaleCompare("cache",option+1) == 0)
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4344 if (IsGeometry(argv[i]) == MagickFalse)
4345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4348 if (LocaleCompare("caption",option+1) == 0)
4353 if (i == (ssize_t) argc)
4354 ThrowMogrifyException(OptionError,"MissingArgument",option);
4357 if (LocaleCompare("channel",option+1) == 0)
4365 if (i == (ssize_t) (argc-1))
4366 ThrowMogrifyException(OptionError,"MissingArgument",option);
4367 channel=ParseChannelOption(argv[i]);
4369 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4373 if (LocaleCompare("cdl",option+1) == 0)
4378 if (i == (ssize_t) (argc-1))
4379 ThrowMogrifyException(OptionError,"MissingArgument",option);
4382 if (LocaleCompare("charcoal",option+1) == 0)
4387 if (i == (ssize_t) argc)
4388 ThrowMogrifyException(OptionError,"MissingArgument",option);
4389 if (IsGeometry(argv[i]) == MagickFalse)
4390 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4393 if (LocaleCompare("chop",option+1) == 0)
4398 if (i == (ssize_t) argc)
4399 ThrowMogrifyException(OptionError,"MissingArgument",option);
4400 if (IsGeometry(argv[i]) == MagickFalse)
4401 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4404 if (LocaleCompare("clamp",option+1) == 0)
4406 if (LocaleCompare("clip",option+1) == 0)
4408 if (LocaleCompare("clip-mask",option+1) == 0)
4413 if (i == (ssize_t) argc)
4414 ThrowMogrifyException(OptionError,"MissingArgument",option);
4417 if (LocaleCompare("clut",option+1) == 0)
4419 if (LocaleCompare("coalesce",option+1) == 0)
4421 if (LocaleCompare("colorize",option+1) == 0)
4426 if (i == (ssize_t) argc)
4427 ThrowMogrifyException(OptionError,"MissingArgument",option);
4428 if (IsGeometry(argv[i]) == MagickFalse)
4429 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4432 if (LocaleCompare("color-matrix",option+1) == 0)
4440 if (i == (ssize_t) (argc-1))
4441 ThrowMogrifyException(OptionError,"MissingArgument",option);
4442 kernel_info=AcquireKernelInfo(argv[i]);
4443 if (kernel_info == (KernelInfo *) NULL)
4444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4445 kernel_info=DestroyKernelInfo(kernel_info);
4448 if (LocaleCompare("colors",option+1) == 0)
4453 if (i == (ssize_t) argc)
4454 ThrowMogrifyException(OptionError,"MissingArgument",option);
4455 if (IsGeometry(argv[i]) == MagickFalse)
4456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4459 if (LocaleCompare("colorspace",option+1) == 0)
4467 if (i == (ssize_t) argc)
4468 ThrowMogrifyException(OptionError,"MissingArgument",option);
4469 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4472 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4476 if (LocaleCompare("combine",option+1) == 0)
4478 if (LocaleCompare("comment",option+1) == 0)
4483 if (i == (ssize_t) argc)
4484 ThrowMogrifyException(OptionError,"MissingArgument",option);
4487 if (LocaleCompare("composite",option+1) == 0)
4489 if (LocaleCompare("compress",option+1) == 0)
4497 if (i == (ssize_t) argc)
4498 ThrowMogrifyException(OptionError,"MissingArgument",option);
4499 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4502 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4506 if (LocaleCompare("concurrent",option+1) == 0)
4508 if (LocaleCompare("contrast",option+1) == 0)
4510 if (LocaleCompare("contrast-stretch",option+1) == 0)
4513 if (i == (ssize_t) argc)
4514 ThrowMogrifyException(OptionError,"MissingArgument",option);
4515 if (IsGeometry(argv[i]) == MagickFalse)
4516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4519 if (LocaleCompare("convolve",option+1) == 0)
4527 if (i == (ssize_t) argc)
4528 ThrowMogrifyException(OptionError,"MissingArgument",option);
4529 kernel_info=AcquireKernelInfo(argv[i]);
4530 if (kernel_info == (KernelInfo *) NULL)
4531 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4532 kernel_info=DestroyKernelInfo(kernel_info);
4535 if (LocaleCompare("crop",option+1) == 0)
4540 if (i == (ssize_t) argc)
4541 ThrowMogrifyException(OptionError,"MissingArgument",option);
4542 if (IsGeometry(argv[i]) == MagickFalse)
4543 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4546 if (LocaleCompare("cycle",option+1) == 0)
4551 if (i == (ssize_t) argc)
4552 ThrowMogrifyException(OptionError,"MissingArgument",option);
4553 if (IsGeometry(argv[i]) == MagickFalse)
4554 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4557 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4561 if (LocaleCompare("decipher",option+1) == 0)
4566 if (i == (ssize_t) (argc-1))
4567 ThrowMogrifyException(OptionError,"MissingArgument",option);
4570 if (LocaleCompare("deconstruct",option+1) == 0)
4572 if (LocaleCompare("debug",option+1) == 0)
4580 if (i == (ssize_t) argc)
4581 ThrowMogrifyException(OptionError,"MissingArgument",option);
4582 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4584 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4586 (void) SetLogEventMask(argv[i]);
4589 if (LocaleCompare("define",option+1) == 0)
4592 if (i == (ssize_t) argc)
4593 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 define=GetImageOption(image_info,argv[i]);
4600 if (define == (const char *) NULL)
4601 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4606 if (LocaleCompare("delay",option+1) == 0)
4611 if (i == (ssize_t) argc)
4612 ThrowMogrifyException(OptionError,"MissingArgument",option);
4613 if (IsGeometry(argv[i]) == MagickFalse)
4614 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4617 if (LocaleCompare("density",option+1) == 0)
4622 if (i == (ssize_t) argc)
4623 ThrowMogrifyException(OptionError,"MissingArgument",option);
4624 if (IsGeometry(argv[i]) == MagickFalse)
4625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4628 if (LocaleCompare("depth",option+1) == 0)
4633 if (i == (ssize_t) argc)
4634 ThrowMogrifyException(OptionError,"MissingArgument",option);
4635 if (IsGeometry(argv[i]) == MagickFalse)
4636 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4639 if (LocaleCompare("deskew",option+1) == 0)
4644 if (i == (ssize_t) argc)
4645 ThrowMogrifyException(OptionError,"MissingArgument",option);
4646 if (IsGeometry(argv[i]) == MagickFalse)
4647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4650 if (LocaleCompare("despeckle",option+1) == 0)
4652 if (LocaleCompare("dft",option+1) == 0)
4654 if (LocaleCompare("direction",option+1) == 0)
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4664 direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
4667 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4671 if (LocaleCompare("display",option+1) == 0)
4676 if (i == (ssize_t) argc)
4677 ThrowMogrifyException(OptionError,"MissingArgument",option);
4680 if (LocaleCompare("dispose",option+1) == 0)
4688 if (i == (ssize_t) argc)
4689 ThrowMogrifyException(OptionError,"MissingArgument",option);
4690 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4692 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4696 if (LocaleCompare("distort",option+1) == 0)
4702 if (i == (ssize_t) argc)
4703 ThrowMogrifyException(OptionError,"MissingArgument",option);
4704 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4706 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4709 if (i == (ssize_t) (argc-1))
4710 ThrowMogrifyException(OptionError,"MissingArgument",option);
4713 if (LocaleCompare("dither",option+1) == 0)
4721 if (i == (ssize_t) argc)
4722 ThrowMogrifyException(OptionError,"MissingArgument",option);
4723 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4725 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4729 if (LocaleCompare("draw",option+1) == 0)
4734 if (i == (ssize_t) argc)
4735 ThrowMogrifyException(OptionError,"MissingArgument",option);
4738 if (LocaleCompare("duration",option+1) == 0)
4743 if (i == (ssize_t) (argc-1))
4744 ThrowMogrifyException(OptionError,"MissingArgument",option);
4745 if (IsGeometry(argv[i]) == MagickFalse)
4746 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4749 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4753 if (LocaleCompare("edge",option+1) == 0)
4758 if (i == (ssize_t) argc)
4759 ThrowMogrifyException(OptionError,"MissingArgument",option);
4760 if (IsGeometry(argv[i]) == MagickFalse)
4761 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4764 if (LocaleCompare("emboss",option+1) == 0)
4769 if (i == (ssize_t) argc)
4770 ThrowMogrifyException(OptionError,"MissingArgument",option);
4771 if (IsGeometry(argv[i]) == MagickFalse)
4772 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4775 if (LocaleCompare("encipher",option+1) == 0)
4780 if (i == (ssize_t) argc)
4781 ThrowMogrifyException(OptionError,"MissingArgument",option);
4784 if (LocaleCompare("encoding",option+1) == 0)
4789 if (i == (ssize_t) argc)
4790 ThrowMogrifyException(OptionError,"MissingArgument",option);
4793 if (LocaleCompare("endian",option+1) == 0)
4801 if (i == (ssize_t) argc)
4802 ThrowMogrifyException(OptionError,"MissingArgument",option);
4803 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4805 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4809 if (LocaleCompare("enhance",option+1) == 0)
4811 if (LocaleCompare("equalize",option+1) == 0)
4813 if (LocaleCompare("evaluate",option+1) == 0)
4821 if (i == (ssize_t) argc)
4822 ThrowMogrifyException(OptionError,"MissingArgument",option);
4823 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4825 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4828 if (i == (ssize_t) (argc-1))
4829 ThrowMogrifyException(OptionError,"MissingArgument",option);
4830 if (IsGeometry(argv[i]) == MagickFalse)
4831 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4834 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4842 if (i == (ssize_t) argc)
4843 ThrowMogrifyException(OptionError,"MissingArgument",option);
4844 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4846 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4850 if (LocaleCompare("extent",option+1) == 0)
4855 if (i == (ssize_t) argc)
4856 ThrowMogrifyException(OptionError,"MissingArgument",option);
4857 if (IsGeometry(argv[i]) == MagickFalse)
4858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4861 if (LocaleCompare("extract",option+1) == 0)
4866 if (i == (ssize_t) argc)
4867 ThrowMogrifyException(OptionError,"MissingArgument",option);
4868 if (IsGeometry(argv[i]) == MagickFalse)
4869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4872 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4876 if (LocaleCompare("family",option+1) == 0)
4881 if (i == (ssize_t) (argc-1))
4882 ThrowMogrifyException(OptionError,"MissingArgument",option);
4885 if (LocaleCompare("fill",option+1) == 0)
4890 if (i == (ssize_t) argc)
4891 ThrowMogrifyException(OptionError,"MissingArgument",option);
4894 if (LocaleCompare("filter",option+1) == 0)
4902 if (i == (ssize_t) argc)
4903 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4906 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4910 if (LocaleCompare("flatten",option+1) == 0)
4912 if (LocaleCompare("flip",option+1) == 0)
4914 if (LocaleCompare("flop",option+1) == 0)
4916 if (LocaleCompare("floodfill",option+1) == 0)
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,"MissingArgument",option);
4923 if (IsGeometry(argv[i]) == MagickFalse)
4924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4926 if (i == (ssize_t) argc)
4927 ThrowMogrifyException(OptionError,"MissingArgument",option);
4930 if (LocaleCompare("font",option+1) == 0)
4935 if (i == (ssize_t) argc)
4936 ThrowMogrifyException(OptionError,"MissingArgument",option);
4939 if (LocaleCompare("format",option+1) == 0)
4941 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4942 (void) CloneString(&format,(char *) NULL);
4946 if (i == (ssize_t) argc)
4947 ThrowMogrifyException(OptionError,"MissingArgument",option);
4948 (void) CloneString(&format,argv[i]);
4949 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4950 (void) ConcatenateMagickString(image_info->filename,":",
4952 (void) SetImageInfo(image_info,0,exception);
4953 if (*image_info->magick == '\0')
4954 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4958 if (LocaleCompare("frame",option+1) == 0)
4963 if (i == (ssize_t) argc)
4964 ThrowMogrifyException(OptionError,"MissingArgument",option);
4965 if (IsGeometry(argv[i]) == MagickFalse)
4966 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4969 if (LocaleCompare("function",option+1) == 0)
4977 if (i == (ssize_t) argc)
4978 ThrowMogrifyException(OptionError,"MissingArgument",option);
4979 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
4981 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4983 if (i == (ssize_t) (argc-1))
4984 ThrowMogrifyException(OptionError,"MissingArgument",option);
4987 if (LocaleCompare("fuzz",option+1) == 0)
4992 if (i == (ssize_t) argc)
4993 ThrowMogrifyException(OptionError,"MissingArgument",option);
4994 if (IsGeometry(argv[i]) == MagickFalse)
4995 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4998 if (LocaleCompare("fx",option+1) == 0)
5003 if (i == (ssize_t) (argc-1))
5004 ThrowMogrifyException(OptionError,"MissingArgument",option);
5007 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5011 if (LocaleCompare("gamma",option+1) == 0)
5014 if (i == (ssize_t) argc)
5015 ThrowMogrifyException(OptionError,"MissingArgument",option);
5016 if (IsGeometry(argv[i]) == MagickFalse)
5017 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5020 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5021 (LocaleCompare("gaussian",option+1) == 0))
5024 if (i == (ssize_t) argc)
5025 ThrowMogrifyException(OptionError,"MissingArgument",option);
5026 if (IsGeometry(argv[i]) == MagickFalse)
5027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5030 if (LocaleCompare("geometry",option+1) == 0)
5035 if (i == (ssize_t) argc)
5036 ThrowMogrifyException(OptionError,"MissingArgument",option);
5037 if (IsGeometry(argv[i]) == MagickFalse)
5038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5041 if (LocaleCompare("gravity",option+1) == 0)
5049 if (i == (ssize_t) argc)
5050 ThrowMogrifyException(OptionError,"MissingArgument",option);
5051 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5053 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5057 if (LocaleCompare("green-primary",option+1) == 0)
5062 if (i == (ssize_t) argc)
5063 ThrowMogrifyException(OptionError,"MissingArgument",option);
5064 if (IsGeometry(argv[i]) == MagickFalse)
5065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5068 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5072 if (LocaleCompare("hald-clut",option+1) == 0)
5074 if ((LocaleCompare("help",option+1) == 0) ||
5075 (LocaleCompare("-help",option+1) == 0))
5076 return(MogrifyUsage());
5077 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5081 if (LocaleCompare("identify",option+1) == 0)
5083 if (LocaleCompare("idft",option+1) == 0)
5085 if (LocaleCompare("implode",option+1) == 0)
5090 if (i == (ssize_t) argc)
5091 ThrowMogrifyException(OptionError,"MissingArgument",option);
5092 if (IsGeometry(argv[i]) == MagickFalse)
5093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5096 if (LocaleCompare("intent",option+1) == 0)
5104 if (i == (ssize_t) (argc-1))
5105 ThrowMogrifyException(OptionError,"MissingArgument",option);
5106 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5108 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5112 if (LocaleCompare("interlace",option+1) == 0)
5120 if (i == (ssize_t) argc)
5121 ThrowMogrifyException(OptionError,"MissingArgument",option);
5122 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5125 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5129 if (LocaleCompare("interline-spacing",option+1) == 0)
5134 if (i == (ssize_t) (argc-1))
5135 ThrowMogrifyException(OptionError,"MissingArgument",option);
5136 if (IsGeometry(argv[i]) == MagickFalse)
5137 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5140 if (LocaleCompare("interpolate",option+1) == 0)
5148 if (i == (ssize_t) argc)
5149 ThrowMogrifyException(OptionError,"MissingArgument",option);
5150 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5152 if (interpolate < 0)
5153 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5157 if (LocaleCompare("interword-spacing",option+1) == 0)
5162 if (i == (ssize_t) (argc-1))
5163 ThrowMogrifyException(OptionError,"MissingArgument",option);
5164 if (IsGeometry(argv[i]) == MagickFalse)
5165 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5168 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5172 if (LocaleCompare("kerning",option+1) == 0)
5177 if (i == (ssize_t) (argc-1))
5178 ThrowMogrifyException(OptionError,"MissingArgument",option);
5179 if (IsGeometry(argv[i]) == MagickFalse)
5180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5183 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5187 if (LocaleCompare("label",option+1) == 0)
5192 if (i == (ssize_t) argc)
5193 ThrowMogrifyException(OptionError,"MissingArgument",option);
5196 if (LocaleCompare("lat",option+1) == 0)
5201 if (i == (ssize_t) argc)
5202 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 if (IsGeometry(argv[i]) == MagickFalse)
5204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5206 if (LocaleCompare("layers",option+1) == 0)
5214 if (i == (ssize_t) (argc-1))
5215 ThrowMogrifyException(OptionError,"MissingArgument",option);
5216 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5218 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5222 if (LocaleCompare("level",option+1) == 0)
5225 if (i == (ssize_t) argc)
5226 ThrowMogrifyException(OptionError,"MissingArgument",option);
5227 if (IsGeometry(argv[i]) == MagickFalse)
5228 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5231 if (LocaleCompare("level-colors",option+1) == 0)
5234 if (i == (ssize_t) argc)
5235 ThrowMogrifyException(OptionError,"MissingArgument",option);
5238 if (LocaleCompare("linewidth",option+1) == 0)
5243 if (i == (ssize_t) argc)
5244 ThrowMogrifyException(OptionError,"MissingArgument",option);
5245 if (IsGeometry(argv[i]) == MagickFalse)
5246 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5249 if (LocaleCompare("limit",option+1) == 0)
5263 if (i == (ssize_t) argc)
5264 ThrowMogrifyException(OptionError,"MissingArgument",option);
5265 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5268 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5271 if (i == (ssize_t) argc)
5272 ThrowMogrifyException(OptionError,"MissingArgument",option);
5273 value=strtod(argv[i],&p);
5274 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5275 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5278 if (LocaleCompare("liquid-rescale",option+1) == 0)
5281 if (i == (ssize_t) argc)
5282 ThrowMogrifyException(OptionError,"MissingArgument",option);
5283 if (IsGeometry(argv[i]) == MagickFalse)
5284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5287 if (LocaleCompare("list",option+1) == 0)
5295 if (i == (ssize_t) argc)
5296 ThrowMogrifyException(OptionError,"MissingArgument",option);
5297 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5299 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5300 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5302 return(status != 0 ? MagickFalse : MagickTrue);
5304 if (LocaleCompare("log",option+1) == 0)
5309 if ((i == (ssize_t) argc) ||
5310 (strchr(argv[i],'%') == (char *) NULL))
5311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5314 if (LocaleCompare("loop",option+1) == 0)
5319 if (i == (ssize_t) argc)
5320 ThrowMogrifyException(OptionError,"MissingArgument",option);
5321 if (IsGeometry(argv[i]) == MagickFalse)
5322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5325 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5329 if (LocaleCompare("map",option+1) == 0)
5331 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5335 if (i == (ssize_t) argc)
5336 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 if (LocaleCompare("mask",option+1) == 0)
5344 if (i == (ssize_t) argc)
5345 ThrowMogrifyException(OptionError,"MissingArgument",option);
5348 if (LocaleCompare("matte",option+1) == 0)
5350 if (LocaleCompare("mattecolor",option+1) == 0)
5355 if (i == (ssize_t) argc)
5356 ThrowMogrifyException(OptionError,"MissingArgument",option);
5359 if (LocaleCompare("maximum",option+1) == 0)
5361 if (LocaleCompare("minimum",option+1) == 0)
5363 if (LocaleCompare("modulate",option+1) == 0)
5368 if (i == (ssize_t) argc)
5369 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (IsGeometry(argv[i]) == MagickFalse)
5371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5374 if (LocaleCompare("median",option+1) == 0)
5379 if (i == (ssize_t) argc)
5380 ThrowMogrifyException(OptionError,"MissingArgument",option);
5381 if (IsGeometry(argv[i]) == MagickFalse)
5382 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5385 if (LocaleCompare("monitor",option+1) == 0)
5387 if (LocaleCompare("monochrome",option+1) == 0)
5389 if (LocaleCompare("morph",option+1) == 0)
5394 if (i == (ssize_t) (argc-1))
5395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 if (IsGeometry(argv[i]) == MagickFalse)
5397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5400 if (LocaleCompare("morphology",option+1) == 0)
5403 token[MaxTextExtent];
5412 if (i == (ssize_t) argc)
5413 ThrowMogrifyException(OptionError,"MissingArgument",option);
5414 GetMagickToken(argv[i],NULL,token);
5415 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5417 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5420 if (i == (ssize_t) (argc-1))
5421 ThrowMogrifyException(OptionError,"MissingArgument",option);
5422 kernel_info=AcquireKernelInfo(argv[i]);
5423 if (kernel_info == (KernelInfo *) NULL)
5424 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5425 kernel_info=DestroyKernelInfo(kernel_info);
5428 if (LocaleCompare("mosaic",option+1) == 0)
5430 if (LocaleCompare("motion-blur",option+1) == 0)
5435 if (i == (ssize_t) argc)
5436 ThrowMogrifyException(OptionError,"MissingArgument",option);
5437 if (IsGeometry(argv[i]) == MagickFalse)
5438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5441 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5445 if (LocaleCompare("negate",option+1) == 0)
5447 if (LocaleCompare("noise",option+1) == 0)
5450 if (i == (ssize_t) argc)
5451 ThrowMogrifyException(OptionError,"MissingArgument",option);
5457 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5459 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5463 if (IsGeometry(argv[i]) == MagickFalse)
5464 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5467 if (LocaleCompare("noop",option+1) == 0)
5469 if (LocaleCompare("normalize",option+1) == 0)
5471 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5475 if (LocaleCompare("opaque",option+1) == 0)
5478 if (i == (ssize_t) argc)
5479 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (LocaleCompare("ordered-dither",option+1) == 0)
5487 if (i == (ssize_t) argc)
5488 ThrowMogrifyException(OptionError,"MissingArgument",option);
5491 if (LocaleCompare("orient",option+1) == 0)
5496 orientation=UndefinedOrientation;
5500 if (i == (ssize_t) (argc-1))
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5502 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5504 if (orientation < 0)
5505 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5509 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5513 if (LocaleCompare("page",option+1) == 0)
5518 if (i == (ssize_t) argc)
5519 ThrowMogrifyException(OptionError,"MissingArgument",option);
5522 if (LocaleCompare("paint",option+1) == 0)
5527 if (i == (ssize_t) argc)
5528 ThrowMogrifyException(OptionError,"MissingArgument",option);
5529 if (IsGeometry(argv[i]) == MagickFalse)
5530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5533 if (LocaleCompare("path",option+1) == 0)
5535 (void) CloneString(&path,(char *) NULL);
5539 if (i == (ssize_t) argc)
5540 ThrowMogrifyException(OptionError,"MissingArgument",option);
5541 (void) CloneString(&path,argv[i]);
5544 if (LocaleCompare("pointsize",option+1) == 0)
5549 if (i == (ssize_t) argc)
5550 ThrowMogrifyException(OptionError,"MissingArgument",option);
5551 if (IsGeometry(argv[i]) == MagickFalse)
5552 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5555 if (LocaleCompare("polaroid",option+1) == 0)
5560 if (i == (ssize_t) argc)
5561 ThrowMogrifyException(OptionError,"MissingArgument",option);
5562 if (IsGeometry(argv[i]) == MagickFalse)
5563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5566 if (LocaleCompare("posterize",option+1) == 0)
5571 if (i == (ssize_t) argc)
5572 ThrowMogrifyException(OptionError,"MissingArgument",option);
5573 if (IsGeometry(argv[i]) == MagickFalse)
5574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5577 if (LocaleCompare("precision",option+1) == 0)
5582 if (i == (ssize_t) argc)
5583 ThrowMogrifyException(OptionError,"MissingArgument",option);
5584 if (IsGeometry(argv[i]) == MagickFalse)
5585 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5588 if (LocaleCompare("print",option+1) == 0)
5593 if (i == (ssize_t) argc)
5594 ThrowMogrifyException(OptionError,"MissingArgument",option);
5597 if (LocaleCompare("process",option+1) == 0)
5602 if (i == (ssize_t) (argc-1))
5603 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 if (LocaleCompare("profile",option+1) == 0)
5609 if (i == (ssize_t) argc)
5610 ThrowMogrifyException(OptionError,"MissingArgument",option);
5613 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5617 if (LocaleCompare("quality",option+1) == 0)
5622 if (i == (ssize_t) argc)
5623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5624 if (IsGeometry(argv[i]) == MagickFalse)
5625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5628 if (LocaleCompare("quantize",option+1) == 0)
5636 if (i == (ssize_t) (argc-1))
5637 ThrowMogrifyException(OptionError,"MissingArgument",option);
5638 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5641 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5645 if (LocaleCompare("quiet",option+1) == 0)
5647 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5651 if (LocaleCompare("radial-blur",option+1) == 0)
5654 if (i == (ssize_t) argc)
5655 ThrowMogrifyException(OptionError,"MissingArgument",option);
5656 if (IsGeometry(argv[i]) == MagickFalse)
5657 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5660 if (LocaleCompare("raise",option+1) == 0)
5663 if (i == (ssize_t) argc)
5664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 if (IsGeometry(argv[i]) == MagickFalse)
5666 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5669 if (LocaleCompare("random-threshold",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("recolor",option+1) == 0)
5685 if (i == (ssize_t) (argc-1))
5686 ThrowMogrifyException(OptionError,"MissingArgument",option);
5687 if (IsGeometry(argv[i]) == MagickFalse)
5688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5691 if (LocaleCompare("red-primary",option+1) == 0)
5696 if (i == (ssize_t) argc)
5697 ThrowMogrifyException(OptionError,"MissingArgument",option);
5698 if (IsGeometry(argv[i]) == MagickFalse)
5699 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5701 if (LocaleCompare("regard-warnings",option+1) == 0)
5703 if (LocaleCompare("region",option+1) == 0)
5708 if (i == (ssize_t) argc)
5709 ThrowMogrifyException(OptionError,"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5714 if (LocaleCompare("remap",option+1) == 0)
5719 if (i == (ssize_t) (argc-1))
5720 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 if (LocaleCompare("render",option+1) == 0)
5725 if (LocaleCompare("repage",option+1) == 0)
5730 if (i == (ssize_t) argc)
5731 ThrowMogrifyException(OptionError,"MissingArgument",option);
5732 if (IsGeometry(argv[i]) == MagickFalse)
5733 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5736 if (LocaleCompare("resample",option+1) == 0)
5741 if (i == (ssize_t) argc)
5742 ThrowMogrifyException(OptionError,"MissingArgument",option);
5743 if (IsGeometry(argv[i]) == MagickFalse)
5744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5747 if (LocaleCompare("resize",option+1) == 0)
5752 if (i == (ssize_t) argc)
5753 ThrowMogrifyException(OptionError,"MissingArgument",option);
5754 if (IsGeometry(argv[i]) == MagickFalse)
5755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5758 if (LocaleCompare("reverse",option+1) == 0)
5760 if (LocaleCompare("roll",option+1) == 0)
5765 if (i == (ssize_t) argc)
5766 ThrowMogrifyException(OptionError,"MissingArgument",option);
5767 if (IsGeometry(argv[i]) == MagickFalse)
5768 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5771 if (LocaleCompare("rotate",option+1) == 0)
5774 if (i == (ssize_t) argc)
5775 ThrowMogrifyException(OptionError,"MissingArgument",option);
5776 if (IsGeometry(argv[i]) == MagickFalse)
5777 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5780 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5784 if (LocaleCompare("sample",option+1) == 0)
5789 if (i == (ssize_t) argc)
5790 ThrowMogrifyException(OptionError,"MissingArgument",option);
5791 if (IsGeometry(argv[i]) == MagickFalse)
5792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5795 if (LocaleCompare("sampling-factor",option+1) == 0)
5800 if (i == (ssize_t) argc)
5801 ThrowMogrifyException(OptionError,"MissingArgument",option);
5802 if (IsGeometry(argv[i]) == MagickFalse)
5803 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5806 if (LocaleCompare("scale",option+1) == 0)
5811 if (i == (ssize_t) argc)
5812 ThrowMogrifyException(OptionError,"MissingArgument",option);
5813 if (IsGeometry(argv[i]) == MagickFalse)
5814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5817 if (LocaleCompare("scene",option+1) == 0)
5822 if (i == (ssize_t) argc)
5823 ThrowMogrifyException(OptionError,"MissingArgument",option);
5824 if (IsGeometry(argv[i]) == MagickFalse)
5825 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5828 if (LocaleCompare("seed",option+1) == 0)
5833 if (i == (ssize_t) argc)
5834 ThrowMogrifyException(OptionError,"MissingArgument",option);
5835 if (IsGeometry(argv[i]) == MagickFalse)
5836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5839 if (LocaleCompare("segment",option+1) == 0)
5844 if (i == (ssize_t) argc)
5845 ThrowMogrifyException(OptionError,"MissingArgument",option);
5846 if (IsGeometry(argv[i]) == MagickFalse)
5847 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5850 if (LocaleCompare("selective-blur",option+1) == 0)
5853 if (i == (ssize_t) argc)
5854 ThrowMogrifyException(OptionError,"MissingArgument",option);
5855 if (IsGeometry(argv[i]) == MagickFalse)
5856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5859 if (LocaleCompare("separate",option+1) == 0)
5861 if (LocaleCompare("sepia-tone",option+1) == 0)
5866 if (i == (ssize_t) argc)
5867 ThrowMogrifyException(OptionError,"MissingArgument",option);
5868 if (IsGeometry(argv[i]) == MagickFalse)
5869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 if (LocaleCompare("set",option+1) == 0)
5875 if (i == (ssize_t) argc)
5876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 if (i == (ssize_t) argc)
5881 ThrowMogrifyException(OptionError,"MissingArgument",option);
5884 if (LocaleCompare("shade",option+1) == 0)
5887 if (i == (ssize_t) argc)
5888 ThrowMogrifyException(OptionError,"MissingArgument",option);
5889 if (IsGeometry(argv[i]) == MagickFalse)
5890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5893 if (LocaleCompare("shadow",option+1) == 0)
5898 if (i == (ssize_t) argc)
5899 ThrowMogrifyException(OptionError,"MissingArgument",option);
5900 if (IsGeometry(argv[i]) == MagickFalse)
5901 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5904 if (LocaleCompare("sharpen",option+1) == 0)
5907 if (i == (ssize_t) argc)
5908 ThrowMogrifyException(OptionError,"MissingArgument",option);
5909 if (IsGeometry(argv[i]) == MagickFalse)
5910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5913 if (LocaleCompare("shave",option+1) == 0)
5918 if (i == (ssize_t) argc)
5919 ThrowMogrifyException(OptionError,"MissingArgument",option);
5920 if (IsGeometry(argv[i]) == MagickFalse)
5921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5924 if (LocaleCompare("shear",option+1) == 0)
5927 if (i == (ssize_t) argc)
5928 ThrowMogrifyException(OptionError,"MissingArgument",option);
5929 if (IsGeometry(argv[i]) == MagickFalse)
5930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5933 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5936 if (i == (ssize_t) (argc-1))
5937 ThrowMogrifyException(OptionError,"MissingArgument",option);
5938 if (IsGeometry(argv[i]) == MagickFalse)
5939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5942 if (LocaleCompare("size",option+1) == 0)
5947 if (i == (ssize_t) argc)
5948 ThrowMogrifyException(OptionError,"MissingArgument",option);
5949 if (IsGeometry(argv[i]) == MagickFalse)
5950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5953 if (LocaleCompare("sketch",option+1) == 0)
5958 if (i == (ssize_t) argc)
5959 ThrowMogrifyException(OptionError,"MissingArgument",option);
5960 if (IsGeometry(argv[i]) == MagickFalse)
5961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5964 if (LocaleCompare("solarize",option+1) == 0)
5969 if (i == (ssize_t) argc)
5970 ThrowMogrifyException(OptionError,"MissingArgument",option);
5971 if (IsGeometry(argv[i]) == MagickFalse)
5972 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5975 if (LocaleCompare("sparse-color",option+1) == 0)
5981 if (i == (ssize_t) argc)
5982 ThrowMogrifyException(OptionError,"MissingArgument",option);
5983 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5985 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5988 if (i == (ssize_t) (argc-1))
5989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5992 if (LocaleCompare("spread",option+1) == 0)
5997 if (i == (ssize_t) argc)
5998 ThrowMogrifyException(OptionError,"MissingArgument",option);
5999 if (IsGeometry(argv[i]) == MagickFalse)
6000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003 if (LocaleCompare("stretch",option+1) == 0)
6011 if (i == (ssize_t) (argc-1))
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6013 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6015 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6019 if (LocaleCompare("strip",option+1) == 0)
6021 if (LocaleCompare("stroke",option+1) == 0)
6026 if (i == (ssize_t) argc)
6027 ThrowMogrifyException(OptionError,"MissingArgument",option);
6030 if (LocaleCompare("strokewidth",option+1) == 0)
6035 if (i == (ssize_t) argc)
6036 ThrowMogrifyException(OptionError,"MissingArgument",option);
6037 if (IsGeometry(argv[i]) == MagickFalse)
6038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6041 if (LocaleCompare("style",option+1) == 0)
6049 if (i == (ssize_t) (argc-1))
6050 ThrowMogrifyException(OptionError,"MissingArgument",option);
6051 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6053 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6057 if (LocaleCompare("swirl",option+1) == 0)
6062 if (i == (ssize_t) argc)
6063 ThrowMogrifyException(OptionError,"MissingArgument",option);
6064 if (IsGeometry(argv[i]) == MagickFalse)
6065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6068 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6072 if (LocaleCompare("taint",option+1) == 0)
6074 if (LocaleCompare("texture",option+1) == 0)
6079 if (i == (ssize_t) argc)
6080 ThrowMogrifyException(OptionError,"MissingArgument",option);
6083 if (LocaleCompare("tile",option+1) == 0)
6088 if (i == (ssize_t) (argc-1))
6089 ThrowMogrifyException(OptionError,"MissingArgument",option);
6092 if (LocaleCompare("tile-offset",option+1) == 0)
6097 if (i == (ssize_t) argc)
6098 ThrowMogrifyException(OptionError,"MissingArgument",option);
6099 if (IsGeometry(argv[i]) == MagickFalse)
6100 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6103 if (LocaleCompare("tint",option+1) == 0)
6108 if (i == (ssize_t) (argc-1))
6109 ThrowMogrifyException(OptionError,"MissingArgument",option);
6110 if (IsGeometry(argv[i]) == MagickFalse)
6111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6114 if (LocaleCompare("transform",option+1) == 0)
6116 if (LocaleCompare("transpose",option+1) == 0)
6118 if (LocaleCompare("transverse",option+1) == 0)
6120 if (LocaleCompare("threshold",option+1) == 0)
6125 if (i == (ssize_t) argc)
6126 ThrowMogrifyException(OptionError,"MissingArgument",option);
6127 if (IsGeometry(argv[i]) == MagickFalse)
6128 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6131 if (LocaleCompare("thumbnail",option+1) == 0)
6136 if (i == (ssize_t) argc)
6137 ThrowMogrifyException(OptionError,"MissingArgument",option);
6138 if (IsGeometry(argv[i]) == MagickFalse)
6139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6142 if (LocaleCompare("transparent",option+1) == 0)
6145 if (i == (ssize_t) argc)
6146 ThrowMogrifyException(OptionError,"MissingArgument",option);
6149 if (LocaleCompare("transparent-color",option+1) == 0)
6154 if (i == (ssize_t) (argc-1))
6155 ThrowMogrifyException(OptionError,"MissingArgument",option);
6158 if (LocaleCompare("treedepth",option+1) == 0)
6163 if (i == (ssize_t) argc)
6164 ThrowMogrifyException(OptionError,"MissingArgument",option);
6165 if (IsGeometry(argv[i]) == MagickFalse)
6166 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6169 if (LocaleCompare("trim",option+1) == 0)
6171 if (LocaleCompare("type",option+1) == 0)
6179 if (i == (ssize_t) argc)
6180 ThrowMogrifyException(OptionError,"MissingArgument",option);
6181 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6183 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6187 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6191 if (LocaleCompare("undercolor",option+1) == 0)
6196 if (i == (ssize_t) argc)
6197 ThrowMogrifyException(OptionError,"MissingArgument",option);
6200 if (LocaleCompare("unique-colors",option+1) == 0)
6202 if (LocaleCompare("units",option+1) == 0)
6210 if (i == (ssize_t) argc)
6211 ThrowMogrifyException(OptionError,"MissingArgument",option);
6212 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6215 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6219 if (LocaleCompare("unsharp",option+1) == 0)
6222 if (i == (ssize_t) argc)
6223 ThrowMogrifyException(OptionError,"MissingArgument",option);
6224 if (IsGeometry(argv[i]) == MagickFalse)
6225 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6228 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6232 if (LocaleCompare("verbose",option+1) == 0)
6234 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6237 if ((LocaleCompare("version",option+1) == 0) ||
6238 (LocaleCompare("-version",option+1) == 0))
6240 (void) fprintf(stdout,"Version: %s\n",
6241 GetMagickVersion((size_t *) NULL));
6242 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6243 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
6246 if (LocaleCompare("view",option+1) == 0)
6251 if (i == (ssize_t) argc)
6252 ThrowMogrifyException(OptionError,"MissingArgument",option);
6255 if (LocaleCompare("vignette",option+1) == 0)
6260 if (i == (ssize_t) argc)
6261 ThrowMogrifyException(OptionError,"MissingArgument",option);
6262 if (IsGeometry(argv[i]) == MagickFalse)
6263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6266 if (LocaleCompare("virtual-pixel",option+1) == 0)
6274 if (i == (ssize_t) argc)
6275 ThrowMogrifyException(OptionError,"MissingArgument",option);
6276 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6279 ThrowMogrifyException(OptionError,
6280 "UnrecognizedVirtualPixelMethod",argv[i]);
6283 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6287 if (LocaleCompare("wave",option+1) == 0)
6290 if (i == (ssize_t) argc)
6291 ThrowMogrifyException(OptionError,"MissingArgument",option);
6292 if (IsGeometry(argv[i]) == MagickFalse)
6293 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6296 if (LocaleCompare("weight",option+1) == 0)
6301 if (i == (ssize_t) (argc-1))
6302 ThrowMogrifyException(OptionError,"MissingArgument",option);
6305 if (LocaleCompare("white-point",option+1) == 0)
6310 if (i == (ssize_t) argc)
6311 ThrowMogrifyException(OptionError,"MissingArgument",option);
6312 if (IsGeometry(argv[i]) == MagickFalse)
6313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6316 if (LocaleCompare("white-threshold",option+1) == 0)
6321 if (i == (ssize_t) argc)
6322 ThrowMogrifyException(OptionError,"MissingArgument",option);
6323 if (IsGeometry(argv[i]) == MagickFalse)
6324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6327 if (LocaleCompare("write",option+1) == 0)
6330 if (i == (ssize_t) (argc-1))
6331 ThrowMogrifyException(OptionError,"MissingArgument",option);
6334 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6339 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6341 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6342 MagickFalse : MagickTrue;
6343 if (fire != MagickFalse)
6344 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6347 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6348 if (i != (ssize_t) argc)
6349 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6351 return(status != 0 ? MagickTrue : MagickFalse);
6355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6359 + M o g r i f y I m a g e I n f o %
6363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6365 % MogrifyImageInfo() applies image processing settings to the image as
6366 % prescribed by command line options.
6368 % The format of the MogrifyImageInfo method is:
6370 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6371 % const char **argv,ExceptionInfo *exception)
6373 % A description of each parameter follows:
6375 % o image_info: the image info..
6377 % o argc: Specifies a pointer to an integer describing the number of
6378 % elements in the argument vector.
6380 % o argv: Specifies a pointer to a text array containing the command line
6383 % o exception: return any errors or warnings in this structure.
6386 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6387 const int argc,const char **argv,ExceptionInfo *exception)
6402 Initialize method variables.
6404 assert(image_info != (ImageInfo *) NULL);
6405 assert(image_info->signature == MagickSignature);
6406 if (image_info->debug != MagickFalse)
6407 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6408 image_info->filename);
6412 Set the image settings.
6414 for (i=0; i < (ssize_t) argc; i++)
6417 if (IsMagickOption(option) == MagickFalse)
6419 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6421 if ((i+count) >= (ssize_t) argc)
6423 switch (*(option+1))
6427 if (LocaleCompare("adjoin",option+1) == 0)
6429 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6432 if (LocaleCompare("antialias",option+1) == 0)
6434 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6437 if (LocaleCompare("attenuate",option+1) == 0)
6441 (void) DeleteImageOption(image_info,option+1);
6444 (void) SetImageOption(image_info,option+1,argv[i+1]);
6447 if (LocaleCompare("authenticate",option+1) == 0)
6450 (void) CloneString(&image_info->authenticate,(char *) NULL);
6452 (void) CloneString(&image_info->authenticate,argv[i+1]);
6459 if (LocaleCompare("background",option+1) == 0)
6463 (void) DeleteImageOption(image_info,option+1);
6464 (void) QueryColorDatabase(BackgroundColor,
6465 &image_info->background_color,exception);
6468 (void) SetImageOption(image_info,option+1,argv[i+1]);
6469 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6473 if (LocaleCompare("bias",option+1) == 0)
6477 (void) SetImageOption(image_info,option+1,"0.0");
6480 (void) SetImageOption(image_info,option+1,argv[i+1]);
6483 if (LocaleCompare("black-point-compensation",option+1) == 0)
6487 (void) SetImageOption(image_info,option+1,"false");
6490 (void) SetImageOption(image_info,option+1,"true");
6493 if (LocaleCompare("blue-primary",option+1) == 0)
6497 (void) SetImageOption(image_info,option+1,"0.0");
6500 (void) SetImageOption(image_info,option+1,argv[i+1]);
6503 if (LocaleCompare("bordercolor",option+1) == 0)
6507 (void) DeleteImageOption(image_info,option+1);
6508 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6512 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6514 (void) SetImageOption(image_info,option+1,argv[i+1]);
6517 if (LocaleCompare("box",option+1) == 0)
6521 (void) SetImageOption(image_info,"undercolor","none");
6524 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6531 if (LocaleCompare("cache",option+1) == 0)
6536 limit=MagickResourceInfinity;
6537 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6538 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6539 (void) SetMagickResourceLimit(MemoryResource,limit);
6540 (void) SetMagickResourceLimit(MapResource,2*limit);
6543 if (LocaleCompare("caption",option+1) == 0)
6547 (void) DeleteImageOption(image_info,option+1);
6550 (void) SetImageOption(image_info,option+1,argv[i+1]);
6553 if (LocaleCompare("channel",option+1) == 0)
6557 image_info->channel=DefaultChannels;
6560 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6563 if (LocaleCompare("colors",option+1) == 0)
6565 image_info->colors=StringToUnsignedLong(argv[i+1]);
6568 if (LocaleCompare("colorspace",option+1) == 0)
6572 image_info->colorspace=UndefinedColorspace;
6573 (void) SetImageOption(image_info,option+1,"undefined");
6576 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6577 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6578 (void) SetImageOption(image_info,option+1,argv[i+1]);
6581 if (LocaleCompare("compress",option+1) == 0)
6585 image_info->compression=UndefinedCompression;
6586 (void) SetImageOption(image_info,option+1,"undefined");
6589 image_info->compression=(CompressionType) ParseMagickOption(
6590 MagickCompressOptions,MagickFalse,argv[i+1]);
6591 (void) SetImageOption(image_info,option+1,argv[i+1]);
6594 if (LocaleCompare("comment",option+1) == 0)
6598 (void) DeleteImageOption(image_info,option+1);
6601 (void) SetImageOption(image_info,option+1,argv[i+1]);
6604 if (LocaleCompare("compose",option+1) == 0)
6608 (void) SetImageOption(image_info,option+1,"undefined");
6611 (void) SetImageOption(image_info,option+1,argv[i+1]);
6614 if (LocaleCompare("compress",option+1) == 0)
6618 image_info->compression=UndefinedCompression;
6619 (void) SetImageOption(image_info,option+1,"undefined");
6622 image_info->compression=(CompressionType) ParseMagickOption(
6623 MagickCompressOptions,MagickFalse,argv[i+1]);
6624 (void) SetImageOption(image_info,option+1,argv[i+1]);
6631 if (LocaleCompare("debug",option+1) == 0)
6634 (void) SetLogEventMask("none");
6636 (void) SetLogEventMask(argv[i+1]);
6637 image_info->debug=IsEventLogging();
6640 if (LocaleCompare("define",option+1) == 0)
6644 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6645 (void) DeleteImageRegistry(argv[i+1]+9);
6647 (void) DeleteImageOption(image_info,argv[i+1]);
6650 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6652 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6656 (void) DefineImageOption(image_info,argv[i+1]);
6659 if (LocaleCompare("delay",option+1) == 0)
6663 (void) SetImageOption(image_info,option+1,"0");
6666 (void) SetImageOption(image_info,option+1,argv[i+1]);
6669 if (LocaleCompare("density",option+1) == 0)
6676 if (image_info->density != (char *) NULL)
6677 image_info->density=DestroyString(image_info->density);
6678 (void) SetImageOption(image_info,option+1,"72");
6681 (void) CloneString(&image_info->density,argv[i+1]);
6682 (void) SetImageOption(image_info,option+1,argv[i+1]);
6685 if (LocaleCompare("depth",option+1) == 0)
6689 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6692 image_info->depth=StringToUnsignedLong(argv[i+1]);
6695 if (LocaleCompare("direction",option+1) == 0)
6699 (void) SetImageOption(image_info,option+1,"undefined");
6702 (void) SetImageOption(image_info,option+1,argv[i+1]);
6705 if (LocaleCompare("display",option+1) == 0)
6709 if (image_info->server_name != (char *) NULL)
6710 image_info->server_name=DestroyString(
6711 image_info->server_name);
6714 (void) CloneString(&image_info->server_name,argv[i+1]);
6717 if (LocaleCompare("dispose",option+1) == 0)
6721 (void) SetImageOption(image_info,option+1,"undefined");
6724 (void) SetImageOption(image_info,option+1,argv[i+1]);
6727 if (LocaleCompare("dither",option+1) == 0)
6731 image_info->dither=MagickFalse;
6732 (void) SetImageOption(image_info,option+1,"none");
6735 (void) SetImageOption(image_info,option+1,argv[i+1]);
6736 image_info->dither=MagickTrue;
6743 if (LocaleCompare("encoding",option+1) == 0)
6747 (void) SetImageOption(image_info,option+1,"undefined");
6750 (void) SetImageOption(image_info,option+1,argv[i+1]);
6753 if (LocaleCompare("endian",option+1) == 0)
6757 image_info->endian=UndefinedEndian;
6758 (void) SetImageOption(image_info,option+1,"undefined");
6761 image_info->endian=(EndianType) ParseMagickOption(
6762 MagickEndianOptions,MagickFalse,argv[i+1]);
6763 (void) SetImageOption(image_info,option+1,argv[i+1]);
6766 if (LocaleCompare("extract",option+1) == 0)
6769 Set image extract geometry.
6773 if (image_info->extract != (char *) NULL)
6774 image_info->extract=DestroyString(image_info->extract);
6777 (void) CloneString(&image_info->extract,argv[i+1]);
6784 if (LocaleCompare("fill",option+1) == 0)
6788 (void) SetImageOption(image_info,option+1,"none");
6791 (void) SetImageOption(image_info,option+1,argv[i+1]);
6794 if (LocaleCompare("filter",option+1) == 0)
6798 (void) SetImageOption(image_info,option+1,"undefined");
6801 (void) SetImageOption(image_info,option+1,argv[i+1]);
6804 if (LocaleCompare("font",option+1) == 0)
6808 if (image_info->font != (char *) NULL)
6809 image_info->font=DestroyString(image_info->font);
6812 (void) CloneString(&image_info->font,argv[i+1]);
6815 if (LocaleCompare("format",option+1) == 0)
6820 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6821 if (strchr("gkrz@[#",*(q+1)) != (char *) NULL)
6822 image_info->ping=MagickFalse;
6823 (void) SetImageOption(image_info,option+1,argv[i+1]);
6826 if (LocaleCompare("fuzz",option+1) == 0)
6830 image_info->fuzz=0.0;
6831 (void) SetImageOption(image_info,option+1,"0");
6834 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6836 (void) SetImageOption(image_info,option+1,argv[i+1]);
6843 if (LocaleCompare("gravity",option+1) == 0)
6847 (void) SetImageOption(image_info,option+1,"undefined");
6850 (void) SetImageOption(image_info,option+1,argv[i+1]);
6853 if (LocaleCompare("green-primary",option+1) == 0)
6857 (void) SetImageOption(image_info,option+1,"0.0");
6860 (void) SetImageOption(image_info,option+1,argv[i+1]);
6867 if (LocaleCompare("intent",option+1) == 0)
6871 (void) SetImageOption(image_info,option+1,"undefined");
6874 (void) SetImageOption(image_info,option+1,argv[i+1]);
6877 if (LocaleCompare("interlace",option+1) == 0)
6881 image_info->interlace=UndefinedInterlace;
6882 (void) SetImageOption(image_info,option+1,"undefined");
6885 image_info->interlace=(InterlaceType) ParseMagickOption(
6886 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6887 (void) SetImageOption(image_info,option+1,argv[i+1]);
6890 if (LocaleCompare("interline-spacing",option+1) == 0)
6894 (void) SetImageOption(image_info,option+1,"undefined");
6897 (void) SetImageOption(image_info,option+1,argv[i+1]);
6900 if (LocaleCompare("interpolate",option+1) == 0)
6904 (void) SetImageOption(image_info,option+1,"undefined");
6907 (void) SetImageOption(image_info,option+1,argv[i+1]);
6910 if (LocaleCompare("interword-spacing",option+1) == 0)
6914 (void) SetImageOption(image_info,option+1,"undefined");
6917 (void) SetImageOption(image_info,option+1,argv[i+1]);
6924 if (LocaleCompare("kerning",option+1) == 0)
6928 (void) SetImageOption(image_info,option+1,"undefined");
6931 (void) SetImageOption(image_info,option+1,argv[i+1]);
6938 if (LocaleCompare("label",option+1) == 0)
6942 (void) DeleteImageOption(image_info,option+1);
6945 (void) SetImageOption(image_info,option+1,argv[i+1]);
6948 if (LocaleCompare("limit",option+1) == 0)
6958 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
6959 MagickFalse,argv[i+1]);
6960 limit=MagickResourceInfinity;
6961 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6962 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6963 (void) SetMagickResourceLimit(type,limit);
6966 if (LocaleCompare("list",option+1) == 0)
6972 Display configuration list.
6974 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
6977 case MagickCoderOptions:
6979 (void) ListCoderInfo((FILE *) NULL,exception);
6982 case MagickColorOptions:
6984 (void) ListColorInfo((FILE *) NULL,exception);
6987 case MagickConfigureOptions:
6989 (void) ListConfigureInfo((FILE *) NULL,exception);
6992 case MagickDelegateOptions:
6994 (void) ListDelegateInfo((FILE *) NULL,exception);
6997 case MagickFontOptions:
6999 (void) ListTypeInfo((FILE *) NULL,exception);
7002 case MagickFormatOptions:
7004 (void) ListMagickInfo((FILE *) NULL,exception);
7007 case MagickLocaleOptions:
7009 (void) ListLocaleInfo((FILE *) NULL,exception);
7012 case MagickLogOptions:
7014 (void) ListLogInfo((FILE *) NULL,exception);
7017 case MagickMagicOptions:
7019 (void) ListMagicInfo((FILE *) NULL,exception);
7022 case MagickMimeOptions:
7024 (void) ListMimeInfo((FILE *) NULL,exception);
7027 case MagickModuleOptions:
7029 (void) ListModuleInfo((FILE *) NULL,exception);
7032 case MagickPolicyOptions:
7034 (void) ListPolicyInfo((FILE *) NULL,exception);
7037 case MagickResourceOptions:
7039 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7042 case MagickThresholdOptions:
7044 (void) ListThresholdMaps((FILE *) NULL,exception);
7049 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7056 if (LocaleCompare("log",option+1) == 0)
7060 (void) SetLogFormat(argv[i+1]);
7063 if (LocaleCompare("loop",option+1) == 0)
7067 (void) SetImageOption(image_info,option+1,"0");
7070 (void) SetImageOption(image_info,option+1,argv[i+1]);
7077 if (LocaleCompare("matte",option+1) == 0)
7081 (void) SetImageOption(image_info,option+1,"false");
7084 (void) SetImageOption(image_info,option+1,"true");
7087 if (LocaleCompare("mattecolor",option+1) == 0)
7091 (void) SetImageOption(image_info,option+1,argv[i+1]);
7092 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7096 (void) SetImageOption(image_info,option+1,argv[i+1]);
7097 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7101 if (LocaleCompare("monitor",option+1) == 0)
7103 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7107 if (LocaleCompare("monochrome",option+1) == 0)
7109 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7116 if (LocaleCompare("orient",option+1) == 0)
7120 image_info->orientation=UndefinedOrientation;
7121 (void) SetImageOption(image_info,option+1,"undefined");
7124 image_info->orientation=(OrientationType) ParseMagickOption(
7125 MagickOrientationOptions,MagickFalse,argv[i+1]);
7126 (void) SetImageOption(image_info,option+1,argv[i+1]);
7132 if (LocaleCompare("page",option+1) == 0)
7136 page[MaxTextExtent];
7149 (void) DeleteImageOption(image_info,option+1);
7150 (void) CloneString(&image_info->page,(char *) NULL);
7153 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7154 image_option=GetImageOption(image_info,"page");
7155 if (image_option != (const char *) NULL)
7156 flags=ParseAbsoluteGeometry(image_option,&geometry);
7157 canonical_page=GetPageGeometry(argv[i+1]);
7158 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7159 canonical_page=DestroyString(canonical_page);
7160 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
7161 (unsigned long) geometry.width,(unsigned long) geometry.height);
7162 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7163 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7164 (unsigned long) geometry.width,(unsigned long) geometry.height,
7165 (long) geometry.x,(long) geometry.y);
7166 (void) SetImageOption(image_info,option+1,page);
7167 (void) CloneString(&image_info->page,page);
7170 if (LocaleCompare("pen",option+1) == 0)
7174 (void) SetImageOption(image_info,option+1,"none");
7177 (void) SetImageOption(image_info,option+1,argv[i+1]);
7180 if (LocaleCompare("ping",option+1) == 0)
7182 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7185 if (LocaleCompare("pointsize",option+1) == 0)
7188 geometry_info.rho=0.0;
7190 (void) ParseGeometry(argv[i+1],&geometry_info);
7191 image_info->pointsize=geometry_info.rho;
7194 if (LocaleCompare("precision",option+1) == 0)
7196 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7199 if (LocaleCompare("preview",option+1) == 0)
7206 image_info->preview_type=UndefinedPreview;
7209 image_info->preview_type=(PreviewType) ParseMagickOption(
7210 MagickPreviewOptions,MagickFalse,argv[i+1]);
7217 if (LocaleCompare("quality",option+1) == 0)
7220 Set image compression quality.
7224 image_info->quality=UndefinedCompressionQuality;
7225 (void) SetImageOption(image_info,option+1,"0");
7228 image_info->quality=StringToUnsignedLong(argv[i+1]);
7229 (void) SetImageOption(image_info,option+1,argv[i+1]);
7232 if (LocaleCompare("quiet",option+1) == 0)
7234 static WarningHandler
7235 warning_handler = (WarningHandler) NULL;
7240 Restore error or warning messages.
7242 warning_handler=SetWarningHandler(warning_handler);
7246 Suppress error or warning messages.
7248 warning_handler=SetWarningHandler((WarningHandler) NULL);
7255 if (LocaleCompare("red-primary",option+1) == 0)
7259 (void) SetImageOption(image_info,option+1,"0.0");
7262 (void) SetImageOption(image_info,option+1,argv[i+1]);
7269 if (LocaleCompare("sampling-factor",option+1) == 0)
7272 Set image sampling factor.
7276 if (image_info->sampling_factor != (char *) NULL)
7277 image_info->sampling_factor=DestroyString(
7278 image_info->sampling_factor);
7281 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7284 if (LocaleCompare("scene",option+1) == 0)
7291 image_info->scene=0;
7292 (void) SetImageOption(image_info,option+1,"0");
7295 image_info->scene=StringToUnsignedLong(argv[i+1]);
7296 (void) SetImageOption(image_info,option+1,argv[i+1]);
7299 if (LocaleCompare("seed",option+1) == 0)
7306 seed=(size_t) time((time_t *) NULL);
7307 SeedPseudoRandomGenerator(seed);
7310 seed=StringToUnsignedLong(argv[i+1]);
7311 SeedPseudoRandomGenerator(seed);
7314 if (LocaleCompare("size",option+1) == 0)
7318 if (image_info->size != (char *) NULL)
7319 image_info->size=DestroyString(image_info->size);
7322 (void) CloneString(&image_info->size,argv[i+1]);
7325 if (LocaleCompare("stroke",option+1) == 0)
7329 (void) SetImageOption(image_info,option+1,"none");
7332 (void) SetImageOption(image_info,option+1,argv[i+1]);
7335 if (LocaleCompare("strokewidth",option+1) == 0)
7339 (void) SetImageOption(image_info,option+1,"0");
7342 (void) SetImageOption(image_info,option+1,argv[i+1]);
7349 if (LocaleCompare("taint",option+1) == 0)
7353 (void) SetImageOption(image_info,option+1,"false");
7356 (void) SetImageOption(image_info,option+1,"true");
7359 if (LocaleCompare("texture",option+1) == 0)
7363 if (image_info->texture != (char *) NULL)
7364 image_info->texture=DestroyString(image_info->texture);
7367 (void) CloneString(&image_info->texture,argv[i+1]);
7370 if (LocaleCompare("tile-offset",option+1) == 0)
7374 (void) SetImageOption(image_info,option+1,"0");
7377 (void) SetImageOption(image_info,option+1,argv[i+1]);
7380 if (LocaleCompare("transparent-color",option+1) == 0)
7384 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7385 (void) SetImageOption(image_info,option+1,"none");
7388 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7390 (void) SetImageOption(image_info,option+1,argv[i+1]);
7393 if (LocaleCompare("type",option+1) == 0)
7397 image_info->type=UndefinedType;
7398 (void) SetImageOption(image_info,option+1,"undefined");
7401 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7402 MagickFalse,argv[i+1]);
7403 (void) SetImageOption(image_info,option+1,argv[i+1]);
7410 if (LocaleCompare("undercolor",option+1) == 0)
7414 (void) DeleteImageOption(image_info,option+1);
7417 (void) SetImageOption(image_info,option+1,argv[i+1]);
7420 if (LocaleCompare("units",option+1) == 0)
7424 image_info->units=UndefinedResolution;
7425 (void) SetImageOption(image_info,option+1,"undefined");
7428 image_info->units=(ResolutionType) ParseMagickOption(
7429 MagickResolutionOptions,MagickFalse,argv[i+1]);
7430 (void) SetImageOption(image_info,option+1,argv[i+1]);
7437 if (LocaleCompare("verbose",option+1) == 0)
7441 image_info->verbose=MagickFalse;
7444 image_info->verbose=MagickTrue;
7445 image_info->ping=MagickFalse;
7448 if (LocaleCompare("view",option+1) == 0)
7452 if (image_info->view != (char *) NULL)
7453 image_info->view=DestroyString(image_info->view);
7456 (void) CloneString(&image_info->view,argv[i+1]);
7459 if (LocaleCompare("virtual-pixel",option+1) == 0)
7463 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7464 (void) SetImageOption(image_info,option+1,"undefined");
7467 image_info->virtual_pixel_method=(VirtualPixelMethod)
7468 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7470 (void) SetImageOption(image_info,option+1,argv[i+1]);
7477 if (LocaleCompare("white-point",option+1) == 0)
7481 (void) SetImageOption(image_info,option+1,"0.0");
7484 (void) SetImageOption(image_info,option+1,argv[i+1]);
7498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7502 + M o g r i f y I m a g e L i s t %
7506 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7508 % MogrifyImageList() applies any command line options that might affect the
7509 % entire image list (e.g. -append, -coalesce, etc.).
7511 % The format of the MogrifyImage method is:
7513 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7514 % const char **argv,Image **images,ExceptionInfo *exception)
7516 % A description of each parameter follows:
7518 % o image_info: the image info..
7520 % o argc: Specifies a pointer to an integer describing the number of
7521 % elements in the argument vector.
7523 % o argv: Specifies a pointer to a text array containing the command line
7526 % o images: the images.
7528 % o exception: return any errors or warnings in this structure.
7531 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7532 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7557 Apply options to the image list.
7559 assert(image_info != (ImageInfo *) NULL);
7560 assert(image_info->signature == MagickSignature);
7561 assert(images != (Image **) NULL);
7562 assert((*images)->signature == MagickSignature);
7563 if ((*images)->debug != MagickFalse)
7564 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7565 (*images)->filename);
7566 if ((argc <= 0) || (*argv == (char *) NULL))
7568 mogrify_info=CloneImageInfo(image_info);
7569 quantize_info=AcquireQuantizeInfo(mogrify_info);
7570 channel=mogrify_info->channel;
7572 for (i=0; i < (ssize_t) argc; i++)
7574 if (*images == (Image *) NULL)
7577 if (IsMagickOption(option) == MagickFalse)
7579 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7581 if ((i+count) >= (ssize_t) argc)
7583 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7584 switch (*(option+1))
7588 if (LocaleCompare("affinity",option+1) == 0)
7590 (void) SyncImagesSettings(mogrify_info,*images);
7593 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7594 InheritException(exception,&(*images)->exception);
7600 if (LocaleCompare("append",option+1) == 0)
7605 (void) SyncImagesSettings(mogrify_info,*images);
7606 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7607 MagickFalse,exception);
7608 if (append_image == (Image *) NULL)
7613 *images=DestroyImageList(*images);
7614 *images=append_image;
7617 if (LocaleCompare("average",option+1) == 0)
7623 Average an image sequence (deprecated).
7625 (void) SyncImagesSettings(mogrify_info,*images);
7626 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7628 if (average_image == (Image *) NULL)
7633 *images=DestroyImageList(*images);
7634 *images=average_image;
7641 if (LocaleCompare("channel",option+1) == 0)
7645 channel=DefaultChannels;
7648 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7651 if (LocaleCompare("clut",option+1) == 0)
7657 (void) SyncImagesSettings(mogrify_info,*images);
7658 image=RemoveFirstImageFromList(images);
7659 clut_image=RemoveFirstImageFromList(images);
7660 if (clut_image == (Image *) NULL)
7665 (void) ClutImageChannel(image,channel,clut_image);
7666 clut_image=DestroyImage(clut_image);
7667 InheritException(exception,&image->exception);
7668 *images=DestroyImageList(*images);
7672 if (LocaleCompare("coalesce",option+1) == 0)
7677 (void) SyncImagesSettings(mogrify_info,*images);
7678 coalesce_image=CoalesceImages(*images,exception);
7679 if (coalesce_image == (Image *) NULL)
7684 *images=DestroyImageList(*images);
7685 *images=coalesce_image;
7688 if (LocaleCompare("combine",option+1) == 0)
7693 (void) SyncImagesSettings(mogrify_info,*images);
7694 combine_image=CombineImages(*images,channel,exception);
7695 if (combine_image == (Image *) NULL)
7700 *images=DestroyImageList(*images);
7701 *images=combine_image;
7704 if (LocaleCompare("composite",option+1) == 0)
7714 (void) SyncImagesSettings(mogrify_info,*images);
7715 image=RemoveFirstImageFromList(images);
7716 composite_image=RemoveFirstImageFromList(images);
7717 if (composite_image == (Image *) NULL)
7722 (void) TransformImage(&composite_image,(char *) NULL,
7723 composite_image->geometry);
7724 SetGeometry(composite_image,&geometry);
7725 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7726 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7728 mask_image=RemoveFirstImageFromList(images);
7729 if (mask_image != (Image *) NULL)
7731 if ((image->compose == DisplaceCompositeOp) ||
7732 (image->compose == DistortCompositeOp))
7735 Merge Y displacement into X displacement image.
7737 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7739 mask_image=DestroyImage(mask_image);
7744 Set a blending mask for the composition.
7746 image->mask=mask_image;
7747 (void) NegateImage(image->mask,MagickFalse);
7750 (void) CompositeImageChannel(image,channel,image->compose,
7751 composite_image,geometry.x,geometry.y);
7752 if (image->mask != (Image *) NULL)
7753 image->mask=DestroyImage(image->mask);
7754 composite_image=DestroyImage(composite_image);
7755 InheritException(exception,&image->exception);
7756 *images=DestroyImageList(*images);
7760 if (LocaleCompare("crop",option+1) == 0)
7768 (void) SyncImagesSettings(mogrify_info,*images);
7769 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7770 if (((geometry.width == 0) && (geometry.height == 0)) ||
7771 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7773 (void) TransformImages(images,argv[i+1],(char *) NULL);
7774 InheritException(exception,&(*images)->exception);
7781 if (LocaleCompare("deconstruct",option+1) == 0)
7786 (void) SyncImagesSettings(mogrify_info,*images);
7787 deconstruct_image=DeconstructImages(*images,exception);
7788 if (deconstruct_image == (Image *) NULL)
7793 *images=DestroyImageList(*images);
7794 *images=deconstruct_image;
7797 if (LocaleCompare("delete",option+1) == 0)
7800 DeleteImages(images,"-1",exception);
7802 DeleteImages(images,argv[i+1],exception);
7805 if (LocaleCompare("dither",option+1) == 0)
7809 quantize_info->dither=MagickFalse;
7812 quantize_info->dither=MagickTrue;
7813 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7814 MagickDitherOptions,MagickFalse,argv[i+1]);
7821 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7826 MagickEvaluateOperator
7829 (void) SyncImageSettings(mogrify_info,*images);
7830 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7831 MagickFalse,argv[i+1]);
7832 evaluate_image=EvaluateImages(*images,op,exception);
7833 if (evaluate_image == (Image *) NULL)
7838 *images=DestroyImageList(*images);
7839 *images=evaluate_image;
7846 if (LocaleCompare("fft",option+1) == 0)
7852 Implements the discrete Fourier transform (DFT).
7854 (void) SyncImageSettings(mogrify_info,*images);
7855 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7856 MagickTrue : MagickFalse,exception);
7857 if (fourier_image == (Image *) NULL)
7859 *images=DestroyImage(*images);
7860 *images=fourier_image;
7863 if (LocaleCompare("flatten",option+1) == 0)
7868 (void) SyncImagesSettings(mogrify_info,*images);
7869 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7870 if (flatten_image == (Image *) NULL)
7872 *images=DestroyImageList(*images);
7873 *images=flatten_image;
7876 if (LocaleCompare("fx",option+1) == 0)
7881 (void) SyncImagesSettings(mogrify_info,*images);
7882 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7883 if (fx_image == (Image *) NULL)
7888 *images=DestroyImageList(*images);
7896 if (LocaleCompare("hald-clut",option+1) == 0)
7902 (void) SyncImagesSettings(mogrify_info,*images);
7903 image=RemoveFirstImageFromList(images);
7904 hald_image=RemoveFirstImageFromList(images);
7905 if (hald_image == (Image *) NULL)
7910 (void) HaldClutImageChannel(image,channel,hald_image);
7911 hald_image=DestroyImage(hald_image);
7912 InheritException(exception,&image->exception);
7913 if (*images != (Image *) NULL)
7914 *images=DestroyImageList(*images);
7922 if (LocaleCompare("ift",option+1) == 0)
7930 Implements the inverse fourier discrete Fourier transform (DFT).
7932 (void) SyncImagesSettings(mogrify_info,*images);
7933 magnitude_image=RemoveFirstImageFromList(images);
7934 phase_image=RemoveFirstImageFromList(images);
7935 if (phase_image == (Image *) NULL)
7940 fourier_image=InverseFourierTransformImage(magnitude_image,
7941 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7942 if (fourier_image == (Image *) NULL)
7944 if (*images != (Image *) NULL)
7945 *images=DestroyImage(*images);
7946 *images=fourier_image;
7949 if (LocaleCompare("insert",option+1) == 0)
7957 index=StringToLong(argv[i+1]);
7958 p=RemoveLastImageFromList(images);
7959 if (p == (Image *) NULL)
7961 (void) ThrowMagickException(exception,GetMagickModule(),
7962 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7968 PrependImageToList(images,q);
7970 if (index == (ssize_t) GetImageListLength(*images))
7971 AppendImageToList(images,q);
7974 q=GetImageFromList(*images,index-1);
7975 if (q == (Image *) NULL)
7977 (void) ThrowMagickException(exception,GetMagickModule(),
7978 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7982 InsertImageInList(&q,p);
7984 *images=GetFirstImageInList(q);
7991 if (LocaleCompare("layers",option+1) == 0)
7999 (void) SyncImagesSettings(mogrify_info,*images);
8000 layers=(Image *) NULL;
8001 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
8002 MagickFalse,argv[i+1]);
8007 layers=CoalesceImages(*images,exception);
8010 case CompareAnyLayer:
8011 case CompareClearLayer:
8012 case CompareOverlayLayer:
8015 layers=CompareImageLayers(*images,method,exception);
8021 case TrimBoundsLayer:
8023 layers=MergeImageLayers(*images,method,exception);
8028 layers=DisposeImages(*images,exception);
8031 case OptimizeImageLayer:
8033 layers=OptimizeImageLayers(*images,exception);
8036 case OptimizePlusLayer:
8038 layers=OptimizePlusImageLayers(*images,exception);
8041 case OptimizeTransLayer:
8043 OptimizeImageTransparency(*images,exception);
8046 case RemoveDupsLayer:
8048 RemoveDuplicateLayers(images,exception);
8051 case RemoveZeroLayer:
8053 RemoveZeroDelayLayers(images,exception);
8059 General Purpose, GIF Animation Optimizer.
8061 layers=CoalesceImages(*images,exception);
8062 if (layers == (Image *) NULL)
8067 InheritException(exception,&layers->exception);
8068 *images=DestroyImageList(*images);
8070 layers=OptimizeImageLayers(*images,exception);
8071 if (layers == (Image *) NULL)
8076 InheritException(exception,&layers->exception);
8077 *images=DestroyImageList(*images);
8079 layers=(Image *) NULL;
8080 OptimizeImageTransparency(*images,exception);
8081 InheritException(exception,&(*images)->exception);
8082 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8085 case CompositeLayer:
8097 Split image sequence at the first 'NULL:' image.
8100 while (source != (Image *) NULL)
8102 source=GetNextImageInList(source);
8103 if ((source != (Image *) NULL) &&
8104 (LocaleCompare(source->magick,"NULL") == 0))
8107 if (source != (Image *) NULL)
8109 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8110 (GetNextImageInList(source) == (Image *) NULL))
8111 source=(Image *) NULL;
8115 Separate the two lists, junk the null: image.
8117 source=SplitImageList(source->previous);
8118 DeleteImageFromList(&source);
8121 if (source == (Image *) NULL)
8123 (void) ThrowMagickException(exception,GetMagickModule(),
8124 OptionError,"MissingNullSeparator","layers Composite");
8129 Adjust offset with gravity and virtual canvas.
8131 SetGeometry(*images,&geometry);
8132 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8133 geometry.width=source->page.width != 0 ?
8134 source->page.width : source->columns;
8135 geometry.height=source->page.height != 0 ?
8136 source->page.height : source->rows;
8137 GravityAdjustGeometry((*images)->page.width != 0 ?
8138 (*images)->page.width : (*images)->columns,
8139 (*images)->page.height != 0 ? (*images)->page.height :
8140 (*images)->rows,(*images)->gravity,&geometry);
8141 compose=OverCompositeOp;
8142 option=GetImageOption(mogrify_info,"compose");
8143 if (option != (const char *) NULL)
8144 compose=(CompositeOperator) ParseMagickOption(
8145 MagickComposeOptions,MagickFalse,option);
8146 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8148 source=DestroyImageList(source);
8152 if (layers == (Image *) NULL)
8154 InheritException(exception,&layers->exception);
8155 *images=DestroyImageList(*images);
8163 if (LocaleCompare("map",option+1) == 0)
8165 (void) SyncImagesSettings(mogrify_info,*images);
8168 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8169 InheritException(exception,&(*images)->exception);
8175 if (LocaleCompare("maximum",option+1) == 0)
8181 Maximum image sequence (deprecated).
8183 (void) SyncImagesSettings(mogrify_info,*images);
8184 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8185 if (maximum_image == (Image *) NULL)
8190 *images=DestroyImageList(*images);
8191 *images=maximum_image;
8194 if (LocaleCompare("minimum",option+1) == 0)
8200 Minimum image sequence (deprecated).
8202 (void) SyncImagesSettings(mogrify_info,*images);
8203 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8204 if (minimum_image == (Image *) NULL)
8209 *images=DestroyImageList(*images);
8210 *images=minimum_image;
8213 if (LocaleCompare("morph",option+1) == 0)
8218 (void) SyncImagesSettings(mogrify_info,*images);
8219 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8221 if (morph_image == (Image *) NULL)
8226 *images=DestroyImageList(*images);
8227 *images=morph_image;
8230 if (LocaleCompare("mosaic",option+1) == 0)
8235 (void) SyncImagesSettings(mogrify_info,*images);
8236 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8237 if (mosaic_image == (Image *) NULL)
8242 *images=DestroyImageList(*images);
8243 *images=mosaic_image;
8250 if (LocaleCompare("print",option+1) == 0)
8255 (void) SyncImagesSettings(mogrify_info,*images);
8256 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8257 if (string == (char *) NULL)
8259 InheritException(exception,&(*images)->exception);
8260 (void) fprintf(stdout,"%s",string);
8261 string=DestroyString(string);
8263 if (LocaleCompare("process",option+1) == 0)
8272 (void) SyncImagesSettings(mogrify_info,*images);
8273 arguments=StringToArgv(argv[i+1],&number_arguments);
8274 if (arguments == (char **) NULL)
8276 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8297 Support old style syntax, filter="-option arg".
8299 length=strlen(argv[i+1]);
8300 token=(char *) NULL;
8301 if (~length >= MaxTextExtent)
8302 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8304 if (token == (char *) NULL)
8307 arguments=argv[i+1];
8308 token_info=AcquireTokenInfo();
8309 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8310 "\"",'\0',&breaker,&next,"e);
8311 token_info=DestroyTokenInfo(token_info);
8317 argv=(&(arguments[next]));
8318 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8321 token=DestroyString(token);
8324 (void) SubstituteString(&arguments[1],"-","");
8325 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8326 number_arguments-2,(const char **) arguments+2,exception);
8327 for (j=0; j < number_arguments; j++)
8328 arguments[j]=DestroyString(arguments[j]);
8329 arguments=(char **) RelinquishMagickMemory(arguments);
8336 if (LocaleCompare("reverse",option+1) == 0)
8338 ReverseImageList(images);
8339 InheritException(exception,&(*images)->exception);
8346 if (LocaleCompare("swap",option+1) == 0)
8367 flags=ParseGeometry(argv[i+1],&geometry_info);
8368 index=(ssize_t) geometry_info.rho;
8369 if ((flags & SigmaValue) != 0)
8370 swap_index=(ssize_t) geometry_info.sigma;
8372 p=GetImageFromList(*images,index);
8373 q=GetImageFromList(*images,swap_index);
8374 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8376 (void) ThrowMagickException(exception,GetMagickModule(),
8377 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8383 swap=CloneImage(p,0,0,MagickTrue,exception);
8384 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8385 ReplaceImageInList(&q,swap);
8386 *images=GetFirstImageInList(q);
8393 if (LocaleCompare("write",option+1) == 0)
8404 (void) SyncImagesSettings(mogrify_info,*images);
8405 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8406 (void) DeleteImageRegistry(key);
8407 write_images=(*images);
8409 write_images=CloneImageList(*images,exception);
8410 write_info=CloneImageInfo(mogrify_info);
8411 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8412 write_info=DestroyImageInfo(write_info);
8414 write_images=DestroyImageList(write_images);
8424 quantize_info=DestroyQuantizeInfo(quantize_info);
8425 mogrify_info=DestroyImageInfo(mogrify_info);
8426 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8427 return(status != 0 ? MagickTrue : MagickFalse);
8431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8435 + M o g r i f y I m a g e s %
8439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8441 % MogrifyImages() applies image processing options to a sequence of images as
8442 % prescribed by command line options.
8444 % The format of the MogrifyImage method is:
8446 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8447 % const MagickBooleanType post,const int argc,const char **argv,
8448 % Image **images,Exceptioninfo *exception)
8450 % A description of each parameter follows:
8452 % o image_info: the image info..
8454 % o post: If true, post process image list operators otherwise pre-process.
8456 % o argc: Specifies a pointer to an integer describing the number of
8457 % elements in the argument vector.
8459 % o argv: Specifies a pointer to a text array containing the command line
8462 % o images: the images.
8464 % o exception: return any errors or warnings in this structure.
8467 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8468 const MagickBooleanType post,const int argc,const char **argv,
8469 Image **images,ExceptionInfo *exception)
8471 #define MogrifyImageTag "Mogrify/Image"
8490 Apply options to individual images in the list.
8492 assert(image_info != (ImageInfo *) NULL);
8493 assert(image_info->signature == MagickSignature);
8494 if (images == (Image **) NULL)
8495 return(MogrifyImage(image_info,argc,argv,images,exception));
8496 assert((*images)->signature == MagickSignature);
8497 if ((*images)->debug != MagickFalse)
8498 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8499 (*images)->filename);
8500 if ((argc <= 0) || (*argv == (char *) NULL))
8502 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8504 mogrify_images=NewImageList();
8505 number_images=GetImageListLength(*images);
8507 if (post == MagickFalse)
8508 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8509 for (i=0; i < (ssize_t) number_images; i++)
8511 image=RemoveFirstImageFromList(images);
8512 if (image == (Image *) NULL)
8514 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8515 AppendImageToList(&mogrify_images,image);
8516 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8518 if (proceed == MagickFalse)
8521 if (post != MagickFalse)
8522 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8523 *images=mogrify_images;
8524 return(status != 0 ? MagickTrue : MagickFalse);