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)
1075 register PixelPacket
1078 (void) SyncImageSettings(mogrify_info,*image);
1084 (void) SetImageMask(*image,(Image *) NULL);
1085 InheritException(exception,&(*image)->exception);
1091 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1092 if (mask_image == (Image *) NULL)
1094 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1095 return(MagickFalse);
1096 mask_view=AcquireCacheView(mask_image);
1097 for (y=0; y < (ssize_t) mask_image->rows; y++)
1099 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1101 if (q == (PixelPacket *) NULL)
1103 for (x=0; x < (ssize_t) mask_image->columns; x++)
1105 if (mask_image->matte == MagickFalse)
1106 q->opacity=PixelIntensityToQuantum(q);
1108 q->green=q->opacity;
1112 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1115 mask_view=DestroyCacheView(mask_view);
1116 mask_image->matte=MagickTrue;
1117 (void) SetImageClipMask(*image,mask_image);
1118 mask_image=DestroyImage(mask_image);
1119 InheritException(exception,&(*image)->exception);
1122 if (LocaleCompare("clip-path",option+1) == 0)
1124 (void) SyncImageSettings(mogrify_info,*image);
1125 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1127 InheritException(exception,&(*image)->exception);
1130 if (LocaleCompare("colorize",option+1) == 0)
1138 (void) SyncImageSettings(mogrify_info,*image);
1139 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1141 if (colorize_image == (Image *) NULL)
1143 *image=DestroyImage(*image);
1144 *image=colorize_image;
1147 if (LocaleCompare("color-matrix",option+1) == 0)
1155 (void) SyncImageSettings(mogrify_info,*image);
1156 kernel=AcquireKernelInfo(argv[i+1]);
1157 if (kernel == (KernelInfo *) NULL)
1159 color_image=ColorMatrixImage(*image,kernel,exception);
1160 kernel=DestroyKernelInfo(kernel);
1161 if (color_image == (Image *) NULL)
1163 *image=DestroyImage(*image);
1167 if (LocaleCompare("colors",option+1) == 0)
1170 Reduce the number of colors in the image.
1172 (void) SyncImageSettings(mogrify_info,*image);
1173 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1174 if (quantize_info->number_colors == 0)
1176 if (((*image)->storage_class == DirectClass) ||
1177 (*image)->colors > quantize_info->number_colors)
1178 (void) QuantizeImage(quantize_info,*image);
1180 (void) CompressImageColormap(*image);
1181 InheritException(exception,&(*image)->exception);
1184 if (LocaleCompare("colorspace",option+1) == 0)
1189 (void) SyncImageSettings(mogrify_info,*image);
1192 (void) TransformImageColorspace(*image,RGBColorspace);
1193 InheritException(exception,&(*image)->exception);
1196 colorspace=(ColorspaceType) ParseMagickOption(
1197 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1198 (void) TransformImageColorspace(*image,colorspace);
1199 InheritException(exception,&(*image)->exception);
1202 if (LocaleCompare("contrast",option+1) == 0)
1204 (void) SyncImageSettings(mogrify_info,*image);
1205 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1207 InheritException(exception,&(*image)->exception);
1210 if (LocaleCompare("contrast-stretch",option+1) == 0)
1220 Contrast stretch image.
1222 (void) SyncImageSettings(mogrify_info,*image);
1223 flags=ParseGeometry(argv[i+1],&geometry_info);
1224 black_point=geometry_info.rho;
1225 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1227 if ((flags & PercentValue) != 0)
1229 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1230 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1232 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1234 (void) ContrastStretchImageChannel(*image,channel,black_point,
1236 InheritException(exception,&(*image)->exception);
1239 if (LocaleCompare("convolve",option+1) == 0)
1253 (void) SyncImageSettings(mogrify_info,*image);
1254 kernel=AcquireKernelInfo(argv[i+1]);
1255 if (kernel == (KernelInfo *) NULL)
1258 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1259 gamma+=kernel->values[j];
1260 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1261 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1262 kernel->values[j]*=gamma;
1263 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
1264 kernel=DestroyKernelInfo(kernel);
1265 if (convolve_image == (Image *) NULL)
1267 *image=DestroyImage(*image);
1268 *image=convolve_image;
1271 if (LocaleCompare("crop",option+1) == 0)
1273 (void) SyncImageSettings(mogrify_info,*image);
1274 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1275 if (((geometry.width != 0) || (geometry.height != 0)) &&
1276 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1278 (void) TransformImage(image,argv[i+1],(char *) NULL);
1279 InheritException(exception,&(*image)->exception);
1282 if (LocaleCompare("cycle",option+1) == 0)
1285 Cycle an image colormap.
1287 (void) SyncImageSettings(mogrify_info,*image);
1288 (void) CycleColormapImage(*image,StringToLong(argv[i+1]));
1289 InheritException(exception,&(*image)->exception);
1296 if (LocaleCompare("decipher",option+1) == 0)
1304 (void) SyncImageSettings(mogrify_info,*image);
1305 passkey=FileToStringInfo(argv[i+1],~0,exception);
1306 if (passkey != (StringInfo *) NULL)
1308 (void) PasskeyDecipherImage(*image,passkey,exception);
1309 passkey=DestroyStringInfo(passkey);
1313 if (LocaleCompare("density",option+1) == 0)
1318 (void) CloneString(&draw_info->density,argv[i+1]);
1321 if (LocaleCompare("depth",option+1) == 0)
1323 (void) SyncImageSettings(mogrify_info,*image);
1326 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1329 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1332 if (LocaleCompare("deskew",option+1) == 0)
1341 Straighten the image.
1343 (void) SyncImageSettings(mogrify_info,*image);
1345 threshold=40.0*QuantumRange/100.0;
1347 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1348 deskew_image=DeskewImage(*image,threshold,exception);
1349 if (deskew_image == (Image *) NULL)
1351 *image=DestroyImage(*image);
1352 *image=deskew_image;
1355 if (LocaleCompare("despeckle",option+1) == 0)
1361 Reduce the speckles within an image.
1363 (void) SyncImageSettings(mogrify_info,*image);
1364 despeckle_image=DespeckleImage(*image,exception);
1365 if (despeckle_image == (Image *) NULL)
1367 *image=DestroyImage(*image);
1368 *image=despeckle_image;
1371 if (LocaleCompare("display",option+1) == 0)
1373 (void) CloneString(&draw_info->server_name,argv[i+1]);
1376 if (LocaleCompare("distort",option+1) == 0)
1380 token[MaxTextExtent];
1403 (void) SyncImageSettings(mogrify_info,*image);
1404 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1405 MagickFalse,argv[i+1]);
1406 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1407 InheritException(exception,&(*image)->exception);
1408 if (args == (char *) NULL)
1411 for (x=0; *p != '\0'; x++)
1413 GetMagickToken(p,&p,token);
1415 GetMagickToken(p,&p,token);
1417 number_arguments=(size_t) x;
1418 arguments=(double *) AcquireQuantumMemory(number_arguments,
1419 sizeof(*arguments));
1420 if (arguments == (double *) NULL)
1421 ThrowWandFatalException(ResourceLimitFatalError,
1422 "MemoryAllocationFailed",(*image)->filename);
1423 (void) ResetMagickMemory(arguments,0,number_arguments*
1424 sizeof(*arguments));
1426 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1428 GetMagickToken(p,&p,token);
1430 GetMagickToken(p,&p,token);
1431 arguments[x]=StringToDouble(token);
1433 args=DestroyString(args);
1434 distort_image=DistortImage(*image,method,number_arguments,arguments,
1435 (*option == '+') ? MagickTrue : MagickFalse,exception);
1436 arguments=(double *) RelinquishMagickMemory(arguments);
1437 if (distort_image == (Image *) NULL)
1439 *image=DestroyImage(*image);
1440 *image=distort_image;
1443 if (LocaleCompare("dither",option+1) == 0)
1447 quantize_info->dither=MagickFalse;
1450 quantize_info->dither=MagickTrue;
1451 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
1452 MagickDitherOptions,MagickFalse,argv[i+1]);
1453 if (quantize_info->dither_method == NoDitherMethod)
1454 quantize_info->dither=MagickFalse;
1457 if (LocaleCompare("draw",option+1) == 0)
1462 (void) SyncImageSettings(mogrify_info,*image);
1463 (void) CloneString(&draw_info->primitive,argv[i+1]);
1464 (void) DrawImage(*image,draw_info);
1465 InheritException(exception,&(*image)->exception);
1472 if (LocaleCompare("edge",option+1) == 0)
1478 Enhance edges in the image.
1480 (void) SyncImageSettings(mogrify_info,*image);
1481 flags=ParseGeometry(argv[i+1],&geometry_info);
1482 if ((flags & SigmaValue) == 0)
1483 geometry_info.sigma=1.0;
1484 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1485 if (edge_image == (Image *) NULL)
1487 *image=DestroyImage(*image);
1491 if (LocaleCompare("emboss",option+1) == 0)
1497 Gaussian embossen image.
1499 (void) SyncImageSettings(mogrify_info,*image);
1500 flags=ParseGeometry(argv[i+1],&geometry_info);
1501 if ((flags & SigmaValue) == 0)
1502 geometry_info.sigma=1.0;
1503 emboss_image=EmbossImage(*image,geometry_info.rho,
1504 geometry_info.sigma,exception);
1505 if (emboss_image == (Image *) NULL)
1507 *image=DestroyImage(*image);
1508 *image=emboss_image;
1511 if (LocaleCompare("encipher",option+1) == 0)
1519 (void) SyncImageSettings(mogrify_info,*image);
1520 passkey=FileToStringInfo(argv[i+1],~0,exception);
1521 if (passkey != (StringInfo *) NULL)
1523 (void) PasskeyEncipherImage(*image,passkey,exception);
1524 passkey=DestroyStringInfo(passkey);
1528 if (LocaleCompare("encoding",option+1) == 0)
1530 (void) CloneString(&draw_info->encoding,argv[i+1]);
1533 if (LocaleCompare("enhance",option+1) == 0)
1541 (void) SyncImageSettings(mogrify_info,*image);
1542 enhance_image=EnhanceImage(*image,exception);
1543 if (enhance_image == (Image *) NULL)
1545 *image=DestroyImage(*image);
1546 *image=enhance_image;
1549 if (LocaleCompare("equalize",option+1) == 0)
1554 (void) SyncImageSettings(mogrify_info,*image);
1555 (void) EqualizeImageChannel(*image,channel);
1556 InheritException(exception,&(*image)->exception);
1559 if (LocaleCompare("evaluate",option+1) == 0)
1564 MagickEvaluateOperator
1567 (void) SyncImageSettings(mogrify_info,*image);
1568 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1569 MagickFalse,argv[i+1]);
1570 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1571 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1574 if (LocaleCompare("extent",option+1) == 0)
1580 Set the image extent.
1582 (void) SyncImageSettings(mogrify_info,*image);
1583 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1584 if (geometry.width == 0)
1585 geometry.width=(*image)->columns;
1586 if (geometry.height == 0)
1587 geometry.height=(*image)->rows;
1588 extent_image=ExtentImage(*image,&geometry,exception);
1589 if (extent_image == (Image *) NULL)
1591 *image=DestroyImage(*image);
1592 *image=extent_image;
1599 if (LocaleCompare("family",option+1) == 0)
1603 if (draw_info->family != (char *) NULL)
1604 draw_info->family=DestroyString(draw_info->family);
1607 (void) CloneString(&draw_info->family,argv[i+1]);
1610 if (LocaleCompare("features",option+1) == 0)
1614 (void) DeleteImageArtifact(*image,"identify:features");
1617 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1620 if (LocaleCompare("fill",option+1) == 0)
1625 GetMagickPixelPacket(*image,&fill);
1628 (void) QueryMagickColor("none",&fill,exception);
1629 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1630 if (draw_info->fill_pattern != (Image *) NULL)
1631 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1634 sans=AcquireExceptionInfo();
1635 (void) QueryMagickColor(argv[i+1],&fill,sans);
1636 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1637 sans=DestroyExceptionInfo(sans);
1638 if (status == MagickFalse)
1639 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1643 if (LocaleCompare("flip",option+1) == 0)
1649 Flip image scanlines.
1651 (void) SyncImageSettings(mogrify_info,*image);
1652 flip_image=FlipImage(*image,exception);
1653 if (flip_image == (Image *) NULL)
1655 *image=DestroyImage(*image);
1659 if (LocaleCompare("flop",option+1) == 0)
1665 Flop image scanlines.
1667 (void) SyncImageSettings(mogrify_info,*image);
1668 flop_image=FlopImage(*image,exception);
1669 if (flop_image == (Image *) NULL)
1671 *image=DestroyImage(*image);
1675 if (LocaleCompare("floodfill",option+1) == 0)
1683 (void) SyncImageSettings(mogrify_info,*image);
1684 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1685 (void) QueryMagickColor(argv[i+2],&target,exception);
1686 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1687 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1688 InheritException(exception,&(*image)->exception);
1691 if (LocaleCompare("font",option+1) == 0)
1695 if (draw_info->font != (char *) NULL)
1696 draw_info->font=DestroyString(draw_info->font);
1699 (void) CloneString(&draw_info->font,argv[i+1]);
1702 if (LocaleCompare("format",option+1) == 0)
1707 if (LocaleCompare("frame",option+1) == 0)
1716 Surround image with an ornamental border.
1718 (void) SyncImageSettings(mogrify_info,*image);
1719 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1720 frame_info.width=geometry.width;
1721 frame_info.height=geometry.height;
1722 if ((flags & HeightValue) == 0)
1723 frame_info.height=geometry.width;
1724 frame_info.outer_bevel=geometry.x;
1725 frame_info.inner_bevel=geometry.y;
1726 frame_info.x=(ssize_t) frame_info.width;
1727 frame_info.y=(ssize_t) frame_info.height;
1728 frame_info.width=(*image)->columns+2*frame_info.width;
1729 frame_info.height=(*image)->rows+2*frame_info.height;
1730 frame_image=FrameImage(*image,&frame_info,exception);
1731 if (frame_image == (Image *) NULL)
1733 *image=DestroyImage(*image);
1737 if (LocaleCompare("function",option+1) == 0)
1741 token[MaxTextExtent];
1759 Function Modify Image Values
1761 (void) SyncImageSettings(mogrify_info,*image);
1762 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1763 MagickFalse,argv[i+1]);
1764 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1765 InheritException(exception,&(*image)->exception);
1766 if (arguments == (char *) NULL)
1768 p=(char *) arguments;
1769 for (x=0; *p != '\0'; x++)
1771 GetMagickToken(p,&p,token);
1773 GetMagickToken(p,&p,token);
1775 number_parameters=(size_t) x;
1776 parameters=(double *) AcquireQuantumMemory(number_parameters,
1777 sizeof(*parameters));
1778 if (parameters == (double *) NULL)
1779 ThrowWandFatalException(ResourceLimitFatalError,
1780 "MemoryAllocationFailed",(*image)->filename);
1781 (void) ResetMagickMemory(parameters,0,number_parameters*
1782 sizeof(*parameters));
1783 p=(char *) arguments;
1784 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1786 GetMagickToken(p,&p,token);
1788 GetMagickToken(p,&p,token);
1789 parameters[x]=StringToDouble(token);
1791 arguments=DestroyString(arguments);
1792 (void) FunctionImageChannel(*image,channel,function,
1793 number_parameters,parameters,exception);
1794 parameters=(double *) RelinquishMagickMemory(parameters);
1801 if (LocaleCompare("gamma",option+1) == 0)
1806 (void) SyncImageSettings(mogrify_info,*image);
1808 (*image)->gamma=StringToDouble(argv[i+1]);
1811 if (strchr(argv[i+1],',') != (char *) NULL)
1812 (void) GammaImage(*image,argv[i+1]);
1814 (void) GammaImageChannel(*image,channel,
1815 StringToDouble(argv[i+1]));
1816 InheritException(exception,&(*image)->exception);
1820 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1821 (LocaleCompare("gaussian",option+1) == 0))
1827 Gaussian blur image.
1829 (void) SyncImageSettings(mogrify_info,*image);
1830 flags=ParseGeometry(argv[i+1],&geometry_info);
1831 if ((flags & SigmaValue) == 0)
1832 geometry_info.sigma=1.0;
1833 gaussian_image=GaussianBlurImageChannel(*image,channel,
1834 geometry_info.rho,geometry_info.sigma,exception);
1835 if (gaussian_image == (Image *) NULL)
1837 *image=DestroyImage(*image);
1838 *image=gaussian_image;
1841 if (LocaleCompare("geometry",option+1) == 0)
1843 (void) SyncImageSettings(mogrify_info,*image);
1846 if ((*image)->geometry != (char *) NULL)
1847 (*image)->geometry=DestroyString((*image)->geometry);
1850 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1851 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1852 (void) CloneString(&(*image)->geometry,argv[i+1]);
1861 resize_image=ResizeImage(*image,geometry.width,geometry.height,
1862 (*image)->filter,(*image)->blur,exception);
1863 if (resize_image == (Image *) NULL)
1865 *image=DestroyImage(*image);
1866 *image=resize_image;
1870 if (LocaleCompare("gravity",option+1) == 0)
1874 draw_info->gravity=UndefinedGravity;
1877 draw_info->gravity=(GravityType) ParseMagickOption(
1878 MagickGravityOptions,MagickFalse,argv[i+1]);
1885 if (LocaleCompare("highlight-color",option+1) == 0)
1887 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1894 if (LocaleCompare("identify",option+1) == 0)
1899 (void) SyncImageSettings(mogrify_info,*image);
1900 if (format == (char *) NULL)
1902 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1903 InheritException(exception,&(*image)->exception);
1906 text=InterpretImageProperties(mogrify_info,*image,format);
1907 InheritException(exception,&(*image)->exception);
1908 if (text == (char *) NULL)
1910 (void) fputs(text,stdout);
1911 (void) fputc('\n',stdout);
1912 text=DestroyString(text);
1915 if (LocaleCompare("implode",option+1) == 0)
1923 (void) SyncImageSettings(mogrify_info,*image);
1924 (void) ParseGeometry(argv[i+1],&geometry_info);
1925 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1926 if (implode_image == (Image *) NULL)
1928 *image=DestroyImage(*image);
1929 *image=implode_image;
1932 if (LocaleCompare("interline-spacing",option+1) == 0)
1935 (void) ParseGeometry("0",&geometry_info);
1937 (void) ParseGeometry(argv[i+1],&geometry_info);
1938 draw_info->interline_spacing=geometry_info.rho;
1941 if (LocaleCompare("interword-spacing",option+1) == 0)
1944 (void) ParseGeometry("0",&geometry_info);
1946 (void) ParseGeometry(argv[i+1],&geometry_info);
1947 draw_info->interword_spacing=geometry_info.rho;
1954 if (LocaleCompare("kerning",option+1) == 0)
1957 (void) ParseGeometry("0",&geometry_info);
1959 (void) ParseGeometry(argv[i+1],&geometry_info);
1960 draw_info->kerning=geometry_info.rho;
1967 if (LocaleCompare("lat",option+1) == 0)
1973 Local adaptive threshold image.
1975 (void) SyncImageSettings(mogrify_info,*image);
1976 flags=ParseGeometry(argv[i+1],&geometry_info);
1977 if ((flags & PercentValue) != 0)
1978 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1979 threshold_image=AdaptiveThresholdImage(*image,(size_t)
1980 geometry_info.rho,(size_t) geometry_info.sigma,
1981 (ssize_t) geometry_info.xi,exception);
1982 if (threshold_image == (Image *) NULL)
1984 *image=DestroyImage(*image);
1985 *image=threshold_image;
1988 if (LocaleCompare("level",option+1) == 0)
2001 (void) SyncImageSettings(mogrify_info,*image);
2002 flags=ParseGeometry(argv[i+1],&geometry_info);
2003 black_point=geometry_info.rho;
2004 white_point=(MagickRealType) QuantumRange;
2005 if ((flags & SigmaValue) != 0)
2006 white_point=geometry_info.sigma;
2008 if ((flags & XiValue) != 0)
2009 gamma=geometry_info.xi;
2010 if ((flags & PercentValue) != 0)
2012 black_point*=(MagickRealType) (QuantumRange/100.0);
2013 white_point*=(MagickRealType) (QuantumRange/100.0);
2015 if ((flags & SigmaValue) == 0)
2016 white_point=(MagickRealType) QuantumRange-black_point;
2017 if ((*option == '+') || ((flags & AspectValue) != 0))
2018 (void) LevelizeImageChannel(*image,channel,black_point,
2021 (void) LevelImageChannel(*image,channel,black_point,white_point,
2023 InheritException(exception,&(*image)->exception);
2026 if (LocaleCompare("level-colors",option+1) == 0)
2029 token[MaxTextExtent];
2038 p=(const char *) argv[i+1];
2039 GetMagickToken(p,&p,token); /* get black point color */
2040 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2041 (void) QueryMagickColor(token,&black_point,exception);
2043 (void) QueryMagickColor("#000000",&black_point,exception);
2044 if (isalpha((int) token[0]) || (token[0] == '#'))
2045 GetMagickToken(p,&p,token);
2047 white_point=black_point; /* set everything to that color */
2051 Get white point color.
2053 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2054 GetMagickToken(p,&p,token);
2055 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2056 (void) QueryMagickColor(token,&white_point,exception);
2058 (void) QueryMagickColor("#ffffff",&white_point,exception);
2060 (void) LevelColorsImageChannel(*image,channel,&black_point,
2061 &white_point,*option == '+' ? MagickTrue : MagickFalse);
2064 if (LocaleCompare("linear-stretch",option+1) == 0)
2073 (void) SyncImageSettings(mogrify_info,*image);
2074 flags=ParseGeometry(argv[i+1],&geometry_info);
2075 black_point=geometry_info.rho;
2076 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2077 if ((flags & SigmaValue) != 0)
2078 white_point=geometry_info.sigma;
2079 if ((flags & PercentValue) != 0)
2081 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2082 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2084 if ((flags & SigmaValue) == 0)
2085 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2087 (void) LinearStretchImage(*image,black_point,white_point);
2088 InheritException(exception,&(*image)->exception);
2091 if (LocaleCompare("linewidth",option+1) == 0)
2093 draw_info->stroke_width=StringToDouble(argv[i+1]);
2096 if (LocaleCompare("liquid-rescale",option+1) == 0)
2102 Liquid rescale image.
2104 (void) SyncImageSettings(mogrify_info,*image);
2105 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2106 if ((flags & XValue) == 0)
2108 if ((flags & YValue) == 0)
2110 resize_image=LiquidRescaleImage(*image,geometry.width,
2111 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2112 if (resize_image == (Image *) NULL)
2114 *image=DestroyImage(*image);
2115 *image=resize_image;
2118 if (LocaleCompare("lowlight-color",option+1) == 0)
2120 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2127 if (LocaleCompare("map",option+1) == 0)
2133 Transform image colors to match this set of colors.
2135 (void) SyncImageSettings(mogrify_info,*image);
2138 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2139 if (remap_image == (Image *) NULL)
2141 (void) RemapImage(quantize_info,*image,remap_image);
2142 InheritException(exception,&(*image)->exception);
2143 remap_image=DestroyImage(remap_image);
2146 if (LocaleCompare("mask",option+1) == 0)
2151 (void) SyncImageSettings(mogrify_info,*image);
2157 (void) SetImageMask(*image,(Image *) NULL);
2158 InheritException(exception,&(*image)->exception);
2164 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2165 if (mask == (Image *) NULL)
2167 (void) SetImageMask(*image,mask);
2168 mask=DestroyImage(mask);
2169 InheritException(exception,&(*image)->exception);
2172 if (LocaleCompare("matte",option+1) == 0)
2174 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2175 SetAlphaChannel : DeactivateAlphaChannel );
2176 InheritException(exception,&(*image)->exception);
2179 if (LocaleCompare("median",option+1) == 0)
2185 Median filter image.
2187 (void) SyncImageSettings(mogrify_info,*image);
2188 (void) ParseGeometry(argv[i+1],&geometry_info);
2189 median_image=MedianFilterImage(*image,geometry_info.rho,exception);
2190 if (median_image == (Image *) NULL)
2192 *image=DestroyImage(*image);
2193 *image=median_image;
2196 if (LocaleCompare("modulate",option+1) == 0)
2198 (void) SyncImageSettings(mogrify_info,*image);
2199 (void) ModulateImage(*image,argv[i+1]);
2200 InheritException(exception,&(*image)->exception);
2203 if (LocaleCompare("monitor",option+1) == 0)
2207 (void) SetImageProgressMonitor(*image,
2208 (MagickProgressMonitor) NULL,(void *) NULL);
2211 (void) SetImageProgressMonitor(*image,MonitorProgress,
2215 if (LocaleCompare("monochrome",option+1) == 0)
2217 (void) SyncImageSettings(mogrify_info,*image);
2218 (void) SetImageType(*image,BilevelType);
2219 InheritException(exception,&(*image)->exception);
2222 if (LocaleCompare("morphology",option+1) == 0)
2225 token[MaxTextExtent];
2243 Morphological Image Operation
2245 (void) SyncImageSettings(mogrify_info,*image);
2247 GetMagickToken(p,&p,token);
2248 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
2251 GetMagickToken(p,&p,token);
2252 if ((*p == ':') || (*p == ','))
2253 GetMagickToken(p,&p,token);
2255 iterations=StringToLong(p);
2256 kernel=AcquireKernelInfo(argv[i+2]);
2257 if (kernel == (KernelInfo *) NULL)
2259 (void) ThrowMagickException(exception,GetMagickModule(),
2260 OptionError,"UnabletoParseKernel","morphology");
2264 morphology_image=MorphologyImageChannel(*image,channel,method,
2265 iterations,kernel,exception);
2266 kernel=DestroyKernelInfo(kernel);
2267 if (morphology_image == (Image *) NULL)
2269 *image=DestroyImage(*image);
2270 *image=morphology_image;
2273 if (LocaleCompare("motion-blur",option+1) == 0)
2281 (void) SyncImageSettings(mogrify_info,*image);
2282 flags=ParseGeometry(argv[i+1],&geometry_info);
2283 if ((flags & SigmaValue) == 0)
2284 geometry_info.sigma=1.0;
2285 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2286 geometry_info.sigma,geometry_info.xi,exception);
2287 if (blur_image == (Image *) NULL)
2289 *image=DestroyImage(*image);
2297 if (LocaleCompare("negate",option+1) == 0)
2299 (void) SyncImageSettings(mogrify_info,*image);
2300 (void) NegateImageChannel(*image,channel,*option == '+' ?
2301 MagickTrue : MagickFalse);
2302 InheritException(exception,&(*image)->exception);
2305 if (LocaleCompare("noise",option+1) == 0)
2310 (void) SyncImageSettings(mogrify_info,*image);
2313 (void) ParseGeometry(argv[i+1],&geometry_info);
2314 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
2322 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2323 MagickFalse,argv[i+1]);
2324 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2327 if (noisy_image == (Image *) NULL)
2329 *image=DestroyImage(*image);
2333 if (LocaleCompare("normalize",option+1) == 0)
2335 (void) SyncImageSettings(mogrify_info,*image);
2336 (void) NormalizeImageChannel(*image,channel);
2337 InheritException(exception,&(*image)->exception);
2344 if (LocaleCompare("opaque",option+1) == 0)
2349 (void) SyncImageSettings(mogrify_info,*image);
2350 (void) QueryMagickColor(argv[i+1],&target,exception);
2351 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2352 *option == '-' ? MagickFalse : MagickTrue);
2355 if (LocaleCompare("ordered-dither",option+1) == 0)
2357 (void) SyncImageSettings(mogrify_info,*image);
2358 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2366 if (LocaleCompare("paint",option+1) == 0)
2374 (void) SyncImageSettings(mogrify_info,*image);
2375 (void) ParseGeometry(argv[i+1],&geometry_info);
2376 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2377 if (paint_image == (Image *) NULL)
2379 *image=DestroyImage(*image);
2383 if (LocaleCompare("pen",option+1) == 0)
2387 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2390 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2393 if (LocaleCompare("pointsize",option+1) == 0)
2396 (void) ParseGeometry("12",&geometry_info);
2398 (void) ParseGeometry(argv[i+1],&geometry_info);
2399 draw_info->pointsize=geometry_info.rho;
2402 if (LocaleCompare("polaroid",option+1) == 0)
2414 Simulate a Polaroid picture.
2416 (void) SyncImageSettings(mogrify_info,*image);
2417 random_info=AcquireRandomInfo();
2418 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2419 random_info=DestroyRandomInfo(random_info);
2422 SetGeometryInfo(&geometry_info);
2423 flags=ParseGeometry(argv[i+1],&geometry_info);
2424 angle=geometry_info.rho;
2426 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2427 if (polaroid_image == (Image *) NULL)
2429 *image=DestroyImage(*image);
2430 *image=polaroid_image;
2433 if (LocaleCompare("posterize",option+1) == 0)
2438 (void) SyncImageSettings(mogrify_info,*image);
2439 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2440 quantize_info->dither);
2441 InheritException(exception,&(*image)->exception);
2444 if (LocaleCompare("preview",option+1) == 0)
2455 (void) SyncImageSettings(mogrify_info,*image);
2457 preview_type=UndefinedPreview;
2459 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2460 MagickFalse,argv[i+1]);
2461 preview_image=PreviewImage(*image,preview_type,exception);
2462 if (preview_image == (Image *) NULL)
2464 *image=DestroyImage(*image);
2465 *image=preview_image;
2468 if (LocaleCompare("profile",option+1) == 0)
2482 (void) SyncImageSettings(mogrify_info,*image);
2486 Remove a profile from the image.
2488 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2490 InheritException(exception,&(*image)->exception);
2494 Associate a profile with the image.
2496 profile_info=CloneImageInfo(mogrify_info);
2497 profile=GetImageProfile(*image,"iptc");
2498 if (profile != (StringInfo *) NULL)
2499 profile_info->profile=(void *) CloneStringInfo(profile);
2500 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2501 profile_info=DestroyImageInfo(profile_info);
2502 if (profile_image == (Image *) NULL)
2507 profile_info=CloneImageInfo(mogrify_info);
2508 (void) CopyMagickString(profile_info->filename,argv[i+1],
2510 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2511 if (profile != (StringInfo *) NULL)
2513 (void) ProfileImage(*image,profile_info->magick,
2514 GetStringInfoDatum(profile),(size_t)
2515 GetStringInfoLength(profile),MagickFalse);
2516 profile=DestroyStringInfo(profile);
2518 profile_info=DestroyImageInfo(profile_info);
2521 ResetImageProfileIterator(profile_image);
2522 name=GetNextImageProfile(profile_image);
2523 while (name != (const char *) NULL)
2525 profile=GetImageProfile(profile_image,name);
2526 if (profile != (StringInfo *) NULL)
2527 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2528 (size_t) GetStringInfoLength(profile),MagickFalse);
2529 name=GetNextImageProfile(profile_image);
2531 profile_image=DestroyImage(profile_image);
2538 if (LocaleCompare("quantize",option+1) == 0)
2542 quantize_info->colorspace=UndefinedColorspace;
2545 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2546 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2553 if (LocaleCompare("radial-blur",option+1) == 0)
2561 (void) SyncImageSettings(mogrify_info,*image);
2562 blur_image=RadialBlurImageChannel(*image,channel,
2563 StringToDouble(argv[i+1]),exception);
2564 if (blur_image == (Image *) NULL)
2566 *image=DestroyImage(*image);
2570 if (LocaleCompare("raise",option+1) == 0)
2573 Surround image with a raise of solid color.
2575 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2576 if ((flags & SigmaValue) == 0)
2577 geometry.height=geometry.width;
2578 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2580 InheritException(exception,&(*image)->exception);
2583 if (LocaleCompare("random-threshold",option+1) == 0)
2588 (void) SyncImageSettings(mogrify_info,*image);
2589 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2593 if (LocaleCompare("recolor",option+1) == 0)
2601 (void) SyncImageSettings(mogrify_info,*image);
2602 kernel=AcquireKernelInfo(argv[i+1]);
2603 if (kernel == (KernelInfo *) NULL)
2605 color_image=ColorMatrixImage(*image,kernel,exception);
2606 kernel=DestroyKernelInfo(kernel);
2607 if (color_image == (Image *) NULL)
2609 *image=DestroyImage(*image);
2613 if (LocaleCompare("region",option+1) == 0)
2618 (void) SyncImageSettings(mogrify_info,*image);
2619 if (region_image != (Image *) NULL)
2624 (void) CompositeImage(region_image,(*image)->matte !=
2625 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2626 region_geometry.x,region_geometry.y);
2627 InheritException(exception,®ion_image->exception);
2628 *image=DestroyImage(*image);
2629 *image=region_image;
2633 if (region_image != (Image *) NULL)
2634 region_image=(Image *) NULL;
2638 Apply transformations to a selected region of the image.
2640 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2642 crop_image=CropImage(*image,®ion_geometry,exception);
2643 if (crop_image == (Image *) NULL)
2645 region_image=(*image);
2649 if (LocaleCompare("render",option+1) == 0)
2651 (void) SyncImageSettings(mogrify_info,*image);
2652 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2655 if (LocaleCompare("remap",option+1) == 0)
2661 Transform image colors to match this set of colors.
2663 (void) SyncImageSettings(mogrify_info,*image);
2666 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2667 if (remap_image == (Image *) NULL)
2669 (void) RemapImage(quantize_info,*image,remap_image);
2670 InheritException(exception,&(*image)->exception);
2671 remap_image=DestroyImage(remap_image);
2674 if (LocaleCompare("repage",option+1) == 0)
2678 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2681 (void) ResetImagePage(*image,argv[i+1]);
2682 InheritException(exception,&(*image)->exception);
2685 if (LocaleCompare("resample",option+1) == 0)
2693 (void) SyncImageSettings(mogrify_info,*image);
2694 flags=ParseGeometry(argv[i+1],&geometry_info);
2695 if ((flags & SigmaValue) == 0)
2696 geometry_info.sigma=geometry_info.rho;
2697 resample_image=ResampleImage(*image,geometry_info.rho,
2698 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2699 if (resample_image == (Image *) NULL)
2701 *image=DestroyImage(*image);
2702 *image=resample_image;
2705 if (LocaleCompare("resize",option+1) == 0)
2713 (void) SyncImageSettings(mogrify_info,*image);
2714 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2715 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2716 (*image)->filter,(*image)->blur,exception);
2717 if (resize_image == (Image *) NULL)
2719 *image=DestroyImage(*image);
2720 *image=resize_image;
2723 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2725 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2728 if (LocaleCompare("roll",option+1) == 0)
2736 (void) SyncImageSettings(mogrify_info,*image);
2737 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2738 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2739 if (roll_image == (Image *) NULL)
2741 *image=DestroyImage(*image);
2745 if (LocaleCompare("rotate",option+1) == 0)
2754 Check for conditional image rotation.
2756 (void) SyncImageSettings(mogrify_info,*image);
2757 if (strchr(argv[i+1],'>') != (char *) NULL)
2758 if ((*image)->columns <= (*image)->rows)
2760 if (strchr(argv[i+1],'<') != (char *) NULL)
2761 if ((*image)->columns >= (*image)->rows)
2766 geometry=ConstantString(argv[i+1]);
2767 (void) SubstituteString(&geometry,">","");
2768 (void) SubstituteString(&geometry,"<","");
2769 (void) ParseGeometry(geometry,&geometry_info);
2770 geometry=DestroyString(geometry);
2771 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2772 if (rotate_image == (Image *) NULL)
2774 *image=DestroyImage(*image);
2775 *image=rotate_image;
2782 if (LocaleCompare("sample",option+1) == 0)
2788 Sample image with pixel replication.
2790 (void) SyncImageSettings(mogrify_info,*image);
2791 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2792 sample_image=SampleImage(*image,geometry.width,geometry.height,
2794 if (sample_image == (Image *) NULL)
2796 *image=DestroyImage(*image);
2797 *image=sample_image;
2800 if (LocaleCompare("scale",option+1) == 0)
2808 (void) SyncImageSettings(mogrify_info,*image);
2809 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2810 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2812 if (scale_image == (Image *) NULL)
2814 *image=DestroyImage(*image);
2818 if (LocaleCompare("selective-blur",option+1) == 0)
2824 Selectively blur pixels within a contrast threshold.
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 flags=ParseGeometry(argv[i+1],&geometry_info);
2828 if ((flags & PercentValue) != 0)
2829 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2830 blur_image=SelectiveBlurImageChannel(*image,channel,
2831 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2832 if (blur_image == (Image *) NULL)
2834 *image=DestroyImage(*image);
2838 if (LocaleCompare("separate",option+1) == 0)
2844 Break channels into separate images.
2846 (void) SyncImageSettings(mogrify_info,*image);
2847 separate_images=SeparateImages(*image,channel,exception);
2848 if (separate_images == (Image *) NULL)
2850 *image=DestroyImage(*image);
2851 *image=separate_images;
2854 if (LocaleCompare("sepia-tone",option+1) == 0)
2865 (void) SyncImageSettings(mogrify_info,*image);
2866 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2867 sepia_image=SepiaToneImage(*image,threshold,exception);
2868 if (sepia_image == (Image *) NULL)
2870 *image=DestroyImage(*image);
2874 if (LocaleCompare("segment",option+1) == 0)
2879 (void) SyncImageSettings(mogrify_info,*image);
2880 flags=ParseGeometry(argv[i+1],&geometry_info);
2881 if ((flags & SigmaValue) == 0)
2882 geometry_info.sigma=1.0;
2883 (void) SegmentImage(*image,(*image)->colorspace,
2884 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2885 InheritException(exception,&(*image)->exception);
2888 if (LocaleCompare("set",option+1) == 0)
2898 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2899 (void) DeleteImageRegistry(argv[i+1]+9);
2901 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2903 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2904 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2907 (void) DeleteImageProperty(*image,argv[i+1]);
2910 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2911 if (value == (char *) NULL)
2913 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2914 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2917 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2919 (void) SetImageOption(image_info,argv[i+1]+7,value);
2920 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2921 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2924 (void) SetImageProperty(*image,argv[i+1],value);
2925 value=DestroyString(value);
2928 if (LocaleCompare("shade",option+1) == 0)
2936 (void) SyncImageSettings(mogrify_info,*image);
2937 flags=ParseGeometry(argv[i+1],&geometry_info);
2938 if ((flags & SigmaValue) == 0)
2939 geometry_info.sigma=1.0;
2940 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2941 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2942 if (shade_image == (Image *) NULL)
2944 *image=DestroyImage(*image);
2948 if (LocaleCompare("shadow",option+1) == 0)
2956 (void) SyncImageSettings(mogrify_info,*image);
2957 flags=ParseGeometry(argv[i+1],&geometry_info);
2958 if ((flags & SigmaValue) == 0)
2959 geometry_info.sigma=1.0;
2960 if ((flags & XiValue) == 0)
2961 geometry_info.xi=4.0;
2962 if ((flags & PsiValue) == 0)
2963 geometry_info.psi=4.0;
2964 shadow_image=ShadowImage(*image,geometry_info.rho,
2965 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2966 ceil(geometry_info.psi-0.5),exception);
2967 if (shadow_image == (Image *) NULL)
2969 *image=DestroyImage(*image);
2970 *image=shadow_image;
2973 if (LocaleCompare("sharpen",option+1) == 0)
2981 (void) SyncImageSettings(mogrify_info,*image);
2982 flags=ParseGeometry(argv[i+1],&geometry_info);
2983 if ((flags & SigmaValue) == 0)
2984 geometry_info.sigma=1.0;
2985 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2986 geometry_info.sigma,exception);
2987 if (sharp_image == (Image *) NULL)
2989 *image=DestroyImage(*image);
2993 if (LocaleCompare("shave",option+1) == 0)
2999 Shave the image edges.
3001 (void) SyncImageSettings(mogrify_info,*image);
3002 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
3003 shave_image=ShaveImage(*image,&geometry,exception);
3004 if (shave_image == (Image *) NULL)
3006 *image=DestroyImage(*image);
3010 if (LocaleCompare("shear",option+1) == 0)
3018 (void) SyncImageSettings(mogrify_info,*image);
3019 flags=ParseGeometry(argv[i+1],&geometry_info);
3020 if ((flags & SigmaValue) == 0)
3021 geometry_info.sigma=geometry_info.rho;
3022 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3024 if (shear_image == (Image *) NULL)
3026 *image=DestroyImage(*image);
3030 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3033 Sigmoidal non-linearity contrast control.
3035 (void) SyncImageSettings(mogrify_info,*image);
3036 flags=ParseGeometry(argv[i+1],&geometry_info);
3037 if ((flags & SigmaValue) == 0)
3038 geometry_info.sigma=(double) QuantumRange/2.0;
3039 if ((flags & PercentValue) != 0)
3040 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3042 (void) SigmoidalContrastImageChannel(*image,channel,
3043 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3044 geometry_info.sigma);
3045 InheritException(exception,&(*image)->exception);
3048 if (LocaleCompare("sketch",option+1) == 0)
3056 (void) SyncImageSettings(mogrify_info,*image);
3057 flags=ParseGeometry(argv[i+1],&geometry_info);
3058 if ((flags & SigmaValue) == 0)
3059 geometry_info.sigma=1.0;
3060 sketch_image=SketchImage(*image,geometry_info.rho,
3061 geometry_info.sigma,geometry_info.xi,exception);
3062 if (sketch_image == (Image *) NULL)
3064 *image=DestroyImage(*image);
3065 *image=sketch_image;
3068 if (LocaleCompare("solarize",option+1) == 0)
3073 (void) SyncImageSettings(mogrify_info,*image);
3074 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3075 (void) SolarizeImage(*image,threshold);
3076 InheritException(exception,&(*image)->exception);
3079 if (LocaleCompare("sparse-color",option+1) == 0)
3091 Sparse Color Interpolated Gradient
3093 (void) SyncImageSettings(mogrify_info,*image);
3094 method=(SparseColorMethod) ParseMagickOption(
3095 MagickSparseColorOptions,MagickFalse,argv[i+1]);
3096 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
3097 InheritException(exception,&(*image)->exception);
3098 if (arguments == (char *) NULL)
3100 sparse_image=SparseColorOption(*image,channel,method,arguments,
3101 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3102 arguments=DestroyString(arguments);
3103 if (sparse_image == (Image *) NULL)
3105 *image=DestroyImage(*image);
3106 *image=sparse_image;
3109 if (LocaleCompare("splice",option+1) == 0)
3115 Splice a solid color into the image.
3117 (void) SyncImageSettings(mogrify_info,*image);
3118 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3119 splice_image=SpliceImage(*image,&geometry,exception);
3120 if (splice_image == (Image *) NULL)
3122 *image=DestroyImage(*image);
3123 *image=splice_image;
3126 if (LocaleCompare("spread",option+1) == 0)
3134 (void) SyncImageSettings(mogrify_info,*image);
3135 (void) ParseGeometry(argv[i+1],&geometry_info);
3136 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3137 if (spread_image == (Image *) NULL)
3139 *image=DestroyImage(*image);
3140 *image=spread_image;
3143 if (LocaleCompare("stretch",option+1) == 0)
3147 draw_info->stretch=UndefinedStretch;
3150 draw_info->stretch=(StretchType) ParseMagickOption(
3151 MagickStretchOptions,MagickFalse,argv[i+1]);
3154 if (LocaleCompare("strip",option+1) == 0)
3157 Strip image of profiles and comments.
3159 (void) SyncImageSettings(mogrify_info,*image);
3160 (void) StripImage(*image);
3161 InheritException(exception,&(*image)->exception);
3164 if (LocaleCompare("stroke",option+1) == 0)
3171 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3172 if (draw_info->stroke_pattern != (Image *) NULL)
3173 draw_info->stroke_pattern=DestroyImage(
3174 draw_info->stroke_pattern);
3177 sans=AcquireExceptionInfo();
3178 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3179 sans=DestroyExceptionInfo(sans);
3180 if (status == MagickFalse)
3181 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3185 if (LocaleCompare("strokewidth",option+1) == 0)
3187 draw_info->stroke_width=StringToDouble(argv[i+1]);
3190 if (LocaleCompare("style",option+1) == 0)
3194 draw_info->style=UndefinedStyle;
3197 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3198 MagickFalse,argv[i+1]);
3201 if (LocaleCompare("swirl",option+1) == 0)
3209 (void) SyncImageSettings(mogrify_info,*image);
3210 (void) ParseGeometry(argv[i+1],&geometry_info);
3211 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3212 if (swirl_image == (Image *) NULL)
3214 *image=DestroyImage(*image);
3222 if (LocaleCompare("threshold",option+1) == 0)
3230 (void) SyncImageSettings(mogrify_info,*image);
3232 threshold=(double) QuantumRange/2.5;
3234 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3235 (void) BilevelImageChannel(*image,channel,threshold);
3236 InheritException(exception,&(*image)->exception);
3239 if (LocaleCompare("thumbnail",option+1) == 0)
3247 (void) SyncImageSettings(mogrify_info,*image);
3248 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3249 thumbnail_image=ThumbnailImage(*image,geometry.width,
3250 geometry.height,exception);
3251 if (thumbnail_image == (Image *) NULL)
3253 *image=DestroyImage(*image);
3254 *image=thumbnail_image;
3257 if (LocaleCompare("tile",option+1) == 0)
3261 if (draw_info->fill_pattern != (Image *) NULL)
3262 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3265 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3269 if (LocaleCompare("tint",option+1) == 0)
3277 (void) SyncImageSettings(mogrify_info,*image);
3278 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3279 if (tint_image == (Image *) NULL)
3281 *image=DestroyImage(*image);
3285 if (LocaleCompare("transform",option+1) == 0)
3291 Affine transform image.
3293 (void) SyncImageSettings(mogrify_info,*image);
3294 transform_image=AffineTransformImage(*image,&draw_info->affine,
3296 if (transform_image == (Image *) NULL)
3298 *image=DestroyImage(*image);
3299 *image=transform_image;
3302 if (LocaleCompare("transparent",option+1) == 0)
3307 (void) SyncImageSettings(mogrify_info,*image);
3308 (void) QueryMagickColor(argv[i+1],&target,exception);
3309 (void) TransparentPaintImage(*image,&target,(Quantum)
3310 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3311 InheritException(exception,&(*image)->exception);
3314 if (LocaleCompare("transpose",option+1) == 0)
3320 Transpose image scanlines.
3322 (void) SyncImageSettings(mogrify_info,*image);
3323 transpose_image=TransposeImage(*image,exception);
3324 if (transpose_image == (Image *) NULL)
3326 *image=DestroyImage(*image);
3327 *image=transpose_image;
3330 if (LocaleCompare("transverse",option+1) == 0)
3336 Transverse image scanlines.
3338 (void) SyncImageSettings(mogrify_info,*image);
3339 transverse_image=TransverseImage(*image,exception);
3340 if (transverse_image == (Image *) NULL)
3342 *image=DestroyImage(*image);
3343 *image=transverse_image;
3346 if (LocaleCompare("treedepth",option+1) == 0)
3348 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3351 if (LocaleCompare("trim",option+1) == 0)
3359 (void) SyncImageSettings(mogrify_info,*image);
3360 trim_image=TrimImage(*image,exception);
3361 if (trim_image == (Image *) NULL)
3363 *image=DestroyImage(*image);
3367 if (LocaleCompare("type",option+1) == 0)
3372 (void) SyncImageSettings(mogrify_info,*image);
3376 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3378 (*image)->type=UndefinedType;
3379 (void) SetImageType(*image,type);
3380 InheritException(exception,&(*image)->exception);
3387 if (LocaleCompare("undercolor",option+1) == 0)
3389 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3393 if (LocaleCompare("unique",option+1) == 0)
3397 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3400 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3401 (void) SetImageArtifact(*image,"identify:verbose","true");
3404 if (LocaleCompare("unique-colors",option+1) == 0)
3410 Unique image colors.
3412 (void) SyncImageSettings(mogrify_info,*image);
3413 unique_image=UniqueImageColors(*image,exception);
3414 if (unique_image == (Image *) NULL)
3416 *image=DestroyImage(*image);
3417 *image=unique_image;
3420 if (LocaleCompare("unsharp",option+1) == 0)
3428 (void) SyncImageSettings(mogrify_info,*image);
3429 flags=ParseGeometry(argv[i+1],&geometry_info);
3430 if ((flags & SigmaValue) == 0)
3431 geometry_info.sigma=1.0;
3432 if ((flags & XiValue) == 0)
3433 geometry_info.xi=1.0;
3434 if ((flags & PsiValue) == 0)
3435 geometry_info.psi=0.05;
3436 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3437 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3438 geometry_info.psi,exception);
3439 if (unsharp_image == (Image *) NULL)
3441 *image=DestroyImage(*image);
3442 *image=unsharp_image;
3449 if (LocaleCompare("verbose",option+1) == 0)
3451 (void) SetImageArtifact(*image,option+1,
3452 *option == '+' ? "false" : "true");
3455 if (LocaleCompare("vignette",option+1) == 0)
3463 (void) SyncImageSettings(mogrify_info,*image);
3464 flags=ParseGeometry(argv[i+1],&geometry_info);
3465 if ((flags & SigmaValue) == 0)
3466 geometry_info.sigma=1.0;
3467 if ((flags & XiValue) == 0)
3468 geometry_info.xi=0.1*(*image)->columns;
3469 if ((flags & PsiValue) == 0)
3470 geometry_info.psi=0.1*(*image)->rows;
3471 vignette_image=VignetteImage(*image,geometry_info.rho,
3472 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3473 ceil(geometry_info.psi-0.5),exception);
3474 if (vignette_image == (Image *) NULL)
3476 *image=DestroyImage(*image);
3477 *image=vignette_image;
3480 if (LocaleCompare("virtual-pixel",option+1) == 0)
3484 (void) SetImageVirtualPixelMethod(*image,
3485 UndefinedVirtualPixelMethod);
3488 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3489 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3497 if (LocaleCompare("wave",option+1) == 0)
3505 (void) SyncImageSettings(mogrify_info,*image);
3506 flags=ParseGeometry(argv[i+1],&geometry_info);
3507 if ((flags & SigmaValue) == 0)
3508 geometry_info.sigma=1.0;
3509 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3511 if (wave_image == (Image *) NULL)
3513 *image=DestroyImage(*image);
3517 if (LocaleCompare("weight",option+1) == 0)
3519 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3520 if (LocaleCompare(argv[i+1],"all") == 0)
3521 draw_info->weight=0;
3522 if (LocaleCompare(argv[i+1],"bold") == 0)
3523 draw_info->weight=700;
3524 if (LocaleCompare(argv[i+1],"bolder") == 0)
3525 if (draw_info->weight <= 800)
3526 draw_info->weight+=100;
3527 if (LocaleCompare(argv[i+1],"lighter") == 0)
3528 if (draw_info->weight >= 100)
3529 draw_info->weight-=100;
3530 if (LocaleCompare(argv[i+1],"normal") == 0)
3531 draw_info->weight=400;
3534 if (LocaleCompare("white-threshold",option+1) == 0)
3537 White threshold image.
3539 (void) SyncImageSettings(mogrify_info,*image);
3540 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3542 InheritException(exception,&(*image)->exception);
3552 if (region_image != (Image *) NULL)
3555 Composite transformed region onto image.
3557 (void) SyncImageSettings(mogrify_info,*image);
3558 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3559 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3561 InheritException(exception,®ion_image->exception);
3562 *image=DestroyImage(*image);
3563 *image=region_image;
3568 quantize_info=DestroyQuantizeInfo(quantize_info);
3569 draw_info=DestroyDrawInfo(draw_info);
3570 mogrify_info=DestroyImageInfo(mogrify_info);
3571 status=(*image)->exception.severity == UndefinedException ? MagickTrue :
3577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3581 % M o g r i f y I m a g e C o m m a n d %
3585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3587 % MogrifyImageCommand() transforms an image or a sequence of images. These
3588 % transforms include image scaling, image rotation, color reduction, and
3589 % others. The transmogrified image overwrites the original image.
3591 % The format of the MogrifyImageCommand method is:
3593 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3594 % const char **argv,char **metadata,ExceptionInfo *exception)
3596 % A description of each parameter follows:
3598 % o image_info: the image info.
3600 % o argc: the number of elements in the argument vector.
3602 % o argv: A text array containing the command line arguments.
3604 % o metadata: any metadata is returned here.
3606 % o exception: return any errors or warnings in this structure.
3610 static MagickBooleanType MogrifyUsage(void)
3615 "-debug events display copious debugging information",
3616 "-help print program options",
3617 "-list type print a list of supported option arguments",
3618 "-log format format of debugging information",
3619 "-version print version information",
3624 "-adaptive-blur geometry",
3625 " adaptively blur pixels; decrease effect near edges",
3626 "-adaptive-resize geometry",
3627 " adaptively resize image using 'mesh' interpolation",
3628 "-adaptive-sharpen geometry",
3629 " adaptively sharpen pixels; increase effect near edges",
3630 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3631 " transparent, extract, background, or shape",
3632 "-annotate geometry text",
3633 " annotate the image with text",
3634 "-auto-gamma automagically adjust gamma level of image",
3635 "-auto-level automagically adjust color levels of image",
3636 "-auto-orient automagically orient (rotate) image",
3637 "-bench iterations measure performance",
3638 "-black-threshold value",
3639 " force all pixels below the threshold into black",
3640 "-blue-shift simulate a scene at nighttime in the moonlight",
3641 "-blur geometry reduce image noise and reduce detail levels",
3642 "-border geometry surround image with a border of color",
3643 "-bordercolor color border color",
3644 "-brightness-contrast geometry",
3645 " improve brightness / contrast of the image",
3646 "-cdl filename color correct with a color decision list",
3647 "-charcoal radius simulate a charcoal drawing",
3648 "-chop geometry remove pixels from the image interior",
3649 "-clamp restrict pixel range from 0 to the quantum depth",
3650 "-clip clip along the first path from the 8BIM profile",
3651 "-clip-mask filename associate a clip mask with the image",
3652 "-clip-path id clip along a named path from the 8BIM profile",
3653 "-colorize value colorize the image with the fill color",
3654 "-color-matrix matrix apply color correction to the image",
3655 "-contrast enhance or reduce the image contrast",
3656 "-contrast-stretch geometry",
3657 " improve contrast by `stretching' the intensity range",
3658 "-convolve coefficients",
3659 " apply a convolution kernel to the image",
3660 "-cycle amount cycle the image colormap",
3661 "-decipher filename convert cipher pixels to plain pixels",
3662 "-deskew threshold straighten an image",
3663 "-despeckle reduce the speckles within an image",
3664 "-distort method args",
3665 " distort images according to given method ad args",
3666 "-draw string annotate the image with a graphic primitive",
3667 "-edge radius apply a filter to detect edges in the image",
3668 "-encipher filename convert plain pixels to cipher pixels",
3669 "-emboss radius emboss an image",
3670 "-enhance apply a digital filter to enhance a noisy image",
3671 "-equalize perform histogram equalization to an image",
3672 "-evaluate operator value",
3673 " evaluate an arithmetic, relational, or logical expression",
3674 "-extent geometry set the image size",
3675 "-extract geometry extract area from image",
3676 "-fft implements the discrete Fourier transform (DFT)",
3677 "-flip flip image vertically",
3678 "-floodfill geometry color",
3679 " floodfill the image with color",
3680 "-flop flop image horizontally",
3681 "-frame geometry surround image with an ornamental border",
3682 "-function name parameters",
3683 " apply function over image values",
3684 "-gamma value level of gamma correction",
3685 "-gaussian-blur geometry",
3686 " reduce image noise and reduce detail levels",
3687 "-geometry geometry preferred size or location of the image",
3688 "-identify identify the format and characteristics of the image",
3689 "-ift implements the inverse discrete Fourier transform (DFT)",
3690 "-implode amount implode image pixels about the center",
3691 "-lat geometry local adaptive thresholding",
3692 "-layers method optimize, merge, or compare image layers",
3693 "-level value adjust the level of image contrast",
3694 "-level-colors color,color",
3695 " level image with the given colors",
3696 "-linear-stretch geometry",
3697 " improve contrast by `stretching with saturation'",
3698 "-liquid-rescale geometry",
3699 " rescale image with seam-carving",
3700 "-median radius apply a median filter to the image",
3701 "-modulate value vary the brightness, saturation, and hue",
3702 "-monochrome transform image to black and white",
3703 "-morphology method kernel",
3704 " apply a morphology method to the image",
3705 "-motion-blur geometry",
3706 " simulate motion blur",
3707 "-negate replace every pixel with its complementary color ",
3708 "-noise radius add or reduce noise in an image",
3709 "-normalize transform image to span the full range of colors",
3710 "-opaque color change this color to the fill color",
3711 "-ordered-dither NxN",
3712 " add a noise pattern to the image with specific",
3714 "-paint radius simulate an oil painting",
3715 "-polaroid angle simulate a Polaroid picture",
3716 "-posterize levels reduce the image to a limited number of color levels",
3717 "-profile filename add, delete, or apply an image profile",
3718 "-quantize colorspace reduce colors in this colorspace",
3719 "-radial-blur angle radial blur the image",
3720 "-raise value lighten/darken image edges to create a 3-D effect",
3721 "-random-threshold low,high",
3722 " random threshold the image",
3723 "-region geometry apply options to a portion of the image",
3724 "-render render vector graphics",
3725 "-repage geometry size and location of an image canvas",
3726 "-resample geometry change the resolution of an image",
3727 "-resize geometry resize the image",
3728 "-roll geometry roll an image vertically or horizontally",
3729 "-rotate degrees apply Paeth rotation to the image",
3730 "-sample geometry scale image with pixel sampling",
3731 "-scale geometry scale the image",
3732 "-segment values segment an image",
3733 "-selective-blur geometry",
3734 " selectively blur pixels within a contrast threshold",
3735 "-sepia-tone threshold",
3736 " simulate a sepia-toned photo",
3737 "-set property value set an image property",
3738 "-shade degrees shade the image using a distant light source",
3739 "-shadow geometry simulate an image shadow",
3740 "-sharpen geometry sharpen the image",
3741 "-shave geometry shave pixels from the image edges",
3742 "-shear geometry slide one edge of the image along the X or Y axis",
3743 "-sigmoidal-contrast geometry",
3744 " increase the contrast without saturating highlights or shadows",
3745 "-sketch geometry simulate a pencil sketch",
3746 "-solarize threshold negate all pixels above the threshold level",
3747 "-sparse-color method args",
3748 " fill in a image based on a few color points",
3749 "-splice geometry splice the background color into the image",
3750 "-spread radius displace image pixels by a random amount",
3751 "-strip strip image of all profiles and comments",
3752 "-swirl degrees swirl image pixels about the center",
3753 "-threshold value threshold the image",
3754 "-thumbnail geometry create a thumbnail of the image",
3755 "-tile filename tile image when filling a graphic primitive",
3756 "-tint value tint the image with the fill color",
3757 "-transform affine transform image",
3758 "-transparent color make this color transparent within the image",
3759 "-transpose flip image vertically and rotate 90 degrees",
3760 "-transverse flop image horizontally and rotate 270 degrees",
3761 "-trim trim image edges",
3762 "-type type image type",
3763 "-unique-colors discard all but one of any pixel color",
3764 "-unsharp geometry sharpen the image",
3765 "-vignette geometry soften the edges of the image in vignette style",
3766 "-wave geometry alter an image along a sine wave",
3767 "-white-threshold value",
3768 " force all pixels above the threshold into white",
3771 *sequence_operators[]=
3773 "-append append an image sequence top to bottom",
3774 "-clut apply a color lookup table to the image",
3775 "-coalesce merge a sequence of images",
3776 "-combine combine a sequence of images",
3777 "-composite composite image",
3778 "-crop geometry cut out a rectangular region of the image",
3779 "-deconstruct break down an image sequence into constituent parts",
3780 "-evaluate-sequence operator",
3781 " evaluate an arithmetic, relational, or logical expression",
3782 "-flatten flatten a sequence of images",
3783 "-fx expression apply mathematical expression to an image channel(s)",
3784 "-hald-clut apply a Hald color lookup table to the image",
3785 "-morph value morph an image sequence",
3786 "-mosaic create a mosaic from an image sequence",
3787 "-print string interpret string and print to console",
3788 "-process arguments process the image with a custom image filter",
3789 "-reverse reverse image sequence",
3790 "-separate separate an image channel into a grayscale image",
3791 "-write filename write images to this file",
3796 "-adjoin join images into a single multi-image file",
3797 "-affine matrix affine transform matrix",
3798 "-alpha option activate, deactivate, reset, or set the alpha channel",
3799 "-antialias remove pixel-aliasing",
3800 "-authenticate password",
3801 " decipher image with this password",
3802 "-attenuate value lessen (or intensify) when adding noise to an image",
3803 "-background color background color",
3804 "-bias value add bias when convolving an image",
3805 "-black-point-compensation",
3806 " use black point compensation",
3807 "-blue-primary point chromaticity blue primary point",
3808 "-bordercolor color border color",
3809 "-caption string assign a caption to an image",
3810 "-channel type apply option to select image channels",
3811 "-colors value preferred number of colors in the image",
3812 "-colorspace type alternate image colorspace",
3813 "-comment string annotate image with comment",
3814 "-compose operator set image composite operator",
3815 "-compress type type of pixel compression when writing the image",
3816 "-define format:option",
3817 " define one or more image format options",
3818 "-delay value display the next image after pausing",
3819 "-density geometry horizontal and vertical density of the image",
3820 "-depth value image depth",
3821 "-direction type render text right-to-left or left-to-right",
3822 "-display server get image or font from this X server",
3823 "-dispose method layer disposal method",
3824 "-dither method apply error diffusion to image",
3825 "-encoding type text encoding type",
3826 "-endian type endianness (MSB or LSB) of the image",
3827 "-family name render text with this font family",
3828 "-fill color color to use when filling a graphic primitive",
3829 "-filter type use this filter when resizing an image",
3830 "-font name render text with this font",
3831 "-format \"string\" output formatted image characteristics",
3832 "-fuzz distance colors within this distance are considered equal",
3833 "-gravity type horizontal and vertical text placement",
3834 "-green-primary point chromaticity green primary point",
3835 "-intent type type of rendering intent when managing the image color",
3836 "-interlace type type of image interlacing scheme",
3837 "-interline-spacing value",
3838 " set the space between two text lines",
3839 "-interpolate method pixel color interpolation method",
3840 "-interword-spacing value",
3841 " set the space between two words",
3842 "-kerning value set the space between two letters",
3843 "-label string assign a label to an image",
3844 "-limit type value pixel cache resource limit",
3845 "-loop iterations add Netscape loop extension to your GIF animation",
3846 "-mask filename associate a mask with the image",
3847 "-mattecolor color frame color",
3848 "-monitor monitor progress",
3849 "-orient type image orientation",
3850 "-page geometry size and location of an image canvas (setting)",
3851 "-ping efficiently determine image attributes",
3852 "-pointsize value font point size",
3853 "-precision value maximum number of significant digits to print",
3854 "-preview type image preview type",
3855 "-quality value JPEG/MIFF/PNG compression level",
3856 "-quiet suppress all warning messages",
3857 "-red-primary point chromaticity red primary point",
3858 "-regard-warnings pay attention to warning messages",
3859 "-remap filename transform image colors to match this set of colors",
3860 "-respect-parentheses settings remain in effect until parenthesis boundary",
3861 "-sampling-factor geometry",
3862 " horizontal and vertical sampling factor",
3863 "-scene value image scene number",
3864 "-seed value seed a new sequence of pseudo-random numbers",
3865 "-size geometry width and height of image",
3866 "-stretch type render text with this font stretch",
3867 "-stroke color graphic primitive stroke color",
3868 "-strokewidth value graphic primitive stroke width",
3869 "-style type render text with this font style",
3870 "-synchronize synchronize image to storage device",
3871 "-taint declare the image as modified",
3872 "-texture filename name of texture to tile onto the image background",
3873 "-tile-offset geometry",
3875 "-treedepth value color tree depth",
3876 "-transparent-color color",
3877 " transparent color",
3878 "-undercolor color annotation bounding box color",
3879 "-units type the units of image resolution",
3880 "-verbose print detailed information about the image",
3881 "-view FlashPix viewing transforms",
3882 "-virtual-pixel method",
3883 " virtual pixel access method",
3884 "-weight type render text with this font weight",
3885 "-white-point point chromaticity white point",
3890 "-clone index clone an image",
3891 "-delete index delete the image from the image sequence",
3892 "-insert index insert last image into the image sequence",
3893 "-swap indexes swap two images in the image sequence",
3900 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3901 (void) printf("Copyright: %s\n",GetMagickCopyright());
3902 (void) printf("Features: %s\n\n",GetMagickFeatures());
3903 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3905 (void) printf("\nImage Settings:\n");
3906 for (p=settings; *p != (char *) NULL; p++)
3907 (void) printf(" %s\n",*p);
3908 (void) printf("\nImage Operators:\n");
3909 for (p=operators; *p != (char *) NULL; p++)
3910 (void) printf(" %s\n",*p);
3911 (void) printf("\nImage Sequence Operators:\n");
3912 for (p=sequence_operators; *p != (char *) NULL; p++)
3913 (void) printf(" %s\n",*p);
3914 (void) printf("\nImage Stack Operators:\n");
3915 for (p=stack_operators; *p != (char *) NULL; p++)
3916 (void) printf(" %s\n",*p);
3917 (void) printf("\nMiscellaneous Options:\n");
3918 for (p=miscellaneous; *p != (char *) NULL; p++)
3919 (void) printf(" %s\n",*p);
3921 "\nBy default, the image format of `file' is determined by its magic\n");
3923 "number. To specify a particular image format, precede the filename\n");
3925 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3927 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3928 (void) printf("'-' for standard input or output.\n");
3929 return(MagickFalse);
3932 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3933 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3935 #define DestroyMogrify() \
3937 if (format != (char *) NULL) \
3938 format=DestroyString(format); \
3939 if (path != (char *) NULL) \
3940 path=DestroyString(path); \
3941 DestroyImageStack(); \
3942 for (i=0; i < (ssize_t) argc; i++) \
3943 argv[i]=DestroyString(argv[i]); \
3944 argv=(char **) RelinquishMagickMemory(argv); \
3946 #define ThrowMogrifyException(asperity,tag,option) \
3948 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3951 return(MagickFalse); \
3953 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3955 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3956 "InvalidArgument","`%s': %s",argument,option); \
3958 return(MagickFalse); \
3970 image_stack[MaxImageStackDepth+1];
3992 assert(image_info != (ImageInfo *) NULL);
3993 assert(image_info->signature == MagickSignature);
3994 if (image_info->debug != MagickFalse)
3995 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3996 assert(exception != (ExceptionInfo *) NULL);
4000 if ((LocaleCompare("version",option+1) == 0) ||
4001 (LocaleCompare("-version",option+1) == 0))
4003 (void) fprintf(stdout,"Version: %s\n",
4004 GetMagickVersion((size_t *) NULL));
4005 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
4006 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
4007 return(MagickFalse);
4011 return(MogrifyUsage());
4012 format=(char *) NULL;
4014 global_colormap=MagickFalse;
4018 option=(char *) NULL;
4024 ReadCommandlLine(argc,&argv);
4025 status=ExpandFilenames(&argc,&argv);
4026 if (status == MagickFalse)
4027 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4028 GetExceptionMessage(errno));
4029 for (i=1; i < (ssize_t) argc; i++)
4032 if (LocaleCompare(option,"(") == 0)
4034 FireImageStack(MagickFalse,MagickTrue,pend);
4035 if (k == MaxImageStackDepth)
4036 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4041 if (LocaleCompare(option,")") == 0)
4043 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4045 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4049 if (IsMagickOption(option) == MagickFalse)
4052 backup_filename[MaxTextExtent],
4059 Option is a file name: begin by reading image from specified file.
4061 FireImageStack(MagickFalse,MagickFalse,pend);
4063 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
4065 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4066 images=ReadImages(image_info,exception);
4067 status&=(images != (Image *) NULL) &&
4068 (exception->severity < ErrorException);
4069 if (images == (Image *) NULL)
4071 if (format != (char *) NULL)
4072 (void) CopyMagickString(images->filename,images->magick_filename,
4074 if (path != (char *) NULL)
4076 GetPathComponent(option,TailPath,filename);
4077 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4078 path,*DirectorySeparator,filename);
4080 if (format != (char *) NULL)
4081 AppendImageFormat(format,images->filename);
4082 AppendImageStack(images);
4083 FinalizeImageSettings(image_info,image,MagickFalse);
4084 if (global_colormap != MagickFalse)
4089 quantize_info=AcquireQuantizeInfo(image_info);
4090 (void) RemapImages(quantize_info,images,(Image *) NULL);
4091 quantize_info=DestroyQuantizeInfo(quantize_info);
4093 *backup_filename='\0';
4094 if ((LocaleCompare(image->filename,"-") != 0) &&
4095 (IsPathWritable(image->filename) != MagickFalse))
4101 Rename image file as backup.
4103 (void) CopyMagickString(backup_filename,image->filename,
4105 for (i=0; i < 6; i++)
4107 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4108 if (IsPathAccessible(backup_filename) == MagickFalse)
4111 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4112 (rename(image->filename,backup_filename) != 0))
4113 *backup_filename='\0';
4116 Write transmogrified image to disk.
4118 image_info->synchronize=MagickTrue;
4119 status&=WriteImages(image_info,image,image->filename,exception);
4120 if ((status == MagickFalse) && (*backup_filename != '\0'))
4121 (void) remove(backup_filename);
4122 RemoveAllImageStack();
4125 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4126 switch (*(option+1))
4130 if (LocaleCompare("adaptive-blur",option+1) == 0)
4133 if (i == (ssize_t) argc)
4134 ThrowMogrifyException(OptionError,"MissingArgument",option);
4135 if (IsGeometry(argv[i]) == MagickFalse)
4136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4139 if (LocaleCompare("adaptive-resize",option+1) == 0)
4142 if (i == (ssize_t) argc)
4143 ThrowMogrifyException(OptionError,"MissingArgument",option);
4144 if (IsGeometry(argv[i]) == MagickFalse)
4145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4148 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4151 if (i == (ssize_t) argc)
4152 ThrowMogrifyException(OptionError,"MissingArgument",option);
4153 if (IsGeometry(argv[i]) == MagickFalse)
4154 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4157 if (LocaleCompare("affine",option+1) == 0)
4162 if (i == (ssize_t) argc)
4163 ThrowMogrifyException(OptionError,"MissingArgument",option);
4166 if (LocaleCompare("alpha",option+1) == 0)
4174 if (i == (ssize_t) argc)
4175 ThrowMogrifyException(OptionError,"MissingArgument",option);
4176 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4178 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4182 if (LocaleCompare("annotate",option+1) == 0)
4187 if (i == (ssize_t) argc)
4188 ThrowMogrifyException(OptionError,"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4191 if (i == (ssize_t) argc)
4192 ThrowMogrifyException(OptionError,"MissingArgument",option);
4196 if (LocaleCompare("antialias",option+1) == 0)
4198 if (LocaleCompare("append",option+1) == 0)
4200 if (LocaleCompare("attenuate",option+1) == 0)
4205 if (i == (ssize_t) (argc-1))
4206 ThrowMogrifyException(OptionError,"MissingArgument",option);
4207 if (IsGeometry(argv[i]) == MagickFalse)
4208 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4211 if (LocaleCompare("authenticate",option+1) == 0)
4216 if (i == (ssize_t) argc)
4217 ThrowMogrifyException(OptionError,"MissingArgument",option);
4220 if (LocaleCompare("auto-gamma",option+1) == 0)
4222 if (LocaleCompare("auto-level",option+1) == 0)
4224 if (LocaleCompare("auto-orient",option+1) == 0)
4226 if (LocaleCompare("average",option+1) == 0)
4228 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4232 if (LocaleCompare("background",option+1) == 0)
4237 if (i == (ssize_t) argc)
4238 ThrowMogrifyException(OptionError,"MissingArgument",option);
4241 if (LocaleCompare("bias",option+1) == 0)
4246 if (i == (ssize_t) (argc-1))
4247 ThrowMogrifyException(OptionError,"MissingArgument",option);
4248 if (IsGeometry(argv[i]) == MagickFalse)
4249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4252 if (LocaleCompare("black-point-compensation",option+1) == 0)
4254 if (LocaleCompare("black-threshold",option+1) == 0)
4259 if (i == (ssize_t) argc)
4260 ThrowMogrifyException(OptionError,"MissingArgument",option);
4261 if (IsGeometry(argv[i]) == MagickFalse)
4262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4265 if (LocaleCompare("blue-primary",option+1) == 0)
4270 if (i == (ssize_t) argc)
4271 ThrowMogrifyException(OptionError,"MissingArgument",option);
4272 if (IsGeometry(argv[i]) == MagickFalse)
4273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4276 if (LocaleCompare("blue-shift",option+1) == 0)
4279 if (i == (ssize_t) argc)
4280 ThrowMogrifyException(OptionError,"MissingArgument",option);
4281 if (IsGeometry(argv[i]) == MagickFalse)
4282 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4285 if (LocaleCompare("blur",option+1) == 0)
4288 if (i == (ssize_t) argc)
4289 ThrowMogrifyException(OptionError,"MissingArgument",option);
4290 if (IsGeometry(argv[i]) == MagickFalse)
4291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4294 if (LocaleCompare("border",option+1) == 0)
4299 if (i == (ssize_t) argc)
4300 ThrowMogrifyException(OptionError,"MissingArgument",option);
4301 if (IsGeometry(argv[i]) == MagickFalse)
4302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4305 if (LocaleCompare("bordercolor",option+1) == 0)
4310 if (i == (ssize_t) argc)
4311 ThrowMogrifyException(OptionError,"MissingArgument",option);
4314 if (LocaleCompare("box",option+1) == 0)
4319 if (i == (ssize_t) argc)
4320 ThrowMogrifyException(OptionError,"MissingArgument",option);
4323 if (LocaleCompare("brightness-contrast",option+1) == 0)
4326 if (i == (ssize_t) argc)
4327 ThrowMogrifyException(OptionError,"MissingArgument",option);
4328 if (IsGeometry(argv[i]) == MagickFalse)
4329 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4332 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4336 if (LocaleCompare("cache",option+1) == 0)
4341 if (i == (ssize_t) argc)
4342 ThrowMogrifyException(OptionError,"MissingArgument",option);
4343 if (IsGeometry(argv[i]) == MagickFalse)
4344 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4347 if (LocaleCompare("caption",option+1) == 0)
4352 if (i == (ssize_t) argc)
4353 ThrowMogrifyException(OptionError,"MissingArgument",option);
4356 if (LocaleCompare("channel",option+1) == 0)
4364 if (i == (ssize_t) (argc-1))
4365 ThrowMogrifyException(OptionError,"MissingArgument",option);
4366 channel=ParseChannelOption(argv[i]);
4368 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4372 if (LocaleCompare("cdl",option+1) == 0)
4377 if (i == (ssize_t) (argc-1))
4378 ThrowMogrifyException(OptionError,"MissingArgument",option);
4381 if (LocaleCompare("charcoal",option+1) == 0)
4386 if (i == (ssize_t) argc)
4387 ThrowMogrifyException(OptionError,"MissingArgument",option);
4388 if (IsGeometry(argv[i]) == MagickFalse)
4389 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4392 if (LocaleCompare("chop",option+1) == 0)
4397 if (i == (ssize_t) argc)
4398 ThrowMogrifyException(OptionError,"MissingArgument",option);
4399 if (IsGeometry(argv[i]) == MagickFalse)
4400 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4403 if (LocaleCompare("clamp",option+1) == 0)
4405 if (LocaleCompare("clip",option+1) == 0)
4407 if (LocaleCompare("clip-mask",option+1) == 0)
4412 if (i == (ssize_t) argc)
4413 ThrowMogrifyException(OptionError,"MissingArgument",option);
4416 if (LocaleCompare("clut",option+1) == 0)
4418 if (LocaleCompare("coalesce",option+1) == 0)
4420 if (LocaleCompare("colorize",option+1) == 0)
4425 if (i == (ssize_t) argc)
4426 ThrowMogrifyException(OptionError,"MissingArgument",option);
4427 if (IsGeometry(argv[i]) == MagickFalse)
4428 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4431 if (LocaleCompare("color-matrix",option+1) == 0)
4439 if (i == (ssize_t) (argc-1))
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4441 kernel_info=AcquireKernelInfo(argv[i]);
4442 if (kernel_info == (KernelInfo *) NULL)
4443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4444 kernel_info=DestroyKernelInfo(kernel_info);
4447 if (LocaleCompare("colors",option+1) == 0)
4452 if (i == (ssize_t) argc)
4453 ThrowMogrifyException(OptionError,"MissingArgument",option);
4454 if (IsGeometry(argv[i]) == MagickFalse)
4455 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4458 if (LocaleCompare("colorspace",option+1) == 0)
4466 if (i == (ssize_t) argc)
4467 ThrowMogrifyException(OptionError,"MissingArgument",option);
4468 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4471 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4475 if (LocaleCompare("combine",option+1) == 0)
4477 if (LocaleCompare("comment",option+1) == 0)
4482 if (i == (ssize_t) argc)
4483 ThrowMogrifyException(OptionError,"MissingArgument",option);
4486 if (LocaleCompare("composite",option+1) == 0)
4488 if (LocaleCompare("compress",option+1) == 0)
4496 if (i == (ssize_t) argc)
4497 ThrowMogrifyException(OptionError,"MissingArgument",option);
4498 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4501 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4505 if (LocaleCompare("concurrent",option+1) == 0)
4507 if (LocaleCompare("contrast",option+1) == 0)
4509 if (LocaleCompare("contrast-stretch",option+1) == 0)
4512 if (i == (ssize_t) argc)
4513 ThrowMogrifyException(OptionError,"MissingArgument",option);
4514 if (IsGeometry(argv[i]) == MagickFalse)
4515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4518 if (LocaleCompare("convolve",option+1) == 0)
4526 if (i == (ssize_t) argc)
4527 ThrowMogrifyException(OptionError,"MissingArgument",option);
4528 kernel_info=AcquireKernelInfo(argv[i]);
4529 if (kernel_info == (KernelInfo *) NULL)
4530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4531 kernel_info=DestroyKernelInfo(kernel_info);
4534 if (LocaleCompare("crop",option+1) == 0)
4539 if (i == (ssize_t) argc)
4540 ThrowMogrifyException(OptionError,"MissingArgument",option);
4541 if (IsGeometry(argv[i]) == MagickFalse)
4542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4545 if (LocaleCompare("cycle",option+1) == 0)
4550 if (i == (ssize_t) argc)
4551 ThrowMogrifyException(OptionError,"MissingArgument",option);
4552 if (IsGeometry(argv[i]) == MagickFalse)
4553 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4556 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4560 if (LocaleCompare("decipher",option+1) == 0)
4565 if (i == (ssize_t) (argc-1))
4566 ThrowMogrifyException(OptionError,"MissingArgument",option);
4569 if (LocaleCompare("deconstruct",option+1) == 0)
4571 if (LocaleCompare("debug",option+1) == 0)
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4583 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4585 (void) SetLogEventMask(argv[i]);
4588 if (LocaleCompare("define",option+1) == 0)
4591 if (i == (ssize_t) argc)
4592 ThrowMogrifyException(OptionError,"MissingArgument",option);
4598 define=GetImageOption(image_info,argv[i]);
4599 if (define == (const char *) NULL)
4600 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4605 if (LocaleCompare("delay",option+1) == 0)
4610 if (i == (ssize_t) argc)
4611 ThrowMogrifyException(OptionError,"MissingArgument",option);
4612 if (IsGeometry(argv[i]) == MagickFalse)
4613 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4616 if (LocaleCompare("density",option+1) == 0)
4621 if (i == (ssize_t) argc)
4622 ThrowMogrifyException(OptionError,"MissingArgument",option);
4623 if (IsGeometry(argv[i]) == MagickFalse)
4624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4627 if (LocaleCompare("depth",option+1) == 0)
4632 if (i == (ssize_t) argc)
4633 ThrowMogrifyException(OptionError,"MissingArgument",option);
4634 if (IsGeometry(argv[i]) == MagickFalse)
4635 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4638 if (LocaleCompare("deskew",option+1) == 0)
4643 if (i == (ssize_t) argc)
4644 ThrowMogrifyException(OptionError,"MissingArgument",option);
4645 if (IsGeometry(argv[i]) == MagickFalse)
4646 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4649 if (LocaleCompare("despeckle",option+1) == 0)
4651 if (LocaleCompare("dft",option+1) == 0)
4653 if (LocaleCompare("direction",option+1) == 0)
4661 if (i == (ssize_t) argc)
4662 ThrowMogrifyException(OptionError,"MissingArgument",option);
4663 direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
4666 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4670 if (LocaleCompare("display",option+1) == 0)
4675 if (i == (ssize_t) argc)
4676 ThrowMogrifyException(OptionError,"MissingArgument",option);
4679 if (LocaleCompare("dispose",option+1) == 0)
4687 if (i == (ssize_t) argc)
4688 ThrowMogrifyException(OptionError,"MissingArgument",option);
4689 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4691 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4695 if (LocaleCompare("distort",option+1) == 0)
4701 if (i == (ssize_t) argc)
4702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4705 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4708 if (i == (ssize_t) (argc-1))
4709 ThrowMogrifyException(OptionError,"MissingArgument",option);
4712 if (LocaleCompare("dither",option+1) == 0)
4720 if (i == (ssize_t) argc)
4721 ThrowMogrifyException(OptionError,"MissingArgument",option);
4722 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4724 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4728 if (LocaleCompare("draw",option+1) == 0)
4733 if (i == (ssize_t) argc)
4734 ThrowMogrifyException(OptionError,"MissingArgument",option);
4737 if (LocaleCompare("duration",option+1) == 0)
4742 if (i == (ssize_t) (argc-1))
4743 ThrowMogrifyException(OptionError,"MissingArgument",option);
4744 if (IsGeometry(argv[i]) == MagickFalse)
4745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4748 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4752 if (LocaleCompare("edge",option+1) == 0)
4757 if (i == (ssize_t) argc)
4758 ThrowMogrifyException(OptionError,"MissingArgument",option);
4759 if (IsGeometry(argv[i]) == MagickFalse)
4760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4763 if (LocaleCompare("emboss",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,"MissingArgument",option);
4770 if (IsGeometry(argv[i]) == MagickFalse)
4771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4774 if (LocaleCompare("encipher",option+1) == 0)
4779 if (i == (ssize_t) argc)
4780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4783 if (LocaleCompare("encoding",option+1) == 0)
4788 if (i == (ssize_t) argc)
4789 ThrowMogrifyException(OptionError,"MissingArgument",option);
4792 if (LocaleCompare("endian",option+1) == 0)
4800 if (i == (ssize_t) argc)
4801 ThrowMogrifyException(OptionError,"MissingArgument",option);
4802 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4804 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4808 if (LocaleCompare("enhance",option+1) == 0)
4810 if (LocaleCompare("equalize",option+1) == 0)
4812 if (LocaleCompare("evaluate",option+1) == 0)
4820 if (i == (ssize_t) argc)
4821 ThrowMogrifyException(OptionError,"MissingArgument",option);
4822 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4824 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4827 if (i == (ssize_t) (argc-1))
4828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4829 if (IsGeometry(argv[i]) == MagickFalse)
4830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4833 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4841 if (i == (ssize_t) argc)
4842 ThrowMogrifyException(OptionError,"MissingArgument",option);
4843 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4845 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4849 if (LocaleCompare("extent",option+1) == 0)
4854 if (i == (ssize_t) argc)
4855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4856 if (IsGeometry(argv[i]) == MagickFalse)
4857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4860 if (LocaleCompare("extract",option+1) == 0)
4865 if (i == (ssize_t) argc)
4866 ThrowMogrifyException(OptionError,"MissingArgument",option);
4867 if (IsGeometry(argv[i]) == MagickFalse)
4868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4871 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4875 if (LocaleCompare("family",option+1) == 0)
4880 if (i == (ssize_t) (argc-1))
4881 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 if (LocaleCompare("fill",option+1) == 0)
4889 if (i == (ssize_t) argc)
4890 ThrowMogrifyException(OptionError,"MissingArgument",option);
4893 if (LocaleCompare("filter",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4903 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4905 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4909 if (LocaleCompare("flatten",option+1) == 0)
4911 if (LocaleCompare("flip",option+1) == 0)
4913 if (LocaleCompare("flop",option+1) == 0)
4915 if (LocaleCompare("floodfill",option+1) == 0)
4920 if (i == (ssize_t) argc)
4921 ThrowMogrifyException(OptionError,"MissingArgument",option);
4922 if (IsGeometry(argv[i]) == MagickFalse)
4923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4925 if (i == (ssize_t) argc)
4926 ThrowMogrifyException(OptionError,"MissingArgument",option);
4929 if (LocaleCompare("font",option+1) == 0)
4934 if (i == (ssize_t) argc)
4935 ThrowMogrifyException(OptionError,"MissingArgument",option);
4938 if (LocaleCompare("format",option+1) == 0)
4940 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4941 (void) CloneString(&format,(char *) NULL);
4945 if (i == (ssize_t) argc)
4946 ThrowMogrifyException(OptionError,"MissingArgument",option);
4947 (void) CloneString(&format,argv[i]);
4948 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4949 (void) ConcatenateMagickString(image_info->filename,":",
4951 (void) SetImageInfo(image_info,0,exception);
4952 if (*image_info->magick == '\0')
4953 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4957 if (LocaleCompare("frame",option+1) == 0)
4962 if (i == (ssize_t) argc)
4963 ThrowMogrifyException(OptionError,"MissingArgument",option);
4964 if (IsGeometry(argv[i]) == MagickFalse)
4965 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4968 if (LocaleCompare("function",option+1) == 0)
4976 if (i == (ssize_t) argc)
4977 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
4980 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4982 if (i == (ssize_t) (argc-1))
4983 ThrowMogrifyException(OptionError,"MissingArgument",option);
4986 if (LocaleCompare("fuzz",option+1) == 0)
4991 if (i == (ssize_t) argc)
4992 ThrowMogrifyException(OptionError,"MissingArgument",option);
4993 if (IsGeometry(argv[i]) == MagickFalse)
4994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4997 if (LocaleCompare("fx",option+1) == 0)
5002 if (i == (ssize_t) (argc-1))
5003 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5010 if (LocaleCompare("gamma",option+1) == 0)
5013 if (i == (ssize_t) argc)
5014 ThrowMogrifyException(OptionError,"MissingArgument",option);
5015 if (IsGeometry(argv[i]) == MagickFalse)
5016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5019 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5020 (LocaleCompare("gaussian",option+1) == 0))
5023 if (i == (ssize_t) argc)
5024 ThrowMogrifyException(OptionError,"MissingArgument",option);
5025 if (IsGeometry(argv[i]) == MagickFalse)
5026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5029 if (LocaleCompare("geometry",option+1) == 0)
5034 if (i == (ssize_t) argc)
5035 ThrowMogrifyException(OptionError,"MissingArgument",option);
5036 if (IsGeometry(argv[i]) == MagickFalse)
5037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5040 if (LocaleCompare("gravity",option+1) == 0)
5048 if (i == (ssize_t) argc)
5049 ThrowMogrifyException(OptionError,"MissingArgument",option);
5050 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5052 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5056 if (LocaleCompare("green-primary",option+1) == 0)
5061 if (i == (ssize_t) argc)
5062 ThrowMogrifyException(OptionError,"MissingArgument",option);
5063 if (IsGeometry(argv[i]) == MagickFalse)
5064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5067 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5071 if (LocaleCompare("hald-clut",option+1) == 0)
5073 if ((LocaleCompare("help",option+1) == 0) ||
5074 (LocaleCompare("-help",option+1) == 0))
5075 return(MogrifyUsage());
5076 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5080 if (LocaleCompare("identify",option+1) == 0)
5082 if (LocaleCompare("idft",option+1) == 0)
5084 if (LocaleCompare("implode",option+1) == 0)
5089 if (i == (ssize_t) argc)
5090 ThrowMogrifyException(OptionError,"MissingArgument",option);
5091 if (IsGeometry(argv[i]) == MagickFalse)
5092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5095 if (LocaleCompare("intent",option+1) == 0)
5103 if (i == (ssize_t) (argc-1))
5104 ThrowMogrifyException(OptionError,"MissingArgument",option);
5105 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5107 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5111 if (LocaleCompare("interlace",option+1) == 0)
5119 if (i == (ssize_t) argc)
5120 ThrowMogrifyException(OptionError,"MissingArgument",option);
5121 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5124 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5128 if (LocaleCompare("interline-spacing",option+1) == 0)
5133 if (i == (ssize_t) (argc-1))
5134 ThrowMogrifyException(OptionError,"MissingArgument",option);
5135 if (IsGeometry(argv[i]) == MagickFalse)
5136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5139 if (LocaleCompare("interpolate",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5149 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5151 if (interpolate < 0)
5152 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5156 if (LocaleCompare("interword-spacing",option+1) == 0)
5161 if (i == (ssize_t) (argc-1))
5162 ThrowMogrifyException(OptionError,"MissingArgument",option);
5163 if (IsGeometry(argv[i]) == MagickFalse)
5164 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5167 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5171 if (LocaleCompare("kerning",option+1) == 0)
5176 if (i == (ssize_t) (argc-1))
5177 ThrowMogrifyException(OptionError,"MissingArgument",option);
5178 if (IsGeometry(argv[i]) == MagickFalse)
5179 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5182 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5186 if (LocaleCompare("label",option+1) == 0)
5191 if (i == (ssize_t) argc)
5192 ThrowMogrifyException(OptionError,"MissingArgument",option);
5195 if (LocaleCompare("lat",option+1) == 0)
5200 if (i == (ssize_t) argc)
5201 ThrowMogrifyException(OptionError,"MissingArgument",option);
5202 if (IsGeometry(argv[i]) == MagickFalse)
5203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5205 if (LocaleCompare("layers",option+1) == 0)
5213 if (i == (ssize_t) (argc-1))
5214 ThrowMogrifyException(OptionError,"MissingArgument",option);
5215 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5217 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5221 if (LocaleCompare("level",option+1) == 0)
5224 if (i == (ssize_t) argc)
5225 ThrowMogrifyException(OptionError,"MissingArgument",option);
5226 if (IsGeometry(argv[i]) == MagickFalse)
5227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5230 if (LocaleCompare("level-colors",option+1) == 0)
5233 if (i == (ssize_t) argc)
5234 ThrowMogrifyException(OptionError,"MissingArgument",option);
5237 if (LocaleCompare("linewidth",option+1) == 0)
5242 if (i == (ssize_t) argc)
5243 ThrowMogrifyException(OptionError,"MissingArgument",option);
5244 if (IsGeometry(argv[i]) == MagickFalse)
5245 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5248 if (LocaleCompare("limit",option+1) == 0)
5262 if (i == (ssize_t) argc)
5263 ThrowMogrifyException(OptionError,"MissingArgument",option);
5264 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5267 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5270 if (i == (ssize_t) argc)
5271 ThrowMogrifyException(OptionError,"MissingArgument",option);
5272 value=strtod(argv[i],&p);
5273 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5277 if (LocaleCompare("liquid-rescale",option+1) == 0)
5280 if (i == (ssize_t) argc)
5281 ThrowMogrifyException(OptionError,"MissingArgument",option);
5282 if (IsGeometry(argv[i]) == MagickFalse)
5283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5286 if (LocaleCompare("list",option+1) == 0)
5294 if (i == (ssize_t) argc)
5295 ThrowMogrifyException(OptionError,"MissingArgument",option);
5296 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5298 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5299 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5301 return(status != 0 ? MagickFalse : MagickTrue);
5303 if (LocaleCompare("log",option+1) == 0)
5308 if ((i == (ssize_t) argc) ||
5309 (strchr(argv[i],'%') == (char *) NULL))
5310 ThrowMogrifyException(OptionError,"MissingArgument",option);
5313 if (LocaleCompare("loop",option+1) == 0)
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,"MissingArgument",option);
5320 if (IsGeometry(argv[i]) == MagickFalse)
5321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5324 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5328 if (LocaleCompare("map",option+1) == 0)
5330 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5334 if (i == (ssize_t) argc)
5335 ThrowMogrifyException(OptionError,"MissingArgument",option);
5338 if (LocaleCompare("mask",option+1) == 0)
5343 if (i == (ssize_t) argc)
5344 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 if (LocaleCompare("matte",option+1) == 0)
5349 if (LocaleCompare("mattecolor",option+1) == 0)
5354 if (i == (ssize_t) argc)
5355 ThrowMogrifyException(OptionError,"MissingArgument",option);
5358 if (LocaleCompare("maximum",option+1) == 0)
5360 if (LocaleCompare("minimum",option+1) == 0)
5362 if (LocaleCompare("modulate",option+1) == 0)
5367 if (i == (ssize_t) argc)
5368 ThrowMogrifyException(OptionError,"MissingArgument",option);
5369 if (IsGeometry(argv[i]) == MagickFalse)
5370 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5373 if (LocaleCompare("median",option+1) == 0)
5378 if (i == (ssize_t) argc)
5379 ThrowMogrifyException(OptionError,"MissingArgument",option);
5380 if (IsGeometry(argv[i]) == MagickFalse)
5381 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5384 if (LocaleCompare("monitor",option+1) == 0)
5386 if (LocaleCompare("monochrome",option+1) == 0)
5388 if (LocaleCompare("morph",option+1) == 0)
5393 if (i == (ssize_t) (argc-1))
5394 ThrowMogrifyException(OptionError,"MissingArgument",option);
5395 if (IsGeometry(argv[i]) == MagickFalse)
5396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5399 if (LocaleCompare("morphology",option+1) == 0)
5402 token[MaxTextExtent];
5411 if (i == (ssize_t) argc)
5412 ThrowMogrifyException(OptionError,"MissingArgument",option);
5413 GetMagickToken(argv[i],NULL,token);
5414 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5416 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5419 if (i == (ssize_t) (argc-1))
5420 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 kernel_info=AcquireKernelInfo(argv[i]);
5422 if (kernel_info == (KernelInfo *) NULL)
5423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5424 kernel_info=DestroyKernelInfo(kernel_info);
5427 if (LocaleCompare("mosaic",option+1) == 0)
5429 if (LocaleCompare("motion-blur",option+1) == 0)
5434 if (i == (ssize_t) argc)
5435 ThrowMogrifyException(OptionError,"MissingArgument",option);
5436 if (IsGeometry(argv[i]) == MagickFalse)
5437 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5440 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5444 if (LocaleCompare("negate",option+1) == 0)
5446 if (LocaleCompare("noise",option+1) == 0)
5449 if (i == (ssize_t) argc)
5450 ThrowMogrifyException(OptionError,"MissingArgument",option);
5456 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5458 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5462 if (IsGeometry(argv[i]) == MagickFalse)
5463 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5466 if (LocaleCompare("noop",option+1) == 0)
5468 if (LocaleCompare("normalize",option+1) == 0)
5470 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5474 if (LocaleCompare("opaque",option+1) == 0)
5477 if (i == (ssize_t) argc)
5478 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (LocaleCompare("ordered-dither",option+1) == 0)
5486 if (i == (ssize_t) argc)
5487 ThrowMogrifyException(OptionError,"MissingArgument",option);
5490 if (LocaleCompare("orient",option+1) == 0)
5495 orientation=UndefinedOrientation;
5499 if (i == (ssize_t) (argc-1))
5500 ThrowMogrifyException(OptionError,"MissingArgument",option);
5501 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5503 if (orientation < 0)
5504 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5508 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5512 if (LocaleCompare("page",option+1) == 0)
5517 if (i == (ssize_t) argc)
5518 ThrowMogrifyException(OptionError,"MissingArgument",option);
5521 if (LocaleCompare("paint",option+1) == 0)
5526 if (i == (ssize_t) argc)
5527 ThrowMogrifyException(OptionError,"MissingArgument",option);
5528 if (IsGeometry(argv[i]) == MagickFalse)
5529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532 if (LocaleCompare("path",option+1) == 0)
5534 (void) CloneString(&path,(char *) NULL);
5538 if (i == (ssize_t) argc)
5539 ThrowMogrifyException(OptionError,"MissingArgument",option);
5540 (void) CloneString(&path,argv[i]);
5543 if (LocaleCompare("pointsize",option+1) == 0)
5548 if (i == (ssize_t) argc)
5549 ThrowMogrifyException(OptionError,"MissingArgument",option);
5550 if (IsGeometry(argv[i]) == MagickFalse)
5551 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5554 if (LocaleCompare("polaroid",option+1) == 0)
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5561 if (IsGeometry(argv[i]) == MagickFalse)
5562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5565 if (LocaleCompare("posterize",option+1) == 0)
5570 if (i == (ssize_t) argc)
5571 ThrowMogrifyException(OptionError,"MissingArgument",option);
5572 if (IsGeometry(argv[i]) == MagickFalse)
5573 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5576 if (LocaleCompare("precision",option+1) == 0)
5581 if (i == (ssize_t) argc)
5582 ThrowMogrifyException(OptionError,"MissingArgument",option);
5583 if (IsGeometry(argv[i]) == MagickFalse)
5584 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5587 if (LocaleCompare("print",option+1) == 0)
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5596 if (LocaleCompare("process",option+1) == 0)
5601 if (i == (ssize_t) (argc-1))
5602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5605 if (LocaleCompare("profile",option+1) == 0)
5608 if (i == (ssize_t) argc)
5609 ThrowMogrifyException(OptionError,"MissingArgument",option);
5612 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5616 if (LocaleCompare("quality",option+1) == 0)
5621 if (i == (ssize_t) argc)
5622 ThrowMogrifyException(OptionError,"MissingArgument",option);
5623 if (IsGeometry(argv[i]) == MagickFalse)
5624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5627 if (LocaleCompare("quantize",option+1) == 0)
5635 if (i == (ssize_t) (argc-1))
5636 ThrowMogrifyException(OptionError,"MissingArgument",option);
5637 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5640 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5644 if (LocaleCompare("quiet",option+1) == 0)
5646 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5650 if (LocaleCompare("radial-blur",option+1) == 0)
5653 if (i == (ssize_t) argc)
5654 ThrowMogrifyException(OptionError,"MissingArgument",option);
5655 if (IsGeometry(argv[i]) == MagickFalse)
5656 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5659 if (LocaleCompare("raise",option+1) == 0)
5662 if (i == (ssize_t) argc)
5663 ThrowMogrifyException(OptionError,"MissingArgument",option);
5664 if (IsGeometry(argv[i]) == MagickFalse)
5665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5668 if (LocaleCompare("random-threshold",option+1) == 0)
5673 if (i == (ssize_t) argc)
5674 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 if (IsGeometry(argv[i]) == MagickFalse)
5676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5679 if (LocaleCompare("recolor",option+1) == 0)
5684 if (i == (ssize_t) (argc-1))
5685 ThrowMogrifyException(OptionError,"MissingArgument",option);
5686 if (IsGeometry(argv[i]) == MagickFalse)
5687 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5690 if (LocaleCompare("red-primary",option+1) == 0)
5695 if (i == (ssize_t) argc)
5696 ThrowMogrifyException(OptionError,"MissingArgument",option);
5697 if (IsGeometry(argv[i]) == MagickFalse)
5698 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5700 if (LocaleCompare("regard-warnings",option+1) == 0)
5702 if (LocaleCompare("region",option+1) == 0)
5707 if (i == (ssize_t) argc)
5708 ThrowMogrifyException(OptionError,"MissingArgument",option);
5709 if (IsGeometry(argv[i]) == MagickFalse)
5710 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5713 if (LocaleCompare("remap",option+1) == 0)
5718 if (i == (ssize_t) (argc-1))
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5722 if (LocaleCompare("render",option+1) == 0)
5724 if (LocaleCompare("repage",option+1) == 0)
5729 if (i == (ssize_t) argc)
5730 ThrowMogrifyException(OptionError,"MissingArgument",option);
5731 if (IsGeometry(argv[i]) == MagickFalse)
5732 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5735 if (LocaleCompare("resample",option+1) == 0)
5740 if (i == (ssize_t) argc)
5741 ThrowMogrifyException(OptionError,"MissingArgument",option);
5742 if (IsGeometry(argv[i]) == MagickFalse)
5743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5746 if (LocaleCompare("resize",option+1) == 0)
5751 if (i == (ssize_t) argc)
5752 ThrowMogrifyException(OptionError,"MissingArgument",option);
5753 if (IsGeometry(argv[i]) == MagickFalse)
5754 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5757 if (LocaleCompare("reverse",option+1) == 0)
5759 if (LocaleCompare("roll",option+1) == 0)
5764 if (i == (ssize_t) argc)
5765 ThrowMogrifyException(OptionError,"MissingArgument",option);
5766 if (IsGeometry(argv[i]) == MagickFalse)
5767 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5770 if (LocaleCompare("rotate",option+1) == 0)
5773 if (i == (ssize_t) argc)
5774 ThrowMogrifyException(OptionError,"MissingArgument",option);
5775 if (IsGeometry(argv[i]) == MagickFalse)
5776 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5779 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5783 if (LocaleCompare("sample",option+1) == 0)
5788 if (i == (ssize_t) argc)
5789 ThrowMogrifyException(OptionError,"MissingArgument",option);
5790 if (IsGeometry(argv[i]) == MagickFalse)
5791 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5794 if (LocaleCompare("sampling-factor",option+1) == 0)
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5801 if (IsGeometry(argv[i]) == MagickFalse)
5802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5805 if (LocaleCompare("scale",option+1) == 0)
5810 if (i == (ssize_t) argc)
5811 ThrowMogrifyException(OptionError,"MissingArgument",option);
5812 if (IsGeometry(argv[i]) == MagickFalse)
5813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5816 if (LocaleCompare("scene",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5827 if (LocaleCompare("seed",option+1) == 0)
5832 if (i == (ssize_t) argc)
5833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 if (IsGeometry(argv[i]) == MagickFalse)
5835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5838 if (LocaleCompare("segment",option+1) == 0)
5843 if (i == (ssize_t) argc)
5844 ThrowMogrifyException(OptionError,"MissingArgument",option);
5845 if (IsGeometry(argv[i]) == MagickFalse)
5846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5849 if (LocaleCompare("selective-blur",option+1) == 0)
5852 if (i == (ssize_t) argc)
5853 ThrowMogrifyException(OptionError,"MissingArgument",option);
5854 if (IsGeometry(argv[i]) == MagickFalse)
5855 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5858 if (LocaleCompare("separate",option+1) == 0)
5860 if (LocaleCompare("sepia-tone",option+1) == 0)
5865 if (i == (ssize_t) argc)
5866 ThrowMogrifyException(OptionError,"MissingArgument",option);
5867 if (IsGeometry(argv[i]) == MagickFalse)
5868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5871 if (LocaleCompare("set",option+1) == 0)
5874 if (i == (ssize_t) argc)
5875 ThrowMogrifyException(OptionError,"MissingArgument",option);
5879 if (i == (ssize_t) argc)
5880 ThrowMogrifyException(OptionError,"MissingArgument",option);
5883 if (LocaleCompare("shade",option+1) == 0)
5886 if (i == (ssize_t) argc)
5887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 if (IsGeometry(argv[i]) == MagickFalse)
5889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5892 if (LocaleCompare("shadow",option+1) == 0)
5897 if (i == (ssize_t) argc)
5898 ThrowMogrifyException(OptionError,"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5903 if (LocaleCompare("sharpen",option+1) == 0)
5906 if (i == (ssize_t) argc)
5907 ThrowMogrifyException(OptionError,"MissingArgument",option);
5908 if (IsGeometry(argv[i]) == MagickFalse)
5909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 if (LocaleCompare("shave",option+1) == 0)
5917 if (i == (ssize_t) argc)
5918 ThrowMogrifyException(OptionError,"MissingArgument",option);
5919 if (IsGeometry(argv[i]) == MagickFalse)
5920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5923 if (LocaleCompare("shear",option+1) == 0)
5926 if (i == (ssize_t) argc)
5927 ThrowMogrifyException(OptionError,"MissingArgument",option);
5928 if (IsGeometry(argv[i]) == MagickFalse)
5929 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5932 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5935 if (i == (ssize_t) (argc-1))
5936 ThrowMogrifyException(OptionError,"MissingArgument",option);
5937 if (IsGeometry(argv[i]) == MagickFalse)
5938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5941 if (LocaleCompare("size",option+1) == 0)
5946 if (i == (ssize_t) argc)
5947 ThrowMogrifyException(OptionError,"MissingArgument",option);
5948 if (IsGeometry(argv[i]) == MagickFalse)
5949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5952 if (LocaleCompare("sketch",option+1) == 0)
5957 if (i == (ssize_t) argc)
5958 ThrowMogrifyException(OptionError,"MissingArgument",option);
5959 if (IsGeometry(argv[i]) == MagickFalse)
5960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5963 if (LocaleCompare("solarize",option+1) == 0)
5968 if (i == (ssize_t) argc)
5969 ThrowMogrifyException(OptionError,"MissingArgument",option);
5970 if (IsGeometry(argv[i]) == MagickFalse)
5971 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5974 if (LocaleCompare("sparse-color",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,"MissingArgument",option);
5982 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5984 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5987 if (i == (ssize_t) (argc-1))
5988 ThrowMogrifyException(OptionError,"MissingArgument",option);
5991 if (LocaleCompare("spread",option+1) == 0)
5996 if (i == (ssize_t) argc)
5997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5998 if (IsGeometry(argv[i]) == MagickFalse)
5999 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6002 if (LocaleCompare("stretch",option+1) == 0)
6010 if (i == (ssize_t) (argc-1))
6011 ThrowMogrifyException(OptionError,"MissingArgument",option);
6012 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6014 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6018 if (LocaleCompare("strip",option+1) == 0)
6020 if (LocaleCompare("stroke",option+1) == 0)
6025 if (i == (ssize_t) argc)
6026 ThrowMogrifyException(OptionError,"MissingArgument",option);
6029 if (LocaleCompare("strokewidth",option+1) == 0)
6034 if (i == (ssize_t) argc)
6035 ThrowMogrifyException(OptionError,"MissingArgument",option);
6036 if (IsGeometry(argv[i]) == MagickFalse)
6037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6040 if (LocaleCompare("style",option+1) == 0)
6048 if (i == (ssize_t) (argc-1))
6049 ThrowMogrifyException(OptionError,"MissingArgument",option);
6050 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6052 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6056 if (LocaleCompare("swirl",option+1) == 0)
6061 if (i == (ssize_t) argc)
6062 ThrowMogrifyException(OptionError,"MissingArgument",option);
6063 if (IsGeometry(argv[i]) == MagickFalse)
6064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6067 if (LocaleCompare("synchronize",option+1) == 0)
6069 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6073 if (LocaleCompare("taint",option+1) == 0)
6075 if (LocaleCompare("texture",option+1) == 0)
6080 if (i == (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,"MissingArgument",option);
6084 if (LocaleCompare("tile",option+1) == 0)
6089 if (i == (ssize_t) (argc-1))
6090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6093 if (LocaleCompare("tile-offset",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6104 if (LocaleCompare("tint",option+1) == 0)
6109 if (i == (ssize_t) (argc-1))
6110 ThrowMogrifyException(OptionError,"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6115 if (LocaleCompare("transform",option+1) == 0)
6117 if (LocaleCompare("transpose",option+1) == 0)
6119 if (LocaleCompare("transverse",option+1) == 0)
6121 if (LocaleCompare("threshold",option+1) == 0)
6126 if (i == (ssize_t) argc)
6127 ThrowMogrifyException(OptionError,"MissingArgument",option);
6128 if (IsGeometry(argv[i]) == MagickFalse)
6129 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6132 if (LocaleCompare("thumbnail",option+1) == 0)
6137 if (i == (ssize_t) argc)
6138 ThrowMogrifyException(OptionError,"MissingArgument",option);
6139 if (IsGeometry(argv[i]) == MagickFalse)
6140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6143 if (LocaleCompare("transparent",option+1) == 0)
6146 if (i == (ssize_t) argc)
6147 ThrowMogrifyException(OptionError,"MissingArgument",option);
6150 if (LocaleCompare("transparent-color",option+1) == 0)
6155 if (i == (ssize_t) (argc-1))
6156 ThrowMogrifyException(OptionError,"MissingArgument",option);
6159 if (LocaleCompare("treedepth",option+1) == 0)
6164 if (i == (ssize_t) argc)
6165 ThrowMogrifyException(OptionError,"MissingArgument",option);
6166 if (IsGeometry(argv[i]) == MagickFalse)
6167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6170 if (LocaleCompare("trim",option+1) == 0)
6172 if (LocaleCompare("type",option+1) == 0)
6180 if (i == (ssize_t) argc)
6181 ThrowMogrifyException(OptionError,"MissingArgument",option);
6182 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6184 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6188 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6192 if (LocaleCompare("undercolor",option+1) == 0)
6197 if (i == (ssize_t) argc)
6198 ThrowMogrifyException(OptionError,"MissingArgument",option);
6201 if (LocaleCompare("unique-colors",option+1) == 0)
6203 if (LocaleCompare("units",option+1) == 0)
6211 if (i == (ssize_t) argc)
6212 ThrowMogrifyException(OptionError,"MissingArgument",option);
6213 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6216 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6220 if (LocaleCompare("unsharp",option+1) == 0)
6223 if (i == (ssize_t) argc)
6224 ThrowMogrifyException(OptionError,"MissingArgument",option);
6225 if (IsGeometry(argv[i]) == MagickFalse)
6226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6229 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6233 if (LocaleCompare("verbose",option+1) == 0)
6235 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6238 if ((LocaleCompare("version",option+1) == 0) ||
6239 (LocaleCompare("-version",option+1) == 0))
6241 (void) fprintf(stdout,"Version: %s\n",
6242 GetMagickVersion((size_t *) NULL));
6243 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6244 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
6247 if (LocaleCompare("view",option+1) == 0)
6252 if (i == (ssize_t) argc)
6253 ThrowMogrifyException(OptionError,"MissingArgument",option);
6256 if (LocaleCompare("vignette",option+1) == 0)
6261 if (i == (ssize_t) argc)
6262 ThrowMogrifyException(OptionError,"MissingArgument",option);
6263 if (IsGeometry(argv[i]) == MagickFalse)
6264 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6267 if (LocaleCompare("virtual-pixel",option+1) == 0)
6275 if (i == (ssize_t) argc)
6276 ThrowMogrifyException(OptionError,"MissingArgument",option);
6277 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6280 ThrowMogrifyException(OptionError,
6281 "UnrecognizedVirtualPixelMethod",argv[i]);
6284 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6288 if (LocaleCompare("wave",option+1) == 0)
6291 if (i == (ssize_t) argc)
6292 ThrowMogrifyException(OptionError,"MissingArgument",option);
6293 if (IsGeometry(argv[i]) == MagickFalse)
6294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6297 if (LocaleCompare("weight",option+1) == 0)
6302 if (i == (ssize_t) (argc-1))
6303 ThrowMogrifyException(OptionError,"MissingArgument",option);
6306 if (LocaleCompare("white-point",option+1) == 0)
6311 if (i == (ssize_t) argc)
6312 ThrowMogrifyException(OptionError,"MissingArgument",option);
6313 if (IsGeometry(argv[i]) == MagickFalse)
6314 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6317 if (LocaleCompare("white-threshold",option+1) == 0)
6322 if (i == (ssize_t) argc)
6323 ThrowMogrifyException(OptionError,"MissingArgument",option);
6324 if (IsGeometry(argv[i]) == MagickFalse)
6325 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6328 if (LocaleCompare("write",option+1) == 0)
6331 if (i == (ssize_t) (argc-1))
6332 ThrowMogrifyException(OptionError,"MissingArgument",option);
6335 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6340 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6342 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6343 MagickFalse : MagickTrue;
6344 if (fire != MagickFalse)
6345 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6348 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6349 if (i != (ssize_t) argc)
6350 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6352 return(status != 0 ? MagickTrue : MagickFalse);
6356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6360 + M o g r i f y I m a g e I n f o %
6364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6366 % MogrifyImageInfo() applies image processing settings to the image as
6367 % prescribed by command line options.
6369 % The format of the MogrifyImageInfo method is:
6371 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6372 % const char **argv,ExceptionInfo *exception)
6374 % A description of each parameter follows:
6376 % o image_info: the image info..
6378 % o argc: Specifies a pointer to an integer describing the number of
6379 % elements in the argument vector.
6381 % o argv: Specifies a pointer to a text array containing the command line
6384 % o exception: return any errors or warnings in this structure.
6387 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6388 const int argc,const char **argv,ExceptionInfo *exception)
6403 Initialize method variables.
6405 assert(image_info != (ImageInfo *) NULL);
6406 assert(image_info->signature == MagickSignature);
6407 if (image_info->debug != MagickFalse)
6408 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6409 image_info->filename);
6413 Set the image settings.
6415 for (i=0; i < (ssize_t) argc; i++)
6418 if (IsMagickOption(option) == MagickFalse)
6420 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6422 if ((i+count) >= (ssize_t) argc)
6424 switch (*(option+1))
6428 if (LocaleCompare("adjoin",option+1) == 0)
6430 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6433 if (LocaleCompare("antialias",option+1) == 0)
6435 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6438 if (LocaleCompare("attenuate",option+1) == 0)
6442 (void) DeleteImageOption(image_info,option+1);
6445 (void) SetImageOption(image_info,option+1,argv[i+1]);
6448 if (LocaleCompare("authenticate",option+1) == 0)
6451 (void) CloneString(&image_info->authenticate,(char *) NULL);
6453 (void) CloneString(&image_info->authenticate,argv[i+1]);
6460 if (LocaleCompare("background",option+1) == 0)
6464 (void) DeleteImageOption(image_info,option+1);
6465 (void) QueryColorDatabase(BackgroundColor,
6466 &image_info->background_color,exception);
6469 (void) SetImageOption(image_info,option+1,argv[i+1]);
6470 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6474 if (LocaleCompare("bias",option+1) == 0)
6478 (void) SetImageOption(image_info,option+1,"0.0");
6481 (void) SetImageOption(image_info,option+1,argv[i+1]);
6484 if (LocaleCompare("black-point-compensation",option+1) == 0)
6488 (void) SetImageOption(image_info,option+1,"false");
6491 (void) SetImageOption(image_info,option+1,"true");
6494 if (LocaleCompare("blue-primary",option+1) == 0)
6498 (void) SetImageOption(image_info,option+1,"0.0");
6501 (void) SetImageOption(image_info,option+1,argv[i+1]);
6504 if (LocaleCompare("bordercolor",option+1) == 0)
6508 (void) DeleteImageOption(image_info,option+1);
6509 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6513 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6515 (void) SetImageOption(image_info,option+1,argv[i+1]);
6518 if (LocaleCompare("box",option+1) == 0)
6522 (void) SetImageOption(image_info,"undercolor","none");
6525 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6532 if (LocaleCompare("cache",option+1) == 0)
6537 limit=MagickResourceInfinity;
6538 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6539 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6540 (void) SetMagickResourceLimit(MemoryResource,limit);
6541 (void) SetMagickResourceLimit(MapResource,2*limit);
6544 if (LocaleCompare("caption",option+1) == 0)
6548 (void) DeleteImageOption(image_info,option+1);
6551 (void) SetImageOption(image_info,option+1,argv[i+1]);
6554 if (LocaleCompare("channel",option+1) == 0)
6558 image_info->channel=DefaultChannels;
6561 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6564 if (LocaleCompare("colors",option+1) == 0)
6566 image_info->colors=StringToUnsignedLong(argv[i+1]);
6569 if (LocaleCompare("colorspace",option+1) == 0)
6573 image_info->colorspace=UndefinedColorspace;
6574 (void) SetImageOption(image_info,option+1,"undefined");
6577 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6578 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6579 (void) SetImageOption(image_info,option+1,argv[i+1]);
6582 if (LocaleCompare("compress",option+1) == 0)
6586 image_info->compression=UndefinedCompression;
6587 (void) SetImageOption(image_info,option+1,"undefined");
6590 image_info->compression=(CompressionType) ParseMagickOption(
6591 MagickCompressOptions,MagickFalse,argv[i+1]);
6592 (void) SetImageOption(image_info,option+1,argv[i+1]);
6595 if (LocaleCompare("comment",option+1) == 0)
6599 (void) DeleteImageOption(image_info,option+1);
6602 (void) SetImageOption(image_info,option+1,argv[i+1]);
6605 if (LocaleCompare("compose",option+1) == 0)
6609 (void) SetImageOption(image_info,option+1,"undefined");
6612 (void) SetImageOption(image_info,option+1,argv[i+1]);
6615 if (LocaleCompare("compress",option+1) == 0)
6619 image_info->compression=UndefinedCompression;
6620 (void) SetImageOption(image_info,option+1,"undefined");
6623 image_info->compression=(CompressionType) ParseMagickOption(
6624 MagickCompressOptions,MagickFalse,argv[i+1]);
6625 (void) SetImageOption(image_info,option+1,argv[i+1]);
6632 if (LocaleCompare("debug",option+1) == 0)
6635 (void) SetLogEventMask("none");
6637 (void) SetLogEventMask(argv[i+1]);
6638 image_info->debug=IsEventLogging();
6641 if (LocaleCompare("define",option+1) == 0)
6645 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6646 (void) DeleteImageRegistry(argv[i+1]+9);
6648 (void) DeleteImageOption(image_info,argv[i+1]);
6651 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6653 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6657 (void) DefineImageOption(image_info,argv[i+1]);
6660 if (LocaleCompare("delay",option+1) == 0)
6664 (void) SetImageOption(image_info,option+1,"0");
6667 (void) SetImageOption(image_info,option+1,argv[i+1]);
6670 if (LocaleCompare("density",option+1) == 0)
6677 if (image_info->density != (char *) NULL)
6678 image_info->density=DestroyString(image_info->density);
6679 (void) SetImageOption(image_info,option+1,"72");
6682 (void) CloneString(&image_info->density,argv[i+1]);
6683 (void) SetImageOption(image_info,option+1,argv[i+1]);
6686 if (LocaleCompare("depth",option+1) == 0)
6690 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6693 image_info->depth=StringToUnsignedLong(argv[i+1]);
6696 if (LocaleCompare("direction",option+1) == 0)
6700 (void) SetImageOption(image_info,option+1,"undefined");
6703 (void) SetImageOption(image_info,option+1,argv[i+1]);
6706 if (LocaleCompare("display",option+1) == 0)
6710 if (image_info->server_name != (char *) NULL)
6711 image_info->server_name=DestroyString(
6712 image_info->server_name);
6715 (void) CloneString(&image_info->server_name,argv[i+1]);
6718 if (LocaleCompare("dispose",option+1) == 0)
6722 (void) SetImageOption(image_info,option+1,"undefined");
6725 (void) SetImageOption(image_info,option+1,argv[i+1]);
6728 if (LocaleCompare("dither",option+1) == 0)
6732 image_info->dither=MagickFalse;
6733 (void) SetImageOption(image_info,option+1,"none");
6736 (void) SetImageOption(image_info,option+1,argv[i+1]);
6737 image_info->dither=MagickTrue;
6744 if (LocaleCompare("encoding",option+1) == 0)
6748 (void) SetImageOption(image_info,option+1,"undefined");
6751 (void) SetImageOption(image_info,option+1,argv[i+1]);
6754 if (LocaleCompare("endian",option+1) == 0)
6758 image_info->endian=UndefinedEndian;
6759 (void) SetImageOption(image_info,option+1,"undefined");
6762 image_info->endian=(EndianType) ParseMagickOption(
6763 MagickEndianOptions,MagickFalse,argv[i+1]);
6764 (void) SetImageOption(image_info,option+1,argv[i+1]);
6767 if (LocaleCompare("extract",option+1) == 0)
6770 Set image extract geometry.
6774 if (image_info->extract != (char *) NULL)
6775 image_info->extract=DestroyString(image_info->extract);
6778 (void) CloneString(&image_info->extract,argv[i+1]);
6785 if (LocaleCompare("fill",option+1) == 0)
6789 (void) SetImageOption(image_info,option+1,"none");
6792 (void) SetImageOption(image_info,option+1,argv[i+1]);
6795 if (LocaleCompare("filter",option+1) == 0)
6799 (void) SetImageOption(image_info,option+1,"undefined");
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
6805 if (LocaleCompare("font",option+1) == 0)
6809 if (image_info->font != (char *) NULL)
6810 image_info->font=DestroyString(image_info->font);
6813 (void) CloneString(&image_info->font,argv[i+1]);
6816 if (LocaleCompare("format",option+1) == 0)
6821 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6822 if (strchr("gkrz@[#",*(q+1)) != (char *) NULL)
6823 image_info->ping=MagickFalse;
6824 (void) SetImageOption(image_info,option+1,argv[i+1]);
6827 if (LocaleCompare("fuzz",option+1) == 0)
6831 image_info->fuzz=0.0;
6832 (void) SetImageOption(image_info,option+1,"0");
6835 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6837 (void) SetImageOption(image_info,option+1,argv[i+1]);
6844 if (LocaleCompare("gravity",option+1) == 0)
6848 (void) SetImageOption(image_info,option+1,"undefined");
6851 (void) SetImageOption(image_info,option+1,argv[i+1]);
6854 if (LocaleCompare("green-primary",option+1) == 0)
6858 (void) SetImageOption(image_info,option+1,"0.0");
6861 (void) SetImageOption(image_info,option+1,argv[i+1]);
6868 if (LocaleCompare("intent",option+1) == 0)
6872 (void) SetImageOption(image_info,option+1,"undefined");
6875 (void) SetImageOption(image_info,option+1,argv[i+1]);
6878 if (LocaleCompare("interlace",option+1) == 0)
6882 image_info->interlace=UndefinedInterlace;
6883 (void) SetImageOption(image_info,option+1,"undefined");
6886 image_info->interlace=(InterlaceType) ParseMagickOption(
6887 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6888 (void) SetImageOption(image_info,option+1,argv[i+1]);
6891 if (LocaleCompare("interline-spacing",option+1) == 0)
6895 (void) SetImageOption(image_info,option+1,"undefined");
6898 (void) SetImageOption(image_info,option+1,argv[i+1]);
6901 if (LocaleCompare("interpolate",option+1) == 0)
6905 (void) SetImageOption(image_info,option+1,"undefined");
6908 (void) SetImageOption(image_info,option+1,argv[i+1]);
6911 if (LocaleCompare("interword-spacing",option+1) == 0)
6915 (void) SetImageOption(image_info,option+1,"undefined");
6918 (void) SetImageOption(image_info,option+1,argv[i+1]);
6925 if (LocaleCompare("kerning",option+1) == 0)
6929 (void) SetImageOption(image_info,option+1,"undefined");
6932 (void) SetImageOption(image_info,option+1,argv[i+1]);
6939 if (LocaleCompare("label",option+1) == 0)
6943 (void) DeleteImageOption(image_info,option+1);
6946 (void) SetImageOption(image_info,option+1,argv[i+1]);
6949 if (LocaleCompare("limit",option+1) == 0)
6959 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
6960 MagickFalse,argv[i+1]);
6961 limit=MagickResourceInfinity;
6962 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6963 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6964 (void) SetMagickResourceLimit(type,limit);
6967 if (LocaleCompare("list",option+1) == 0)
6973 Display configuration list.
6975 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
6978 case MagickCoderOptions:
6980 (void) ListCoderInfo((FILE *) NULL,exception);
6983 case MagickColorOptions:
6985 (void) ListColorInfo((FILE *) NULL,exception);
6988 case MagickConfigureOptions:
6990 (void) ListConfigureInfo((FILE *) NULL,exception);
6993 case MagickDelegateOptions:
6995 (void) ListDelegateInfo((FILE *) NULL,exception);
6998 case MagickFontOptions:
7000 (void) ListTypeInfo((FILE *) NULL,exception);
7003 case MagickFormatOptions:
7005 (void) ListMagickInfo((FILE *) NULL,exception);
7008 case MagickLocaleOptions:
7010 (void) ListLocaleInfo((FILE *) NULL,exception);
7013 case MagickLogOptions:
7015 (void) ListLogInfo((FILE *) NULL,exception);
7018 case MagickMagicOptions:
7020 (void) ListMagicInfo((FILE *) NULL,exception);
7023 case MagickMimeOptions:
7025 (void) ListMimeInfo((FILE *) NULL,exception);
7028 case MagickModuleOptions:
7030 (void) ListModuleInfo((FILE *) NULL,exception);
7033 case MagickPolicyOptions:
7035 (void) ListPolicyInfo((FILE *) NULL,exception);
7038 case MagickResourceOptions:
7040 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7043 case MagickThresholdOptions:
7045 (void) ListThresholdMaps((FILE *) NULL,exception);
7050 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7057 if (LocaleCompare("log",option+1) == 0)
7061 (void) SetLogFormat(argv[i+1]);
7064 if (LocaleCompare("loop",option+1) == 0)
7068 (void) SetImageOption(image_info,option+1,"0");
7071 (void) SetImageOption(image_info,option+1,argv[i+1]);
7078 if (LocaleCompare("matte",option+1) == 0)
7082 (void) SetImageOption(image_info,option+1,"false");
7085 (void) SetImageOption(image_info,option+1,"true");
7088 if (LocaleCompare("mattecolor",option+1) == 0)
7092 (void) SetImageOption(image_info,option+1,argv[i+1]);
7093 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7097 (void) SetImageOption(image_info,option+1,argv[i+1]);
7098 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7102 if (LocaleCompare("monitor",option+1) == 0)
7104 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7108 if (LocaleCompare("monochrome",option+1) == 0)
7110 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7117 if (LocaleCompare("orient",option+1) == 0)
7121 image_info->orientation=UndefinedOrientation;
7122 (void) SetImageOption(image_info,option+1,"undefined");
7125 image_info->orientation=(OrientationType) ParseMagickOption(
7126 MagickOrientationOptions,MagickFalse,argv[i+1]);
7127 (void) SetImageOption(image_info,option+1,argv[i+1]);
7133 if (LocaleCompare("page",option+1) == 0)
7137 page[MaxTextExtent];
7150 (void) DeleteImageOption(image_info,option+1);
7151 (void) CloneString(&image_info->page,(char *) NULL);
7154 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7155 image_option=GetImageOption(image_info,"page");
7156 if (image_option != (const char *) NULL)
7157 flags=ParseAbsoluteGeometry(image_option,&geometry);
7158 canonical_page=GetPageGeometry(argv[i+1]);
7159 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7160 canonical_page=DestroyString(canonical_page);
7161 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
7162 (unsigned long) geometry.width,(unsigned long) geometry.height);
7163 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7164 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7165 (unsigned long) geometry.width,(unsigned long) geometry.height,
7166 (long) geometry.x,(long) geometry.y);
7167 (void) SetImageOption(image_info,option+1,page);
7168 (void) CloneString(&image_info->page,page);
7171 if (LocaleCompare("pen",option+1) == 0)
7175 (void) SetImageOption(image_info,option+1,"none");
7178 (void) SetImageOption(image_info,option+1,argv[i+1]);
7181 if (LocaleCompare("ping",option+1) == 0)
7183 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7186 if (LocaleCompare("pointsize",option+1) == 0)
7189 geometry_info.rho=0.0;
7191 (void) ParseGeometry(argv[i+1],&geometry_info);
7192 image_info->pointsize=geometry_info.rho;
7195 if (LocaleCompare("precision",option+1) == 0)
7197 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7200 if (LocaleCompare("preview",option+1) == 0)
7207 image_info->preview_type=UndefinedPreview;
7210 image_info->preview_type=(PreviewType) ParseMagickOption(
7211 MagickPreviewOptions,MagickFalse,argv[i+1]);
7218 if (LocaleCompare("quality",option+1) == 0)
7221 Set image compression quality.
7225 image_info->quality=UndefinedCompressionQuality;
7226 (void) SetImageOption(image_info,option+1,"0");
7229 image_info->quality=StringToUnsignedLong(argv[i+1]);
7230 (void) SetImageOption(image_info,option+1,argv[i+1]);
7233 if (LocaleCompare("quiet",option+1) == 0)
7235 static WarningHandler
7236 warning_handler = (WarningHandler) NULL;
7241 Restore error or warning messages.
7243 warning_handler=SetWarningHandler(warning_handler);
7247 Suppress error or warning messages.
7249 warning_handler=SetWarningHandler((WarningHandler) NULL);
7256 if (LocaleCompare("red-primary",option+1) == 0)
7260 (void) SetImageOption(image_info,option+1,"0.0");
7263 (void) SetImageOption(image_info,option+1,argv[i+1]);
7270 if (LocaleCompare("sampling-factor",option+1) == 0)
7273 Set image sampling factor.
7277 if (image_info->sampling_factor != (char *) NULL)
7278 image_info->sampling_factor=DestroyString(
7279 image_info->sampling_factor);
7282 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7285 if (LocaleCompare("scene",option+1) == 0)
7292 image_info->scene=0;
7293 (void) SetImageOption(image_info,option+1,"0");
7296 image_info->scene=StringToUnsignedLong(argv[i+1]);
7297 (void) SetImageOption(image_info,option+1,argv[i+1]);
7300 if (LocaleCompare("seed",option+1) == 0)
7307 seed=(size_t) time((time_t *) NULL);
7308 SeedPseudoRandomGenerator(seed);
7311 seed=StringToUnsignedLong(argv[i+1]);
7312 SeedPseudoRandomGenerator(seed);
7315 if (LocaleCompare("size",option+1) == 0)
7319 if (image_info->size != (char *) NULL)
7320 image_info->size=DestroyString(image_info->size);
7323 (void) CloneString(&image_info->size,argv[i+1]);
7326 if (LocaleCompare("stroke",option+1) == 0)
7330 (void) SetImageOption(image_info,option+1,"none");
7333 (void) SetImageOption(image_info,option+1,argv[i+1]);
7336 if (LocaleCompare("strokewidth",option+1) == 0)
7340 (void) SetImageOption(image_info,option+1,"0");
7343 (void) SetImageOption(image_info,option+1,argv[i+1]);
7346 if (LocaleCompare("synchronize",option+1) == 0)
7350 image_info->synchronize=MagickFalse;
7353 image_info->synchronize=MagickTrue;
7360 if (LocaleCompare("taint",option+1) == 0)
7364 (void) SetImageOption(image_info,option+1,"false");
7367 (void) SetImageOption(image_info,option+1,"true");
7370 if (LocaleCompare("texture",option+1) == 0)
7374 if (image_info->texture != (char *) NULL)
7375 image_info->texture=DestroyString(image_info->texture);
7378 (void) CloneString(&image_info->texture,argv[i+1]);
7381 if (LocaleCompare("tile-offset",option+1) == 0)
7385 (void) SetImageOption(image_info,option+1,"0");
7388 (void) SetImageOption(image_info,option+1,argv[i+1]);
7391 if (LocaleCompare("transparent-color",option+1) == 0)
7395 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7396 (void) SetImageOption(image_info,option+1,"none");
7399 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7401 (void) SetImageOption(image_info,option+1,argv[i+1]);
7404 if (LocaleCompare("type",option+1) == 0)
7408 image_info->type=UndefinedType;
7409 (void) SetImageOption(image_info,option+1,"undefined");
7412 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7413 MagickFalse,argv[i+1]);
7414 (void) SetImageOption(image_info,option+1,argv[i+1]);
7421 if (LocaleCompare("undercolor",option+1) == 0)
7425 (void) DeleteImageOption(image_info,option+1);
7428 (void) SetImageOption(image_info,option+1,argv[i+1]);
7431 if (LocaleCompare("units",option+1) == 0)
7435 image_info->units=UndefinedResolution;
7436 (void) SetImageOption(image_info,option+1,"undefined");
7439 image_info->units=(ResolutionType) ParseMagickOption(
7440 MagickResolutionOptions,MagickFalse,argv[i+1]);
7441 (void) SetImageOption(image_info,option+1,argv[i+1]);
7448 if (LocaleCompare("verbose",option+1) == 0)
7452 image_info->verbose=MagickFalse;
7455 image_info->verbose=MagickTrue;
7456 image_info->ping=MagickFalse;
7459 if (LocaleCompare("view",option+1) == 0)
7463 if (image_info->view != (char *) NULL)
7464 image_info->view=DestroyString(image_info->view);
7467 (void) CloneString(&image_info->view,argv[i+1]);
7470 if (LocaleCompare("virtual-pixel",option+1) == 0)
7474 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7475 (void) SetImageOption(image_info,option+1,"undefined");
7478 image_info->virtual_pixel_method=(VirtualPixelMethod)
7479 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7481 (void) SetImageOption(image_info,option+1,argv[i+1]);
7488 if (LocaleCompare("white-point",option+1) == 0)
7492 (void) SetImageOption(image_info,option+1,"0.0");
7495 (void) SetImageOption(image_info,option+1,argv[i+1]);
7509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7513 + M o g r i f y I m a g e L i s t %
7517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7519 % MogrifyImageList() applies any command line options that might affect the
7520 % entire image list (e.g. -append, -coalesce, etc.).
7522 % The format of the MogrifyImage method is:
7524 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7525 % const char **argv,Image **images,ExceptionInfo *exception)
7527 % A description of each parameter follows:
7529 % o image_info: the image info..
7531 % o argc: Specifies a pointer to an integer describing the number of
7532 % elements in the argument vector.
7534 % o argv: Specifies a pointer to a text array containing the command line
7537 % o images: the images.
7539 % o exception: return any errors or warnings in this structure.
7542 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7543 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7568 Apply options to the image list.
7570 assert(image_info != (ImageInfo *) NULL);
7571 assert(image_info->signature == MagickSignature);
7572 assert(images != (Image **) NULL);
7573 assert((*images)->signature == MagickSignature);
7574 if ((*images)->debug != MagickFalse)
7575 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7576 (*images)->filename);
7577 if ((argc <= 0) || (*argv == (char *) NULL))
7579 mogrify_info=CloneImageInfo(image_info);
7580 quantize_info=AcquireQuantizeInfo(mogrify_info);
7581 channel=mogrify_info->channel;
7583 for (i=0; i < (ssize_t) argc; i++)
7585 if (*images == (Image *) NULL)
7588 if (IsMagickOption(option) == MagickFalse)
7590 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7592 if ((i+count) >= (ssize_t) argc)
7594 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7595 switch (*(option+1))
7599 if (LocaleCompare("affinity",option+1) == 0)
7601 (void) SyncImagesSettings(mogrify_info,*images);
7604 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7605 InheritException(exception,&(*images)->exception);
7611 if (LocaleCompare("append",option+1) == 0)
7616 (void) SyncImagesSettings(mogrify_info,*images);
7617 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7618 MagickFalse,exception);
7619 if (append_image == (Image *) NULL)
7624 *images=DestroyImageList(*images);
7625 *images=append_image;
7628 if (LocaleCompare("average",option+1) == 0)
7634 Average an image sequence (deprecated).
7636 (void) SyncImagesSettings(mogrify_info,*images);
7637 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7639 if (average_image == (Image *) NULL)
7644 *images=DestroyImageList(*images);
7645 *images=average_image;
7652 if (LocaleCompare("channel",option+1) == 0)
7656 channel=DefaultChannels;
7659 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7662 if (LocaleCompare("clut",option+1) == 0)
7668 (void) SyncImagesSettings(mogrify_info,*images);
7669 image=RemoveFirstImageFromList(images);
7670 clut_image=RemoveFirstImageFromList(images);
7671 if (clut_image == (Image *) NULL)
7676 (void) ClutImageChannel(image,channel,clut_image);
7677 clut_image=DestroyImage(clut_image);
7678 InheritException(exception,&image->exception);
7679 *images=DestroyImageList(*images);
7683 if (LocaleCompare("coalesce",option+1) == 0)
7688 (void) SyncImagesSettings(mogrify_info,*images);
7689 coalesce_image=CoalesceImages(*images,exception);
7690 if (coalesce_image == (Image *) NULL)
7695 *images=DestroyImageList(*images);
7696 *images=coalesce_image;
7699 if (LocaleCompare("combine",option+1) == 0)
7704 (void) SyncImagesSettings(mogrify_info,*images);
7705 combine_image=CombineImages(*images,channel,exception);
7706 if (combine_image == (Image *) NULL)
7711 *images=DestroyImageList(*images);
7712 *images=combine_image;
7715 if (LocaleCompare("composite",option+1) == 0)
7725 (void) SyncImagesSettings(mogrify_info,*images);
7726 image=RemoveFirstImageFromList(images);
7727 composite_image=RemoveFirstImageFromList(images);
7728 if (composite_image == (Image *) NULL)
7733 (void) TransformImage(&composite_image,(char *) NULL,
7734 composite_image->geometry);
7735 SetGeometry(composite_image,&geometry);
7736 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7737 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7739 mask_image=RemoveFirstImageFromList(images);
7740 if (mask_image != (Image *) NULL)
7742 if ((image->compose == DisplaceCompositeOp) ||
7743 (image->compose == DistortCompositeOp))
7746 Merge Y displacement into X displacement image.
7748 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7750 mask_image=DestroyImage(mask_image);
7755 Set a blending mask for the composition.
7757 image->mask=mask_image;
7758 (void) NegateImage(image->mask,MagickFalse);
7761 (void) CompositeImageChannel(image,channel,image->compose,
7762 composite_image,geometry.x,geometry.y);
7763 if (image->mask != (Image *) NULL)
7764 image->mask=DestroyImage(image->mask);
7765 composite_image=DestroyImage(composite_image);
7766 InheritException(exception,&image->exception);
7767 *images=DestroyImageList(*images);
7771 if (LocaleCompare("crop",option+1) == 0)
7779 (void) SyncImagesSettings(mogrify_info,*images);
7780 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7781 if (((geometry.width == 0) && (geometry.height == 0)) ||
7782 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7784 (void) TransformImages(images,argv[i+1],(char *) NULL);
7785 InheritException(exception,&(*images)->exception);
7792 if (LocaleCompare("deconstruct",option+1) == 0)
7797 (void) SyncImagesSettings(mogrify_info,*images);
7798 deconstruct_image=DeconstructImages(*images,exception);
7799 if (deconstruct_image == (Image *) NULL)
7804 *images=DestroyImageList(*images);
7805 *images=deconstruct_image;
7808 if (LocaleCompare("delete",option+1) == 0)
7811 DeleteImages(images,"-1",exception);
7813 DeleteImages(images,argv[i+1],exception);
7816 if (LocaleCompare("dither",option+1) == 0)
7820 quantize_info->dither=MagickFalse;
7823 quantize_info->dither=MagickTrue;
7824 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7825 MagickDitherOptions,MagickFalse,argv[i+1]);
7832 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7837 MagickEvaluateOperator
7840 (void) SyncImageSettings(mogrify_info,*images);
7841 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7842 MagickFalse,argv[i+1]);
7843 evaluate_image=EvaluateImages(*images,op,exception);
7844 if (evaluate_image == (Image *) NULL)
7849 *images=DestroyImageList(*images);
7850 *images=evaluate_image;
7857 if (LocaleCompare("fft",option+1) == 0)
7863 Implements the discrete Fourier transform (DFT).
7865 (void) SyncImageSettings(mogrify_info,*images);
7866 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7867 MagickTrue : MagickFalse,exception);
7868 if (fourier_image == (Image *) NULL)
7870 *images=DestroyImage(*images);
7871 *images=fourier_image;
7874 if (LocaleCompare("flatten",option+1) == 0)
7879 (void) SyncImagesSettings(mogrify_info,*images);
7880 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7881 if (flatten_image == (Image *) NULL)
7883 *images=DestroyImageList(*images);
7884 *images=flatten_image;
7887 if (LocaleCompare("fx",option+1) == 0)
7892 (void) SyncImagesSettings(mogrify_info,*images);
7893 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7894 if (fx_image == (Image *) NULL)
7899 *images=DestroyImageList(*images);
7907 if (LocaleCompare("hald-clut",option+1) == 0)
7913 (void) SyncImagesSettings(mogrify_info,*images);
7914 image=RemoveFirstImageFromList(images);
7915 hald_image=RemoveFirstImageFromList(images);
7916 if (hald_image == (Image *) NULL)
7921 (void) HaldClutImageChannel(image,channel,hald_image);
7922 hald_image=DestroyImage(hald_image);
7923 InheritException(exception,&image->exception);
7924 if (*images != (Image *) NULL)
7925 *images=DestroyImageList(*images);
7933 if (LocaleCompare("ift",option+1) == 0)
7941 Implements the inverse fourier discrete Fourier transform (DFT).
7943 (void) SyncImagesSettings(mogrify_info,*images);
7944 magnitude_image=RemoveFirstImageFromList(images);
7945 phase_image=RemoveFirstImageFromList(images);
7946 if (phase_image == (Image *) NULL)
7951 fourier_image=InverseFourierTransformImage(magnitude_image,
7952 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7953 if (fourier_image == (Image *) NULL)
7955 if (*images != (Image *) NULL)
7956 *images=DestroyImage(*images);
7957 *images=fourier_image;
7960 if (LocaleCompare("insert",option+1) == 0)
7968 index=StringToLong(argv[i+1]);
7969 p=RemoveLastImageFromList(images);
7970 if (p == (Image *) NULL)
7972 (void) ThrowMagickException(exception,GetMagickModule(),
7973 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7979 PrependImageToList(images,q);
7981 if (index == (ssize_t) GetImageListLength(*images))
7982 AppendImageToList(images,q);
7985 q=GetImageFromList(*images,index-1);
7986 if (q == (Image *) NULL)
7988 (void) ThrowMagickException(exception,GetMagickModule(),
7989 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7993 InsertImageInList(&q,p);
7995 *images=GetFirstImageInList(q);
8002 if (LocaleCompare("layers",option+1) == 0)
8010 (void) SyncImagesSettings(mogrify_info,*images);
8011 layers=(Image *) NULL;
8012 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
8013 MagickFalse,argv[i+1]);
8018 layers=CoalesceImages(*images,exception);
8021 case CompareAnyLayer:
8022 case CompareClearLayer:
8023 case CompareOverlayLayer:
8026 layers=CompareImageLayers(*images,method,exception);
8032 case TrimBoundsLayer:
8034 layers=MergeImageLayers(*images,method,exception);
8039 layers=DisposeImages(*images,exception);
8042 case OptimizeImageLayer:
8044 layers=OptimizeImageLayers(*images,exception);
8047 case OptimizePlusLayer:
8049 layers=OptimizePlusImageLayers(*images,exception);
8052 case OptimizeTransLayer:
8054 OptimizeImageTransparency(*images,exception);
8057 case RemoveDupsLayer:
8059 RemoveDuplicateLayers(images,exception);
8062 case RemoveZeroLayer:
8064 RemoveZeroDelayLayers(images,exception);
8070 General Purpose, GIF Animation Optimizer.
8072 layers=CoalesceImages(*images,exception);
8073 if (layers == (Image *) NULL)
8078 InheritException(exception,&layers->exception);
8079 *images=DestroyImageList(*images);
8081 layers=OptimizeImageLayers(*images,exception);
8082 if (layers == (Image *) NULL)
8087 InheritException(exception,&layers->exception);
8088 *images=DestroyImageList(*images);
8090 layers=(Image *) NULL;
8091 OptimizeImageTransparency(*images,exception);
8092 InheritException(exception,&(*images)->exception);
8093 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8096 case CompositeLayer:
8108 Split image sequence at the first 'NULL:' image.
8111 while (source != (Image *) NULL)
8113 source=GetNextImageInList(source);
8114 if ((source != (Image *) NULL) &&
8115 (LocaleCompare(source->magick,"NULL") == 0))
8118 if (source != (Image *) NULL)
8120 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8121 (GetNextImageInList(source) == (Image *) NULL))
8122 source=(Image *) NULL;
8126 Separate the two lists, junk the null: image.
8128 source=SplitImageList(source->previous);
8129 DeleteImageFromList(&source);
8132 if (source == (Image *) NULL)
8134 (void) ThrowMagickException(exception,GetMagickModule(),
8135 OptionError,"MissingNullSeparator","layers Composite");
8140 Adjust offset with gravity and virtual canvas.
8142 SetGeometry(*images,&geometry);
8143 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8144 geometry.width=source->page.width != 0 ?
8145 source->page.width : source->columns;
8146 geometry.height=source->page.height != 0 ?
8147 source->page.height : source->rows;
8148 GravityAdjustGeometry((*images)->page.width != 0 ?
8149 (*images)->page.width : (*images)->columns,
8150 (*images)->page.height != 0 ? (*images)->page.height :
8151 (*images)->rows,(*images)->gravity,&geometry);
8152 compose=OverCompositeOp;
8153 option=GetImageOption(mogrify_info,"compose");
8154 if (option != (const char *) NULL)
8155 compose=(CompositeOperator) ParseMagickOption(
8156 MagickComposeOptions,MagickFalse,option);
8157 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8159 source=DestroyImageList(source);
8163 if (layers == (Image *) NULL)
8165 InheritException(exception,&layers->exception);
8166 *images=DestroyImageList(*images);
8174 if (LocaleCompare("map",option+1) == 0)
8176 (void) SyncImagesSettings(mogrify_info,*images);
8179 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8180 InheritException(exception,&(*images)->exception);
8186 if (LocaleCompare("maximum",option+1) == 0)
8192 Maximum image sequence (deprecated).
8194 (void) SyncImagesSettings(mogrify_info,*images);
8195 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8196 if (maximum_image == (Image *) NULL)
8201 *images=DestroyImageList(*images);
8202 *images=maximum_image;
8205 if (LocaleCompare("minimum",option+1) == 0)
8211 Minimum image sequence (deprecated).
8213 (void) SyncImagesSettings(mogrify_info,*images);
8214 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8215 if (minimum_image == (Image *) NULL)
8220 *images=DestroyImageList(*images);
8221 *images=minimum_image;
8224 if (LocaleCompare("morph",option+1) == 0)
8229 (void) SyncImagesSettings(mogrify_info,*images);
8230 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8232 if (morph_image == (Image *) NULL)
8237 *images=DestroyImageList(*images);
8238 *images=morph_image;
8241 if (LocaleCompare("mosaic",option+1) == 0)
8246 (void) SyncImagesSettings(mogrify_info,*images);
8247 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8248 if (mosaic_image == (Image *) NULL)
8253 *images=DestroyImageList(*images);
8254 *images=mosaic_image;
8261 if (LocaleCompare("print",option+1) == 0)
8266 (void) SyncImagesSettings(mogrify_info,*images);
8267 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8268 if (string == (char *) NULL)
8270 InheritException(exception,&(*images)->exception);
8271 (void) fprintf(stdout,"%s",string);
8272 string=DestroyString(string);
8274 if (LocaleCompare("process",option+1) == 0)
8283 (void) SyncImagesSettings(mogrify_info,*images);
8284 arguments=StringToArgv(argv[i+1],&number_arguments);
8285 if (arguments == (char **) NULL)
8287 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8308 Support old style syntax, filter="-option arg".
8310 length=strlen(argv[i+1]);
8311 token=(char *) NULL;
8312 if (~length >= MaxTextExtent)
8313 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8315 if (token == (char *) NULL)
8318 arguments=argv[i+1];
8319 token_info=AcquireTokenInfo();
8320 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8321 "\"",'\0',&breaker,&next,"e);
8322 token_info=DestroyTokenInfo(token_info);
8328 argv=(&(arguments[next]));
8329 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8332 token=DestroyString(token);
8335 (void) SubstituteString(&arguments[1],"-","");
8336 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8337 number_arguments-2,(const char **) arguments+2,exception);
8338 for (j=0; j < number_arguments; j++)
8339 arguments[j]=DestroyString(arguments[j]);
8340 arguments=(char **) RelinquishMagickMemory(arguments);
8347 if (LocaleCompare("reverse",option+1) == 0)
8349 ReverseImageList(images);
8350 InheritException(exception,&(*images)->exception);
8357 if (LocaleCompare("swap",option+1) == 0)
8378 flags=ParseGeometry(argv[i+1],&geometry_info);
8379 index=(ssize_t) geometry_info.rho;
8380 if ((flags & SigmaValue) != 0)
8381 swap_index=(ssize_t) geometry_info.sigma;
8383 p=GetImageFromList(*images,index);
8384 q=GetImageFromList(*images,swap_index);
8385 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8387 (void) ThrowMagickException(exception,GetMagickModule(),
8388 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8394 swap=CloneImage(p,0,0,MagickTrue,exception);
8395 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8396 ReplaceImageInList(&q,swap);
8397 *images=GetFirstImageInList(q);
8404 if (LocaleCompare("write",option+1) == 0)
8415 (void) SyncImagesSettings(mogrify_info,*images);
8416 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8417 (void) DeleteImageRegistry(key);
8418 write_images=(*images);
8420 write_images=CloneImageList(*images,exception);
8421 write_info=CloneImageInfo(mogrify_info);
8422 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8423 write_info=DestroyImageInfo(write_info);
8425 write_images=DestroyImageList(write_images);
8435 quantize_info=DestroyQuantizeInfo(quantize_info);
8436 mogrify_info=DestroyImageInfo(mogrify_info);
8437 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8438 return(status != 0 ? MagickTrue : MagickFalse);
8442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8446 + M o g r i f y I m a g e s %
8450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8452 % MogrifyImages() applies image processing options to a sequence of images as
8453 % prescribed by command line options.
8455 % The format of the MogrifyImage method is:
8457 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8458 % const MagickBooleanType post,const int argc,const char **argv,
8459 % Image **images,Exceptioninfo *exception)
8461 % A description of each parameter follows:
8463 % o image_info: the image info..
8465 % o post: If true, post process image list operators otherwise pre-process.
8467 % o argc: Specifies a pointer to an integer describing the number of
8468 % elements in the argument vector.
8470 % o argv: Specifies a pointer to a text array containing the command line
8473 % o images: the images.
8475 % o exception: return any errors or warnings in this structure.
8478 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8479 const MagickBooleanType post,const int argc,const char **argv,
8480 Image **images,ExceptionInfo *exception)
8482 #define MogrifyImageTag "Mogrify/Image"
8501 Apply options to individual images in the list.
8503 assert(image_info != (ImageInfo *) NULL);
8504 assert(image_info->signature == MagickSignature);
8505 if (images == (Image **) NULL)
8506 return(MogrifyImage(image_info,argc,argv,images,exception));
8507 assert((*images)->signature == MagickSignature);
8508 if ((*images)->debug != MagickFalse)
8509 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8510 (*images)->filename);
8511 if ((argc <= 0) || (*argv == (char *) NULL))
8513 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8515 mogrify_images=NewImageList();
8516 number_images=GetImageListLength(*images);
8518 if (post == MagickFalse)
8519 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8520 for (i=0; i < (ssize_t) number_images; i++)
8522 image=RemoveFirstImageFromList(images);
8523 if (image == (Image *) NULL)
8525 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8526 AppendImageToList(&mogrify_images,image);
8527 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8529 if (proceed == MagickFalse)
8532 if (post != MagickFalse)
8533 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8534 *images=mogrify_images;
8535 return(status != 0 ? MagickTrue : MagickFalse);