2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
13 % MagickWand Module Methods %
20 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "wand/studio.h"
48 #include "wand/MagickWand.h"
49 #include "wand/mogrify-private.h"
50 #include "magick/monitor-private.h"
51 #include "magick/thread-private.h"
52 #include "magick/string-private.h"
57 #define UndefinedCompressionQuality 0UL
63 BackgroundColor[] = "#fff", /* white */
64 BorderColor[] = "#dfdfdf", /* gray */
65 MatteColor[] = "#bdbdbd"; /* gray */
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 + M a g i c k C o m m a n d G e n e s i s %
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 % MagickCommandGenesis() applies image processing options to an image as
79 % prescribed by command line options.
81 % The format of the MagickCommandGenesis method is:
83 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
84 % MagickCommand command,const int argc,const char **argv,Image **image)
86 % A description of each parameter follows:
88 % o image_info: the image info.
90 % o command: the magick command.
92 % o argc: Specifies a pointer to an integer describing the number of
93 % elements in the argument vector.
95 % o argv: Specifies a pointer to a text array containing the command line
100 % o exception: return any errors or warnings in this structure.
103 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
104 MagickCommand command,int argc,char **argv,char **metadata,
105 ExceptionInfo *exception)
129 (void) setlocale(LC_ALL,"");
130 (void) setlocale(LC_NUMERIC,"C");
131 concurrent=MagickFalse;
135 regard_warnings=MagickFalse;
136 for (i=1; i < (ssize_t) (argc-1); i++)
139 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
141 if (LocaleCompare("bench",option+1) == 0)
142 iterations=StringToUnsignedLong(argv[++i]);
143 if (LocaleCompare("concurrent",option+1) == 0)
144 concurrent=MagickTrue;
145 if (LocaleCompare("debug",option+1) == 0)
146 (void) SetLogEventMask(argv[++i]);
147 if (LocaleCompare("duration",option+1) == 0)
148 duration=StringToDouble(argv[++i]);
149 if (LocaleCompare("regard-warnings",option+1) == 0)
150 regard_warnings=MagickTrue;
152 timer=AcquireTimerInfo();
153 if (concurrent == MagickFalse)
155 for (i=0; i < (ssize_t) iterations; i++)
157 if (status != MagickFalse)
161 if (GetElapsedTime(timer) > duration)
163 (void) ContinueTimer(timer);
165 status=command(image_info,argc,argv,metadata,exception);
166 if (exception->severity != UndefinedException)
168 if ((exception->severity > ErrorException) ||
169 (regard_warnings != MagickFalse))
171 CatchException(exception);
173 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
175 (void) fputs(*metadata,stdout);
176 (void) fputc('\n',stdout);
177 *metadata=DestroyString(*metadata);
184 #if defined(MAGICKCORE_OPENMP_SUPPORT)
185 # pragma omp parallel for shared(status)
187 for (i=0; i < (ssize_t) iterations; i++)
189 if (status != MagickFalse)
193 if (GetElapsedTime(timer) > duration)
195 (void) ContinueTimer(timer);
197 status=command(image_info,argc,argv,metadata,exception);
198 #if defined(MAGICKCORE_OPENMP_SUPPORT)
199 # pragma omp critical (MagickCore_Launch_Command)
202 if (exception->severity != UndefinedException)
204 if ((exception->severity > ErrorException) ||
205 (regard_warnings != MagickFalse))
207 CatchException(exception);
209 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
211 (void) fputs(*metadata,stdout);
212 (void) fputc('\n',stdout);
213 *metadata=DestroyString(*metadata);
220 elapsed_time=GetElapsedTime(timer);
221 user_time=GetUserTime(timer);
222 (void) fprintf(stderr,
223 "Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",(unsigned long)
224 iterations,1.0*iterations/elapsed_time,user_time,(long)
225 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
226 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
228 timer=DestroyTimerInfo(timer);
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 + M o g r i f y I m a g e %
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % MogrifyImage() applies image processing options to an image as prescribed
244 % by command line options.
246 % The format of the MogrifyImage method is:
248 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
249 % const char **argv,Image **image)
251 % A description of each parameter follows:
253 % o image_info: the image info..
255 % o argc: Specifies a pointer to an integer describing the number of
256 % elements in the argument vector.
258 % o argv: Specifies a pointer to a text array containing the command line
261 % o image: the image.
263 % o exception: return any errors or warnings in this structure.
267 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
268 ExceptionInfo *exception)
282 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
283 sans_exception=AcquireExceptionInfo();
284 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
285 sans_exception=DestroyExceptionInfo(sans_exception);
286 if (image != (Image *) NULL)
288 read_info=CloneImageInfo(image_info);
289 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
290 image=ReadImage(read_info,exception);
291 read_info=DestroyImageInfo(read_info);
292 if (image != (Image *) NULL)
293 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
297 static MagickBooleanType IsPathWritable(const char *path)
299 if (IsPathAccessible(path) == MagickFalse)
301 if (access(path,W_OK) != 0)
306 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
313 static MagickBooleanType MonitorProgress(const char *text,
314 const MagickOffsetType offset,const MagickSizeType extent,
315 void *wand_unused(client_data))
318 message[MaxTextExtent],
329 (void) CopyMagickMemory(tag,text,MaxTextExtent);
331 if (p != (char *) NULL)
333 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
334 locale_message=GetLocaleMessage(message);
335 if (locale_message == message)
337 if (p == (char *) NULL)
338 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
339 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
341 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
342 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
343 (100L*offset/(extent-1)));
344 if (offset == (MagickOffsetType) (extent-1))
345 (void) fprintf(stderr,"\n");
346 (void) fflush(stderr);
350 static Image *SparseColorOption(const Image *image,const ChannelType channel,
351 const SparseColorMethod method,const char *arguments,
352 const MagickBooleanType color_from_image,ExceptionInfo *exception)
358 token[MaxTextExtent];
384 assert(image != (Image *) NULL);
385 assert(image->signature == MagickSignature);
386 if (image->debug != MagickFalse)
387 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
388 assert(exception != (ExceptionInfo *) NULL);
389 assert(exception->signature == MagickSignature);
391 Limit channels according to image - and add up number of color channel.
394 if (image->colorspace != CMYKColorspace)
395 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
396 if (image->matte == MagickFalse)
397 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
399 if ((channels & RedChannel) != 0)
401 if ((channels & GreenChannel) != 0)
403 if ((channels & BlueChannel) != 0)
405 if ((channels & IndexChannel) != 0)
407 if ((channels & OpacityChannel) != 0)
410 Read string, to determine number of arguments needed,
416 GetMagickToken(p,&p,token);
417 if ( token[0] == ',' ) continue;
418 if ( isalpha((int) token[0]) || token[0] == '#' ) {
419 if ( color_from_image ) {
420 (void) ThrowMagickException(exception,GetMagickModule(),
421 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
422 "Color arg given, when colors are coming from image");
423 return( (Image *)NULL);
425 x += number_colors; /* color argument */
428 x++; /* floating point argument */
432 if ( color_from_image ) {
433 /* just the control points are being given */
434 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
435 number_arguments=(x/2)*(2+number_colors);
438 /* control points and color values */
439 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
443 (void) ThrowMagickException(exception,GetMagickModule(),
444 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
445 "Invalid number of Arguments");
446 return( (Image *)NULL);
449 /* Allocate and fill in the floating point arguments */
450 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
451 sizeof(*sparse_arguments));
452 if (sparse_arguments == (double *) NULL) {
453 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
454 "MemoryAllocationFailed","%s","SparseColorOption");
455 return( (Image *)NULL);
457 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
458 sizeof(*sparse_arguments));
461 while( *p != '\0' && x < number_arguments ) {
463 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
464 if ( token[0] == '\0' ) break;
465 if ( isalpha((int) token[0]) || token[0] == '#' ) {
466 (void) ThrowMagickException(exception,GetMagickModule(),
467 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
468 "Color found, instead of X-coord");
472 sparse_arguments[x++]=StringToDouble(token);
474 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
475 if ( token[0] == '\0' ) break;
476 if ( isalpha((int) token[0]) || token[0] == '#' ) {
477 (void) ThrowMagickException(exception,GetMagickModule(),
478 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
479 "Color found, instead of Y-coord");
483 sparse_arguments[x++]=StringToDouble(token);
484 /* color values for this control point */
486 if ( (color_from_image ) {
487 /* get color from image */
493 /* color name or function given in string argument */
494 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
495 if ( token[0] == '\0' ) break;
496 if ( isalpha((int) token[0]) || token[0] == '#' ) {
497 /* Color string given */
498 (void) QueryMagickColor(token,&color,exception);
499 if ( channels & RedChannel )
500 sparse_arguments[x++] = QuantumScale*color.red;
501 if ( channels & GreenChannel )
502 sparse_arguments[x++] = QuantumScale*color.green;
503 if ( channels & BlueChannel )
504 sparse_arguments[x++] = QuantumScale*color.blue;
505 if ( channels & IndexChannel )
506 sparse_arguments[x++] = QuantumScale*color.index;
507 if ( channels & OpacityChannel )
508 sparse_arguments[x++] = QuantumScale*color.opacity;
512 /* the color name/function/value was not found - error */
515 /* Colors given as a set of floating point values - experimental */
516 /* NB: token contains the first floating point value to use! */
517 if ( channels & RedChannel ) {
518 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
519 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
521 sparse_arguments[x++]=StringToDouble(token);
522 token[0] = ','; /* used this token - get another */
524 if ( channels & GreenChannel ) {
525 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
526 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
528 sparse_arguments[x++]=StringToDouble(token);
529 token[0] = ','; /* used this token - get another */
531 if ( channels & BlueChannel ) {
532 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
533 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
535 sparse_arguments[x++]=StringToDouble(token);
536 token[0] = ','; /* used this token - get another */
538 if ( channels & IndexChannel ) {
539 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
540 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
542 sparse_arguments[x++]=StringToDouble(token);
543 token[0] = ','; /* used this token - get another */
545 if ( channels & OpacityChannel ) {
546 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
547 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
549 sparse_arguments[x++]=StringToDouble(token);
550 token[0] = ','; /* used this token - get another */
556 if ( number_arguments != x && !error ) {
557 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
558 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
559 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
560 return( (Image *)NULL);
563 return( (Image *)NULL);
565 /* Call the Interpolation function with the parsed arguments */
566 sparse_image=SparseColorImage(image,channels,method,number_arguments,
567 sparse_arguments,exception);
568 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
569 return( sparse_image );
572 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
573 const char **argv,Image **image,ExceptionInfo *exception)
614 Initialize method variables.
616 assert(image_info != (const ImageInfo *) NULL);
617 assert(image_info->signature == MagickSignature);
618 assert(image != (Image **) NULL);
619 assert((*image)->signature == MagickSignature);
620 if ((*image)->debug != MagickFalse)
621 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
624 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
625 quantize_info=AcquireQuantizeInfo(image_info);
626 SetGeometryInfo(&geometry_info);
627 GetMagickPixelPacket(*image,&fill);
628 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
630 channel=image_info->channel;
631 format=GetImageOption(image_info,"format");
632 SetGeometry(*image,®ion_geometry);
633 region_image=NewImageList();
635 Transmogrify the image.
637 for (i=0; i < (ssize_t) argc; i++)
640 if (IsMagickOption(option) == MagickFalse)
642 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
644 if ((i+count) >= (ssize_t) argc)
646 status=MogrifyImageInfo(image_info,(int) count+1,argv+i,exception);
651 if (LocaleCompare("adaptive-blur",option+1) == 0)
659 (void) SyncImageSettings(image_info,*image);
660 flags=ParseGeometry(argv[i+1],&geometry_info);
661 if ((flags & SigmaValue) == 0)
662 geometry_info.sigma=1.0;
663 blur_image=AdaptiveBlurImageChannel(*image,channel,
664 geometry_info.rho,geometry_info.sigma,exception);
665 if (blur_image == (Image *) NULL)
667 *image=DestroyImage(*image);
671 if (LocaleCompare("adaptive-resize",option+1) == 0)
677 Adaptive resize image.
679 (void) SyncImageSettings(image_info,*image);
680 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
681 resize_image=AdaptiveResizeImage(*image,geometry.width,
682 geometry.height,exception);
683 if (resize_image == (Image *) NULL)
685 *image=DestroyImage(*image);
689 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
695 Adaptive sharpen image.
697 (void) SyncImageSettings(image_info,*image);
698 flags=ParseGeometry(argv[i+1],&geometry_info);
699 if ((flags & SigmaValue) == 0)
700 geometry_info.sigma=1.0;
701 sharp_image=AdaptiveSharpenImageChannel(*image,channel,
702 geometry_info.rho,geometry_info.sigma,exception);
703 if (sharp_image == (Image *) NULL)
705 *image=DestroyImage(*image);
709 if (LocaleCompare("affine",option+1) == 0)
716 GetAffineMatrix(&draw_info->affine);
719 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
722 if (LocaleCompare("alpha",option+1) == 0)
727 (void) SyncImageSettings(image_info,*image);
728 alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
729 MagickFalse,argv[i+1]);
730 (void) SetImageAlphaChannel(*image,alpha_type);
731 InheritException(exception,&(*image)->exception);
734 if (LocaleCompare("annotate",option+1) == 0)
738 geometry[MaxTextExtent];
743 (void) SyncImageSettings(image_info,*image);
744 SetGeometryInfo(&geometry_info);
745 flags=ParseGeometry(argv[i+1],&geometry_info);
746 if ((flags & SigmaValue) == 0)
747 geometry_info.sigma=geometry_info.rho;
748 text=InterpretImageProperties(image_info,*image,argv[i+2]);
749 InheritException(exception,&(*image)->exception);
750 if (text == (char *) NULL)
752 (void) CloneString(&draw_info->text,text);
753 text=DestroyString(text);
754 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
755 geometry_info.xi,geometry_info.psi);
756 (void) CloneString(&draw_info->geometry,geometry);
757 draw_info->affine.sx=cos(DegreesToRadians(
758 fmod(geometry_info.rho,360.0)));
759 draw_info->affine.rx=sin(DegreesToRadians(
760 fmod(geometry_info.rho,360.0)));
761 draw_info->affine.ry=(-sin(DegreesToRadians(
762 fmod(geometry_info.sigma,360.0))));
763 draw_info->affine.sy=cos(DegreesToRadians(
764 fmod(geometry_info.sigma,360.0)));
765 (void) AnnotateImage(*image,draw_info);
766 InheritException(exception,&(*image)->exception);
769 if (LocaleCompare("antialias",option+1) == 0)
771 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
773 draw_info->text_antialias=(*option == '-') ? MagickTrue :
777 if (LocaleCompare("auto-gamma",option+1) == 0)
780 Auto Adjust Gamma of image based on its mean
782 (void) SyncImageSettings(image_info,*image);
783 (void) AutoGammaImageChannel(*image,channel);
786 if (LocaleCompare("auto-level",option+1) == 0)
789 Perfectly Normalize (max/min stretch) the image
791 (void) SyncImageSettings(image_info,*image);
792 (void) AutoLevelImageChannel(*image,channel);
795 if (LocaleCompare("auto-orient",option+1) == 0)
800 (void) SyncImageSettings(image_info,*image);
801 orient_image=NewImageList();
802 switch ((*image)->orientation)
804 case TopRightOrientation:
806 orient_image=FlopImage(*image,exception);
809 case BottomRightOrientation:
811 orient_image=RotateImage(*image,180.0,exception);
814 case BottomLeftOrientation:
816 orient_image=FlipImage(*image,exception);
819 case LeftTopOrientation:
821 orient_image=TransposeImage(*image,exception);
824 case RightTopOrientation:
826 orient_image=RotateImage(*image,90.0,exception);
829 case RightBottomOrientation:
831 orient_image=TransverseImage(*image,exception);
834 case LeftBottomOrientation:
836 orient_image=RotateImage(*image,270.0,exception);
842 if (orient_image == (Image *) NULL)
844 orient_image->orientation=TopLeftOrientation;
845 *image=DestroyImage(*image);
853 if (LocaleCompare("black-threshold",option+1) == 0)
856 Black threshold image.
858 (void) SyncImageSettings(image_info,*image);
859 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
861 InheritException(exception,&(*image)->exception);
864 if (LocaleCompare("blue-shift",option+1) == 0)
872 (void) SyncImageSettings(image_info,*image);
873 geometry_info.rho=1.5;
875 flags=ParseGeometry(argv[i+1],&geometry_info);
876 shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
877 if (shift_image == (Image *) NULL)
879 *image=DestroyImage(*image);
883 if (LocaleCompare("blur",option+1) == 0)
891 (void) SyncImageSettings(image_info,*image);
892 flags=ParseGeometry(argv[i+1],&geometry_info);
893 if ((flags & SigmaValue) == 0)
894 geometry_info.sigma=1.0;
895 blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
896 geometry_info.sigma,exception);
897 if (blur_image == (Image *) NULL)
899 *image=DestroyImage(*image);
903 if (LocaleCompare("border",option+1) == 0)
909 Surround image with a border of solid color.
911 (void) SyncImageSettings(image_info,*image);
912 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
913 if ((flags & SigmaValue) == 0)
914 geometry.height=geometry.width;
915 border_image=BorderImage(*image,&geometry,exception);
916 if (border_image == (Image *) NULL)
918 *image=DestroyImage(*image);
922 if (LocaleCompare("bordercolor",option+1) == 0)
926 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
930 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
934 if (LocaleCompare("box",option+1) == 0)
936 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
940 if (LocaleCompare("brightness-contrast",option+1) == 0)
953 Brightness / contrast image.
955 (void) SyncImageSettings(image_info,*image);
956 flags=ParseGeometry(argv[i+1],&geometry_info);
957 brightness=geometry_info.rho;
959 if ((flags & SigmaValue) != 0)
960 contrast=geometry_info.sigma;
961 (void) BrightnessContrastImageChannel(*image,channel,brightness,
963 InheritException(exception,&(*image)->exception);
970 if (LocaleCompare("cdl",option+1) == 0)
973 *color_correction_collection;
976 Color correct with a color decision list.
978 (void) SyncImageSettings(image_info,*image);
979 color_correction_collection=FileToString(argv[i+1],~0,exception);
980 if (color_correction_collection == (char *) NULL)
982 (void) ColorDecisionListImage(*image,color_correction_collection);
983 InheritException(exception,&(*image)->exception);
986 if (LocaleCompare("channel",option+1) == 0)
990 channel=DefaultChannels;
993 channel=(ChannelType) ParseChannelOption(argv[i+1]);
996 if (LocaleCompare("charcoal",option+1) == 0)
1004 (void) SyncImageSettings(image_info,*image);
1005 flags=ParseGeometry(argv[i+1],&geometry_info);
1006 if ((flags & SigmaValue) == 0)
1007 geometry_info.sigma=1.0;
1008 charcoal_image=CharcoalImage(*image,geometry_info.rho,
1009 geometry_info.sigma,exception);
1010 if (charcoal_image == (Image *) NULL)
1012 *image=DestroyImage(*image);
1013 *image=charcoal_image;
1016 if (LocaleCompare("chop",option+1) == 0)
1024 (void) SyncImageSettings(image_info,*image);
1025 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1026 chop_image=ChopImage(*image,&geometry,exception);
1027 if (chop_image == (Image *) NULL)
1029 *image=DestroyImage(*image);
1033 if (LocaleCompare("clamp",option+1) == 0)
1038 (void) SyncImageSettings(image_info,*image);
1039 (void) ClampImageChannel(*image,channel);
1040 InheritException(exception,&(*image)->exception);
1043 if (LocaleCompare("clip",option+1) == 0)
1045 (void) SyncImageSettings(image_info,*image);
1048 (void) SetImageClipMask(*image,(Image *) NULL);
1049 InheritException(exception,&(*image)->exception);
1052 (void) ClipImage(*image);
1053 InheritException(exception,&(*image)->exception);
1056 if (LocaleCompare("clip-mask",option+1) == 0)
1067 register PixelPacket
1070 (void) SyncImageSettings(image_info,*image);
1076 (void) SetImageMask(*image,(Image *) NULL);
1077 InheritException(exception,&(*image)->exception);
1083 mask=GetImageCache(image_info,argv[i+1],exception);
1084 if (mask == (Image *) NULL)
1086 for (y=0; y < (ssize_t) mask->rows; y++)
1088 q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception);
1089 if (q == (PixelPacket *) NULL)
1091 for (x=0; x < (ssize_t) mask->columns; x++)
1093 if (mask->matte == MagickFalse)
1094 q->opacity=PixelIntensityToQuantum(q);
1096 q->green=q->opacity;
1100 if (SyncAuthenticPixels(mask,exception) == MagickFalse)
1103 if (SetImageStorageClass(mask,DirectClass) == MagickFalse)
1104 return(MagickFalse);
1105 mask->matte=MagickTrue;
1106 (void) SetImageClipMask(*image,mask);
1107 mask=DestroyImage(mask);
1108 InheritException(exception,&(*image)->exception);
1111 if (LocaleCompare("clip-path",option+1) == 0)
1113 (void) SyncImageSettings(image_info,*image);
1114 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1116 InheritException(exception,&(*image)->exception);
1119 if (LocaleCompare("colorize",option+1) == 0)
1127 (void) SyncImageSettings(image_info,*image);
1128 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1130 if (colorize_image == (Image *) NULL)
1132 *image=DestroyImage(*image);
1133 *image=colorize_image;
1136 if (LocaleCompare("color-matrix",option+1) == 0)
1144 (void) SyncImageSettings(image_info,*image);
1145 kernel=AcquireKernelInfo(argv[i+1]);
1146 if (kernel == (KernelInfo *) NULL)
1148 color_image=ColorMatrixImage(*image,kernel,exception);
1149 kernel=DestroyKernelInfo(kernel);
1150 if (color_image == (Image *) NULL)
1152 *image=DestroyImage(*image);
1156 if (LocaleCompare("colors",option+1) == 0)
1159 Reduce the number of colors in the image.
1161 (void) SyncImageSettings(image_info,*image);
1162 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1163 if (quantize_info->number_colors == 0)
1165 if (((*image)->storage_class == DirectClass) ||
1166 (*image)->colors > quantize_info->number_colors)
1167 (void) QuantizeImage(quantize_info,*image);
1169 (void) CompressImageColormap(*image);
1170 InheritException(exception,&(*image)->exception);
1173 if (LocaleCompare("colorspace",option+1) == 0)
1178 (void) SyncImageSettings(image_info,*image);
1181 (void) TransformImageColorspace(*image,RGBColorspace);
1182 InheritException(exception,&(*image)->exception);
1185 colorspace=(ColorspaceType) ParseMagickOption(
1186 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1187 (void) TransformImageColorspace(*image,colorspace);
1188 InheritException(exception,&(*image)->exception);
1191 if (LocaleCompare("contrast",option+1) == 0)
1193 (void) SyncImageSettings(image_info,*image);
1194 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1196 InheritException(exception,&(*image)->exception);
1199 if (LocaleCompare("contrast-stretch",option+1) == 0)
1209 Contrast stretch image.
1211 (void) SyncImageSettings(image_info,*image);
1212 flags=ParseGeometry(argv[i+1],&geometry_info);
1213 black_point=geometry_info.rho;
1214 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1216 if ((flags & PercentValue) != 0)
1218 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1219 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1221 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1223 (void) ContrastStretchImageChannel(*image,channel,black_point,
1225 InheritException(exception,&(*image)->exception);
1228 if (LocaleCompare("convolve",option+1) == 0)
1242 (void) SyncImageSettings(image_info,*image);
1243 kernel=AcquireKernelInfo(argv[i+1]);
1244 if (kernel == (KernelInfo *) NULL)
1247 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1248 gamma+=kernel->values[j];
1249 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1250 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1251 kernel->values[j]*=gamma;
1252 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
1253 kernel=DestroyKernelInfo(kernel);
1254 if (convolve_image == (Image *) NULL)
1256 *image=DestroyImage(*image);
1257 *image=convolve_image;
1260 if (LocaleCompare("crop",option+1) == 0)
1262 (void) SyncImageSettings(image_info,*image);
1263 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1264 if (((geometry.width != 0) || (geometry.height != 0)) &&
1265 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1267 (void) TransformImage(image,argv[i+1],(char *) NULL);
1268 InheritException(exception,&(*image)->exception);
1271 if (LocaleCompare("cycle",option+1) == 0)
1274 Cycle an image colormap.
1276 (void) SyncImageSettings(image_info,*image);
1277 (void) CycleColormapImage(*image,StringToLong(argv[i+1]));
1278 InheritException(exception,&(*image)->exception);
1285 if (LocaleCompare("decipher",option+1) == 0)
1293 (void) SyncImageSettings(image_info,*image);
1294 passkey=FileToStringInfo(argv[i+1],~0,exception);
1295 if (passkey != (StringInfo *) NULL)
1297 (void) PasskeyDecipherImage(*image,passkey,exception);
1298 passkey=DestroyStringInfo(passkey);
1302 if (LocaleCompare("density",option+1) == 0)
1307 (void) CloneString(&draw_info->density,argv[i+1]);
1310 if (LocaleCompare("depth",option+1) == 0)
1312 (void) SyncImageSettings(image_info,*image);
1315 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1318 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1321 if (LocaleCompare("deskew",option+1) == 0)
1330 Straighten the image.
1332 (void) SyncImageSettings(image_info,*image);
1334 threshold=40.0*QuantumRange/100.0;
1336 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1337 deskew_image=DeskewImage(*image,threshold,exception);
1338 if (deskew_image == (Image *) NULL)
1340 *image=DestroyImage(*image);
1341 *image=deskew_image;
1344 if (LocaleCompare("despeckle",option+1) == 0)
1350 Reduce the speckles within an image.
1352 (void) SyncImageSettings(image_info,*image);
1353 despeckle_image=DespeckleImage(*image,exception);
1354 if (despeckle_image == (Image *) NULL)
1356 *image=DestroyImage(*image);
1357 *image=despeckle_image;
1360 if (LocaleCompare("display",option+1) == 0)
1362 (void) CloneString(&draw_info->server_name,argv[i+1]);
1365 if (LocaleCompare("distort",option+1) == 0)
1369 token[MaxTextExtent];
1392 (void) SyncImageSettings(image_info,*image);
1393 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1394 MagickFalse,argv[i+1]);
1395 args=InterpretImageProperties(image_info,*image,argv[i+2]);
1396 InheritException(exception,&(*image)->exception);
1397 if (args == (char *) NULL)
1400 for (x=0; *p != '\0'; x++)
1402 GetMagickToken(p,&p,token);
1404 GetMagickToken(p,&p,token);
1406 number_arguments=(size_t) x;
1407 arguments=(double *) AcquireQuantumMemory(number_arguments,
1408 sizeof(*arguments));
1409 if (arguments == (double *) NULL)
1410 ThrowWandFatalException(ResourceLimitFatalError,
1411 "MemoryAllocationFailed",(*image)->filename);
1412 (void) ResetMagickMemory(arguments,0,number_arguments*
1413 sizeof(*arguments));
1415 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1417 GetMagickToken(p,&p,token);
1419 GetMagickToken(p,&p,token);
1420 arguments[x]=StringToDouble(token);
1422 args=DestroyString(args);
1423 distort_image=DistortImage(*image,method,number_arguments,arguments,
1424 (*option == '+') ? MagickTrue : MagickFalse,exception);
1425 arguments=(double *) RelinquishMagickMemory(arguments);
1426 if (distort_image == (Image *) NULL)
1428 *image=DestroyImage(*image);
1429 *image=distort_image;
1432 if (LocaleCompare("dither",option+1) == 0)
1436 quantize_info->dither=MagickFalse;
1439 quantize_info->dither=MagickTrue;
1440 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
1441 MagickDitherOptions,MagickFalse,argv[i+1]);
1442 if (quantize_info->dither_method == NoDitherMethod)
1443 quantize_info->dither=MagickFalse;
1446 if (LocaleCompare("draw",option+1) == 0)
1451 (void) SyncImageSettings(image_info,*image);
1452 (void) CloneString(&draw_info->primitive,argv[i+1]);
1453 (void) DrawImage(*image,draw_info);
1454 InheritException(exception,&(*image)->exception);
1461 if (LocaleCompare("edge",option+1) == 0)
1467 Enhance edges in the image.
1469 (void) SyncImageSettings(image_info,*image);
1470 flags=ParseGeometry(argv[i+1],&geometry_info);
1471 if ((flags & SigmaValue) == 0)
1472 geometry_info.sigma=1.0;
1473 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1474 if (edge_image == (Image *) NULL)
1476 *image=DestroyImage(*image);
1480 if (LocaleCompare("emboss",option+1) == 0)
1486 Gaussian embossen image.
1488 (void) SyncImageSettings(image_info,*image);
1489 flags=ParseGeometry(argv[i+1],&geometry_info);
1490 if ((flags & SigmaValue) == 0)
1491 geometry_info.sigma=1.0;
1492 emboss_image=EmbossImage(*image,geometry_info.rho,
1493 geometry_info.sigma,exception);
1494 if (emboss_image == (Image *) NULL)
1496 *image=DestroyImage(*image);
1497 *image=emboss_image;
1500 if (LocaleCompare("encipher",option+1) == 0)
1508 (void) SyncImageSettings(image_info,*image);
1509 passkey=FileToStringInfo(argv[i+1],~0,exception);
1510 if (passkey != (StringInfo *) NULL)
1512 (void) PasskeyEncipherImage(*image,passkey,exception);
1513 passkey=DestroyStringInfo(passkey);
1517 if (LocaleCompare("encoding",option+1) == 0)
1519 (void) CloneString(&draw_info->encoding,argv[i+1]);
1522 if (LocaleCompare("enhance",option+1) == 0)
1530 (void) SyncImageSettings(image_info,*image);
1531 enhance_image=EnhanceImage(*image,exception);
1532 if (enhance_image == (Image *) NULL)
1534 *image=DestroyImage(*image);
1535 *image=enhance_image;
1538 if (LocaleCompare("equalize",option+1) == 0)
1543 (void) SyncImageSettings(image_info,*image);
1544 (void) EqualizeImageChannel(*image,channel);
1545 InheritException(exception,&(*image)->exception);
1548 if (LocaleCompare("evaluate",option+1) == 0)
1553 MagickEvaluateOperator
1556 (void) SyncImageSettings(image_info,*image);
1557 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1558 MagickFalse,argv[i+1]);
1559 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1560 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1563 if (LocaleCompare("extent",option+1) == 0)
1569 Set the image extent.
1571 (void) SyncImageSettings(image_info,*image);
1572 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1573 if (geometry.width == 0)
1574 geometry.width=(*image)->columns;
1575 if (geometry.height == 0)
1576 geometry.height=(*image)->rows;
1577 geometry.x=(-geometry.x);
1578 geometry.y=(-geometry.y);
1579 extent_image=ExtentImage(*image,&geometry,exception);
1580 if (extent_image == (Image *) NULL)
1582 *image=DestroyImage(*image);
1583 *image=extent_image;
1590 if (LocaleCompare("family",option+1) == 0)
1594 if (draw_info->family != (char *) NULL)
1595 draw_info->family=DestroyString(draw_info->family);
1598 (void) CloneString(&draw_info->family,argv[i+1]);
1601 if (LocaleCompare("features",option+1) == 0)
1605 (void) DeleteImageArtifact(*image,"identify:features");
1608 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1611 if (LocaleCompare("fill",option+1) == 0)
1616 GetMagickPixelPacket(*image,&fill);
1619 (void) QueryMagickColor("none",&fill,exception);
1620 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1621 if (draw_info->fill_pattern != (Image *) NULL)
1622 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1625 sans=AcquireExceptionInfo();
1626 (void) QueryMagickColor(argv[i+1],&fill,sans);
1627 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1628 sans=DestroyExceptionInfo(sans);
1629 if (status == MagickFalse)
1630 draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
1634 if (LocaleCompare("flip",option+1) == 0)
1640 Flip image scanlines.
1642 (void) SyncImageSettings(image_info,*image);
1643 flip_image=FlipImage(*image,exception);
1644 if (flip_image == (Image *) NULL)
1646 *image=DestroyImage(*image);
1650 if (LocaleCompare("flop",option+1) == 0)
1656 Flop image scanlines.
1658 (void) SyncImageSettings(image_info,*image);
1659 flop_image=FlopImage(*image,exception);
1660 if (flop_image == (Image *) NULL)
1662 *image=DestroyImage(*image);
1666 if (LocaleCompare("floodfill",option+1) == 0)
1674 (void) SyncImageSettings(image_info,*image);
1675 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1676 (void) QueryMagickColor(argv[i+2],&target,exception);
1677 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1678 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1679 InheritException(exception,&(*image)->exception);
1682 if (LocaleCompare("font",option+1) == 0)
1686 if (draw_info->font != (char *) NULL)
1687 draw_info->font=DestroyString(draw_info->font);
1690 (void) CloneString(&draw_info->font,argv[i+1]);
1693 if (LocaleCompare("format",option+1) == 0)
1698 if (LocaleCompare("frame",option+1) == 0)
1707 Surround image with an ornamental border.
1709 (void) SyncImageSettings(image_info,*image);
1710 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1711 frame_info.width=geometry.width;
1712 frame_info.height=geometry.height;
1713 if ((flags & HeightValue) == 0)
1714 frame_info.height=geometry.width;
1715 frame_info.outer_bevel=geometry.x;
1716 frame_info.inner_bevel=geometry.y;
1717 frame_info.x=(ssize_t) frame_info.width;
1718 frame_info.y=(ssize_t) frame_info.height;
1719 frame_info.width=(*image)->columns+2*frame_info.width;
1720 frame_info.height=(*image)->rows+2*frame_info.height;
1721 frame_image=FrameImage(*image,&frame_info,exception);
1722 if (frame_image == (Image *) NULL)
1724 *image=DestroyImage(*image);
1728 if (LocaleCompare("function",option+1) == 0)
1732 token[MaxTextExtent];
1750 Function Modify Image Values
1752 (void) SyncImageSettings(image_info,*image);
1753 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1754 MagickFalse,argv[i+1]);
1755 arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
1756 InheritException(exception,&(*image)->exception);
1757 if (arguments == (char *) NULL)
1759 p=(char *) arguments;
1760 for (x=0; *p != '\0'; x++)
1762 GetMagickToken(p,&p,token);
1764 GetMagickToken(p,&p,token);
1766 number_parameters=(size_t) x;
1767 parameters=(double *) AcquireQuantumMemory(number_parameters,
1768 sizeof(*parameters));
1769 if (parameters == (double *) NULL)
1770 ThrowWandFatalException(ResourceLimitFatalError,
1771 "MemoryAllocationFailed",(*image)->filename);
1772 (void) ResetMagickMemory(parameters,0,number_parameters*
1773 sizeof(*parameters));
1774 p=(char *) arguments;
1775 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1777 GetMagickToken(p,&p,token);
1779 GetMagickToken(p,&p,token);
1780 parameters[x]=StringToDouble(token);
1782 arguments=DestroyString(arguments);
1783 (void) FunctionImageChannel(*image,channel,function,
1784 number_parameters,parameters,exception);
1785 parameters=(double *) RelinquishMagickMemory(parameters);
1792 if (LocaleCompare("gamma",option+1) == 0)
1797 (void) SyncImageSettings(image_info,*image);
1799 (*image)->gamma=StringToDouble(argv[i+1]);
1802 if (strchr(argv[i+1],',') != (char *) NULL)
1803 (void) GammaImage(*image,argv[i+1]);
1805 (void) GammaImageChannel(*image,channel,
1806 StringToDouble(argv[i+1]));
1807 InheritException(exception,&(*image)->exception);
1811 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1812 (LocaleCompare("gaussian",option+1) == 0))
1818 Gaussian blur image.
1820 (void) SyncImageSettings(image_info,*image);
1821 flags=ParseGeometry(argv[i+1],&geometry_info);
1822 if ((flags & SigmaValue) == 0)
1823 geometry_info.sigma=1.0;
1824 gaussian_image=GaussianBlurImageChannel(*image,channel,
1825 geometry_info.rho,geometry_info.sigma,exception);
1826 if (gaussian_image == (Image *) NULL)
1828 *image=DestroyImage(*image);
1829 *image=gaussian_image;
1832 if (LocaleCompare("geometry",option+1) == 0)
1834 (void) SyncImageSettings(image_info,*image);
1837 if ((*image)->geometry != (char *) NULL)
1838 (*image)->geometry=DestroyString((*image)->geometry);
1841 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1842 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1843 (void) CloneString(&(*image)->geometry,argv[i+1]);
1852 zoom_image=ZoomImage(*image,geometry.width,geometry.height,
1854 if (zoom_image == (Image *) NULL)
1856 *image=DestroyImage(*image);
1861 if (LocaleCompare("gravity",option+1) == 0)
1865 draw_info->gravity=UndefinedGravity;
1868 draw_info->gravity=(GravityType) ParseMagickOption(
1869 MagickGravityOptions,MagickFalse,argv[i+1]);
1876 if (LocaleCompare("highlight-color",option+1) == 0)
1878 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1885 if (LocaleCompare("identify",option+1) == 0)
1890 (void) SyncImageSettings(image_info,*image);
1891 if (format == (char *) NULL)
1893 (void) IdentifyImage(*image,stdout,image_info->verbose);
1894 InheritException(exception,&(*image)->exception);
1897 text=InterpretImageProperties(image_info,*image,format);
1898 InheritException(exception,&(*image)->exception);
1899 if (text == (char *) NULL)
1901 (void) fputs(text,stdout);
1902 (void) fputc('\n',stdout);
1903 text=DestroyString(text);
1906 if (LocaleCompare("implode",option+1) == 0)
1914 (void) SyncImageSettings(image_info,*image);
1915 (void) ParseGeometry(argv[i+1],&geometry_info);
1916 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1917 if (implode_image == (Image *) NULL)
1919 *image=DestroyImage(*image);
1920 *image=implode_image;
1923 if (LocaleCompare("interline-spacing",option+1) == 0)
1926 (void) ParseGeometry("0",&geometry_info);
1928 (void) ParseGeometry(argv[i+1],&geometry_info);
1929 draw_info->interline_spacing=geometry_info.rho;
1932 if (LocaleCompare("interword-spacing",option+1) == 0)
1935 (void) ParseGeometry("0",&geometry_info);
1937 (void) ParseGeometry(argv[i+1],&geometry_info);
1938 draw_info->interword_spacing=geometry_info.rho;
1945 if (LocaleCompare("kerning",option+1) == 0)
1948 (void) ParseGeometry("0",&geometry_info);
1950 (void) ParseGeometry(argv[i+1],&geometry_info);
1951 draw_info->kerning=geometry_info.rho;
1958 if (LocaleCompare("lat",option+1) == 0)
1964 Local adaptive threshold image.
1966 (void) SyncImageSettings(image_info,*image);
1967 flags=ParseGeometry(argv[i+1],&geometry_info);
1968 if ((flags & PercentValue) != 0)
1969 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1970 threshold_image=AdaptiveThresholdImage(*image,(size_t)
1971 geometry_info.rho,(size_t) geometry_info.sigma,
1972 (ssize_t) geometry_info.xi,exception);
1973 if (threshold_image == (Image *) NULL)
1975 *image=DestroyImage(*image);
1976 *image=threshold_image;
1979 if (LocaleCompare("level",option+1) == 0)
1992 (void) SyncImageSettings(image_info,*image);
1993 flags=ParseGeometry(argv[i+1],&geometry_info);
1994 black_point=geometry_info.rho;
1995 white_point=(MagickRealType) QuantumRange;
1996 if ((flags & SigmaValue) != 0)
1997 white_point=geometry_info.sigma;
1999 if ((flags & XiValue) != 0)
2000 gamma=geometry_info.xi;
2001 if ((flags & PercentValue) != 0)
2003 black_point*=(MagickRealType) (QuantumRange/100.0);
2004 white_point*=(MagickRealType) (QuantumRange/100.0);
2006 if ((flags & SigmaValue) == 0)
2007 white_point=(MagickRealType) QuantumRange-black_point;
2008 if ((*option == '+') || ((flags & AspectValue) != 0))
2009 (void) LevelizeImageChannel(*image,channel,black_point,
2012 (void) LevelImageChannel(*image,channel,black_point,white_point,
2014 InheritException(exception,&(*image)->exception);
2017 if (LocaleCompare("level-colors",option+1) == 0)
2020 token[MaxTextExtent];
2029 p=(const char *) argv[i+1];
2030 GetMagickToken(p,&p,token); /* get black point color */
2031 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2032 (void) QueryMagickColor(token,&black_point,exception);
2034 (void) QueryMagickColor("#000000",&black_point,exception);
2035 if (isalpha((int) token[0]) || (token[0] == '#'))
2036 GetMagickToken(p,&p,token);
2038 white_point=black_point; /* set everything to that color */
2042 Get white point color.
2044 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2045 GetMagickToken(p,&p,token);
2046 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2047 (void) QueryMagickColor(token,&white_point,exception);
2049 (void) QueryMagickColor("#ffffff",&white_point,exception);
2051 (void) LevelColorsImageChannel(*image,channel,&black_point,
2052 &white_point,*option == '+' ? MagickTrue : MagickFalse);
2055 if (LocaleCompare("linear-stretch",option+1) == 0)
2064 (void) SyncImageSettings(image_info,*image);
2065 flags=ParseGeometry(argv[i+1],&geometry_info);
2066 black_point=geometry_info.rho;
2067 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2068 if ((flags & SigmaValue) != 0)
2069 white_point=geometry_info.sigma;
2070 if ((flags & PercentValue) != 0)
2072 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2073 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2075 if ((flags & SigmaValue) == 0)
2076 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2078 (void) LinearStretchImage(*image,black_point,white_point);
2079 InheritException(exception,&(*image)->exception);
2082 if (LocaleCompare("linewidth",option+1) == 0)
2084 draw_info->stroke_width=StringToDouble(argv[i+1]);
2087 if (LocaleCompare("liquid-rescale",option+1) == 0)
2093 Liquid rescale image.
2095 (void) SyncImageSettings(image_info,*image);
2096 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2097 if ((flags & XValue) == 0)
2099 if ((flags & YValue) == 0)
2101 resize_image=LiquidRescaleImage(*image,geometry.width,
2102 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2103 if (resize_image == (Image *) NULL)
2105 *image=DestroyImage(*image);
2106 *image=resize_image;
2109 if (LocaleCompare("lowlight-color",option+1) == 0)
2111 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2118 if (LocaleCompare("map",option+1) == 0)
2124 Transform image colors to match this set of colors.
2126 (void) SyncImageSettings(image_info,*image);
2129 remap_image=GetImageCache(image_info,argv[i+1],exception);
2130 if (remap_image == (Image *) NULL)
2132 (void) RemapImage(quantize_info,*image,remap_image);
2133 InheritException(exception,&(*image)->exception);
2134 remap_image=DestroyImage(remap_image);
2137 if (LocaleCompare("mask",option+1) == 0)
2142 (void) SyncImageSettings(image_info,*image);
2148 (void) SetImageMask(*image,(Image *) NULL);
2149 InheritException(exception,&(*image)->exception);
2155 mask=GetImageCache(image_info,argv[i+1],exception);
2156 if (mask == (Image *) NULL)
2158 (void) SetImageMask(*image,mask);
2159 mask=DestroyImage(mask);
2160 InheritException(exception,&(*image)->exception);
2163 if (LocaleCompare("matte",option+1) == 0)
2165 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2166 SetAlphaChannel : DeactivateAlphaChannel );
2167 InheritException(exception,&(*image)->exception);
2170 if (LocaleCompare("median",option+1) == 0)
2176 Median filter image.
2178 (void) SyncImageSettings(image_info,*image);
2179 (void) ParseGeometry(argv[i+1],&geometry_info);
2180 median_image=MedianFilterImage(*image,geometry_info.rho,exception);
2181 if (median_image == (Image *) NULL)
2183 *image=DestroyImage(*image);
2184 *image=median_image;
2187 if (LocaleCompare("modulate",option+1) == 0)
2189 (void) SyncImageSettings(image_info,*image);
2190 (void) ModulateImage(*image,argv[i+1]);
2191 InheritException(exception,&(*image)->exception);
2194 if (LocaleCompare("monitor",option+1) == 0)
2198 (void) SetImageProgressMonitor(*image,
2199 (MagickProgressMonitor) NULL,(void *) NULL);
2202 (void) SetImageProgressMonitor(*image,MonitorProgress,
2206 if (LocaleCompare("monochrome",option+1) == 0)
2208 (void) SyncImageSettings(image_info,*image);
2209 (void) SetImageType(*image,BilevelType);
2210 InheritException(exception,&(*image)->exception);
2213 if (LocaleCompare("morphology",option+1) == 0)
2216 token[MaxTextExtent];
2234 Morphological Image Operation
2236 (void) SyncImageSettings(image_info,*image);
2238 GetMagickToken(p,&p,token);
2239 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
2242 GetMagickToken(p,&p,token);
2243 if ((*p == ':') || (*p == ','))
2244 GetMagickToken(p,&p,token);
2246 iterations=StringToLong(p);
2247 kernel=AcquireKernelInfo(argv[i+2]);
2248 if (kernel == (KernelInfo *) NULL)
2250 (void) ThrowMagickException(exception,GetMagickModule(),
2251 OptionError,"UnabletoParseKernel","morphology");
2255 morphology_image=MorphologyImageChannel(*image,channel,method,
2256 iterations,kernel,exception);
2257 kernel=DestroyKernelInfo(kernel);
2258 if (morphology_image == (Image *) NULL)
2260 *image=DestroyImage(*image);
2261 *image=morphology_image;
2264 if (LocaleCompare("motion-blur",option+1) == 0)
2272 (void) SyncImageSettings(image_info,*image);
2273 flags=ParseGeometry(argv[i+1],&geometry_info);
2274 if ((flags & SigmaValue) == 0)
2275 geometry_info.sigma=1.0;
2276 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2277 geometry_info.sigma,geometry_info.xi,exception);
2278 if (blur_image == (Image *) NULL)
2280 *image=DestroyImage(*image);
2288 if (LocaleCompare("negate",option+1) == 0)
2290 (void) SyncImageSettings(image_info,*image);
2291 (void) NegateImageChannel(*image,channel,*option == '+' ?
2292 MagickTrue : MagickFalse);
2293 InheritException(exception,&(*image)->exception);
2296 if (LocaleCompare("noise",option+1) == 0)
2301 (void) SyncImageSettings(image_info,*image);
2304 (void) ParseGeometry(argv[i+1],&geometry_info);
2305 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
2313 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2314 MagickFalse,argv[i+1]);
2315 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2318 if (noisy_image == (Image *) NULL)
2320 *image=DestroyImage(*image);
2324 if (LocaleCompare("normalize",option+1) == 0)
2326 (void) SyncImageSettings(image_info,*image);
2327 (void) NormalizeImageChannel(*image,channel);
2328 InheritException(exception,&(*image)->exception);
2335 if (LocaleCompare("opaque",option+1) == 0)
2340 (void) SyncImageSettings(image_info,*image);
2341 (void) QueryMagickColor(argv[i+1],&target,exception);
2342 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2343 *option == '-' ? MagickFalse : MagickTrue);
2346 if (LocaleCompare("ordered-dither",option+1) == 0)
2348 (void) SyncImageSettings(image_info,*image);
2349 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2357 if (LocaleCompare("paint",option+1) == 0)
2365 (void) SyncImageSettings(image_info,*image);
2366 (void) ParseGeometry(argv[i+1],&geometry_info);
2367 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2368 if (paint_image == (Image *) NULL)
2370 *image=DestroyImage(*image);
2374 if (LocaleCompare("pen",option+1) == 0)
2378 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2381 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2384 if (LocaleCompare("pointsize",option+1) == 0)
2387 (void) ParseGeometry("12",&geometry_info);
2389 (void) ParseGeometry(argv[i+1],&geometry_info);
2390 draw_info->pointsize=geometry_info.rho;
2393 if (LocaleCompare("polaroid",option+1) == 0)
2405 Simulate a Polaroid picture.
2407 (void) SyncImageSettings(image_info,*image);
2408 random_info=AcquireRandomInfo();
2409 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2410 random_info=DestroyRandomInfo(random_info);
2413 SetGeometryInfo(&geometry_info);
2414 flags=ParseGeometry(argv[i+1],&geometry_info);
2415 angle=geometry_info.rho;
2417 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2418 if (polaroid_image == (Image *) NULL)
2420 *image=DestroyImage(*image);
2421 *image=polaroid_image;
2424 if (LocaleCompare("posterize",option+1) == 0)
2429 (void) SyncImageSettings(image_info,*image);
2430 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2431 quantize_info->dither);
2432 InheritException(exception,&(*image)->exception);
2435 if (LocaleCompare("preview",option+1) == 0)
2446 (void) SyncImageSettings(image_info,*image);
2448 preview_type=UndefinedPreview;
2450 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2451 MagickFalse,argv[i+1]);
2452 preview_image=PreviewImage(*image,preview_type,exception);
2453 if (preview_image == (Image *) NULL)
2455 *image=DestroyImage(*image);
2456 *image=preview_image;
2459 if (LocaleCompare("profile",option+1) == 0)
2473 (void) SyncImageSettings(image_info,*image);
2477 Remove a profile from the image.
2479 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2481 InheritException(exception,&(*image)->exception);
2485 Associate a profile with the image.
2487 profile_info=CloneImageInfo(image_info);
2488 profile=GetImageProfile(*image,"iptc");
2489 if (profile != (StringInfo *) NULL)
2490 profile_info->profile=(void *) CloneStringInfo(profile);
2491 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2492 profile_info=DestroyImageInfo(profile_info);
2493 if (profile_image == (Image *) NULL)
2498 profile_info=CloneImageInfo(image_info);
2499 (void) CopyMagickString(profile_info->filename,argv[i+1],
2501 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2502 if (profile != (StringInfo *) NULL)
2504 (void) ProfileImage(*image,profile_info->magick,
2505 GetStringInfoDatum(profile),(size_t)
2506 GetStringInfoLength(profile),MagickFalse);
2507 profile=DestroyStringInfo(profile);
2509 profile_info=DestroyImageInfo(profile_info);
2512 ResetImageProfileIterator(profile_image);
2513 name=GetNextImageProfile(profile_image);
2514 while (name != (const char *) NULL)
2516 profile=GetImageProfile(profile_image,name);
2517 if (profile != (StringInfo *) NULL)
2518 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2519 (size_t) GetStringInfoLength(profile),MagickFalse);
2520 name=GetNextImageProfile(profile_image);
2522 profile_image=DestroyImage(profile_image);
2529 if (LocaleCompare("quantize",option+1) == 0)
2533 quantize_info->colorspace=UndefinedColorspace;
2536 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2537 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2544 if (LocaleCompare("radial-blur",option+1) == 0)
2552 (void) SyncImageSettings(image_info,*image);
2553 blur_image=RadialBlurImageChannel(*image,channel,
2554 StringToDouble(argv[i+1]),exception);
2555 if (blur_image == (Image *) NULL)
2557 *image=DestroyImage(*image);
2561 if (LocaleCompare("raise",option+1) == 0)
2564 Surround image with a raise of solid color.
2566 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2567 if ((flags & SigmaValue) == 0)
2568 geometry.height=geometry.width;
2569 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2571 InheritException(exception,&(*image)->exception);
2574 if (LocaleCompare("random-threshold",option+1) == 0)
2579 (void) SyncImageSettings(image_info,*image);
2580 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2584 if (LocaleCompare("recolor",option+1) == 0)
2592 (void) SyncImageSettings(image_info,*image);
2593 kernel=AcquireKernelInfo(argv[i+1]);
2594 if (kernel == (KernelInfo *) NULL)
2596 color_image=ColorMatrixImage(*image,kernel,exception);
2597 kernel=DestroyKernelInfo(kernel);
2598 if (color_image == (Image *) NULL)
2600 *image=DestroyImage(*image);
2604 if (LocaleCompare("region",option+1) == 0)
2609 (void) SyncImageSettings(image_info,*image);
2610 if (region_image != (Image *) NULL)
2615 (void) CompositeImage(region_image,(*image)->matte !=
2616 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2617 region_geometry.x,region_geometry.y);
2618 InheritException(exception,®ion_image->exception);
2619 *image=DestroyImage(*image);
2620 *image=region_image;
2624 if (region_image != (Image *) NULL)
2625 region_image=DestroyImage(region_image);
2629 Apply transformations to a selected region of the image.
2631 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2633 crop_image=CropImage(*image,®ion_geometry,exception);
2634 if (crop_image == (Image *) NULL)
2636 region_image=(*image);
2640 if (LocaleCompare("render",option+1) == 0)
2642 (void) SyncImageSettings(image_info,*image);
2643 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2646 if (LocaleCompare("remap",option+1) == 0)
2652 Transform image colors to match this set of colors.
2654 (void) SyncImageSettings(image_info,*image);
2657 remap_image=GetImageCache(image_info,argv[i+1],exception);
2658 if (remap_image == (Image *) NULL)
2660 (void) RemapImage(quantize_info,*image,remap_image);
2661 InheritException(exception,&(*image)->exception);
2662 remap_image=DestroyImage(remap_image);
2665 if (LocaleCompare("repage",option+1) == 0)
2669 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2672 (void) ResetImagePage(*image,argv[i+1]);
2673 InheritException(exception,&(*image)->exception);
2676 if (LocaleCompare("resample",option+1) == 0)
2684 (void) SyncImageSettings(image_info,*image);
2685 flags=ParseGeometry(argv[i+1],&geometry_info);
2686 if ((flags & SigmaValue) == 0)
2687 geometry_info.sigma=geometry_info.rho;
2688 resample_image=ResampleImage(*image,geometry_info.rho,
2689 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2690 if (resample_image == (Image *) NULL)
2692 *image=DestroyImage(*image);
2693 *image=resample_image;
2696 if (LocaleCompare("resize",option+1) == 0)
2704 (void) SyncImageSettings(image_info,*image);
2705 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2706 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2707 (*image)->filter,(*image)->blur,exception);
2708 if (resize_image == (Image *) NULL)
2710 *image=DestroyImage(*image);
2711 *image=resize_image;
2714 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2716 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2719 if (LocaleCompare("roll",option+1) == 0)
2727 (void) SyncImageSettings(image_info,*image);
2728 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2729 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2730 if (roll_image == (Image *) NULL)
2732 *image=DestroyImage(*image);
2736 if (LocaleCompare("rotate",option+1) == 0)
2745 Check for conditional image rotation.
2747 (void) SyncImageSettings(image_info,*image);
2748 if (strchr(argv[i+1],'>') != (char *) NULL)
2749 if ((*image)->columns <= (*image)->rows)
2751 if (strchr(argv[i+1],'<') != (char *) NULL)
2752 if ((*image)->columns >= (*image)->rows)
2757 geometry=ConstantString(argv[i+1]);
2758 (void) SubstituteString(&geometry,">","");
2759 (void) SubstituteString(&geometry,"<","");
2760 (void) ParseGeometry(geometry,&geometry_info);
2761 geometry=DestroyString(geometry);
2762 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2763 if (rotate_image == (Image *) NULL)
2765 *image=DestroyImage(*image);
2766 *image=rotate_image;
2773 if (LocaleCompare("sample",option+1) == 0)
2779 Sample image with pixel replication.
2781 (void) SyncImageSettings(image_info,*image);
2782 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2783 sample_image=SampleImage(*image,geometry.width,geometry.height,
2785 if (sample_image == (Image *) NULL)
2787 *image=DestroyImage(*image);
2788 *image=sample_image;
2791 if (LocaleCompare("scale",option+1) == 0)
2799 (void) SyncImageSettings(image_info,*image);
2800 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2801 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2803 if (scale_image == (Image *) NULL)
2805 *image=DestroyImage(*image);
2809 if (LocaleCompare("selective-blur",option+1) == 0)
2815 Selectively blur pixels within a contrast threshold.
2817 (void) SyncImageSettings(image_info,*image);
2818 flags=ParseGeometry(argv[i+1],&geometry_info);
2819 if ((flags & PercentValue) != 0)
2820 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2821 blur_image=SelectiveBlurImageChannel(*image,channel,
2822 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2823 if (blur_image == (Image *) NULL)
2825 *image=DestroyImage(*image);
2829 if (LocaleCompare("separate",option+1) == 0)
2835 Break channels into separate images.
2837 (void) SyncImageSettings(image_info,*image);
2838 separate_images=SeparateImages(*image,channel,exception);
2839 if (separate_images == (Image *) NULL)
2841 *image=DestroyImage(*image);
2842 *image=separate_images;
2845 if (LocaleCompare("sepia-tone",option+1) == 0)
2856 (void) SyncImageSettings(image_info,*image);
2857 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2858 sepia_image=SepiaToneImage(*image,threshold,exception);
2859 if (sepia_image == (Image *) NULL)
2861 *image=DestroyImage(*image);
2865 if (LocaleCompare("segment",option+1) == 0)
2870 (void) SyncImageSettings(image_info,*image);
2871 flags=ParseGeometry(argv[i+1],&geometry_info);
2872 if ((flags & SigmaValue) == 0)
2873 geometry_info.sigma=1.0;
2874 (void) SegmentImage(*image,(*image)->colorspace,image_info->verbose,
2875 geometry_info.rho,geometry_info.sigma);
2876 InheritException(exception,&(*image)->exception);
2879 if (LocaleCompare("set",option+1) == 0)
2884 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2885 (void) DeleteImageRegistry(argv[i+1]+9);
2887 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2888 (void) DeleteImageOption(image_info,argv[i+1]+7);
2890 (void) DeleteImageProperty(*image,argv[i+1]);
2896 value=InterpretImageProperties(image_info,*image,argv[i+2]);
2897 if (value != (char *) NULL)
2899 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2900 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,
2903 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2905 (void) SetImageOption(image_info,argv[i+1]+7,value);
2906 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2909 (void) SetImageProperty(*image,argv[i+1],value);
2910 value=DestroyString(value);
2915 if (LocaleCompare("shade",option+1) == 0)
2923 (void) SyncImageSettings(image_info,*image);
2924 flags=ParseGeometry(argv[i+1],&geometry_info);
2925 if ((flags & SigmaValue) == 0)
2926 geometry_info.sigma=1.0;
2927 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2928 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2929 if (shade_image == (Image *) NULL)
2931 *image=DestroyImage(*image);
2935 if (LocaleCompare("shadow",option+1) == 0)
2943 (void) SyncImageSettings(image_info,*image);
2944 flags=ParseGeometry(argv[i+1],&geometry_info);
2945 if ((flags & SigmaValue) == 0)
2946 geometry_info.sigma=1.0;
2947 if ((flags & XiValue) == 0)
2948 geometry_info.xi=4.0;
2949 if ((flags & PsiValue) == 0)
2950 geometry_info.psi=4.0;
2951 shadow_image=ShadowImage(*image,geometry_info.rho,
2952 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2953 ceil(geometry_info.psi-0.5),exception);
2954 if (shadow_image == (Image *) NULL)
2956 *image=DestroyImage(*image);
2957 *image=shadow_image;
2960 if (LocaleCompare("sharpen",option+1) == 0)
2968 (void) SyncImageSettings(image_info,*image);
2969 flags=ParseGeometry(argv[i+1],&geometry_info);
2970 if ((flags & SigmaValue) == 0)
2971 geometry_info.sigma=1.0;
2972 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2973 geometry_info.sigma,exception);
2974 if (sharp_image == (Image *) NULL)
2976 *image=DestroyImage(*image);
2980 if (LocaleCompare("shave",option+1) == 0)
2986 Shave the image edges.
2988 (void) SyncImageSettings(image_info,*image);
2989 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2990 shave_image=ShaveImage(*image,&geometry,exception);
2991 if (shave_image == (Image *) NULL)
2993 *image=DestroyImage(*image);
2997 if (LocaleCompare("shear",option+1) == 0)
3005 (void) SyncImageSettings(image_info,*image);
3006 flags=ParseGeometry(argv[i+1],&geometry_info);
3007 if ((flags & SigmaValue) == 0)
3008 geometry_info.sigma=geometry_info.rho;
3009 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3011 if (shear_image == (Image *) NULL)
3013 *image=DestroyImage(*image);
3017 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3020 Sigmoidal non-linearity contrast control.
3022 (void) SyncImageSettings(image_info,*image);
3023 flags=ParseGeometry(argv[i+1],&geometry_info);
3024 if ((flags & SigmaValue) == 0)
3025 geometry_info.sigma=(double) QuantumRange/2.0;
3026 if ((flags & PercentValue) != 0)
3027 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3029 (void) SigmoidalContrastImageChannel(*image,channel,
3030 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3031 geometry_info.sigma);
3032 InheritException(exception,&(*image)->exception);
3035 if (LocaleCompare("sketch",option+1) == 0)
3043 (void) SyncImageSettings(image_info,*image);
3044 flags=ParseGeometry(argv[i+1],&geometry_info);
3045 if ((flags & SigmaValue) == 0)
3046 geometry_info.sigma=1.0;
3047 sketch_image=SketchImage(*image,geometry_info.rho,
3048 geometry_info.sigma,geometry_info.xi,exception);
3049 if (sketch_image == (Image *) NULL)
3051 *image=DestroyImage(*image);
3052 *image=sketch_image;
3055 if (LocaleCompare("solarize",option+1) == 0)
3060 (void) SyncImageSettings(image_info,*image);
3061 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3062 (void) SolarizeImage(*image,threshold);
3063 InheritException(exception,&(*image)->exception);
3066 if (LocaleCompare("sparse-color",option+1) == 0)
3078 Sparse Color Interpolated Gradient
3080 (void) SyncImageSettings(image_info,*image);
3081 method=(SparseColorMethod) ParseMagickOption(
3082 MagickSparseColorOptions,MagickFalse,argv[i+1]);
3083 arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
3084 InheritException(exception,&(*image)->exception);
3085 if (arguments == (char *) NULL)
3087 sparse_image=SparseColorOption(*image,channel,method,arguments,
3088 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3089 arguments=DestroyString(arguments);
3090 if (sparse_image == (Image *) NULL)
3092 *image=DestroyImage(*image);
3093 *image=sparse_image;
3096 if (LocaleCompare("splice",option+1) == 0)
3102 Splice a solid color into the image.
3104 (void) SyncImageSettings(image_info,*image);
3105 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3106 splice_image=SpliceImage(*image,&geometry,exception);
3107 if (splice_image == (Image *) NULL)
3109 *image=DestroyImage(*image);
3110 *image=splice_image;
3113 if (LocaleCompare("spread",option+1) == 0)
3121 (void) SyncImageSettings(image_info,*image);
3122 (void) ParseGeometry(argv[i+1],&geometry_info);
3123 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3124 if (spread_image == (Image *) NULL)
3126 *image=DestroyImage(*image);
3127 *image=spread_image;
3130 if (LocaleCompare("stretch",option+1) == 0)
3134 draw_info->stretch=UndefinedStretch;
3137 draw_info->stretch=(StretchType) ParseMagickOption(
3138 MagickStretchOptions,MagickFalse,argv[i+1]);
3141 if (LocaleCompare("strip",option+1) == 0)
3144 Strip image of profiles and comments.
3146 (void) SyncImageSettings(image_info,*image);
3147 (void) StripImage(*image);
3148 InheritException(exception,&(*image)->exception);
3151 if (LocaleCompare("stroke",option+1) == 0)
3158 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3159 if (draw_info->stroke_pattern != (Image *) NULL)
3160 draw_info->stroke_pattern=DestroyImage(
3161 draw_info->stroke_pattern);
3164 sans=AcquireExceptionInfo();
3165 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3166 sans=DestroyExceptionInfo(sans);
3167 if (status == MagickFalse)
3168 draw_info->stroke_pattern=GetImageCache(image_info,argv[i+1],
3172 if (LocaleCompare("strokewidth",option+1) == 0)
3174 draw_info->stroke_width=StringToDouble(argv[i+1]);
3177 if (LocaleCompare("style",option+1) == 0)
3181 draw_info->style=UndefinedStyle;
3184 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3185 MagickFalse,argv[i+1]);
3188 if (LocaleCompare("swirl",option+1) == 0)
3196 (void) SyncImageSettings(image_info,*image);
3197 (void) ParseGeometry(argv[i+1],&geometry_info);
3198 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3199 if (swirl_image == (Image *) NULL)
3201 *image=DestroyImage(*image);
3209 if (LocaleCompare("threshold",option+1) == 0)
3217 (void) SyncImageSettings(image_info,*image);
3219 threshold=(double) QuantumRange/2.5;
3221 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3222 (void) BilevelImageChannel(*image,channel,threshold);
3223 InheritException(exception,&(*image)->exception);
3226 if (LocaleCompare("thumbnail",option+1) == 0)
3234 (void) SyncImageSettings(image_info,*image);
3235 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3236 thumbnail_image=ThumbnailImage(*image,geometry.width,
3237 geometry.height,exception);
3238 if (thumbnail_image == (Image *) NULL)
3240 *image=DestroyImage(*image);
3241 *image=thumbnail_image;
3244 if (LocaleCompare("tile",option+1) == 0)
3248 if (draw_info->fill_pattern != (Image *) NULL)
3249 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3252 draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
3256 if (LocaleCompare("tint",option+1) == 0)
3264 (void) SyncImageSettings(image_info,*image);
3265 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3266 if (tint_image == (Image *) NULL)
3268 *image=DestroyImage(*image);
3272 if (LocaleCompare("transform",option+1) == 0)
3278 Affine transform image.
3280 (void) SyncImageSettings(image_info,*image);
3281 transform_image=AffineTransformImage(*image,&draw_info->affine,
3283 if (transform_image == (Image *) NULL)
3285 *image=DestroyImage(*image);
3286 *image=transform_image;
3289 if (LocaleCompare("transparent",option+1) == 0)
3294 (void) SyncImageSettings(image_info,*image);
3295 (void) QueryMagickColor(argv[i+1],&target,exception);
3296 (void) TransparentPaintImage(*image,&target,(Quantum)
3297 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3298 InheritException(exception,&(*image)->exception);
3301 if (LocaleCompare("transpose",option+1) == 0)
3307 Transpose image scanlines.
3309 (void) SyncImageSettings(image_info,*image);
3310 transpose_image=TransposeImage(*image,exception);
3311 if (transpose_image == (Image *) NULL)
3313 *image=DestroyImage(*image);
3314 *image=transpose_image;
3317 if (LocaleCompare("transverse",option+1) == 0)
3323 Transverse image scanlines.
3325 (void) SyncImageSettings(image_info,*image);
3326 transverse_image=TransverseImage(*image,exception);
3327 if (transverse_image == (Image *) NULL)
3329 *image=DestroyImage(*image);
3330 *image=transverse_image;
3333 if (LocaleCompare("treedepth",option+1) == 0)
3335 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3338 if (LocaleCompare("trim",option+1) == 0)
3346 (void) SyncImageSettings(image_info,*image);
3347 trim_image=TrimImage(*image,exception);
3348 if (trim_image == (Image *) NULL)
3350 *image=DestroyImage(*image);
3354 if (LocaleCompare("type",option+1) == 0)
3359 (void) SyncImageSettings(image_info,*image);
3363 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3365 (*image)->type=UndefinedType;
3366 (void) SetImageType(*image,type);
3367 InheritException(exception,&(*image)->exception);
3374 if (LocaleCompare("undercolor",option+1) == 0)
3376 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3380 if (LocaleCompare("unique",option+1) == 0)
3384 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3387 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3390 if (LocaleCompare("unique-colors",option+1) == 0)
3396 Unique image colors.
3398 (void) SyncImageSettings(image_info,*image);
3399 unique_image=UniqueImageColors(*image,exception);
3400 if (unique_image == (Image *) NULL)
3402 *image=DestroyImage(*image);
3403 *image=unique_image;
3406 if (LocaleCompare("unsharp",option+1) == 0)
3414 (void) SyncImageSettings(image_info,*image);
3415 flags=ParseGeometry(argv[i+1],&geometry_info);
3416 if ((flags & SigmaValue) == 0)
3417 geometry_info.sigma=1.0;
3418 if ((flags & XiValue) == 0)
3419 geometry_info.xi=1.0;
3420 if ((flags & PsiValue) == 0)
3421 geometry_info.psi=0.05;
3422 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3423 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3424 geometry_info.psi,exception);
3425 if (unsharp_image == (Image *) NULL)
3427 *image=DestroyImage(*image);
3428 *image=unsharp_image;
3435 if (LocaleCompare("verbose",option+1) == 0)
3437 (void) SetImageArtifact(*image,option+1,
3438 *option == '+' ? "false" : "true");
3441 if (LocaleCompare("vignette",option+1) == 0)
3449 (void) SyncImageSettings(image_info,*image);
3450 flags=ParseGeometry(argv[i+1],&geometry_info);
3451 if ((flags & SigmaValue) == 0)
3452 geometry_info.sigma=1.0;
3453 if ((flags & XiValue) == 0)
3454 geometry_info.xi=0.1*(*image)->columns;
3455 if ((flags & PsiValue) == 0)
3456 geometry_info.psi=0.1*(*image)->rows;
3457 vignette_image=VignetteImage(*image,geometry_info.rho,
3458 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3459 ceil(geometry_info.psi-0.5),exception);
3460 if (vignette_image == (Image *) NULL)
3462 *image=DestroyImage(*image);
3463 *image=vignette_image;
3466 if (LocaleCompare("virtual-pixel",option+1) == 0)
3470 (void) SetImageVirtualPixelMethod(*image,
3471 UndefinedVirtualPixelMethod);
3474 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3475 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3483 if (LocaleCompare("wave",option+1) == 0)
3491 (void) SyncImageSettings(image_info,*image);
3492 flags=ParseGeometry(argv[i+1],&geometry_info);
3493 if ((flags & SigmaValue) == 0)
3494 geometry_info.sigma=1.0;
3495 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3497 if (wave_image == (Image *) NULL)
3499 *image=DestroyImage(*image);
3503 if (LocaleCompare("weight",option+1) == 0)
3505 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3506 if (LocaleCompare(argv[i+1],"all") == 0)
3507 draw_info->weight=0;
3508 if (LocaleCompare(argv[i+1],"bold") == 0)
3509 draw_info->weight=700;
3510 if (LocaleCompare(argv[i+1],"bolder") == 0)
3511 if (draw_info->weight <= 800)
3512 draw_info->weight+=100;
3513 if (LocaleCompare(argv[i+1],"lighter") == 0)
3514 if (draw_info->weight >= 100)
3515 draw_info->weight-=100;
3516 if (LocaleCompare(argv[i+1],"normal") == 0)
3517 draw_info->weight=400;
3520 if (LocaleCompare("white-threshold",option+1) == 0)
3523 White threshold image.
3525 (void) SyncImageSettings(image_info,*image);
3526 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3528 InheritException(exception,&(*image)->exception);
3538 if (region_image != (Image *) NULL)
3541 Composite transformed region onto image.
3543 (void) SyncImageSettings(image_info,*image);
3544 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3545 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3547 InheritException(exception,®ion_image->exception);
3548 *image=DestroyImage(*image);
3549 *image=region_image;
3554 quantize_info=DestroyQuantizeInfo(quantize_info);
3555 draw_info=DestroyDrawInfo(draw_info);
3556 status=(*image)->exception.severity == UndefinedException ?
3557 MagickTrue : MagickFalse;
3562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3566 % M o g r i f y I m a g e C o m m a n d %
3570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3572 % MogrifyImageCommand() transforms an image or a sequence of images. These
3573 % transforms include image scaling, image rotation, color reduction, and
3574 % others. The transmogrified image overwrites the original image.
3576 % The format of the MogrifyImageCommand method is:
3578 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3579 % const char **argv,char **metadata,ExceptionInfo *exception)
3581 % A description of each parameter follows:
3583 % o image_info: the image info.
3585 % o argc: the number of elements in the argument vector.
3587 % o argv: A text array containing the command line arguments.
3589 % o metadata: any metadata is returned here.
3591 % o exception: return any errors or warnings in this structure.
3595 static MagickBooleanType MogrifyUsage(void)
3600 "-debug events display copious debugging information",
3601 "-help print program options",
3602 "-list type print a list of supported option arguments",
3603 "-log format format of debugging information",
3604 "-version print version information",
3609 "-adaptive-blur geometry",
3610 " adaptively blur pixels; decrease effect near edges",
3611 "-adaptive-resize geometry",
3612 " adaptively resize image using 'mesh' interpolation",
3613 "-adaptive-sharpen geometry",
3614 " adaptively sharpen pixels; increase effect near edges",
3615 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3616 " transparent, extract, background, or shape",
3617 "-annotate geometry text",
3618 " annotate the image with text",
3619 "-auto-gamma automagically adjust gamma level of image",
3620 "-auto-level automagically adjust color levels of image",
3621 "-auto-orient automagically orient (rotate) image",
3622 "-bench iterations measure performance",
3623 "-black-threshold value",
3624 " force all pixels below the threshold into black",
3625 "-blue-shift simulate a scene at nighttime in the moonlight",
3626 "-blur geometry reduce image noise and reduce detail levels",
3627 "-border geometry surround image with a border of color",
3628 "-bordercolor color border color",
3629 "-brightness-contrast geometry",
3630 " improve brightness / contrast of the image",
3631 "-cdl filename color correct with a color decision list",
3632 "-charcoal radius simulate a charcoal drawing",
3633 "-chop geometry remove pixels from the image interior",
3634 "-clamp restrict pixel range from 0 to the quantum depth",
3635 "-clip clip along the first path from the 8BIM profile",
3636 "-clip-mask filename associate a clip mask with the image",
3637 "-clip-path id clip along a named path from the 8BIM profile",
3638 "-colorize value colorize the image with the fill color",
3639 "-color-matrix matrix apply color correction to the image",
3640 "-contrast enhance or reduce the image contrast",
3641 "-contrast-stretch geometry",
3642 " improve contrast by `stretching' the intensity range",
3643 "-convolve coefficients",
3644 " apply a convolution kernel to the image",
3645 "-cycle amount cycle the image colormap",
3646 "-decipher filename convert cipher pixels to plain pixels",
3647 "-deskew threshold straighten an image",
3648 "-despeckle reduce the speckles within an image",
3649 "-distort method args",
3650 " distort images according to given method ad args",
3651 "-draw string annotate the image with a graphic primitive",
3652 "-edge radius apply a filter to detect edges in the image",
3653 "-encipher filename convert plain pixels to cipher pixels",
3654 "-emboss radius emboss an image",
3655 "-enhance apply a digital filter to enhance a noisy image",
3656 "-equalize perform histogram equalization to an image",
3657 "-evaluate operator value",
3658 " evaluate an arithmetic, relational, or logical expression",
3659 "-extent geometry set the image size",
3660 "-extract geometry extract area from image",
3661 "-fft implements the discrete Fourier transform (DFT)",
3662 "-flip flip image vertically",
3663 "-floodfill geometry color",
3664 " floodfill the image with color",
3665 "-flop flop image horizontally",
3666 "-frame geometry surround image with an ornamental border",
3667 "-function name parameters",
3668 " apply function over image values",
3669 "-gamma value level of gamma correction",
3670 "-gaussian-blur geometry",
3671 " reduce image noise and reduce detail levels",
3672 "-geometry geometry preferred size or location of the image",
3673 "-identify identify the format and characteristics of the image",
3674 "-ift implements the inverse discrete Fourier transform (DFT)",
3675 "-implode amount implode image pixels about the center",
3676 "-lat geometry local adaptive thresholding",
3677 "-layers method optimize, merge, or compare image layers",
3678 "-level value adjust the level of image contrast",
3679 "-level-colors color,color",
3680 " level image with the given colors",
3681 "-linear-stretch geometry",
3682 " improve contrast by `stretching with saturation'",
3683 "-liquid-rescale geometry",
3684 " rescale image with seam-carving",
3685 "-median radius apply a median filter to the image",
3686 "-modulate value vary the brightness, saturation, and hue",
3687 "-monochrome transform image to black and white",
3688 "-morphology method kernel",
3689 " apply a morphology method to the image",
3690 "-motion-blur geometry",
3691 " simulate motion blur",
3692 "-negate replace every pixel with its complementary color ",
3693 "-noise radius add or reduce noise in an image",
3694 "-normalize transform image to span the full range of colors",
3695 "-opaque color change this color to the fill color",
3696 "-ordered-dither NxN",
3697 " add a noise pattern to the image with specific",
3699 "-paint radius simulate an oil painting",
3700 "-polaroid angle simulate a Polaroid picture",
3701 "-posterize levels reduce the image to a limited number of color levels",
3702 "-profile filename add, delete, or apply an image profile",
3703 "-quantize colorspace reduce colors in this colorspace",
3704 "-radial-blur angle radial blur the image",
3705 "-raise value lighten/darken image edges to create a 3-D effect",
3706 "-random-threshold low,high",
3707 " random threshold the image",
3708 "-region geometry apply options to a portion of the image",
3709 "-render render vector graphics",
3710 "-repage geometry size and location of an image canvas",
3711 "-resample geometry change the resolution of an image",
3712 "-resize geometry resize the image",
3713 "-roll geometry roll an image vertically or horizontally",
3714 "-rotate degrees apply Paeth rotation to the image",
3715 "-sample geometry scale image with pixel sampling",
3716 "-scale geometry scale the image",
3717 "-segment values segment an image",
3718 "-selective-blur geometry",
3719 " selectively blur pixels within a contrast threshold",
3720 "-sepia-tone threshold",
3721 " simulate a sepia-toned photo",
3722 "-set property value set an image property",
3723 "-shade degrees shade the image using a distant light source",
3724 "-shadow geometry simulate an image shadow",
3725 "-sharpen geometry sharpen the image",
3726 "-shave geometry shave pixels from the image edges",
3727 "-shear geometry slide one edge of the image along the X or Y axis",
3728 "-sigmoidal-contrast geometry",
3729 " increase the contrast without saturating highlights or shadows",
3730 "-sketch geometry simulate a pencil sketch",
3731 "-solarize threshold negate all pixels above the threshold level",
3732 "-sparse-color method args",
3733 " fill in a image based on a few color points",
3734 "-splice geometry splice the background color into the image",
3735 "-spread radius displace image pixels by a random amount",
3736 "-strip strip image of all profiles and comments",
3737 "-swirl degrees swirl image pixels about the center",
3738 "-threshold value threshold the image",
3739 "-thumbnail geometry create a thumbnail of the image",
3740 "-tile filename tile image when filling a graphic primitive",
3741 "-tint value tint the image with the fill color",
3742 "-transform affine transform image",
3743 "-transparent color make this color transparent within the image",
3744 "-transpose flip image vertically and rotate 90 degrees",
3745 "-transverse flop image horizontally and rotate 270 degrees",
3746 "-trim trim image edges",
3747 "-type type image type",
3748 "-unique-colors discard all but one of any pixel color",
3749 "-unsharp geometry sharpen the image",
3750 "-vignette geometry soften the edges of the image in vignette style",
3751 "-wave geometry alter an image along a sine wave",
3752 "-white-threshold value",
3753 " force all pixels above the threshold into white",
3756 *sequence_operators[]=
3758 "-append append an image sequence",
3759 "-clut apply a color lookup table to the image",
3760 "-coalesce merge a sequence of images",
3761 "-combine combine a sequence of images",
3762 "-composite composite image",
3763 "-crop geometry cut out a rectangular region of the image",
3764 "-deconstruct break down an image sequence into constituent parts",
3765 "-evaluate-sequence operator",
3766 " evaluate an arithmetic, relational, or logical expression",
3767 "-flatten flatten a sequence of images",
3768 "-fx expression apply mathematical expression to an image channel(s)",
3769 "-hald-clut apply a Hald color lookup table to the image",
3770 "-morph value morph an image sequence",
3771 "-mosaic create a mosaic from an image sequence",
3772 "-print string interpret string and print to console",
3773 "-process arguments process the image with a custom image filter",
3774 "-reverse reverse image sequence",
3775 "-separate separate an image channel into a grayscale image",
3776 "-write filename write images to this file",
3781 "-adjoin join images into a single multi-image file",
3782 "-affine matrix affine transform matrix",
3783 "-alpha option activate, deactivate, reset, or set the alpha channel",
3784 "-antialias remove pixel-aliasing",
3785 "-authenticate password",
3786 " decipher image with this password",
3787 "-attenuate value lessen (or intensify) when adding noise to an image",
3788 "-background color background color",
3789 "-bias value add bias when convolving an image",
3790 "-black-point-compensation",
3791 " use black point compensation",
3792 "-blue-primary point chromaticity blue primary point",
3793 "-bordercolor color border color",
3794 "-caption string assign a caption to an image",
3795 "-channel type apply option to select image channels",
3796 "-colors value preferred number of colors in the image",
3797 "-colorspace type alternate image colorspace",
3798 "-comment string annotate image with comment",
3799 "-compose operator set image composite operator",
3800 "-compress type type of pixel compression when writing the image",
3801 "-define format:option",
3802 " define one or more image format options",
3803 "-delay value display the next image after pausing",
3804 "-density geometry horizontal and vertical density of the image",
3805 "-depth value image depth",
3806 "-direction type render text right-to-left or left-to-right",
3807 "-display server get image or font from this X server",
3808 "-dispose method layer disposal method",
3809 "-dither method apply error diffusion to image",
3810 "-encoding type text encoding type",
3811 "-endian type endianness (MSB or LSB) of the image",
3812 "-family name render text with this font family",
3813 "-fill color color to use when filling a graphic primitive",
3814 "-filter type use this filter when resizing an image",
3815 "-font name render text with this font",
3816 "-format \"string\" output formatted image characteristics",
3817 "-fuzz distance colors within this distance are considered equal",
3818 "-gravity type horizontal and vertical text placement",
3819 "-green-primary point chromaticity green primary point",
3820 "-intent type type of rendering intent when managing the image color",
3821 "-interlace type type of image interlacing scheme",
3822 "-interline-spacing value",
3823 " set the space between two text lines",
3824 "-interpolate method pixel color interpolation method",
3825 "-interword-spacing value",
3826 " set the space between two words",
3827 "-kerning value set the space between two letters",
3828 "-label string assign a label to an image",
3829 "-limit type value pixel cache resource limit",
3830 "-loop iterations add Netscape loop extension to your GIF animation",
3831 "-mask filename associate a mask with the image",
3832 "-mattecolor color frame color",
3833 "-monitor monitor progress",
3834 "-orient type image orientation",
3835 "-page geometry size and location of an image canvas (setting)",
3836 "-ping efficiently determine image attributes",
3837 "-pointsize value font point size",
3838 "-precision value maximum number of significant digits to print",
3839 "-preview type image preview type",
3840 "-quality value JPEG/MIFF/PNG compression level",
3841 "-quiet suppress all warning messages",
3842 "-red-primary point chromaticity red primary point",
3843 "-regard-warnings pay attention to warning messages",
3844 "-remap filename transform image colors to match this set of colors",
3845 "-respect-parentheses settings remain in effect until parenthesis boundary",
3846 "-sampling-factor geometry",
3847 " horizontal and vertical sampling factor",
3848 "-scene value image scene number",
3849 "-seed value seed a new sequence of pseudo-random numbers",
3850 "-size geometry width and height of image",
3851 "-stretch type render text with this font stretch",
3852 "-stroke color graphic primitive stroke color",
3853 "-strokewidth value graphic primitive stroke width",
3854 "-style type render text with this font style",
3855 "-taint image as ineligible for bi-modal delegate",
3856 "-texture filename name of texture to tile onto the image background",
3857 "-tile-offset geometry",
3859 "-treedepth value color tree depth",
3860 "-transparent-color color",
3861 " transparent color",
3862 "-undercolor color annotation bounding box color",
3863 "-units type the units of image resolution",
3864 "-verbose print detailed information about the image",
3865 "-view FlashPix viewing transforms",
3866 "-virtual-pixel method",
3867 " virtual pixel access method",
3868 "-weight type render text with this font weight",
3869 "-white-point point chromaticity white point",
3874 "-clone index clone an image",
3875 "-delete index delete the image from the image sequence",
3876 "-insert index insert last image into the image sequence",
3877 "-swap indexes swap two images in the image sequence",
3884 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3885 (void) printf("Copyright: %s\n",GetMagickCopyright());
3886 (void) printf("Features: %s\n\n",GetMagickFeatures());
3887 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3889 (void) printf("\nImage Settings:\n");
3890 for (p=settings; *p != (char *) NULL; p++)
3891 (void) printf(" %s\n",*p);
3892 (void) printf("\nImage Operators:\n");
3893 for (p=operators; *p != (char *) NULL; p++)
3894 (void) printf(" %s\n",*p);
3895 (void) printf("\nImage Sequence Operators:\n");
3896 for (p=sequence_operators; *p != (char *) NULL; p++)
3897 (void) printf(" %s\n",*p);
3898 (void) printf("\nImage Stack Operators:\n");
3899 for (p=stack_operators; *p != (char *) NULL; p++)
3900 (void) printf(" %s\n",*p);
3901 (void) printf("\nMiscellaneous Options:\n");
3902 for (p=miscellaneous; *p != (char *) NULL; p++)
3903 (void) printf(" %s\n",*p);
3905 "\nBy default, the image format of `file' is determined by its magic\n");
3907 "number. To specify a particular image format, precede the filename\n");
3909 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3911 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3912 (void) printf("'-' for standard input or output.\n");
3913 return(MagickFalse);
3916 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3917 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3919 #define DestroyMogrify() \
3921 if (format != (char *) NULL) \
3922 format=DestroyString(format); \
3923 if (path != (char *) NULL) \
3924 path=DestroyString(path); \
3925 DestroyImageStack(); \
3926 for (i=0; i < (ssize_t) argc; i++) \
3927 argv[i]=DestroyString(argv[i]); \
3928 argv=(char **) RelinquishMagickMemory(argv); \
3930 #define ThrowMogrifyException(asperity,tag,option) \
3932 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3935 return(MagickFalse); \
3937 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3939 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3940 "InvalidArgument","`%s': %s",argument,option); \
3942 return(MagickFalse); \
3954 image_stack[MaxImageStackDepth+1];
3976 assert(image_info != (ImageInfo *) NULL);
3977 assert(image_info->signature == MagickSignature);
3978 if (image_info->debug != MagickFalse)
3979 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3980 assert(exception != (ExceptionInfo *) NULL);
3984 if ((LocaleCompare("version",option+1) == 0) ||
3985 (LocaleCompare("-version",option+1) == 0))
3987 (void) fprintf(stdout,"Version: %s\n",
3988 GetMagickVersion((size_t *) NULL));
3989 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
3990 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
3991 return(MagickFalse);
3995 return(MogrifyUsage());
3996 format=(char *) NULL;
3998 global_colormap=MagickFalse;
4002 option=(char *) NULL;
4008 ReadCommandlLine(argc,&argv);
4009 status=ExpandFilenames(&argc,&argv);
4010 if (status == MagickFalse)
4011 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4012 GetExceptionMessage(errno));
4013 for (i=1; i < (ssize_t) argc; i++)
4016 if (LocaleCompare(option,"(") == 0)
4018 FireImageStack(MagickFalse,MagickTrue,pend);
4019 if (k == MaxImageStackDepth)
4020 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4025 if (LocaleCompare(option,")") == 0)
4027 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4029 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4033 if (IsMagickOption(option) == MagickFalse)
4036 backup_filename[MaxTextExtent],
4043 Option is a file name: begin by reading image from specified file.
4045 FireImageStack(MagickFalse,MagickFalse,pend);
4047 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
4049 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4050 images=ReadImages(image_info,exception);
4051 status&=(images != (Image *) NULL) &&
4052 (exception->severity < ErrorException);
4053 if (images == (Image *) NULL)
4055 if (path != (char *) NULL)
4057 GetPathComponent(option,TailPath,filename);
4058 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4059 path,*DirectorySeparator,filename);
4061 if (format != (char *) NULL)
4062 AppendImageFormat(format,images->filename);
4063 AppendImageStack(images);
4064 FinalizeImageSettings(image_info,image,MagickFalse);
4065 if (global_colormap != MagickFalse)
4070 quantize_info=AcquireQuantizeInfo(image_info);
4071 (void) RemapImages(quantize_info,images,(Image *) NULL);
4072 quantize_info=DestroyQuantizeInfo(quantize_info);
4074 *backup_filename='\0';
4075 if ((LocaleCompare(image->filename,"-") != 0) &&
4076 (IsPathWritable(image->filename) != MagickFalse))
4082 Rename image file as backup.
4084 (void) CopyMagickString(backup_filename,image->filename,
4086 for (i=0; i < 6; i++)
4088 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4089 if (IsPathAccessible(backup_filename) == MagickFalse)
4092 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4093 (rename(image->filename,backup_filename) != 0))
4094 *backup_filename='\0';
4097 Write transmogrified image to disk.
4099 image_info->synchronize=MagickTrue;
4100 status&=WriteImages(image_info,image,image->filename,exception);
4101 if ((status == MagickFalse) && (*backup_filename != '\0'))
4102 (void) remove(backup_filename);
4103 RemoveAllImageStack();
4106 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4107 switch (*(option+1))
4111 if (LocaleCompare("adaptive-blur",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 if (IsGeometry(argv[i]) == MagickFalse)
4117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4120 if (LocaleCompare("adaptive-resize",option+1) == 0)
4123 if (i == (ssize_t) argc)
4124 ThrowMogrifyException(OptionError,"MissingArgument",option);
4125 if (IsGeometry(argv[i]) == MagickFalse)
4126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4129 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4132 if (i == (ssize_t) argc)
4133 ThrowMogrifyException(OptionError,"MissingArgument",option);
4134 if (IsGeometry(argv[i]) == MagickFalse)
4135 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4138 if (LocaleCompare("affine",option+1) == 0)
4143 if (i == (ssize_t) argc)
4144 ThrowMogrifyException(OptionError,"MissingArgument",option);
4145 if (IsGeometry(argv[i]) == MagickFalse)
4146 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4149 if (LocaleCompare("alpha",option+1) == 0)
4157 if (i == (ssize_t) argc)
4158 ThrowMogrifyException(OptionError,"MissingArgument",option);
4159 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4161 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4165 if (LocaleCompare("annotate",option+1) == 0)
4170 if (i == (ssize_t) argc)
4171 ThrowMogrifyException(OptionError,"MissingArgument",option);
4172 if (IsGeometry(argv[i]) == MagickFalse)
4173 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4174 if (i == (ssize_t) argc)
4175 ThrowMogrifyException(OptionError,"MissingArgument",option);
4179 if (LocaleCompare("antialias",option+1) == 0)
4181 if (LocaleCompare("append",option+1) == 0)
4183 if (LocaleCompare("attenuate",option+1) == 0)
4188 if (i == (ssize_t) (argc-1))
4189 ThrowMogrifyException(OptionError,"MissingArgument",option);
4190 if (IsGeometry(argv[i]) == MagickFalse)
4191 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 if (LocaleCompare("authenticate",option+1) == 0)
4199 if (i == (ssize_t) argc)
4200 ThrowMogrifyException(OptionError,"MissingArgument",option);
4203 if (LocaleCompare("auto-gamma",option+1) == 0)
4205 if (LocaleCompare("auto-level",option+1) == 0)
4207 if (LocaleCompare("auto-orient",option+1) == 0)
4209 if (LocaleCompare("average",option+1) == 0)
4211 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4215 if (LocaleCompare("background",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4224 if (LocaleCompare("bias",option+1) == 0)
4229 if (i == (ssize_t) (argc-1))
4230 ThrowMogrifyException(OptionError,"MissingArgument",option);
4231 if (IsGeometry(argv[i]) == MagickFalse)
4232 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4235 if (LocaleCompare("black-point-compensation",option+1) == 0)
4237 if (LocaleCompare("black-threshold",option+1) == 0)
4242 if (i == (ssize_t) argc)
4243 ThrowMogrifyException(OptionError,"MissingArgument",option);
4244 if (IsGeometry(argv[i]) == MagickFalse)
4245 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4248 if (LocaleCompare("blue-primary",option+1) == 0)
4253 if (i == (ssize_t) argc)
4254 ThrowMogrifyException(OptionError,"MissingArgument",option);
4255 if (IsGeometry(argv[i]) == MagickFalse)
4256 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4259 if (LocaleCompare("blue-shift",option+1) == 0)
4262 if (i == (ssize_t) argc)
4263 ThrowMogrifyException(OptionError,"MissingArgument",option);
4264 if (IsGeometry(argv[i]) == MagickFalse)
4265 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4268 if (LocaleCompare("blur",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,"MissingArgument",option);
4273 if (IsGeometry(argv[i]) == MagickFalse)
4274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4277 if (LocaleCompare("border",option+1) == 0)
4282 if (i == (ssize_t) argc)
4283 ThrowMogrifyException(OptionError,"MissingArgument",option);
4284 if (IsGeometry(argv[i]) == MagickFalse)
4285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4288 if (LocaleCompare("bordercolor",option+1) == 0)
4293 if (i == (ssize_t) argc)
4294 ThrowMogrifyException(OptionError,"MissingArgument",option);
4297 if (LocaleCompare("box",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4306 if (LocaleCompare("brightness-contrast",option+1) == 0)
4309 if (i == (ssize_t) argc)
4310 ThrowMogrifyException(OptionError,"MissingArgument",option);
4311 if (IsGeometry(argv[i]) == MagickFalse)
4312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4315 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4319 if (LocaleCompare("cache",option+1) == 0)
4324 if (i == (ssize_t) argc)
4325 ThrowMogrifyException(OptionError,"MissingArgument",option);
4326 if (IsGeometry(argv[i]) == MagickFalse)
4327 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4330 if (LocaleCompare("caption",option+1) == 0)
4335 if (i == (ssize_t) argc)
4336 ThrowMogrifyException(OptionError,"MissingArgument",option);
4339 if (LocaleCompare("channel",option+1) == 0)
4347 if (i == (ssize_t) (argc-1))
4348 ThrowMogrifyException(OptionError,"MissingArgument",option);
4349 channel=ParseChannelOption(argv[i]);
4351 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4355 if (LocaleCompare("cdl",option+1) == 0)
4360 if (i == (ssize_t) (argc-1))
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4364 if (LocaleCompare("charcoal",option+1) == 0)
4369 if (i == (ssize_t) argc)
4370 ThrowMogrifyException(OptionError,"MissingArgument",option);
4371 if (IsGeometry(argv[i]) == MagickFalse)
4372 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4375 if (LocaleCompare("chop",option+1) == 0)
4380 if (i == (ssize_t) argc)
4381 ThrowMogrifyException(OptionError,"MissingArgument",option);
4382 if (IsGeometry(argv[i]) == MagickFalse)
4383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4386 if (LocaleCompare("clamp",option+1) == 0)
4388 if (LocaleCompare("clip",option+1) == 0)
4390 if (LocaleCompare("clip-mask",option+1) == 0)
4395 if (i == (ssize_t) argc)
4396 ThrowMogrifyException(OptionError,"MissingArgument",option);
4399 if (LocaleCompare("clut",option+1) == 0)
4401 if (LocaleCompare("coalesce",option+1) == 0)
4403 if (LocaleCompare("colorize",option+1) == 0)
4408 if (i == (ssize_t) argc)
4409 ThrowMogrifyException(OptionError,"MissingArgument",option);
4410 if (IsGeometry(argv[i]) == MagickFalse)
4411 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4414 if (LocaleCompare("color-matrix",option+1) == 0)
4419 if (i == (ssize_t) (argc-1))
4420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4421 if (IsGeometry(argv[i]) == MagickFalse)
4422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4425 if (LocaleCompare("colors",option+1) == 0)
4430 if (i == (ssize_t) argc)
4431 ThrowMogrifyException(OptionError,"MissingArgument",option);
4432 if (IsGeometry(argv[i]) == MagickFalse)
4433 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4436 if (LocaleCompare("colorspace",option+1) == 0)
4444 if (i == (ssize_t) argc)
4445 ThrowMogrifyException(OptionError,"MissingArgument",option);
4446 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4449 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4453 if (LocaleCompare("combine",option+1) == 0)
4455 if (LocaleCompare("comment",option+1) == 0)
4460 if (i == (ssize_t) argc)
4461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4464 if (LocaleCompare("composite",option+1) == 0)
4466 if (LocaleCompare("compress",option+1) == 0)
4474 if (i == (ssize_t) argc)
4475 ThrowMogrifyException(OptionError,"MissingArgument",option);
4476 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4479 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4483 if (LocaleCompare("concurrent",option+1) == 0)
4485 if (LocaleCompare("contrast",option+1) == 0)
4487 if (LocaleCompare("contrast-stretch",option+1) == 0)
4490 if (i == (ssize_t) argc)
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 if (IsGeometry(argv[i]) == MagickFalse)
4493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4496 if (LocaleCompare("convolve",option+1) == 0)
4499 token[MaxTextExtent];
4504 if (i == (ssize_t) argc)
4505 ThrowMogrifyException(OptionError,"MissingArgument",option);
4508 if (IsGeometry(argv[i]) == MagickFalse)
4509 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4511 /* Allow the use of built-in kernels like 'gaussian'
4512 * These may not work for kernels with 'nan' values, like 'diamond'
4514 GetMagickToken(argv[i],NULL,token);
4515 if ( isalpha((int)token[0]) )
4520 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
4522 ThrowMogrifyException(OptionError,"UnrecognizedKernelType",
4525 /* geometry current returns invalid if 'nan' values are used */
4526 else if (IsGeometry(argv[i]) == MagickFalse)
4527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4531 if (LocaleCompare("crop",option+1) == 0)
4536 if (i == (ssize_t) argc)
4537 ThrowMogrifyException(OptionError,"MissingArgument",option);
4538 if (IsGeometry(argv[i]) == MagickFalse)
4539 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4542 if (LocaleCompare("cycle",option+1) == 0)
4547 if (i == (ssize_t) argc)
4548 ThrowMogrifyException(OptionError,"MissingArgument",option);
4549 if (IsGeometry(argv[i]) == MagickFalse)
4550 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4553 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4557 if (LocaleCompare("decipher",option+1) == 0)
4562 if (i == (ssize_t) (argc-1))
4563 ThrowMogrifyException(OptionError,"MissingArgument",option);
4566 if (LocaleCompare("deconstruct",option+1) == 0)
4568 if (LocaleCompare("debug",option+1) == 0)
4576 if (i == (ssize_t) argc)
4577 ThrowMogrifyException(OptionError,"MissingArgument",option);
4578 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4580 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4582 (void) SetLogEventMask(argv[i]);
4585 if (LocaleCompare("define",option+1) == 0)
4588 if (i == (ssize_t) argc)
4589 ThrowMogrifyException(OptionError,"MissingArgument",option);
4595 define=GetImageOption(image_info,argv[i]);
4596 if (define == (const char *) NULL)
4597 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4602 if (LocaleCompare("delay",option+1) == 0)
4607 if (i == (ssize_t) argc)
4608 ThrowMogrifyException(OptionError,"MissingArgument",option);
4609 if (IsGeometry(argv[i]) == MagickFalse)
4610 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4613 if (LocaleCompare("density",option+1) == 0)
4618 if (i == (ssize_t) argc)
4619 ThrowMogrifyException(OptionError,"MissingArgument",option);
4620 if (IsGeometry(argv[i]) == MagickFalse)
4621 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4624 if (LocaleCompare("depth",option+1) == 0)
4629 if (i == (ssize_t) argc)
4630 ThrowMogrifyException(OptionError,"MissingArgument",option);
4631 if (IsGeometry(argv[i]) == MagickFalse)
4632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4635 if (LocaleCompare("deskew",option+1) == 0)
4640 if (i == (ssize_t) argc)
4641 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4646 if (LocaleCompare("despeckle",option+1) == 0)
4648 if (LocaleCompare("dft",option+1) == 0)
4650 if (LocaleCompare("direction",option+1) == 0)
4658 if (i == (ssize_t) argc)
4659 ThrowMogrifyException(OptionError,"MissingArgument",option);
4660 direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
4663 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4667 if (LocaleCompare("display",option+1) == 0)
4672 if (i == (ssize_t) argc)
4673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4676 if (LocaleCompare("dispose",option+1) == 0)
4684 if (i == (ssize_t) argc)
4685 ThrowMogrifyException(OptionError,"MissingArgument",option);
4686 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4688 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4692 if (LocaleCompare("distort",option+1) == 0)
4698 if (i == (ssize_t) argc)
4699 ThrowMogrifyException(OptionError,"MissingArgument",option);
4700 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4702 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4705 if (i == (ssize_t) (argc-1))
4706 ThrowMogrifyException(OptionError,"MissingArgument",option);
4709 if (LocaleCompare("dither",option+1) == 0)
4717 if (i == (ssize_t) argc)
4718 ThrowMogrifyException(OptionError,"MissingArgument",option);
4719 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4721 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4725 if (LocaleCompare("draw",option+1) == 0)
4730 if (i == (ssize_t) argc)
4731 ThrowMogrifyException(OptionError,"MissingArgument",option);
4734 if (LocaleCompare("duration",option+1) == 0)
4739 if (i == (ssize_t) (argc-1))
4740 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 if (IsGeometry(argv[i]) == MagickFalse)
4742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4745 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4749 if (LocaleCompare("edge",option+1) == 0)
4754 if (i == (ssize_t) argc)
4755 ThrowMogrifyException(OptionError,"MissingArgument",option);
4756 if (IsGeometry(argv[i]) == MagickFalse)
4757 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4760 if (LocaleCompare("emboss",option+1) == 0)
4765 if (i == (ssize_t) argc)
4766 ThrowMogrifyException(OptionError,"MissingArgument",option);
4767 if (IsGeometry(argv[i]) == MagickFalse)
4768 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4771 if (LocaleCompare("encipher",option+1) == 0)
4776 if (i == (ssize_t) argc)
4777 ThrowMogrifyException(OptionError,"MissingArgument",option);
4780 if (LocaleCompare("encoding",option+1) == 0)
4785 if (i == (ssize_t) argc)
4786 ThrowMogrifyException(OptionError,"MissingArgument",option);
4789 if (LocaleCompare("endian",option+1) == 0)
4797 if (i == (ssize_t) argc)
4798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4801 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4805 if (LocaleCompare("enhance",option+1) == 0)
4807 if (LocaleCompare("equalize",option+1) == 0)
4809 if (LocaleCompare("evaluate",option+1) == 0)
4817 if (i == (ssize_t) argc)
4818 ThrowMogrifyException(OptionError,"MissingArgument",option);
4819 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4821 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4824 if (i == (ssize_t) (argc-1))
4825 ThrowMogrifyException(OptionError,"MissingArgument",option);
4826 if (IsGeometry(argv[i]) == MagickFalse)
4827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4830 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4838 if (i == (ssize_t) argc)
4839 ThrowMogrifyException(OptionError,"MissingArgument",option);
4840 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4842 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4846 if (LocaleCompare("extent",option+1) == 0)
4851 if (i == (ssize_t) argc)
4852 ThrowMogrifyException(OptionError,"MissingArgument",option);
4853 if (IsGeometry(argv[i]) == MagickFalse)
4854 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4857 if (LocaleCompare("extract",option+1) == 0)
4862 if (i == (ssize_t) argc)
4863 ThrowMogrifyException(OptionError,"MissingArgument",option);
4864 if (IsGeometry(argv[i]) == MagickFalse)
4865 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4868 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4872 if (LocaleCompare("family",option+1) == 0)
4877 if (i == (ssize_t) (argc-1))
4878 ThrowMogrifyException(OptionError,"MissingArgument",option);
4881 if (LocaleCompare("fill",option+1) == 0)
4886 if (i == (ssize_t) argc)
4887 ThrowMogrifyException(OptionError,"MissingArgument",option);
4890 if (LocaleCompare("filter",option+1) == 0)
4898 if (i == (ssize_t) argc)
4899 ThrowMogrifyException(OptionError,"MissingArgument",option);
4900 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4902 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4906 if (LocaleCompare("flatten",option+1) == 0)
4908 if (LocaleCompare("flip",option+1) == 0)
4910 if (LocaleCompare("flop",option+1) == 0)
4912 if (LocaleCompare("floodfill",option+1) == 0)
4917 if (i == (ssize_t) argc)
4918 ThrowMogrifyException(OptionError,"MissingArgument",option);
4919 if (IsGeometry(argv[i]) == MagickFalse)
4920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 if (LocaleCompare("font",option+1) == 0)
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,"MissingArgument",option);
4935 if (LocaleCompare("format",option+1) == 0)
4937 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4938 (void) CloneString(&format,(char *) NULL);
4942 if (i == (ssize_t) argc)
4943 ThrowMogrifyException(OptionError,"MissingArgument",option);
4944 (void) CloneString(&format,argv[i]);
4945 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4946 (void) ConcatenateMagickString(image_info->filename,":",
4948 (void) SetImageInfo(image_info,0,exception);
4949 if (*image_info->magick == '\0')
4950 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4954 if (LocaleCompare("frame",option+1) == 0)
4959 if (i == (ssize_t) argc)
4960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4961 if (IsGeometry(argv[i]) == MagickFalse)
4962 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4965 if (LocaleCompare("function",option+1) == 0)
4973 if (i == (ssize_t) argc)
4974 ThrowMogrifyException(OptionError,"MissingArgument",option);
4975 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
4977 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4979 if (i == (ssize_t) (argc-1))
4980 ThrowMogrifyException(OptionError,"MissingArgument",option);
4983 if (LocaleCompare("fuzz",option+1) == 0)
4988 if (i == (ssize_t) argc)
4989 ThrowMogrifyException(OptionError,"MissingArgument",option);
4990 if (IsGeometry(argv[i]) == MagickFalse)
4991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4994 if (LocaleCompare("fx",option+1) == 0)
4999 if (i == (ssize_t) (argc-1))
5000 ThrowMogrifyException(OptionError,"MissingArgument",option);
5003 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5007 if (LocaleCompare("gamma",option+1) == 0)
5010 if (i == (ssize_t) argc)
5011 ThrowMogrifyException(OptionError,"MissingArgument",option);
5012 if (IsGeometry(argv[i]) == MagickFalse)
5013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5016 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5017 (LocaleCompare("gaussian",option+1) == 0))
5020 if (i == (ssize_t) argc)
5021 ThrowMogrifyException(OptionError,"MissingArgument",option);
5022 if (IsGeometry(argv[i]) == MagickFalse)
5023 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5026 if (LocaleCompare("geometry",option+1) == 0)
5031 if (i == (ssize_t) argc)
5032 ThrowMogrifyException(OptionError,"MissingArgument",option);
5033 if (IsGeometry(argv[i]) == MagickFalse)
5034 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5037 if (LocaleCompare("gravity",option+1) == 0)
5045 if (i == (ssize_t) argc)
5046 ThrowMogrifyException(OptionError,"MissingArgument",option);
5047 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5049 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5053 if (LocaleCompare("green-primary",option+1) == 0)
5058 if (i == (ssize_t) argc)
5059 ThrowMogrifyException(OptionError,"MissingArgument",option);
5060 if (IsGeometry(argv[i]) == MagickFalse)
5061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5064 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5068 if (LocaleCompare("hald-clut",option+1) == 0)
5070 if ((LocaleCompare("help",option+1) == 0) ||
5071 (LocaleCompare("-help",option+1) == 0))
5072 return(MogrifyUsage());
5073 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5077 if (LocaleCompare("identify",option+1) == 0)
5079 if (LocaleCompare("idft",option+1) == 0)
5081 if (LocaleCompare("implode",option+1) == 0)
5086 if (i == (ssize_t) argc)
5087 ThrowMogrifyException(OptionError,"MissingArgument",option);
5088 if (IsGeometry(argv[i]) == MagickFalse)
5089 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5092 if (LocaleCompare("intent",option+1) == 0)
5100 if (i == (ssize_t) (argc-1))
5101 ThrowMogrifyException(OptionError,"MissingArgument",option);
5102 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5104 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5108 if (LocaleCompare("interlace",option+1) == 0)
5116 if (i == (ssize_t) argc)
5117 ThrowMogrifyException(OptionError,"MissingArgument",option);
5118 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5121 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5125 if (LocaleCompare("interline-spacing",option+1) == 0)
5130 if (i == (ssize_t) (argc-1))
5131 ThrowMogrifyException(OptionError,"MissingArgument",option);
5132 if (IsGeometry(argv[i]) == MagickFalse)
5133 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5136 if (LocaleCompare("interpolate",option+1) == 0)
5144 if (i == (ssize_t) argc)
5145 ThrowMogrifyException(OptionError,"MissingArgument",option);
5146 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5148 if (interpolate < 0)
5149 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5153 if (LocaleCompare("interword-spacing",option+1) == 0)
5158 if (i == (ssize_t) (argc-1))
5159 ThrowMogrifyException(OptionError,"MissingArgument",option);
5160 if (IsGeometry(argv[i]) == MagickFalse)
5161 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5164 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5168 if (LocaleCompare("kerning",option+1) == 0)
5173 if (i == (ssize_t) (argc-1))
5174 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 if (IsGeometry(argv[i]) == MagickFalse)
5176 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5179 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5183 if (LocaleCompare("label",option+1) == 0)
5188 if (i == (ssize_t) argc)
5189 ThrowMogrifyException(OptionError,"MissingArgument",option);
5192 if (LocaleCompare("lat",option+1) == 0)
5197 if (i == (ssize_t) argc)
5198 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 if (IsGeometry(argv[i]) == MagickFalse)
5200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5202 if (LocaleCompare("layers",option+1) == 0)
5210 if (i == (ssize_t) (argc-1))
5211 ThrowMogrifyException(OptionError,"MissingArgument",option);
5212 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5214 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5218 if (LocaleCompare("level",option+1) == 0)
5221 if (i == (ssize_t) argc)
5222 ThrowMogrifyException(OptionError,"MissingArgument",option);
5223 if (IsGeometry(argv[i]) == MagickFalse)
5224 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5227 if (LocaleCompare("level-colors",option+1) == 0)
5230 if (i == (ssize_t) argc)
5231 ThrowMogrifyException(OptionError,"MissingArgument",option);
5234 if (LocaleCompare("linewidth",option+1) == 0)
5239 if (i == (ssize_t) argc)
5240 ThrowMogrifyException(OptionError,"MissingArgument",option);
5241 if (IsGeometry(argv[i]) == MagickFalse)
5242 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5245 if (LocaleCompare("limit",option+1) == 0)
5259 if (i == (ssize_t) argc)
5260 ThrowMogrifyException(OptionError,"MissingArgument",option);
5261 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5264 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,"MissingArgument",option);
5269 value=strtod(argv[i],&p);
5270 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5271 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5274 if (LocaleCompare("liquid-rescale",option+1) == 0)
5277 if (i == (ssize_t) argc)
5278 ThrowMogrifyException(OptionError,"MissingArgument",option);
5279 if (IsGeometry(argv[i]) == MagickFalse)
5280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5283 if (LocaleCompare("list",option+1) == 0)
5291 if (i == (ssize_t) argc)
5292 ThrowMogrifyException(OptionError,"MissingArgument",option);
5293 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5295 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5296 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5298 return(status != 0 ? MagickFalse : MagickTrue);
5300 if (LocaleCompare("log",option+1) == 0)
5305 if ((i == (ssize_t) argc) ||
5306 (strchr(argv[i],'%') == (char *) NULL))
5307 ThrowMogrifyException(OptionError,"MissingArgument",option);
5310 if (LocaleCompare("loop",option+1) == 0)
5315 if (i == (ssize_t) argc)
5316 ThrowMogrifyException(OptionError,"MissingArgument",option);
5317 if (IsGeometry(argv[i]) == MagickFalse)
5318 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5321 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5325 if (LocaleCompare("map",option+1) == 0)
5327 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5331 if (i == (ssize_t) argc)
5332 ThrowMogrifyException(OptionError,"MissingArgument",option);
5335 if (LocaleCompare("mask",option+1) == 0)
5340 if (i == (ssize_t) argc)
5341 ThrowMogrifyException(OptionError,"MissingArgument",option);
5344 if (LocaleCompare("matte",option+1) == 0)
5346 if (LocaleCompare("mattecolor",option+1) == 0)
5351 if (i == (ssize_t) argc)
5352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5355 if (LocaleCompare("maximum",option+1) == 0)
5357 if (LocaleCompare("minimum",option+1) == 0)
5359 if (LocaleCompare("modulate",option+1) == 0)
5364 if (i == (ssize_t) argc)
5365 ThrowMogrifyException(OptionError,"MissingArgument",option);
5366 if (IsGeometry(argv[i]) == MagickFalse)
5367 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5370 if (LocaleCompare("median",option+1) == 0)
5375 if (i == (ssize_t) argc)
5376 ThrowMogrifyException(OptionError,"MissingArgument",option);
5377 if (IsGeometry(argv[i]) == MagickFalse)
5378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5381 if (LocaleCompare("monitor",option+1) == 0)
5383 if (LocaleCompare("monochrome",option+1) == 0)
5385 if (LocaleCompare("morph",option+1) == 0)
5390 if (i == (ssize_t) (argc-1))
5391 ThrowMogrifyException(OptionError,"MissingArgument",option);
5392 if (IsGeometry(argv[i]) == MagickFalse)
5393 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5396 if (LocaleCompare("morphology",option+1) == 0)
5402 token[MaxTextExtent];
5405 if (i == (ssize_t) argc)
5406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 GetMagickToken(argv[i],NULL,token);
5408 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5410 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5413 if (i == (ssize_t) (argc-1))
5414 ThrowMogrifyException(OptionError,"MissingArgument",option);
5415 GetMagickToken(argv[i],NULL,token);
5416 if (isalpha((int) ((unsigned char) *token)) != 0)
5418 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
5420 ThrowMogrifyException(OptionError,"UnrecognizedKernelType",
5425 if (LocaleCompare("mosaic",option+1) == 0)
5427 if (LocaleCompare("motion-blur",option+1) == 0)
5432 if (i == (ssize_t) argc)
5433 ThrowMogrifyException(OptionError,"MissingArgument",option);
5434 if (IsGeometry(argv[i]) == MagickFalse)
5435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5438 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5442 if (LocaleCompare("negate",option+1) == 0)
5444 if (LocaleCompare("noise",option+1) == 0)
5447 if (i == (ssize_t) argc)
5448 ThrowMogrifyException(OptionError,"MissingArgument",option);
5454 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5456 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5460 if (IsGeometry(argv[i]) == MagickFalse)
5461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5464 if (LocaleCompare("noop",option+1) == 0)
5466 if (LocaleCompare("normalize",option+1) == 0)
5468 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5472 if (LocaleCompare("opaque",option+1) == 0)
5475 if (i == (ssize_t) argc)
5476 ThrowMogrifyException(OptionError,"MissingArgument",option);
5479 if (LocaleCompare("ordered-dither",option+1) == 0)
5484 if (i == (ssize_t) argc)
5485 ThrowMogrifyException(OptionError,"MissingArgument",option);
5488 if (LocaleCompare("orient",option+1) == 0)
5493 orientation=UndefinedOrientation;
5497 if (i == (ssize_t) (argc-1))
5498 ThrowMogrifyException(OptionError,"MissingArgument",option);
5499 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5501 if (orientation < 0)
5502 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5506 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5510 if (LocaleCompare("page",option+1) == 0)
5515 if (i == (ssize_t) argc)
5516 ThrowMogrifyException(OptionError,"MissingArgument",option);
5519 if (LocaleCompare("paint",option+1) == 0)
5524 if (i == (ssize_t) argc)
5525 ThrowMogrifyException(OptionError,"MissingArgument",option);
5526 if (IsGeometry(argv[i]) == MagickFalse)
5527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5530 if (LocaleCompare("path",option+1) == 0)
5532 (void) CloneString(&path,(char *) NULL);
5536 if (i == (ssize_t) argc)
5537 ThrowMogrifyException(OptionError,"MissingArgument",option);
5538 (void) CloneString(&path,argv[i]);
5541 if (LocaleCompare("pointsize",option+1) == 0)
5546 if (i == (ssize_t) argc)
5547 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 if (IsGeometry(argv[i]) == MagickFalse)
5549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5552 if (LocaleCompare("polaroid",option+1) == 0)
5557 if (i == (ssize_t) argc)
5558 ThrowMogrifyException(OptionError,"MissingArgument",option);
5559 if (IsGeometry(argv[i]) == MagickFalse)
5560 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5563 if (LocaleCompare("posterize",option+1) == 0)
5568 if (i == (ssize_t) argc)
5569 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 if (IsGeometry(argv[i]) == MagickFalse)
5571 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5574 if (LocaleCompare("precision",option+1) == 0)
5579 if (i == (ssize_t) argc)
5580 ThrowMogrifyException(OptionError,"MissingArgument",option);
5581 if (IsGeometry(argv[i]) == MagickFalse)
5582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5585 if (LocaleCompare("print",option+1) == 0)
5590 if (i == (ssize_t) argc)
5591 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (LocaleCompare("process",option+1) == 0)
5599 if (i == (ssize_t) (argc-1))
5600 ThrowMogrifyException(OptionError,"MissingArgument",option);
5603 if (LocaleCompare("profile",option+1) == 0)
5606 if (i == (ssize_t) argc)
5607 ThrowMogrifyException(OptionError,"MissingArgument",option);
5610 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5614 if (LocaleCompare("quality",option+1) == 0)
5619 if (i == (ssize_t) argc)
5620 ThrowMogrifyException(OptionError,"MissingArgument",option);
5621 if (IsGeometry(argv[i]) == MagickFalse)
5622 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5625 if (LocaleCompare("quantize",option+1) == 0)
5633 if (i == (ssize_t) (argc-1))
5634 ThrowMogrifyException(OptionError,"MissingArgument",option);
5635 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5638 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5642 if (LocaleCompare("quiet",option+1) == 0)
5644 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5648 if (LocaleCompare("radial-blur",option+1) == 0)
5651 if (i == (ssize_t) argc)
5652 ThrowMogrifyException(OptionError,"MissingArgument",option);
5653 if (IsGeometry(argv[i]) == MagickFalse)
5654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5657 if (LocaleCompare("raise",option+1) == 0)
5660 if (i == (ssize_t) argc)
5661 ThrowMogrifyException(OptionError,"MissingArgument",option);
5662 if (IsGeometry(argv[i]) == MagickFalse)
5663 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5666 if (LocaleCompare("random-threshold",option+1) == 0)
5671 if (i == (ssize_t) argc)
5672 ThrowMogrifyException(OptionError,"MissingArgument",option);
5673 if (IsGeometry(argv[i]) == MagickFalse)
5674 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5677 if (LocaleCompare("recolor",option+1) == 0)
5682 if (i == (ssize_t) (argc-1))
5683 ThrowMogrifyException(OptionError,"MissingArgument",option);
5684 if (IsGeometry(argv[i]) == MagickFalse)
5685 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5688 if (LocaleCompare("red-primary",option+1) == 0)
5693 if (i == (ssize_t) argc)
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 if (IsGeometry(argv[i]) == MagickFalse)
5696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5698 if (LocaleCompare("regard-warnings",option+1) == 0)
5700 if (LocaleCompare("region",option+1) == 0)
5705 if (i == (ssize_t) argc)
5706 ThrowMogrifyException(OptionError,"MissingArgument",option);
5707 if (IsGeometry(argv[i]) == MagickFalse)
5708 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5711 if (LocaleCompare("remap",option+1) == 0)
5716 if (i == (ssize_t) (argc-1))
5717 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 if (LocaleCompare("render",option+1) == 0)
5722 if (LocaleCompare("repage",option+1) == 0)
5727 if (i == (ssize_t) argc)
5728 ThrowMogrifyException(OptionError,"MissingArgument",option);
5729 if (IsGeometry(argv[i]) == MagickFalse)
5730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5733 if (LocaleCompare("resample",option+1) == 0)
5738 if (i == (ssize_t) argc)
5739 ThrowMogrifyException(OptionError,"MissingArgument",option);
5740 if (IsGeometry(argv[i]) == MagickFalse)
5741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5744 if (LocaleCompare("resize",option+1) == 0)
5749 if (i == (ssize_t) argc)
5750 ThrowMogrifyException(OptionError,"MissingArgument",option);
5751 if (IsGeometry(argv[i]) == MagickFalse)
5752 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5755 if (LocaleCompare("reverse",option+1) == 0)
5757 if (LocaleCompare("roll",option+1) == 0)
5762 if (i == (ssize_t) argc)
5763 ThrowMogrifyException(OptionError,"MissingArgument",option);
5764 if (IsGeometry(argv[i]) == MagickFalse)
5765 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5768 if (LocaleCompare("rotate",option+1) == 0)
5771 if (i == (ssize_t) argc)
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5781 if (LocaleCompare("sample",option+1) == 0)
5786 if (i == (ssize_t) argc)
5787 ThrowMogrifyException(OptionError,"MissingArgument",option);
5788 if (IsGeometry(argv[i]) == MagickFalse)
5789 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5792 if (LocaleCompare("sampling-factor",option+1) == 0)
5797 if (i == (ssize_t) argc)
5798 ThrowMogrifyException(OptionError,"MissingArgument",option);
5799 if (IsGeometry(argv[i]) == MagickFalse)
5800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5803 if (LocaleCompare("scale",option+1) == 0)
5808 if (i == (ssize_t) argc)
5809 ThrowMogrifyException(OptionError,"MissingArgument",option);
5810 if (IsGeometry(argv[i]) == MagickFalse)
5811 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5814 if (LocaleCompare("scene",option+1) == 0)
5819 if (i == (ssize_t) argc)
5820 ThrowMogrifyException(OptionError,"MissingArgument",option);
5821 if (IsGeometry(argv[i]) == MagickFalse)
5822 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5825 if (LocaleCompare("seed",option+1) == 0)
5830 if (i == (ssize_t) argc)
5831 ThrowMogrifyException(OptionError,"MissingArgument",option);
5832 if (IsGeometry(argv[i]) == MagickFalse)
5833 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5836 if (LocaleCompare("segment",option+1) == 0)
5841 if (i == (ssize_t) argc)
5842 ThrowMogrifyException(OptionError,"MissingArgument",option);
5843 if (IsGeometry(argv[i]) == MagickFalse)
5844 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5847 if (LocaleCompare("selective-blur",option+1) == 0)
5850 if (i == (ssize_t) argc)
5851 ThrowMogrifyException(OptionError,"MissingArgument",option);
5852 if (IsGeometry(argv[i]) == MagickFalse)
5853 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5856 if (LocaleCompare("separate",option+1) == 0)
5858 if (LocaleCompare("sepia-tone",option+1) == 0)
5863 if (i == (ssize_t) argc)
5864 ThrowMogrifyException(OptionError,"MissingArgument",option);
5865 if (IsGeometry(argv[i]) == MagickFalse)
5866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5869 if (LocaleCompare("set",option+1) == 0)
5872 if (i == (ssize_t) argc)
5873 ThrowMogrifyException(OptionError,"MissingArgument",option);
5877 if (i == (ssize_t) argc)
5878 ThrowMogrifyException(OptionError,"MissingArgument",option);
5881 if (LocaleCompare("shade",option+1) == 0)
5884 if (i == (ssize_t) argc)
5885 ThrowMogrifyException(OptionError,"MissingArgument",option);
5886 if (IsGeometry(argv[i]) == MagickFalse)
5887 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5890 if (LocaleCompare("shadow",option+1) == 0)
5895 if (i == (ssize_t) argc)
5896 ThrowMogrifyException(OptionError,"MissingArgument",option);
5897 if (IsGeometry(argv[i]) == MagickFalse)
5898 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5901 if (LocaleCompare("sharpen",option+1) == 0)
5904 if (i == (ssize_t) argc)
5905 ThrowMogrifyException(OptionError,"MissingArgument",option);
5906 if (IsGeometry(argv[i]) == MagickFalse)
5907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5910 if (LocaleCompare("shave",option+1) == 0)
5915 if (i == (ssize_t) argc)
5916 ThrowMogrifyException(OptionError,"MissingArgument",option);
5917 if (IsGeometry(argv[i]) == MagickFalse)
5918 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5921 if (LocaleCompare("shear",option+1) == 0)
5924 if (i == (ssize_t) argc)
5925 ThrowMogrifyException(OptionError,"MissingArgument",option);
5926 if (IsGeometry(argv[i]) == MagickFalse)
5927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5930 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5933 if (i == (ssize_t) (argc-1))
5934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 if (IsGeometry(argv[i]) == MagickFalse)
5936 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939 if (LocaleCompare("size",option+1) == 0)
5944 if (i == (ssize_t) argc)
5945 ThrowMogrifyException(OptionError,"MissingArgument",option);
5946 if (IsGeometry(argv[i]) == MagickFalse)
5947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5950 if (LocaleCompare("sketch",option+1) == 0)
5955 if (i == (ssize_t) argc)
5956 ThrowMogrifyException(OptionError,"MissingArgument",option);
5957 if (IsGeometry(argv[i]) == MagickFalse)
5958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5961 if (LocaleCompare("solarize",option+1) == 0)
5966 if (i == (ssize_t) argc)
5967 ThrowMogrifyException(OptionError,"MissingArgument",option);
5968 if (IsGeometry(argv[i]) == MagickFalse)
5969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5972 if (LocaleCompare("sparse-color",option+1) == 0)
5978 if (i == (ssize_t) argc)
5979 ThrowMogrifyException(OptionError,"MissingArgument",option);
5980 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5982 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5985 if (i == (ssize_t) (argc-1))
5986 ThrowMogrifyException(OptionError,"MissingArgument",option);
5989 if (LocaleCompare("spread",option+1) == 0)
5994 if (i == (ssize_t) argc)
5995 ThrowMogrifyException(OptionError,"MissingArgument",option);
5996 if (IsGeometry(argv[i]) == MagickFalse)
5997 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6000 if (LocaleCompare("stretch",option+1) == 0)
6008 if (i == (ssize_t) (argc-1))
6009 ThrowMogrifyException(OptionError,"MissingArgument",option);
6010 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6012 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6016 if (LocaleCompare("strip",option+1) == 0)
6018 if (LocaleCompare("stroke",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6027 if (LocaleCompare("strokewidth",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6034 if (IsGeometry(argv[i]) == MagickFalse)
6035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6038 if (LocaleCompare("style",option+1) == 0)
6046 if (i == (ssize_t) (argc-1))
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6050 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6054 if (LocaleCompare("swirl",option+1) == 0)
6059 if (i == (ssize_t) argc)
6060 ThrowMogrifyException(OptionError,"MissingArgument",option);
6061 if (IsGeometry(argv[i]) == MagickFalse)
6062 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6065 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6069 if (LocaleCompare("taint",option+1) == 0)
6071 if (LocaleCompare("texture",option+1) == 0)
6076 if (i == (ssize_t) argc)
6077 ThrowMogrifyException(OptionError,"MissingArgument",option);
6080 if (LocaleCompare("tile",option+1) == 0)
6085 if (i == (ssize_t) (argc-1))
6086 ThrowMogrifyException(OptionError,"MissingArgument",option);
6089 if (LocaleCompare("tile-offset",option+1) == 0)
6094 if (i == (ssize_t) argc)
6095 ThrowMogrifyException(OptionError,"MissingArgument",option);
6096 if (IsGeometry(argv[i]) == MagickFalse)
6097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6100 if (LocaleCompare("tint",option+1) == 0)
6105 if (i == (ssize_t) (argc-1))
6106 ThrowMogrifyException(OptionError,"MissingArgument",option);
6107 if (IsGeometry(argv[i]) == MagickFalse)
6108 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6111 if (LocaleCompare("transform",option+1) == 0)
6113 if (LocaleCompare("transpose",option+1) == 0)
6115 if (LocaleCompare("transverse",option+1) == 0)
6117 if (LocaleCompare("threshold",option+1) == 0)
6122 if (i == (ssize_t) argc)
6123 ThrowMogrifyException(OptionError,"MissingArgument",option);
6124 if (IsGeometry(argv[i]) == MagickFalse)
6125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6128 if (LocaleCompare("thumbnail",option+1) == 0)
6133 if (i == (ssize_t) argc)
6134 ThrowMogrifyException(OptionError,"MissingArgument",option);
6135 if (IsGeometry(argv[i]) == MagickFalse)
6136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6139 if (LocaleCompare("transparent",option+1) == 0)
6142 if (i == (ssize_t) argc)
6143 ThrowMogrifyException(OptionError,"MissingArgument",option);
6146 if (LocaleCompare("transparent-color",option+1) == 0)
6151 if (i == (ssize_t) (argc-1))
6152 ThrowMogrifyException(OptionError,"MissingArgument",option);
6155 if (LocaleCompare("treedepth",option+1) == 0)
6160 if (i == (ssize_t) argc)
6161 ThrowMogrifyException(OptionError,"MissingArgument",option);
6162 if (IsGeometry(argv[i]) == MagickFalse)
6163 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6166 if (LocaleCompare("trim",option+1) == 0)
6168 if (LocaleCompare("type",option+1) == 0)
6176 if (i == (ssize_t) argc)
6177 ThrowMogrifyException(OptionError,"MissingArgument",option);
6178 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6180 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6184 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6188 if (LocaleCompare("undercolor",option+1) == 0)
6193 if (i == (ssize_t) argc)
6194 ThrowMogrifyException(OptionError,"MissingArgument",option);
6197 if (LocaleCompare("unique-colors",option+1) == 0)
6199 if (LocaleCompare("units",option+1) == 0)
6207 if (i == (ssize_t) argc)
6208 ThrowMogrifyException(OptionError,"MissingArgument",option);
6209 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6212 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6216 if (LocaleCompare("unsharp",option+1) == 0)
6219 if (i == (ssize_t) argc)
6220 ThrowMogrifyException(OptionError,"MissingArgument",option);
6221 if (IsGeometry(argv[i]) == MagickFalse)
6222 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6225 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6229 if (LocaleCompare("verbose",option+1) == 0)
6231 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6234 if ((LocaleCompare("version",option+1) == 0) ||
6235 (LocaleCompare("-version",option+1) == 0))
6237 (void) fprintf(stdout,"Version: %s\n",
6238 GetMagickVersion((size_t *) NULL));
6239 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6240 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
6243 if (LocaleCompare("view",option+1) == 0)
6248 if (i == (ssize_t) argc)
6249 ThrowMogrifyException(OptionError,"MissingArgument",option);
6252 if (LocaleCompare("vignette",option+1) == 0)
6257 if (i == (ssize_t) argc)
6258 ThrowMogrifyException(OptionError,"MissingArgument",option);
6259 if (IsGeometry(argv[i]) == MagickFalse)
6260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6263 if (LocaleCompare("virtual-pixel",option+1) == 0)
6271 if (i == (ssize_t) argc)
6272 ThrowMogrifyException(OptionError,"MissingArgument",option);
6273 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6276 ThrowMogrifyException(OptionError,
6277 "UnrecognizedVirtualPixelMethod",argv[i]);
6280 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6284 if (LocaleCompare("wave",option+1) == 0)
6287 if (i == (ssize_t) argc)
6288 ThrowMogrifyException(OptionError,"MissingArgument",option);
6289 if (IsGeometry(argv[i]) == MagickFalse)
6290 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6293 if (LocaleCompare("weight",option+1) == 0)
6298 if (i == (ssize_t) (argc-1))
6299 ThrowMogrifyException(OptionError,"MissingArgument",option);
6302 if (LocaleCompare("white-point",option+1) == 0)
6307 if (i == (ssize_t) argc)
6308 ThrowMogrifyException(OptionError,"MissingArgument",option);
6309 if (IsGeometry(argv[i]) == MagickFalse)
6310 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6313 if (LocaleCompare("white-threshold",option+1) == 0)
6318 if (i == (ssize_t) argc)
6319 ThrowMogrifyException(OptionError,"MissingArgument",option);
6320 if (IsGeometry(argv[i]) == MagickFalse)
6321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6324 if (LocaleCompare("write",option+1) == 0)
6327 if (i == (ssize_t) (argc-1))
6328 ThrowMogrifyException(OptionError,"MissingArgument",option);
6331 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6336 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6338 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6339 MagickFalse : MagickTrue;
6340 if (fire != MagickFalse)
6341 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6344 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6345 if (i != (ssize_t) argc)
6346 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6348 return(status != 0 ? MagickTrue : MagickFalse);
6352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6356 + M o g r i f y I m a g e I n f o %
6360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6362 % MogrifyImageInfo() applies image processing settings to the image as
6363 % prescribed by command line options.
6365 % The format of the MogrifyImageInfo method is:
6367 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6368 % const char **argv,ExceptionInfo *exception)
6370 % A description of each parameter follows:
6372 % o image_info: the image info..
6374 % o argc: Specifies a pointer to an integer describing the number of
6375 % elements in the argument vector.
6377 % o argv: Specifies a pointer to a text array containing the command line
6380 % o exception: return any errors or warnings in this structure.
6383 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6384 const int argc,const char **argv,ExceptionInfo *exception)
6399 Initialize method variables.
6401 assert(image_info != (ImageInfo *) NULL);
6402 assert(image_info->signature == MagickSignature);
6403 if (image_info->debug != MagickFalse)
6404 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6405 image_info->filename);
6409 Set the image settings.
6411 for (i=0; i < (ssize_t) argc; i++)
6414 if (IsMagickOption(option) == MagickFalse)
6416 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6418 if ((i+count) >= (ssize_t) argc)
6420 switch (*(option+1))
6424 if (LocaleCompare("adjoin",option+1) == 0)
6426 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6429 if (LocaleCompare("antialias",option+1) == 0)
6431 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6434 if (LocaleCompare("attenuate",option+1) == 0)
6438 (void) DeleteImageOption(image_info,option+1);
6441 (void) SetImageOption(image_info,option+1,argv[i+1]);
6444 if (LocaleCompare("authenticate",option+1) == 0)
6447 (void) CloneString(&image_info->authenticate,(char *) NULL);
6449 (void) CloneString(&image_info->authenticate,argv[i+1]);
6456 if (LocaleCompare("background",option+1) == 0)
6460 (void) DeleteImageOption(image_info,option+1);
6461 (void) QueryColorDatabase(BackgroundColor,
6462 &image_info->background_color,exception);
6465 (void) SetImageOption(image_info,option+1,argv[i+1]);
6466 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6470 if (LocaleCompare("bias",option+1) == 0)
6474 (void) SetImageOption(image_info,option+1,"0.0");
6477 (void) SetImageOption(image_info,option+1,argv[i+1]);
6480 if (LocaleCompare("black-point-compensation",option+1) == 0)
6484 (void) SetImageOption(image_info,option+1,"false");
6487 (void) SetImageOption(image_info,option+1,"true");
6490 if (LocaleCompare("blue-primary",option+1) == 0)
6494 (void) SetImageOption(image_info,option+1,"0.0");
6497 (void) SetImageOption(image_info,option+1,argv[i+1]);
6500 if (LocaleCompare("bordercolor",option+1) == 0)
6504 (void) DeleteImageOption(image_info,option+1);
6505 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6509 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6511 (void) SetImageOption(image_info,option+1,argv[i+1]);
6514 if (LocaleCompare("box",option+1) == 0)
6518 (void) SetImageOption(image_info,"undercolor","none");
6521 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6528 if (LocaleCompare("cache",option+1) == 0)
6533 limit=MagickResourceInfinity;
6534 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6535 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6536 (void) SetMagickResourceLimit(MemoryResource,limit);
6537 (void) SetMagickResourceLimit(MapResource,2*limit);
6540 if (LocaleCompare("caption",option+1) == 0)
6544 (void) DeleteImageOption(image_info,option+1);
6547 (void) SetImageOption(image_info,option+1,argv[i+1]);
6550 if (LocaleCompare("channel",option+1) == 0)
6554 image_info->channel=DefaultChannels;
6557 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6560 if (LocaleCompare("colors",option+1) == 0)
6562 image_info->colors=StringToUnsignedLong(argv[i+1]);
6565 if (LocaleCompare("colorspace",option+1) == 0)
6569 image_info->colorspace=UndefinedColorspace;
6570 (void) SetImageOption(image_info,option+1,"undefined");
6573 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6574 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6575 (void) SetImageOption(image_info,option+1,argv[i+1]);
6578 if (LocaleCompare("compress",option+1) == 0)
6582 image_info->compression=UndefinedCompression;
6583 (void) SetImageOption(image_info,option+1,"undefined");
6586 image_info->compression=(CompressionType) ParseMagickOption(
6587 MagickCompressOptions,MagickFalse,argv[i+1]);
6588 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 if (LocaleCompare("comment",option+1) == 0)
6595 (void) DeleteImageOption(image_info,option+1);
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("compose",option+1) == 0)
6605 (void) SetImageOption(image_info,option+1,"undefined");
6608 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 if (LocaleCompare("compress",option+1) == 0)
6615 image_info->compression=UndefinedCompression;
6616 (void) SetImageOption(image_info,option+1,"undefined");
6619 image_info->compression=(CompressionType) ParseMagickOption(
6620 MagickCompressOptions,MagickFalse,argv[i+1]);
6621 (void) SetImageOption(image_info,option+1,argv[i+1]);
6628 if (LocaleCompare("debug",option+1) == 0)
6631 (void) SetLogEventMask("none");
6633 (void) SetLogEventMask(argv[i+1]);
6634 image_info->debug=IsEventLogging();
6637 if (LocaleCompare("define",option+1) == 0)
6641 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6642 (void) DeleteImageRegistry(argv[i+1]+9);
6644 (void) DeleteImageOption(image_info,argv[i+1]);
6647 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6649 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6653 (void) DefineImageOption(image_info,argv[i+1]);
6656 if (LocaleCompare("delay",option+1) == 0)
6660 (void) SetImageOption(image_info,option+1,"0");
6663 (void) SetImageOption(image_info,option+1,argv[i+1]);
6666 if (LocaleCompare("density",option+1) == 0)
6673 if (image_info->density != (char *) NULL)
6674 image_info->density=DestroyString(image_info->density);
6675 (void) SetImageOption(image_info,option+1,"72");
6678 (void) CloneString(&image_info->density,argv[i+1]);
6679 (void) SetImageOption(image_info,option+1,argv[i+1]);
6682 if (LocaleCompare("depth",option+1) == 0)
6686 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6689 image_info->depth=StringToUnsignedLong(argv[i+1]);
6692 if (LocaleCompare("direction",option+1) == 0)
6696 (void) SetImageOption(image_info,option+1,"undefined");
6699 (void) SetImageOption(image_info,option+1,argv[i+1]);
6702 if (LocaleCompare("display",option+1) == 0)
6706 if (image_info->server_name != (char *) NULL)
6707 image_info->server_name=DestroyString(
6708 image_info->server_name);
6711 (void) CloneString(&image_info->server_name,argv[i+1]);
6714 if (LocaleCompare("dispose",option+1) == 0)
6718 (void) SetImageOption(image_info,option+1,"undefined");
6721 (void) SetImageOption(image_info,option+1,argv[i+1]);
6724 if (LocaleCompare("dither",option+1) == 0)
6728 image_info->dither=MagickFalse;
6729 (void) SetImageOption(image_info,option+1,"undefined");
6732 (void) SetImageOption(image_info,option+1,argv[i+1]);
6733 image_info->dither=MagickTrue;
6740 if (LocaleCompare("encoding",option+1) == 0)
6744 (void) SetImageOption(image_info,option+1,"undefined");
6747 (void) SetImageOption(image_info,option+1,argv[i+1]);
6750 if (LocaleCompare("endian",option+1) == 0)
6754 image_info->endian=UndefinedEndian;
6755 (void) SetImageOption(image_info,option+1,"undefined");
6758 image_info->endian=(EndianType) ParseMagickOption(
6759 MagickEndianOptions,MagickFalse,argv[i+1]);
6760 (void) SetImageOption(image_info,option+1,argv[i+1]);
6763 if (LocaleCompare("extract",option+1) == 0)
6766 Set image extract geometry.
6770 if (image_info->extract != (char *) NULL)
6771 image_info->extract=DestroyString(image_info->extract);
6774 (void) CloneString(&image_info->extract,argv[i+1]);
6781 if (LocaleCompare("fill",option+1) == 0)
6785 (void) SetImageOption(image_info,option+1,"none");
6788 (void) SetImageOption(image_info,option+1,argv[i+1]);
6791 if (LocaleCompare("filter",option+1) == 0)
6795 (void) SetImageOption(image_info,option+1,"undefined");
6798 (void) SetImageOption(image_info,option+1,argv[i+1]);
6801 if (LocaleCompare("font",option+1) == 0)
6805 if (image_info->font != (char *) NULL)
6806 image_info->font=DestroyString(image_info->font);
6809 (void) CloneString(&image_info->font,argv[i+1]);
6812 if (LocaleCompare("format",option+1) == 0)
6817 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6818 if (strchr("gkrz@[#",*(q+1)) != (char *) NULL)
6819 image_info->ping=MagickFalse;
6820 (void) SetImageOption(image_info,option+1,argv[i+1]);
6823 if (LocaleCompare("fuzz",option+1) == 0)
6827 image_info->fuzz=0.0;
6828 (void) SetImageOption(image_info,option+1,"0");
6831 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6833 (void) SetImageOption(image_info,option+1,argv[i+1]);
6840 if (LocaleCompare("gravity",option+1) == 0)
6844 (void) SetImageOption(image_info,option+1,"undefined");
6847 (void) SetImageOption(image_info,option+1,argv[i+1]);
6850 if (LocaleCompare("green-primary",option+1) == 0)
6854 (void) SetImageOption(image_info,option+1,"0.0");
6857 (void) SetImageOption(image_info,option+1,argv[i+1]);
6864 if (LocaleCompare("intent",option+1) == 0)
6868 (void) SetImageOption(image_info,option+1,"undefined");
6871 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 if (LocaleCompare("interlace",option+1) == 0)
6878 image_info->interlace=UndefinedInterlace;
6879 (void) SetImageOption(image_info,option+1,"undefined");
6882 image_info->interlace=(InterlaceType) ParseMagickOption(
6883 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6884 (void) SetImageOption(image_info,option+1,argv[i+1]);
6887 if (LocaleCompare("interline-spacing",option+1) == 0)
6891 (void) SetImageOption(image_info,option+1,"undefined");
6894 (void) SetImageOption(image_info,option+1,argv[i+1]);
6897 if (LocaleCompare("interpolate",option+1) == 0)
6901 (void) SetImageOption(image_info,option+1,"undefined");
6904 (void) SetImageOption(image_info,option+1,argv[i+1]);
6907 if (LocaleCompare("interword-spacing",option+1) == 0)
6911 (void) SetImageOption(image_info,option+1,"undefined");
6914 (void) SetImageOption(image_info,option+1,argv[i+1]);
6921 if (LocaleCompare("kerning",option+1) == 0)
6925 (void) SetImageOption(image_info,option+1,"undefined");
6928 (void) SetImageOption(image_info,option+1,argv[i+1]);
6935 if (LocaleCompare("label",option+1) == 0)
6939 (void) DeleteImageOption(image_info,option+1);
6942 (void) SetImageOption(image_info,option+1,argv[i+1]);
6945 if (LocaleCompare("limit",option+1) == 0)
6955 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
6956 MagickFalse,argv[i+1]);
6957 limit=MagickResourceInfinity;
6958 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6959 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6960 (void) SetMagickResourceLimit(type,limit);
6963 if (LocaleCompare("list",option+1) == 0)
6969 Display configuration list.
6971 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
6974 case MagickCoderOptions:
6976 (void) ListCoderInfo((FILE *) NULL,exception);
6979 case MagickColorOptions:
6981 (void) ListColorInfo((FILE *) NULL,exception);
6984 case MagickConfigureOptions:
6986 (void) ListConfigureInfo((FILE *) NULL,exception);
6989 case MagickDelegateOptions:
6991 (void) ListDelegateInfo((FILE *) NULL,exception);
6994 case MagickFontOptions:
6996 (void) ListTypeInfo((FILE *) NULL,exception);
6999 case MagickFormatOptions:
7001 (void) ListMagickInfo((FILE *) NULL,exception);
7004 case MagickLocaleOptions:
7006 (void) ListLocaleInfo((FILE *) NULL,exception);
7009 case MagickLogOptions:
7011 (void) ListLogInfo((FILE *) NULL,exception);
7014 case MagickMagicOptions:
7016 (void) ListMagicInfo((FILE *) NULL,exception);
7019 case MagickMimeOptions:
7021 (void) ListMimeInfo((FILE *) NULL,exception);
7024 case MagickModuleOptions:
7026 (void) ListModuleInfo((FILE *) NULL,exception);
7029 case MagickPolicyOptions:
7031 (void) ListPolicyInfo((FILE *) NULL,exception);
7034 case MagickResourceOptions:
7036 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7039 case MagickThresholdOptions:
7041 (void) ListThresholdMaps((FILE *) NULL,exception);
7046 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7053 if (LocaleCompare("log",option+1) == 0)
7057 (void) SetLogFormat(argv[i+1]);
7060 if (LocaleCompare("loop",option+1) == 0)
7064 (void) SetImageOption(image_info,option+1,"0");
7067 (void) SetImageOption(image_info,option+1,argv[i+1]);
7074 if (LocaleCompare("matte",option+1) == 0)
7078 (void) SetImageOption(image_info,option+1,"false");
7081 (void) SetImageOption(image_info,option+1,"true");
7084 if (LocaleCompare("mattecolor",option+1) == 0)
7088 (void) SetImageOption(image_info,option+1,argv[i+1]);
7089 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7093 (void) SetImageOption(image_info,option+1,argv[i+1]);
7094 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7098 if (LocaleCompare("monitor",option+1) == 0)
7100 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7104 if (LocaleCompare("monochrome",option+1) == 0)
7106 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7113 if (LocaleCompare("orient",option+1) == 0)
7117 image_info->orientation=UndefinedOrientation;
7118 (void) SetImageOption(image_info,option+1,"undefined");
7121 image_info->orientation=(OrientationType) ParseMagickOption(
7122 MagickOrientationOptions,MagickFalse,argv[i+1]);
7123 (void) SetImageOption(image_info,option+1,"undefined");
7129 if (LocaleCompare("page",option+1) == 0)
7133 page[MaxTextExtent];
7146 (void) DeleteImageOption(image_info,option+1);
7147 (void) CloneString(&image_info->page,(char *) NULL);
7150 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7151 image_option=GetImageOption(image_info,"page");
7152 if (image_option != (const char *) NULL)
7153 flags=ParseAbsoluteGeometry(image_option,&geometry);
7154 canonical_page=GetPageGeometry(argv[i+1]);
7155 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7156 canonical_page=DestroyString(canonical_page);
7157 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
7158 (unsigned long) geometry.width,(unsigned long) geometry.height);
7159 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7160 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7161 (unsigned long) geometry.width,(unsigned long) geometry.height,
7162 (long) geometry.x,(long) geometry.y);
7163 (void) SetImageOption(image_info,option+1,page);
7164 (void) CloneString(&image_info->page,page);
7167 if (LocaleCompare("pen",option+1) == 0)
7171 (void) SetImageOption(image_info,option+1,"none");
7174 (void) SetImageOption(image_info,option+1,argv[i+1]);
7177 if (LocaleCompare("ping",option+1) == 0)
7179 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7182 if (LocaleCompare("pointsize",option+1) == 0)
7185 geometry_info.rho=0.0;
7187 (void) ParseGeometry(argv[i+1],&geometry_info);
7188 image_info->pointsize=geometry_info.rho;
7191 if (LocaleCompare("precision",option+1) == 0)
7193 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7196 if (LocaleCompare("preview",option+1) == 0)
7203 image_info->preview_type=UndefinedPreview;
7206 image_info->preview_type=(PreviewType) ParseMagickOption(
7207 MagickPreviewOptions,MagickFalse,argv[i+1]);
7214 if (LocaleCompare("quality",option+1) == 0)
7217 Set image compression quality.
7221 image_info->quality=UndefinedCompressionQuality;
7222 (void) SetImageOption(image_info,option+1,"0");
7225 image_info->quality=StringToUnsignedLong(argv[i+1]);
7226 (void) SetImageOption(image_info,option+1,argv[i+1]);
7229 if (LocaleCompare("quiet",option+1) == 0)
7231 static WarningHandler
7232 warning_handler = (WarningHandler) NULL;
7237 Restore error or warning messages.
7239 warning_handler=SetWarningHandler(warning_handler);
7243 Suppress error or warning messages.
7245 warning_handler=SetWarningHandler((WarningHandler) NULL);
7252 if (LocaleCompare("red-primary",option+1) == 0)
7256 (void) SetImageOption(image_info,option+1,"0.0");
7259 (void) SetImageOption(image_info,option+1,argv[i+1]);
7266 if (LocaleCompare("sampling-factor",option+1) == 0)
7269 Set image sampling factor.
7273 if (image_info->sampling_factor != (char *) NULL)
7274 image_info->sampling_factor=DestroyString(
7275 image_info->sampling_factor);
7278 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7281 if (LocaleCompare("scene",option+1) == 0)
7288 image_info->scene=0;
7289 (void) SetImageOption(image_info,option+1,"0");
7292 image_info->scene=StringToUnsignedLong(argv[i+1]);
7293 (void) SetImageOption(image_info,option+1,argv[i+1]);
7296 if (LocaleCompare("seed",option+1) == 0)
7303 seed=(size_t) time((time_t *) NULL);
7304 SeedPseudoRandomGenerator(seed);
7307 seed=StringToUnsignedLong(argv[i+1]);
7308 SeedPseudoRandomGenerator(seed);
7311 if (LocaleCompare("size",option+1) == 0)
7315 if (image_info->size != (char *) NULL)
7316 image_info->size=DestroyString(image_info->size);
7319 (void) CloneString(&image_info->size,argv[i+1]);
7322 if (LocaleCompare("stroke",option+1) == 0)
7326 (void) SetImageOption(image_info,option+1,"none");
7329 (void) SetImageOption(image_info,option+1,argv[i+1]);
7332 if (LocaleCompare("strokewidth",option+1) == 0)
7336 (void) SetImageOption(image_info,option+1,"0");
7339 (void) SetImageOption(image_info,option+1,argv[i+1]);
7346 if (LocaleCompare("taint",option+1) == 0)
7350 (void) SetImageOption(image_info,option+1,"false");
7353 (void) SetImageOption(image_info,option+1,"true");
7356 if (LocaleCompare("texture",option+1) == 0)
7360 if (image_info->texture != (char *) NULL)
7361 image_info->texture=DestroyString(image_info->texture);
7364 (void) CloneString(&image_info->texture,argv[i+1]);
7367 if (LocaleCompare("tile-offset",option+1) == 0)
7371 (void) SetImageOption(image_info,option+1,"0");
7374 (void) SetImageOption(image_info,option+1,argv[i+1]);
7377 if (LocaleCompare("transparent-color",option+1) == 0)
7381 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7382 (void) SetImageOption(image_info,option+1,"none");
7385 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7387 (void) SetImageOption(image_info,option+1,argv[i+1]);
7390 if (LocaleCompare("type",option+1) == 0)
7394 image_info->type=UndefinedType;
7395 (void) SetImageOption(image_info,option+1,"undefined");
7398 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7399 MagickFalse,argv[i+1]);
7400 (void) SetImageOption(image_info,option+1,argv[i+1]);
7407 if (LocaleCompare("undercolor",option+1) == 0)
7411 (void) DeleteImageOption(image_info,option+1);
7414 (void) SetImageOption(image_info,option+1,argv[i+1]);
7417 if (LocaleCompare("units",option+1) == 0)
7421 image_info->units=UndefinedResolution;
7422 (void) SetImageOption(image_info,option+1,"undefined");
7425 image_info->units=(ResolutionType) ParseMagickOption(
7426 MagickResolutionOptions,MagickFalse,argv[i+1]);
7427 (void) SetImageOption(image_info,option+1,argv[i+1]);
7434 if (LocaleCompare("verbose",option+1) == 0)
7438 image_info->verbose=MagickFalse;
7441 image_info->verbose=MagickTrue;
7442 image_info->ping=MagickFalse;
7445 if (LocaleCompare("view",option+1) == 0)
7449 if (image_info->view != (char *) NULL)
7450 image_info->view=DestroyString(image_info->view);
7453 (void) CloneString(&image_info->view,argv[i+1]);
7456 if (LocaleCompare("virtual-pixel",option+1) == 0)
7460 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7461 (void) SetImageOption(image_info,option+1,"undefined");
7464 image_info->virtual_pixel_method=(VirtualPixelMethod)
7465 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7467 (void) SetImageOption(image_info,option+1,argv[i+1]);
7474 if (LocaleCompare("white-point",option+1) == 0)
7478 (void) SetImageOption(image_info,option+1,"0.0");
7481 (void) SetImageOption(image_info,option+1,argv[i+1]);
7495 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7499 + M o g r i f y I m a g e L i s t %
7503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7505 % MogrifyImageList() applies any command line options that might affect the
7506 % entire image list (e.g. -append, -coalesce, etc.).
7508 % The format of the MogrifyImage method is:
7510 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7511 % const char **argv,Image **images,ExceptionInfo *exception)
7513 % A description of each parameter follows:
7515 % o image_info: the image info..
7517 % o argc: Specifies a pointer to an integer describing the number of
7518 % elements in the argument vector.
7520 % o argv: Specifies a pointer to a text array containing the command line
7523 % o images: the images.
7525 % o exception: return any errors or warnings in this structure.
7528 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7529 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7551 Apply options to the image list.
7553 assert(image_info != (ImageInfo *) NULL);
7554 assert(image_info->signature == MagickSignature);
7555 assert(images != (Image **) NULL);
7556 assert((*images)->signature == MagickSignature);
7557 if ((*images)->debug != MagickFalse)
7558 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7559 (*images)->filename);
7560 if ((argc <= 0) || (*argv == (char *) NULL))
7562 quantize_info=AcquireQuantizeInfo(image_info);
7563 channel=image_info->channel;
7565 for (i=0; i < (ssize_t) argc; i++)
7567 if (*images == (Image *) NULL)
7570 if (IsMagickOption(option) == MagickFalse)
7572 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7574 if ((i+count) >= (ssize_t) argc)
7576 status=MogrifyImageInfo(image_info,(int) count+1,argv+i,exception);
7577 switch (*(option+1))
7581 if (LocaleCompare("affinity",option+1) == 0)
7583 (void) SyncImagesSettings(image_info,*images);
7586 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7587 InheritException(exception,&(*images)->exception);
7593 if (LocaleCompare("append",option+1) == 0)
7598 (void) SyncImagesSettings(image_info,*images);
7599 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7600 MagickFalse,exception);
7601 if (append_image == (Image *) NULL)
7606 *images=DestroyImageList(*images);
7607 *images=append_image;
7610 if (LocaleCompare("average",option+1) == 0)
7616 Average an image sequence (deprecated).
7618 (void) SyncImagesSettings(image_info,*images);
7619 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7621 if (average_image == (Image *) NULL)
7626 *images=DestroyImageList(*images);
7627 *images=average_image;
7634 if (LocaleCompare("channel",option+1) == 0)
7638 channel=DefaultChannels;
7641 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7644 if (LocaleCompare("clut",option+1) == 0)
7650 (void) SyncImagesSettings(image_info,*images);
7651 image=RemoveFirstImageFromList(images);
7652 clut_image=RemoveFirstImageFromList(images);
7653 if (clut_image == (Image *) NULL)
7658 (void) ClutImageChannel(image,channel,clut_image);
7659 clut_image=DestroyImage(clut_image);
7660 InheritException(exception,&image->exception);
7661 *images=DestroyImageList(*images);
7665 if (LocaleCompare("coalesce",option+1) == 0)
7670 (void) SyncImagesSettings(image_info,*images);
7671 coalesce_image=CoalesceImages(*images,exception);
7672 if (coalesce_image == (Image *) NULL)
7677 *images=DestroyImageList(*images);
7678 *images=coalesce_image;
7681 if (LocaleCompare("combine",option+1) == 0)
7686 (void) SyncImagesSettings(image_info,*images);
7687 combine_image=CombineImages(*images,channel,exception);
7688 if (combine_image == (Image *) NULL)
7693 *images=DestroyImageList(*images);
7694 *images=combine_image;
7697 if (LocaleCompare("composite",option+1) == 0)
7707 (void) SyncImagesSettings(image_info,*images);
7708 image=RemoveFirstImageFromList(images);
7709 composite_image=RemoveFirstImageFromList(images);
7710 if (composite_image == (Image *) NULL)
7715 (void) TransformImage(&composite_image,(char *) NULL,
7716 composite_image->geometry);
7717 SetGeometry(composite_image,&geometry);
7718 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7719 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7721 mask_image=RemoveFirstImageFromList(images);
7722 if (mask_image != (Image *) NULL)
7724 if ((image->compose == DisplaceCompositeOp) ||
7725 (image->compose == DistortCompositeOp))
7728 Merge Y displacement into X displacement image.
7730 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7732 mask_image=DestroyImage(mask_image);
7737 Set a blending mask for the composition.
7739 image->mask=mask_image;
7740 (void) NegateImage(image->mask,MagickFalse);
7743 (void) CompositeImageChannel(image,channel,image->compose,
7744 composite_image,geometry.x,geometry.y);
7745 if (image->mask != (Image *) NULL)
7746 image->mask=DestroyImage(image->mask);
7747 composite_image=DestroyImage(composite_image);
7748 InheritException(exception,&image->exception);
7749 *images=DestroyImageList(*images);
7753 if (LocaleCompare("crop",option+1) == 0)
7761 (void) SyncImagesSettings(image_info,*images);
7762 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7763 if (((geometry.width == 0) && (geometry.height == 0)) ||
7764 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7766 (void) TransformImages(images,argv[i+1],(char *) NULL);
7767 InheritException(exception,&(*images)->exception);
7774 if (LocaleCompare("deconstruct",option+1) == 0)
7779 (void) SyncImagesSettings(image_info,*images);
7780 deconstruct_image=DeconstructImages(*images,exception);
7781 if (deconstruct_image == (Image *) NULL)
7786 *images=DestroyImageList(*images);
7787 *images=deconstruct_image;
7790 if (LocaleCompare("delete",option+1) == 0)
7793 DeleteImages(images,"-1",exception);
7795 DeleteImages(images,argv[i+1],exception);
7798 if (LocaleCompare("dither",option+1) == 0)
7802 quantize_info->dither=MagickFalse;
7805 quantize_info->dither=MagickTrue;
7806 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7807 MagickDitherOptions,MagickFalse,argv[i+1]);
7814 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7819 MagickEvaluateOperator
7822 (void) SyncImageSettings(image_info,*images);
7823 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7824 MagickFalse,argv[i+1]);
7825 evaluate_image=EvaluateImages(*images,op,exception);
7826 if (evaluate_image == (Image *) NULL)
7831 *images=DestroyImageList(*images);
7832 *images=evaluate_image;
7839 if (LocaleCompare("fft",option+1) == 0)
7845 Implements the discrete Fourier transform (DFT).
7847 (void) SyncImageSettings(image_info,*images);
7848 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7849 MagickTrue : MagickFalse,exception);
7850 if (fourier_image == (Image *) NULL)
7852 *images=DestroyImage(*images);
7853 *images=fourier_image;
7856 if (LocaleCompare("flatten",option+1) == 0)
7861 (void) SyncImagesSettings(image_info,*images);
7862 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7863 if (flatten_image == (Image *) NULL)
7865 *images=DestroyImageList(*images);
7866 *images=flatten_image;
7869 if (LocaleCompare("fx",option+1) == 0)
7874 (void) SyncImagesSettings(image_info,*images);
7875 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7876 if (fx_image == (Image *) NULL)
7881 *images=DestroyImageList(*images);
7889 if (LocaleCompare("hald-clut",option+1) == 0)
7895 (void) SyncImagesSettings(image_info,*images);
7896 image=RemoveFirstImageFromList(images);
7897 hald_image=RemoveFirstImageFromList(images);
7898 if (hald_image == (Image *) NULL)
7903 (void) HaldClutImageChannel(image,channel,hald_image);
7904 hald_image=DestroyImage(hald_image);
7905 InheritException(exception,&image->exception);
7906 if (*images != (Image *) NULL)
7907 *images=DestroyImageList(*images);
7915 if (LocaleCompare("ift",option+1) == 0)
7923 Implements the inverse fourier discrete Fourier transform (DFT).
7925 (void) SyncImagesSettings(image_info,*images);
7926 magnitude_image=RemoveFirstImageFromList(images);
7927 phase_image=RemoveFirstImageFromList(images);
7928 if (phase_image == (Image *) NULL)
7933 fourier_image=InverseFourierTransformImage(magnitude_image,
7934 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7935 if (fourier_image == (Image *) NULL)
7937 if (*images != (Image *) NULL)
7938 *images=DestroyImage(*images);
7939 *images=fourier_image;
7942 if (LocaleCompare("insert",option+1) == 0)
7950 index=StringToLong(argv[i+1]);
7951 p=RemoveLastImageFromList(images);
7952 if (p == (Image *) NULL)
7954 (void) ThrowMagickException(exception,GetMagickModule(),
7955 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7961 PrependImageToList(images,q);
7963 if (index == (ssize_t) GetImageListLength(*images))
7964 AppendImageToList(images,q);
7967 q=GetImageFromList(*images,index-1);
7968 if (q == (Image *) NULL)
7970 (void) ThrowMagickException(exception,GetMagickModule(),
7971 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7975 InsertImageInList(&q,p);
7977 *images=GetFirstImageInList(q);
7984 if (LocaleCompare("layers",option+1) == 0)
7992 (void) SyncImagesSettings(image_info,*images);
7993 layers=(Image *) NULL;
7994 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
7995 MagickFalse,argv[i+1]);
8000 layers=CoalesceImages(*images,exception);
8003 case CompareAnyLayer:
8004 case CompareClearLayer:
8005 case CompareOverlayLayer:
8008 layers=CompareImageLayers(*images,method,exception);
8014 case TrimBoundsLayer:
8016 layers=MergeImageLayers(*images,method,exception);
8021 layers=DisposeImages(*images,exception);
8024 case OptimizeImageLayer:
8026 layers=OptimizeImageLayers(*images,exception);
8029 case OptimizePlusLayer:
8031 layers=OptimizePlusImageLayers(*images,exception);
8034 case OptimizeTransLayer:
8036 OptimizeImageTransparency(*images,exception);
8039 case RemoveDupsLayer:
8041 RemoveDuplicateLayers(images,exception);
8044 case RemoveZeroLayer:
8046 RemoveZeroDelayLayers(images,exception);
8052 General Purpose, GIF Animation Optimizer.
8054 layers=CoalesceImages(*images,exception);
8055 if (layers == (Image *) NULL)
8060 InheritException(exception,&layers->exception);
8061 *images=DestroyImageList(*images);
8063 layers=OptimizeImageLayers(*images,exception);
8064 if (layers == (Image *) NULL)
8069 InheritException(exception,&layers->exception);
8070 *images=DestroyImageList(*images);
8072 layers=(Image *) NULL;
8073 OptimizeImageTransparency(*images,exception);
8074 InheritException(exception,&(*images)->exception);
8075 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8078 case CompositeLayer:
8090 Split image sequence at the first 'NULL:' image.
8093 while (source != (Image *) NULL)
8095 source=GetNextImageInList(source);
8096 if ((source != (Image *) NULL) &&
8097 (LocaleCompare(source->magick,"NULL") == 0))
8100 if (source != (Image *) NULL)
8102 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8103 (GetNextImageInList(source) == (Image *) NULL))
8104 source=(Image *) NULL;
8108 Separate the two lists, junk the null: image.
8110 source=SplitImageList(source->previous);
8111 DeleteImageFromList(&source);
8114 if (source == (Image *) NULL)
8116 (void) ThrowMagickException(exception,GetMagickModule(),
8117 OptionError,"MissingNullSeparator","layers Composite");
8122 Adjust offset with gravity and virtual canvas.
8124 SetGeometry(*images,&geometry);
8125 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8126 geometry.width=source->page.width != 0 ?
8127 source->page.width : source->columns;
8128 geometry.height=source->page.height != 0 ?
8129 source->page.height : source->rows;
8130 GravityAdjustGeometry((*images)->page.width != 0 ?
8131 (*images)->page.width : (*images)->columns,
8132 (*images)->page.height != 0 ? (*images)->page.height :
8133 (*images)->rows,(*images)->gravity,&geometry);
8134 compose=OverCompositeOp;
8135 option=GetImageOption(image_info,"compose");
8136 if (option != (const char *) NULL)
8137 compose=(CompositeOperator) ParseMagickOption(
8138 MagickComposeOptions,MagickFalse,option);
8139 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8141 source=DestroyImageList(source);
8145 if (layers == (Image *) NULL)
8147 InheritException(exception,&layers->exception);
8148 *images=DestroyImageList(*images);
8156 if (LocaleCompare("map",option+1) == 0)
8158 (void) SyncImagesSettings(image_info,*images);
8161 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8162 InheritException(exception,&(*images)->exception);
8168 if (LocaleCompare("maximum",option+1) == 0)
8174 Maximum image sequence (deprecated).
8176 (void) SyncImagesSettings(image_info,*images);
8177 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8178 if (maximum_image == (Image *) NULL)
8183 *images=DestroyImageList(*images);
8184 *images=maximum_image;
8187 if (LocaleCompare("minimum",option+1) == 0)
8193 Minimum image sequence (deprecated).
8195 (void) SyncImagesSettings(image_info,*images);
8196 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8197 if (minimum_image == (Image *) NULL)
8202 *images=DestroyImageList(*images);
8203 *images=minimum_image;
8206 if (LocaleCompare("morph",option+1) == 0)
8211 (void) SyncImagesSettings(image_info,*images);
8212 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8214 if (morph_image == (Image *) NULL)
8219 *images=DestroyImageList(*images);
8220 *images=morph_image;
8223 if (LocaleCompare("mosaic",option+1) == 0)
8228 (void) SyncImagesSettings(image_info,*images);
8229 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8230 if (mosaic_image == (Image *) NULL)
8235 *images=DestroyImageList(*images);
8236 *images=mosaic_image;
8243 if (LocaleCompare("print",option+1) == 0)
8248 (void) SyncImagesSettings(image_info,*images);
8249 string=InterpretImageProperties(image_info,*images,argv[i+1]);
8250 if (string == (char *) NULL)
8252 InheritException(exception,&(*images)->exception);
8253 (void) fprintf(stdout,"%s",string);
8254 string=DestroyString(string);
8256 if (LocaleCompare("process",option+1) == 0)
8265 (void) SyncImagesSettings(image_info,*images);
8266 arguments=StringToArgv(argv[i+1],&number_arguments);
8267 if (arguments == (char **) NULL)
8269 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8290 Support old style syntax, filter="-option arg".
8292 length=strlen(argv[i+1]);
8293 token=(char *) NULL;
8294 if (~length >= MaxTextExtent)
8295 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8297 if (token == (char *) NULL)
8300 arguments=argv[i+1];
8301 token_info=AcquireTokenInfo();
8302 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8303 "\"",'\0',&breaker,&next,"e);
8304 token_info=DestroyTokenInfo(token_info);
8310 argv=(&(arguments[next]));
8311 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8314 token=DestroyString(token);
8317 (void) SubstituteString(&arguments[1],"-","");
8318 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8319 number_arguments-2,(const char **) arguments+2,exception);
8320 for (j=0; j < number_arguments; j++)
8321 arguments[j]=DestroyString(arguments[j]);
8322 arguments=(char **) RelinquishMagickMemory(arguments);
8329 if (LocaleCompare("reverse",option+1) == 0)
8331 ReverseImageList(images);
8332 InheritException(exception,&(*images)->exception);
8339 if (LocaleCompare("swap",option+1) == 0)
8360 flags=ParseGeometry(argv[i+1],&geometry_info);
8361 index=(ssize_t) geometry_info.rho;
8362 if ((flags & SigmaValue) != 0)
8363 swap_index=(ssize_t) geometry_info.sigma;
8365 p=GetImageFromList(*images,index);
8366 q=GetImageFromList(*images,swap_index);
8367 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8369 (void) ThrowMagickException(exception,GetMagickModule(),
8370 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8376 swap=CloneImage(p,0,0,MagickTrue,exception);
8377 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8378 ReplaceImageInList(&q,swap);
8379 *images=GetFirstImageInList(q);
8386 if (LocaleCompare("write",option+1) == 0)
8397 (void) SyncImagesSettings(image_info,*images);
8398 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8399 (void) DeleteImageRegistry(key);
8400 write_images=(*images);
8402 write_images=CloneImageList(*images,exception);
8403 write_info=CloneImageInfo(image_info);
8404 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8405 write_info=DestroyImageInfo(write_info);
8407 write_images=DestroyImageList(write_images);
8417 quantize_info=DestroyQuantizeInfo(quantize_info);
8418 return(status != 0 ? MagickTrue : MagickFalse);
8422 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8426 + M o g r i f y I m a g e s %
8430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8432 % MogrifyImages() applies image processing options to a sequence of images as
8433 % prescribed by command line options.
8435 % The format of the MogrifyImage method is:
8437 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8438 % const MagickBooleanType post,const int argc,const char **argv,
8439 % Image **images,Exceptioninfo *exception)
8441 % A description of each parameter follows:
8443 % o image_info: the image info..
8445 % o post: If true, post process image list operators otherwise pre-process.
8447 % o argc: Specifies a pointer to an integer describing the number of
8448 % elements in the argument vector.
8450 % o argv: Specifies a pointer to a text array containing the command line
8453 % o images: the images.
8455 % o exception: return any errors or warnings in this structure.
8458 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8459 const MagickBooleanType post,const int argc,const char **argv,
8460 Image **images,ExceptionInfo *exception)
8462 #define MogrifyImageTag "Mogrify/Image"
8481 Apply options to individual images in the list.
8483 assert(image_info != (ImageInfo *) NULL);
8484 assert(image_info->signature == MagickSignature);
8485 if (images == (Image **) NULL)
8486 return(MogrifyImage(image_info,argc,argv,images,exception));
8487 assert((*images)->signature == MagickSignature);
8488 if ((*images)->debug != MagickFalse)
8489 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8490 (*images)->filename);
8491 if ((argc <= 0) || (*argv == (char *) NULL))
8493 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8495 mogrify_images=NewImageList();
8496 number_images=GetImageListLength(*images);
8498 if (post == MagickFalse)
8499 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8500 for (i=0; i < (ssize_t) number_images; i++)
8502 image=RemoveFirstImageFromList(images);
8503 if (image == (Image *) NULL)
8505 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8506 AppendImageToList(&mogrify_images,image);
8507 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8509 if (proceed == MagickFalse)
8512 if (post != MagickFalse)
8513 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8514 *images=mogrify_images;
8515 return(status != 0 ? MagickTrue : MagickFalse);