2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
13 % MagickWand Module Methods %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "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,int argc,char **argv,char **metadata,
85 % ExceptionInfo *exception)
87 % A description of each parameter follows:
89 % o image_info: the image info.
91 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
92 % MogrifyImageCommand, CompositeImageCommand, CompareImageCommand,
93 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
94 % DisplayImageCommand, or AnimateImageCommand.
96 % o argc: Specifies a pointer to an integer describing the number of
97 % elements in the argument vector.
99 % o argv: Specifies a pointer to a text array containing the command line
102 % o metadata: any metadata is returned here.
104 % o exception: return any errors or warnings in this structure.
107 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
108 MagickCommand command,int argc,char **argv,char **metadata,
109 ExceptionInfo *exception)
133 (void) setlocale(LC_ALL,"");
134 (void) setlocale(LC_NUMERIC,"C");
135 concurrent=MagickFalse;
139 regard_warnings=MagickFalse;
140 for (i=1; i < (ssize_t) (argc-1); i++)
143 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
145 if (LocaleCompare("bench",option+1) == 0)
146 iterations=StringToUnsignedLong(argv[++i]);
147 if (LocaleCompare("concurrent",option+1) == 0)
148 concurrent=MagickTrue;
149 if (LocaleCompare("debug",option+1) == 0)
150 (void) SetLogEventMask(argv[++i]);
151 if (LocaleCompare("duration",option+1) == 0)
152 duration=StringToDouble(argv[++i]);
153 if (LocaleCompare("regard-warnings",option+1) == 0)
154 regard_warnings=MagickTrue;
156 timer=AcquireTimerInfo();
157 if (concurrent == MagickFalse)
159 for (i=0; i < (ssize_t) iterations; i++)
161 if (status != MagickFalse)
165 if (GetElapsedTime(timer) > duration)
167 (void) ContinueTimer(timer);
169 status=command(image_info,argc,argv,metadata,exception);
170 if (exception->severity != UndefinedException)
172 if ((exception->severity > ErrorException) ||
173 (regard_warnings != MagickFalse))
175 CatchException(exception);
177 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
179 (void) fputs(*metadata,stdout);
180 (void) fputc('\n',stdout);
181 *metadata=DestroyString(*metadata);
188 #if defined(MAGICKCORE_OPENMP_SUPPORT)
189 # pragma omp parallel for shared(status)
191 for (i=0; i < (ssize_t) iterations; i++)
193 if (status != MagickFalse)
197 if (GetElapsedTime(timer) > duration)
199 (void) ContinueTimer(timer);
201 status=command(image_info,argc,argv,metadata,exception);
202 #if defined(MAGICKCORE_OPENMP_SUPPORT)
203 # pragma omp critical (MagickCore_CommandGenesis)
206 if (exception->severity != UndefinedException)
208 if ((exception->severity > ErrorException) ||
209 (regard_warnings != MagickFalse))
211 CatchException(exception);
213 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
215 (void) fputs(*metadata,stdout);
216 (void) fputc('\n',stdout);
217 *metadata=DestroyString(*metadata);
224 elapsed_time=GetElapsedTime(timer);
225 user_time=GetUserTime(timer);
226 (void) fprintf(stderr,
227 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
228 iterations,1.0*iterations/elapsed_time,user_time,(double)
229 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
230 (1000.0*(elapsed_time-floor(elapsed_time))));
231 (void) fflush(stderr);
233 timer=DestroyTimerInfo(timer);
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 + M o g r i f y I m a g e %
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 % MogrifyImage() applies simple single image processing options to a single
249 % image. That image however may be part of a longer list of images.
251 % The image in the list may be modified in three different ways...
253 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
254 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
255 % * replace by a list of images (only the -separate option!)
257 % In each case the result is returned into the list, and a pointer to the
258 % modified image (last image added if replaced by a list of images) is
261 % ASIDE: The -crop is present but restricted to non-tile single image crops
263 % This means if all the images are being processed (such as by
264 % MogrifyImages(), next image to be processed will be as per the pointer
265 % (*image)->next. Also the image list may grow as a result of some specific
266 % operations but as images are never merged or deleted, it will never shrink
267 % in length. Typically the list will remain the same length.
269 % WARNING: As the image pointed to may be replaced, the first image in the
270 % list may also change. GetFirstImageInList() should be used by caller if
271 % they wish return the Image pointer to the first image in list.
274 % The format of the MogrifyImage method is:
276 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
277 % const char **argv,Image **image)
279 % A description of each parameter follows:
281 % o image_info: the image info..
283 % o argc: Specifies a pointer to an integer describing the number of
284 % elements in the argument vector.
286 % o argv: Specifies a pointer to a text array containing the command line
289 % o image: the image.
291 % o exception: return any errors or warnings in this structure.
296 ** GetImageCache() will read an image into a image cache if not already
297 ** present then return the image that is in the cache under that filename.
299 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
300 ExceptionInfo *exception)
314 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
315 sans_exception=AcquireExceptionInfo();
316 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
317 sans_exception=DestroyExceptionInfo(sans_exception);
318 if (image != (Image *) NULL)
320 read_info=CloneImageInfo(image_info);
321 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
322 image=ReadImage(read_info,exception);
323 read_info=DestroyImageInfo(read_info);
324 if (image != (Image *) NULL)
325 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
329 static MagickBooleanType IsPathWritable(const char *path)
331 if (IsPathAccessible(path) == MagickFalse)
333 if (access(path,W_OK) != 0)
338 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
345 static MagickBooleanType MonitorProgress(const char *text,
346 const MagickOffsetType offset,const MagickSizeType extent,
347 void *wand_unused(client_data))
350 message[MaxTextExtent],
361 (void) CopyMagickMemory(tag,text,MaxTextExtent);
363 if (p != (char *) NULL)
365 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
366 locale_message=GetLocaleMessage(message);
367 if (locale_message == message)
369 if (p == (char *) NULL)
370 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
371 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
373 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
374 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
375 (100L*offset/(extent-1)));
376 if (offset == (MagickOffsetType) (extent-1))
377 (void) fprintf(stderr,"\n");
378 (void) fflush(stderr);
383 ** SparseColorOption() parse the complex -sparse-color argument into an
384 ** an array of floating point values than call SparseColorImage().
385 ** Argument is a complex mix of floating-point pixel coodinates, and color
386 ** specifications (or direct floating point numbers). The number of floats
387 ** needed to represent a color varies depending on teh current channel
390 static Image *SparseColorOption(const Image *image,const ChannelType channel,
391 const SparseColorMethod method,const char *arguments,
392 const MagickBooleanType color_from_image,ExceptionInfo *exception)
398 token[MaxTextExtent];
424 assert(image != (Image *) NULL);
425 assert(image->signature == MagickSignature);
426 if (image->debug != MagickFalse)
427 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
428 assert(exception != (ExceptionInfo *) NULL);
429 assert(exception->signature == MagickSignature);
431 Limit channels according to image - and add up number of color channel.
434 if (image->colorspace != CMYKColorspace)
435 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
436 if (image->matte == MagickFalse)
437 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
439 if ((channels & RedChannel) != 0)
441 if ((channels & GreenChannel) != 0)
443 if ((channels & BlueChannel) != 0)
445 if ((channels & IndexChannel) != 0)
447 if ((channels & OpacityChannel) != 0)
451 Read string, to determine number of arguments needed,
457 GetMagickToken(p,&p,token);
458 if ( token[0] == ',' ) continue;
459 if ( isalpha((int) token[0]) || token[0] == '#' ) {
460 if ( color_from_image ) {
461 (void) ThrowMagickException(exception,GetMagickModule(),
462 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
463 "Color arg given, when colors are coming from image");
464 return( (Image *)NULL);
466 x += number_colors; /* color argument */
469 x++; /* floating point argument */
473 if ( color_from_image ) {
474 /* just the control points are being given */
475 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
476 number_arguments=(x/2)*(2+number_colors);
479 /* control points and color values */
480 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
484 (void) ThrowMagickException(exception,GetMagickModule(),
485 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
486 "Invalid number of Arguments");
487 return( (Image *)NULL);
490 /* Allocate and fill in the floating point arguments */
491 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
492 sizeof(*sparse_arguments));
493 if (sparse_arguments == (double *) NULL) {
494 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
495 "MemoryAllocationFailed","%s","SparseColorOption");
496 return( (Image *)NULL);
498 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
499 sizeof(*sparse_arguments));
502 while( *p != '\0' && x < number_arguments ) {
504 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
505 if ( token[0] == '\0' ) break;
506 if ( isalpha((int) token[0]) || token[0] == '#' ) {
507 (void) ThrowMagickException(exception,GetMagickModule(),
508 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
509 "Color found, instead of X-coord");
513 sparse_arguments[x++]=StringToDouble(token);
515 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
516 if ( token[0] == '\0' ) break;
517 if ( isalpha((int) token[0]) || token[0] == '#' ) {
518 (void) ThrowMagickException(exception,GetMagickModule(),
519 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
520 "Color found, instead of Y-coord");
524 sparse_arguments[x++]=StringToDouble(token);
525 /* color values for this control point */
527 if ( (color_from_image ) {
528 /* get color from image */
534 /* color name or function given in string argument */
535 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
536 if ( token[0] == '\0' ) break;
537 if ( isalpha((int) token[0]) || token[0] == '#' ) {
538 /* Color string given */
539 (void) QueryMagickColor(token,&color,exception);
540 if ( channels & RedChannel )
541 sparse_arguments[x++] = QuantumScale*color.red;
542 if ( channels & GreenChannel )
543 sparse_arguments[x++] = QuantumScale*color.green;
544 if ( channels & BlueChannel )
545 sparse_arguments[x++] = QuantumScale*color.blue;
546 if ( channels & IndexChannel )
547 sparse_arguments[x++] = QuantumScale*color.index;
548 if ( channels & OpacityChannel )
549 sparse_arguments[x++] = QuantumScale*color.opacity;
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
554 if ( channels & RedChannel ) {
555 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
556 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
558 sparse_arguments[x++]=StringToDouble(token);
559 token[0] = ','; /* used this token - get another */
561 if ( channels & GreenChannel ) {
562 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
563 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
565 sparse_arguments[x++]=StringToDouble(token);
566 token[0] = ','; /* used this token - get another */
568 if ( channels & BlueChannel ) {
569 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
570 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
572 sparse_arguments[x++]=StringToDouble(token);
573 token[0] = ','; /* used this token - get another */
575 if ( channels & IndexChannel ) {
576 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
577 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
579 sparse_arguments[x++]=StringToDouble(token);
580 token[0] = ','; /* used this token - get another */
582 if ( channels & OpacityChannel ) {
583 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
584 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
586 sparse_arguments[x++]=StringToDouble(token);
587 token[0] = ','; /* used this token - get another */
592 if ( number_arguments != x && !error ) {
593 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
594 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
595 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
596 return( (Image *)NULL);
599 return( (Image *)NULL);
601 /* Call the Interpolation function with the parsed arguments */
602 sparse_image=SparseColorImage(image,channels,method,number_arguments,
603 sparse_arguments,exception);
604 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
605 return( sparse_image );
608 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
609 const char **argv,Image **image,ExceptionInfo *exception)
650 Initialize method variables.
652 assert(image_info != (const ImageInfo *) NULL);
653 assert(image_info->signature == MagickSignature);
654 assert(image != (Image **) NULL);
655 assert((*image)->signature == MagickSignature);
656 if ((*image)->debug != MagickFalse)
657 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
660 mogrify_info=CloneImageInfo(image_info);
661 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
662 quantize_info=AcquireQuantizeInfo(mogrify_info);
663 SetGeometryInfo(&geometry_info);
664 GetMagickPixelPacket(*image,&fill);
665 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
667 channel=mogrify_info->channel;
668 format=GetImageOption(mogrify_info,"format");
669 SetGeometry(*image,®ion_geometry);
670 region_image=NewImageList();
672 Transmogrify the image.
674 for (i=0; i < (ssize_t) argc; i++)
683 if (IsCommandOption(option) == MagickFalse)
685 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
686 count=MagickMax(count,0L);
687 if ((i+count) >= (ssize_t) argc)
689 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
690 mogrify_image=(Image *)NULL;
695 if (LocaleCompare("adaptive-blur",option+1) == 0)
700 (void) SyncImageSettings(mogrify_info,*image);
701 flags=ParseGeometry(argv[i+1],&geometry_info);
702 if ((flags & SigmaValue) == 0)
703 geometry_info.sigma=1.0;
704 mogrify_image=AdaptiveBlurImageChannel(*image,channel,
705 geometry_info.rho,geometry_info.sigma,exception);
708 if (LocaleCompare("adaptive-resize",option+1) == 0)
711 Adaptive resize image.
713 (void) SyncImageSettings(mogrify_info,*image);
714 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
715 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
716 geometry.height,exception);
719 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
722 Adaptive sharpen image.
724 (void) SyncImageSettings(mogrify_info,*image);
725 flags=ParseGeometry(argv[i+1],&geometry_info);
726 if ((flags & SigmaValue) == 0)
727 geometry_info.sigma=1.0;
728 mogrify_image=AdaptiveSharpenImageChannel(*image,channel,
729 geometry_info.rho,geometry_info.sigma,exception);
732 if (LocaleCompare("affine",option+1) == 0)
739 GetAffineMatrix(&draw_info->affine);
742 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
745 if (LocaleCompare("alpha",option+1) == 0)
750 (void) SyncImageSettings(mogrify_info,*image);
751 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
752 MagickFalse,argv[i+1]);
753 (void) SetImageAlphaChannel(*image,alpha_type);
754 InheritException(exception,&(*image)->exception);
757 if (LocaleCompare("annotate",option+1) == 0)
761 geometry[MaxTextExtent];
766 (void) SyncImageSettings(mogrify_info,*image);
767 SetGeometryInfo(&geometry_info);
768 flags=ParseGeometry(argv[i+1],&geometry_info);
769 if ((flags & SigmaValue) == 0)
770 geometry_info.sigma=geometry_info.rho;
771 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
772 InheritException(exception,&(*image)->exception);
773 if (text == (char *) NULL)
775 (void) CloneString(&draw_info->text,text);
776 text=DestroyString(text);
777 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
778 geometry_info.xi,geometry_info.psi);
779 (void) CloneString(&draw_info->geometry,geometry);
780 draw_info->affine.sx=cos(DegreesToRadians(
781 fmod(geometry_info.rho,360.0)));
782 draw_info->affine.rx=sin(DegreesToRadians(
783 fmod(geometry_info.rho,360.0)));
784 draw_info->affine.ry=(-sin(DegreesToRadians(
785 fmod(geometry_info.sigma,360.0))));
786 draw_info->affine.sy=cos(DegreesToRadians(
787 fmod(geometry_info.sigma,360.0)));
788 (void) AnnotateImage(*image,draw_info);
789 InheritException(exception,&(*image)->exception);
792 if (LocaleCompare("antialias",option+1) == 0)
794 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
796 draw_info->text_antialias=(*option == '-') ? MagickTrue :
800 if (LocaleCompare("auto-gamma",option+1) == 0)
803 Auto Adjust Gamma of image based on its mean
805 (void) SyncImageSettings(mogrify_info,*image);
806 (void) AutoGammaImageChannel(*image,channel);
809 if (LocaleCompare("auto-level",option+1) == 0)
812 Perfectly Normalize (max/min stretch) the image
814 (void) SyncImageSettings(mogrify_info,*image);
815 (void) AutoLevelImageChannel(*image,channel);
818 if (LocaleCompare("auto-orient",option+1) == 0)
820 (void) SyncImageSettings(mogrify_info,*image);
821 switch ((*image)->orientation)
823 case TopRightOrientation:
825 mogrify_image=FlopImage(*image,exception);
828 case BottomRightOrientation:
830 mogrify_image=RotateImage(*image,180.0,exception);
833 case BottomLeftOrientation:
835 mogrify_image=FlipImage(*image,exception);
838 case LeftTopOrientation:
840 mogrify_image=TransposeImage(*image,exception);
843 case RightTopOrientation:
845 mogrify_image=RotateImage(*image,90.0,exception);
848 case RightBottomOrientation:
850 mogrify_image=TransverseImage(*image,exception);
853 case LeftBottomOrientation:
855 mogrify_image=RotateImage(*image,270.0,exception);
861 if (mogrify_image != (Image *) NULL)
862 mogrify_image->orientation=TopLeftOrientation;
869 if (LocaleCompare("black-threshold",option+1) == 0)
872 Black threshold image.
874 (void) SyncImageSettings(mogrify_info,*image);
875 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
877 InheritException(exception,&(*image)->exception);
880 if (LocaleCompare("blue-shift",option+1) == 0)
885 (void) SyncImageSettings(mogrify_info,*image);
886 geometry_info.rho=1.5;
888 flags=ParseGeometry(argv[i+1],&geometry_info);
889 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
892 if (LocaleCompare("blur",option+1) == 0)
897 (void) SyncImageSettings(mogrify_info,*image);
898 flags=ParseGeometry(argv[i+1],&geometry_info);
899 if ((flags & SigmaValue) == 0)
900 geometry_info.sigma=1.0;
901 mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho,
902 geometry_info.sigma,exception);
905 if (LocaleCompare("border",option+1) == 0)
908 Surround image with a border of solid color.
910 (void) SyncImageSettings(mogrify_info,*image);
911 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
912 if ((flags & SigmaValue) == 0)
913 geometry.height=geometry.width;
914 mogrify_image=BorderImage(*image,&geometry,exception);
917 if (LocaleCompare("bordercolor",option+1) == 0)
921 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
925 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
929 if (LocaleCompare("box",option+1) == 0)
931 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
935 if (LocaleCompare("brightness-contrast",option+1) == 0)
948 Brightness / contrast image.
950 (void) SyncImageSettings(mogrify_info,*image);
951 flags=ParseGeometry(argv[i+1],&geometry_info);
952 brightness=geometry_info.rho;
954 if ((flags & SigmaValue) != 0)
955 contrast=geometry_info.sigma;
956 (void) BrightnessContrastImageChannel(*image,channel,brightness,
958 InheritException(exception,&(*image)->exception);
965 if (LocaleCompare("cdl",option+1) == 0)
968 *color_correction_collection;
971 Color correct with a color decision list.
973 (void) SyncImageSettings(mogrify_info,*image);
974 color_correction_collection=FileToString(argv[i+1],~0,exception);
975 if (color_correction_collection == (char *) NULL)
977 (void) ColorDecisionListImage(*image,color_correction_collection);
978 InheritException(exception,&(*image)->exception);
981 if (LocaleCompare("channel",option+1) == 0)
984 channel=DefaultChannels;
986 channel=(ChannelType) ParseChannelOption(argv[i+1]);
989 if (LocaleCompare("charcoal",option+1) == 0)
994 (void) SyncImageSettings(mogrify_info,*image);
995 flags=ParseGeometry(argv[i+1],&geometry_info);
996 if ((flags & SigmaValue) == 0)
997 geometry_info.sigma=1.0;
998 mogrify_image=CharcoalImage(*image,geometry_info.rho,
999 geometry_info.sigma,exception);
1002 if (LocaleCompare("chop",option+1) == 0)
1007 (void) SyncImageSettings(mogrify_info,*image);
1008 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1009 mogrify_image=ChopImage(*image,&geometry,exception);
1012 if (LocaleCompare("clamp",option+1) == 0)
1017 (void) SyncImageSettings(mogrify_info,*image);
1018 (void) ClampImageChannel(*image,channel);
1019 InheritException(exception,&(*image)->exception);
1022 if (LocaleCompare("clip",option+1) == 0)
1024 (void) SyncImageSettings(mogrify_info,*image);
1027 (void) SetImageClipMask(*image,(Image *) NULL);
1028 InheritException(exception,&(*image)->exception);
1031 (void) ClipImage(*image);
1032 InheritException(exception,&(*image)->exception);
1035 if (LocaleCompare("clip-mask",option+1) == 0)
1043 register PixelPacket
1052 (void) SyncImageSettings(mogrify_info,*image);
1058 (void) SetImageMask(*image,(Image *) NULL);
1059 InheritException(exception,&(*image)->exception);
1064 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1066 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1067 if (mask_image == (Image *) NULL)
1069 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1070 return(MagickFalse);
1071 mask_view=AcquireCacheView(mask_image);
1072 for (y=0; y < (ssize_t) mask_image->rows; y++)
1074 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1076 if (q == (PixelPacket *) NULL)
1078 for (x=0; x < (ssize_t) mask_image->columns; x++)
1080 if (mask_image->matte == MagickFalse)
1081 q->opacity=PixelIntensityToQuantum(q);
1083 q->green=q->opacity;
1087 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1090 mask_view=DestroyCacheView(mask_view);
1091 mask_image->matte=MagickTrue;
1092 (void) SetImageClipMask(*image,mask_image);
1093 mask_image=DestroyImage(mask_image);
1094 InheritException(exception,&(*image)->exception);
1097 if (LocaleCompare("clip-path",option+1) == 0)
1099 (void) SyncImageSettings(mogrify_info,*image);
1100 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1102 InheritException(exception,&(*image)->exception);
1105 if (LocaleCompare("colorize",option+1) == 0)
1110 (void) SyncImageSettings(mogrify_info,*image);
1111 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1115 if (LocaleCompare("color-matrix",option+1) == 0)
1120 (void) SyncImageSettings(mogrify_info,*image);
1121 kernel=AcquireKernelInfo(argv[i+1]);
1122 if (kernel == (KernelInfo *) NULL)
1124 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1125 kernel=DestroyKernelInfo(kernel);
1128 if (LocaleCompare("colors",option+1) == 0)
1131 Reduce the number of colors in the image.
1133 (void) SyncImageSettings(mogrify_info,*image);
1134 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1135 if (quantize_info->number_colors == 0)
1137 if (((*image)->storage_class == DirectClass) ||
1138 (*image)->colors > quantize_info->number_colors)
1139 (void) QuantizeImage(quantize_info,*image);
1141 (void) CompressImageColormap(*image);
1142 InheritException(exception,&(*image)->exception);
1145 if (LocaleCompare("colorspace",option+1) == 0)
1150 (void) SyncImageSettings(mogrify_info,*image);
1153 (void) TransformImageColorspace(*image,RGBColorspace);
1154 InheritException(exception,&(*image)->exception);
1157 colorspace=(ColorspaceType) ParseCommandOption(
1158 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1159 (void) TransformImageColorspace(*image,colorspace);
1160 InheritException(exception,&(*image)->exception);
1163 if (LocaleCompare("contrast",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image);
1166 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1168 InheritException(exception,&(*image)->exception);
1171 if (LocaleCompare("contrast-stretch",option+1) == 0)
1181 Contrast stretch image.
1183 (void) SyncImageSettings(mogrify_info,*image);
1184 flags=ParseGeometry(argv[i+1],&geometry_info);
1185 black_point=geometry_info.rho;
1186 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1188 if ((flags & PercentValue) != 0)
1190 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1191 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1193 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1195 (void) ContrastStretchImageChannel(*image,channel,black_point,
1197 InheritException(exception,&(*image)->exception);
1200 if (LocaleCompare("convolve",option+1) == 0)
1211 (void) SyncImageSettings(mogrify_info,*image);
1212 kernel=AcquireKernelInfo(argv[i+1]);
1213 if (kernel == (KernelInfo *) NULL)
1216 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1217 gamma+=kernel->values[j];
1218 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1219 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1220 kernel->values[j]*=gamma;
1221 mogrify_image=FilterImageChannel(*image,channel,kernel,exception);
1222 kernel=DestroyKernelInfo(kernel);
1225 if (LocaleCompare("crop",option+1) == 0)
1228 Crop a image to a smaller size
1230 (void) SyncImageSettings(mogrify_info,*image);
1232 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1233 if (((geometry.width != 0) || (geometry.height != 0)) &&
1234 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1238 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1239 mogrify_image->next = mogrify_image->previous = (Image *)NULL;
1240 (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL);
1241 InheritException(exception,&mogrify_image->exception);
1243 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1247 if (LocaleCompare("cycle",option+1) == 0)
1250 Cycle an image colormap.
1252 (void) SyncImageSettings(mogrify_info,*image);
1253 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1254 InheritException(exception,&(*image)->exception);
1261 if (LocaleCompare("decipher",option+1) == 0)
1269 (void) SyncImageSettings(mogrify_info,*image);
1270 passkey=FileToStringInfo(argv[i+1],~0,exception);
1271 if (passkey != (StringInfo *) NULL)
1273 (void) PasskeyDecipherImage(*image,passkey,exception);
1274 passkey=DestroyStringInfo(passkey);
1278 if (LocaleCompare("density",option+1) == 0)
1283 (void) CloneString(&draw_info->density,argv[i+1]);
1286 if (LocaleCompare("depth",option+1) == 0)
1288 (void) SyncImageSettings(mogrify_info,*image);
1291 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1294 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1297 if (LocaleCompare("deskew",option+1) == 0)
1303 Straighten the image.
1305 (void) SyncImageSettings(mogrify_info,*image);
1307 threshold=40.0*QuantumRange/100.0;
1309 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1310 mogrify_image=DeskewImage(*image,threshold,exception);
1313 if (LocaleCompare("despeckle",option+1) == 0)
1316 Reduce the speckles within an image.
1318 (void) SyncImageSettings(mogrify_info,*image);
1319 mogrify_image=DespeckleImage(*image,exception);
1322 if (LocaleCompare("display",option+1) == 0)
1324 (void) CloneString(&draw_info->server_name,argv[i+1]);
1327 if (LocaleCompare("distort",option+1) == 0)
1331 token[MaxTextExtent];
1351 (void) SyncImageSettings(mogrify_info,*image);
1352 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1353 MagickFalse,argv[i+1]);
1354 if ( method == ResizeDistortion )
1356 /* Special Case - Argument is actually a resize geometry!
1357 ** Convert that to an appropriate distortion argument array.
1361 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1363 resize_args[0]=(double)geometry.width;
1364 resize_args[1]=(double)geometry.height;
1365 mogrify_image=DistortImage(*image,method,(size_t)2,
1366 resize_args,MagickTrue,exception);
1369 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1370 InheritException(exception,&(*image)->exception);
1371 if (args == (char *) NULL)
1374 for (x=0; *p != '\0'; x++)
1376 GetMagickToken(p,&p,token);
1378 GetMagickToken(p,&p,token);
1380 number_arguments=(size_t) x;
1381 arguments=(double *) AcquireQuantumMemory(number_arguments,
1382 sizeof(*arguments));
1383 if (arguments == (double *) NULL)
1384 ThrowWandFatalException(ResourceLimitFatalError,
1385 "MemoryAllocationFailed",(*image)->filename);
1386 (void) ResetMagickMemory(arguments,0,number_arguments*
1387 sizeof(*arguments));
1389 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1391 GetMagickToken(p,&p,token);
1393 GetMagickToken(p,&p,token);
1394 arguments[x]=StringToDouble(token);
1396 args=DestroyString(args);
1397 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1398 (*option == '+') ? MagickTrue : MagickFalse,exception);
1399 arguments=(double *) RelinquishMagickMemory(arguments);
1402 if (LocaleCompare("dither",option+1) == 0)
1406 quantize_info->dither=MagickFalse;
1409 quantize_info->dither=MagickTrue;
1410 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1411 MagickDitherOptions,MagickFalse,argv[i+1]);
1412 if (quantize_info->dither_method == NoDitherMethod)
1413 quantize_info->dither=MagickFalse;
1416 if (LocaleCompare("draw",option+1) == 0)
1421 (void) SyncImageSettings(mogrify_info,*image);
1422 (void) CloneString(&draw_info->primitive,argv[i+1]);
1423 (void) DrawImage(*image,draw_info);
1424 InheritException(exception,&(*image)->exception);
1431 if (LocaleCompare("edge",option+1) == 0)
1434 Enhance edges in the image.
1436 (void) SyncImageSettings(mogrify_info,*image);
1437 flags=ParseGeometry(argv[i+1],&geometry_info);
1438 if ((flags & SigmaValue) == 0)
1439 geometry_info.sigma=1.0;
1440 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1443 if (LocaleCompare("emboss",option+1) == 0)
1446 Gaussian embossen image.
1448 (void) SyncImageSettings(mogrify_info,*image);
1449 flags=ParseGeometry(argv[i+1],&geometry_info);
1450 if ((flags & SigmaValue) == 0)
1451 geometry_info.sigma=1.0;
1452 mogrify_image=EmbossImage(*image,geometry_info.rho,
1453 geometry_info.sigma,exception);
1456 if (LocaleCompare("encipher",option+1) == 0)
1464 (void) SyncImageSettings(mogrify_info,*image);
1465 passkey=FileToStringInfo(argv[i+1],~0,exception);
1466 if (passkey != (StringInfo *) NULL)
1468 (void) PasskeyEncipherImage(*image,passkey,exception);
1469 passkey=DestroyStringInfo(passkey);
1473 if (LocaleCompare("encoding",option+1) == 0)
1475 (void) CloneString(&draw_info->encoding,argv[i+1]);
1478 if (LocaleCompare("enhance",option+1) == 0)
1483 (void) SyncImageSettings(mogrify_info,*image);
1484 mogrify_image=EnhanceImage(*image,exception);
1487 if (LocaleCompare("equalize",option+1) == 0)
1492 (void) SyncImageSettings(mogrify_info,*image);
1493 (void) EqualizeImageChannel(*image,channel);
1494 InheritException(exception,&(*image)->exception);
1497 if (LocaleCompare("evaluate",option+1) == 0)
1502 MagickEvaluateOperator
1505 (void) SyncImageSettings(mogrify_info,*image);
1506 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
1507 MagickFalse,argv[i+1]);
1508 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1509 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1512 if (LocaleCompare("extent",option+1) == 0)
1515 Set the image extent.
1517 (void) SyncImageSettings(mogrify_info,*image);
1518 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1519 if (geometry.width == 0)
1520 geometry.width=(*image)->columns;
1521 if (geometry.height == 0)
1522 geometry.height=(*image)->rows;
1523 mogrify_image=ExtentImage(*image,&geometry,exception);
1530 if (LocaleCompare("family",option+1) == 0)
1534 if (draw_info->family != (char *) NULL)
1535 draw_info->family=DestroyString(draw_info->family);
1538 (void) CloneString(&draw_info->family,argv[i+1]);
1541 if (LocaleCompare("features",option+1) == 0)
1545 (void) DeleteImageArtifact(*image,"identify:features");
1548 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1551 if (LocaleCompare("fill",option+1) == 0)
1556 GetMagickPixelPacket(*image,&fill);
1559 (void) QueryMagickColor("none",&fill,exception);
1560 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1561 if (draw_info->fill_pattern != (Image *) NULL)
1562 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1565 sans=AcquireExceptionInfo();
1566 (void) QueryMagickColor(argv[i+1],&fill,sans);
1567 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1568 sans=DestroyExceptionInfo(sans);
1569 if (status == MagickFalse)
1570 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1574 if (LocaleCompare("flip",option+1) == 0)
1577 Flip image scanlines.
1579 (void) SyncImageSettings(mogrify_info,*image);
1580 mogrify_image=FlipImage(*image,exception);
1583 if (LocaleCompare("flop",option+1) == 0)
1586 Flop image scanlines.
1588 (void) SyncImageSettings(mogrify_info,*image);
1589 mogrify_image=FlopImage(*image,exception);
1592 if (LocaleCompare("floodfill",option+1) == 0)
1600 (void) SyncImageSettings(mogrify_info,*image);
1601 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1602 (void) QueryMagickColor(argv[i+2],&target,exception);
1603 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1604 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1605 InheritException(exception,&(*image)->exception);
1608 if (LocaleCompare("font",option+1) == 0)
1612 if (draw_info->font != (char *) NULL)
1613 draw_info->font=DestroyString(draw_info->font);
1616 (void) CloneString(&draw_info->font,argv[i+1]);
1619 if (LocaleCompare("format",option+1) == 0)
1624 if (LocaleCompare("frame",option+1) == 0)
1630 Surround image with an ornamental border.
1632 (void) SyncImageSettings(mogrify_info,*image);
1633 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1634 frame_info.width=geometry.width;
1635 frame_info.height=geometry.height;
1636 if ((flags & HeightValue) == 0)
1637 frame_info.height=geometry.width;
1638 frame_info.outer_bevel=geometry.x;
1639 frame_info.inner_bevel=geometry.y;
1640 frame_info.x=(ssize_t) frame_info.width;
1641 frame_info.y=(ssize_t) frame_info.height;
1642 frame_info.width=(*image)->columns+2*frame_info.width;
1643 frame_info.height=(*image)->rows+2*frame_info.height;
1644 mogrify_image=FrameImage(*image,&frame_info,exception);
1647 if (LocaleCompare("function",option+1) == 0)
1651 token[MaxTextExtent];
1669 Function Modify Image Values
1671 (void) SyncImageSettings(mogrify_info,*image);
1672 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1673 MagickFalse,argv[i+1]);
1674 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1675 InheritException(exception,&(*image)->exception);
1676 if (arguments == (char *) NULL)
1678 p=(char *) arguments;
1679 for (x=0; *p != '\0'; x++)
1681 GetMagickToken(p,&p,token);
1683 GetMagickToken(p,&p,token);
1685 number_parameters=(size_t) x;
1686 parameters=(double *) AcquireQuantumMemory(number_parameters,
1687 sizeof(*parameters));
1688 if (parameters == (double *) NULL)
1689 ThrowWandFatalException(ResourceLimitFatalError,
1690 "MemoryAllocationFailed",(*image)->filename);
1691 (void) ResetMagickMemory(parameters,0,number_parameters*
1692 sizeof(*parameters));
1693 p=(char *) arguments;
1694 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1696 GetMagickToken(p,&p,token);
1698 GetMagickToken(p,&p,token);
1699 parameters[x]=StringToDouble(token);
1701 arguments=DestroyString(arguments);
1702 (void) FunctionImageChannel(*image,channel,function,
1703 number_parameters,parameters,exception);
1704 parameters=(double *) RelinquishMagickMemory(parameters);
1711 if (LocaleCompare("gamma",option+1) == 0)
1716 (void) SyncImageSettings(mogrify_info,*image);
1718 (*image)->gamma=StringToDouble(argv[i+1]);
1721 if (strchr(argv[i+1],',') != (char *) NULL)
1722 (void) GammaImage(*image,argv[i+1]);
1724 (void) GammaImageChannel(*image,channel,
1725 StringToDouble(argv[i+1]));
1726 InheritException(exception,&(*image)->exception);
1730 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1731 (LocaleCompare("gaussian",option+1) == 0))
1734 Gaussian blur image.
1736 (void) SyncImageSettings(mogrify_info,*image);
1737 flags=ParseGeometry(argv[i+1],&geometry_info);
1738 if ((flags & SigmaValue) == 0)
1739 geometry_info.sigma=1.0;
1740 mogrify_image=GaussianBlurImageChannel(*image,channel,
1741 geometry_info.rho,geometry_info.sigma,exception);
1744 if (LocaleCompare("geometry",option+1) == 0)
1747 Record Image offset, Resize last image.
1749 (void) SyncImageSettings(mogrify_info,*image);
1752 if ((*image)->geometry != (char *) NULL)
1753 (*image)->geometry=DestroyString((*image)->geometry);
1756 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1757 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1758 (void) CloneString(&(*image)->geometry,argv[i+1]);
1760 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1761 (*image)->filter,(*image)->blur,exception);
1764 if (LocaleCompare("gravity",option+1) == 0)
1768 draw_info->gravity=UndefinedGravity;
1771 draw_info->gravity=(GravityType) ParseCommandOption(
1772 MagickGravityOptions,MagickFalse,argv[i+1]);
1779 if (LocaleCompare("highlight-color",option+1) == 0)
1781 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1788 if (LocaleCompare("identify",option+1) == 0)
1793 (void) SyncImageSettings(mogrify_info,*image);
1794 if (format == (char *) NULL)
1796 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1797 InheritException(exception,&(*image)->exception);
1800 text=InterpretImageProperties(mogrify_info,*image,format);
1801 InheritException(exception,&(*image)->exception);
1802 if (text == (char *) NULL)
1804 (void) fputs(text,stdout);
1805 (void) fputc('\n',stdout);
1806 text=DestroyString(text);
1809 if (LocaleCompare("implode",option+1) == 0)
1814 (void) SyncImageSettings(mogrify_info,*image);
1815 (void) ParseGeometry(argv[i+1],&geometry_info);
1816 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1819 if (LocaleCompare("interline-spacing",option+1) == 0)
1822 (void) ParseGeometry("0",&geometry_info);
1824 (void) ParseGeometry(argv[i+1],&geometry_info);
1825 draw_info->interline_spacing=geometry_info.rho;
1828 if (LocaleCompare("interword-spacing",option+1) == 0)
1831 (void) ParseGeometry("0",&geometry_info);
1833 (void) ParseGeometry(argv[i+1],&geometry_info);
1834 draw_info->interword_spacing=geometry_info.rho;
1841 if (LocaleCompare("kerning",option+1) == 0)
1844 (void) ParseGeometry("0",&geometry_info);
1846 (void) ParseGeometry(argv[i+1],&geometry_info);
1847 draw_info->kerning=geometry_info.rho;
1854 if (LocaleCompare("lat",option+1) == 0)
1857 Local adaptive threshold image.
1859 (void) SyncImageSettings(mogrify_info,*image);
1860 flags=ParseGeometry(argv[i+1],&geometry_info);
1861 if ((flags & PercentValue) != 0)
1862 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1863 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1864 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1865 geometry_info.xi,exception);
1868 if (LocaleCompare("level",option+1) == 0)
1881 (void) SyncImageSettings(mogrify_info,*image);
1882 flags=ParseGeometry(argv[i+1],&geometry_info);
1883 black_point=geometry_info.rho;
1884 white_point=(MagickRealType) QuantumRange;
1885 if ((flags & SigmaValue) != 0)
1886 white_point=geometry_info.sigma;
1888 if ((flags & XiValue) != 0)
1889 gamma=geometry_info.xi;
1890 if ((flags & PercentValue) != 0)
1892 black_point*=(MagickRealType) (QuantumRange/100.0);
1893 white_point*=(MagickRealType) (QuantumRange/100.0);
1895 if ((flags & SigmaValue) == 0)
1896 white_point=(MagickRealType) QuantumRange-black_point;
1897 if ((*option == '+') || ((flags & AspectValue) != 0))
1898 (void) LevelizeImageChannel(*image,channel,black_point,
1901 (void) LevelImageChannel(*image,channel,black_point,white_point,
1903 InheritException(exception,&(*image)->exception);
1906 if (LocaleCompare("level-colors",option+1) == 0)
1909 token[MaxTextExtent];
1918 p=(const char *) argv[i+1];
1919 GetMagickToken(p,&p,token); /* get black point color */
1920 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1921 (void) QueryMagickColor(token,&black_point,exception);
1923 (void) QueryMagickColor("#000000",&black_point,exception);
1924 if (isalpha((int) token[0]) || (token[0] == '#'))
1925 GetMagickToken(p,&p,token);
1927 white_point=black_point; /* set everything to that color */
1930 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1931 GetMagickToken(p,&p,token); /* Get white point color. */
1932 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1933 (void) QueryMagickColor(token,&white_point,exception);
1935 (void) QueryMagickColor("#ffffff",&white_point,exception);
1937 (void) LevelColorsImageChannel(*image,channel,&black_point,
1938 &white_point,*option == '+' ? MagickTrue : MagickFalse);
1941 if (LocaleCompare("linear-stretch",option+1) == 0)
1950 (void) SyncImageSettings(mogrify_info,*image);
1951 flags=ParseGeometry(argv[i+1],&geometry_info);
1952 black_point=geometry_info.rho;
1953 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1954 if ((flags & SigmaValue) != 0)
1955 white_point=geometry_info.sigma;
1956 if ((flags & PercentValue) != 0)
1958 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1959 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1961 if ((flags & SigmaValue) == 0)
1962 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1964 (void) LinearStretchImage(*image,black_point,white_point);
1965 InheritException(exception,&(*image)->exception);
1968 if (LocaleCompare("linewidth",option+1) == 0)
1970 draw_info->stroke_width=StringToDouble(argv[i+1]);
1973 if (LocaleCompare("liquid-rescale",option+1) == 0)
1976 Liquid rescale image.
1978 (void) SyncImageSettings(mogrify_info,*image);
1979 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1980 if ((flags & XValue) == 0)
1982 if ((flags & YValue) == 0)
1984 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1985 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1988 if (LocaleCompare("lowlight-color",option+1) == 0)
1990 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1997 if (LocaleCompare("map",option+1) == 0)
2003 Transform image colors to match this set of colors.
2005 (void) SyncImageSettings(mogrify_info,*image);
2008 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2009 if (remap_image == (Image *) NULL)
2011 (void) RemapImage(quantize_info,*image,remap_image);
2012 InheritException(exception,&(*image)->exception);
2013 remap_image=DestroyImage(remap_image);
2016 if (LocaleCompare("mask",option+1) == 0)
2021 (void) SyncImageSettings(mogrify_info,*image);
2027 (void) SetImageMask(*image,(Image *) NULL);
2028 InheritException(exception,&(*image)->exception);
2034 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2035 if (mask == (Image *) NULL)
2037 (void) SetImageMask(*image,mask);
2038 mask=DestroyImage(mask);
2039 InheritException(exception,&(*image)->exception);
2042 if (LocaleCompare("matte",option+1) == 0)
2044 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2045 SetAlphaChannel : DeactivateAlphaChannel );
2046 InheritException(exception,&(*image)->exception);
2049 if (LocaleCompare("median",option+1) == 0)
2052 Median filter image.
2054 (void) SyncImageSettings(mogrify_info,*image);
2055 (void) ParseGeometry(argv[i+1],&geometry_info);
2056 mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic,
2057 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2060 if (LocaleCompare("mode",option+1) == 0)
2065 (void) SyncImageSettings(mogrify_info,*image);
2066 (void) ParseGeometry(argv[i+1],&geometry_info);
2067 mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic,
2068 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
2071 if (LocaleCompare("modulate",option+1) == 0)
2073 (void) SyncImageSettings(mogrify_info,*image);
2074 (void) ModulateImage(*image,argv[i+1]);
2075 InheritException(exception,&(*image)->exception);
2078 if (LocaleCompare("monitor",option+1) == 0)
2082 (void) SetImageProgressMonitor(*image,
2083 (MagickProgressMonitor) NULL,(void *) NULL);
2086 (void) SetImageProgressMonitor(*image,MonitorProgress,
2090 if (LocaleCompare("monochrome",option+1) == 0)
2092 (void) SyncImageSettings(mogrify_info,*image);
2093 (void) SetImageType(*image,BilevelType);
2094 InheritException(exception,&(*image)->exception);
2097 if (LocaleCompare("morphology",option+1) == 0)
2100 token[MaxTextExtent];
2115 Morphological Image Operation
2117 (void) SyncImageSettings(mogrify_info,*image);
2119 GetMagickToken(p,&p,token);
2120 method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions,
2123 GetMagickToken(p,&p,token);
2124 if ((*p == ':') || (*p == ','))
2125 GetMagickToken(p,&p,token);
2127 iterations=(ssize_t) StringToLong(p);
2128 kernel=AcquireKernelInfo(argv[i+2]);
2129 if (kernel == (KernelInfo *) NULL)
2131 (void) ThrowMagickException(exception,GetMagickModule(),
2132 OptionError,"UnabletoParseKernel","morphology");
2136 mogrify_image=MorphologyImageChannel(*image,channel,method,
2137 iterations,kernel,exception);
2138 kernel=DestroyKernelInfo(kernel);
2141 if (LocaleCompare("motion-blur",option+1) == 0)
2146 (void) SyncImageSettings(mogrify_info,*image);
2147 flags=ParseGeometry(argv[i+1],&geometry_info);
2148 if ((flags & SigmaValue) == 0)
2149 geometry_info.sigma=1.0;
2150 mogrify_image=MotionBlurImageChannel(*image,channel,
2151 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2158 if (LocaleCompare("negate",option+1) == 0)
2160 (void) SyncImageSettings(mogrify_info,*image);
2161 (void) NegateImageChannel(*image,channel,*option == '+' ?
2162 MagickTrue : MagickFalse);
2163 InheritException(exception,&(*image)->exception);
2166 if (LocaleCompare("noise",option+1) == 0)
2168 (void) SyncImageSettings(mogrify_info,*image);
2171 (void) ParseGeometry(argv[i+1],&geometry_info);
2172 mogrify_image=StatisticImageChannel(*image,channel,
2173 NonpeakStatistic,(size_t) geometry_info.rho,(size_t)
2174 geometry_info.rho,exception);
2181 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2182 MagickFalse,argv[i+1]);
2183 mogrify_image=AddNoiseImageChannel(*image,channel,noise,
2188 if (LocaleCompare("normalize",option+1) == 0)
2190 (void) SyncImageSettings(mogrify_info,*image);
2191 (void) NormalizeImageChannel(*image,channel);
2192 InheritException(exception,&(*image)->exception);
2199 if (LocaleCompare("opaque",option+1) == 0)
2204 (void) SyncImageSettings(mogrify_info,*image);
2205 (void) QueryMagickColor(argv[i+1],&target,exception);
2206 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2207 *option == '-' ? MagickFalse : MagickTrue);
2210 if (LocaleCompare("ordered-dither",option+1) == 0)
2212 (void) SyncImageSettings(mogrify_info,*image);
2213 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2221 if (LocaleCompare("paint",option+1) == 0)
2229 (void) SyncImageSettings(mogrify_info,*image);
2230 (void) ParseGeometry(argv[i+1],&geometry_info);
2231 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2232 if (paint_image == (Image *) NULL)
2234 *image=DestroyImage(*image);
2238 if (LocaleCompare("pen",option+1) == 0)
2242 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2245 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2248 if (LocaleCompare("pointsize",option+1) == 0)
2251 (void) ParseGeometry("12",&geometry_info);
2253 (void) ParseGeometry(argv[i+1],&geometry_info);
2254 draw_info->pointsize=geometry_info.rho;
2257 if (LocaleCompare("polaroid",option+1) == 0)
2266 Simulate a Polaroid picture.
2268 (void) SyncImageSettings(mogrify_info,*image);
2269 random_info=AcquireRandomInfo();
2270 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2271 random_info=DestroyRandomInfo(random_info);
2274 SetGeometryInfo(&geometry_info);
2275 flags=ParseGeometry(argv[i+1],&geometry_info);
2276 angle=geometry_info.rho;
2278 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2281 if (LocaleCompare("posterize",option+1) == 0)
2286 (void) SyncImageSettings(mogrify_info,*image);
2287 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2288 quantize_info->dither);
2289 InheritException(exception,&(*image)->exception);
2292 if (LocaleCompare("preview",option+1) == 0)
2300 (void) SyncImageSettings(mogrify_info,*image);
2302 preview_type=UndefinedPreview;
2304 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
2305 MagickFalse,argv[i+1]);
2306 mogrify_image=PreviewImage(*image,preview_type,exception);
2309 if (LocaleCompare("profile",option+1) == 0)
2323 (void) SyncImageSettings(mogrify_info,*image);
2327 Remove a profile from the image.
2329 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2331 InheritException(exception,&(*image)->exception);
2335 Associate a profile with the image.
2337 profile_info=CloneImageInfo(mogrify_info);
2338 profile=GetImageProfile(*image,"iptc");
2339 if (profile != (StringInfo *) NULL)
2340 profile_info->profile=(void *) CloneStringInfo(profile);
2341 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2342 profile_info=DestroyImageInfo(profile_info);
2343 if (profile_image == (Image *) NULL)
2348 profile_info=CloneImageInfo(mogrify_info);
2349 (void) CopyMagickString(profile_info->filename,argv[i+1],
2351 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2352 if (profile != (StringInfo *) NULL)
2354 (void) ProfileImage(*image,profile_info->magick,
2355 GetStringInfoDatum(profile),(size_t)
2356 GetStringInfoLength(profile),MagickFalse);
2357 profile=DestroyStringInfo(profile);
2359 profile_info=DestroyImageInfo(profile_info);
2362 ResetImageProfileIterator(profile_image);
2363 name=GetNextImageProfile(profile_image);
2364 while (name != (const char *) NULL)
2366 profile=GetImageProfile(profile_image,name);
2367 if (profile != (StringInfo *) NULL)
2368 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2369 (size_t) GetStringInfoLength(profile),MagickFalse);
2370 name=GetNextImageProfile(profile_image);
2372 profile_image=DestroyImage(profile_image);
2379 if (LocaleCompare("quantize",option+1) == 0)
2383 quantize_info->colorspace=UndefinedColorspace;
2386 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2387 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2394 if (LocaleCompare("radial-blur",option+1) == 0)
2399 (void) SyncImageSettings(mogrify_info,*image);
2400 mogrify_image=RadialBlurImageChannel(*image,channel,
2401 StringToDouble(argv[i+1]),exception);
2404 if (LocaleCompare("raise",option+1) == 0)
2407 Surround image with a raise of solid color.
2409 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2410 if ((flags & SigmaValue) == 0)
2411 geometry.height=geometry.width;
2412 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2414 InheritException(exception,&(*image)->exception);
2417 if (LocaleCompare("random-threshold",option+1) == 0)
2422 (void) SyncImageSettings(mogrify_info,*image);
2423 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2427 if (LocaleCompare("recolor",option+1) == 0)
2432 (void) SyncImageSettings(mogrify_info,*image);
2433 kernel=AcquireKernelInfo(argv[i+1]);
2434 if (kernel == (KernelInfo *) NULL)
2436 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2437 kernel=DestroyKernelInfo(kernel);
2440 if (LocaleCompare("region",option+1) == 0)
2442 (void) SyncImageSettings(mogrify_info,*image);
2443 if (region_image != (Image *) NULL)
2448 (void) CompositeImage(region_image,region_image->matte !=
2449 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2450 region_geometry.x,region_geometry.y);
2451 InheritException(exception,®ion_image->exception);
2452 *image=DestroyImage(*image);
2453 *image=region_image;
2454 region_image = (Image *) NULL;
2459 Apply transformations to a selected region of the image.
2461 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2463 mogrify_image=CropImage(*image,®ion_geometry,exception);
2464 if (mogrify_image == (Image *) NULL)
2466 region_image=(*image);
2467 *image=mogrify_image;
2468 mogrify_image=(Image *) NULL;
2471 if (LocaleCompare("render",option+1) == 0)
2473 (void) SyncImageSettings(mogrify_info,*image);
2474 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2477 if (LocaleCompare("remap",option+1) == 0)
2483 Transform image colors to match this set of colors.
2485 (void) SyncImageSettings(mogrify_info,*image);
2488 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2489 if (remap_image == (Image *) NULL)
2491 (void) RemapImage(quantize_info,*image,remap_image);
2492 InheritException(exception,&(*image)->exception);
2493 remap_image=DestroyImage(remap_image);
2496 if (LocaleCompare("repage",option+1) == 0)
2500 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2503 (void) ResetImagePage(*image,argv[i+1]);
2504 InheritException(exception,&(*image)->exception);
2507 if (LocaleCompare("resample",option+1) == 0)
2512 (void) SyncImageSettings(mogrify_info,*image);
2513 flags=ParseGeometry(argv[i+1],&geometry_info);
2514 if ((flags & SigmaValue) == 0)
2515 geometry_info.sigma=geometry_info.rho;
2516 mogrify_image=ResampleImage(*image,geometry_info.rho,
2517 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2520 if (LocaleCompare("resize",option+1) == 0)
2525 (void) SyncImageSettings(mogrify_info,*image);
2526 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2527 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2528 (*image)->filter,(*image)->blur,exception);
2531 if (LocaleCompare("roll",option+1) == 0)
2536 (void) SyncImageSettings(mogrify_info,*image);
2537 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2538 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2541 if (LocaleCompare("rotate",option+1) == 0)
2547 Check for conditional image rotation.
2549 (void) SyncImageSettings(mogrify_info,*image);
2550 if (strchr(argv[i+1],'>') != (char *) NULL)
2551 if ((*image)->columns <= (*image)->rows)
2553 if (strchr(argv[i+1],'<') != (char *) NULL)
2554 if ((*image)->columns >= (*image)->rows)
2559 geometry=ConstantString(argv[i+1]);
2560 (void) SubstituteString(&geometry,">","");
2561 (void) SubstituteString(&geometry,"<","");
2562 (void) ParseGeometry(geometry,&geometry_info);
2563 geometry=DestroyString(geometry);
2564 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2571 if (LocaleCompare("sample",option+1) == 0)
2574 Sample image with pixel replication.
2576 (void) SyncImageSettings(mogrify_info,*image);
2577 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2578 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2582 if (LocaleCompare("scale",option+1) == 0)
2587 (void) SyncImageSettings(mogrify_info,*image);
2588 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2589 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2593 if (LocaleCompare("selective-blur",option+1) == 0)
2596 Selectively blur pixels within a contrast threshold.
2598 (void) SyncImageSettings(mogrify_info,*image);
2599 flags=ParseGeometry(argv[i+1],&geometry_info);
2600 if ((flags & PercentValue) != 0)
2601 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2602 mogrify_image=SelectiveBlurImageChannel(*image,channel,
2603 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2606 if (LocaleCompare("separate",option+1) == 0)
2609 Break channels into separate images.
2610 WARNING: This can generate multiple images!
2612 (void) SyncImageSettings(mogrify_info,*image);
2613 mogrify_image=SeparateImages(*image,channel,exception);
2616 if (LocaleCompare("sepia-tone",option+1) == 0)
2624 (void) SyncImageSettings(mogrify_info,*image);
2625 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2626 mogrify_image=SepiaToneImage(*image,threshold,exception);
2629 if (LocaleCompare("segment",option+1) == 0)
2634 (void) SyncImageSettings(mogrify_info,*image);
2635 flags=ParseGeometry(argv[i+1],&geometry_info);
2636 if ((flags & SigmaValue) == 0)
2637 geometry_info.sigma=1.0;
2638 (void) SegmentImage(*image,(*image)->colorspace,
2639 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2640 InheritException(exception,&(*image)->exception);
2643 if (LocaleCompare("set",option+1) == 0)
2653 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2654 (void) DeleteImageRegistry(argv[i+1]+9);
2656 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2658 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2659 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2662 (void) DeleteImageProperty(*image,argv[i+1]);
2665 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2666 if (value == (char *) NULL)
2668 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2669 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2672 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2674 (void) SetImageOption(image_info,argv[i+1]+7,value);
2675 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2676 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2679 (void) SetImageProperty(*image,argv[i+1],value);
2680 value=DestroyString(value);
2683 if (LocaleCompare("shade",option+1) == 0)
2688 (void) SyncImageSettings(mogrify_info,*image);
2689 flags=ParseGeometry(argv[i+1],&geometry_info);
2690 if ((flags & SigmaValue) == 0)
2691 geometry_info.sigma=1.0;
2692 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2693 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2696 if (LocaleCompare("shadow",option+1) == 0)
2701 (void) SyncImageSettings(mogrify_info,*image);
2702 flags=ParseGeometry(argv[i+1],&geometry_info);
2703 if ((flags & SigmaValue) == 0)
2704 geometry_info.sigma=1.0;
2705 if ((flags & XiValue) == 0)
2706 geometry_info.xi=4.0;
2707 if ((flags & PsiValue) == 0)
2708 geometry_info.psi=4.0;
2709 mogrify_image=ShadowImage(*image,geometry_info.rho,
2710 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2711 ceil(geometry_info.psi-0.5),exception);
2714 if (LocaleCompare("sharpen",option+1) == 0)
2719 (void) SyncImageSettings(mogrify_info,*image);
2720 flags=ParseGeometry(argv[i+1],&geometry_info);
2721 if ((flags & SigmaValue) == 0)
2722 geometry_info.sigma=1.0;
2723 mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2724 geometry_info.sigma,exception);
2727 if (LocaleCompare("shave",option+1) == 0)
2730 Shave the image edges.
2732 (void) SyncImageSettings(mogrify_info,*image);
2733 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2734 mogrify_image=ShaveImage(*image,&geometry,exception);
2737 if (LocaleCompare("shear",option+1) == 0)
2742 (void) SyncImageSettings(mogrify_info,*image);
2743 flags=ParseGeometry(argv[i+1],&geometry_info);
2744 if ((flags & SigmaValue) == 0)
2745 geometry_info.sigma=geometry_info.rho;
2746 mogrify_image=ShearImage(*image,geometry_info.rho,
2747 geometry_info.sigma,exception);
2750 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2753 Sigmoidal non-linearity contrast control.
2755 (void) SyncImageSettings(mogrify_info,*image);
2756 flags=ParseGeometry(argv[i+1],&geometry_info);
2757 if ((flags & SigmaValue) == 0)
2758 geometry_info.sigma=(double) QuantumRange/2.0;
2759 if ((flags & PercentValue) != 0)
2760 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2762 (void) SigmoidalContrastImageChannel(*image,channel,
2763 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
2764 geometry_info.sigma);
2765 InheritException(exception,&(*image)->exception);
2768 if (LocaleCompare("sketch",option+1) == 0)
2773 (void) SyncImageSettings(mogrify_info,*image);
2774 flags=ParseGeometry(argv[i+1],&geometry_info);
2775 if ((flags & SigmaValue) == 0)
2776 geometry_info.sigma=1.0;
2777 mogrify_image=SketchImage(*image,geometry_info.rho,
2778 geometry_info.sigma,geometry_info.xi,exception);
2781 if (LocaleCompare("solarize",option+1) == 0)
2786 (void) SyncImageSettings(mogrify_info,*image);
2787 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2788 (void) SolarizeImage(*image,threshold);
2789 InheritException(exception,&(*image)->exception);
2792 if (LocaleCompare("sparse-color",option+1) == 0)
2801 Sparse Color Interpolated Gradient
2803 (void) SyncImageSettings(mogrify_info,*image);
2804 method=(SparseColorMethod) ParseCommandOption(
2805 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2806 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2807 InheritException(exception,&(*image)->exception);
2808 if (arguments == (char *) NULL)
2810 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2811 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2812 arguments=DestroyString(arguments);
2815 if (LocaleCompare("splice",option+1) == 0)
2818 Splice a solid color into the image.
2820 (void) SyncImageSettings(mogrify_info,*image);
2821 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2822 mogrify_image=SpliceImage(*image,&geometry,exception);
2825 if (LocaleCompare("spread",option+1) == 0)
2830 (void) SyncImageSettings(mogrify_info,*image);
2831 (void) ParseGeometry(argv[i+1],&geometry_info);
2832 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2835 if (LocaleCompare("statistic",option+1) == 0)
2840 (void) SyncImageSettings(mogrify_info,*image);
2841 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2842 MagickFalse,argv[i+1]);
2843 (void) ParseGeometry(argv[i+2],&geometry_info);
2844 mogrify_image=StatisticImageChannel(*image,channel,type,(size_t)
2845 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2848 if (LocaleCompare("stretch",option+1) == 0)
2852 draw_info->stretch=UndefinedStretch;
2855 draw_info->stretch=(StretchType) ParseCommandOption(
2856 MagickStretchOptions,MagickFalse,argv[i+1]);
2859 if (LocaleCompare("strip",option+1) == 0)
2862 Strip image of profiles and comments.
2864 (void) SyncImageSettings(mogrify_info,*image);
2865 (void) StripImage(*image);
2866 InheritException(exception,&(*image)->exception);
2869 if (LocaleCompare("stroke",option+1) == 0)
2876 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2877 if (draw_info->stroke_pattern != (Image *) NULL)
2878 draw_info->stroke_pattern=DestroyImage(
2879 draw_info->stroke_pattern);
2882 sans=AcquireExceptionInfo();
2883 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2884 sans=DestroyExceptionInfo(sans);
2885 if (status == MagickFalse)
2886 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2890 if (LocaleCompare("strokewidth",option+1) == 0)
2892 draw_info->stroke_width=StringToDouble(argv[i+1]);
2895 if (LocaleCompare("style",option+1) == 0)
2899 draw_info->style=UndefinedStyle;
2902 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2903 MagickFalse,argv[i+1]);
2906 if (LocaleCompare("swirl",option+1) == 0)
2911 (void) SyncImageSettings(mogrify_info,*image);
2912 (void) ParseGeometry(argv[i+1],&geometry_info);
2913 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
2920 if (LocaleCompare("threshold",option+1) == 0)
2928 (void) SyncImageSettings(mogrify_info,*image);
2930 threshold=(double) QuantumRange/2.5;
2932 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2933 (void) BilevelImageChannel(*image,channel,threshold);
2934 InheritException(exception,&(*image)->exception);
2937 if (LocaleCompare("thumbnail",option+1) == 0)
2942 (void) SyncImageSettings(mogrify_info,*image);
2943 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2944 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2948 if (LocaleCompare("tile",option+1) == 0)
2952 if (draw_info->fill_pattern != (Image *) NULL)
2953 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2956 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2960 if (LocaleCompare("tint",option+1) == 0)
2965 (void) SyncImageSettings(mogrify_info,*image);
2966 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
2969 if (LocaleCompare("transform",option+1) == 0)
2972 Affine transform image.
2974 (void) SyncImageSettings(mogrify_info,*image);
2975 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2979 if (LocaleCompare("transparent",option+1) == 0)
2984 (void) SyncImageSettings(mogrify_info,*image);
2985 (void) QueryMagickColor(argv[i+1],&target,exception);
2986 (void) TransparentPaintImage(*image,&target,(Quantum)
2987 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
2988 InheritException(exception,&(*image)->exception);
2991 if (LocaleCompare("transpose",option+1) == 0)
2994 Transpose image scanlines.
2996 (void) SyncImageSettings(mogrify_info,*image);
2997 mogrify_image=TransposeImage(*image,exception);
3000 if (LocaleCompare("transverse",option+1) == 0)
3003 Transverse image scanlines.
3005 (void) SyncImageSettings(mogrify_info,*image);
3006 mogrify_image=TransverseImage(*image,exception);
3009 if (LocaleCompare("treedepth",option+1) == 0)
3011 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3014 if (LocaleCompare("trim",option+1) == 0)
3019 (void) SyncImageSettings(mogrify_info,*image);
3020 mogrify_image=TrimImage(*image,exception);
3023 if (LocaleCompare("type",option+1) == 0)
3028 (void) SyncImageSettings(mogrify_info,*image);
3032 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3034 (*image)->type=UndefinedType;
3035 (void) SetImageType(*image,type);
3036 InheritException(exception,&(*image)->exception);
3043 if (LocaleCompare("undercolor",option+1) == 0)
3045 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3049 if (LocaleCompare("unique",option+1) == 0)
3053 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3056 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3057 (void) SetImageArtifact(*image,"verbose","true");
3060 if (LocaleCompare("unique-colors",option+1) == 0)
3063 Unique image colors.
3065 (void) SyncImageSettings(mogrify_info,*image);
3066 mogrify_image=UniqueImageColors(*image,exception);
3069 if (LocaleCompare("unsharp",option+1) == 0)
3074 (void) SyncImageSettings(mogrify_info,*image);
3075 flags=ParseGeometry(argv[i+1],&geometry_info);
3076 if ((flags & SigmaValue) == 0)
3077 geometry_info.sigma=1.0;
3078 if ((flags & XiValue) == 0)
3079 geometry_info.xi=1.0;
3080 if ((flags & PsiValue) == 0)
3081 geometry_info.psi=0.05;
3082 mogrify_image=UnsharpMaskImageChannel(*image,channel,
3083 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3084 geometry_info.psi,exception);
3091 if (LocaleCompare("verbose",option+1) == 0)
3093 (void) SetImageArtifact(*image,option+1,
3094 *option == '+' ? "false" : "true");
3097 if (LocaleCompare("vignette",option+1) == 0)
3102 (void) SyncImageSettings(mogrify_info,*image);
3103 flags=ParseGeometry(argv[i+1],&geometry_info);
3104 if ((flags & SigmaValue) == 0)
3105 geometry_info.sigma=1.0;
3106 if ((flags & XiValue) == 0)
3107 geometry_info.xi=0.1*(*image)->columns;
3108 if ((flags & PsiValue) == 0)
3109 geometry_info.psi=0.1*(*image)->rows;
3110 mogrify_image=VignetteImage(*image,geometry_info.rho,
3111 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3112 ceil(geometry_info.psi-0.5),exception);
3115 if (LocaleCompare("virtual-pixel",option+1) == 0)
3119 (void) SetImageVirtualPixelMethod(*image,
3120 UndefinedVirtualPixelMethod);
3123 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3124 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3132 if (LocaleCompare("wave",option+1) == 0)
3137 (void) SyncImageSettings(mogrify_info,*image);
3138 flags=ParseGeometry(argv[i+1],&geometry_info);
3139 if ((flags & SigmaValue) == 0)
3140 geometry_info.sigma=1.0;
3141 mogrify_image=WaveImage(*image,geometry_info.rho,
3142 geometry_info.sigma,exception);
3145 if (LocaleCompare("weight",option+1) == 0)
3147 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3148 if (LocaleCompare(argv[i+1],"all") == 0)
3149 draw_info->weight=0;
3150 if (LocaleCompare(argv[i+1],"bold") == 0)
3151 draw_info->weight=700;
3152 if (LocaleCompare(argv[i+1],"bolder") == 0)
3153 if (draw_info->weight <= 800)
3154 draw_info->weight+=100;
3155 if (LocaleCompare(argv[i+1],"lighter") == 0)
3156 if (draw_info->weight >= 100)
3157 draw_info->weight-=100;
3158 if (LocaleCompare(argv[i+1],"normal") == 0)
3159 draw_info->weight=400;
3162 if (LocaleCompare("white-threshold",option+1) == 0)
3165 White threshold image.
3167 (void) SyncImageSettings(mogrify_info,*image);
3168 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3170 InheritException(exception,&(*image)->exception);
3179 Replace current image with any image that was generated
3181 if (mogrify_image != (Image *) NULL)
3182 ReplaceImageInListReturnLast(image,mogrify_image);
3185 if (region_image != (Image *) NULL)
3188 Composite transformed region onto image.
3190 (void) SyncImageSettings(mogrify_info,*image);
3191 (void) CompositeImage(region_image,region_image->matte !=
3192 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3193 region_geometry.x,region_geometry.y);
3194 InheritException(exception,®ion_image->exception);
3195 *image=DestroyImage(*image);
3196 *image=region_image;
3197 region_image = (Image *) NULL;
3202 quantize_info=DestroyQuantizeInfo(quantize_info);
3203 draw_info=DestroyDrawInfo(draw_info);
3204 mogrify_info=DestroyImageInfo(mogrify_info);
3205 status=(*image)->exception.severity == UndefinedException ? 1 : 0;
3206 return(status == 0 ? MagickFalse : MagickTrue);
3210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3214 + M o g r i f y I m a g e C o m m a n d %
3218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 % MogrifyImageCommand() transforms an image or a sequence of images. These
3221 % transforms include image scaling, image rotation, color reduction, and
3222 % others. The transmogrified image overwrites the original image.
3224 % The format of the MogrifyImageCommand method is:
3226 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3227 % const char **argv,char **metadata,ExceptionInfo *exception)
3229 % A description of each parameter follows:
3231 % o image_info: the image info.
3233 % o argc: the number of elements in the argument vector.
3235 % o argv: A text array containing the command line arguments.
3237 % o metadata: any metadata is returned here.
3239 % o exception: return any errors or warnings in this structure.
3243 static MagickBooleanType MogrifyUsage(void)
3248 "-debug events display copious debugging information",
3249 "-help print program options",
3250 "-list type print a list of supported option arguments",
3251 "-log format format of debugging information",
3252 "-version print version information",
3257 "-adaptive-blur geometry",
3258 " adaptively blur pixels; decrease effect near edges",
3259 "-adaptive-resize geometry",
3260 " adaptively resize image using 'mesh' interpolation",
3261 "-adaptive-sharpen geometry",
3262 " adaptively sharpen pixels; increase effect near edges",
3263 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3264 " transparent, extract, background, or shape",
3265 "-annotate geometry text",
3266 " annotate the image with text",
3267 "-auto-gamma automagically adjust gamma level of image",
3268 "-auto-level automagically adjust color levels of image",
3269 "-auto-orient automagically orient (rotate) image",
3270 "-bench iterations measure performance",
3271 "-black-threshold value",
3272 " force all pixels below the threshold into black",
3273 "-blue-shift simulate a scene at nighttime in the moonlight",
3274 "-blur geometry reduce image noise and reduce detail levels",
3275 "-border geometry surround image with a border of color",
3276 "-bordercolor color border color",
3277 "-brightness-contrast geometry",
3278 " improve brightness / contrast of the image",
3279 "-cdl filename color correct with a color decision list",
3280 "-charcoal radius simulate a charcoal drawing",
3281 "-chop geometry remove pixels from the image interior",
3282 "-clamp restrict pixel range from 0 to the quantum depth",
3283 "-clip clip along the first path from the 8BIM profile",
3284 "-clip-mask filename associate a clip mask with the image",
3285 "-clip-path id clip along a named path from the 8BIM profile",
3286 "-colorize value colorize the image with the fill color",
3287 "-color-matrix matrix apply color correction to the image",
3288 "-contrast enhance or reduce the image contrast",
3289 "-contrast-stretch geometry",
3290 " improve contrast by `stretching' the intensity range",
3291 "-convolve coefficients",
3292 " apply a convolution kernel to the image",
3293 "-cycle amount cycle the image colormap",
3294 "-decipher filename convert cipher pixels to plain pixels",
3295 "-deskew threshold straighten an image",
3296 "-despeckle reduce the speckles within an image",
3297 "-distort method args",
3298 " distort images according to given method ad args",
3299 "-draw string annotate the image with a graphic primitive",
3300 "-edge radius apply a filter to detect edges in the image",
3301 "-encipher filename convert plain pixels to cipher pixels",
3302 "-emboss radius emboss an image",
3303 "-enhance apply a digital filter to enhance a noisy image",
3304 "-equalize perform histogram equalization to an image",
3305 "-evaluate operator value",
3306 " evaluate an arithmetic, relational, or logical expression",
3307 "-extent geometry set the image size",
3308 "-extract geometry extract area from image",
3309 "-fft implements the discrete Fourier transform (DFT)",
3310 "-flip flip image vertically",
3311 "-floodfill geometry color",
3312 " floodfill the image with color",
3313 "-flop flop image horizontally",
3314 "-frame geometry surround image with an ornamental border",
3315 "-function name parameters",
3316 " apply function over image values",
3317 "-gamma value level of gamma correction",
3318 "-gaussian-blur geometry",
3319 " reduce image noise and reduce detail levels",
3320 "-geometry geometry preferred size or location of the image",
3321 "-identify identify the format and characteristics of the image",
3322 "-ift implements the inverse discrete Fourier transform (DFT)",
3323 "-implode amount implode image pixels about the center",
3324 "-lat geometry local adaptive thresholding",
3325 "-layers method optimize, merge, or compare image layers",
3326 "-level value adjust the level of image contrast",
3327 "-level-colors color,color",
3328 " level image with the given colors",
3329 "-linear-stretch geometry",
3330 " improve contrast by `stretching with saturation'",
3331 "-liquid-rescale geometry",
3332 " rescale image with seam-carving",
3333 "-median geometry apply a median filter to the image",
3334 "-mode geometry make each pixel the 'predominate color' of the neighborhood",
3335 "-modulate value vary the brightness, saturation, and hue",
3336 "-monochrome transform image to black and white",
3337 "-morphology method kernel",
3338 " apply a morphology method to the image",
3339 "-motion-blur geometry",
3340 " simulate motion blur",
3341 "-negate replace every pixel with its complementary color ",
3342 "-noise geometry add or reduce noise in an image",
3343 "-normalize transform image to span the full range of colors",
3344 "-opaque color change this color to the fill color",
3345 "-ordered-dither NxN",
3346 " add a noise pattern to the image with specific",
3348 "-paint radius simulate an oil painting",
3349 "-polaroid angle simulate a Polaroid picture",
3350 "-posterize levels reduce the image to a limited number of color levels",
3351 "-profile filename add, delete, or apply an image profile",
3352 "-quantize colorspace reduce colors in this colorspace",
3353 "-radial-blur angle radial blur the image",
3354 "-raise value lighten/darken image edges to create a 3-D effect",
3355 "-random-threshold low,high",
3356 " random threshold the image",
3357 "-region geometry apply options to a portion of the image",
3358 "-render render vector graphics",
3359 "-repage geometry size and location of an image canvas",
3360 "-resample geometry change the resolution of an image",
3361 "-resize geometry resize the image",
3362 "-roll geometry roll an image vertically or horizontally",
3363 "-rotate degrees apply Paeth rotation to the image",
3364 "-sample geometry scale image with pixel sampling",
3365 "-scale geometry scale the image",
3366 "-segment values segment an image",
3367 "-selective-blur geometry",
3368 " selectively blur pixels within a contrast threshold",
3369 "-sepia-tone threshold",
3370 " simulate a sepia-toned photo",
3371 "-set property value set an image property",
3372 "-shade degrees shade the image using a distant light source",
3373 "-shadow geometry simulate an image shadow",
3374 "-sharpen geometry sharpen the image",
3375 "-shave geometry shave pixels from the image edges",
3376 "-shear geometry slide one edge of the image along the X or Y axis",
3377 "-sigmoidal-contrast geometry",
3378 " increase the contrast without saturating highlights or shadows",
3379 "-sketch geometry simulate a pencil sketch",
3380 "-solarize threshold negate all pixels above the threshold level",
3381 "-sparse-color method args",
3382 " fill in a image based on a few color points",
3383 "-splice geometry splice the background color into the image",
3384 "-spread radius displace image pixels by a random amount",
3385 "-statistic type radius",
3386 " replace each pixel with corresponding statistic from the neighborhood",
3387 "-strip strip image of all profiles and comments",
3388 "-swirl degrees swirl image pixels about the center",
3389 "-threshold value threshold the image",
3390 "-thumbnail geometry create a thumbnail of the image",
3391 "-tile filename tile image when filling a graphic primitive",
3392 "-tint value tint the image with the fill color",
3393 "-transform affine transform image",
3394 "-transparent color make this color transparent within the image",
3395 "-transpose flip image vertically and rotate 90 degrees",
3396 "-transverse flop image horizontally and rotate 270 degrees",
3397 "-trim trim image edges",
3398 "-type type image type",
3399 "-unique-colors discard all but one of any pixel color",
3400 "-unsharp geometry sharpen the image",
3401 "-vignette geometry soften the edges of the image in vignette style",
3402 "-wave geometry alter an image along a sine wave",
3403 "-white-threshold value",
3404 " force all pixels above the threshold into white",
3407 *sequence_operators[]=
3409 "-append append an image sequence",
3410 "-clut apply a color lookup table to the image",
3411 "-coalesce merge a sequence of images",
3412 "-combine combine a sequence of images",
3413 "-composite composite image",
3414 "-crop geometry cut out a rectangular region of the image",
3415 "-deconstruct break down an image sequence into constituent parts",
3416 "-evaluate-sequence operator",
3417 " evaluate an arithmetic, relational, or logical expression",
3418 "-flatten flatten a sequence of images",
3419 "-fx expression apply mathematical expression to an image channel(s)",
3420 "-hald-clut apply a Hald color lookup table to the image",
3421 "-morph value morph an image sequence",
3422 "-mosaic create a mosaic from an image sequence",
3423 "-print string interpret string and print to console",
3424 "-process arguments process the image with a custom image filter",
3425 "-separate separate an image channel into a grayscale image",
3426 "-smush geometry smush an image sequence together",
3427 "-write filename write images to this file",
3432 "-adjoin join images into a single multi-image file",
3433 "-affine matrix affine transform matrix",
3434 "-alpha option activate, deactivate, reset, or set the alpha channel",
3435 "-antialias remove pixel-aliasing",
3436 "-authenticate password",
3437 " decipher image with this password",
3438 "-attenuate value lessen (or intensify) when adding noise to an image",
3439 "-background color background color",
3440 "-bias value add bias when convolving an image",
3441 "-black-point-compensation",
3442 " use black point compensation",
3443 "-blue-primary point chromaticity blue primary point",
3444 "-bordercolor color border color",
3445 "-caption string assign a caption to an image",
3446 "-channel type apply option to select image channels",
3447 "-colors value preferred number of colors in the image",
3448 "-colorspace type alternate image colorspace",
3449 "-comment string annotate image with comment",
3450 "-compose operator set image composite operator",
3451 "-compress type type of pixel compression when writing the image",
3452 "-define format:option",
3453 " define one or more image format options",
3454 "-delay value display the next image after pausing",
3455 "-density geometry horizontal and vertical density of the image",
3456 "-depth value image depth",
3457 "-direction type render text right-to-left or left-to-right",
3458 "-display server get image or font from this X server",
3459 "-dispose method layer disposal method",
3460 "-dither method apply error diffusion to image",
3461 "-encoding type text encoding type",
3462 "-endian type endianness (MSB or LSB) of the image",
3463 "-family name render text with this font family",
3464 "-fill color color to use when filling a graphic primitive",
3465 "-filter type use this filter when resizing an image",
3466 "-font name render text with this font",
3467 "-format \"string\" output formatted image characteristics",
3468 "-fuzz distance colors within this distance are considered equal",
3469 "-gravity type horizontal and vertical text placement",
3470 "-green-primary point chromaticity green primary point",
3471 "-intent type type of rendering intent when managing the image color",
3472 "-interlace type type of image interlacing scheme",
3473 "-interline-spacing value",
3474 " set the space between two text lines",
3475 "-interpolate method pixel color interpolation method",
3476 "-interword-spacing value",
3477 " set the space between two words",
3478 "-kerning value set the space between two letters",
3479 "-label string assign a label to an image",
3480 "-limit type value pixel cache resource limit",
3481 "-loop iterations add Netscape loop extension to your GIF animation",
3482 "-mask filename associate a mask with the image",
3483 "-mattecolor color frame color",
3484 "-monitor monitor progress",
3485 "-orient type image orientation",
3486 "-page geometry size and location of an image canvas (setting)",
3487 "-ping efficiently determine image attributes",
3488 "-pointsize value font point size",
3489 "-precision value maximum number of significant digits to print",
3490 "-preview type image preview type",
3491 "-quality value JPEG/MIFF/PNG compression level",
3492 "-quiet suppress all warning messages",
3493 "-red-primary point chromaticity red primary point",
3494 "-regard-warnings pay attention to warning messages",
3495 "-remap filename transform image colors to match this set of colors",
3496 "-respect-parentheses settings remain in effect until parenthesis boundary",
3497 "-sampling-factor geometry",
3498 " horizontal and vertical sampling factor",
3499 "-scene value image scene number",
3500 "-seed value seed a new sequence of pseudo-random numbers",
3501 "-size geometry width and height of image",
3502 "-stretch type render text with this font stretch",
3503 "-stroke color graphic primitive stroke color",
3504 "-strokewidth value graphic primitive stroke width",
3505 "-style type render text with this font style",
3506 "-synchronize synchronize image to storage device",
3507 "-taint declare the image as modified",
3508 "-texture filename name of texture to tile onto the image background",
3509 "-tile-offset geometry",
3511 "-treedepth value color tree depth",
3512 "-transparent-color color",
3513 " transparent color",
3514 "-undercolor color annotation bounding box color",
3515 "-units type the units of image resolution",
3516 "-verbose print detailed information about the image",
3517 "-view FlashPix viewing transforms",
3518 "-virtual-pixel method",
3519 " virtual pixel access method",
3520 "-weight type render text with this font weight",
3521 "-white-point point chromaticity white point",
3526 "-delete indexes delete the image from the image sequence",
3527 "-duplicate count,indexes",
3528 " duplicate an image one or more times",
3529 "-insert index insert last image into the image sequence",
3530 "-reverse reverse image sequence",
3531 "-swap indexes swap two images in the image sequence",
3538 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3539 (void) printf("Copyright: %s\n",GetMagickCopyright());
3540 (void) printf("Features: %s\n\n",GetMagickFeatures());
3541 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3543 (void) printf("\nImage Settings:\n");
3544 for (p=settings; *p != (char *) NULL; p++)
3545 (void) printf(" %s\n",*p);
3546 (void) printf("\nImage Operators:\n");
3547 for (p=operators; *p != (char *) NULL; p++)
3548 (void) printf(" %s\n",*p);
3549 (void) printf("\nImage Sequence Operators:\n");
3550 for (p=sequence_operators; *p != (char *) NULL; p++)
3551 (void) printf(" %s\n",*p);
3552 (void) printf("\nImage Stack Operators:\n");
3553 for (p=stack_operators; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nMiscellaneous Options:\n");
3556 for (p=miscellaneous; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3559 "\nBy default, the image format of `file' is determined by its magic\n");
3561 "number. To specify a particular image format, precede the filename\n");
3563 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3565 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3566 (void) printf("'-' for standard input or output.\n");
3567 return(MagickFalse);
3570 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3571 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3573 #define DestroyMogrify() \
3575 if (format != (char *) NULL) \
3576 format=DestroyString(format); \
3577 if (path != (char *) NULL) \
3578 path=DestroyString(path); \
3579 DestroyImageStack(); \
3580 for (i=0; i < (ssize_t) argc; i++) \
3581 argv[i]=DestroyString(argv[i]); \
3582 argv=(char **) RelinquishMagickMemory(argv); \
3584 #define ThrowMogrifyException(asperity,tag,option) \
3586 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3589 return(MagickFalse); \
3591 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3593 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3594 "InvalidArgument","`%s': %s",argument,option); \
3596 return(MagickFalse); \
3608 image_stack[MaxImageStackDepth+1];
3616 respect_parenthesis;
3631 assert(image_info != (ImageInfo *) NULL);
3632 assert(image_info->signature == MagickSignature);
3633 if (image_info->debug != MagickFalse)
3634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3635 assert(exception != (ExceptionInfo *) NULL);
3639 if ((LocaleCompare("version",option+1) == 0) ||
3640 (LocaleCompare("-version",option+1) == 0))
3642 (void) fprintf(stdout,"Version: %s\n",
3643 GetMagickVersion((size_t *) NULL));
3644 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
3645 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
3646 return(MagickFalse);
3650 return(MogrifyUsage());
3651 format=(char *) NULL;
3653 global_colormap=MagickFalse;
3657 option=(char *) NULL;
3659 respect_parenthesis=MagickFalse;
3664 ReadCommandlLine(argc,&argv);
3665 status=ExpandFilenames(&argc,&argv);
3666 if (status == MagickFalse)
3667 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3668 GetExceptionMessage(errno));
3669 for (i=1; i < (ssize_t) argc; i++)
3672 if (LocaleCompare(option,"(") == 0)
3674 FireImageStack(MagickFalse,MagickTrue,pend);
3675 if (k == MaxImageStackDepth)
3676 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3681 if (LocaleCompare(option,")") == 0)
3683 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3685 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3689 if (IsCommandOption(option) == MagickFalse)
3692 backup_filename[MaxTextExtent],
3699 Option is a file name: begin by reading image from specified file.
3701 FireImageStack(MagickFalse,MagickFalse,pend);
3703 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3705 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3706 images=ReadImages(image_info,exception);
3707 status&=(images != (Image *) NULL) &&
3708 (exception->severity < ErrorException);
3709 if (images == (Image *) NULL)
3711 if (format != (char *) NULL)
3712 (void) CopyMagickString(images->filename,images->magick_filename,
3714 if (path != (char *) NULL)
3716 GetPathComponent(option,TailPath,filename);
3717 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
3718 path,*DirectorySeparator,filename);
3720 if (format != (char *) NULL)
3721 AppendImageFormat(format,images->filename);
3722 AppendImageStack(images);
3723 FinalizeImageSettings(image_info,image,MagickFalse);
3724 if (global_colormap != MagickFalse)
3729 quantize_info=AcquireQuantizeInfo(image_info);
3730 (void) RemapImages(quantize_info,images,(Image *) NULL);
3731 quantize_info=DestroyQuantizeInfo(quantize_info);
3733 *backup_filename='\0';
3734 if ((LocaleCompare(image->filename,"-") != 0) &&
3735 (IsPathWritable(image->filename) != MagickFalse))
3741 Rename image file as backup.
3743 (void) CopyMagickString(backup_filename,image->filename,
3745 for (i=0; i < 6; i++)
3747 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3748 if (IsPathAccessible(backup_filename) == MagickFalse)
3751 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3752 (rename(image->filename,backup_filename) != 0))
3753 *backup_filename='\0';
3756 Write transmogrified image to disk.
3758 image_info->synchronize=MagickTrue;
3759 status&=WriteImages(image_info,image,image->filename,exception);
3760 if ((status == MagickFalse) && (*backup_filename != '\0'))
3761 (void) remove(backup_filename);
3762 RemoveAllImageStack();
3765 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3766 switch (*(option+1))
3770 if (LocaleCompare("adaptive-blur",option+1) == 0)
3773 if (i == (ssize_t) argc)
3774 ThrowMogrifyException(OptionError,"MissingArgument",option);
3775 if (IsGeometry(argv[i]) == MagickFalse)
3776 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3779 if (LocaleCompare("adaptive-resize",option+1) == 0)
3782 if (i == (ssize_t) argc)
3783 ThrowMogrifyException(OptionError,"MissingArgument",option);
3784 if (IsGeometry(argv[i]) == MagickFalse)
3785 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3788 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3791 if (i == (ssize_t) argc)
3792 ThrowMogrifyException(OptionError,"MissingArgument",option);
3793 if (IsGeometry(argv[i]) == MagickFalse)
3794 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3797 if (LocaleCompare("affine",option+1) == 0)
3802 if (i == (ssize_t) argc)
3803 ThrowMogrifyException(OptionError,"MissingArgument",option);
3806 if (LocaleCompare("alpha",option+1) == 0)
3814 if (i == (ssize_t) argc)
3815 ThrowMogrifyException(OptionError,"MissingArgument",option);
3816 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3818 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3822 if (LocaleCompare("annotate",option+1) == 0)
3827 if (i == (ssize_t) argc)
3828 ThrowMogrifyException(OptionError,"MissingArgument",option);
3829 if (IsGeometry(argv[i]) == MagickFalse)
3830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3831 if (i == (ssize_t) argc)
3832 ThrowMogrifyException(OptionError,"MissingArgument",option);
3836 if (LocaleCompare("antialias",option+1) == 0)
3838 if (LocaleCompare("append",option+1) == 0)
3840 if (LocaleCompare("attenuate",option+1) == 0)
3845 if (i == (ssize_t) (argc-1))
3846 ThrowMogrifyException(OptionError,"MissingArgument",option);
3847 if (IsGeometry(argv[i]) == MagickFalse)
3848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3851 if (LocaleCompare("authenticate",option+1) == 0)
3856 if (i == (ssize_t) argc)
3857 ThrowMogrifyException(OptionError,"MissingArgument",option);
3860 if (LocaleCompare("auto-gamma",option+1) == 0)
3862 if (LocaleCompare("auto-level",option+1) == 0)
3864 if (LocaleCompare("auto-orient",option+1) == 0)
3866 if (LocaleCompare("average",option+1) == 0)
3868 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3872 if (LocaleCompare("background",option+1) == 0)
3877 if (i == (ssize_t) argc)
3878 ThrowMogrifyException(OptionError,"MissingArgument",option);
3881 if (LocaleCompare("bias",option+1) == 0)
3886 if (i == (ssize_t) (argc-1))
3887 ThrowMogrifyException(OptionError,"MissingArgument",option);
3888 if (IsGeometry(argv[i]) == MagickFalse)
3889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3892 if (LocaleCompare("black-point-compensation",option+1) == 0)
3894 if (LocaleCompare("black-threshold",option+1) == 0)
3899 if (i == (ssize_t) argc)
3900 ThrowMogrifyException(OptionError,"MissingArgument",option);
3901 if (IsGeometry(argv[i]) == MagickFalse)
3902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3905 if (LocaleCompare("blue-primary",option+1) == 0)
3910 if (i == (ssize_t) argc)
3911 ThrowMogrifyException(OptionError,"MissingArgument",option);
3912 if (IsGeometry(argv[i]) == MagickFalse)
3913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3916 if (LocaleCompare("blue-shift",option+1) == 0)
3919 if (i == (ssize_t) argc)
3920 ThrowMogrifyException(OptionError,"MissingArgument",option);
3921 if (IsGeometry(argv[i]) == MagickFalse)
3922 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3925 if (LocaleCompare("blur",option+1) == 0)
3928 if (i == (ssize_t) argc)
3929 ThrowMogrifyException(OptionError,"MissingArgument",option);
3930 if (IsGeometry(argv[i]) == MagickFalse)
3931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 if (LocaleCompare("border",option+1) == 0)
3939 if (i == (ssize_t) argc)
3940 ThrowMogrifyException(OptionError,"MissingArgument",option);
3941 if (IsGeometry(argv[i]) == MagickFalse)
3942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3945 if (LocaleCompare("bordercolor",option+1) == 0)
3950 if (i == (ssize_t) argc)
3951 ThrowMogrifyException(OptionError,"MissingArgument",option);
3954 if (LocaleCompare("box",option+1) == 0)
3959 if (i == (ssize_t) argc)
3960 ThrowMogrifyException(OptionError,"MissingArgument",option);
3963 if (LocaleCompare("brightness-contrast",option+1) == 0)
3966 if (i == (ssize_t) argc)
3967 ThrowMogrifyException(OptionError,"MissingArgument",option);
3968 if (IsGeometry(argv[i]) == MagickFalse)
3969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3972 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3976 if (LocaleCompare("cache",option+1) == 0)
3981 if (i == (ssize_t) argc)
3982 ThrowMogrifyException(OptionError,"MissingArgument",option);
3983 if (IsGeometry(argv[i]) == MagickFalse)
3984 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3987 if (LocaleCompare("caption",option+1) == 0)
3992 if (i == (ssize_t) argc)
3993 ThrowMogrifyException(OptionError,"MissingArgument",option);
3996 if (LocaleCompare("channel",option+1) == 0)
4004 if (i == (ssize_t) (argc-1))
4005 ThrowMogrifyException(OptionError,"MissingArgument",option);
4006 channel=ParseChannelOption(argv[i]);
4008 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4012 if (LocaleCompare("cdl",option+1) == 0)
4017 if (i == (ssize_t) (argc-1))
4018 ThrowMogrifyException(OptionError,"MissingArgument",option);
4021 if (LocaleCompare("charcoal",option+1) == 0)
4026 if (i == (ssize_t) argc)
4027 ThrowMogrifyException(OptionError,"MissingArgument",option);
4028 if (IsGeometry(argv[i]) == MagickFalse)
4029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4032 if (LocaleCompare("chop",option+1) == 0)
4037 if (i == (ssize_t) argc)
4038 ThrowMogrifyException(OptionError,"MissingArgument",option);
4039 if (IsGeometry(argv[i]) == MagickFalse)
4040 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4043 if (LocaleCompare("clamp",option+1) == 0)
4045 if (LocaleCompare("clip",option+1) == 0)
4047 if (LocaleCompare("clip-mask",option+1) == 0)
4052 if (i == (ssize_t) argc)
4053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4056 if (LocaleCompare("clut",option+1) == 0)
4058 if (LocaleCompare("coalesce",option+1) == 0)
4060 if (LocaleCompare("colorize",option+1) == 0)
4065 if (i == (ssize_t) argc)
4066 ThrowMogrifyException(OptionError,"MissingArgument",option);
4067 if (IsGeometry(argv[i]) == MagickFalse)
4068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4071 if (LocaleCompare("color-matrix",option+1) == 0)
4079 if (i == (ssize_t) (argc-1))
4080 ThrowMogrifyException(OptionError,"MissingArgument",option);
4081 kernel_info=AcquireKernelInfo(argv[i]);
4082 if (kernel_info == (KernelInfo *) NULL)
4083 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4084 kernel_info=DestroyKernelInfo(kernel_info);
4087 if (LocaleCompare("colors",option+1) == 0)
4092 if (i == (ssize_t) argc)
4093 ThrowMogrifyException(OptionError,"MissingArgument",option);
4094 if (IsGeometry(argv[i]) == MagickFalse)
4095 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4098 if (LocaleCompare("colorspace",option+1) == 0)
4106 if (i == (ssize_t) argc)
4107 ThrowMogrifyException(OptionError,"MissingArgument",option);
4108 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4111 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4115 if (LocaleCompare("combine",option+1) == 0)
4117 if (LocaleCompare("comment",option+1) == 0)
4122 if (i == (ssize_t) argc)
4123 ThrowMogrifyException(OptionError,"MissingArgument",option);
4126 if (LocaleCompare("composite",option+1) == 0)
4128 if (LocaleCompare("compress",option+1) == 0)
4136 if (i == (ssize_t) argc)
4137 ThrowMogrifyException(OptionError,"MissingArgument",option);
4138 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4141 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4145 if (LocaleCompare("concurrent",option+1) == 0)
4147 if (LocaleCompare("contrast",option+1) == 0)
4149 if (LocaleCompare("contrast-stretch",option+1) == 0)
4152 if (i == (ssize_t) argc)
4153 ThrowMogrifyException(OptionError,"MissingArgument",option);
4154 if (IsGeometry(argv[i]) == MagickFalse)
4155 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4158 if (LocaleCompare("convolve",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4168 kernel_info=AcquireKernelInfo(argv[i]);
4169 if (kernel_info == (KernelInfo *) NULL)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4171 kernel_info=DestroyKernelInfo(kernel_info);
4174 if (LocaleCompare("crop",option+1) == 0)
4179 if (i == (ssize_t) argc)
4180 ThrowMogrifyException(OptionError,"MissingArgument",option);
4181 if (IsGeometry(argv[i]) == MagickFalse)
4182 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4185 if (LocaleCompare("cycle",option+1) == 0)
4190 if (i == (ssize_t) argc)
4191 ThrowMogrifyException(OptionError,"MissingArgument",option);
4192 if (IsGeometry(argv[i]) == MagickFalse)
4193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4196 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4200 if (LocaleCompare("decipher",option+1) == 0)
4205 if (i == (ssize_t) (argc-1))
4206 ThrowMogrifyException(OptionError,"MissingArgument",option);
4209 if (LocaleCompare("deconstruct",option+1) == 0)
4211 if (LocaleCompare("debug",option+1) == 0)
4219 if (i == (ssize_t) argc)
4220 ThrowMogrifyException(OptionError,"MissingArgument",option);
4221 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4223 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4225 (void) SetLogEventMask(argv[i]);
4228 if (LocaleCompare("define",option+1) == 0)
4231 if (i == (ssize_t) argc)
4232 ThrowMogrifyException(OptionError,"MissingArgument",option);
4238 define=GetImageOption(image_info,argv[i]);
4239 if (define == (const char *) NULL)
4240 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4245 if (LocaleCompare("delay",option+1) == 0)
4250 if (i == (ssize_t) argc)
4251 ThrowMogrifyException(OptionError,"MissingArgument",option);
4252 if (IsGeometry(argv[i]) == MagickFalse)
4253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4256 if (LocaleCompare("delete",option+1) == 0)
4261 if (i == (ssize_t) (argc-1))
4262 ThrowMogrifyException(OptionError,"MissingArgument",option);
4263 if (IsGeometry(argv[i]) == MagickFalse)
4264 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4267 if (LocaleCompare("density",option+1) == 0)
4272 if (i == (ssize_t) argc)
4273 ThrowMogrifyException(OptionError,"MissingArgument",option);
4274 if (IsGeometry(argv[i]) == MagickFalse)
4275 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4278 if (LocaleCompare("depth",option+1) == 0)
4283 if (i == (ssize_t) argc)
4284 ThrowMogrifyException(OptionError,"MissingArgument",option);
4285 if (IsGeometry(argv[i]) == MagickFalse)
4286 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4289 if (LocaleCompare("deskew",option+1) == 0)
4294 if (i == (ssize_t) argc)
4295 ThrowMogrifyException(OptionError,"MissingArgument",option);
4296 if (IsGeometry(argv[i]) == MagickFalse)
4297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4300 if (LocaleCompare("despeckle",option+1) == 0)
4302 if (LocaleCompare("dft",option+1) == 0)
4304 if (LocaleCompare("direction",option+1) == 0)
4312 if (i == (ssize_t) argc)
4313 ThrowMogrifyException(OptionError,"MissingArgument",option);
4314 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4317 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4321 if (LocaleCompare("display",option+1) == 0)
4326 if (i == (ssize_t) argc)
4327 ThrowMogrifyException(OptionError,"MissingArgument",option);
4330 if (LocaleCompare("dispose",option+1) == 0)
4338 if (i == (ssize_t) argc)
4339 ThrowMogrifyException(OptionError,"MissingArgument",option);
4340 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4342 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4346 if (LocaleCompare("distort",option+1) == 0)
4352 if (i == (ssize_t) argc)
4353 ThrowMogrifyException(OptionError,"MissingArgument",option);
4354 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4356 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4359 if (i == (ssize_t) (argc-1))
4360 ThrowMogrifyException(OptionError,"MissingArgument",option);
4363 if (LocaleCompare("dither",option+1) == 0)
4371 if (i == (ssize_t) argc)
4372 ThrowMogrifyException(OptionError,"MissingArgument",option);
4373 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4375 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4379 if (LocaleCompare("draw",option+1) == 0)
4384 if (i == (ssize_t) argc)
4385 ThrowMogrifyException(OptionError,"MissingArgument",option);
4388 if (LocaleCompare("duplicate",option+1) == 0)
4393 if (i == (ssize_t) (argc-1))
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4395 if (IsGeometry(argv[i]) == MagickFalse)
4396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4399 if (LocaleCompare("duration",option+1) == 0)
4404 if (i == (ssize_t) (argc-1))
4405 ThrowMogrifyException(OptionError,"MissingArgument",option);
4406 if (IsGeometry(argv[i]) == MagickFalse)
4407 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4410 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4414 if (LocaleCompare("edge",option+1) == 0)
4419 if (i == (ssize_t) argc)
4420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4421 if (IsGeometry(argv[i]) == MagickFalse)
4422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4425 if (LocaleCompare("emboss",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("encipher",option+1) == 0)
4441 if (i == (ssize_t) argc)
4442 ThrowMogrifyException(OptionError,"MissingArgument",option);
4445 if (LocaleCompare("encoding",option+1) == 0)
4450 if (i == (ssize_t) argc)
4451 ThrowMogrifyException(OptionError,"MissingArgument",option);
4454 if (LocaleCompare("endian",option+1) == 0)
4462 if (i == (ssize_t) argc)
4463 ThrowMogrifyException(OptionError,"MissingArgument",option);
4464 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4466 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4470 if (LocaleCompare("enhance",option+1) == 0)
4472 if (LocaleCompare("equalize",option+1) == 0)
4474 if (LocaleCompare("evaluate",option+1) == 0)
4482 if (i == (ssize_t) argc)
4483 ThrowMogrifyException(OptionError,"MissingArgument",option);
4484 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4486 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4489 if (i == (ssize_t) (argc-1))
4490 ThrowMogrifyException(OptionError,"MissingArgument",option);
4491 if (IsGeometry(argv[i]) == MagickFalse)
4492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4495 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4503 if (i == (ssize_t) argc)
4504 ThrowMogrifyException(OptionError,"MissingArgument",option);
4505 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4507 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4511 if (LocaleCompare("extent",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4518 if (IsGeometry(argv[i]) == MagickFalse)
4519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4522 if (LocaleCompare("extract",option+1) == 0)
4527 if (i == (ssize_t) argc)
4528 ThrowMogrifyException(OptionError,"MissingArgument",option);
4529 if (IsGeometry(argv[i]) == MagickFalse)
4530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4533 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4537 if (LocaleCompare("family",option+1) == 0)
4542 if (i == (ssize_t) (argc-1))
4543 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 if (LocaleCompare("fill",option+1) == 0)
4551 if (i == (ssize_t) argc)
4552 ThrowMogrifyException(OptionError,"MissingArgument",option);
4555 if (LocaleCompare("filter",option+1) == 0)
4563 if (i == (ssize_t) argc)
4564 ThrowMogrifyException(OptionError,"MissingArgument",option);
4565 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4567 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4571 if (LocaleCompare("flatten",option+1) == 0)
4573 if (LocaleCompare("flip",option+1) == 0)
4575 if (LocaleCompare("flop",option+1) == 0)
4577 if (LocaleCompare("floodfill",option+1) == 0)
4582 if (i == (ssize_t) argc)
4583 ThrowMogrifyException(OptionError,"MissingArgument",option);
4584 if (IsGeometry(argv[i]) == MagickFalse)
4585 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4587 if (i == (ssize_t) argc)
4588 ThrowMogrifyException(OptionError,"MissingArgument",option);
4591 if (LocaleCompare("font",option+1) == 0)
4596 if (i == (ssize_t) argc)
4597 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (LocaleCompare("format",option+1) == 0)
4602 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4603 (void) CloneString(&format,(char *) NULL);
4607 if (i == (ssize_t) argc)
4608 ThrowMogrifyException(OptionError,"MissingArgument",option);
4609 (void) CloneString(&format,argv[i]);
4610 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4611 (void) ConcatenateMagickString(image_info->filename,":",
4613 (void) SetImageInfo(image_info,0,exception);
4614 if (*image_info->magick == '\0')
4615 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4619 if (LocaleCompare("frame",option+1) == 0)
4624 if (i == (ssize_t) argc)
4625 ThrowMogrifyException(OptionError,"MissingArgument",option);
4626 if (IsGeometry(argv[i]) == MagickFalse)
4627 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4630 if (LocaleCompare("function",option+1) == 0)
4638 if (i == (ssize_t) argc)
4639 ThrowMogrifyException(OptionError,"MissingArgument",option);
4640 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4642 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4644 if (i == (ssize_t) (argc-1))
4645 ThrowMogrifyException(OptionError,"MissingArgument",option);
4648 if (LocaleCompare("fuzz",option+1) == 0)
4653 if (i == (ssize_t) argc)
4654 ThrowMogrifyException(OptionError,"MissingArgument",option);
4655 if (IsGeometry(argv[i]) == MagickFalse)
4656 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4659 if (LocaleCompare("fx",option+1) == 0)
4664 if (i == (ssize_t) (argc-1))
4665 ThrowMogrifyException(OptionError,"MissingArgument",option);
4668 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4672 if (LocaleCompare("gamma",option+1) == 0)
4675 if (i == (ssize_t) argc)
4676 ThrowMogrifyException(OptionError,"MissingArgument",option);
4677 if (IsGeometry(argv[i]) == MagickFalse)
4678 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4681 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4682 (LocaleCompare("gaussian",option+1) == 0))
4685 if (i == (ssize_t) argc)
4686 ThrowMogrifyException(OptionError,"MissingArgument",option);
4687 if (IsGeometry(argv[i]) == MagickFalse)
4688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4691 if (LocaleCompare("geometry",option+1) == 0)
4696 if (i == (ssize_t) argc)
4697 ThrowMogrifyException(OptionError,"MissingArgument",option);
4698 if (IsGeometry(argv[i]) == MagickFalse)
4699 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4702 if (LocaleCompare("gravity",option+1) == 0)
4710 if (i == (ssize_t) argc)
4711 ThrowMogrifyException(OptionError,"MissingArgument",option);
4712 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4714 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4718 if (LocaleCompare("green-primary",option+1) == 0)
4723 if (i == (ssize_t) argc)
4724 ThrowMogrifyException(OptionError,"MissingArgument",option);
4725 if (IsGeometry(argv[i]) == MagickFalse)
4726 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4729 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4733 if (LocaleCompare("hald-clut",option+1) == 0)
4735 if ((LocaleCompare("help",option+1) == 0) ||
4736 (LocaleCompare("-help",option+1) == 0))
4737 return(MogrifyUsage());
4738 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4742 if (LocaleCompare("identify",option+1) == 0)
4744 if (LocaleCompare("idft",option+1) == 0)
4746 if (LocaleCompare("implode",option+1) == 0)
4751 if (i == (ssize_t) argc)
4752 ThrowMogrifyException(OptionError,"MissingArgument",option);
4753 if (IsGeometry(argv[i]) == MagickFalse)
4754 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757 if (LocaleCompare("intent",option+1) == 0)
4765 if (i == (ssize_t) (argc-1))
4766 ThrowMogrifyException(OptionError,"MissingArgument",option);
4767 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4769 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4773 if (LocaleCompare("interlace",option+1) == 0)
4781 if (i == (ssize_t) argc)
4782 ThrowMogrifyException(OptionError,"MissingArgument",option);
4783 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4786 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4790 if (LocaleCompare("interline-spacing",option+1) == 0)
4795 if (i == (ssize_t) (argc-1))
4796 ThrowMogrifyException(OptionError,"MissingArgument",option);
4797 if (IsGeometry(argv[i]) == MagickFalse)
4798 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4801 if (LocaleCompare("interpolate",option+1) == 0)
4809 if (i == (ssize_t) argc)
4810 ThrowMogrifyException(OptionError,"MissingArgument",option);
4811 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4813 if (interpolate < 0)
4814 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4818 if (LocaleCompare("interword-spacing",option+1) == 0)
4823 if (i == (ssize_t) (argc-1))
4824 ThrowMogrifyException(OptionError,"MissingArgument",option);
4825 if (IsGeometry(argv[i]) == MagickFalse)
4826 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4829 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4833 if (LocaleCompare("kerning",option+1) == 0)
4838 if (i == (ssize_t) (argc-1))
4839 ThrowMogrifyException(OptionError,"MissingArgument",option);
4840 if (IsGeometry(argv[i]) == MagickFalse)
4841 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4844 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4848 if (LocaleCompare("label",option+1) == 0)
4853 if (i == (ssize_t) argc)
4854 ThrowMogrifyException(OptionError,"MissingArgument",option);
4857 if (LocaleCompare("lat",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]);
4867 if (LocaleCompare("layers",option+1) == 0)
4875 if (i == (ssize_t) (argc-1))
4876 ThrowMogrifyException(OptionError,"MissingArgument",option);
4877 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4879 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4883 if (LocaleCompare("level",option+1) == 0)
4886 if (i == (ssize_t) argc)
4887 ThrowMogrifyException(OptionError,"MissingArgument",option);
4888 if (IsGeometry(argv[i]) == MagickFalse)
4889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4892 if (LocaleCompare("level-colors",option+1) == 0)
4895 if (i == (ssize_t) argc)
4896 ThrowMogrifyException(OptionError,"MissingArgument",option);
4899 if (LocaleCompare("linewidth",option+1) == 0)
4904 if (i == (ssize_t) argc)
4905 ThrowMogrifyException(OptionError,"MissingArgument",option);
4906 if (IsGeometry(argv[i]) == MagickFalse)
4907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4910 if (LocaleCompare("limit",option+1) == 0)
4924 if (i == (ssize_t) argc)
4925 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4929 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4932 if (i == (ssize_t) argc)
4933 ThrowMogrifyException(OptionError,"MissingArgument",option);
4934 value=strtod(argv[i],&p);
4936 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4940 if (LocaleCompare("liquid-rescale",option+1) == 0)
4943 if (i == (ssize_t) argc)
4944 ThrowMogrifyException(OptionError,"MissingArgument",option);
4945 if (IsGeometry(argv[i]) == MagickFalse)
4946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4949 if (LocaleCompare("list",option+1) == 0)
4957 if (i == (ssize_t) argc)
4958 ThrowMogrifyException(OptionError,"MissingArgument",option);
4959 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4961 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4962 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4964 return(status != 0 ? MagickFalse : MagickTrue);
4966 if (LocaleCompare("log",option+1) == 0)
4971 if ((i == (ssize_t) argc) ||
4972 (strchr(argv[i],'%') == (char *) NULL))
4973 ThrowMogrifyException(OptionError,"MissingArgument",option);
4976 if (LocaleCompare("loop",option+1) == 0)
4981 if (i == (ssize_t) argc)
4982 ThrowMogrifyException(OptionError,"MissingArgument",option);
4983 if (IsGeometry(argv[i]) == MagickFalse)
4984 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4987 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4991 if (LocaleCompare("map",option+1) == 0)
4993 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4997 if (i == (ssize_t) argc)
4998 ThrowMogrifyException(OptionError,"MissingArgument",option);
5001 if (LocaleCompare("mask",option+1) == 0)
5006 if (i == (ssize_t) argc)
5007 ThrowMogrifyException(OptionError,"MissingArgument",option);
5010 if (LocaleCompare("matte",option+1) == 0)
5012 if (LocaleCompare("mattecolor",option+1) == 0)
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,"MissingArgument",option);
5021 if (LocaleCompare("maximum",option+1) == 0)
5023 if (LocaleCompare("minimum",option+1) == 0)
5025 if (LocaleCompare("modulate",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,"MissingArgument",option);
5032 if (IsGeometry(argv[i]) == MagickFalse)
5033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5036 if (LocaleCompare("median",option+1) == 0)
5041 if (i == (ssize_t) argc)
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5043 if (IsGeometry(argv[i]) == MagickFalse)
5044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5047 if (LocaleCompare("mode",option+1) == 0)
5052 if (i == (ssize_t) argc)
5053 ThrowMogrifyException(OptionError,"MissingArgument",option);
5054 if (IsGeometry(argv[i]) == MagickFalse)
5055 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5058 if (LocaleCompare("monitor",option+1) == 0)
5060 if (LocaleCompare("monochrome",option+1) == 0)
5062 if (LocaleCompare("morph",option+1) == 0)
5067 if (i == (ssize_t) (argc-1))
5068 ThrowMogrifyException(OptionError,"MissingArgument",option);
5069 if (IsGeometry(argv[i]) == MagickFalse)
5070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5073 if (LocaleCompare("morphology",option+1) == 0)
5076 token[MaxTextExtent];
5085 if (i == (ssize_t) argc)
5086 ThrowMogrifyException(OptionError,"MissingArgument",option);
5087 GetMagickToken(argv[i],NULL,token);
5088 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5090 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5093 if (i == (ssize_t) (argc-1))
5094 ThrowMogrifyException(OptionError,"MissingArgument",option);
5095 kernel_info=AcquireKernelInfo(argv[i]);
5096 if (kernel_info == (KernelInfo *) NULL)
5097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5098 kernel_info=DestroyKernelInfo(kernel_info);
5101 if (LocaleCompare("mosaic",option+1) == 0)
5103 if (LocaleCompare("motion-blur",option+1) == 0)
5108 if (i == (ssize_t) argc)
5109 ThrowMogrifyException(OptionError,"MissingArgument",option);
5110 if (IsGeometry(argv[i]) == MagickFalse)
5111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5114 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5118 if (LocaleCompare("negate",option+1) == 0)
5120 if (LocaleCompare("noise",option+1) == 0)
5123 if (i == (ssize_t) argc)
5124 ThrowMogrifyException(OptionError,"MissingArgument",option);
5130 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5132 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5136 if (IsGeometry(argv[i]) == MagickFalse)
5137 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5140 if (LocaleCompare("noop",option+1) == 0)
5142 if (LocaleCompare("normalize",option+1) == 0)
5144 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5148 if (LocaleCompare("opaque",option+1) == 0)
5151 if (i == (ssize_t) argc)
5152 ThrowMogrifyException(OptionError,"MissingArgument",option);
5155 if (LocaleCompare("ordered-dither",option+1) == 0)
5160 if (i == (ssize_t) argc)
5161 ThrowMogrifyException(OptionError,"MissingArgument",option);
5164 if (LocaleCompare("orient",option+1) == 0)
5169 orientation=UndefinedOrientation;
5173 if (i == (ssize_t) (argc-1))
5174 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5177 if (orientation < 0)
5178 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5182 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5186 if (LocaleCompare("page",option+1) == 0)
5191 if (i == (ssize_t) argc)
5192 ThrowMogrifyException(OptionError,"MissingArgument",option);
5195 if (LocaleCompare("paint",option+1) == 0)
5200 if (i == (ssize_t) argc)
5201 ThrowMogrifyException(OptionError,"MissingArgument",option);
5202 if (IsGeometry(argv[i]) == MagickFalse)
5203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5206 if (LocaleCompare("path",option+1) == 0)
5208 (void) CloneString(&path,(char *) NULL);
5212 if (i == (ssize_t) argc)
5213 ThrowMogrifyException(OptionError,"MissingArgument",option);
5214 (void) CloneString(&path,argv[i]);
5217 if (LocaleCompare("pointsize",option+1) == 0)
5222 if (i == (ssize_t) argc)
5223 ThrowMogrifyException(OptionError,"MissingArgument",option);
5224 if (IsGeometry(argv[i]) == MagickFalse)
5225 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5228 if (LocaleCompare("polaroid",option+1) == 0)
5233 if (i == (ssize_t) argc)
5234 ThrowMogrifyException(OptionError,"MissingArgument",option);
5235 if (IsGeometry(argv[i]) == MagickFalse)
5236 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5239 if (LocaleCompare("posterize",option+1) == 0)
5244 if (i == (ssize_t) argc)
5245 ThrowMogrifyException(OptionError,"MissingArgument",option);
5246 if (IsGeometry(argv[i]) == MagickFalse)
5247 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5250 if (LocaleCompare("precision",option+1) == 0)
5255 if (i == (ssize_t) argc)
5256 ThrowMogrifyException(OptionError,"MissingArgument",option);
5257 if (IsGeometry(argv[i]) == MagickFalse)
5258 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5261 if (LocaleCompare("print",option+1) == 0)
5266 if (i == (ssize_t) argc)
5267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5270 if (LocaleCompare("process",option+1) == 0)
5275 if (i == (ssize_t) (argc-1))
5276 ThrowMogrifyException(OptionError,"MissingArgument",option);
5279 if (LocaleCompare("profile",option+1) == 0)
5282 if (i == (ssize_t) argc)
5283 ThrowMogrifyException(OptionError,"MissingArgument",option);
5286 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5290 if (LocaleCompare("quality",option+1) == 0)
5295 if (i == (ssize_t) argc)
5296 ThrowMogrifyException(OptionError,"MissingArgument",option);
5297 if (IsGeometry(argv[i]) == MagickFalse)
5298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5301 if (LocaleCompare("quantize",option+1) == 0)
5309 if (i == (ssize_t) (argc-1))
5310 ThrowMogrifyException(OptionError,"MissingArgument",option);
5311 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5314 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5318 if (LocaleCompare("quiet",option+1) == 0)
5320 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5324 if (LocaleCompare("radial-blur",option+1) == 0)
5327 if (i == (ssize_t) argc)
5328 ThrowMogrifyException(OptionError,"MissingArgument",option);
5329 if (IsGeometry(argv[i]) == MagickFalse)
5330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5333 if (LocaleCompare("raise",option+1) == 0)
5336 if (i == (ssize_t) argc)
5337 ThrowMogrifyException(OptionError,"MissingArgument",option);
5338 if (IsGeometry(argv[i]) == MagickFalse)
5339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5342 if (LocaleCompare("random-threshold",option+1) == 0)
5347 if (i == (ssize_t) argc)
5348 ThrowMogrifyException(OptionError,"MissingArgument",option);
5349 if (IsGeometry(argv[i]) == MagickFalse)
5350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5353 if (LocaleCompare("recolor",option+1) == 0)
5358 if (i == (ssize_t) (argc-1))
5359 ThrowMogrifyException(OptionError,"MissingArgument",option);
5360 if (IsGeometry(argv[i]) == MagickFalse)
5361 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5364 if (LocaleCompare("red-primary",option+1) == 0)
5369 if (i == (ssize_t) argc)
5370 ThrowMogrifyException(OptionError,"MissingArgument",option);
5371 if (IsGeometry(argv[i]) == MagickFalse)
5372 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5374 if (LocaleCompare("regard-warnings",option+1) == 0)
5376 if (LocaleCompare("region",option+1) == 0)
5381 if (i == (ssize_t) argc)
5382 ThrowMogrifyException(OptionError,"MissingArgument",option);
5383 if (IsGeometry(argv[i]) == MagickFalse)
5384 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5387 if (LocaleCompare("remap",option+1) == 0)
5392 if (i == (ssize_t) (argc-1))
5393 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 if (LocaleCompare("render",option+1) == 0)
5398 if (LocaleCompare("repage",option+1) == 0)
5403 if (i == (ssize_t) argc)
5404 ThrowMogrifyException(OptionError,"MissingArgument",option);
5405 if (IsGeometry(argv[i]) == MagickFalse)
5406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5409 if (LocaleCompare("resample",option+1) == 0)
5414 if (i == (ssize_t) argc)
5415 ThrowMogrifyException(OptionError,"MissingArgument",option);
5416 if (IsGeometry(argv[i]) == MagickFalse)
5417 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5420 if (LocaleCompare("resize",option+1) == 0)
5425 if (i == (ssize_t) argc)
5426 ThrowMogrifyException(OptionError,"MissingArgument",option);
5427 if (IsGeometry(argv[i]) == MagickFalse)
5428 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5431 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5433 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5436 if (LocaleCompare("reverse",option+1) == 0)
5438 if (LocaleCompare("roll",option+1) == 0)
5443 if (i == (ssize_t) argc)
5444 ThrowMogrifyException(OptionError,"MissingArgument",option);
5445 if (IsGeometry(argv[i]) == MagickFalse)
5446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5449 if (LocaleCompare("rotate",option+1) == 0)
5452 if (i == (ssize_t) argc)
5453 ThrowMogrifyException(OptionError,"MissingArgument",option);
5454 if (IsGeometry(argv[i]) == MagickFalse)
5455 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5458 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5462 if (LocaleCompare("sample",option+1) == 0)
5467 if (i == (ssize_t) argc)
5468 ThrowMogrifyException(OptionError,"MissingArgument",option);
5469 if (IsGeometry(argv[i]) == MagickFalse)
5470 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5473 if (LocaleCompare("sampling-factor",option+1) == 0)
5478 if (i == (ssize_t) argc)
5479 ThrowMogrifyException(OptionError,"MissingArgument",option);
5480 if (IsGeometry(argv[i]) == MagickFalse)
5481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 if (LocaleCompare("scale",option+1) == 0)
5489 if (i == (ssize_t) argc)
5490 ThrowMogrifyException(OptionError,"MissingArgument",option);
5491 if (IsGeometry(argv[i]) == MagickFalse)
5492 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5495 if (LocaleCompare("scene",option+1) == 0)
5500 if (i == (ssize_t) argc)
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5502 if (IsGeometry(argv[i]) == MagickFalse)
5503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5506 if (LocaleCompare("seed",option+1) == 0)
5511 if (i == (ssize_t) argc)
5512 ThrowMogrifyException(OptionError,"MissingArgument",option);
5513 if (IsGeometry(argv[i]) == MagickFalse)
5514 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5517 if (LocaleCompare("segment",option+1) == 0)
5522 if (i == (ssize_t) argc)
5523 ThrowMogrifyException(OptionError,"MissingArgument",option);
5524 if (IsGeometry(argv[i]) == MagickFalse)
5525 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5528 if (LocaleCompare("selective-blur",option+1) == 0)
5531 if (i == (ssize_t) argc)
5532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 if (IsGeometry(argv[i]) == MagickFalse)
5534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 if (LocaleCompare("separate",option+1) == 0)
5539 if (LocaleCompare("sepia-tone",option+1) == 0)
5544 if (i == (ssize_t) argc)
5545 ThrowMogrifyException(OptionError,"MissingArgument",option);
5546 if (IsGeometry(argv[i]) == MagickFalse)
5547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5550 if (LocaleCompare("set",option+1) == 0)
5553 if (i == (ssize_t) argc)
5554 ThrowMogrifyException(OptionError,"MissingArgument",option);
5558 if (i == (ssize_t) argc)
5559 ThrowMogrifyException(OptionError,"MissingArgument",option);
5562 if (LocaleCompare("shade",option+1) == 0)
5565 if (i == (ssize_t) argc)
5566 ThrowMogrifyException(OptionError,"MissingArgument",option);
5567 if (IsGeometry(argv[i]) == MagickFalse)
5568 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5571 if (LocaleCompare("shadow",option+1) == 0)
5576 if (i == (ssize_t) argc)
5577 ThrowMogrifyException(OptionError,"MissingArgument",option);
5578 if (IsGeometry(argv[i]) == MagickFalse)
5579 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5582 if (LocaleCompare("sharpen",option+1) == 0)
5585 if (i == (ssize_t) argc)
5586 ThrowMogrifyException(OptionError,"MissingArgument",option);
5587 if (IsGeometry(argv[i]) == MagickFalse)
5588 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5591 if (LocaleCompare("shave",option+1) == 0)
5596 if (i == (ssize_t) argc)
5597 ThrowMogrifyException(OptionError,"MissingArgument",option);
5598 if (IsGeometry(argv[i]) == MagickFalse)
5599 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5602 if (LocaleCompare("shear",option+1) == 0)
5605 if (i == (ssize_t) argc)
5606 ThrowMogrifyException(OptionError,"MissingArgument",option);
5607 if (IsGeometry(argv[i]) == MagickFalse)
5608 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5611 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5614 if (i == (ssize_t) (argc-1))
5615 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 if (IsGeometry(argv[i]) == MagickFalse)
5617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620 if (LocaleCompare("size",option+1) == 0)
5625 if (i == (ssize_t) argc)
5626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 if (IsGeometry(argv[i]) == MagickFalse)
5628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 if (LocaleCompare("sketch",option+1) == 0)
5636 if (i == (ssize_t) argc)
5637 ThrowMogrifyException(OptionError,"MissingArgument",option);
5638 if (IsGeometry(argv[i]) == MagickFalse)
5639 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleCompare("smush",option+1) == 0)
5645 if (i == (ssize_t) argc)
5646 ThrowMogrifyException(OptionError,"MissingArgument",option);
5647 if (IsGeometry(argv[i]) == MagickFalse)
5648 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5652 if (LocaleCompare("solarize",option+1) == 0)
5657 if (i == (ssize_t) argc)
5658 ThrowMogrifyException(OptionError,"MissingArgument",option);
5659 if (IsGeometry(argv[i]) == MagickFalse)
5660 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5663 if (LocaleCompare("sparse-color",option+1) == 0)
5669 if (i == (ssize_t) argc)
5670 ThrowMogrifyException(OptionError,"MissingArgument",option);
5671 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5673 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5676 if (i == (ssize_t) (argc-1))
5677 ThrowMogrifyException(OptionError,"MissingArgument",option);
5680 if (LocaleCompare("spread",option+1) == 0)
5685 if (i == (ssize_t) argc)
5686 ThrowMogrifyException(OptionError,"MissingArgument",option);
5687 if (IsGeometry(argv[i]) == MagickFalse)
5688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5691 if (LocaleCompare("statistic",option+1) == 0)
5699 if (i == (ssize_t) argc)
5700 ThrowMogrifyException(OptionError,"MissingArgument",option);
5701 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5703 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5706 if (i == (ssize_t) (argc-1))
5707 ThrowMogrifyException(OptionError,"MissingArgument",option);
5708 if (IsGeometry(argv[i]) == MagickFalse)
5709 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5712 if (LocaleCompare("stretch",option+1) == 0)
5720 if (i == (ssize_t) (argc-1))
5721 ThrowMogrifyException(OptionError,"MissingArgument",option);
5722 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5724 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5728 if (LocaleCompare("strip",option+1) == 0)
5730 if (LocaleCompare("stroke",option+1) == 0)
5735 if (i == (ssize_t) argc)
5736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5739 if (LocaleCompare("strokewidth",option+1) == 0)
5744 if (i == (ssize_t) argc)
5745 ThrowMogrifyException(OptionError,"MissingArgument",option);
5746 if (IsGeometry(argv[i]) == MagickFalse)
5747 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5750 if (LocaleCompare("style",option+1) == 0)
5758 if (i == (ssize_t) (argc-1))
5759 ThrowMogrifyException(OptionError,"MissingArgument",option);
5760 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5762 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5766 if (LocaleCompare("swap",option+1) == 0)
5771 if (i == (ssize_t) (argc-1))
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 if (LocaleCompare("swirl",option+1) == 0)
5782 if (i == (ssize_t) argc)
5783 ThrowMogrifyException(OptionError,"MissingArgument",option);
5784 if (IsGeometry(argv[i]) == MagickFalse)
5785 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5788 if (LocaleCompare("synchronize",option+1) == 0)
5790 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5794 if (LocaleCompare("taint",option+1) == 0)
5796 if (LocaleCompare("texture",option+1) == 0)
5801 if (i == (ssize_t) argc)
5802 ThrowMogrifyException(OptionError,"MissingArgument",option);
5805 if (LocaleCompare("tile",option+1) == 0)
5810 if (i == (ssize_t) (argc-1))
5811 ThrowMogrifyException(OptionError,"MissingArgument",option);
5814 if (LocaleCompare("tile-offset",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("tint",option+1) == 0)
5830 if (i == (ssize_t) (argc-1))
5831 ThrowMogrifyException(OptionError,"MissingArgument",option);
5832 if (IsGeometry(argv[i]) == MagickFalse)
5833 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5836 if (LocaleCompare("transform",option+1) == 0)
5838 if (LocaleCompare("transpose",option+1) == 0)
5840 if (LocaleCompare("transverse",option+1) == 0)
5842 if (LocaleCompare("threshold",option+1) == 0)
5847 if (i == (ssize_t) argc)
5848 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 if (LocaleCompare("thumbnail",option+1) == 0)
5858 if (i == (ssize_t) argc)
5859 ThrowMogrifyException(OptionError,"MissingArgument",option);
5860 if (IsGeometry(argv[i]) == MagickFalse)
5861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5864 if (LocaleCompare("transparent",option+1) == 0)
5867 if (i == (ssize_t) argc)
5868 ThrowMogrifyException(OptionError,"MissingArgument",option);
5871 if (LocaleCompare("transparent-color",option+1) == 0)
5876 if (i == (ssize_t) (argc-1))
5877 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 if (LocaleCompare("treedepth",option+1) == 0)
5885 if (i == (ssize_t) argc)
5886 ThrowMogrifyException(OptionError,"MissingArgument",option);
5887 if (IsGeometry(argv[i]) == MagickFalse)
5888 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5891 if (LocaleCompare("trim",option+1) == 0)
5893 if (LocaleCompare("type",option+1) == 0)
5901 if (i == (ssize_t) argc)
5902 ThrowMogrifyException(OptionError,"MissingArgument",option);
5903 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5905 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5909 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5913 if (LocaleCompare("undercolor",option+1) == 0)
5918 if (i == (ssize_t) argc)
5919 ThrowMogrifyException(OptionError,"MissingArgument",option);
5922 if (LocaleCompare("unique-colors",option+1) == 0)
5924 if (LocaleCompare("units",option+1) == 0)
5932 if (i == (ssize_t) argc)
5933 ThrowMogrifyException(OptionError,"MissingArgument",option);
5934 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5937 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5941 if (LocaleCompare("unsharp",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5954 if (LocaleCompare("verbose",option+1) == 0)
5956 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5959 if ((LocaleCompare("version",option+1) == 0) ||
5960 (LocaleCompare("-version",option+1) == 0))
5962 (void) fprintf(stdout,"Version: %s\n",
5963 GetMagickVersion((size_t *) NULL));
5964 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
5965 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
5968 if (LocaleCompare("view",option+1) == 0)
5973 if (i == (ssize_t) argc)
5974 ThrowMogrifyException(OptionError,"MissingArgument",option);
5977 if (LocaleCompare("vignette",option+1) == 0)
5982 if (i == (ssize_t) argc)
5983 ThrowMogrifyException(OptionError,"MissingArgument",option);
5984 if (IsGeometry(argv[i]) == MagickFalse)
5985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5988 if (LocaleCompare("virtual-pixel",option+1) == 0)
5996 if (i == (ssize_t) argc)
5997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5998 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6001 ThrowMogrifyException(OptionError,
6002 "UnrecognizedVirtualPixelMethod",argv[i]);
6005 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6009 if (LocaleCompare("wave",option+1) == 0)
6012 if (i == (ssize_t) argc)
6013 ThrowMogrifyException(OptionError,"MissingArgument",option);
6014 if (IsGeometry(argv[i]) == MagickFalse)
6015 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6018 if (LocaleCompare("weight",option+1) == 0)
6023 if (i == (ssize_t) (argc-1))
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6027 if (LocaleCompare("white-point",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("white-threshold",option+1) == 0)
6043 if (i == (ssize_t) argc)
6044 ThrowMogrifyException(OptionError,"MissingArgument",option);
6045 if (IsGeometry(argv[i]) == MagickFalse)
6046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6049 if (LocaleCompare("write",option+1) == 0)
6052 if (i == (ssize_t) (argc-1))
6053 ThrowMogrifyException(OptionError,"MissingArgument",option);
6056 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6061 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6063 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6064 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6065 if (fire != MagickFalse)
6066 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6069 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6070 if (i != (ssize_t) argc)
6071 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6073 return(status != 0 ? MagickTrue : MagickFalse);
6077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6081 + M o g r i f y I m a g e I n f o %
6085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6087 % MogrifyImageInfo() applies image processing settings to the image as
6088 % prescribed by command line options.
6090 % The format of the MogrifyImageInfo method is:
6092 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6093 % const char **argv,ExceptionInfo *exception)
6095 % A description of each parameter follows:
6097 % o image_info: the image info..
6099 % o argc: Specifies a pointer to an integer describing the number of
6100 % elements in the argument vector.
6102 % o argv: Specifies a pointer to a text array containing the command line
6105 % o exception: return any errors or warnings in this structure.
6108 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6109 const int argc,const char **argv,ExceptionInfo *exception)
6124 Initialize method variables.
6126 assert(image_info != (ImageInfo *) NULL);
6127 assert(image_info->signature == MagickSignature);
6128 if (image_info->debug != MagickFalse)
6129 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6130 image_info->filename);
6134 Set the image settings.
6136 for (i=0; i < (ssize_t) argc; i++)
6139 if (IsCommandOption(option) == MagickFalse)
6141 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6142 count=MagickMax(count,0L);
6143 if ((i+count) >= (ssize_t) argc)
6145 switch (*(option+1))
6149 if (LocaleCompare("adjoin",option+1) == 0)
6151 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6154 if (LocaleCompare("antialias",option+1) == 0)
6156 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6159 if (LocaleCompare("attenuate",option+1) == 0)
6163 (void) DeleteImageOption(image_info,option+1);
6166 (void) SetImageOption(image_info,option+1,argv[i+1]);
6169 if (LocaleCompare("authenticate",option+1) == 0)
6172 (void) CloneString(&image_info->authenticate,(char *) NULL);
6174 (void) CloneString(&image_info->authenticate,argv[i+1]);
6181 if (LocaleCompare("background",option+1) == 0)
6185 (void) DeleteImageOption(image_info,option+1);
6186 (void) QueryColorDatabase(BackgroundColor,
6187 &image_info->background_color,exception);
6190 (void) SetImageOption(image_info,option+1,argv[i+1]);
6191 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6195 if (LocaleCompare("bias",option+1) == 0)
6199 (void) SetImageOption(image_info,option+1,"0.0");
6202 (void) SetImageOption(image_info,option+1,argv[i+1]);
6205 if (LocaleCompare("black-point-compensation",option+1) == 0)
6209 (void) SetImageOption(image_info,option+1,"false");
6212 (void) SetImageOption(image_info,option+1,"true");
6215 if (LocaleCompare("blue-primary",option+1) == 0)
6219 (void) SetImageOption(image_info,option+1,"0.0");
6222 (void) SetImageOption(image_info,option+1,argv[i+1]);
6225 if (LocaleCompare("bordercolor",option+1) == 0)
6229 (void) DeleteImageOption(image_info,option+1);
6230 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6234 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6236 (void) SetImageOption(image_info,option+1,argv[i+1]);
6239 if (LocaleCompare("box",option+1) == 0)
6243 (void) SetImageOption(image_info,"undercolor","none");
6246 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6253 if (LocaleCompare("cache",option+1) == 0)
6258 limit=MagickResourceInfinity;
6259 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6260 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6261 (void) SetMagickResourceLimit(MemoryResource,limit);
6262 (void) SetMagickResourceLimit(MapResource,2*limit);
6265 if (LocaleCompare("caption",option+1) == 0)
6269 (void) DeleteImageOption(image_info,option+1);
6272 (void) SetImageOption(image_info,option+1,argv[i+1]);
6275 if (LocaleCompare("channel",option+1) == 0)
6279 image_info->channel=DefaultChannels;
6282 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6285 if (LocaleCompare("colors",option+1) == 0)
6287 image_info->colors=StringToUnsignedLong(argv[i+1]);
6290 if (LocaleCompare("colorspace",option+1) == 0)
6294 image_info->colorspace=UndefinedColorspace;
6295 (void) SetImageOption(image_info,option+1,"undefined");
6298 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6299 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6300 (void) SetImageOption(image_info,option+1,argv[i+1]);
6303 if (LocaleCompare("compress",option+1) == 0)
6307 image_info->compression=UndefinedCompression;
6308 (void) SetImageOption(image_info,option+1,"undefined");
6311 image_info->compression=(CompressionType) ParseCommandOption(
6312 MagickCompressOptions,MagickFalse,argv[i+1]);
6313 (void) SetImageOption(image_info,option+1,argv[i+1]);
6316 if (LocaleCompare("comment",option+1) == 0)
6320 (void) DeleteImageOption(image_info,option+1);
6323 (void) SetImageOption(image_info,option+1,argv[i+1]);
6326 if (LocaleCompare("compose",option+1) == 0)
6330 (void) SetImageOption(image_info,option+1,"undefined");
6333 (void) SetImageOption(image_info,option+1,argv[i+1]);
6336 if (LocaleCompare("compress",option+1) == 0)
6340 image_info->compression=UndefinedCompression;
6341 (void) SetImageOption(image_info,option+1,"undefined");
6344 image_info->compression=(CompressionType) ParseCommandOption(
6345 MagickCompressOptions,MagickFalse,argv[i+1]);
6346 (void) SetImageOption(image_info,option+1,argv[i+1]);
6353 if (LocaleCompare("debug",option+1) == 0)
6356 (void) SetLogEventMask("none");
6358 (void) SetLogEventMask(argv[i+1]);
6359 image_info->debug=IsEventLogging();
6362 if (LocaleCompare("define",option+1) == 0)
6366 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6367 (void) DeleteImageRegistry(argv[i+1]+9);
6369 (void) DeleteImageOption(image_info,argv[i+1]);
6372 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6374 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6378 (void) DefineImageOption(image_info,argv[i+1]);
6381 if (LocaleCompare("delay",option+1) == 0)
6385 (void) SetImageOption(image_info,option+1,"0");
6388 (void) SetImageOption(image_info,option+1,argv[i+1]);
6391 if (LocaleCompare("density",option+1) == 0)
6398 if (image_info->density != (char *) NULL)
6399 image_info->density=DestroyString(image_info->density);
6400 (void) SetImageOption(image_info,option+1,"72");
6403 (void) CloneString(&image_info->density,argv[i+1]);
6404 (void) SetImageOption(image_info,option+1,argv[i+1]);
6407 if (LocaleCompare("depth",option+1) == 0)
6411 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6414 image_info->depth=StringToUnsignedLong(argv[i+1]);
6417 if (LocaleCompare("direction",option+1) == 0)
6421 (void) SetImageOption(image_info,option+1,"undefined");
6424 (void) SetImageOption(image_info,option+1,argv[i+1]);
6427 if (LocaleCompare("display",option+1) == 0)
6431 if (image_info->server_name != (char *) NULL)
6432 image_info->server_name=DestroyString(
6433 image_info->server_name);
6436 (void) CloneString(&image_info->server_name,argv[i+1]);
6439 if (LocaleCompare("dispose",option+1) == 0)
6443 (void) SetImageOption(image_info,option+1,"undefined");
6446 (void) SetImageOption(image_info,option+1,argv[i+1]);
6449 if (LocaleCompare("dither",option+1) == 0)
6453 image_info->dither=MagickFalse;
6454 (void) SetImageOption(image_info,option+1,"none");
6457 (void) SetImageOption(image_info,option+1,argv[i+1]);
6458 image_info->dither=MagickTrue;
6465 if (LocaleCompare("encoding",option+1) == 0)
6469 (void) SetImageOption(image_info,option+1,"undefined");
6472 (void) SetImageOption(image_info,option+1,argv[i+1]);
6475 if (LocaleCompare("endian",option+1) == 0)
6479 image_info->endian=UndefinedEndian;
6480 (void) SetImageOption(image_info,option+1,"undefined");
6483 image_info->endian=(EndianType) ParseCommandOption(
6484 MagickEndianOptions,MagickFalse,argv[i+1]);
6485 (void) SetImageOption(image_info,option+1,argv[i+1]);
6488 if (LocaleCompare("extract",option+1) == 0)
6491 Set image extract geometry.
6495 if (image_info->extract != (char *) NULL)
6496 image_info->extract=DestroyString(image_info->extract);
6499 (void) CloneString(&image_info->extract,argv[i+1]);
6506 if (LocaleCompare("fill",option+1) == 0)
6510 (void) SetImageOption(image_info,option+1,"none");
6513 (void) SetImageOption(image_info,option+1,argv[i+1]);
6516 if (LocaleCompare("filter",option+1) == 0)
6520 (void) SetImageOption(image_info,option+1,"undefined");
6523 (void) SetImageOption(image_info,option+1,argv[i+1]);
6526 if (LocaleCompare("font",option+1) == 0)
6530 if (image_info->font != (char *) NULL)
6531 image_info->font=DestroyString(image_info->font);
6534 (void) CloneString(&image_info->font,argv[i+1]);
6537 if (LocaleCompare("format",option+1) == 0)
6542 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6543 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6544 image_info->ping=MagickFalse;
6545 (void) SetImageOption(image_info,option+1,argv[i+1]);
6548 if (LocaleCompare("fuzz",option+1) == 0)
6552 image_info->fuzz=0.0;
6553 (void) SetImageOption(image_info,option+1,"0");
6556 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6558 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 if (LocaleCompare("gravity",option+1) == 0)
6569 (void) SetImageOption(image_info,option+1,"undefined");
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("green-primary",option+1) == 0)
6579 (void) SetImageOption(image_info,option+1,"0.0");
6582 (void) SetImageOption(image_info,option+1,argv[i+1]);
6589 if (LocaleCompare("intent",option+1) == 0)
6593 (void) SetImageOption(image_info,option+1,"undefined");
6596 (void) SetImageOption(image_info,option+1,argv[i+1]);
6599 if (LocaleCompare("interlace",option+1) == 0)
6603 image_info->interlace=UndefinedInterlace;
6604 (void) SetImageOption(image_info,option+1,"undefined");
6607 image_info->interlace=(InterlaceType) ParseCommandOption(
6608 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6609 (void) SetImageOption(image_info,option+1,argv[i+1]);
6612 if (LocaleCompare("interline-spacing",option+1) == 0)
6616 (void) SetImageOption(image_info,option+1,"undefined");
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6622 if (LocaleCompare("interpolate",option+1) == 0)
6626 (void) SetImageOption(image_info,option+1,"undefined");
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6632 if (LocaleCompare("interword-spacing",option+1) == 0)
6636 (void) SetImageOption(image_info,option+1,"undefined");
6639 (void) SetImageOption(image_info,option+1,argv[i+1]);
6646 if (LocaleCompare("kerning",option+1) == 0)
6650 (void) SetImageOption(image_info,option+1,"undefined");
6653 (void) SetImageOption(image_info,option+1,argv[i+1]);
6660 if (LocaleCompare("label",option+1) == 0)
6664 (void) DeleteImageOption(image_info,option+1);
6667 (void) SetImageOption(image_info,option+1,argv[i+1]);
6670 if (LocaleCompare("limit",option+1) == 0)
6680 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6681 MagickFalse,argv[i+1]);
6682 limit=MagickResourceInfinity;
6683 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6684 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6685 (void) SetMagickResourceLimit(type,limit);
6688 if (LocaleCompare("list",option+1) == 0)
6694 Display configuration list.
6696 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6699 case MagickCoderOptions:
6701 (void) ListCoderInfo((FILE *) NULL,exception);
6704 case MagickColorOptions:
6706 (void) ListColorInfo((FILE *) NULL,exception);
6709 case MagickConfigureOptions:
6711 (void) ListConfigureInfo((FILE *) NULL,exception);
6714 case MagickDelegateOptions:
6716 (void) ListDelegateInfo((FILE *) NULL,exception);
6719 case MagickFontOptions:
6721 (void) ListTypeInfo((FILE *) NULL,exception);
6724 case MagickFormatOptions:
6726 (void) ListMagickInfo((FILE *) NULL,exception);
6729 case MagickLocaleOptions:
6731 (void) ListLocaleInfo((FILE *) NULL,exception);
6734 case MagickLogOptions:
6736 (void) ListLogInfo((FILE *) NULL,exception);
6739 case MagickMagicOptions:
6741 (void) ListMagicInfo((FILE *) NULL,exception);
6744 case MagickMimeOptions:
6746 (void) ListMimeInfo((FILE *) NULL,exception);
6749 case MagickModuleOptions:
6751 (void) ListModuleInfo((FILE *) NULL,exception);
6754 case MagickPolicyOptions:
6756 (void) ListPolicyInfo((FILE *) NULL,exception);
6759 case MagickResourceOptions:
6761 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6764 case MagickThresholdOptions:
6766 (void) ListThresholdMaps((FILE *) NULL,exception);
6771 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6778 if (LocaleCompare("log",option+1) == 0)
6782 (void) SetLogFormat(argv[i+1]);
6785 if (LocaleCompare("loop",option+1) == 0)
6789 (void) SetImageOption(image_info,option+1,"0");
6792 (void) SetImageOption(image_info,option+1,argv[i+1]);
6799 if (LocaleCompare("matte",option+1) == 0)
6803 (void) SetImageOption(image_info,option+1,"false");
6806 (void) SetImageOption(image_info,option+1,"true");
6809 if (LocaleCompare("mattecolor",option+1) == 0)
6813 (void) SetImageOption(image_info,option+1,argv[i+1]);
6814 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
6818 (void) SetImageOption(image_info,option+1,argv[i+1]);
6819 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6823 if (LocaleCompare("monitor",option+1) == 0)
6825 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6829 if (LocaleCompare("monochrome",option+1) == 0)
6831 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6838 if (LocaleCompare("orient",option+1) == 0)
6842 image_info->orientation=UndefinedOrientation;
6843 (void) SetImageOption(image_info,option+1,"undefined");
6846 image_info->orientation=(OrientationType) ParseCommandOption(
6847 MagickOrientationOptions,MagickFalse,argv[i+1]);
6848 (void) SetImageOption(image_info,option+1,argv[i+1]);
6854 if (LocaleCompare("page",option+1) == 0)
6858 page[MaxTextExtent];
6871 (void) DeleteImageOption(image_info,option+1);
6872 (void) CloneString(&image_info->page,(char *) NULL);
6875 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6876 image_option=GetImageOption(image_info,"page");
6877 if (image_option != (const char *) NULL)
6878 flags=ParseAbsoluteGeometry(image_option,&geometry);
6879 canonical_page=GetPageGeometry(argv[i+1]);
6880 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6881 canonical_page=DestroyString(canonical_page);
6882 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
6883 (unsigned long) geometry.width,(unsigned long) geometry.height);
6884 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6885 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6886 (unsigned long) geometry.width,(unsigned long) geometry.height,
6887 (long) geometry.x,(long) geometry.y);
6888 (void) SetImageOption(image_info,option+1,page);
6889 (void) CloneString(&image_info->page,page);
6892 if (LocaleCompare("pen",option+1) == 0)
6896 (void) SetImageOption(image_info,option+1,"none");
6899 (void) SetImageOption(image_info,option+1,argv[i+1]);
6902 if (LocaleCompare("ping",option+1) == 0)
6904 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6907 if (LocaleCompare("pointsize",option+1) == 0)
6910 geometry_info.rho=0.0;
6912 (void) ParseGeometry(argv[i+1],&geometry_info);
6913 image_info->pointsize=geometry_info.rho;
6916 if (LocaleCompare("precision",option+1) == 0)
6918 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6921 if (LocaleCompare("preview",option+1) == 0)
6928 image_info->preview_type=UndefinedPreview;
6931 image_info->preview_type=(PreviewType) ParseCommandOption(
6932 MagickPreviewOptions,MagickFalse,argv[i+1]);
6939 if (LocaleCompare("quality",option+1) == 0)
6942 Set image compression quality.
6946 image_info->quality=UndefinedCompressionQuality;
6947 (void) SetImageOption(image_info,option+1,"0");
6950 image_info->quality=StringToUnsignedLong(argv[i+1]);
6951 (void) SetImageOption(image_info,option+1,argv[i+1]);
6954 if (LocaleCompare("quiet",option+1) == 0)
6956 static WarningHandler
6957 warning_handler = (WarningHandler) NULL;
6962 Restore error or warning messages.
6964 warning_handler=SetWarningHandler(warning_handler);
6968 Suppress error or warning messages.
6970 warning_handler=SetWarningHandler((WarningHandler) NULL);
6977 if (LocaleCompare("red-primary",option+1) == 0)
6981 (void) SetImageOption(image_info,option+1,"0.0");
6984 (void) SetImageOption(image_info,option+1,argv[i+1]);
6991 if (LocaleCompare("sampling-factor",option+1) == 0)
6994 Set image sampling factor.
6998 if (image_info->sampling_factor != (char *) NULL)
6999 image_info->sampling_factor=DestroyString(
7000 image_info->sampling_factor);
7003 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7006 if (LocaleCompare("scene",option+1) == 0)
7013 image_info->scene=0;
7014 (void) SetImageOption(image_info,option+1,"0");
7017 image_info->scene=StringToUnsignedLong(argv[i+1]);
7018 (void) SetImageOption(image_info,option+1,argv[i+1]);
7021 if (LocaleCompare("seed",option+1) == 0)
7028 seed=(size_t) time((time_t *) NULL);
7029 SeedPseudoRandomGenerator(seed);
7032 seed=StringToUnsignedLong(argv[i+1]);
7033 SeedPseudoRandomGenerator(seed);
7036 if (LocaleCompare("size",option+1) == 0)
7040 if (image_info->size != (char *) NULL)
7041 image_info->size=DestroyString(image_info->size);
7044 (void) CloneString(&image_info->size,argv[i+1]);
7047 if (LocaleCompare("stroke",option+1) == 0)
7051 (void) SetImageOption(image_info,option+1,"none");
7054 (void) SetImageOption(image_info,option+1,argv[i+1]);
7057 if (LocaleCompare("strokewidth",option+1) == 0)
7061 (void) SetImageOption(image_info,option+1,"0");
7064 (void) SetImageOption(image_info,option+1,argv[i+1]);
7067 if (LocaleCompare("synchronize",option+1) == 0)
7071 image_info->synchronize=MagickFalse;
7074 image_info->synchronize=MagickTrue;
7081 if (LocaleCompare("taint",option+1) == 0)
7085 (void) SetImageOption(image_info,option+1,"false");
7088 (void) SetImageOption(image_info,option+1,"true");
7091 if (LocaleCompare("texture",option+1) == 0)
7095 if (image_info->texture != (char *) NULL)
7096 image_info->texture=DestroyString(image_info->texture);
7099 (void) CloneString(&image_info->texture,argv[i+1]);
7102 if (LocaleCompare("tile-offset",option+1) == 0)
7106 (void) SetImageOption(image_info,option+1,"0");
7109 (void) SetImageOption(image_info,option+1,argv[i+1]);
7112 if (LocaleCompare("transparent-color",option+1) == 0)
7116 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7117 (void) SetImageOption(image_info,option+1,"none");
7120 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7122 (void) SetImageOption(image_info,option+1,argv[i+1]);
7125 if (LocaleCompare("type",option+1) == 0)
7129 image_info->type=UndefinedType;
7130 (void) SetImageOption(image_info,option+1,"undefined");
7133 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7134 MagickFalse,argv[i+1]);
7135 (void) SetImageOption(image_info,option+1,argv[i+1]);
7142 if (LocaleCompare("undercolor",option+1) == 0)
7146 (void) DeleteImageOption(image_info,option+1);
7149 (void) SetImageOption(image_info,option+1,argv[i+1]);
7152 if (LocaleCompare("units",option+1) == 0)
7156 image_info->units=UndefinedResolution;
7157 (void) SetImageOption(image_info,option+1,"undefined");
7160 image_info->units=(ResolutionType) ParseCommandOption(
7161 MagickResolutionOptions,MagickFalse,argv[i+1]);
7162 (void) SetImageOption(image_info,option+1,argv[i+1]);
7169 if (LocaleCompare("verbose",option+1) == 0)
7173 image_info->verbose=MagickFalse;
7176 image_info->verbose=MagickTrue;
7177 image_info->ping=MagickFalse;
7180 if (LocaleCompare("view",option+1) == 0)
7184 if (image_info->view != (char *) NULL)
7185 image_info->view=DestroyString(image_info->view);
7188 (void) CloneString(&image_info->view,argv[i+1]);
7191 if (LocaleCompare("virtual-pixel",option+1) == 0)
7195 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7196 (void) SetImageOption(image_info,option+1,"undefined");
7199 image_info->virtual_pixel_method=(VirtualPixelMethod)
7200 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7202 (void) SetImageOption(image_info,option+1,argv[i+1]);
7209 if (LocaleCompare("white-point",option+1) == 0)
7213 (void) SetImageOption(image_info,option+1,"0.0");
7216 (void) SetImageOption(image_info,option+1,argv[i+1]);
7230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7234 + M o g r i f y I m a g e L i s t %
7238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7240 % MogrifyImageList() applies any command line options that might affect the
7241 % entire image list (e.g. -append, -coalesce, etc.).
7243 % The format of the MogrifyImage method is:
7245 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7246 % const char **argv,Image **images,ExceptionInfo *exception)
7248 % A description of each parameter follows:
7250 % o image_info: the image info..
7252 % o argc: Specifies a pointer to an integer describing the number of
7253 % elements in the argument vector.
7255 % o argv: Specifies a pointer to a text array containing the command line
7258 % o images: pointer to pointer of the first image in image list.
7260 % o exception: return any errors or warnings in this structure.
7263 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7264 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7289 Apply options to the image list.
7291 assert(image_info != (ImageInfo *) NULL);
7292 assert(image_info->signature == MagickSignature);
7293 assert(images != (Image **) NULL);
7294 assert((*images)->previous == (Image *) NULL);
7295 assert((*images)->signature == MagickSignature);
7296 if ((*images)->debug != MagickFalse)
7297 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7298 (*images)->filename);
7299 if ((argc <= 0) || (*argv == (char *) NULL))
7301 mogrify_info=CloneImageInfo(image_info);
7302 quantize_info=AcquireQuantizeInfo(mogrify_info);
7303 channel=mogrify_info->channel;
7305 for (i=0; i < (ssize_t) argc; i++)
7307 if (*images == (Image *) NULL)
7310 if (IsCommandOption(option) == MagickFalse)
7312 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7313 count=MagickMax(count,0L);
7314 if ((i+count) >= (ssize_t) argc)
7316 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7317 switch (*(option+1))
7321 if (LocaleCompare("affinity",option+1) == 0)
7323 (void) SyncImagesSettings(mogrify_info,*images);
7326 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7327 InheritException(exception,&(*images)->exception);
7333 if (LocaleCompare("append",option+1) == 0)
7338 (void) SyncImagesSettings(mogrify_info,*images);
7339 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7340 MagickFalse,exception);
7341 if (append_image == (Image *) NULL)
7346 *images=DestroyImageList(*images);
7347 *images=append_image;
7350 if (LocaleCompare("average",option+1) == 0)
7356 Average an image sequence (deprecated).
7358 (void) SyncImagesSettings(mogrify_info,*images);
7359 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7361 if (average_image == (Image *) NULL)
7366 *images=DestroyImageList(*images);
7367 *images=average_image;
7374 if (LocaleCompare("channel",option+1) == 0)
7378 channel=DefaultChannels;
7381 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7384 if (LocaleCompare("clut",option+1) == 0)
7390 (void) SyncImagesSettings(mogrify_info,*images);
7391 image=RemoveFirstImageFromList(images);
7392 clut_image=RemoveFirstImageFromList(images);
7393 if (clut_image == (Image *) NULL)
7398 (void) ClutImageChannel(image,channel,clut_image);
7399 clut_image=DestroyImage(clut_image);
7400 InheritException(exception,&image->exception);
7401 *images=DestroyImageList(*images);
7405 if (LocaleCompare("coalesce",option+1) == 0)
7410 (void) SyncImagesSettings(mogrify_info,*images);
7411 coalesce_image=CoalesceImages(*images,exception);
7412 if (coalesce_image == (Image *) NULL)
7417 *images=DestroyImageList(*images);
7418 *images=coalesce_image;
7421 if (LocaleCompare("combine",option+1) == 0)
7426 (void) SyncImagesSettings(mogrify_info,*images);
7427 combine_image=CombineImages(*images,channel,exception);
7428 if (combine_image == (Image *) NULL)
7433 *images=DestroyImageList(*images);
7434 *images=combine_image;
7437 if (LocaleCompare("composite",option+1) == 0)
7447 (void) SyncImagesSettings(mogrify_info,*images);
7448 image=RemoveFirstImageFromList(images);
7449 composite_image=RemoveFirstImageFromList(images);
7450 if (composite_image == (Image *) NULL)
7455 (void) TransformImage(&composite_image,(char *) NULL,
7456 composite_image->geometry);
7457 SetGeometry(composite_image,&geometry);
7458 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7459 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7461 mask_image=RemoveFirstImageFromList(images);
7462 if (mask_image != (Image *) NULL)
7464 if ((image->compose == DisplaceCompositeOp) ||
7465 (image->compose == DistortCompositeOp))
7468 Merge Y displacement into X displacement image.
7470 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7472 mask_image=DestroyImage(mask_image);
7477 Set a blending mask for the composition.
7479 /* POSIBLE ERROR; what if image->mask already set */
7480 image->mask=mask_image;
7481 (void) NegateImage(image->mask,MagickFalse);
7484 (void) CompositeImageChannel(image,channel,image->compose,
7485 composite_image,geometry.x,geometry.y);
7486 if (mask_image != (Image *) NULL)
7487 mask_image=image->mask=DestroyImage(image->mask);
7488 composite_image=DestroyImage(composite_image);
7489 InheritException(exception,&image->exception);
7490 *images=DestroyImageList(*images);
7495 This has been merged completely into MogrifyImage()
7496 if (LocaleCompare("crop",option+1) == 0)
7507 (void) SyncImagesSettings(mogrify_info,*images);
7508 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7509 if (((geometry.width == 0) && (geometry.height == 0)) ||
7510 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7512 (void) TransformImages(images,argv[i+1],(char *) NULL);
7513 InheritException(exception,&(*images)->exception);
7521 if (LocaleCompare("deconstruct",option+1) == 0)
7526 (void) SyncImagesSettings(mogrify_info,*images);
7527 deconstruct_image=DeconstructImages(*images,exception);
7528 if (deconstruct_image == (Image *) NULL)
7533 *images=DestroyImageList(*images);
7534 *images=deconstruct_image;
7537 if (LocaleCompare("delete",option+1) == 0)
7540 DeleteImages(images,"-1",exception);
7542 DeleteImages(images,argv[i+1],exception);
7545 if (LocaleCompare("dither",option+1) == 0)
7549 quantize_info->dither=MagickFalse;
7552 quantize_info->dither=MagickTrue;
7553 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7554 MagickDitherOptions,MagickFalse,argv[i+1]);
7557 if (LocaleCompare("duplicate",option+1) == 0)
7563 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7572 number_duplicates=(size_t) StringToLong(argv[i+1]);
7573 p=strchr(argv[i+1],',');
7574 if (p == (const char *) NULL)
7575 duplicate_images=DuplicateImages(*images,number_duplicates,
7578 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7581 AppendImageToList(images, duplicate_images);
7582 (void) SyncImagesSettings(mogrify_info,*images);
7589 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7594 MagickEvaluateOperator
7597 (void) SyncImageSettings(mogrify_info,*images);
7598 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
7599 MagickFalse,argv[i+1]);
7600 evaluate_image=EvaluateImages(*images,op,exception);
7601 if (evaluate_image == (Image *) NULL)
7606 *images=DestroyImageList(*images);
7607 *images=evaluate_image;
7614 if (LocaleCompare("fft",option+1) == 0)
7620 Implements the discrete Fourier transform (DFT).
7622 (void) SyncImageSettings(mogrify_info,*images);
7623 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7624 MagickTrue : MagickFalse,exception);
7625 if (fourier_image == (Image *) NULL)
7627 *images=DestroyImage(*images);
7628 *images=fourier_image;
7631 if (LocaleCompare("flatten",option+1) == 0)
7636 (void) SyncImagesSettings(mogrify_info,*images);
7637 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7638 if (flatten_image == (Image *) NULL)
7640 *images=DestroyImageList(*images);
7641 *images=flatten_image;
7644 if (LocaleCompare("fx",option+1) == 0)
7649 (void) SyncImagesSettings(mogrify_info,*images);
7650 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7651 if (fx_image == (Image *) NULL)
7656 *images=DestroyImageList(*images);
7664 if (LocaleCompare("hald-clut",option+1) == 0)
7670 (void) SyncImagesSettings(mogrify_info,*images);
7671 image=RemoveFirstImageFromList(images);
7672 hald_image=RemoveFirstImageFromList(images);
7673 if (hald_image == (Image *) NULL)
7678 (void) HaldClutImageChannel(image,channel,hald_image);
7679 hald_image=DestroyImage(hald_image);
7680 InheritException(exception,&image->exception);
7681 if (*images != (Image *) NULL)
7682 *images=DestroyImageList(*images);
7690 if (LocaleCompare("ift",option+1) == 0)
7698 Implements the inverse fourier discrete Fourier transform (DFT).
7700 (void) SyncImagesSettings(mogrify_info,*images);
7701 magnitude_image=RemoveFirstImageFromList(images);
7702 phase_image=RemoveFirstImageFromList(images);
7703 if (phase_image == (Image *) NULL)
7708 fourier_image=InverseFourierTransformImage(magnitude_image,
7709 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7710 if (fourier_image == (Image *) NULL)
7712 if (*images != (Image *) NULL)
7713 *images=DestroyImage(*images);
7714 *images=fourier_image;
7717 if (LocaleCompare("insert",option+1) == 0)
7725 index=(ssize_t) StringToLong(argv[i+1]);
7726 p=RemoveLastImageFromList(images);
7727 if (p == (Image *) NULL)
7729 (void) ThrowMagickException(exception,GetMagickModule(),
7730 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7736 PrependImageToList(images,q);
7738 if (index == (ssize_t) GetImageListLength(*images))
7739 AppendImageToList(images,q);
7742 q=GetImageFromList(*images,index-1);
7743 if (q == (Image *) NULL)
7745 (void) ThrowMagickException(exception,GetMagickModule(),
7746 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7750 InsertImageInList(&q,p);
7752 *images=GetFirstImageInList(q);
7759 if (LocaleCompare("layers",option+1) == 0)
7767 (void) SyncImagesSettings(mogrify_info,*images);
7768 layers=(Image *) NULL;
7769 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7770 MagickFalse,argv[i+1]);
7775 layers=CoalesceImages(*images,exception);
7778 case CompareAnyLayer:
7779 case CompareClearLayer:
7780 case CompareOverlayLayer:
7783 layers=CompareImageLayers(*images,method,exception);
7789 case TrimBoundsLayer:
7791 layers=MergeImageLayers(*images,method,exception);
7796 layers=DisposeImages(*images,exception);
7799 case OptimizeImageLayer:
7801 layers=OptimizeImageLayers(*images,exception);
7804 case OptimizePlusLayer:
7806 layers=OptimizePlusImageLayers(*images,exception);
7809 case OptimizeTransLayer:
7811 OptimizeImageTransparency(*images,exception);
7814 case RemoveDupsLayer:
7816 RemoveDuplicateLayers(images,exception);
7819 case RemoveZeroLayer:
7821 RemoveZeroDelayLayers(images,exception);
7827 General Purpose, GIF Animation Optimizer.
7829 layers=CoalesceImages(*images,exception);
7830 if (layers == (Image *) NULL)
7835 InheritException(exception,&layers->exception);
7836 *images=DestroyImageList(*images);
7838 layers=OptimizeImageLayers(*images,exception);
7839 if (layers == (Image *) NULL)
7844 InheritException(exception,&layers->exception);
7845 *images=DestroyImageList(*images);
7847 layers=(Image *) NULL;
7848 OptimizeImageTransparency(*images,exception);
7849 InheritException(exception,&(*images)->exception);
7850 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7853 case CompositeLayer:
7865 Split image sequence at the first 'NULL:' image.
7868 while (source != (Image *) NULL)
7870 source=GetNextImageInList(source);
7871 if ((source != (Image *) NULL) &&
7872 (LocaleCompare(source->magick,"NULL") == 0))
7875 if (source != (Image *) NULL)
7877 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7878 (GetNextImageInList(source) == (Image *) NULL))
7879 source=(Image *) NULL;
7883 Separate the two lists, junk the null: image.
7885 source=SplitImageList(source->previous);
7886 DeleteImageFromList(&source);
7889 if (source == (Image *) NULL)
7891 (void) ThrowMagickException(exception,GetMagickModule(),
7892 OptionError,"MissingNullSeparator","layers Composite");
7897 Adjust offset with gravity and virtual canvas.
7899 SetGeometry(*images,&geometry);
7900 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7901 geometry.width=source->page.width != 0 ?
7902 source->page.width : source->columns;
7903 geometry.height=source->page.height != 0 ?
7904 source->page.height : source->rows;
7905 GravityAdjustGeometry((*images)->page.width != 0 ?
7906 (*images)->page.width : (*images)->columns,
7907 (*images)->page.height != 0 ? (*images)->page.height :
7908 (*images)->rows,(*images)->gravity,&geometry);
7909 compose=OverCompositeOp;
7910 option=GetImageOption(mogrify_info,"compose");
7911 if (option != (const char *) NULL)
7912 compose=(CompositeOperator) ParseCommandOption(
7913 MagickComposeOptions,MagickFalse,option);
7914 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7916 source=DestroyImageList(source);
7920 if (layers == (Image *) NULL)
7922 InheritException(exception,&layers->exception);
7923 *images=DestroyImageList(*images);
7931 if (LocaleCompare("map",option+1) == 0)
7933 (void) SyncImagesSettings(mogrify_info,*images);
7936 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7937 InheritException(exception,&(*images)->exception);
7943 if (LocaleCompare("maximum",option+1) == 0)
7949 Maximum image sequence (deprecated).
7951 (void) SyncImagesSettings(mogrify_info,*images);
7952 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7953 if (maximum_image == (Image *) NULL)
7958 *images=DestroyImageList(*images);
7959 *images=maximum_image;
7962 if (LocaleCompare("minimum",option+1) == 0)
7968 Minimum image sequence (deprecated).
7970 (void) SyncImagesSettings(mogrify_info,*images);
7971 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7972 if (minimum_image == (Image *) NULL)
7977 *images=DestroyImageList(*images);
7978 *images=minimum_image;
7981 if (LocaleCompare("morph",option+1) == 0)
7986 (void) SyncImagesSettings(mogrify_info,*images);
7987 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7989 if (morph_image == (Image *) NULL)
7994 *images=DestroyImageList(*images);
7995 *images=morph_image;
7998 if (LocaleCompare("mosaic",option+1) == 0)
8003 (void) SyncImagesSettings(mogrify_info,*images);
8004 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8005 if (mosaic_image == (Image *) NULL)
8010 *images=DestroyImageList(*images);
8011 *images=mosaic_image;
8018 if (LocaleCompare("print",option+1) == 0)
8023 (void) SyncImagesSettings(mogrify_info,*images);
8024 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8025 if (string == (char *) NULL)
8027 InheritException(exception,&(*images)->exception);
8028 (void) fprintf(stdout,"%s",string);
8029 string=DestroyString(string);
8031 if (LocaleCompare("process",option+1) == 0)
8040 (void) SyncImagesSettings(mogrify_info,*images);
8041 arguments=StringToArgv(argv[i+1],&number_arguments);
8042 if (arguments == (char **) NULL)
8044 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8065 Support old style syntax, filter="-option arg".
8067 length=strlen(argv[i+1]);
8068 token=(char *) NULL;
8069 if (~length >= MaxTextExtent)
8070 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8072 if (token == (char *) NULL)
8075 arguments=argv[i+1];
8076 token_info=AcquireTokenInfo();
8077 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8078 "\"",'\0',&breaker,&next,"e);
8079 token_info=DestroyTokenInfo(token_info);
8085 argv=(&(arguments[next]));
8086 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8089 token=DestroyString(token);
8092 (void) SubstituteString(&arguments[1],"-","");
8093 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8094 number_arguments-2,(const char **) arguments+2,exception);
8095 for (j=0; j < number_arguments; j++)
8096 arguments[j]=DestroyString(arguments[j]);
8097 arguments=(char **) RelinquishMagickMemory(arguments);
8104 if (LocaleCompare("reverse",option+1) == 0)
8106 ReverseImageList(images);
8107 InheritException(exception,&(*images)->exception);
8114 if (LocaleCompare("smush",option+1) == 0)
8122 (void) SyncImagesSettings(mogrify_info,*images);
8123 offset=(ssize_t) StringToLong(argv[i+1]);
8124 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8125 MagickFalse,offset,exception);
8126 if (smush_image == (Image *) NULL)
8131 *images=DestroyImageList(*images);
8132 *images=smush_image;
8135 if (LocaleCompare("swap",option+1) == 0)
8156 flags=ParseGeometry(argv[i+1],&geometry_info);
8157 index=(ssize_t) geometry_info.rho;
8158 if ((flags & SigmaValue) != 0)
8159 swap_index=(ssize_t) geometry_info.sigma;
8161 p=GetImageFromList(*images,index);
8162 q=GetImageFromList(*images,swap_index);
8163 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8165 (void) ThrowMagickException(exception,GetMagickModule(),
8166 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8172 swap=CloneImage(p,0,0,MagickTrue,exception);
8173 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8174 ReplaceImageInList(&q,swap);
8175 *images=GetFirstImageInList(q);
8182 if (LocaleCompare("write",option+1) == 0)
8193 (void) SyncImagesSettings(mogrify_info,*images);
8194 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8195 (void) DeleteImageRegistry(key);
8196 write_images=(*images);
8198 write_images=CloneImageList(*images,exception);
8199 write_info=CloneImageInfo(mogrify_info);
8200 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8201 write_info=DestroyImageInfo(write_info);
8203 write_images=DestroyImageList(write_images);
8213 quantize_info=DestroyQuantizeInfo(quantize_info);
8214 mogrify_info=DestroyImageInfo(mogrify_info);
8215 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8216 return(status != 0 ? MagickTrue : MagickFalse);
8220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8224 + M o g r i f y I m a g e s %
8228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8230 % MogrifyImages() applies image processing options to a sequence of images as
8231 % prescribed by command line options.
8233 % The format of the MogrifyImage method is:
8235 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8236 % const MagickBooleanType post,const int argc,const char **argv,
8237 % Image **images,Exceptioninfo *exception)
8239 % A description of each parameter follows:
8241 % o image_info: the image info..
8243 % o post: If true, post process image list operators otherwise pre-process.
8245 % o argc: Specifies a pointer to an integer describing the number of
8246 % elements in the argument vector.
8248 % o argv: Specifies a pointer to a text array containing the command line
8251 % o images: pointer to a pointer of the first image in image list.
8253 % o exception: return any errors or warnings in this structure.
8256 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8257 const MagickBooleanType post,const int argc,const char **argv,
8258 Image **images,ExceptionInfo *exception)
8260 #define MogrifyImageTag "Mogrify/Image"
8274 assert(image_info != (ImageInfo *) NULL);
8275 assert(image_info->signature == MagickSignature);
8276 if (images == (Image **) NULL)
8277 return(MogrifyImage(image_info,argc,argv,images,exception));
8278 assert((*images)->previous == (Image *) NULL);
8279 assert((*images)->signature == MagickSignature);
8280 if ((*images)->debug != MagickFalse)
8281 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8282 (*images)->filename);
8283 if ((argc <= 0) || (*argv == (char *) NULL))
8285 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8290 fprintf(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,post?"post":"pre");
8294 Pre-process multi-image sequence operators
8296 if (post == MagickFalse)
8297 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8300 For each image, process simple single image operators
8303 n=GetImageListLength(*images);
8307 fprintf(stderr, "mogrify %ld of %ld\n",
8308 (long)GetImageIndexInList(*images),(long)GetImageListLength(*images));
8310 status&=MogrifyImage(image_info,argc,argv,images,exception);
8311 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8312 if (proceed == MagickFalse)
8314 if ( (*images)->next == (Image *) NULL )
8316 *images=(*images)->next;
8319 assert( *images != (Image *) NULL );
8321 fprintf(stderr, "mogrify end %ld of %ld\n",
8322 (long)GetImageIndexInList(*images),(long)GetImageListLength(*images));
8326 Post-process, multi-image sequence operators
8328 *images=GetFirstImageInList(*images);
8329 if (post != MagickFalse)
8330 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8331 return(status != 0 ? MagickTrue : MagickFalse);