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 concurrent=MagickFalse;
133 regard_warnings=MagickFalse;
134 for (i=1; i < (long) (argc-1); i++)
137 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
139 if (LocaleCompare("bench",option+1) == 0)
140 iterations=StringToUnsignedLong(argv[++i]);
141 if (LocaleCompare("concurrent",option+1) == 0)
142 concurrent=MagickTrue;
143 if (LocaleCompare("debug",option+1) == 0)
144 (void) SetLogEventMask(argv[++i]);
145 if (LocaleCompare("duration",option+1) == 0)
146 duration=StringToDouble(argv[++i]);
147 if (LocaleCompare("regard-warnings",option+1) == 0)
148 regard_warnings=MagickTrue;
150 timer=AcquireTimerInfo();
151 if (concurrent == MagickFalse)
153 for (i=0; i < (long) iterations; i++)
155 if (status != MagickFalse)
159 if (GetElapsedTime(timer) > duration)
161 (void) ContinueTimer(timer);
163 status=command(image_info,argc,argv,metadata,exception);
164 if (exception->severity != UndefinedException)
166 if ((exception->severity > ErrorException) ||
167 (regard_warnings != MagickFalse))
169 CatchException(exception);
171 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
173 (void) fputs(*metadata,stdout);
174 (void) fputc('\n',stdout);
175 *metadata=DestroyString(*metadata);
182 #if defined(MAGICKCORE_OPENMP_SUPPORT)
183 # pragma omp parallel for shared(status)
185 for (i=0; i < (long) iterations; i++)
187 if (status != MagickFalse)
191 if (GetElapsedTime(timer) > duration)
193 (void) ContinueTimer(timer);
195 status=command(image_info,argc,argv,metadata,exception);
196 #if defined(MAGICKCORE_OPENMP_SUPPORT)
197 # pragma omp critical (MagickCore_Launch_Command)
200 if (exception->severity != UndefinedException)
202 if ((exception->severity > ErrorException) ||
203 (regard_warnings != MagickFalse))
205 CatchException(exception);
207 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
209 (void) fputs(*metadata,stdout);
210 (void) fputc('\n',stdout);
211 *metadata=DestroyString(*metadata);
218 elapsed_time=GetElapsedTime(timer);
219 user_time=GetUserTime(timer);
220 (void) fprintf(stderr,
221 "Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",
222 iterations,1.0*iterations/elapsed_time,user_time,(long)
223 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
224 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
226 timer=DestroyTimerInfo(timer);
231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235 + M o g r i f y I m a g e %
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % MogrifyImage() applies image processing options to an image as prescribed
242 % by command line options.
244 % The format of the MogrifyImage method is:
246 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
247 % const char **argv,Image **image)
249 % A description of each parameter follows:
251 % o image_info: the image info..
253 % o argc: Specifies a pointer to an integer describing the number of
254 % elements in the argument vector.
256 % o argv: Specifies a pointer to a text array containing the command line
259 % o image: the image.
261 % o exception: return any errors or warnings in this structure.
265 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
266 ExceptionInfo *exception)
280 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
281 sans_exception=AcquireExceptionInfo();
282 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
283 sans_exception=DestroyExceptionInfo(sans_exception);
284 if (image != (Image *) NULL)
286 read_info=CloneImageInfo(image_info);
287 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
288 image=ReadImage(read_info,exception);
289 read_info=DestroyImageInfo(read_info);
290 if (image != (Image *) NULL)
291 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
295 static int IsPathDirectory(const char *path)
303 if ((path == (const char *) NULL) || (*path == '\0'))
305 status=GetPathAttributes(path,&attributes);
306 if (status == MagickFalse)
308 if (S_ISDIR(attributes.st_mode) == 0)
313 static MagickBooleanType IsPathWritable(const char *path)
315 if (IsPathAccessible(path) == MagickFalse)
317 if (access(path,W_OK) != 0)
322 static inline long MagickMax(const long x,const long y)
329 static MagickBooleanType MonitorProgress(const char *text,
330 const MagickOffsetType offset,const MagickSizeType extent,
331 void *wand_unused(client_data))
334 message[MaxTextExtent],
345 (void) CopyMagickMemory(tag,text,MaxTextExtent);
347 if (p != (char *) NULL)
349 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
350 locale_message=GetLocaleMessage(message);
351 if (locale_message == message)
353 if (p == (char *) NULL)
354 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
355 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
357 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
358 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
359 (100L*offset/(extent-1)));
360 if (offset == (MagickOffsetType) (extent-1))
361 (void) fprintf(stderr,"\n");
362 (void) fflush(stderr);
366 static Image *SparseColorOption(const Image *image,const ChannelType channel,
367 const SparseColorMethod method,const char *arguments,
368 const MagickBooleanType color_from_image,ExceptionInfo *exception)
374 token[MaxTextExtent];
382 register unsigned long
400 assert(image != (Image *) NULL);
401 assert(image->signature == MagickSignature);
402 if (image->debug != MagickFalse)
403 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
404 assert(exception != (ExceptionInfo *) NULL);
405 assert(exception->signature == MagickSignature);
407 Limit channels according to image - and add up number of color channel.
410 if (image->colorspace != CMYKColorspace)
411 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
412 if (image->matte == MagickFalse)
413 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
415 if ((channels & RedChannel) != 0)
417 if ((channels & GreenChannel) != 0)
419 if ((channels & BlueChannel) != 0)
421 if ((channels & IndexChannel) != 0)
423 if ((channels & OpacityChannel) != 0)
426 Read string, to determine number of arguments needed,
432 GetMagickToken(p,&p,token);
433 if ( token[0] == ',' ) continue;
434 if ( isalpha((int) token[0]) || token[0] == '#' ) {
435 if ( color_from_image ) {
436 (void) ThrowMagickException(exception,GetMagickModule(),
437 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
438 "Color arg given, when colors are coming from image");
439 return( (Image *)NULL);
441 x += number_colors; /* color argument */
444 x++; /* floating point argument */
448 if ( color_from_image ) {
449 /* just the control points are being given */
450 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
451 number_arguments=(x/2)*(2+number_colors);
454 /* control points and color values */
455 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
459 (void) ThrowMagickException(exception,GetMagickModule(),
460 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
461 "Invalid number of Arguments");
462 return( (Image *)NULL);
465 /* Allocate and fill in the floating point arguments */
466 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
467 sizeof(*sparse_arguments));
468 if (sparse_arguments == (double *) NULL) {
469 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
470 "MemoryAllocationFailed","%s","SparseColorOption");
471 return( (Image *)NULL);
473 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
474 sizeof(*sparse_arguments));
477 while( *p != '\0' && x < number_arguments ) {
479 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
480 if ( token[0] == '\0' ) break;
481 if ( isalpha((int) token[0]) || token[0] == '#' ) {
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Color found, instead of X-coord");
488 sparse_arguments[x++]=StringToDouble(token);
490 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
491 if ( token[0] == '\0' ) break;
492 if ( isalpha((int) token[0]) || token[0] == '#' ) {
493 (void) ThrowMagickException(exception,GetMagickModule(),
494 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
495 "Color found, instead of Y-coord");
499 sparse_arguments[x++]=StringToDouble(token);
500 /* color values for this control point */
502 if ( (color_from_image ) {
503 /* get color from image */
509 /* color name or function given in string argument */
510 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
511 if ( token[0] == '\0' ) break;
512 if ( isalpha((int) token[0]) || token[0] == '#' ) {
513 /* Color string given */
514 (void) QueryMagickColor(token,&color,exception);
515 if ( channels & RedChannel )
516 sparse_arguments[x++] = QuantumScale*color.red;
517 if ( channels & GreenChannel )
518 sparse_arguments[x++] = QuantumScale*color.green;
519 if ( channels & BlueChannel )
520 sparse_arguments[x++] = QuantumScale*color.blue;
521 if ( channels & IndexChannel )
522 sparse_arguments[x++] = QuantumScale*color.index;
523 if ( channels & OpacityChannel )
524 sparse_arguments[x++] = QuantumScale*color.opacity;
528 /* the color name/function/value was not found - error */
531 /* Colors given as a set of floating point values - experimental */
532 /* NB: token contains the first floating point value to use! */
533 if ( channels & RedChannel ) {
534 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
535 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
537 sparse_arguments[x++]=StringToDouble(token);
538 token[0] = ','; /* used this token - get another */
540 if ( channels & GreenChannel ) {
541 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
542 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
544 sparse_arguments[x++]=StringToDouble(token);
545 token[0] = ','; /* used this token - get another */
547 if ( channels & BlueChannel ) {
548 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
549 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
551 sparse_arguments[x++]=StringToDouble(token);
552 token[0] = ','; /* used this token - get another */
554 if ( channels & IndexChannel ) {
555 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
556 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
558 sparse_arguments[x++]=StringToDouble(token);
559 token[0] = ','; /* used this token - get another */
561 if ( channels & OpacityChannel ) {
562 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
563 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
565 sparse_arguments[x++]=StringToDouble(token);
566 token[0] = ','; /* used this token - get another */
572 if ( number_arguments != x && !error ) {
573 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
574 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
575 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
576 return( (Image *)NULL);
579 return( (Image *)NULL);
581 /* Call the Interpolation function with the parsed arguments */
582 sparse_image=SparseColorImage(image,channels,method,number_arguments,
583 sparse_arguments,exception);
584 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
585 return( sparse_image );
588 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
589 const char **argv,Image **image,ExceptionInfo *exception)
630 Initialize method variables.
632 assert(image_info != (const ImageInfo *) NULL);
633 assert(image_info->signature == MagickSignature);
634 assert(image != (Image **) NULL);
635 assert((*image)->signature == MagickSignature);
636 if ((*image)->debug != MagickFalse)
637 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
640 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
641 quantize_info=AcquireQuantizeInfo(image_info);
642 SetGeometryInfo(&geometry_info);
643 GetMagickPixelPacket(*image,&fill);
644 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
646 channel=image_info->channel;
647 format=GetImageOption(image_info,"format");
648 SetGeometry(*image,®ion_geometry);
649 region_image=NewImageList();
651 Transmogrify the image.
653 for (i=0; i < (long) argc; i++)
656 if (IsMagickOption(option) == MagickFalse)
658 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
660 if ((i+count) >= argc)
662 status=MogrifyImageInfo(image_info,count+1,argv+i,exception);
667 if (LocaleCompare("adaptive-blur",option+1) == 0)
675 (void) SyncImageSettings(image_info,*image);
676 flags=ParseGeometry(argv[i+1],&geometry_info);
677 if ((flags & SigmaValue) == 0)
678 geometry_info.sigma=1.0;
679 blur_image=AdaptiveBlurImageChannel(*image,channel,
680 geometry_info.rho,geometry_info.sigma,exception);
681 if (blur_image == (Image *) NULL)
683 *image=DestroyImage(*image);
687 if (LocaleCompare("adaptive-resize",option+1) == 0)
693 Adaptive resize image.
695 (void) SyncImageSettings(image_info,*image);
696 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
697 resize_image=AdaptiveResizeImage(*image,geometry.width,
698 geometry.height,exception);
699 if (resize_image == (Image *) NULL)
701 *image=DestroyImage(*image);
705 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
711 Adaptive sharpen image.
713 (void) SyncImageSettings(image_info,*image);
714 flags=ParseGeometry(argv[i+1],&geometry_info);
715 if ((flags & SigmaValue) == 0)
716 geometry_info.sigma=1.0;
717 sharp_image=AdaptiveSharpenImageChannel(*image,channel,
718 geometry_info.rho,geometry_info.sigma,exception);
719 if (sharp_image == (Image *) NULL)
721 *image=DestroyImage(*image);
725 if (LocaleCompare("affine",option+1) == 0)
732 GetAffineMatrix(&draw_info->affine);
735 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
738 if (LocaleCompare("alpha",option+1) == 0)
743 (void) SyncImageSettings(image_info,*image);
744 alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
745 MagickFalse,argv[i+1]);
746 (void) SetImageAlphaChannel(*image,alpha_type);
747 InheritException(exception,&(*image)->exception);
750 if (LocaleCompare("annotate",option+1) == 0)
754 geometry[MaxTextExtent];
759 (void) SyncImageSettings(image_info,*image);
760 SetGeometryInfo(&geometry_info);
761 flags=ParseGeometry(argv[i+1],&geometry_info);
762 if ((flags & SigmaValue) == 0)
763 geometry_info.sigma=geometry_info.rho;
764 text=InterpretImageProperties(image_info,*image,argv[i+2]);
765 InheritException(exception,&(*image)->exception);
766 if (text == (char *) NULL)
768 (void) CloneString(&draw_info->text,text);
769 text=DestroyString(text);
770 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
771 geometry_info.xi,geometry_info.psi);
772 (void) CloneString(&draw_info->geometry,geometry);
773 draw_info->affine.sx=cos(DegreesToRadians(
774 fmod(geometry_info.rho,360.0)));
775 draw_info->affine.rx=sin(DegreesToRadians(
776 fmod(geometry_info.rho,360.0)));
777 draw_info->affine.ry=(-sin(DegreesToRadians(
778 fmod(geometry_info.sigma,360.0))));
779 draw_info->affine.sy=cos(DegreesToRadians(
780 fmod(geometry_info.sigma,360.0)));
781 (void) AnnotateImage(*image,draw_info);
782 InheritException(exception,&(*image)->exception);
785 if (LocaleCompare("antialias",option+1) == 0)
787 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
789 draw_info->text_antialias=(*option == '-') ? MagickTrue :
793 if (LocaleCompare("auto-gamma",option+1) == 0)
796 Auto Adjust Gamma of image based on its mean
798 (void) SyncImageSettings(image_info,*image);
799 (void) AutoGammaImageChannel(*image,channel);
802 if (LocaleCompare("auto-level",option+1) == 0)
805 Perfectly Normalize (max/min stretch) the image
807 (void) SyncImageSettings(image_info,*image);
808 (void) AutoLevelImageChannel(*image,channel);
811 if (LocaleCompare("auto-orient",option+1) == 0)
816 (void) SyncImageSettings(image_info,*image);
817 orient_image=NewImageList();
818 switch ((*image)->orientation)
820 case TopRightOrientation:
822 orient_image=FlopImage(*image,exception);
825 case BottomRightOrientation:
827 orient_image=RotateImage(*image,180.0,exception);
830 case BottomLeftOrientation:
832 orient_image=FlipImage(*image,exception);
835 case LeftTopOrientation:
837 orient_image=TransposeImage(*image,exception);
840 case RightTopOrientation:
842 orient_image=RotateImage(*image,90.0,exception);
845 case RightBottomOrientation:
847 orient_image=TransverseImage(*image,exception);
850 case LeftBottomOrientation:
852 orient_image=RotateImage(*image,270.0,exception);
858 if (orient_image == (Image *) NULL)
860 orient_image->orientation=TopLeftOrientation;
861 *image=DestroyImage(*image);
869 if (LocaleCompare("black-threshold",option+1) == 0)
872 Black threshold image.
874 (void) SyncImageSettings(image_info,*image);
875 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
877 InheritException(exception,&(*image)->exception);
880 if (LocaleCompare("blue-shift",option+1) == 0)
888 (void) SyncImageSettings(image_info,*image);
889 geometry_info.rho=1.5;
891 flags=ParseGeometry(argv[i+1],&geometry_info);
892 shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
893 if (shift_image == (Image *) NULL)
895 *image=DestroyImage(*image);
899 if (LocaleCompare("blur",option+1) == 0)
907 (void) SyncImageSettings(image_info,*image);
908 flags=ParseGeometry(argv[i+1],&geometry_info);
909 if ((flags & SigmaValue) == 0)
910 geometry_info.sigma=1.0;
911 blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
912 geometry_info.sigma,exception);
913 if (blur_image == (Image *) NULL)
915 *image=DestroyImage(*image);
919 if (LocaleCompare("border",option+1) == 0)
925 Surround image with a border of solid color.
927 (void) SyncImageSettings(image_info,*image);
928 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
929 if ((flags & SigmaValue) == 0)
930 geometry.height=geometry.width;
931 border_image=BorderImage(*image,&geometry,exception);
932 if (border_image == (Image *) NULL)
934 *image=DestroyImage(*image);
938 if (LocaleCompare("bordercolor",option+1) == 0)
942 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
946 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
950 if (LocaleCompare("box",option+1) == 0)
952 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
956 if (LocaleCompare("brightness-contrast",option+1) == 0)
969 Brightness / contrast image.
971 (void) SyncImageSettings(image_info,*image);
972 flags=ParseGeometry(argv[i+1],&geometry_info);
973 brightness=geometry_info.rho;
975 if ((flags & SigmaValue) != 0)
976 contrast=geometry_info.sigma;
977 (void) BrightnessContrastImageChannel(*image,channel,brightness,
979 InheritException(exception,&(*image)->exception);
986 if (LocaleCompare("cdl",option+1) == 0)
989 *color_correction_collection;
992 Color correct with a color decision list.
994 (void) SyncImageSettings(image_info,*image);
995 color_correction_collection=FileToString(argv[i+1],~0,exception);
996 if (color_correction_collection == (char *) NULL)
998 (void) ColorDecisionListImage(*image,color_correction_collection);
999 InheritException(exception,&(*image)->exception);
1002 if (LocaleCompare("channel",option+1) == 0)
1006 channel=DefaultChannels;
1009 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1012 if (LocaleCompare("charcoal",option+1) == 0)
1020 (void) SyncImageSettings(image_info,*image);
1021 flags=ParseGeometry(argv[i+1],&geometry_info);
1022 if ((flags & SigmaValue) == 0)
1023 geometry_info.sigma=1.0;
1024 charcoal_image=CharcoalImage(*image,geometry_info.rho,
1025 geometry_info.sigma,exception);
1026 if (charcoal_image == (Image *) NULL)
1028 *image=DestroyImage(*image);
1029 *image=charcoal_image;
1032 if (LocaleCompare("chop",option+1) == 0)
1040 (void) SyncImageSettings(image_info,*image);
1041 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1042 chop_image=ChopImage(*image,&geometry,exception);
1043 if (chop_image == (Image *) NULL)
1045 *image=DestroyImage(*image);
1049 if (LocaleCompare("clamp",option+1) == 0)
1054 (void) SyncImageSettings(image_info,*image);
1055 (void) ClampImageChannel(*image,channel);
1056 InheritException(exception,&(*image)->exception);
1059 if (LocaleCompare("clip",option+1) == 0)
1061 (void) SyncImageSettings(image_info,*image);
1064 (void) SetImageClipMask(*image,(Image *) NULL);
1065 InheritException(exception,&(*image)->exception);
1068 (void) ClipImage(*image);
1069 InheritException(exception,&(*image)->exception);
1072 if (LocaleCompare("clip-mask",option+1) == 0)
1083 register PixelPacket
1086 (void) SyncImageSettings(image_info,*image);
1092 (void) SetImageMask(*image,(Image *) NULL);
1093 InheritException(exception,&(*image)->exception);
1099 mask=GetImageCache(image_info,argv[i+1],exception);
1100 if (mask == (Image *) NULL)
1102 for (y=0; y < (long) mask->rows; y++)
1104 q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception);
1105 if (q == (PixelPacket *) NULL)
1107 for (x=0; x < (long) mask->columns; x++)
1109 if (mask->matte == MagickFalse)
1110 q->opacity=PixelIntensityToQuantum(q);
1112 q->green=q->opacity;
1116 if (SyncAuthenticPixels(mask,exception) == MagickFalse)
1119 if (SetImageStorageClass(mask,DirectClass) == MagickFalse)
1120 return(MagickFalse);
1121 mask->matte=MagickTrue;
1122 (void) SetImageClipMask(*image,mask);
1123 mask=DestroyImage(mask);
1124 InheritException(exception,&(*image)->exception);
1127 if (LocaleCompare("clip-path",option+1) == 0)
1129 (void) SyncImageSettings(image_info,*image);
1130 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1132 InheritException(exception,&(*image)->exception);
1135 if (LocaleCompare("colorize",option+1) == 0)
1143 (void) SyncImageSettings(image_info,*image);
1144 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1146 if (colorize_image == (Image *) NULL)
1148 *image=DestroyImage(*image);
1149 *image=colorize_image;
1152 if (LocaleCompare("colors",option+1) == 0)
1155 Reduce the number of colors in the image.
1157 (void) SyncImageSettings(image_info,*image);
1158 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1159 if (quantize_info->number_colors == 0)
1161 if (((*image)->storage_class == DirectClass) ||
1162 (*image)->colors > quantize_info->number_colors)
1163 (void) QuantizeImage(quantize_info,*image);
1165 (void) CompressImageColormap(*image);
1166 InheritException(exception,&(*image)->exception);
1169 if (LocaleCompare("colorspace",option+1) == 0)
1174 (void) SyncImageSettings(image_info,*image);
1177 (void) TransformImageColorspace(*image,RGBColorspace);
1178 InheritException(exception,&(*image)->exception);
1181 colorspace=(ColorspaceType) ParseMagickOption(
1182 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1183 (void) TransformImageColorspace(*image,colorspace);
1184 InheritException(exception,&(*image)->exception);
1187 if (LocaleCompare("contrast",option+1) == 0)
1189 (void) SyncImageSettings(image_info,*image);
1190 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1192 InheritException(exception,&(*image)->exception);
1195 if (LocaleCompare("contrast-stretch",option+1) == 0)
1205 Contrast stretch image.
1207 (void) SyncImageSettings(image_info,*image);
1208 flags=ParseGeometry(argv[i+1],&geometry_info);
1209 black_point=geometry_info.rho;
1210 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1212 if ((flags & PercentValue) != 0)
1214 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1215 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1217 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1219 (void) ContrastStretchImageChannel(*image,channel,black_point,
1221 InheritException(exception,&(*image)->exception);
1224 if (LocaleCompare("convolve",option+1) == 0)
1232 kernel=AcquireKernelInfo(argv[i+1]);
1233 if (kernel == (KernelInfo *) NULL)
1235 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
1236 kernel=DestroyKernelInfo(kernel);
1237 if (convolve_image == (Image *) NULL)
1239 *image=DestroyImage(*image);
1240 *image=convolve_image;
1243 if (LocaleCompare("crop",option+1) == 0)
1245 (void) SyncImageSettings(image_info,*image);
1246 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1247 if (((geometry.width != 0) || (geometry.height != 0)) &&
1248 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1250 (void) TransformImage(image,argv[i+1],(char *) NULL);
1251 InheritException(exception,&(*image)->exception);
1254 if (LocaleCompare("cycle",option+1) == 0)
1257 Cycle an image colormap.
1259 (void) SyncImageSettings(image_info,*image);
1260 (void) CycleColormapImage(*image,StringToLong(argv[i+1]));
1261 InheritException(exception,&(*image)->exception);
1268 if (LocaleCompare("decipher",option+1) == 0)
1276 (void) SyncImageSettings(image_info,*image);
1277 passkey=FileToStringInfo(argv[i+1],~0,exception);
1278 if (passkey != (StringInfo *) NULL)
1280 (void) PasskeyDecipherImage(*image,passkey,exception);
1281 passkey=DestroyStringInfo(passkey);
1285 if (LocaleCompare("density",option+1) == 0)
1290 (void) CloneString(&draw_info->density,argv[i+1]);
1293 if (LocaleCompare("depth",option+1) == 0)
1295 (void) SyncImageSettings(image_info,*image);
1298 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1301 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1304 if (LocaleCompare("deskew",option+1) == 0)
1313 Straighten the image.
1315 (void) SyncImageSettings(image_info,*image);
1317 threshold=40.0*QuantumRange/100.0;
1319 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1320 deskew_image=DeskewImage(*image,threshold,exception);
1321 if (deskew_image == (Image *) NULL)
1323 *image=DestroyImage(*image);
1324 *image=deskew_image;
1327 if (LocaleCompare("despeckle",option+1) == 0)
1333 Reduce the speckles within an image.
1335 (void) SyncImageSettings(image_info,*image);
1336 despeckle_image=DespeckleImage(*image,exception);
1337 if (despeckle_image == (Image *) NULL)
1339 *image=DestroyImage(*image);
1340 *image=despeckle_image;
1343 if (LocaleCompare("display",option+1) == 0)
1345 (void) CloneString(&draw_info->server_name,argv[i+1]);
1348 if (LocaleCompare("distort",option+1) == 0)
1352 token[MaxTextExtent];
1375 (void) SyncImageSettings(image_info,*image);
1376 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1377 MagickFalse,argv[i+1]);
1378 args=InterpretImageProperties(image_info,*image,argv[i+2]);
1379 InheritException(exception,&(*image)->exception);
1380 if (args == (char *) NULL)
1383 for (x=0; *p != '\0'; x++)
1385 GetMagickToken(p,&p,token);
1387 GetMagickToken(p,&p,token);
1389 number_arguments=(unsigned long) x;
1390 arguments=(double *) AcquireQuantumMemory(number_arguments,
1391 sizeof(*arguments));
1392 if (arguments == (double *) NULL)
1393 ThrowWandFatalException(ResourceLimitFatalError,
1394 "MemoryAllocationFailed",(*image)->filename);
1395 (void) ResetMagickMemory(arguments,0,number_arguments*
1396 sizeof(*arguments));
1398 for (x=0; (x < (long) number_arguments) && (*p != '\0'); x++)
1400 GetMagickToken(p,&p,token);
1402 GetMagickToken(p,&p,token);
1403 arguments[x]=StringToDouble(token);
1405 args=DestroyString(args);
1406 distort_image=DistortImage(*image,method,number_arguments,arguments,
1407 (*option == '+') ? MagickTrue : MagickFalse,exception);
1408 arguments=(double *) RelinquishMagickMemory(arguments);
1409 if (distort_image == (Image *) NULL)
1411 *image=DestroyImage(*image);
1412 *image=distort_image;
1415 if (LocaleCompare("dither",option+1) == 0)
1419 quantize_info->dither=MagickFalse;
1422 quantize_info->dither=MagickTrue;
1423 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
1424 MagickDitherOptions,MagickFalse,argv[i+1]);
1425 if (quantize_info->dither_method == NoDitherMethod)
1426 quantize_info->dither=MagickFalse;
1429 if (LocaleCompare("draw",option+1) == 0)
1434 (void) SyncImageSettings(image_info,*image);
1435 (void) CloneString(&draw_info->primitive,argv[i+1]);
1436 (void) DrawImage(*image,draw_info);
1437 InheritException(exception,&(*image)->exception);
1444 if (LocaleCompare("edge",option+1) == 0)
1450 Enhance edges in the image.
1452 (void) SyncImageSettings(image_info,*image);
1453 flags=ParseGeometry(argv[i+1],&geometry_info);
1454 if ((flags & SigmaValue) == 0)
1455 geometry_info.sigma=1.0;
1456 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1457 if (edge_image == (Image *) NULL)
1459 *image=DestroyImage(*image);
1463 if (LocaleCompare("emboss",option+1) == 0)
1469 Gaussian embossen image.
1471 (void) SyncImageSettings(image_info,*image);
1472 flags=ParseGeometry(argv[i+1],&geometry_info);
1473 if ((flags & SigmaValue) == 0)
1474 geometry_info.sigma=1.0;
1475 emboss_image=EmbossImage(*image,geometry_info.rho,
1476 geometry_info.sigma,exception);
1477 if (emboss_image == (Image *) NULL)
1479 *image=DestroyImage(*image);
1480 *image=emboss_image;
1483 if (LocaleCompare("encipher",option+1) == 0)
1491 (void) SyncImageSettings(image_info,*image);
1492 passkey=FileToStringInfo(argv[i+1],~0,exception);
1493 if (passkey != (StringInfo *) NULL)
1495 (void) PasskeyEncipherImage(*image,passkey,exception);
1496 passkey=DestroyStringInfo(passkey);
1500 if (LocaleCompare("encoding",option+1) == 0)
1502 (void) CloneString(&draw_info->encoding,argv[i+1]);
1505 if (LocaleCompare("enhance",option+1) == 0)
1513 (void) SyncImageSettings(image_info,*image);
1514 enhance_image=EnhanceImage(*image,exception);
1515 if (enhance_image == (Image *) NULL)
1517 *image=DestroyImage(*image);
1518 *image=enhance_image;
1521 if (LocaleCompare("equalize",option+1) == 0)
1526 (void) SyncImageSettings(image_info,*image);
1527 (void) EqualizeImageChannel(*image,channel);
1528 InheritException(exception,&(*image)->exception);
1531 if (LocaleCompare("evaluate",option+1) == 0)
1536 MagickEvaluateOperator
1539 (void) SyncImageSettings(image_info,*image);
1540 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1541 MagickFalse,argv[i+1]);
1542 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1543 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1546 if (LocaleCompare("extent",option+1) == 0)
1552 Set the image extent.
1554 (void) SyncImageSettings(image_info,*image);
1555 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1556 if (geometry.width == 0)
1557 geometry.width=(*image)->columns;
1558 if (geometry.height == 0)
1559 geometry.height=(*image)->rows;
1560 geometry.x=(-geometry.x);
1561 geometry.y=(-geometry.y);
1562 extent_image=ExtentImage(*image,&geometry,exception);
1563 if (extent_image == (Image *) NULL)
1565 *image=DestroyImage(*image);
1566 *image=extent_image;
1573 if (LocaleCompare("family",option+1) == 0)
1577 if (draw_info->family != (char *) NULL)
1578 draw_info->family=DestroyString(draw_info->family);
1581 (void) CloneString(&draw_info->family,argv[i+1]);
1584 if (LocaleCompare("features",option+1) == 0)
1588 (void) DeleteImageArtifact(*image,"identify:features");
1591 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1594 if (LocaleCompare("fill",option+1) == 0)
1599 GetMagickPixelPacket(*image,&fill);
1602 (void) QueryMagickColor("none",&fill,exception);
1603 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1604 if (draw_info->fill_pattern != (Image *) NULL)
1605 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1608 sans=AcquireExceptionInfo();
1609 (void) QueryMagickColor(argv[i+1],&fill,sans);
1610 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1611 sans=DestroyExceptionInfo(sans);
1612 if (status == MagickFalse)
1613 draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
1617 if (LocaleCompare("flip",option+1) == 0)
1623 Flip image scanlines.
1625 (void) SyncImageSettings(image_info,*image);
1626 flip_image=FlipImage(*image,exception);
1627 if (flip_image == (Image *) NULL)
1629 *image=DestroyImage(*image);
1633 if (LocaleCompare("flop",option+1) == 0)
1639 Flop image scanlines.
1641 (void) SyncImageSettings(image_info,*image);
1642 flop_image=FlopImage(*image,exception);
1643 if (flop_image == (Image *) NULL)
1645 *image=DestroyImage(*image);
1649 if (LocaleCompare("floodfill",option+1) == 0)
1657 (void) SyncImageSettings(image_info,*image);
1658 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1659 (void) QueryMagickColor(argv[i+2],&target,exception);
1660 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1661 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1662 InheritException(exception,&(*image)->exception);
1665 if (LocaleCompare("font",option+1) == 0)
1669 if (draw_info->font != (char *) NULL)
1670 draw_info->font=DestroyString(draw_info->font);
1673 (void) CloneString(&draw_info->font,argv[i+1]);
1676 if (LocaleCompare("format",option+1) == 0)
1681 if (LocaleCompare("frame",option+1) == 0)
1690 Surround image with an ornamental border.
1692 (void) SyncImageSettings(image_info,*image);
1693 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1694 frame_info.width=geometry.width;
1695 frame_info.height=geometry.height;
1696 if ((flags & HeightValue) == 0)
1697 frame_info.height=geometry.width;
1698 frame_info.outer_bevel=geometry.x;
1699 frame_info.inner_bevel=geometry.y;
1700 frame_info.x=(long) frame_info.width;
1701 frame_info.y=(long) frame_info.height;
1702 frame_info.width=(*image)->columns+2*frame_info.width;
1703 frame_info.height=(*image)->rows+2*frame_info.height;
1704 frame_image=FrameImage(*image,&frame_info,exception);
1705 if (frame_image == (Image *) NULL)
1707 *image=DestroyImage(*image);
1711 if (LocaleCompare("function",option+1) == 0)
1715 token[MaxTextExtent];
1733 Function Modify Image Values
1735 (void) SyncImageSettings(image_info,*image);
1736 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1737 MagickFalse,argv[i+1]);
1738 arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
1739 InheritException(exception,&(*image)->exception);
1740 if (arguments == (char *) NULL)
1742 p=(char *) arguments;
1743 for (x=0; *p != '\0'; x++)
1745 GetMagickToken(p,&p,token);
1747 GetMagickToken(p,&p,token);
1749 number_parameters=(unsigned long) x;
1750 parameters=(double *) AcquireQuantumMemory(number_parameters,
1751 sizeof(*parameters));
1752 if (parameters == (double *) NULL)
1753 ThrowWandFatalException(ResourceLimitFatalError,
1754 "MemoryAllocationFailed",(*image)->filename);
1755 (void) ResetMagickMemory(parameters,0,number_parameters*
1756 sizeof(*parameters));
1757 p=(char *) arguments;
1758 for (x=0; (x < (long) number_parameters) && (*p != '\0'); x++)
1760 GetMagickToken(p,&p,token);
1762 GetMagickToken(p,&p,token);
1763 parameters[x]=StringToDouble(token);
1765 arguments=DestroyString(arguments);
1766 (void) FunctionImageChannel(*image,channel,function,
1767 number_parameters,parameters,exception);
1768 parameters=(double *) RelinquishMagickMemory(parameters);
1775 if (LocaleCompare("gamma",option+1) == 0)
1780 (void) SyncImageSettings(image_info,*image);
1782 (*image)->gamma=StringToDouble(argv[i+1]);
1785 if (strchr(argv[i+1],',') != (char *) NULL)
1786 (void) GammaImage(*image,argv[i+1]);
1788 (void) GammaImageChannel(*image,channel,
1789 StringToDouble(argv[i+1]));
1790 InheritException(exception,&(*image)->exception);
1794 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1795 (LocaleCompare("gaussian",option+1) == 0))
1801 Gaussian blur image.
1803 (void) SyncImageSettings(image_info,*image);
1804 flags=ParseGeometry(argv[i+1],&geometry_info);
1805 if ((flags & SigmaValue) == 0)
1806 geometry_info.sigma=1.0;
1807 gaussian_image=GaussianBlurImageChannel(*image,channel,
1808 geometry_info.rho,geometry_info.sigma,exception);
1809 if (gaussian_image == (Image *) NULL)
1811 *image=DestroyImage(*image);
1812 *image=gaussian_image;
1815 if (LocaleCompare("geometry",option+1) == 0)
1817 (void) SyncImageSettings(image_info,*image);
1820 if ((*image)->geometry != (char *) NULL)
1821 (*image)->geometry=DestroyString((*image)->geometry);
1824 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1825 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1826 (void) CloneString(&(*image)->geometry,argv[i+1]);
1835 zoom_image=ZoomImage(*image,geometry.width,geometry.height,
1837 if (zoom_image == (Image *) NULL)
1839 *image=DestroyImage(*image);
1844 if (LocaleCompare("gravity",option+1) == 0)
1848 draw_info->gravity=UndefinedGravity;
1851 draw_info->gravity=(GravityType) ParseMagickOption(
1852 MagickGravityOptions,MagickFalse,argv[i+1]);
1859 if (LocaleCompare("highlight-color",option+1) == 0)
1861 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1868 if (LocaleCompare("identify",option+1) == 0)
1873 (void) SyncImageSettings(image_info,*image);
1874 if (format == (char *) NULL)
1876 (void) IdentifyImage(*image,stdout,image_info->verbose);
1877 InheritException(exception,&(*image)->exception);
1880 text=InterpretImageProperties(image_info,*image,format);
1881 InheritException(exception,&(*image)->exception);
1882 if (text == (char *) NULL)
1884 (void) fputs(text,stdout);
1885 (void) fputc('\n',stdout);
1886 text=DestroyString(text);
1889 if (LocaleCompare("implode",option+1) == 0)
1897 (void) SyncImageSettings(image_info,*image);
1898 (void) ParseGeometry(argv[i+1],&geometry_info);
1899 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1900 if (implode_image == (Image *) NULL)
1902 *image=DestroyImage(*image);
1903 *image=implode_image;
1906 if (LocaleCompare("interline-spacing",option+1) == 0)
1909 (void) ParseGeometry("0",&geometry_info);
1911 (void) ParseGeometry(argv[i+1],&geometry_info);
1912 draw_info->interline_spacing=geometry_info.rho;
1915 if (LocaleCompare("interword-spacing",option+1) == 0)
1918 (void) ParseGeometry("0",&geometry_info);
1920 (void) ParseGeometry(argv[i+1],&geometry_info);
1921 draw_info->interword_spacing=geometry_info.rho;
1928 if (LocaleCompare("kerning",option+1) == 0)
1931 (void) ParseGeometry("0",&geometry_info);
1933 (void) ParseGeometry(argv[i+1],&geometry_info);
1934 draw_info->kerning=geometry_info.rho;
1941 if (LocaleCompare("lat",option+1) == 0)
1947 Local adaptive threshold image.
1949 (void) SyncImageSettings(image_info,*image);
1950 flags=ParseGeometry(argv[i+1],&geometry_info);
1951 if ((flags & PercentValue) != 0)
1952 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1953 threshold_image=AdaptiveThresholdImage(*image,(unsigned long)
1954 geometry_info.rho,(unsigned long) geometry_info.sigma,
1955 (long) geometry_info.xi,exception);
1956 if (threshold_image == (Image *) NULL)
1958 *image=DestroyImage(*image);
1959 *image=threshold_image;
1962 if (LocaleCompare("level",option+1) == 0)
1975 (void) SyncImageSettings(image_info,*image);
1976 flags=ParseGeometry(argv[i+1],&geometry_info);
1977 black_point=geometry_info.rho;
1978 white_point=(MagickRealType) QuantumRange;
1979 if ((flags & SigmaValue) != 0)
1980 white_point=geometry_info.sigma;
1982 if ((flags & XiValue) != 0)
1983 gamma=geometry_info.xi;
1984 if ((flags & PercentValue) != 0)
1986 black_point*=(MagickRealType) (QuantumRange/100.0);
1987 white_point*=(MagickRealType) (QuantumRange/100.0);
1989 if ((flags & SigmaValue) == 0)
1990 white_point=(MagickRealType) QuantumRange-black_point;
1991 if ((*option == '+') || ((flags & AspectValue) != 0))
1992 (void) LevelizeImageChannel(*image,channel,black_point,
1995 (void) LevelImageChannel(*image,channel,black_point,white_point,
1997 InheritException(exception,&(*image)->exception);
2000 if (LocaleCompare("level-colors",option+1) == 0)
2003 token[MaxTextExtent];
2012 p=(const char *) argv[i+1];
2013 GetMagickToken(p,&p,token); /* get black point color */
2014 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2015 (void) QueryMagickColor(token,&black_point,exception);
2017 (void) QueryMagickColor("#000000",&black_point,exception);
2018 if (isalpha((int) token[0]) || (token[0] == '#'))
2019 GetMagickToken(p,&p,token);
2021 white_point=black_point; /* set everything to that color */
2025 Get white point color.
2027 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2028 GetMagickToken(p,&p,token);
2029 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2030 (void) QueryMagickColor(token,&white_point,exception);
2032 (void) QueryMagickColor("#ffffff",&white_point,exception);
2034 (void) LevelColorsImageChannel(*image,channel,&black_point,
2035 &white_point,*option == '+' ? MagickTrue : MagickFalse);
2038 if (LocaleCompare("linear-stretch",option+1) == 0)
2047 (void) SyncImageSettings(image_info,*image);
2048 flags=ParseGeometry(argv[i+1],&geometry_info);
2049 black_point=geometry_info.rho;
2050 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2051 if ((flags & SigmaValue) != 0)
2052 white_point=geometry_info.sigma;
2053 if ((flags & PercentValue) != 0)
2055 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2056 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2058 if ((flags & SigmaValue) == 0)
2059 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2061 (void) LinearStretchImage(*image,black_point,white_point);
2062 InheritException(exception,&(*image)->exception);
2065 if (LocaleCompare("linewidth",option+1) == 0)
2067 draw_info->stroke_width=StringToDouble(argv[i+1]);
2070 if (LocaleCompare("liquid-rescale",option+1) == 0)
2076 Liquid rescale image.
2078 (void) SyncImageSettings(image_info,*image);
2079 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2080 if ((flags & XValue) == 0)
2082 if ((flags & YValue) == 0)
2084 resize_image=LiquidRescaleImage(*image,geometry.width,
2085 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2086 if (resize_image == (Image *) NULL)
2088 *image=DestroyImage(*image);
2089 *image=resize_image;
2092 if (LocaleCompare("lowlight-color",option+1) == 0)
2094 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2101 if (LocaleCompare("map",option+1) == 0)
2107 Transform image colors to match this set of colors.
2109 (void) SyncImageSettings(image_info,*image);
2112 remap_image=GetImageCache(image_info,argv[i+1],exception);
2113 if (remap_image == (Image *) NULL)
2115 (void) RemapImage(quantize_info,*image,remap_image);
2116 InheritException(exception,&(*image)->exception);
2117 remap_image=DestroyImage(remap_image);
2120 if (LocaleCompare("mask",option+1) == 0)
2125 (void) SyncImageSettings(image_info,*image);
2131 (void) SetImageMask(*image,(Image *) NULL);
2132 InheritException(exception,&(*image)->exception);
2138 mask=GetImageCache(image_info,argv[i+1],exception);
2139 if (mask == (Image *) NULL)
2141 (void) SetImageMask(*image,mask);
2142 mask=DestroyImage(mask);
2143 InheritException(exception,&(*image)->exception);
2146 if (LocaleCompare("matte",option+1) == 0)
2148 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2149 SetAlphaChannel : DeactivateAlphaChannel );
2150 InheritException(exception,&(*image)->exception);
2153 if (LocaleCompare("median",option+1) == 0)
2159 Median filter image.
2161 (void) SyncImageSettings(image_info,*image);
2162 (void) ParseGeometry(argv[i+1],&geometry_info);
2163 median_image=MedianFilterImage(*image,geometry_info.rho,exception);
2164 if (median_image == (Image *) NULL)
2166 *image=DestroyImage(*image);
2167 *image=median_image;
2170 if (LocaleCompare("modulate",option+1) == 0)
2172 (void) SyncImageSettings(image_info,*image);
2173 (void) ModulateImage(*image,argv[i+1]);
2174 InheritException(exception,&(*image)->exception);
2177 if (LocaleCompare("monitor",option+1) == 0)
2179 (void) SetImageProgressMonitor(*image,MonitorProgress,
2183 if (LocaleCompare("monochrome",option+1) == 0)
2185 (void) SyncImageSettings(image_info,*image);
2186 (void) SetImageType(*image,BilevelType);
2187 InheritException(exception,&(*image)->exception);
2190 if (LocaleCompare("morphology",option+1) == 0)
2199 token[MaxTextExtent];
2210 Morphological Image Operation
2212 (void) SyncImageSettings(image_info,*image);
2214 GetMagickToken(p,&p,token);
2215 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
2218 GetMagickToken(p,&p,token);
2219 if ( (*p == ':') || (*p == ','))
2220 GetMagickToken(p,&p,token);
2222 iterations = StringToLong(p);
2223 kernel=AcquireKernelInfo(argv[i+2]);
2224 if (kernel == (KernelInfo *) NULL)
2225 ThrowWandFatalException(ResourceLimitFatalError,
2226 "MemoryAllocationFailed",(*image)->filename);
2227 if ( GetImageArtifact(*image,"showkernel") != (const char *) NULL)
2228 ShowKernelInfo(kernel); /* display the kernel to stderr */
2229 morphology_image=MorphologyImageChannel(*image,channel,method,
2230 iterations,kernel,exception);
2231 kernel=DestroyKernelInfo(kernel);
2232 if (morphology_image == (Image *) NULL)
2234 *image=DestroyImage(*image);
2235 *image=morphology_image;
2238 if (LocaleCompare("motion-blur",option+1) == 0)
2246 (void) SyncImageSettings(image_info,*image);
2247 flags=ParseGeometry(argv[i+1],&geometry_info);
2248 if ((flags & SigmaValue) == 0)
2249 geometry_info.sigma=1.0;
2250 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2251 geometry_info.sigma,geometry_info.xi,exception);
2252 if (blur_image == (Image *) NULL)
2254 *image=DestroyImage(*image);
2262 if (LocaleCompare("negate",option+1) == 0)
2264 (void) SyncImageSettings(image_info,*image);
2265 (void) NegateImageChannel(*image,channel,*option == '+' ?
2266 MagickTrue : MagickFalse);
2267 InheritException(exception,&(*image)->exception);
2270 if (LocaleCompare("noise",option+1) == 0)
2275 (void) SyncImageSettings(image_info,*image);
2278 (void) ParseGeometry(argv[i+1],&geometry_info);
2279 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
2287 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2288 MagickFalse,argv[i+1]);
2289 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2292 if (noisy_image == (Image *) NULL)
2294 *image=DestroyImage(*image);
2298 if (LocaleCompare("normalize",option+1) == 0)
2300 (void) SyncImageSettings(image_info,*image);
2301 (void) NormalizeImageChannel(*image,channel);
2302 InheritException(exception,&(*image)->exception);
2309 if (LocaleCompare("opaque",option+1) == 0)
2314 (void) SyncImageSettings(image_info,*image);
2315 (void) QueryMagickColor(argv[i+1],&target,exception);
2316 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2317 *option == '-' ? MagickFalse : MagickTrue);
2320 if (LocaleCompare("ordered-dither",option+1) == 0)
2322 (void) SyncImageSettings(image_info,*image);
2323 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2331 if (LocaleCompare("paint",option+1) == 0)
2339 (void) SyncImageSettings(image_info,*image);
2340 (void) ParseGeometry(argv[i+1],&geometry_info);
2341 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2342 if (paint_image == (Image *) NULL)
2344 *image=DestroyImage(*image);
2348 if (LocaleCompare("pen",option+1) == 0)
2352 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2355 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2358 if (LocaleCompare("pointsize",option+1) == 0)
2361 (void) ParseGeometry("12",&geometry_info);
2363 (void) ParseGeometry(argv[i+1],&geometry_info);
2364 draw_info->pointsize=geometry_info.rho;
2367 if (LocaleCompare("polaroid",option+1) == 0)
2379 Simulate a Polaroid picture.
2381 (void) SyncImageSettings(image_info,*image);
2382 random_info=AcquireRandomInfo();
2383 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2384 random_info=DestroyRandomInfo(random_info);
2387 SetGeometryInfo(&geometry_info);
2388 flags=ParseGeometry(argv[i+1],&geometry_info);
2389 angle=geometry_info.rho;
2391 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2392 if (polaroid_image == (Image *) NULL)
2394 *image=DestroyImage(*image);
2395 *image=polaroid_image;
2398 if (LocaleCompare("posterize",option+1) == 0)
2403 (void) SyncImageSettings(image_info,*image);
2404 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2405 quantize_info->dither);
2406 InheritException(exception,&(*image)->exception);
2409 if (LocaleCompare("preview",option+1) == 0)
2420 (void) SyncImageSettings(image_info,*image);
2422 preview_type=UndefinedPreview;
2424 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2425 MagickFalse,argv[i+1]);
2426 preview_image=PreviewImage(*image,preview_type,exception);
2427 if (preview_image == (Image *) NULL)
2429 *image=DestroyImage(*image);
2430 *image=preview_image;
2433 if (LocaleCompare("profile",option+1) == 0)
2447 (void) SyncImageSettings(image_info,*image);
2451 Remove a profile from the image.
2453 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2455 InheritException(exception,&(*image)->exception);
2459 Associate a profile with the image.
2461 profile_info=CloneImageInfo(image_info);
2462 profile=GetImageProfile(*image,"iptc");
2463 if (profile != (StringInfo *) NULL)
2464 profile_info->profile=(void *) CloneStringInfo(profile);
2465 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2466 profile_info=DestroyImageInfo(profile_info);
2467 if (profile_image == (Image *) NULL)
2470 name[MaxTextExtent],
2471 filename[MaxTextExtent];
2479 (void) CopyMagickString(filename,argv[i+1],MaxTextExtent);
2480 (void) CopyMagickString(name,argv[i+1],MaxTextExtent);
2481 for (p=filename; *p != '\0'; p++)
2482 if ((*p == ':') && (IsPathDirectory(argv[i+1]) < 0) &&
2483 (IsPathAccessible(argv[i+1]) == MagickFalse))
2489 Look for profile name (e.g. name:profile).
2491 (void) CopyMagickString(name,filename,(size_t)
2493 for (q=filename; *q != '\0'; q++)
2497 profile=FileToStringInfo(filename,~0UL,exception);
2498 if (profile != (StringInfo *) NULL)
2500 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2501 (unsigned long) GetStringInfoLength(profile),MagickFalse);
2502 profile=DestroyStringInfo(profile);
2506 ResetImageProfileIterator(profile_image);
2507 name=GetNextImageProfile(profile_image);
2508 while (name != (const char *) NULL)
2510 profile=GetImageProfile(profile_image,name);
2511 if (profile != (StringInfo *) NULL)
2512 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2513 (unsigned long) GetStringInfoLength(profile),MagickFalse);
2514 name=GetNextImageProfile(profile_image);
2516 profile_image=DestroyImage(profile_image);
2523 if (LocaleCompare("quantize",option+1) == 0)
2527 quantize_info->colorspace=UndefinedColorspace;
2530 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2531 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2538 if (LocaleCompare("radial-blur",option+1) == 0)
2546 (void) SyncImageSettings(image_info,*image);
2547 blur_image=RadialBlurImageChannel(*image,channel,
2548 StringToDouble(argv[i+1]),exception);
2549 if (blur_image == (Image *) NULL)
2551 *image=DestroyImage(*image);
2555 if (LocaleCompare("raise",option+1) == 0)
2558 Surround image with a raise of solid color.
2560 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2561 if ((flags & SigmaValue) == 0)
2562 geometry.height=geometry.width;
2563 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2565 InheritException(exception,&(*image)->exception);
2568 if (LocaleCompare("random-threshold",option+1) == 0)
2573 (void) SyncImageSettings(image_info,*image);
2574 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2578 if (LocaleCompare("recolor",option+1) == 0)
2581 token[MaxTextExtent];
2599 Transform color image.
2601 (void) SyncImageSettings(image_info,*image);
2603 for (x=0; *p != '\0'; x++)
2605 GetMagickToken(p,&p,token);
2607 GetMagickToken(p,&p,token);
2609 order=(unsigned long) sqrt((double) x+1.0);
2610 color_matrix=(double *) AcquireQuantumMemory(order,order*
2611 sizeof(*color_matrix));
2612 if (color_matrix == (double *) NULL)
2613 ThrowWandFatalException(ResourceLimitFatalError,
2614 "MemoryAllocationFailed",(*image)->filename);
2616 for (x=0; (x < (long) (order*order)) && (*p != '\0'); x++)
2618 GetMagickToken(p,&p,token);
2620 GetMagickToken(p,&p,token);
2621 color_matrix[x]=StringToDouble(token);
2623 for ( ; x < (long) (order*order); x++)
2624 color_matrix[x]=0.0;
2625 recolor_image=RecolorImage(*image,order,color_matrix,exception);
2626 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
2627 if (recolor_image == (Image *) NULL)
2629 *image=DestroyImage(*image);
2630 *image=recolor_image;
2633 if (LocaleCompare("region",option+1) == 0)
2638 (void) SyncImageSettings(image_info,*image);
2639 if (region_image != (Image *) NULL)
2644 (void) CompositeImage(region_image,(*image)->matte !=
2645 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2646 region_geometry.x,region_geometry.y);
2647 InheritException(exception,®ion_image->exception);
2648 *image=DestroyImage(*image);
2649 *image=region_image;
2653 if (region_image != (Image *) NULL)
2654 region_image=DestroyImage(region_image);
2658 Apply transformations to a selected region of the image.
2660 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2662 crop_image=CropImage(*image,®ion_geometry,exception);
2663 if (crop_image == (Image *) NULL)
2665 region_image=(*image);
2669 if (LocaleCompare("render",option+1) == 0)
2671 (void) SyncImageSettings(image_info,*image);
2672 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2675 if (LocaleCompare("remap",option+1) == 0)
2681 Transform image colors to match this set of colors.
2683 (void) SyncImageSettings(image_info,*image);
2686 remap_image=GetImageCache(image_info,argv[i+1],exception);
2687 if (remap_image == (Image *) NULL)
2689 (void) RemapImage(quantize_info,*image,remap_image);
2690 InheritException(exception,&(*image)->exception);
2691 remap_image=DestroyImage(remap_image);
2694 if (LocaleCompare("repage",option+1) == 0)
2698 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2701 (void) ResetImagePage(*image,argv[i+1]);
2702 InheritException(exception,&(*image)->exception);
2705 if (LocaleCompare("resample",option+1) == 0)
2713 (void) SyncImageSettings(image_info,*image);
2714 flags=ParseGeometry(argv[i+1],&geometry_info);
2715 if ((flags & SigmaValue) == 0)
2716 geometry_info.sigma=geometry_info.rho;
2717 resample_image=ResampleImage(*image,geometry_info.rho,
2718 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2719 if (resample_image == (Image *) NULL)
2721 *image=DestroyImage(*image);
2722 *image=resample_image;
2725 if (LocaleCompare("resize",option+1) == 0)
2733 (void) SyncImageSettings(image_info,*image);
2734 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2735 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2736 (*image)->filter,(*image)->blur,exception);
2737 if (resize_image == (Image *) NULL)
2739 *image=DestroyImage(*image);
2740 *image=resize_image;
2743 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2745 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2748 if (LocaleCompare("roll",option+1) == 0)
2756 (void) SyncImageSettings(image_info,*image);
2757 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2758 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2759 if (roll_image == (Image *) NULL)
2761 *image=DestroyImage(*image);
2765 if (LocaleCompare("rotate",option+1) == 0)
2774 Check for conditional image rotation.
2776 (void) SyncImageSettings(image_info,*image);
2777 if (strchr(argv[i+1],'>') != (char *) NULL)
2778 if ((*image)->columns <= (*image)->rows)
2780 if (strchr(argv[i+1],'<') != (char *) NULL)
2781 if ((*image)->columns >= (*image)->rows)
2786 geometry=ConstantString(argv[i+1]);
2787 (void) SubstituteString(&geometry,">","");
2788 (void) SubstituteString(&geometry,"<","");
2789 (void) ParseGeometry(geometry,&geometry_info);
2790 geometry=DestroyString(geometry);
2791 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2792 if (rotate_image == (Image *) NULL)
2794 *image=DestroyImage(*image);
2795 *image=rotate_image;
2802 if (LocaleCompare("sample",option+1) == 0)
2808 Sample image with pixel replication.
2810 (void) SyncImageSettings(image_info,*image);
2811 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2812 sample_image=SampleImage(*image,geometry.width,geometry.height,
2814 if (sample_image == (Image *) NULL)
2816 *image=DestroyImage(*image);
2817 *image=sample_image;
2820 if (LocaleCompare("scale",option+1) == 0)
2828 (void) SyncImageSettings(image_info,*image);
2829 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2830 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2832 if (scale_image == (Image *) NULL)
2834 *image=DestroyImage(*image);
2838 if (LocaleCompare("selective-blur",option+1) == 0)
2844 Selectively blur pixels within a contrast threshold.
2846 (void) SyncImageSettings(image_info,*image);
2847 flags=ParseGeometry(argv[i+1],&geometry_info);
2848 if ((flags & PercentValue) != 0)
2849 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2850 blur_image=SelectiveBlurImageChannel(*image,channel,
2851 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2852 if (blur_image == (Image *) NULL)
2854 *image=DestroyImage(*image);
2858 if (LocaleCompare("separate",option+1) == 0)
2864 Break channels into separate images.
2866 (void) SyncImageSettings(image_info,*image);
2867 separate_images=SeparateImages(*image,channel,exception);
2868 if (separate_images == (Image *) NULL)
2870 *image=DestroyImage(*image);
2871 *image=separate_images;
2874 if (LocaleCompare("sepia-tone",option+1) == 0)
2885 (void) SyncImageSettings(image_info,*image);
2886 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2887 sepia_image=SepiaToneImage(*image,threshold,exception);
2888 if (sepia_image == (Image *) NULL)
2890 *image=DestroyImage(*image);
2894 if (LocaleCompare("segment",option+1) == 0)
2899 (void) SyncImageSettings(image_info,*image);
2900 flags=ParseGeometry(argv[i+1],&geometry_info);
2901 if ((flags & SigmaValue) == 0)
2902 geometry_info.sigma=1.0;
2903 (void) SegmentImage(*image,(*image)->colorspace,image_info->verbose,
2904 geometry_info.rho,geometry_info.sigma);
2905 InheritException(exception,&(*image)->exception);
2908 if (LocaleCompare("set",option+1) == 0)
2913 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2914 (void) DeleteImageRegistry(argv[i+1]+9);
2916 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2917 (void) DeleteImageOption(image_info,argv[i+1]+7);
2919 (void) DeleteImageProperty(*image,argv[i+1]);
2925 value=InterpretImageProperties(image_info,*image,argv[i+2]);
2926 if (value != (char *) NULL)
2928 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2929 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,
2932 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2934 (void) SetImageOption(image_info,argv[i+1]+7,value);
2935 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2938 (void) SetImageProperty(*image,argv[i+1],value);
2939 value=DestroyString(value);
2944 if (LocaleCompare("shade",option+1) == 0)
2952 (void) SyncImageSettings(image_info,*image);
2953 flags=ParseGeometry(argv[i+1],&geometry_info);
2954 if ((flags & SigmaValue) == 0)
2955 geometry_info.sigma=1.0;
2956 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2957 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2958 if (shade_image == (Image *) NULL)
2960 *image=DestroyImage(*image);
2964 if (LocaleCompare("shadow",option+1) == 0)
2972 (void) SyncImageSettings(image_info,*image);
2973 flags=ParseGeometry(argv[i+1],&geometry_info);
2974 if ((flags & SigmaValue) == 0)
2975 geometry_info.sigma=1.0;
2976 if ((flags & XiValue) == 0)
2977 geometry_info.xi=4.0;
2978 if ((flags & PsiValue) == 0)
2979 geometry_info.psi=4.0;
2980 shadow_image=ShadowImage(*image,geometry_info.rho,
2981 geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
2982 (geometry_info.psi+0.5),exception);
2983 if (shadow_image == (Image *) NULL)
2985 *image=DestroyImage(*image);
2986 *image=shadow_image;
2989 if (LocaleCompare("sharpen",option+1) == 0)
2997 (void) SyncImageSettings(image_info,*image);
2998 flags=ParseGeometry(argv[i+1],&geometry_info);
2999 if ((flags & SigmaValue) == 0)
3000 geometry_info.sigma=1.0;
3001 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
3002 geometry_info.sigma,exception);
3003 if (sharp_image == (Image *) NULL)
3005 *image=DestroyImage(*image);
3009 if (LocaleCompare("shave",option+1) == 0)
3015 Shave the image edges.
3017 (void) SyncImageSettings(image_info,*image);
3018 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
3019 shave_image=ShaveImage(*image,&geometry,exception);
3020 if (shave_image == (Image *) NULL)
3022 *image=DestroyImage(*image);
3026 if (LocaleCompare("shear",option+1) == 0)
3034 (void) SyncImageSettings(image_info,*image);
3035 flags=ParseGeometry(argv[i+1],&geometry_info);
3036 if ((flags & SigmaValue) == 0)
3037 geometry_info.sigma=geometry_info.rho;
3038 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3040 if (shear_image == (Image *) NULL)
3042 *image=DestroyImage(*image);
3046 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3049 Sigmoidal non-linearity contrast control.
3051 (void) SyncImageSettings(image_info,*image);
3052 flags=ParseGeometry(argv[i+1],&geometry_info);
3053 if ((flags & SigmaValue) == 0)
3054 geometry_info.sigma=(double) QuantumRange/2.0;
3055 if ((flags & PercentValue) != 0)
3056 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3058 (void) SigmoidalContrastImageChannel(*image,channel,
3059 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3060 geometry_info.sigma);
3061 InheritException(exception,&(*image)->exception);
3064 if (LocaleCompare("sketch",option+1) == 0)
3072 (void) SyncImageSettings(image_info,*image);
3073 flags=ParseGeometry(argv[i+1],&geometry_info);
3074 if ((flags & SigmaValue) == 0)
3075 geometry_info.sigma=1.0;
3076 sketch_image=SketchImage(*image,geometry_info.rho,
3077 geometry_info.sigma,geometry_info.xi,exception);
3078 if (sketch_image == (Image *) NULL)
3080 *image=DestroyImage(*image);
3081 *image=sketch_image;
3084 if (LocaleCompare("solarize",option+1) == 0)
3089 (void) SyncImageSettings(image_info,*image);
3090 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3091 (void) SolarizeImage(*image,threshold);
3092 InheritException(exception,&(*image)->exception);
3095 if (LocaleCompare("sparse-color",option+1) == 0)
3107 Sparse Color Interpolated Gradient
3109 (void) SyncImageSettings(image_info,*image);
3110 method=(SparseColorMethod) ParseMagickOption(
3111 MagickSparseColorOptions,MagickFalse,argv[i+1]);
3112 arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
3113 InheritException(exception,&(*image)->exception);
3114 if (arguments == (char *) NULL)
3116 sparse_image=SparseColorOption(*image,channel,method,arguments,
3117 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3118 arguments=DestroyString(arguments);
3119 if (sparse_image == (Image *) NULL)
3121 *image=DestroyImage(*image);
3122 *image=sparse_image;
3125 if (LocaleCompare("splice",option+1) == 0)
3131 Splice a solid color into the image.
3133 (void) SyncImageSettings(image_info,*image);
3134 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3135 splice_image=SpliceImage(*image,&geometry,exception);
3136 if (splice_image == (Image *) NULL)
3138 *image=DestroyImage(*image);
3139 *image=splice_image;
3142 if (LocaleCompare("spread",option+1) == 0)
3150 (void) SyncImageSettings(image_info,*image);
3151 (void) ParseGeometry(argv[i+1],&geometry_info);
3152 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3153 if (spread_image == (Image *) NULL)
3155 *image=DestroyImage(*image);
3156 *image=spread_image;
3159 if (LocaleCompare("stretch",option+1) == 0)
3163 draw_info->stretch=UndefinedStretch;
3166 draw_info->stretch=(StretchType) ParseMagickOption(
3167 MagickStretchOptions,MagickFalse,argv[i+1]);
3170 if (LocaleCompare("strip",option+1) == 0)
3173 Strip image of profiles and comments.
3175 (void) SyncImageSettings(image_info,*image);
3176 (void) StripImage(*image);
3177 InheritException(exception,&(*image)->exception);
3180 if (LocaleCompare("stroke",option+1) == 0)
3187 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3188 if (draw_info->stroke_pattern != (Image *) NULL)
3189 draw_info->stroke_pattern=DestroyImage(
3190 draw_info->stroke_pattern);
3193 sans=AcquireExceptionInfo();
3194 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3195 sans=DestroyExceptionInfo(sans);
3196 if (status == MagickFalse)
3197 draw_info->stroke_pattern=GetImageCache(image_info,argv[i+1],
3201 if (LocaleCompare("strokewidth",option+1) == 0)
3203 draw_info->stroke_width=StringToDouble(argv[i+1]);
3206 if (LocaleCompare("style",option+1) == 0)
3210 draw_info->style=UndefinedStyle;
3213 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3214 MagickFalse,argv[i+1]);
3217 if (LocaleCompare("swirl",option+1) == 0)
3225 (void) SyncImageSettings(image_info,*image);
3226 (void) ParseGeometry(argv[i+1],&geometry_info);
3227 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3228 if (swirl_image == (Image *) NULL)
3230 *image=DestroyImage(*image);
3238 if (LocaleCompare("threshold",option+1) == 0)
3246 (void) SyncImageSettings(image_info,*image);
3248 threshold=(double) QuantumRange/2.5;
3250 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3251 (void) BilevelImageChannel(*image,channel,threshold);
3252 InheritException(exception,&(*image)->exception);
3255 if (LocaleCompare("thumbnail",option+1) == 0)
3263 (void) SyncImageSettings(image_info,*image);
3264 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3265 thumbnail_image=ThumbnailImage(*image,geometry.width,
3266 geometry.height,exception);
3267 if (thumbnail_image == (Image *) NULL)
3269 *image=DestroyImage(*image);
3270 *image=thumbnail_image;
3273 if (LocaleCompare("tile",option+1) == 0)
3277 if (draw_info->fill_pattern != (Image *) NULL)
3278 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3281 draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
3285 if (LocaleCompare("tint",option+1) == 0)
3293 (void) SyncImageSettings(image_info,*image);
3294 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3295 if (tint_image == (Image *) NULL)
3297 *image=DestroyImage(*image);
3301 if (LocaleCompare("transform",option+1) == 0)
3307 Affine transform image.
3309 (void) SyncImageSettings(image_info,*image);
3310 transform_image=AffineTransformImage(*image,&draw_info->affine,
3312 if (transform_image == (Image *) NULL)
3314 *image=DestroyImage(*image);
3315 *image=transform_image;
3318 if (LocaleCompare("transparent",option+1) == 0)
3323 (void) SyncImageSettings(image_info,*image);
3324 (void) QueryMagickColor(argv[i+1],&target,exception);
3325 (void) TransparentPaintImage(*image,&target,(Quantum)
3326 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3327 InheritException(exception,&(*image)->exception);
3330 if (LocaleCompare("transpose",option+1) == 0)
3336 Transpose image scanlines.
3338 (void) SyncImageSettings(image_info,*image);
3339 transpose_image=TransposeImage(*image,exception);
3340 if (transpose_image == (Image *) NULL)
3342 *image=DestroyImage(*image);
3343 *image=transpose_image;
3346 if (LocaleCompare("transverse",option+1) == 0)
3352 Transverse image scanlines.
3354 (void) SyncImageSettings(image_info,*image);
3355 transverse_image=TransverseImage(*image,exception);
3356 if (transverse_image == (Image *) NULL)
3358 *image=DestroyImage(*image);
3359 *image=transverse_image;
3362 if (LocaleCompare("treedepth",option+1) == 0)
3364 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3367 if (LocaleCompare("trim",option+1) == 0)
3375 (void) SyncImageSettings(image_info,*image);
3376 trim_image=TrimImage(*image,exception);
3377 if (trim_image == (Image *) NULL)
3379 *image=DestroyImage(*image);
3383 if (LocaleCompare("type",option+1) == 0)
3388 (void) SyncImageSettings(image_info,*image);
3392 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3394 (*image)->type=UndefinedType;
3395 (void) SetImageType(*image,type);
3396 InheritException(exception,&(*image)->exception);
3403 if (LocaleCompare("undercolor",option+1) == 0)
3405 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3409 if (LocaleCompare("unique",option+1) == 0)
3413 (void) DeleteImageArtifact(*image,"identify:unique");
3416 (void) SetImageArtifact(*image,"identify:unique","true");
3419 if (LocaleCompare("unique-colors",option+1) == 0)
3425 Unique image colors.
3427 (void) SyncImageSettings(image_info,*image);
3428 unique_image=UniqueImageColors(*image,exception);
3429 if (unique_image == (Image *) NULL)
3431 *image=DestroyImage(*image);
3432 *image=unique_image;
3435 if (LocaleCompare("unsharp",option+1) == 0)
3443 (void) SyncImageSettings(image_info,*image);
3444 flags=ParseGeometry(argv[i+1],&geometry_info);
3445 if ((flags & SigmaValue) == 0)
3446 geometry_info.sigma=1.0;
3447 if ((flags & XiValue) == 0)
3448 geometry_info.xi=1.0;
3449 if ((flags & PsiValue) == 0)
3450 geometry_info.psi=0.05;
3451 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3452 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3453 geometry_info.psi,exception);
3454 if (unsharp_image == (Image *) NULL)
3456 *image=DestroyImage(*image);
3457 *image=unsharp_image;
3464 if (LocaleCompare("verbose",option+1) == 0)
3466 (void) SetImageArtifact(*image,option+1,
3467 *option == '+' ? "false" : "true");
3470 if (LocaleCompare("vignette",option+1) == 0)
3478 (void) SyncImageSettings(image_info,*image);
3479 flags=ParseGeometry(argv[i+1],&geometry_info);
3480 if ((flags & SigmaValue) == 0)
3481 geometry_info.sigma=1.0;
3482 if ((flags & XiValue) == 0)
3483 geometry_info.xi=0.1*(*image)->columns;
3484 if ((flags & PsiValue) == 0)
3485 geometry_info.psi=0.1*(*image)->rows;
3486 vignette_image=VignetteImage(*image,geometry_info.rho,
3487 geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
3488 (geometry_info.psi+0.5),exception);
3489 if (vignette_image == (Image *) NULL)
3491 *image=DestroyImage(*image);
3492 *image=vignette_image;
3495 if (LocaleCompare("virtual-pixel",option+1) == 0)
3499 (void) SetImageVirtualPixelMethod(*image,
3500 UndefinedVirtualPixelMethod);
3503 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3504 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3512 if (LocaleCompare("wave",option+1) == 0)
3520 (void) SyncImageSettings(image_info,*image);
3521 flags=ParseGeometry(argv[i+1],&geometry_info);
3522 if ((flags & SigmaValue) == 0)
3523 geometry_info.sigma=1.0;
3524 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3526 if (wave_image == (Image *) NULL)
3528 *image=DestroyImage(*image);
3532 if (LocaleCompare("weight",option+1) == 0)
3534 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3535 if (LocaleCompare(argv[i+1],"all") == 0)
3536 draw_info->weight=0;
3537 if (LocaleCompare(argv[i+1],"bold") == 0)
3538 draw_info->weight=700;
3539 if (LocaleCompare(argv[i+1],"bolder") == 0)
3540 if (draw_info->weight <= 800)
3541 draw_info->weight+=100;
3542 if (LocaleCompare(argv[i+1],"lighter") == 0)
3543 if (draw_info->weight >= 100)
3544 draw_info->weight-=100;
3545 if (LocaleCompare(argv[i+1],"normal") == 0)
3546 draw_info->weight=400;
3549 if (LocaleCompare("white-threshold",option+1) == 0)
3552 White threshold image.
3554 (void) SyncImageSettings(image_info,*image);
3555 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3557 InheritException(exception,&(*image)->exception);
3567 if (region_image != (Image *) NULL)
3570 Composite transformed region onto image.
3572 (void) SyncImageSettings(image_info,*image);
3573 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3574 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3576 InheritException(exception,®ion_image->exception);
3577 *image=DestroyImage(*image);
3578 *image=region_image;
3583 quantize_info=DestroyQuantizeInfo(quantize_info);
3584 draw_info=DestroyDrawInfo(draw_info);
3585 status=(*image)->exception.severity == UndefinedException ?
3586 MagickTrue : MagickFalse;
3591 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3595 % M o g r i f y I m a g e C o m m a n d %
3599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3601 % MogrifyImageCommand() transforms an image or a sequence of images. These
3602 % transforms include image scaling, image rotation, color reduction, and
3603 % others. The transmogrified image overwrites the original image.
3605 % The format of the MogrifyImageCommand method is:
3607 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3608 % const char **argv,char **metadata,ExceptionInfo *exception)
3610 % A description of each parameter follows:
3612 % o image_info: the image info.
3614 % o argc: the number of elements in the argument vector.
3616 % o argv: A text array containing the command line arguments.
3618 % o metadata: any metadata is returned here.
3620 % o exception: return any errors or warnings in this structure.
3624 static MagickBooleanType MogrifyUsage(void)
3629 "-debug events display copious debugging information",
3630 "-help print program options",
3631 "-list type print a list of supported option arguments",
3632 "-log format format of debugging information",
3633 "-version print version information",
3638 "-adaptive-blur geometry",
3639 " adaptively blur pixels; decrease effect near edges",
3640 "-adaptive-resize geometry",
3641 " adaptively resize image using 'mesh' interpolation",
3642 "-adaptive-sharpen geometry",
3643 " adaptively sharpen pixels; increase effect near edges",
3644 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3645 " transparent, extract, background, or shape",
3646 "-annotate geometry text",
3647 " annotate the image with text",
3648 "-auto-gamma automagically adjust gamma level of image",
3649 "-auto-level automagically adjust color levels of image",
3650 "-auto-orient automagically orient (rotate) image",
3651 "-bench iterations measure performance",
3652 "-black-threshold value",
3653 " force all pixels below the threshold into black",
3654 "-blue-shift simulate a scene at nighttime in the moonlight",
3655 "-blur geometry reduce image noise and reduce detail levels",
3656 "-border geometry surround image with a border of color",
3657 "-bordercolor color border color",
3658 "-brightness-contrast geometry",
3659 " improve brightness / contrast of the image",
3660 "-cdl filename color correct with a color decision list",
3661 "-charcoal radius simulate a charcoal drawing",
3662 "-chop geometry remove pixels from the image interior",
3663 "-clamp restrict pixel range from 0 to the quantum depth",
3664 "-clip clip along the first path from the 8BIM profile",
3665 "-clip-mask filename associate a clip mask with the image",
3666 "-clip-path id clip along a named path from the 8BIM profile",
3667 "-colorize value colorize the image with the fill color",
3668 "-contrast enhance or reduce the image contrast",
3669 "-contrast-stretch geometry",
3670 " improve contrast by `stretching' the intensity range",
3671 "-convolve coefficients",
3672 " apply a convolution kernel to the image",
3673 "-cycle amount cycle the image colormap",
3674 "-decipher filename convert cipher pixels to plain pixels",
3675 "-deskew threshold straighten an image",
3676 "-despeckle reduce the speckles within an image",
3677 "-distort method args",
3678 " distort images according to given method ad args",
3679 "-draw string annotate the image with a graphic primitive",
3680 "-edge radius apply a filter to detect edges in the image",
3681 "-encipher filename convert plain pixels to cipher pixels",
3682 "-emboss radius emboss an image",
3683 "-enhance apply a digital filter to enhance a noisy image",
3684 "-equalize perform histogram equalization to an image",
3685 "-evaluate operator value",
3686 " evaluate an expression over image values",
3687 "-extent geometry set the image size",
3688 "-extract geometry extract area from image",
3689 "-fft implements the discrete Fourier transform (DFT)",
3690 "-flip flip image vertically",
3691 "-floodfill geometry color",
3692 " floodfill the image with color",
3693 "-flop flop image horizontally",
3694 "-frame geometry surround image with an ornamental border",
3695 "-function name parameters",
3696 " apply function over image values",
3697 "-gamma value level of gamma correction",
3698 "-gaussian-blur geometry",
3699 " reduce image noise and reduce detail levels",
3700 "-geometry geometry preferred size or location of the image",
3701 "-identify identify the format and characteristics of the image",
3702 "-ift implements the inverse discrete Fourier transform (DFT)",
3703 "-implode amount implode image pixels about the center",
3704 "-lat geometry local adaptive thresholding",
3705 "-layers method optimize, merge, or compare image layers",
3706 "-level value adjust the level of image contrast",
3707 "-level-colors color,color",
3708 " level image with the given colors",
3709 "-linear-stretch geometry",
3710 " improve contrast by `stretching with saturation'",
3711 "-liquid-rescale geometry",
3712 " rescale image with seam-carving",
3713 "-median radius apply a median filter to the image",
3714 "-modulate value vary the brightness, saturation, and hue",
3715 "-monochrome transform image to black and white",
3716 "-morphology method kernel",
3717 " apply a morphology method to the image",
3718 "-motion-blur geometry",
3719 " simulate motion blur",
3720 "-negate replace every pixel with its complementary color ",
3721 "-noise radius add or reduce noise in an image",
3722 "-normalize transform image to span the full range of colors",
3723 "-opaque color change this color to the fill color",
3724 "-ordered-dither NxN",
3725 " add a noise pattern to the image with specific",
3727 "-paint radius simulate an oil painting",
3728 "-polaroid angle simulate a Polaroid picture",
3729 "-posterize levels reduce the image to a limited number of color levels",
3730 "-print string interpret string and print to console",
3731 "-profile filename add, delete, or apply an image profile",
3732 "-quantize colorspace reduce colors in this colorspace",
3733 "-radial-blur angle radial blur the image",
3734 "-raise value lighten/darken image edges to create a 3-D effect",
3735 "-random-threshold low,high",
3736 " random threshold the image",
3737 "-recolor matrix translate, scale, shear, or rotate image colors",
3738 "-region geometry apply options to a portion of the image",
3739 "-render render vector graphics",
3740 "-repage geometry size and location of an image canvas",
3741 "-resample geometry change the resolution of an image",
3742 "-resize geometry resize the image",
3743 "-roll geometry roll an image vertically or horizontally",
3744 "-rotate degrees apply Paeth rotation to the image",
3745 "-sample geometry scale image with pixel sampling",
3746 "-scale geometry scale the image",
3747 "-segment values segment an image",
3748 "-selective-blur geometry",
3749 " selectively blur pixels within a contrast threshold",
3750 "-sepia-tone threshold",
3751 " simulate a sepia-toned photo",
3752 "-set property value set an image property",
3753 "-shade degrees shade the image using a distant light source",
3754 "-shadow geometry simulate an image shadow",
3755 "-sharpen geometry sharpen the image",
3756 "-shave geometry shave pixels from the image edges",
3757 "-shear geometry slide one edge of the image along the X or Y axis",
3758 "-sigmoidal-contrast geometry",
3759 " increase the contrast without saturating highlights or shadows",
3760 "-sketch geometry simulate a pencil sketch",
3761 "-solarize threshold negate all pixels above the threshold level",
3762 "-sparse-color method args",
3763 " fill in a image based on a few color points",
3764 "-splice geometry splice the background color into the image",
3765 "-spread radius displace image pixels by a random amount",
3766 "-strip strip image of all profiles and comments",
3767 "-swirl degrees swirl image pixels about the center",
3768 "-threshold value threshold the image",
3769 "-thumbnail geometry create a thumbnail of the image",
3770 "-tile filename tile image when filling a graphic primitive",
3771 "-tint value tint the image with the fill color",
3772 "-transform affine transform image",
3773 "-transparent color make this color transparent within the image",
3774 "-transpose flip image vertically and rotate 90 degrees",
3775 "-transverse flop image horizontally and rotate 270 degrees",
3776 "-trim trim image edges",
3777 "-type type image type",
3778 "-unique-colors discard all but one of any pixel color",
3779 "-unsharp geometry sharpen the image",
3780 "-vignette geometry soften the edges of the image in vignette style",
3781 "-wave geometry alter an image along a sine wave",
3782 "-white-threshold value",
3783 " force all pixels above the threshold into white",
3786 *sequence_operators[]=
3788 "-append append an image sequence",
3789 "-average average an image sequence",
3790 "-clut apply a color lookup table to the image",
3791 "-coalesce merge a sequence of images",
3792 "-combine combine a sequence of images",
3793 "-composite composite image",
3794 "-crop geometry cut out a rectangular region of the image",
3795 "-deconstruct break down an image sequence into constituent parts",
3796 "-flatten flatten a sequence of images",
3797 "-fx expression apply mathematical expression to an image channel(s)",
3798 "-hald-clut apply a Hald color lookup table to the image",
3799 "-morph value morph an image sequence",
3800 "-mosaic create a mosaic from an image sequence",
3801 "-process arguments process the image with a custom image filter",
3802 "-reverse reverse image sequence",
3803 "-separate separate an image channel into a grayscale image",
3804 "-write filename write images to this file",
3809 "-adjoin join images into a single multi-image file",
3810 "-affine matrix affine transform matrix",
3811 "-alpha option activate, deactivate, reset, or set the alpha channel",
3812 "-antialias remove pixel-aliasing",
3813 "-authenticate password",
3814 " decipher image with this password",
3815 "-attenuate value lessen (or intensify) when adding noise to an image",
3816 "-background color background color",
3817 "-bias value add bias when convolving an image",
3818 "-black-point-compensation",
3819 " use black point compensation",
3820 "-blue-primary point chromaticity blue primary point",
3821 "-bordercolor color border color",
3822 "-caption string assign a caption to an image",
3823 "-channel type apply option to select image channels",
3824 "-colors value preferred number of colors in the image",
3825 "-colorspace type alternate image colorspace",
3826 "-comment string annotate image with comment",
3827 "-compose operator set image composite operator",
3828 "-compress type type of pixel compression when writing the image",
3829 "-define format:option",
3830 " define one or more image format options",
3831 "-delay value display the next image after pausing",
3832 "-density geometry horizontal and vertical density of the image",
3833 "-depth value image depth",
3834 "-display server get image or font from this X server",
3835 "-dispose method layer disposal method",
3836 "-dither method apply error diffusion to image",
3837 "-encoding type text encoding type",
3838 "-endian type endianness (MSB or LSB) of the image",
3839 "-family name render text with this font family",
3840 "-fill color color to use when filling a graphic primitive",
3841 "-filter type use this filter when resizing an image",
3842 "-font name render text with this font",
3843 "-format \"string\" output formatted image characteristics",
3844 "-fuzz distance colors within this distance are considered equal",
3845 "-gravity type horizontal and vertical text placement",
3846 "-green-primary point chromaticity green primary point",
3847 "-intent type type of rendering intent when managing the image color",
3848 "-interlace type type of image interlacing scheme",
3849 "-interline-spacing value",
3850 " set the space between two text lines",
3851 "-interpolate method pixel color interpolation method",
3852 "-interword-spacing value",
3853 " set the space between two words",
3854 "-kerning value set the space between two letters",
3855 "-label string assign a label to an image",
3856 "-limit type value pixel cache resource limit",
3857 "-loop iterations add Netscape loop extension to your GIF animation",
3858 "-mask filename associate a mask with the image",
3859 "-mattecolor color frame color",
3860 "-monitor monitor progress",
3861 "-orient type image orientation",
3862 "-page geometry size and location of an image canvas (setting)",
3863 "-ping efficiently determine image attributes",
3864 "-pointsize value font point size",
3865 "-precision value maximum number of significant digits to print",
3866 "-preview type image preview type",
3867 "-quality value JPEG/MIFF/PNG compression level",
3868 "-quiet suppress all warning messages",
3869 "-red-primary point chromaticity red primary point",
3870 "-regard-warnings pay attention to warning messages",
3871 "-remap filename transform image colors to match this set of colors",
3872 "-respect-parentheses settings remain in effect until parenthesis boundary",
3873 "-sampling-factor geometry",
3874 " horizontal and vertical sampling factor",
3875 "-scene value image scene number",
3876 "-seed value seed a new sequence of pseudo-random numbers",
3877 "-size geometry width and height of image",
3878 "-stretch type render text with this font stretch",
3879 "-stroke color graphic primitive stroke color",
3880 "-strokewidth value graphic primitive stroke width",
3881 "-style type render text with this font style",
3882 "-taint image as ineligible for bi-modal delegate",
3883 "-texture filename name of texture to tile onto the image background",
3884 "-tile-offset geometry",
3886 "-treedepth value color tree depth",
3887 "-transparent-color color",
3888 " transparent color",
3889 "-undercolor color annotation bounding box color",
3890 "-units type the units of image resolution",
3891 "-verbose print detailed information about the image",
3892 "-view FlashPix viewing transforms",
3893 "-virtual-pixel method",
3894 " virtual pixel access method",
3895 "-weight type render text with this font weight",
3896 "-white-point point chromaticity white point",
3901 "-clone index clone an image",
3902 "-delete index delete the image from the image sequence",
3903 "-insert index insert last image into the image sequence",
3904 "-swap indexes swap two images in the image sequence",
3911 (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
3912 (void) printf("Copyright: %s\n",GetMagickCopyright());
3913 (void) printf("Features: %s\n\n",GetMagickFeatures());
3914 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3916 (void) printf("\nImage Settings:\n");
3917 for (p=settings; *p != (char *) NULL; p++)
3918 (void) printf(" %s\n",*p);
3919 (void) printf("\nImage Operators:\n");
3920 for (p=operators; *p != (char *) NULL; p++)
3921 (void) printf(" %s\n",*p);
3922 (void) printf("\nImage Sequence Operators:\n");
3923 for (p=sequence_operators; *p != (char *) NULL; p++)
3924 (void) printf(" %s\n",*p);
3925 (void) printf("\nImage Stack Operators:\n");
3926 for (p=stack_operators; *p != (char *) NULL; p++)
3927 (void) printf(" %s\n",*p);
3928 (void) printf("\nMiscellaneous Options:\n");
3929 for (p=miscellaneous; *p != (char *) NULL; p++)
3930 (void) printf(" %s\n",*p);
3932 "\nBy default, the image format of `file' is determined by its magic\n");
3934 "number. To specify a particular image format, precede the filename\n");
3936 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3938 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3939 (void) printf("'-' for standard input or output.\n");
3940 return(MagickFalse);
3943 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3944 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3946 #define DestroyMogrify() \
3948 if (format != (char *) NULL) \
3949 format=DestroyString(format); \
3950 if (path != (char *) NULL) \
3951 path=DestroyString(path); \
3952 DestroyImageStack(); \
3953 for (i=0; i < (long) argc; i++) \
3954 argv[i]=DestroyString(argv[i]); \
3955 argv=(char **) RelinquishMagickMemory(argv); \
3957 #define ThrowMogrifyException(asperity,tag,option) \
3959 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3962 return(MagickFalse); \
3964 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3966 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3967 "InvalidArgument","`%s': %s",argument,option); \
3969 return(MagickFalse); \
3981 image_stack[MaxImageStackDepth+1];
4003 assert(image_info != (ImageInfo *) NULL);
4004 assert(image_info->signature == MagickSignature);
4005 if (image_info->debug != MagickFalse)
4006 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
4007 assert(exception != (ExceptionInfo *) NULL);
4011 if ((LocaleCompare("version",option+1) == 0) ||
4012 (LocaleCompare("-version",option+1) == 0))
4014 (void) fprintf(stdout,"Version: %s\n",
4015 GetMagickVersion((unsigned long *) NULL));
4016 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
4017 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
4018 return(MagickFalse);
4022 return(MogrifyUsage());
4023 format=(char *) NULL;
4025 global_colormap=MagickFalse;
4029 option=(char *) NULL;
4035 ReadCommandlLine(argc,&argv);
4036 status=ExpandFilenames(&argc,&argv);
4037 if (status == MagickFalse)
4038 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4039 GetExceptionMessage(errno));
4040 for (i=1; i < (long) argc; i++)
4043 if (LocaleCompare(option,"(") == 0)
4045 FireImageStack(MagickFalse,MagickTrue,pend);
4046 if (k == MaxImageStackDepth)
4047 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4052 if (LocaleCompare(option,")") == 0)
4054 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4056 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4060 if (IsMagickOption(option) == MagickFalse)
4063 backup_filename[MaxTextExtent],
4070 Option is a file name: begin by reading image from specified file.
4072 FireImageStack(MagickFalse,MagickFalse,pend);
4074 if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
4076 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4077 images=ReadImages(image_info,exception);
4078 status&=(images != (Image *) NULL) &&
4079 (exception->severity < ErrorException);
4080 if (images == (Image *) NULL)
4082 if (path != (char *) NULL)
4084 GetPathComponent(option,TailPath,filename);
4085 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4086 path,*DirectorySeparator,filename);
4088 if (format != (char *) NULL)
4089 AppendImageFormat(format,images->filename);
4090 AppendImageStack(images);
4091 FinalizeImageSettings(image_info,image,MagickFalse);
4092 if (global_colormap != MagickFalse)
4097 quantize_info=AcquireQuantizeInfo(image_info);
4098 (void) RemapImages(quantize_info,images,(Image *) NULL);
4099 quantize_info=DestroyQuantizeInfo(quantize_info);
4101 *backup_filename='\0';
4102 if ((LocaleCompare(image->filename,"-") != 0) &&
4103 (IsPathWritable(image->filename) != MagickFalse))
4109 Rename image file as backup.
4111 (void) CopyMagickString(backup_filename,image->filename,
4113 for (i=0; i < 6; i++)
4115 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4116 if (IsPathAccessible(backup_filename) == MagickFalse)
4119 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4120 (rename(image->filename,backup_filename) != 0))
4121 *backup_filename='\0';
4124 Write transmogrified image to disk.
4126 image_info->synchronize=MagickTrue;
4127 status&=WriteImages(image_info,image,image->filename,exception);
4128 if ((status == MagickFalse) && (*backup_filename != '\0'))
4129 (void) remove(backup_filename);
4130 RemoveAllImageStack();
4133 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4134 switch (*(option+1))
4138 if (LocaleCompare("adaptive-blur",option+1) == 0)
4141 if (i == (long) argc)
4142 ThrowMogrifyException(OptionError,"MissingArgument",option);
4143 if (IsGeometry(argv[i]) == MagickFalse)
4144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4147 if (LocaleCompare("adaptive-resize",option+1) == 0)
4150 if (i == (long) argc)
4151 ThrowMogrifyException(OptionError,"MissingArgument",option);
4152 if (IsGeometry(argv[i]) == MagickFalse)
4153 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4156 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4159 if (i == (long) argc)
4160 ThrowMogrifyException(OptionError,"MissingArgument",option);
4161 if (IsGeometry(argv[i]) == MagickFalse)
4162 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4165 if (LocaleCompare("affine",option+1) == 0)
4170 if (i == (long) argc)
4171 ThrowMogrifyException(OptionError,"MissingArgument",option);
4172 if (IsGeometry(argv[i]) == MagickFalse)
4173 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4176 if (LocaleCompare("alpha",option+1) == 0)
4184 if (i == (long) argc)
4185 ThrowMogrifyException(OptionError,"MissingArgument",option);
4186 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4188 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4192 if (LocaleCompare("annotate",option+1) == 0)
4197 if (i == (long) argc)
4198 ThrowMogrifyException(OptionError,"MissingArgument",option);
4199 if (IsGeometry(argv[i]) == MagickFalse)
4200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4201 if (i == (long) argc)
4202 ThrowMogrifyException(OptionError,"MissingArgument",option);
4206 if (LocaleCompare("antialias",option+1) == 0)
4208 if (LocaleCompare("append",option+1) == 0)
4210 if (LocaleCompare("attenuate",option+1) == 0)
4215 if (i == (long) (argc-1))
4216 ThrowMogrifyException(OptionError,"MissingArgument",option);
4217 if (IsGeometry(argv[i]) == MagickFalse)
4218 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4221 if (LocaleCompare("authenticate",option+1) == 0)
4226 if (i == (long) argc)
4227 ThrowMogrifyException(OptionError,"MissingArgument",option);
4230 if (LocaleCompare("auto-gamma",option+1) == 0)
4232 if (LocaleCompare("auto-level",option+1) == 0)
4234 if (LocaleCompare("auto-orient",option+1) == 0)
4236 if (LocaleCompare("average",option+1) == 0)
4238 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4242 if (LocaleCompare("background",option+1) == 0)
4247 if (i == (long) argc)
4248 ThrowMogrifyException(OptionError,"MissingArgument",option);
4251 if (LocaleCompare("bias",option+1) == 0)
4256 if (i == (long) (argc-1))
4257 ThrowMogrifyException(OptionError,"MissingArgument",option);
4258 if (IsGeometry(argv[i]) == MagickFalse)
4259 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4262 if (LocaleCompare("black-point-compensation",option+1) == 0)
4264 if (LocaleCompare("black-threshold",option+1) == 0)
4269 if (i == (long) argc)
4270 ThrowMogrifyException(OptionError,"MissingArgument",option);
4271 if (IsGeometry(argv[i]) == MagickFalse)
4272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4275 if (LocaleCompare("blue-primary",option+1) == 0)
4280 if (i == (long) argc)
4281 ThrowMogrifyException(OptionError,"MissingArgument",option);
4282 if (IsGeometry(argv[i]) == MagickFalse)
4283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4286 if (LocaleCompare("blue-shift",option+1) == 0)
4289 if (i == (long) argc)
4290 ThrowMogrifyException(OptionError,"MissingArgument",option);
4291 if (IsGeometry(argv[i]) == MagickFalse)
4292 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4295 if (LocaleCompare("blur",option+1) == 0)
4298 if (i == (long) argc)
4299 ThrowMogrifyException(OptionError,"MissingArgument",option);
4300 if (IsGeometry(argv[i]) == MagickFalse)
4301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4304 if (LocaleCompare("border",option+1) == 0)
4309 if (i == (long) argc)
4310 ThrowMogrifyException(OptionError,"MissingArgument",option);
4311 if (IsGeometry(argv[i]) == MagickFalse)
4312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4315 if (LocaleCompare("bordercolor",option+1) == 0)
4320 if (i == (long) argc)
4321 ThrowMogrifyException(OptionError,"MissingArgument",option);
4324 if (LocaleCompare("box",option+1) == 0)
4329 if (i == (long) argc)
4330 ThrowMogrifyException(OptionError,"MissingArgument",option);
4333 if (LocaleCompare("brightness-contrast",option+1) == 0)
4336 if (i == (long) argc)
4337 ThrowMogrifyException(OptionError,"MissingArgument",option);
4338 if (IsGeometry(argv[i]) == MagickFalse)
4339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4342 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4346 if (LocaleCompare("cache",option+1) == 0)
4351 if (i == (long) argc)
4352 ThrowMogrifyException(OptionError,"MissingArgument",option);
4353 if (IsGeometry(argv[i]) == MagickFalse)
4354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4357 if (LocaleCompare("caption",option+1) == 0)
4362 if (i == (long) argc)
4363 ThrowMogrifyException(OptionError,"MissingArgument",option);
4366 if (LocaleCompare("channel",option+1) == 0)
4374 if (i == (long) (argc-1))
4375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4376 channel=ParseChannelOption(argv[i]);
4378 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4382 if (LocaleCompare("cdl",option+1) == 0)
4387 if (i == (long) (argc-1))
4388 ThrowMogrifyException(OptionError,"MissingArgument",option);
4391 if (LocaleCompare("charcoal",option+1) == 0)
4396 if (i == (long) argc)
4397 ThrowMogrifyException(OptionError,"MissingArgument",option);
4398 if (IsGeometry(argv[i]) == MagickFalse)
4399 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4402 if (LocaleCompare("chop",option+1) == 0)
4407 if (i == (long) argc)
4408 ThrowMogrifyException(OptionError,"MissingArgument",option);
4409 if (IsGeometry(argv[i]) == MagickFalse)
4410 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4413 if (LocaleCompare("clamp",option+1) == 0)
4415 if (LocaleCompare("clip",option+1) == 0)
4417 if (LocaleCompare("clip-mask",option+1) == 0)
4422 if (i == (long) argc)
4423 ThrowMogrifyException(OptionError,"MissingArgument",option);
4426 if (LocaleCompare("clut",option+1) == 0)
4428 if (LocaleCompare("coalesce",option+1) == 0)
4430 if (LocaleCompare("colorize",option+1) == 0)
4435 if (i == (long) argc)
4436 ThrowMogrifyException(OptionError,"MissingArgument",option);
4437 if (IsGeometry(argv[i]) == MagickFalse)
4438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4441 if (LocaleCompare("colors",option+1) == 0)
4446 if (i == (long) argc)
4447 ThrowMogrifyException(OptionError,"MissingArgument",option);
4448 if (IsGeometry(argv[i]) == MagickFalse)
4449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4452 if (LocaleCompare("colorspace",option+1) == 0)
4460 if (i == (long) argc)
4461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4465 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4469 if (LocaleCompare("combine",option+1) == 0)
4471 if (LocaleCompare("comment",option+1) == 0)
4476 if (i == (long) argc)
4477 ThrowMogrifyException(OptionError,"MissingArgument",option);
4480 if (LocaleCompare("composite",option+1) == 0)
4482 if (LocaleCompare("compress",option+1) == 0)
4490 if (i == (long) argc)
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4495 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4499 if (LocaleCompare("concurrent",option+1) == 0)
4501 if (LocaleCompare("contrast",option+1) == 0)
4503 if (LocaleCompare("contrast-stretch",option+1) == 0)
4506 if (i == (long) argc)
4507 ThrowMogrifyException(OptionError,"MissingArgument",option);
4508 if (IsGeometry(argv[i]) == MagickFalse)
4509 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4512 if (LocaleCompare("convolve",option+1) == 0)
4515 token[MaxTextExtent];
4520 if (i == (long) argc)
4521 ThrowMogrifyException(OptionError,"MissingArgument",option);
4523 if (IsGeometry(argv[i]) == MagickFalse)
4524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4526 /* Allow the use of built-in kernels like 'gaussian'
4527 * These may not work for kernels with 'nan' values, like 'diamond'
4529 GetMagickToken(argv[i],NULL,token);
4530 if ( isalpha((int)token[0]) )
4535 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
4537 ThrowMogrifyException(OptionError,"UnrecognizedKernelType",
4540 /* geometry current returns invalid if 'nan' values are used */
4541 else if (IsGeometry(argv[i]) == MagickFalse)
4542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4546 if (LocaleCompare("crop",option+1) == 0)
4551 if (i == (long) argc)
4552 ThrowMogrifyException(OptionError,"MissingArgument",option);
4553 if (IsGeometry(argv[i]) == MagickFalse)
4554 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4557 if (LocaleCompare("cycle",option+1) == 0)
4562 if (i == (long) argc)
4563 ThrowMogrifyException(OptionError,"MissingArgument",option);
4564 if (IsGeometry(argv[i]) == MagickFalse)
4565 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4568 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4572 if (LocaleCompare("decipher",option+1) == 0)
4577 if (i == (long) (argc-1))
4578 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (LocaleCompare("deconstruct",option+1) == 0)
4583 if (LocaleCompare("debug",option+1) == 0)
4591 if (i == (long) argc)
4592 ThrowMogrifyException(OptionError,"MissingArgument",option);
4593 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4595 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4597 (void) SetLogEventMask(argv[i]);
4600 if (LocaleCompare("define",option+1) == 0)
4603 if (i == (long) argc)
4604 ThrowMogrifyException(OptionError,"MissingArgument",option);
4610 define=GetImageOption(image_info,argv[i]);
4611 if (define == (const char *) NULL)
4612 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4617 if (LocaleCompare("delay",option+1) == 0)
4622 if (i == (long) argc)
4623 ThrowMogrifyException(OptionError,"MissingArgument",option);
4624 if (IsGeometry(argv[i]) == MagickFalse)
4625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4628 if (LocaleCompare("density",option+1) == 0)
4633 if (i == (long) argc)
4634 ThrowMogrifyException(OptionError,"MissingArgument",option);
4635 if (IsGeometry(argv[i]) == MagickFalse)
4636 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4639 if (LocaleCompare("depth",option+1) == 0)
4644 if (i == (long) argc)
4645 ThrowMogrifyException(OptionError,"MissingArgument",option);
4646 if (IsGeometry(argv[i]) == MagickFalse)
4647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4650 if (LocaleCompare("deskew",option+1) == 0)
4655 if (i == (long) argc)
4656 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 if (IsGeometry(argv[i]) == MagickFalse)
4658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4661 if (LocaleCompare("despeckle",option+1) == 0)
4663 if (LocaleCompare("dft",option+1) == 0)
4665 if (LocaleCompare("display",option+1) == 0)
4670 if (i == (long) argc)
4671 ThrowMogrifyException(OptionError,"MissingArgument",option);
4674 if (LocaleCompare("dispose",option+1) == 0)
4682 if (i == (long) argc)
4683 ThrowMogrifyException(OptionError,"MissingArgument",option);
4684 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4686 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4690 if (LocaleCompare("distort",option+1) == 0)
4696 if (i == (long) argc)
4697 ThrowMogrifyException(OptionError,"MissingArgument",option);
4698 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4700 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4703 if (i == (long) (argc-1))
4704 ThrowMogrifyException(OptionError,"MissingArgument",option);
4707 if (LocaleCompare("dither",option+1) == 0)
4715 if (i == (long) argc)
4716 ThrowMogrifyException(OptionError,"MissingArgument",option);
4717 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4719 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4723 if (LocaleCompare("draw",option+1) == 0)
4728 if (i == (long) argc)
4729 ThrowMogrifyException(OptionError,"MissingArgument",option);
4732 if (LocaleCompare("duration",option+1) == 0)
4737 if (i == (long) (argc-1))
4738 ThrowMogrifyException(OptionError,"MissingArgument",option);
4739 if (IsGeometry(argv[i]) == MagickFalse)
4740 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4743 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4747 if (LocaleCompare("edge",option+1) == 0)
4752 if (i == (long) argc)
4753 ThrowMogrifyException(OptionError,"MissingArgument",option);
4754 if (IsGeometry(argv[i]) == MagickFalse)
4755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4758 if (LocaleCompare("emboss",option+1) == 0)
4763 if (i == (long) argc)
4764 ThrowMogrifyException(OptionError,"MissingArgument",option);
4765 if (IsGeometry(argv[i]) == MagickFalse)
4766 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4769 if (LocaleCompare("encipher",option+1) == 0)
4774 if (i == (long) argc)
4775 ThrowMogrifyException(OptionError,"MissingArgument",option);
4778 if (LocaleCompare("encoding",option+1) == 0)
4783 if (i == (long) argc)
4784 ThrowMogrifyException(OptionError,"MissingArgument",option);
4787 if (LocaleCompare("endian",option+1) == 0)
4795 if (i == (long) argc)
4796 ThrowMogrifyException(OptionError,"MissingArgument",option);
4797 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4799 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4803 if (LocaleCompare("enhance",option+1) == 0)
4805 if (LocaleCompare("equalize",option+1) == 0)
4807 if (LocaleCompare("evaluate",option+1) == 0)
4815 if (i == (long) argc)
4816 ThrowMogrifyException(OptionError,"MissingArgument",option);
4817 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4819 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4822 if (i == (long) (argc-1))
4823 ThrowMogrifyException(OptionError,"MissingArgument",option);
4824 if (IsGeometry(argv[i]) == MagickFalse)
4825 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4828 if (LocaleCompare("extent",option+1) == 0)
4833 if (i == (long) argc)
4834 ThrowMogrifyException(OptionError,"MissingArgument",option);
4835 if (IsGeometry(argv[i]) == MagickFalse)
4836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4839 if (LocaleCompare("extract",option+1) == 0)
4844 if (i == (long) argc)
4845 ThrowMogrifyException(OptionError,"MissingArgument",option);
4846 if (IsGeometry(argv[i]) == MagickFalse)
4847 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4850 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4854 if (LocaleCompare("family",option+1) == 0)
4859 if (i == (long) (argc-1))
4860 ThrowMogrifyException(OptionError,"MissingArgument",option);
4863 if (LocaleCompare("fill",option+1) == 0)
4868 if (i == (long) argc)
4869 ThrowMogrifyException(OptionError,"MissingArgument",option);
4872 if (LocaleCompare("filter",option+1) == 0)
4880 if (i == (long) argc)
4881 ThrowMogrifyException(OptionError,"MissingArgument",option);
4882 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4884 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4888 if (LocaleCompare("flatten",option+1) == 0)
4890 if (LocaleCompare("flip",option+1) == 0)
4892 if (LocaleCompare("flop",option+1) == 0)
4894 if (LocaleCompare("floodfill",option+1) == 0)
4899 if (i == (long) argc)
4900 ThrowMogrifyException(OptionError,"MissingArgument",option);
4901 if (IsGeometry(argv[i]) == MagickFalse)
4902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4904 if (i == (long) argc)
4905 ThrowMogrifyException(OptionError,"MissingArgument",option);
4908 if (LocaleCompare("font",option+1) == 0)
4913 if (i == (long) argc)
4914 ThrowMogrifyException(OptionError,"MissingArgument",option);
4917 if (LocaleCompare("format",option+1) == 0)
4919 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4920 (void) CloneString(&format,(char *) NULL);
4924 if (i == (long) argc)
4925 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 (void) CloneString(&format,argv[i]);
4927 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4928 (void) ConcatenateMagickString(image_info->filename,":",
4930 (void) SetImageInfo(image_info,0,exception);
4931 if (*image_info->magick == '\0')
4932 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4936 if (LocaleCompare("frame",option+1) == 0)
4941 if (i == (long) argc)
4942 ThrowMogrifyException(OptionError,"MissingArgument",option);
4943 if (IsGeometry(argv[i]) == MagickFalse)
4944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4947 if (LocaleCompare("function",option+1) == 0)
4955 if (i == (long) argc)
4956 ThrowMogrifyException(OptionError,"MissingArgument",option);
4957 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
4959 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4961 if (i == (long) (argc-1))
4962 ThrowMogrifyException(OptionError,"MissingArgument",option);
4965 if (LocaleCompare("fuzz",option+1) == 0)
4970 if (i == (long) argc)
4971 ThrowMogrifyException(OptionError,"MissingArgument",option);
4972 if (IsGeometry(argv[i]) == MagickFalse)
4973 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4976 if (LocaleCompare("fx",option+1) == 0)
4981 if (i == (long) (argc-1))
4982 ThrowMogrifyException(OptionError,"MissingArgument",option);
4985 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4989 if (LocaleCompare("gamma",option+1) == 0)
4992 if (i == (long) argc)
4993 ThrowMogrifyException(OptionError,"MissingArgument",option);
4994 if (IsGeometry(argv[i]) == MagickFalse)
4995 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4998 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4999 (LocaleCompare("gaussian",option+1) == 0))
5002 if (i == (long) argc)
5003 ThrowMogrifyException(OptionError,"MissingArgument",option);
5004 if (IsGeometry(argv[i]) == MagickFalse)
5005 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5008 if (LocaleCompare("geometry",option+1) == 0)
5013 if (i == (long) argc)
5014 ThrowMogrifyException(OptionError,"MissingArgument",option);
5015 if (IsGeometry(argv[i]) == MagickFalse)
5016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5019 if (LocaleCompare("gravity",option+1) == 0)
5027 if (i == (long) argc)
5028 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5031 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5035 if (LocaleCompare("green-primary",option+1) == 0)
5040 if (i == (long) argc)
5041 ThrowMogrifyException(OptionError,"MissingArgument",option);
5042 if (IsGeometry(argv[i]) == MagickFalse)
5043 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5046 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5050 if (LocaleCompare("hald-clut",option+1) == 0)
5052 if ((LocaleCompare("help",option+1) == 0) ||
5053 (LocaleCompare("-help",option+1) == 0))
5054 return(MogrifyUsage());
5055 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5059 if (LocaleCompare("identify",option+1) == 0)
5061 if (LocaleCompare("idft",option+1) == 0)
5063 if (LocaleCompare("implode",option+1) == 0)
5068 if (i == (long) argc)
5069 ThrowMogrifyException(OptionError,"MissingArgument",option);
5070 if (IsGeometry(argv[i]) == MagickFalse)
5071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5074 if (LocaleCompare("intent",option+1) == 0)
5082 if (i == (long) (argc-1))
5083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5084 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5086 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5090 if (LocaleCompare("interlace",option+1) == 0)
5098 if (i == (long) argc)
5099 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5103 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5107 if (LocaleCompare("interline-spacing",option+1) == 0)
5112 if (i == (long) (argc-1))
5113 ThrowMogrifyException(OptionError,"MissingArgument",option);
5114 if (IsGeometry(argv[i]) == MagickFalse)
5115 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5118 if (LocaleCompare("interpolate",option+1) == 0)
5126 if (i == (long) argc)
5127 ThrowMogrifyException(OptionError,"MissingArgument",option);
5128 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5130 if (interpolate < 0)
5131 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5135 if (LocaleCompare("interword-spacing",option+1) == 0)
5140 if (i == (long) (argc-1))
5141 ThrowMogrifyException(OptionError,"MissingArgument",option);
5142 if (IsGeometry(argv[i]) == MagickFalse)
5143 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5146 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5150 if (LocaleCompare("kerning",option+1) == 0)
5155 if (i == (long) (argc-1))
5156 ThrowMogrifyException(OptionError,"MissingArgument",option);
5157 if (IsGeometry(argv[i]) == MagickFalse)
5158 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5161 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5165 if (LocaleCompare("label",option+1) == 0)
5170 if (i == (long) argc)
5171 ThrowMogrifyException(OptionError,"MissingArgument",option);
5174 if (LocaleCompare("lat",option+1) == 0)
5179 if (i == (long) argc)
5180 ThrowMogrifyException(OptionError,"MissingArgument",option);
5181 if (IsGeometry(argv[i]) == MagickFalse)
5182 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5184 if (LocaleCompare("layers",option+1) == 0)
5192 if (i == (long) (argc-1))
5193 ThrowMogrifyException(OptionError,"MissingArgument",option);
5194 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5196 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5200 if (LocaleCompare("level",option+1) == 0)
5203 if (i == (long) argc)
5204 ThrowMogrifyException(OptionError,"MissingArgument",option);
5205 if (IsGeometry(argv[i]) == MagickFalse)
5206 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5209 if (LocaleCompare("level-colors",option+1) == 0)
5212 if (i == (long) argc)
5213 ThrowMogrifyException(OptionError,"MissingArgument",option);
5216 if (LocaleCompare("linewidth",option+1) == 0)
5221 if (i == (long) argc)
5222 ThrowMogrifyException(OptionError,"MissingArgument",option);
5223 if (IsGeometry(argv[i]) == MagickFalse)
5224 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5227 if (LocaleCompare("limit",option+1) == 0)
5241 if (i == (long) argc)
5242 ThrowMogrifyException(OptionError,"MissingArgument",option);
5243 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5246 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5249 if (i == (long) argc)
5250 ThrowMogrifyException(OptionError,"MissingArgument",option);
5251 value=strtod(argv[i],&p);
5252 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5256 if (LocaleCompare("liquid-rescale",option+1) == 0)
5259 if (i == (long) argc)
5260 ThrowMogrifyException(OptionError,"MissingArgument",option);
5261 if (IsGeometry(argv[i]) == MagickFalse)
5262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5265 if (LocaleCompare("list",option+1) == 0)
5273 if (i == (long) argc)
5274 ThrowMogrifyException(OptionError,"MissingArgument",option);
5275 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5277 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5278 (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5282 if (LocaleCompare("log",option+1) == 0)
5287 if ((i == (long) argc) ||
5288 (strchr(argv[i],'%') == (char *) NULL))
5289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5292 if (LocaleCompare("loop",option+1) == 0)
5297 if (i == (long) argc)
5298 ThrowMogrifyException(OptionError,"MissingArgument",option);
5299 if (IsGeometry(argv[i]) == MagickFalse)
5300 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5303 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5307 if (LocaleCompare("map",option+1) == 0)
5309 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5313 if (i == (long) argc)
5314 ThrowMogrifyException(OptionError,"MissingArgument",option);
5317 if (LocaleCompare("mask",option+1) == 0)
5322 if (i == (long) argc)
5323 ThrowMogrifyException(OptionError,"MissingArgument",option);
5326 if (LocaleCompare("matte",option+1) == 0)
5328 if (LocaleCompare("mattecolor",option+1) == 0)
5333 if (i == (long) argc)
5334 ThrowMogrifyException(OptionError,"MissingArgument",option);
5337 if (LocaleCompare("modulate",option+1) == 0)
5342 if (i == (long) argc)
5343 ThrowMogrifyException(OptionError,"MissingArgument",option);
5344 if (IsGeometry(argv[i]) == MagickFalse)
5345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5348 if (LocaleCompare("median",option+1) == 0)
5353 if (i == (long) argc)
5354 ThrowMogrifyException(OptionError,"MissingArgument",option);
5355 if (IsGeometry(argv[i]) == MagickFalse)
5356 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5359 if (LocaleCompare("monitor",option+1) == 0)
5361 if (LocaleCompare("monochrome",option+1) == 0)
5363 if (LocaleCompare("morph",option+1) == 0)
5368 if (i == (long) (argc-1))
5369 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (IsGeometry(argv[i]) == MagickFalse)
5371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5374 if (LocaleCompare("morphology",option+1) == 0)
5380 token[MaxTextExtent];
5383 if (i == (long) argc)
5384 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 GetMagickToken(argv[i],NULL,token);
5386 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5388 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5391 if (i == (long) (argc-1))
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 GetMagickToken(argv[i],NULL,token);
5394 if ( isalpha((int)token[0]) )
5396 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
5398 ThrowMogrifyException(OptionError,"UnrecognizedKernelType",
5402 /* DO NOT ENABLE, geometry can not handle user defined kernels
5403 * which include 'nan' values, though '-' are acceptable.
5405 else if (IsGeometry(argv[i]) == MagickFalse)
5406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5410 if (LocaleCompare("mosaic",option+1) == 0)
5412 if (LocaleCompare("motion-blur",option+1) == 0)
5417 if (i == (long) argc)
5418 ThrowMogrifyException(OptionError,"MissingArgument",option);
5419 if (IsGeometry(argv[i]) == MagickFalse)
5420 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5423 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5427 if (LocaleCompare("negate",option+1) == 0)
5429 if (LocaleCompare("noise",option+1) == 0)
5432 if (i == (long) argc)
5433 ThrowMogrifyException(OptionError,"MissingArgument",option);
5439 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5441 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5445 if (IsGeometry(argv[i]) == MagickFalse)
5446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5449 if (LocaleCompare("noop",option+1) == 0)
5451 if (LocaleCompare("normalize",option+1) == 0)
5453 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5457 if (LocaleCompare("opaque",option+1) == 0)
5460 if (i == (long) argc)
5461 ThrowMogrifyException(OptionError,"MissingArgument",option);
5464 if (LocaleCompare("ordered-dither",option+1) == 0)
5469 if (i == (long) argc)
5470 ThrowMogrifyException(OptionError,"MissingArgument",option);
5473 if (LocaleCompare("orient",option+1) == 0)
5478 orientation=UndefinedOrientation;
5482 if (i == (long) (argc-1))
5483 ThrowMogrifyException(OptionError,"MissingArgument",option);
5484 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5486 if (orientation < 0)
5487 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5491 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5495 if (LocaleCompare("page",option+1) == 0)
5500 if (i == (long) argc)
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5504 if (LocaleCompare("paint",option+1) == 0)
5509 if (i == (long) argc)
5510 ThrowMogrifyException(OptionError,"MissingArgument",option);
5511 if (IsGeometry(argv[i]) == MagickFalse)
5512 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5515 if (LocaleCompare("path",option+1) == 0)
5517 (void) CloneString(&path,(char *) NULL);
5521 if (i == (long) argc)
5522 ThrowMogrifyException(OptionError,"MissingArgument",option);
5523 (void) CloneString(&path,argv[i]);
5526 if (LocaleCompare("pointsize",option+1) == 0)
5531 if (i == (long) argc)
5532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 if (IsGeometry(argv[i]) == MagickFalse)
5534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 if (LocaleCompare("polaroid",option+1) == 0)
5542 if (i == (long) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5544 if (IsGeometry(argv[i]) == MagickFalse)
5545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5548 if (LocaleCompare("posterize",option+1) == 0)
5553 if (i == (long) argc)
5554 ThrowMogrifyException(OptionError,"MissingArgument",option);
5555 if (IsGeometry(argv[i]) == MagickFalse)
5556 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5559 if (LocaleCompare("precision",option+1) == 0)
5564 if (i == (long) argc)
5565 ThrowMogrifyException(OptionError,"MissingArgument",option);
5566 if (IsGeometry(argv[i]) == MagickFalse)
5567 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5570 if (LocaleCompare("print",option+1) == 0)
5575 if (i == (long) argc)
5576 ThrowMogrifyException(OptionError,"MissingArgument",option);
5579 if (LocaleCompare("process",option+1) == 0)
5584 if (i == (long) (argc-1))
5585 ThrowMogrifyException(OptionError,"MissingArgument",option);
5588 if (LocaleCompare("profile",option+1) == 0)
5591 if (i == (long) argc)
5592 ThrowMogrifyException(OptionError,"MissingArgument",option);
5595 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5599 if (LocaleCompare("quality",option+1) == 0)
5604 if (i == (long) argc)
5605 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 if (IsGeometry(argv[i]) == MagickFalse)
5607 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5610 if (LocaleCompare("quantize",option+1) == 0)
5618 if (i == (long) (argc-1))
5619 ThrowMogrifyException(OptionError,"MissingArgument",option);
5620 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5623 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5627 if (LocaleCompare("quiet",option+1) == 0)
5629 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5633 if (LocaleCompare("radial-blur",option+1) == 0)
5636 if (i == (long) argc)
5637 ThrowMogrifyException(OptionError,"MissingArgument",option);
5638 if (IsGeometry(argv[i]) == MagickFalse)
5639 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleCompare("raise",option+1) == 0)
5645 if (i == (long) argc)
5646 ThrowMogrifyException(OptionError,"MissingArgument",option);
5647 if (IsGeometry(argv[i]) == MagickFalse)
5648 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5651 if (LocaleCompare("random-threshold",option+1) == 0)
5656 if (i == (long) argc)
5657 ThrowMogrifyException(OptionError,"MissingArgument",option);
5658 if (IsGeometry(argv[i]) == MagickFalse)
5659 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5662 if (LocaleCompare("red-primary",option+1) == 0)
5667 if (i == (long) argc)
5668 ThrowMogrifyException(OptionError,"MissingArgument",option);
5669 if (IsGeometry(argv[i]) == MagickFalse)
5670 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5672 if (LocaleCompare("region",option+1) == 0)
5677 if (i == (long) argc)
5678 ThrowMogrifyException(OptionError,"MissingArgument",option);
5679 if (IsGeometry(argv[i]) == MagickFalse)
5680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5683 if (LocaleCompare("render",option+1) == 0)
5685 if (LocaleCompare("repage",option+1) == 0)
5690 if (i == (long) argc)
5691 ThrowMogrifyException(OptionError,"MissingArgument",option);
5692 if (IsGeometry(argv[i]) == MagickFalse)
5693 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5696 if (LocaleCompare("resample",option+1) == 0)
5701 if (i == (long) argc)
5702 ThrowMogrifyException(OptionError,"MissingArgument",option);
5703 if (IsGeometry(argv[i]) == MagickFalse)
5704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5707 if (LocaleCompare("resize",option+1) == 0)
5712 if (i == (long) argc)
5713 ThrowMogrifyException(OptionError,"MissingArgument",option);
5714 if (IsGeometry(argv[i]) == MagickFalse)
5715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5718 if (LocaleCompare("reverse",option+1) == 0)
5720 if (LocaleCompare("roll",option+1) == 0)
5725 if (i == (long) argc)
5726 ThrowMogrifyException(OptionError,"MissingArgument",option);
5727 if (IsGeometry(argv[i]) == MagickFalse)
5728 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5731 if (LocaleCompare("rotate",option+1) == 0)
5734 if (i == (long) argc)
5735 ThrowMogrifyException(OptionError,"MissingArgument",option);
5736 if (IsGeometry(argv[i]) == MagickFalse)
5737 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5740 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5744 if (LocaleCompare("sample",option+1) == 0)
5749 if (i == (long) argc)
5750 ThrowMogrifyException(OptionError,"MissingArgument",option);
5751 if (IsGeometry(argv[i]) == MagickFalse)
5752 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5755 if (LocaleCompare("sampling-factor",option+1) == 0)
5760 if (i == (long) argc)
5761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5766 if (LocaleCompare("scale",option+1) == 0)
5771 if (i == (long) argc)
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 if (LocaleCompare("scene",option+1) == 0)
5782 if (i == (long) argc)
5783 ThrowMogrifyException(OptionError,"MissingArgument",option);
5784 if (IsGeometry(argv[i]) == MagickFalse)
5785 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5788 if (LocaleCompare("seed",option+1) == 0)
5793 if (i == (long) argc)
5794 ThrowMogrifyException(OptionError,"MissingArgument",option);
5795 if (IsGeometry(argv[i]) == MagickFalse)
5796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5799 if (LocaleCompare("segment",option+1) == 0)
5804 if (i == (long) argc)
5805 ThrowMogrifyException(OptionError,"MissingArgument",option);
5806 if (IsGeometry(argv[i]) == MagickFalse)
5807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5810 if (LocaleCompare("selective-blur",option+1) == 0)
5813 if (i == (long) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5815 if (IsGeometry(argv[i]) == MagickFalse)
5816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5819 if (LocaleCompare("separate",option+1) == 0)
5821 if (LocaleCompare("sepia-tone",option+1) == 0)
5826 if (i == (long) argc)
5827 ThrowMogrifyException(OptionError,"MissingArgument",option);
5828 if (IsGeometry(argv[i]) == MagickFalse)
5829 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5832 if (LocaleCompare("set",option+1) == 0)
5835 if (i == (long) argc)
5836 ThrowMogrifyException(OptionError,"MissingArgument",option);
5840 if (i == (long) argc)
5841 ThrowMogrifyException(OptionError,"MissingArgument",option);
5844 if (LocaleCompare("shade",option+1) == 0)
5847 if (i == (long) argc)
5848 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 if (LocaleCompare("shadow",option+1) == 0)
5858 if (i == (long) argc)
5859 ThrowMogrifyException(OptionError,"MissingArgument",option);
5860 if (IsGeometry(argv[i]) == MagickFalse)
5861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5864 if (LocaleCompare("sharpen",option+1) == 0)
5867 if (i == (long) argc)
5868 ThrowMogrifyException(OptionError,"MissingArgument",option);
5869 if (IsGeometry(argv[i]) == MagickFalse)
5870 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5873 if (LocaleCompare("shave",option+1) == 0)
5878 if (i == (long) argc)
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 if (IsGeometry(argv[i]) == MagickFalse)
5881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5884 if (LocaleCompare("shear",option+1) == 0)
5887 if (i == (long) argc)
5888 ThrowMogrifyException(OptionError,"MissingArgument",option);
5889 if (IsGeometry(argv[i]) == MagickFalse)
5890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5893 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5896 if (i == (long) (argc-1))
5897 ThrowMogrifyException(OptionError,"MissingArgument",option);
5898 if (IsGeometry(argv[i]) == MagickFalse)
5899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5902 if (LocaleCompare("size",option+1) == 0)
5907 if (i == (long) argc)
5908 ThrowMogrifyException(OptionError,"MissingArgument",option);
5909 if (IsGeometry(argv[i]) == MagickFalse)
5910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5913 if (LocaleCompare("sketch",option+1) == 0)
5918 if (i == (long) argc)
5919 ThrowMogrifyException(OptionError,"MissingArgument",option);
5920 if (IsGeometry(argv[i]) == MagickFalse)
5921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5924 if (LocaleCompare("solarize",option+1) == 0)
5929 if (i == (long) argc)
5930 ThrowMogrifyException(OptionError,"MissingArgument",option);
5931 if (IsGeometry(argv[i]) == MagickFalse)
5932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5935 if (LocaleCompare("sparse-color",option+1) == 0)
5941 if (i == (long) argc)
5942 ThrowMogrifyException(OptionError,"MissingArgument",option);
5943 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5945 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5948 if (i == (long) (argc-1))
5949 ThrowMogrifyException(OptionError,"MissingArgument",option);
5952 if (LocaleCompare("spread",option+1) == 0)
5957 if (i == (long) argc)
5958 ThrowMogrifyException(OptionError,"MissingArgument",option);
5959 if (IsGeometry(argv[i]) == MagickFalse)
5960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5963 if (LocaleCompare("stretch",option+1) == 0)
5971 if (i == (long) (argc-1))
5972 ThrowMogrifyException(OptionError,"MissingArgument",option);
5973 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
5975 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5979 if (LocaleCompare("strip",option+1) == 0)
5981 if (LocaleCompare("stroke",option+1) == 0)
5986 if (i == (long) argc)
5987 ThrowMogrifyException(OptionError,"MissingArgument",option);
5990 if (LocaleCompare("strokewidth",option+1) == 0)
5995 if (i == (long) argc)
5996 ThrowMogrifyException(OptionError,"MissingArgument",option);
5997 if (IsGeometry(argv[i]) == MagickFalse)
5998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6001 if (LocaleCompare("style",option+1) == 0)
6009 if (i == (long) (argc-1))
6010 ThrowMogrifyException(OptionError,"MissingArgument",option);
6011 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6013 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6017 if (LocaleCompare("swirl",option+1) == 0)
6022 if (i == (long) argc)
6023 ThrowMogrifyException(OptionError,"MissingArgument",option);
6024 if (IsGeometry(argv[i]) == MagickFalse)
6025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6028 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6032 if (LocaleCompare("taint",option+1) == 0)
6034 if (LocaleCompare("texture",option+1) == 0)
6039 if (i == (long) argc)
6040 ThrowMogrifyException(OptionError,"MissingArgument",option);
6043 if (LocaleCompare("tile",option+1) == 0)
6048 if (i == (long) (argc-1))
6049 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 if (LocaleCompare("tile-offset",option+1) == 0)
6057 if (i == (long) argc)
6058 ThrowMogrifyException(OptionError,"MissingArgument",option);
6059 if (IsGeometry(argv[i]) == MagickFalse)
6060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6063 if (LocaleCompare("tint",option+1) == 0)
6068 if (i == (long) (argc-1))
6069 ThrowMogrifyException(OptionError,"MissingArgument",option);
6070 if (IsGeometry(argv[i]) == MagickFalse)
6071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6074 if (LocaleCompare("transform",option+1) == 0)
6076 if (LocaleCompare("transpose",option+1) == 0)
6078 if (LocaleCompare("transverse",option+1) == 0)
6080 if (LocaleCompare("threshold",option+1) == 0)
6085 if (i == (long) argc)
6086 ThrowMogrifyException(OptionError,"MissingArgument",option);
6087 if (IsGeometry(argv[i]) == MagickFalse)
6088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6091 if (LocaleCompare("thumbnail",option+1) == 0)
6096 if (i == (long) argc)
6097 ThrowMogrifyException(OptionError,"MissingArgument",option);
6098 if (IsGeometry(argv[i]) == MagickFalse)
6099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6102 if (LocaleCompare("transparent",option+1) == 0)
6105 if (i == (long) argc)
6106 ThrowMogrifyException(OptionError,"MissingArgument",option);
6109 if (LocaleCompare("transparent-color",option+1) == 0)
6114 if (i == (long) (argc-1))
6115 ThrowMogrifyException(OptionError,"MissingArgument",option);
6118 if (LocaleCompare("treedepth",option+1) == 0)
6123 if (i == (long) argc)
6124 ThrowMogrifyException(OptionError,"MissingArgument",option);
6125 if (IsGeometry(argv[i]) == MagickFalse)
6126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6129 if (LocaleCompare("trim",option+1) == 0)
6131 if (LocaleCompare("type",option+1) == 0)
6139 if (i == (long) argc)
6140 ThrowMogrifyException(OptionError,"MissingArgument",option);
6141 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6143 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6147 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6151 if (LocaleCompare("undercolor",option+1) == 0)
6156 if (i == (long) argc)
6157 ThrowMogrifyException(OptionError,"MissingArgument",option);
6160 if (LocaleCompare("unique-colors",option+1) == 0)
6162 if (LocaleCompare("units",option+1) == 0)
6170 if (i == (long) argc)
6171 ThrowMogrifyException(OptionError,"MissingArgument",option);
6172 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6175 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6179 if (LocaleCompare("unsharp",option+1) == 0)
6182 if (i == (long) argc)
6183 ThrowMogrifyException(OptionError,"MissingArgument",option);
6184 if (IsGeometry(argv[i]) == MagickFalse)
6185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6188 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6192 if (LocaleCompare("verbose",option+1) == 0)
6194 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6197 if ((LocaleCompare("version",option+1) == 0) ||
6198 (LocaleCompare("-version",option+1) == 0))
6200 (void) fprintf(stdout,"Version: %s\n",
6201 GetMagickVersion((unsigned long *) NULL));
6202 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6203 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
6206 if (LocaleCompare("view",option+1) == 0)
6211 if (i == (long) argc)
6212 ThrowMogrifyException(OptionError,"MissingArgument",option);
6215 if (LocaleCompare("vignette",option+1) == 0)
6220 if (i == (long) argc)
6221 ThrowMogrifyException(OptionError,"MissingArgument",option);
6222 if (IsGeometry(argv[i]) == MagickFalse)
6223 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6226 if (LocaleCompare("virtual-pixel",option+1) == 0)
6234 if (i == (long) argc)
6235 ThrowMogrifyException(OptionError,"MissingArgument",option);
6236 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6239 ThrowMogrifyException(OptionError,
6240 "UnrecognizedVirtualPixelMethod",argv[i]);
6243 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6247 if (LocaleCompare("wave",option+1) == 0)
6250 if (i == (long) argc)
6251 ThrowMogrifyException(OptionError,"MissingArgument",option);
6252 if (IsGeometry(argv[i]) == MagickFalse)
6253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6256 if (LocaleCompare("weight",option+1) == 0)
6261 if (i == (long) (argc-1))
6262 ThrowMogrifyException(OptionError,"MissingArgument",option);
6265 if (LocaleCompare("white-point",option+1) == 0)
6270 if (i == (long) argc)
6271 ThrowMogrifyException(OptionError,"MissingArgument",option);
6272 if (IsGeometry(argv[i]) == MagickFalse)
6273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6276 if (LocaleCompare("white-threshold",option+1) == 0)
6281 if (i == (long) argc)
6282 ThrowMogrifyException(OptionError,"MissingArgument",option);
6283 if (IsGeometry(argv[i]) == MagickFalse)
6284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6287 if (LocaleCompare("write",option+1) == 0)
6290 if (i == (long) (argc-1))
6291 ThrowMogrifyException(OptionError,"MissingArgument",option);
6294 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6299 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6301 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6302 MagickFalse : MagickTrue;
6303 if (fire != MagickFalse)
6304 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6307 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6309 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6311 return(status != 0 ? MagickTrue : MagickFalse);
6315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6319 + M o g r i f y I m a g e I n f o %
6323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6325 % MogrifyImageInfo() applies image processing settings to the image as
6326 % prescribed by command line options.
6328 % The format of the MogrifyImageInfo method is:
6330 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6331 % const char **argv,ExceptionInfo *exception)
6333 % A description of each parameter follows:
6335 % o image_info: the image info..
6337 % o argc: Specifies a pointer to an integer describing the number of
6338 % elements in the argument vector.
6340 % o argv: Specifies a pointer to a text array containing the command line
6343 % o exception: return any errors or warnings in this structure.
6346 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6347 const int argc,const char **argv,ExceptionInfo *exception)
6362 Initialize method variables.
6364 assert(image_info != (ImageInfo *) NULL);
6365 assert(image_info->signature == MagickSignature);
6366 if (image_info->debug != MagickFalse)
6367 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6368 image_info->filename);
6372 Set the image settings.
6374 for (i=0; i < (long) argc; i++)
6377 if (IsMagickOption(option) == MagickFalse)
6379 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6381 if ((i+count) >= argc)
6383 switch (*(option+1))
6387 if (LocaleCompare("adjoin",option+1) == 0)
6389 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6392 if (LocaleCompare("antialias",option+1) == 0)
6394 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6397 if (LocaleCompare("attenuate",option+1) == 0)
6401 (void) DeleteImageOption(image_info,option+1);
6404 (void) SetImageOption(image_info,option+1,argv[i+1]);
6407 if (LocaleCompare("authenticate",option+1) == 0)
6410 (void) CloneString(&image_info->authenticate,(char *) NULL);
6412 (void) CloneString(&image_info->authenticate,argv[i+1]);
6419 if (LocaleCompare("background",option+1) == 0)
6423 (void) DeleteImageOption(image_info,option+1);
6424 (void) QueryColorDatabase(BackgroundColor,
6425 &image_info->background_color,exception);
6428 (void) SetImageOption(image_info,option+1,argv[i+1]);
6429 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6433 if (LocaleCompare("bias",option+1) == 0)
6437 (void) SetImageOption(image_info,option+1,"0.0");
6440 (void) SetImageOption(image_info,option+1,argv[i+1]);
6443 if (LocaleCompare("black-point-compensation",option+1) == 0)
6447 (void) SetImageOption(image_info,option+1,"false");
6450 (void) SetImageOption(image_info,option+1,"true");
6453 if (LocaleCompare("blue-primary",option+1) == 0)
6457 (void) SetImageOption(image_info,option+1,"0.0");
6460 (void) SetImageOption(image_info,option+1,argv[i+1]);
6463 if (LocaleCompare("bordercolor",option+1) == 0)
6467 (void) DeleteImageOption(image_info,option+1);
6468 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6472 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6474 (void) SetImageOption(image_info,option+1,argv[i+1]);
6477 if (LocaleCompare("box",option+1) == 0)
6481 (void) SetImageOption(image_info,"undercolor","none");
6484 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6491 if (LocaleCompare("cache",option+1) == 0)
6496 limit=MagickResourceInfinity;
6497 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6498 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6499 (void) SetMagickResourceLimit(MemoryResource,limit);
6500 (void) SetMagickResourceLimit(MapResource,2*limit);
6503 if (LocaleCompare("caption",option+1) == 0)
6507 (void) DeleteImageOption(image_info,option+1);
6510 (void) SetImageOption(image_info,option+1,argv[i+1]);
6513 if (LocaleCompare("channel",option+1) == 0)
6517 image_info->channel=DefaultChannels;
6520 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6523 if (LocaleCompare("colors",option+1) == 0)
6525 image_info->colors=StringToUnsignedLong(argv[i+1]);
6528 if (LocaleCompare("colorspace",option+1) == 0)
6532 image_info->colorspace=UndefinedColorspace;
6533 (void) SetImageOption(image_info,option+1,"undefined");
6536 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6537 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6538 (void) SetImageOption(image_info,option+1,argv[i+1]);
6541 if (LocaleCompare("compress",option+1) == 0)
6545 image_info->compression=UndefinedCompression;
6546 (void) SetImageOption(image_info,option+1,"undefined");
6549 image_info->compression=(CompressionType) ParseMagickOption(
6550 MagickCompressOptions,MagickFalse,argv[i+1]);
6551 (void) SetImageOption(image_info,option+1,argv[i+1]);
6554 if (LocaleCompare("comment",option+1) == 0)
6558 (void) DeleteImageOption(image_info,option+1);
6561 (void) SetImageOption(image_info,option+1,argv[i+1]);
6564 if (LocaleCompare("compose",option+1) == 0)
6568 (void) SetImageOption(image_info,option+1,"undefined");
6571 (void) SetImageOption(image_info,option+1,argv[i+1]);
6574 if (LocaleCompare("compress",option+1) == 0)
6578 image_info->compression=UndefinedCompression;
6579 (void) SetImageOption(image_info,option+1,"undefined");
6582 image_info->compression=(CompressionType) ParseMagickOption(
6583 MagickCompressOptions,MagickFalse,argv[i+1]);
6584 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 if (LocaleCompare("debug",option+1) == 0)
6594 (void) SetLogEventMask("none");
6596 (void) SetLogEventMask(argv[i+1]);
6597 image_info->debug=IsEventLogging();
6600 if (LocaleCompare("define",option+1) == 0)
6604 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6605 (void) DeleteImageRegistry(argv[i+1]+9);
6607 (void) DeleteImageOption(image_info,argv[i+1]);
6610 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6612 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6616 (void) DefineImageOption(image_info,argv[i+1]);
6619 if (LocaleCompare("delay",option+1) == 0)
6623 (void) SetImageOption(image_info,option+1,"0");
6626 (void) SetImageOption(image_info,option+1,argv[i+1]);
6629 if (LocaleCompare("density",option+1) == 0)
6636 if (image_info->density != (char *) NULL)
6637 image_info->density=DestroyString(image_info->density);
6638 (void) SetImageOption(image_info,option+1,"72");
6641 (void) CloneString(&image_info->density,argv[i+1]);
6642 (void) SetImageOption(image_info,option+1,argv[i+1]);
6645 if (LocaleCompare("depth",option+1) == 0)
6649 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6652 image_info->depth=StringToUnsignedLong(argv[i+1]);
6655 if (LocaleCompare("display",option+1) == 0)
6659 if (image_info->server_name != (char *) NULL)
6660 image_info->server_name=DestroyString(
6661 image_info->server_name);
6664 (void) CloneString(&image_info->server_name,argv[i+1]);
6667 if (LocaleCompare("dispose",option+1) == 0)
6671 (void) SetImageOption(image_info,option+1,"undefined");
6674 (void) SetImageOption(image_info,option+1,argv[i+1]);
6677 if (LocaleCompare("dither",option+1) == 0)
6681 image_info->dither=MagickFalse;
6682 (void) SetImageOption(image_info,option+1,"undefined");
6685 (void) SetImageOption(image_info,option+1,argv[i+1]);
6686 image_info->dither=MagickTrue;
6693 if (LocaleCompare("encoding",option+1) == 0)
6697 (void) SetImageOption(image_info,option+1,"undefined");
6700 (void) SetImageOption(image_info,option+1,argv[i+1]);
6703 if (LocaleCompare("endian",option+1) == 0)
6707 image_info->endian=UndefinedEndian;
6708 (void) SetImageOption(image_info,option+1,"undefined");
6711 image_info->endian=(EndianType) ParseMagickOption(
6712 MagickEndianOptions,MagickFalse,argv[i+1]);
6713 (void) SetImageOption(image_info,option+1,argv[i+1]);
6716 if (LocaleCompare("extract",option+1) == 0)
6719 Set image extract geometry.
6723 if (image_info->extract != (char *) NULL)
6724 image_info->extract=DestroyString(image_info->extract);
6727 (void) CloneString(&image_info->extract,argv[i+1]);
6734 if (LocaleCompare("fill",option+1) == 0)
6738 (void) SetImageOption(image_info,option+1,"none");
6741 (void) SetImageOption(image_info,option+1,argv[i+1]);
6744 if (LocaleCompare("filter",option+1) == 0)
6748 (void) SetImageOption(image_info,option+1,"undefined");
6751 (void) SetImageOption(image_info,option+1,argv[i+1]);
6754 if (LocaleCompare("font",option+1) == 0)
6758 if (image_info->font != (char *) NULL)
6759 image_info->font=DestroyString(image_info->font);
6762 (void) CloneString(&image_info->font,argv[i+1]);
6765 if (LocaleCompare("format",option+1) == 0)
6770 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6771 if (strchr("gkrz@[#",*(q+1)) != (char *) NULL)
6772 image_info->ping=MagickFalse;
6773 (void) SetImageOption(image_info,option+1,argv[i+1]);
6776 if (LocaleCompare("fuzz",option+1) == 0)
6780 image_info->fuzz=0.0;
6781 (void) SetImageOption(image_info,option+1,"0");
6784 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6786 (void) SetImageOption(image_info,option+1,argv[i+1]);
6793 if (LocaleCompare("gravity",option+1) == 0)
6797 (void) SetImageOption(image_info,option+1,"undefined");
6800 (void) SetImageOption(image_info,option+1,argv[i+1]);
6803 if (LocaleCompare("green-primary",option+1) == 0)
6807 (void) SetImageOption(image_info,option+1,"0.0");
6810 (void) SetImageOption(image_info,option+1,argv[i+1]);
6817 if (LocaleCompare("intent",option+1) == 0)
6821 (void) SetImageOption(image_info,option+1,"undefined");
6824 (void) SetImageOption(image_info,option+1,argv[i+1]);
6827 if (LocaleCompare("interlace",option+1) == 0)
6831 image_info->interlace=UndefinedInterlace;
6832 (void) SetImageOption(image_info,option+1,"undefined");
6835 image_info->interlace=(InterlaceType) ParseMagickOption(
6836 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6837 (void) SetImageOption(image_info,option+1,argv[i+1]);
6840 if (LocaleCompare("interline-spacing",option+1) == 0)
6844 (void) SetImageOption(image_info,option+1,"undefined");
6847 (void) SetImageOption(image_info,option+1,argv[i+1]);
6850 if (LocaleCompare("interpolate",option+1) == 0)
6854 (void) SetImageOption(image_info,option+1,"undefined");
6857 (void) SetImageOption(image_info,option+1,argv[i+1]);
6860 if (LocaleCompare("interword-spacing",option+1) == 0)
6864 (void) SetImageOption(image_info,option+1,"undefined");
6867 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 if (LocaleCompare("kerning",option+1) == 0)
6878 (void) SetImageOption(image_info,option+1,"undefined");
6881 (void) SetImageOption(image_info,option+1,argv[i+1]);
6888 if (LocaleCompare("label",option+1) == 0)
6892 (void) DeleteImageOption(image_info,option+1);
6895 (void) SetImageOption(image_info,option+1,argv[i+1]);
6898 if (LocaleCompare("limit",option+1) == 0)
6908 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
6909 MagickFalse,argv[i+1]);
6910 limit=MagickResourceInfinity;
6911 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6912 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6913 (void) SetMagickResourceLimit(type,limit);
6916 if (LocaleCompare("list",option+1) == 0)
6922 Display configuration list.
6924 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
6927 case MagickCoderOptions:
6929 (void) ListCoderInfo((FILE *) NULL,exception);
6932 case MagickColorOptions:
6934 (void) ListColorInfo((FILE *) NULL,exception);
6937 case MagickConfigureOptions:
6939 (void) ListConfigureInfo((FILE *) NULL,exception);
6942 case MagickDelegateOptions:
6944 (void) ListDelegateInfo((FILE *) NULL,exception);
6947 case MagickFontOptions:
6949 (void) ListTypeInfo((FILE *) NULL,exception);
6952 case MagickFormatOptions:
6954 (void) ListMagickInfo((FILE *) NULL,exception);
6957 case MagickLocaleOptions:
6959 (void) ListLocaleInfo((FILE *) NULL,exception);
6962 case MagickLogOptions:
6964 (void) ListLogInfo((FILE *) NULL,exception);
6967 case MagickMagicOptions:
6969 (void) ListMagicInfo((FILE *) NULL,exception);
6972 case MagickMimeOptions:
6974 (void) ListMimeInfo((FILE *) NULL,exception);
6977 case MagickModuleOptions:
6979 (void) ListModuleInfo((FILE *) NULL,exception);
6982 case MagickPolicyOptions:
6984 (void) ListPolicyInfo((FILE *) NULL,exception);
6987 case MagickResourceOptions:
6989 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6992 case MagickThresholdOptions:
6994 (void) ListThresholdMaps((FILE *) NULL,exception);
6999 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7005 if (LocaleCompare("log",option+1) == 0)
7009 (void) SetLogFormat(argv[i+1]);
7012 if (LocaleCompare("loop",option+1) == 0)
7016 (void) SetImageOption(image_info,option+1,"0");
7019 (void) SetImageOption(image_info,option+1,argv[i+1]);
7026 if (LocaleCompare("matte",option+1) == 0)
7030 (void) SetImageOption(image_info,option+1,"false");
7033 (void) SetImageOption(image_info,option+1,"true");
7036 if (LocaleCompare("mattecolor",option+1) == 0)
7040 (void) SetImageOption(image_info,option+1,argv[i+1]);
7041 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7045 (void) SetImageOption(image_info,option+1,argv[i+1]);
7046 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7050 if (LocaleCompare("monitor",option+1) == 0)
7052 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7056 if (LocaleCompare("monochrome",option+1) == 0)
7058 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7065 if (LocaleCompare("orient",option+1) == 0)
7069 image_info->orientation=UndefinedOrientation;
7070 (void) SetImageOption(image_info,option+1,"undefined");
7073 image_info->orientation=(OrientationType) ParseMagickOption(
7074 MagickOrientationOptions,MagickFalse,argv[i+1]);
7075 (void) SetImageOption(image_info,option+1,"undefined");
7081 if (LocaleCompare("page",option+1) == 0)
7085 page[MaxTextExtent];
7098 (void) DeleteImageOption(image_info,option+1);
7099 (void) CloneString(&image_info->page,(char *) NULL);
7102 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7103 image_option=GetImageOption(image_info,"page");
7104 if (image_option != (const char *) NULL)
7105 flags=ParseAbsoluteGeometry(image_option,&geometry);
7106 canonical_page=GetPageGeometry(argv[i+1]);
7107 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7108 canonical_page=DestroyString(canonical_page);
7109 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
7110 geometry.width,geometry.height);
7111 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7112 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7113 geometry.width,geometry.height,geometry.x,geometry.y);
7114 (void) SetImageOption(image_info,option+1,page);
7115 (void) CloneString(&image_info->page,page);
7118 if (LocaleCompare("pen",option+1) == 0)
7122 (void) SetImageOption(image_info,option+1,"none");
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7128 if (LocaleCompare("ping",option+1) == 0)
7130 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7133 if (LocaleCompare("pointsize",option+1) == 0)
7136 geometry_info.rho=0.0;
7138 (void) ParseGeometry(argv[i+1],&geometry_info);
7139 image_info->pointsize=geometry_info.rho;
7142 if (LocaleCompare("precision",option+1) == 0)
7144 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7147 if (LocaleCompare("preview",option+1) == 0)
7154 image_info->preview_type=UndefinedPreview;
7157 image_info->preview_type=(PreviewType) ParseMagickOption(
7158 MagickPreviewOptions,MagickFalse,argv[i+1]);
7165 if (LocaleCompare("quality",option+1) == 0)
7168 Set image compression quality.
7172 image_info->quality=UndefinedCompressionQuality;
7173 (void) SetImageOption(image_info,option+1,"0");
7176 image_info->quality=StringToUnsignedLong(argv[i+1]);
7177 (void) SetImageOption(image_info,option+1,argv[i+1]);
7180 if (LocaleCompare("quiet",option+1) == 0)
7182 static WarningHandler
7183 warning_handler = (WarningHandler) NULL;
7188 Restore error or warning messages.
7190 warning_handler=SetWarningHandler(warning_handler);
7194 Suppress error or warning messages.
7196 warning_handler=SetWarningHandler((WarningHandler) NULL);
7203 if (LocaleCompare("red-primary",option+1) == 0)
7207 (void) SetImageOption(image_info,option+1,"0.0");
7210 (void) SetImageOption(image_info,option+1,argv[i+1]);
7217 if (LocaleCompare("sampling-factor",option+1) == 0)
7220 Set image sampling factor.
7224 if (image_info->sampling_factor != (char *) NULL)
7225 image_info->sampling_factor=DestroyString(
7226 image_info->sampling_factor);
7229 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7232 if (LocaleCompare("scene",option+1) == 0)
7239 image_info->scene=0;
7240 (void) SetImageOption(image_info,option+1,"0");
7243 image_info->scene=StringToUnsignedLong(argv[i+1]);
7244 (void) SetImageOption(image_info,option+1,argv[i+1]);
7247 if (LocaleCompare("seed",option+1) == 0)
7254 seed=(unsigned long) time((time_t *) NULL);
7255 SeedPseudoRandomGenerator(seed);
7258 seed=StringToUnsignedLong(argv[i+1]);
7259 SeedPseudoRandomGenerator(seed);
7262 if (LocaleCompare("size",option+1) == 0)
7266 if (image_info->size != (char *) NULL)
7267 image_info->size=DestroyString(image_info->size);
7270 (void) CloneString(&image_info->size,argv[i+1]);
7273 if (LocaleCompare("stroke",option+1) == 0)
7277 (void) SetImageOption(image_info,option+1,"none");
7280 (void) SetImageOption(image_info,option+1,argv[i+1]);
7283 if (LocaleCompare("strokewidth",option+1) == 0)
7287 (void) SetImageOption(image_info,option+1,"0");
7290 (void) SetImageOption(image_info,option+1,argv[i+1]);
7297 if (LocaleCompare("taint",option+1) == 0)
7301 (void) SetImageOption(image_info,option+1,"false");
7304 (void) SetImageOption(image_info,option+1,"true");
7307 if (LocaleCompare("texture",option+1) == 0)
7311 if (image_info->texture != (char *) NULL)
7312 image_info->texture=DestroyString(image_info->texture);
7315 (void) CloneString(&image_info->texture,argv[i+1]);
7318 if (LocaleCompare("tile-offset",option+1) == 0)
7322 (void) SetImageOption(image_info,option+1,"0");
7325 (void) SetImageOption(image_info,option+1,argv[i+1]);
7328 if (LocaleCompare("transparent-color",option+1) == 0)
7332 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7333 (void) SetImageOption(image_info,option+1,"none");
7336 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7338 (void) SetImageOption(image_info,option+1,argv[i+1]);
7341 if (LocaleCompare("type",option+1) == 0)
7345 image_info->type=UndefinedType;
7346 (void) SetImageOption(image_info,option+1,"undefined");
7349 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7350 MagickFalse,argv[i+1]);
7351 (void) SetImageOption(image_info,option+1,argv[i+1]);
7358 if (LocaleCompare("undercolor",option+1) == 0)
7362 (void) DeleteImageOption(image_info,option+1);
7365 (void) SetImageOption(image_info,option+1,argv[i+1]);
7368 if (LocaleCompare("units",option+1) == 0)
7372 image_info->units=UndefinedResolution;
7373 (void) SetImageOption(image_info,option+1,"undefined");
7376 image_info->units=(ResolutionType) ParseMagickOption(
7377 MagickResolutionOptions,MagickFalse,argv[i+1]);
7378 (void) SetImageOption(image_info,option+1,argv[i+1]);
7385 if (LocaleCompare("verbose",option+1) == 0)
7389 image_info->verbose=MagickFalse;
7392 image_info->verbose=MagickTrue;
7393 image_info->ping=MagickFalse;
7396 if (LocaleCompare("view",option+1) == 0)
7400 if (image_info->view != (char *) NULL)
7401 image_info->view=DestroyString(image_info->view);
7404 (void) CloneString(&image_info->view,argv[i+1]);
7407 if (LocaleCompare("virtual-pixel",option+1) == 0)
7411 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7412 (void) SetImageOption(image_info,option+1,"undefined");
7415 image_info->virtual_pixel_method=(VirtualPixelMethod)
7416 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7418 (void) SetImageOption(image_info,option+1,argv[i+1]);
7425 if (LocaleCompare("white-point",option+1) == 0)
7429 (void) SetImageOption(image_info,option+1,"0.0");
7432 (void) SetImageOption(image_info,option+1,argv[i+1]);
7446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7450 + M o g r i f y I m a g e L i s t %
7454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7456 % MogrifyImageList() applies any command line options that might affect the
7457 % entire image list (e.g. -append, -coalesce, etc.).
7459 % The format of the MogrifyImage method is:
7461 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7462 % const char **argv,Image **images,ExceptionInfo *exception)
7464 % A description of each parameter follows:
7466 % o image_info: the image info..
7468 % o argc: Specifies a pointer to an integer describing the number of
7469 % elements in the argument vector.
7471 % o argv: Specifies a pointer to a text array containing the command line
7474 % o images: the images.
7476 % o exception: return any errors or warnings in this structure.
7479 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7480 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7502 Apply options to the image list.
7504 assert(image_info != (ImageInfo *) NULL);
7505 assert(image_info->signature == MagickSignature);
7506 assert(images != (Image **) NULL);
7507 assert((*images)->signature == MagickSignature);
7508 if ((*images)->debug != MagickFalse)
7509 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7510 (*images)->filename);
7511 if ((argc <= 0) || (*argv == (char *) NULL))
7513 quantize_info=AcquireQuantizeInfo(image_info);
7514 channel=image_info->channel;
7516 for (i=0; i < (long) argc; i++)
7518 if (*images == (Image *) NULL)
7521 if (IsMagickOption(option) == MagickFalse)
7523 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7525 if ((i+count) >= argc)
7527 status=MogrifyImageInfo(image_info,count+1,argv+i,exception);
7528 switch (*(option+1))
7532 if (LocaleCompare("affinity",option+1) == 0)
7534 (void) SyncImagesSettings(image_info,*images);
7537 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7538 InheritException(exception,&(*images)->exception);
7544 if (LocaleCompare("append",option+1) == 0)
7549 (void) SyncImagesSettings(image_info,*images);
7550 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7551 MagickFalse,exception);
7552 if (append_image == (Image *) NULL)
7557 *images=DestroyImageList(*images);
7558 *images=append_image;
7561 if (LocaleCompare("average",option+1) == 0)
7566 (void) SyncImagesSettings(image_info,*images);
7567 average_image=AverageImages(*images,exception);
7568 if (average_image == (Image *) NULL)
7573 *images=DestroyImageList(*images);
7574 *images=average_image;
7581 if (LocaleCompare("channel",option+1) == 0)
7585 channel=DefaultChannels;
7588 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7591 if (LocaleCompare("clut",option+1) == 0)
7597 (void) SyncImagesSettings(image_info,*images);
7598 image=RemoveFirstImageFromList(images);
7599 clut_image=RemoveFirstImageFromList(images);
7600 if (clut_image == (Image *) NULL)
7605 (void) ClutImageChannel(image,channel,clut_image);
7606 clut_image=DestroyImage(clut_image);
7607 InheritException(exception,&image->exception);
7608 *images=DestroyImageList(*images);
7612 if (LocaleCompare("coalesce",option+1) == 0)
7617 (void) SyncImagesSettings(image_info,*images);
7618 coalesce_image=CoalesceImages(*images,exception);
7619 if (coalesce_image == (Image *) NULL)
7624 *images=DestroyImageList(*images);
7625 *images=coalesce_image;
7628 if (LocaleCompare("combine",option+1) == 0)
7633 (void) SyncImagesSettings(image_info,*images);
7634 combine_image=CombineImages(*images,channel,exception);
7635 if (combine_image == (Image *) NULL)
7640 *images=DestroyImageList(*images);
7641 *images=combine_image;
7644 if (LocaleCompare("composite",option+1) == 0)
7654 (void) SyncImagesSettings(image_info,*images);
7655 image=RemoveFirstImageFromList(images);
7656 composite_image=RemoveFirstImageFromList(images);
7657 if (composite_image == (Image *) NULL)
7662 (void) TransformImage(&composite_image,(char *) NULL,
7663 composite_image->geometry);
7664 SetGeometry(composite_image,&geometry);
7665 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7666 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7668 mask_image=RemoveFirstImageFromList(images);
7669 if (mask_image != (Image *) NULL)
7671 if ((image->compose == DisplaceCompositeOp) ||
7672 (image->compose == DistortCompositeOp))
7675 Merge Y displacement into X displacement image.
7677 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7679 mask_image=DestroyImage(mask_image);
7684 Set a blending mask for the composition.
7686 image->mask=mask_image;
7687 (void) NegateImage(image->mask,MagickFalse);
7690 (void) CompositeImageChannel(image,channel,image->compose,
7691 composite_image,geometry.x,geometry.y);
7692 if (image->mask != (Image *) NULL)
7693 image->mask=DestroyImage(image->mask);
7694 composite_image=DestroyImage(composite_image);
7695 InheritException(exception,&image->exception);
7696 *images=DestroyImageList(*images);
7700 if (LocaleCompare("crop",option+1) == 0)
7708 (void) SyncImagesSettings(image_info,*images);
7709 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7710 if (((geometry.width == 0) && (geometry.height == 0)) ||
7711 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7713 (void) TransformImages(images,argv[i+1],(char *) NULL);
7714 InheritException(exception,&(*images)->exception);
7721 if (LocaleCompare("deconstruct",option+1) == 0)
7726 (void) SyncImagesSettings(image_info,*images);
7727 deconstruct_image=DeconstructImages(*images,exception);
7728 if (deconstruct_image == (Image *) NULL)
7733 *images=DestroyImageList(*images);
7734 *images=deconstruct_image;
7737 if (LocaleCompare("delete",option+1) == 0)
7740 DeleteImages(images,"-1",exception);
7742 DeleteImages(images,argv[i+1],exception);
7745 if (LocaleCompare("dither",option+1) == 0)
7749 quantize_info->dither=MagickFalse;
7752 quantize_info->dither=MagickTrue;
7753 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7754 MagickDitherOptions,MagickFalse,argv[i+1]);
7761 if (LocaleCompare("fft",option+1) == 0)
7767 Implements the discrete Fourier transform (DFT).
7769 (void) SyncImageSettings(image_info,*images);
7770 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7771 MagickTrue : MagickFalse,exception);
7772 if (fourier_image == (Image *) NULL)
7774 *images=DestroyImage(*images);
7775 *images=fourier_image;
7778 if (LocaleCompare("flatten",option+1) == 0)
7783 (void) SyncImagesSettings(image_info,*images);
7784 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7785 if (flatten_image == (Image *) NULL)
7787 *images=DestroyImageList(*images);
7788 *images=flatten_image;
7791 if (LocaleCompare("fx",option+1) == 0)
7796 (void) SyncImagesSettings(image_info,*images);
7797 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7798 if (fx_image == (Image *) NULL)
7803 *images=DestroyImageList(*images);
7811 if (LocaleCompare("hald-clut",option+1) == 0)
7817 (void) SyncImagesSettings(image_info,*images);
7818 image=RemoveFirstImageFromList(images);
7819 hald_image=RemoveFirstImageFromList(images);
7820 if (hald_image == (Image *) NULL)
7825 (void) HaldClutImageChannel(image,channel,hald_image);
7826 hald_image=DestroyImage(hald_image);
7827 InheritException(exception,&image->exception);
7828 if (*images != (Image *) NULL)
7829 *images=DestroyImageList(*images);
7837 if (LocaleCompare("ift",option+1) == 0)
7845 Implements the inverse fourier discrete Fourier transform (DFT).
7847 (void) SyncImagesSettings(image_info,*images);
7848 magnitude_image=RemoveFirstImageFromList(images);
7849 phase_image=RemoveFirstImageFromList(images);
7850 if (phase_image == (Image *) NULL)
7855 fourier_image=InverseFourierTransformImage(magnitude_image,
7856 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7857 if (fourier_image == (Image *) NULL)
7859 if (*images != (Image *) NULL)
7860 *images=DestroyImage(*images);
7861 *images=fourier_image;
7864 if (LocaleCompare("insert",option+1) == 0)
7872 index=StringToLong(argv[i+1]);
7873 p=RemoveLastImageFromList(images);
7874 if (p == (Image *) NULL)
7876 (void) ThrowMagickException(exception,GetMagickModule(),
7877 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7883 PrependImageToList(images,q);
7885 if (index == (long) GetImageListLength(*images))
7886 AppendImageToList(images,q);
7889 q=GetImageFromList(*images,index-1);
7890 if (q == (Image *) NULL)
7892 (void) ThrowMagickException(exception,GetMagickModule(),
7893 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7897 InsertImageInList(&q,p);
7899 *images=GetFirstImageInList(q);
7906 if (LocaleCompare("layers",option+1) == 0)
7914 (void) SyncImagesSettings(image_info,*images);
7915 layers=(Image *) NULL;
7916 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
7917 MagickFalse,argv[i+1]);
7922 layers=CoalesceImages(*images,exception);
7925 case CompareAnyLayer:
7926 case CompareClearLayer:
7927 case CompareOverlayLayer:
7930 layers=CompareImageLayers(*images,method,exception);
7936 case TrimBoundsLayer:
7938 layers=MergeImageLayers(*images,method,exception);
7943 layers=DisposeImages(*images,exception);
7946 case OptimizeImageLayer:
7948 layers=OptimizeImageLayers(*images,exception);
7951 case OptimizePlusLayer:
7953 layers=OptimizePlusImageLayers(*images,exception);
7956 case OptimizeTransLayer:
7958 OptimizeImageTransparency(*images,exception);
7961 case RemoveDupsLayer:
7963 RemoveDuplicateLayers(images,exception);
7966 case RemoveZeroLayer:
7968 RemoveZeroDelayLayers(images,exception);
7974 General Purpose, GIF Animation Optimizer.
7976 layers=CoalesceImages(*images,exception);
7977 if (layers == (Image *) NULL)
7982 InheritException(exception,&layers->exception);
7983 *images=DestroyImageList(*images);
7985 layers=OptimizeImageLayers(*images,exception);
7986 if (layers == (Image *) NULL)
7991 InheritException(exception,&layers->exception);
7992 *images=DestroyImageList(*images);
7994 layers=(Image *) NULL;
7995 OptimizeImageTransparency(*images,exception);
7996 InheritException(exception,&(*images)->exception);
7997 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8000 case CompositeLayer:
8012 Split image sequence at the first 'NULL:' image.
8015 while (source != (Image *) NULL)
8017 source=GetNextImageInList(source);
8018 if ((source != (Image *) NULL) &&
8019 (LocaleCompare(source->magick,"NULL") == 0))
8022 if (source != (Image *) NULL)
8024 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8025 (GetNextImageInList(source) == (Image *) NULL))
8026 source=(Image *) NULL;
8030 Separate the two lists, junk the null: image.
8032 source=SplitImageList(source->previous);
8033 DeleteImageFromList(&source);
8036 if (source == (Image *) NULL)
8038 (void) ThrowMagickException(exception,GetMagickModule(),
8039 OptionError,"MissingNullSeparator","layers Composite");
8044 Adjust offset with gravity and virtual canvas.
8046 SetGeometry(*images,&geometry);
8047 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8048 geometry.width=source->page.width != 0 ?
8049 source->page.width : source->columns;
8050 geometry.height=source->page.height != 0 ?
8051 source->page.height : source->rows;
8052 GravityAdjustGeometry((*images)->page.width != 0 ?
8053 (*images)->page.width : (*images)->columns,
8054 (*images)->page.height != 0 ? (*images)->page.height :
8055 (*images)->rows,(*images)->gravity,&geometry);
8056 compose=OverCompositeOp;
8057 option=GetImageOption(image_info,"compose");
8058 if (option != (const char *) NULL)
8059 compose=(CompositeOperator) ParseMagickOption(
8060 MagickComposeOptions,MagickFalse,option);
8061 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8063 source=DestroyImageList(source);
8067 if (layers == (Image *) NULL)
8069 InheritException(exception,&layers->exception);
8070 *images=DestroyImageList(*images);
8078 if (LocaleCompare("map",option+1) == 0)
8080 (void) SyncImagesSettings(image_info,*images);
8083 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8084 InheritException(exception,&(*images)->exception);
8090 if (LocaleCompare("morph",option+1) == 0)
8095 (void) SyncImagesSettings(image_info,*images);
8096 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8098 if (morph_image == (Image *) NULL)
8103 *images=DestroyImageList(*images);
8104 *images=morph_image;
8107 if (LocaleCompare("mosaic",option+1) == 0)
8112 (void) SyncImagesSettings(image_info,*images);
8113 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8114 if (mosaic_image == (Image *) NULL)
8119 *images=DestroyImageList(*images);
8120 *images=mosaic_image;
8127 if (LocaleCompare("print",option+1) == 0)
8132 (void) SyncImagesSettings(image_info,*images);
8133 string=InterpretImageProperties(image_info,*images,argv[i+1]);
8134 if (string == (char *) NULL)
8136 InheritException(exception,&(*images)->exception);
8137 (void) fprintf(stdout,"%s",string);
8138 string=DestroyString(string);
8140 if (LocaleCompare("process",option+1) == 0)
8149 (void) SyncImagesSettings(image_info,*images);
8150 arguments=StringToArgv(argv[i+1],&number_arguments);
8151 if (arguments == (char **) NULL)
8153 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8174 Support old style syntax, filter="-option arg".
8176 length=strlen(argv[i+1]);
8177 token=(char *) NULL;
8178 if (~length >= MaxTextExtent)
8179 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8181 if (token == (char *) NULL)
8184 arguments=argv[i+1];
8185 token_info=AcquireTokenInfo();
8186 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8187 "\"",'\0',&breaker,&next,"e);
8188 token_info=DestroyTokenInfo(token_info);
8194 argv=(&(arguments[next]));
8195 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8198 token=DestroyString(token);
8201 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8202 number_arguments-2,(const char **) arguments+2,exception);
8203 for (j=0; j < number_arguments; j++)
8204 arguments[j]=DestroyString(arguments[j]);
8205 arguments=(char **) RelinquishMagickMemory(arguments);
8212 if (LocaleCompare("reverse",option+1) == 0)
8214 ReverseImageList(images);
8215 InheritException(exception,&(*images)->exception);
8222 if (LocaleCompare("swap",option+1) == 0)
8243 flags=ParseGeometry(argv[i+1],&geometry_info);
8244 index=(long) geometry_info.rho;
8245 if ((flags & SigmaValue) != 0)
8246 swap_index=(long) geometry_info.sigma;
8248 p=GetImageFromList(*images,index);
8249 q=GetImageFromList(*images,swap_index);
8250 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8252 (void) ThrowMagickException(exception,GetMagickModule(),
8253 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8259 swap=CloneImage(p,0,0,MagickTrue,exception);
8260 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8261 ReplaceImageInList(&q,swap);
8262 *images=GetFirstImageInList(q);
8269 if (LocaleCompare("write",option+1) == 0)
8277 (void) SyncImagesSettings(image_info,*images);
8278 write_images=(*images);
8280 write_images=CloneImageList(*images,exception);
8281 write_info=CloneImageInfo(image_info);
8282 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8283 write_info=DestroyImageInfo(write_info);
8285 write_images=DestroyImageList(write_images);
8295 quantize_info=DestroyQuantizeInfo(quantize_info);
8296 return(status != 0 ? MagickTrue : MagickFalse);
8300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8304 + M o g r i f y I m a g e s %
8308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8310 % MogrifyImages() applies image processing options to a sequence of images as
8311 % prescribed by command line options.
8313 % The format of the MogrifyImage method is:
8315 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8316 % const MagickBooleanType post,const int argc,const char **argv,
8317 % Image **images,Exceptioninfo *exception)
8319 % A description of each parameter follows:
8321 % o image_info: the image info..
8323 % o post: If true, post process image list operators otherwise pre-process.
8325 % o argc: Specifies a pointer to an integer describing the number of
8326 % elements in the argument vector.
8328 % o argv: Specifies a pointer to a text array containing the command line
8331 % o images: the images.
8333 % o exception: return any errors or warnings in this structure.
8336 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8337 const MagickBooleanType post,const int argc,const char **argv,
8338 Image **images,ExceptionInfo *exception)
8340 #define MogrifyImageTag "Mogrify/Image"
8359 Apply options to individual images in the list.
8361 assert(image_info != (ImageInfo *) NULL);
8362 assert(image_info->signature == MagickSignature);
8363 if (images == (Image **) NULL)
8364 return(MogrifyImage(image_info,argc,argv,images,exception));
8365 assert((*images)->signature == MagickSignature);
8366 if ((*images)->debug != MagickFalse)
8367 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8368 (*images)->filename);
8369 if ((argc <= 0) || (*argv == (char *) NULL))
8371 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8373 mogrify_images=NewImageList();
8374 number_images=GetImageListLength(*images);
8376 if (post == MagickFalse)
8377 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8378 for (i=0; i < (long) number_images; i++)
8380 image=RemoveFirstImageFromList(images);
8381 if (image == (Image *) NULL)
8383 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8384 AppendImageToList(&mogrify_images,image);
8385 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8387 if (proceed == MagickFalse)
8390 if (post != MagickFalse)
8391 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8392 *images=mogrify_images;
8393 return(status != 0 ? MagickTrue : MagickFalse);