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 "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/string-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/utility-private.h"
62 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
69 #define UndefinedCompressionQuality 0UL
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % M a g i c k C o m m a n d G e n e s i s %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % MagickCommandGenesis() applies image processing options to an image as
83 % prescribed by command line options.
85 % The format of the MagickCommandGenesis method is:
87 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
88 % MagickCommand command,int argc,char **argv,char **metadata,
89 % ExceptionInfo *exception)
91 % A description of each parameter follows:
93 % o image_info: the image info.
95 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
96 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
97 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98 % DisplayImageCommand, or AnimateImageCommand.
100 % o argc: Specifies a pointer to an integer describing the number of
101 % elements in the argument vector.
103 % o argv: Specifies a pointer to a text array containing the command line
106 % o metadata: any metadata is returned here.
108 % o exception: return any errors or warnings in this structure.
111 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
139 concurrent=MagickFalse;
143 regard_warnings=MagickFalse;
144 for (i=1; i < (ssize_t) (argc-1); i++)
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
149 if (LocaleCompare("bench",option+1) == 0)
150 iterations=StringToUnsignedLong(argv[++i]);
151 if (LocaleCompare("concurrent",option+1) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("debug",option+1) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("duration",option+1) == 0)
156 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
157 if (LocaleCompare("regard-warnings",option+1) == 0)
158 regard_warnings=MagickTrue;
160 timer=AcquireTimerInfo();
161 if (concurrent == MagickFalse)
163 for (i=0; i < (ssize_t) iterations; i++)
165 if (status != MagickFalse)
169 if (GetElapsedTime(timer) > duration)
171 (void) ContinueTimer(timer);
173 status=command(image_info,argc,argv,metadata,exception);
174 if (exception->severity != UndefinedException)
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
179 CatchException(exception);
181 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
183 (void) fputs(*metadata,stdout);
184 (void) fputc('\n',stdout);
185 *metadata=DestroyString(*metadata);
192 #if defined(MAGICKCORE_OPENMP_SUPPORT)
193 # pragma omp parallel for shared(status)
195 for (i=0; i < (ssize_t) iterations; i++)
197 if (status != MagickFalse)
201 if (GetElapsedTime(timer) > duration)
203 (void) ContinueTimer(timer);
205 status=command(image_info,argc,argv,metadata,exception);
206 #if defined(MAGICKCORE_OPENMP_SUPPORT)
207 # pragma omp critical (MagickCore_CommandGenesis)
210 if (exception->severity != UndefinedException)
212 if ((exception->severity > ErrorException) ||
213 (regard_warnings != MagickFalse))
215 CatchException(exception);
217 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
219 (void) fputs(*metadata,stdout);
220 (void) fputc('\n',stdout);
221 *metadata=DestroyString(*metadata);
228 elapsed_time=GetElapsedTime(timer);
229 user_time=GetUserTime(timer);
230 (void) FormatLocaleFile(stderr,
231 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
232 iterations,1.0*iterations/elapsed_time,user_time,(double)
233 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
234 (1000.0*(elapsed_time-floor(elapsed_time))));
235 (void) fflush(stderr);
237 timer=DestroyTimerInfo(timer);
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 + M o g r i f y I m a g e %
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 % MogrifyImage() applies simple single image processing options to a single
253 % image that may be part of a large list, but also handles any 'region'
256 % The image in the list may be modified in three different ways...
258 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
259 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
260 % * replace by a list of images (only the -separate option!)
262 % In each case the result is returned into the list, and a pointer to the
263 % modified image (last image added if replaced by a list of images) is
266 % ASIDE: The -crop is present but restricted to non-tile single image crops
268 % This means if all the images are being processed (such as by
269 % MogrifyImages(), next image to be processed will be as per the pointer
270 % (*image)->next. Also the image list may grow as a result of some specific
271 % operations but as images are never merged or deleted, it will never shrink
272 % in length. Typically the list will remain the same length.
274 % WARNING: As the image pointed to may be replaced, the first image in the
275 % list may also change. GetFirstImageInList() should be used by caller if
276 % they wish return the Image pointer to the first image in list.
279 % The format of the MogrifyImage method is:
281 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
282 % const char **argv,Image **image)
284 % A description of each parameter follows:
286 % o image_info: the image info..
288 % o argc: Specifies a pointer to an integer describing the number of
289 % elements in the argument vector.
291 % o argv: Specifies a pointer to a text array containing the command line
294 % o image: the image.
296 % o exception: return any errors or warnings in this structure.
301 GetImageCache() will read an image into a image cache if not already
302 present then return the image that is in the cache under that filename.
304 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
305 ExceptionInfo *exception)
319 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
320 sans_exception=AcquireExceptionInfo();
321 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
322 sans_exception=DestroyExceptionInfo(sans_exception);
323 if (image != (Image *) NULL)
325 read_info=CloneImageInfo(image_info);
326 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
327 image=ReadImage(read_info,exception);
328 read_info=DestroyImageInfo(read_info);
329 if (image != (Image *) NULL)
330 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
334 static MagickBooleanType IsPathWritable(const char *path)
336 if (IsPathAccessible(path) == MagickFalse)
338 if (access_utf8(path,W_OK) != 0)
343 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
350 static MagickBooleanType MonitorProgress(const char *text,
351 const MagickOffsetType offset,const MagickSizeType extent,
352 void *wand_unused(client_data))
355 message[MaxTextExtent],
366 (void) CopyMagickMemory(tag,text,MaxTextExtent);
368 if (p != (char *) NULL)
370 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
371 locale_message=GetLocaleMessage(message);
372 if (locale_message == message)
374 if (p == (char *) NULL)
375 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
376 locale_message,(long) offset,(unsigned long) extent,(long)
377 (100L*offset/(extent-1)));
379 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
380 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
381 (100L*offset/(extent-1)));
382 if (offset == (MagickOffsetType) (extent-1))
383 (void) FormatLocaleFile(stderr,"\n");
384 (void) fflush(stderr);
389 SparseColorOption() parses the complex -sparse-color argument into an
390 an array of floating point values then calls SparseColorImage().
391 Argument is a complex mix of floating-point pixel coodinates, and color
392 specifications (or direct floating point numbers). The number of floats
393 needed to represent a color varies depending on the current channel
396 static Image *SparseColorOption(const Image *image,
397 const SparseColorMethod method,const char *arguments,
398 const MagickBooleanType color_from_image,ExceptionInfo *exception)
401 token[MaxTextExtent];
425 assert(image != (Image *) NULL);
426 assert(image->signature == MagickSignature);
427 if (image->debug != MagickFalse)
428 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
429 assert(exception != (ExceptionInfo *) NULL);
430 assert(exception->signature == MagickSignature);
432 Limit channels according to image - and add up number of color channel.
435 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
437 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
439 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
441 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
442 (image->colorspace == CMYKColorspace))
444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
445 (image->matte != MagickFalse))
449 Read string, to determine number of arguments needed,
455 GetMagickToken(p,&p,token);
456 if ( token[0] == ',' ) continue;
457 if ( isalpha((int) token[0]) || token[0] == '#' ) {
458 if ( color_from_image ) {
459 (void) ThrowMagickException(exception,GetMagickModule(),
460 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
461 "Color arg given, when colors are coming from image");
462 return( (Image *)NULL);
464 x += number_colors; /* color argument */
467 x++; /* floating point argument */
471 if ( color_from_image ) {
472 /* just the control points are being given */
473 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
474 number_arguments=(x/2)*(2+number_colors);
477 /* control points and color values */
478 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Invalid number of Arguments");
485 return( (Image *)NULL);
488 /* Allocate and fill in the floating point arguments */
489 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
490 sizeof(*sparse_arguments));
491 if (sparse_arguments == (double *) NULL) {
492 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
493 "MemoryAllocationFailed","%s","SparseColorOption");
494 return( (Image *)NULL);
496 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
497 sizeof(*sparse_arguments));
500 while( *p != '\0' && x < number_arguments ) {
502 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
503 if ( token[0] == '\0' ) break;
504 if ( isalpha((int) token[0]) || token[0] == '#' ) {
505 (void) ThrowMagickException(exception,GetMagickModule(),
506 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
507 "Color found, instead of X-coord");
511 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
513 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
514 if ( token[0] == '\0' ) break;
515 if ( isalpha((int) token[0]) || token[0] == '#' ) {
516 (void) ThrowMagickException(exception,GetMagickModule(),
517 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
518 "Color found, instead of Y-coord");
522 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
523 /* color values for this control point */
525 if ( (color_from_image ) {
526 /* get color from image */
532 /* color name or function given in string argument */
533 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
534 if ( token[0] == '\0' ) break;
535 if ( isalpha((int) token[0]) || token[0] == '#' ) {
536 /* Color string given */
537 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
539 sparse_arguments[x++] = QuantumScale*color.red;
540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
541 sparse_arguments[x++] = QuantumScale*color.green;
542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
543 sparse_arguments[x++] = QuantumScale*color.blue;
544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
545 (image->colorspace == CMYKColorspace))
546 sparse_arguments[x++] = QuantumScale*color.black;
547 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
548 (image->matte != MagickFalse))
549 sparse_arguments[x++] = QuantumScale*color.alpha;
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
554 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
556 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
557 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
559 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
560 token[0] = ','; /* used this token - get another */
562 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
568 token[0] = ','; /* used this token - get another */
570 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
572 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
573 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
575 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
576 token[0] = ','; /* used this token - get another */
578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
579 (image->colorspace == CMYKColorspace))
581 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
582 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
584 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
585 token[0] = ','; /* used this token - get another */
587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
588 (image->matte != MagickFalse))
590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
593 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
594 token[0] = ','; /* used this token - get another */
599 if ( number_arguments != x && !error ) {
600 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
601 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( (Image *)NULL);
606 return( (Image *)NULL);
608 /* Call the Interpolation function with the parsed arguments */
609 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
611 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
612 return( sparse_image );
615 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
616 const char **argv,Image **image,ExceptionInfo *exception)
652 PixelInterpolateMethod
666 Initialize method variables.
668 assert(image_info != (const ImageInfo *) NULL);
669 assert(image_info->signature == MagickSignature);
670 assert(image != (Image **) NULL);
671 assert((*image)->signature == MagickSignature);
672 if ((*image)->debug != MagickFalse)
673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
676 mogrify_info=CloneImageInfo(image_info);
677 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
678 quantize_info=AcquireQuantizeInfo(mogrify_info);
679 SetGeometryInfo(&geometry_info);
680 GetPixelInfo(*image,&fill);
681 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
683 compose=(*image)->compose;
684 interpolate_method=UndefinedInterpolatePixel;
685 channel=mogrify_info->channel;
686 format=GetImageOption(mogrify_info,"format");
687 SetGeometry(*image,®ion_geometry);
688 region_image=NewImageList();
690 Transmogrify the image.
692 for (i=0; i < (ssize_t) argc; i++)
701 if (IsCommandOption(option) == MagickFalse)
703 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
705 if ((i+count) >= (ssize_t) argc)
707 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
708 mogrify_image=(Image *)NULL;
713 if (LocaleCompare("adaptive-blur",option+1) == 0)
718 (void) SyncImageSettings(mogrify_info,*image);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
722 if ((flags & XiValue) == 0)
723 geometry_info.xi=0.0;
724 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
725 geometry_info.sigma,geometry_info.xi,exception);
728 if (LocaleCompare("adaptive-resize",option+1) == 0)
731 Adaptive resize image.
733 (void) SyncImageSettings(mogrify_info,*image);
734 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
735 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
736 geometry.height,interpolate_method,exception);
739 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
742 Adaptive sharpen image.
744 (void) SyncImageSettings(mogrify_info,*image);
745 flags=ParseGeometry(argv[i+1],&geometry_info);
746 if ((flags & SigmaValue) == 0)
747 geometry_info.sigma=1.0;
748 if ((flags & XiValue) == 0)
749 geometry_info.xi=0.0;
750 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
751 geometry_info.sigma,geometry_info.xi,exception);
754 if (LocaleCompare("affine",option+1) == 0)
761 GetAffineMatrix(&draw_info->affine);
764 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
767 if (LocaleCompare("alpha",option+1) == 0)
772 (void) SyncImageSettings(mogrify_info,*image);
773 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
774 MagickFalse,argv[i+1]);
775 (void) SetImageAlphaChannel(*image,alpha_type,exception);
778 if (LocaleCompare("annotate",option+1) == 0)
782 geometry[MaxTextExtent];
787 (void) SyncImageSettings(mogrify_info,*image);
788 SetGeometryInfo(&geometry_info);
789 flags=ParseGeometry(argv[i+1],&geometry_info);
790 if ((flags & SigmaValue) == 0)
791 geometry_info.sigma=geometry_info.rho;
792 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
794 if (text == (char *) NULL)
796 (void) CloneString(&draw_info->text,text);
797 text=DestroyString(text);
798 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
799 geometry_info.xi,geometry_info.psi);
800 (void) CloneString(&draw_info->geometry,geometry);
801 draw_info->affine.sx=cos(DegreesToRadians(
802 fmod(geometry_info.rho,360.0)));
803 draw_info->affine.rx=sin(DegreesToRadians(
804 fmod(geometry_info.rho,360.0)));
805 draw_info->affine.ry=(-sin(DegreesToRadians(
806 fmod(geometry_info.sigma,360.0))));
807 draw_info->affine.sy=cos(DegreesToRadians(
808 fmod(geometry_info.sigma,360.0)));
809 (void) AnnotateImage(*image,draw_info,exception);
812 if (LocaleCompare("antialias",option+1) == 0)
814 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
816 draw_info->text_antialias=(*option == '-') ? MagickTrue :
820 if (LocaleCompare("attenuate",option+1) == 0)
827 attenuate=InterpretLocaleValue(argv[i+1],(char **) NULL);
830 if (LocaleCompare("auto-gamma",option+1) == 0)
833 Auto Adjust Gamma of image based on its mean
835 (void) SyncImageSettings(mogrify_info,*image);
836 (void) AutoGammaImage(*image,exception);
839 if (LocaleCompare("auto-level",option+1) == 0)
842 Perfectly Normalize (max/min stretch) the image
844 (void) SyncImageSettings(mogrify_info,*image);
845 (void) AutoLevelImage(*image,exception);
848 if (LocaleCompare("auto-orient",option+1) == 0)
850 (void) SyncImageSettings(mogrify_info,*image);
851 switch ((*image)->orientation)
853 case TopRightOrientation:
855 mogrify_image=FlopImage(*image,exception);
858 case BottomRightOrientation:
860 mogrify_image=RotateImage(*image,180.0,exception);
863 case BottomLeftOrientation:
865 mogrify_image=FlipImage(*image,exception);
868 case LeftTopOrientation:
870 mogrify_image=TransposeImage(*image,exception);
873 case RightTopOrientation:
875 mogrify_image=RotateImage(*image,90.0,exception);
878 case RightBottomOrientation:
880 mogrify_image=TransverseImage(*image,exception);
883 case LeftBottomOrientation:
885 mogrify_image=RotateImage(*image,270.0,exception);
891 if (mogrify_image != (Image *) NULL)
892 mogrify_image->orientation=TopLeftOrientation;
899 if (LocaleCompare("black-threshold",option+1) == 0)
902 Black threshold image.
904 (void) SyncImageSettings(mogrify_info,*image);
905 (void) BlackThresholdImage(*image,argv[i+1],exception);
906 InheritException(exception,&(*image)->exception);
909 if (LocaleCompare("blue-shift",option+1) == 0)
914 (void) SyncImageSettings(mogrify_info,*image);
915 geometry_info.rho=1.5;
917 flags=ParseGeometry(argv[i+1],&geometry_info);
918 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
921 if (LocaleCompare("blur",option+1) == 0)
926 (void) SyncImageSettings(mogrify_info,*image);
927 flags=ParseGeometry(argv[i+1],&geometry_info);
928 if ((flags & SigmaValue) == 0)
929 geometry_info.sigma=1.0;
930 if ((flags & XiValue) == 0)
931 geometry_info.xi=0.0;
932 mogrify_image=BlurImage(*image,geometry_info.rho,
933 geometry_info.sigma,geometry_info.xi,exception);
936 if (LocaleCompare("border",option+1) == 0)
939 Surround image with a border of solid color.
941 (void) SyncImageSettings(mogrify_info,*image);
942 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
943 if ((flags & SigmaValue) == 0)
944 geometry.height=geometry.width;
945 mogrify_image=BorderImage(*image,&geometry,compose,exception);
948 if (LocaleCompare("bordercolor",option+1) == 0)
952 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
953 &draw_info->border_color,exception);
956 (void) QueryColorCompliance(argv[i+1],AllCompliance,
957 &draw_info->border_color,exception);
960 if (LocaleCompare("box",option+1) == 0)
962 (void) QueryColorCompliance(argv[i+1],AllCompliance,
963 &draw_info->undercolor,exception);
966 if (LocaleCompare("brightness-contrast",option+1) == 0)
979 Brightness / contrast image.
981 (void) SyncImageSettings(mogrify_info,*image);
982 flags=ParseGeometry(argv[i+1],&geometry_info);
983 brightness=geometry_info.rho;
985 if ((flags & SigmaValue) != 0)
986 contrast=geometry_info.sigma;
987 (void) BrightnessContrastImage(*image,brightness,contrast,
989 InheritException(exception,&(*image)->exception);
996 if (LocaleCompare("cdl",option+1) == 0)
999 *color_correction_collection;
1002 Color correct with a color decision list.
1004 (void) SyncImageSettings(mogrify_info,*image);
1005 color_correction_collection=FileToString(argv[i+1],~0,exception);
1006 if (color_correction_collection == (char *) NULL)
1008 (void) ColorDecisionListImage(*image,color_correction_collection,
1010 InheritException(exception,&(*image)->exception);
1013 if (LocaleCompare("channel",option+1) == 0)
1016 channel=DefaultChannels;
1018 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1019 SetPixelChannelMap(*image,channel);
1022 if (LocaleCompare("charcoal",option+1) == 0)
1027 (void) SyncImageSettings(mogrify_info,*image);
1028 flags=ParseGeometry(argv[i+1],&geometry_info);
1029 if ((flags & SigmaValue) == 0)
1030 geometry_info.sigma=1.0;
1031 if ((flags & XiValue) == 0)
1032 geometry_info.xi=1.0;
1033 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1034 geometry_info.sigma,geometry_info.xi,exception);
1037 if (LocaleCompare("chop",option+1) == 0)
1042 (void) SyncImageSettings(mogrify_info,*image);
1043 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1044 mogrify_image=ChopImage(*image,&geometry,exception);
1047 if (LocaleCompare("clamp",option+1) == 0)
1052 (void) SyncImageSettings(mogrify_info,*image);
1053 (void) ClampImage(*image,exception);
1056 if (LocaleCompare("clip",option+1) == 0)
1058 (void) SyncImageSettings(mogrify_info,*image);
1061 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1064 (void) ClipImage(*image,exception);
1067 if (LocaleCompare("clip-mask",option+1) == 0)
1084 (void) SyncImageSettings(mogrify_info,*image);
1090 (void) SetImageMask(*image,(Image *) NULL,exception);
1095 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1097 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1098 if (mask_image == (Image *) NULL)
1100 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1101 return(MagickFalse);
1102 mask_view=AcquireCacheView(mask_image);
1103 for (y=0; y < (ssize_t) mask_image->rows; y++)
1105 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1107 if (q == (Quantum *) NULL)
1109 for (x=0; x < (ssize_t) mask_image->columns; x++)
1111 if (mask_image->matte == MagickFalse)
1112 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1113 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1114 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1115 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1116 q+=GetPixelChannels(mask_image);
1118 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1121 mask_view=DestroyCacheView(mask_view);
1122 mask_image->matte=MagickTrue;
1123 (void) SetImageClipMask(*image,mask_image,exception);
1124 InheritException(exception,&(*image)->exception);
1127 if (LocaleCompare("clip-path",option+1) == 0)
1129 (void) SyncImageSettings(mogrify_info,*image);
1130 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1131 MagickFalse,exception);
1134 if (LocaleCompare("colorize",option+1) == 0)
1139 (void) SyncImageSettings(mogrify_info,*image);
1140 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1143 if (LocaleCompare("color-matrix",option+1) == 0)
1148 (void) SyncImageSettings(mogrify_info,*image);
1149 kernel=AcquireKernelInfo(argv[i+1]);
1150 if (kernel == (KernelInfo *) NULL)
1152 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1153 kernel=DestroyKernelInfo(kernel);
1156 if (LocaleCompare("colors",option+1) == 0)
1159 Reduce the number of colors in the image.
1161 (void) SyncImageSettings(mogrify_info,*image);
1162 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1163 if (quantize_info->number_colors == 0)
1165 if (((*image)->storage_class == DirectClass) ||
1166 (*image)->colors > quantize_info->number_colors)
1167 (void) QuantizeImage(quantize_info,*image,exception);
1169 (void) CompressImageColormap(*image,exception);
1172 if (LocaleCompare("colorspace",option+1) == 0)
1177 (void) SyncImageSettings(mogrify_info,*image);
1180 (void) TransformImageColorspace(*image,RGBColorspace,exception);
1183 colorspace=(ColorspaceType) ParseCommandOption(
1184 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1185 (void) TransformImageColorspace(*image,colorspace,exception);
1188 if (LocaleCompare("compose",option+1) == 0)
1190 (void) SyncImageSettings(mogrify_info,*image);
1191 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1192 MagickFalse,argv[i+1]);
1195 if (LocaleCompare("contrast",option+1) == 0)
1197 (void) SyncImageSettings(mogrify_info,*image);
1198 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1199 MagickFalse,exception);
1202 if (LocaleCompare("contrast-stretch",option+1) == 0)
1212 Contrast stretch image.
1214 (void) SyncImageSettings(mogrify_info,*image);
1215 flags=ParseGeometry(argv[i+1],&geometry_info);
1216 black_point=geometry_info.rho;
1217 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1219 if ((flags & PercentValue) != 0)
1221 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1222 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1224 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1226 (void) ContrastStretchImage(*image,black_point,white_point,
1228 InheritException(exception,&(*image)->exception);
1231 if (LocaleCompare("convolve",option+1) == 0)
1236 (void) SyncImageSettings(mogrify_info,*image);
1237 kernel_info=AcquireKernelInfo(argv[i+1]);
1238 if (kernel_info == (KernelInfo *) NULL)
1240 kernel_info->bias=(*image)->bias;
1241 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1242 kernel_info=DestroyKernelInfo(kernel_info);
1245 if (LocaleCompare("crop",option+1) == 0)
1248 Crop a image to a smaller size
1250 (void) SyncImageSettings(mogrify_info,*image);
1251 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1254 if (LocaleCompare("cycle",option+1) == 0)
1257 Cycle an image colormap.
1259 (void) SyncImageSettings(mogrify_info,*image);
1260 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1268 if (LocaleCompare("decipher",option+1) == 0)
1276 (void) SyncImageSettings(mogrify_info,*image);
1277 passkey=FileToStringInfo(argv[i+1],~0,exception);
1278 if (passkey != (StringInfo *) NULL)
1280 (void) PasskeyDecipherImage(*image,passkey,exception);
1281 passkey=DestroyStringInfo(passkey);
1285 if (LocaleCompare("density",option+1) == 0)
1290 (void) CloneString(&draw_info->density,argv[i+1]);
1293 if (LocaleCompare("depth",option+1) == 0)
1295 (void) SyncImageSettings(mogrify_info,*image);
1298 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1301 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1304 if (LocaleCompare("deskew",option+1) == 0)
1310 Straighten the image.
1312 (void) SyncImageSettings(mogrify_info,*image);
1314 threshold=40.0*QuantumRange/100.0;
1316 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1317 mogrify_image=DeskewImage(*image,threshold,exception);
1320 if (LocaleCompare("despeckle",option+1) == 0)
1323 Reduce the speckles within an image.
1325 (void) SyncImageSettings(mogrify_info,*image);
1326 mogrify_image=DespeckleImage(*image,exception);
1329 if (LocaleCompare("display",option+1) == 0)
1331 (void) CloneString(&draw_info->server_name,argv[i+1]);
1334 if (LocaleCompare("distort",option+1) == 0)
1338 token[MaxTextExtent];
1358 (void) SyncImageSettings(mogrify_info,*image);
1359 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1360 MagickFalse,argv[i+1]);
1361 if ( method == ResizeDistortion )
1363 /* Special Case - Argument is actually a resize geometry!
1364 ** Convert that to an appropriate distortion argument array.
1368 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1370 resize_args[0]=(double)geometry.width;
1371 resize_args[1]=(double)geometry.height;
1372 mogrify_image=DistortImage(*image,method,(size_t)2,
1373 resize_args,MagickTrue,exception);
1376 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1378 if (args == (char *) NULL)
1381 for (x=0; *p != '\0'; x++)
1383 GetMagickToken(p,&p,token);
1385 GetMagickToken(p,&p,token);
1387 number_arguments=(size_t) x;
1388 arguments=(double *) AcquireQuantumMemory(number_arguments,
1389 sizeof(*arguments));
1390 if (arguments == (double *) NULL)
1391 ThrowWandFatalException(ResourceLimitFatalError,
1392 "MemoryAllocationFailed",(*image)->filename);
1393 (void) ResetMagickMemory(arguments,0,number_arguments*
1394 sizeof(*arguments));
1396 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1398 GetMagickToken(p,&p,token);
1400 GetMagickToken(p,&p,token);
1401 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1403 args=DestroyString(args);
1404 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1405 (*option == '+') ? MagickTrue : MagickFalse,exception);
1406 arguments=(double *) RelinquishMagickMemory(arguments);
1409 if (LocaleCompare("dither",option+1) == 0)
1413 quantize_info->dither=MagickFalse;
1416 quantize_info->dither=MagickTrue;
1417 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1418 MagickDitherOptions,MagickFalse,argv[i+1]);
1419 if (quantize_info->dither_method == NoDitherMethod)
1420 quantize_info->dither=MagickFalse;
1423 if (LocaleCompare("draw",option+1) == 0)
1428 (void) SyncImageSettings(mogrify_info,*image);
1429 (void) CloneString(&draw_info->primitive,argv[i+1]);
1430 (void) DrawImage(*image,draw_info,exception);
1437 if (LocaleCompare("edge",option+1) == 0)
1440 Enhance edges in the image.
1442 (void) SyncImageSettings(mogrify_info,*image);
1443 flags=ParseGeometry(argv[i+1],&geometry_info);
1444 if ((flags & SigmaValue) == 0)
1445 geometry_info.sigma=1.0;
1446 mogrify_image=EdgeImage(*image,geometry_info.rho,
1447 geometry_info.sigma,exception);
1450 if (LocaleCompare("emboss",option+1) == 0)
1453 Gaussian embossen image.
1455 (void) SyncImageSettings(mogrify_info,*image);
1456 flags=ParseGeometry(argv[i+1],&geometry_info);
1457 if ((flags & SigmaValue) == 0)
1458 geometry_info.sigma=1.0;
1459 mogrify_image=EmbossImage(*image,geometry_info.rho,
1460 geometry_info.sigma,exception);
1463 if (LocaleCompare("encipher",option+1) == 0)
1471 (void) SyncImageSettings(mogrify_info,*image);
1472 passkey=FileToStringInfo(argv[i+1],~0,exception);
1473 if (passkey != (StringInfo *) NULL)
1475 (void) PasskeyEncipherImage(*image,passkey,exception);
1476 passkey=DestroyStringInfo(passkey);
1480 if (LocaleCompare("encoding",option+1) == 0)
1482 (void) CloneString(&draw_info->encoding,argv[i+1]);
1485 if (LocaleCompare("enhance",option+1) == 0)
1490 (void) SyncImageSettings(mogrify_info,*image);
1491 mogrify_image=EnhanceImage(*image,exception);
1494 if (LocaleCompare("equalize",option+1) == 0)
1499 (void) SyncImageSettings(mogrify_info,*image);
1500 (void) EqualizeImage(*image,exception);
1503 if (LocaleCompare("evaluate",option+1) == 0)
1508 MagickEvaluateOperator
1511 (void) SyncImageSettings(mogrify_info,*image);
1512 op=(MagickEvaluateOperator) ParseCommandOption(
1513 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1514 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1515 (void) EvaluateImage(*image,op,constant,exception);
1518 if (LocaleCompare("extent",option+1) == 0)
1521 Set the image extent.
1523 (void) SyncImageSettings(mogrify_info,*image);
1524 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1525 if (geometry.width == 0)
1526 geometry.width=(*image)->columns;
1527 if (geometry.height == 0)
1528 geometry.height=(*image)->rows;
1529 mogrify_image=ExtentImage(*image,&geometry,exception);
1536 if (LocaleCompare("family",option+1) == 0)
1540 if (draw_info->family != (char *) NULL)
1541 draw_info->family=DestroyString(draw_info->family);
1544 (void) CloneString(&draw_info->family,argv[i+1]);
1547 if (LocaleCompare("features",option+1) == 0)
1551 (void) DeleteImageArtifact(*image,"identify:features");
1554 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1557 if (LocaleCompare("fill",option+1) == 0)
1562 GetPixelInfo(*image,&fill);
1565 (void) QueryColorCompliance("none",AllCompliance,&fill,
1567 (void) QueryColorCompliance("none",AllCompliance,
1568 &draw_info->fill,exception);
1569 if (draw_info->fill_pattern != (Image *) NULL)
1570 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1573 sans=AcquireExceptionInfo();
1574 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
1576 status=QueryColorCompliance(argv[i+1],AllCompliance,
1577 &draw_info->fill,sans);
1578 sans=DestroyExceptionInfo(sans);
1579 if (status == MagickFalse)
1580 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1584 if (LocaleCompare("flip",option+1) == 0)
1587 Flip image scanlines.
1589 (void) SyncImageSettings(mogrify_info,*image);
1590 mogrify_image=FlipImage(*image,exception);
1593 if (LocaleCompare("floodfill",option+1) == 0)
1601 (void) SyncImageSettings(mogrify_info,*image);
1602 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1603 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1605 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1606 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1609 if (LocaleCompare("flop",option+1) == 0)
1612 Flop image scanlines.
1614 (void) SyncImageSettings(mogrify_info,*image);
1615 mogrify_image=FlopImage(*image,exception);
1618 if (LocaleCompare("font",option+1) == 0)
1622 if (draw_info->font != (char *) NULL)
1623 draw_info->font=DestroyString(draw_info->font);
1626 (void) CloneString(&draw_info->font,argv[i+1]);
1629 if (LocaleCompare("format",option+1) == 0)
1634 if (LocaleCompare("frame",option+1) == 0)
1640 Surround image with an ornamental border.
1642 (void) SyncImageSettings(mogrify_info,*image);
1643 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1644 frame_info.width=geometry.width;
1645 frame_info.height=geometry.height;
1646 if ((flags & HeightValue) == 0)
1647 frame_info.height=geometry.width;
1648 frame_info.outer_bevel=geometry.x;
1649 frame_info.inner_bevel=geometry.y;
1650 frame_info.x=(ssize_t) frame_info.width;
1651 frame_info.y=(ssize_t) frame_info.height;
1652 frame_info.width=(*image)->columns+2*frame_info.width;
1653 frame_info.height=(*image)->rows+2*frame_info.height;
1654 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1657 if (LocaleCompare("function",option+1) == 0)
1661 token[MaxTextExtent];
1679 Function Modify Image Values
1681 (void) SyncImageSettings(mogrify_info,*image);
1682 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1683 MagickFalse,argv[i+1]);
1684 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1686 if (arguments == (char *) NULL)
1688 p=(char *) arguments;
1689 for (x=0; *p != '\0'; x++)
1691 GetMagickToken(p,&p,token);
1693 GetMagickToken(p,&p,token);
1695 number_parameters=(size_t) x;
1696 parameters=(double *) AcquireQuantumMemory(number_parameters,
1697 sizeof(*parameters));
1698 if (parameters == (double *) NULL)
1699 ThrowWandFatalException(ResourceLimitFatalError,
1700 "MemoryAllocationFailed",(*image)->filename);
1701 (void) ResetMagickMemory(parameters,0,number_parameters*
1702 sizeof(*parameters));
1703 p=(char *) arguments;
1704 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1706 GetMagickToken(p,&p,token);
1708 GetMagickToken(p,&p,token);
1709 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1711 arguments=DestroyString(arguments);
1712 (void) FunctionImage(*image,function,number_parameters,parameters,
1714 parameters=(double *) RelinquishMagickMemory(parameters);
1721 if (LocaleCompare("gamma",option+1) == 0)
1726 (void) SyncImageSettings(mogrify_info,*image);
1728 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1730 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1731 (char **) NULL),exception);
1734 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1735 (LocaleCompare("gaussian",option+1) == 0))
1738 Gaussian blur image.
1740 (void) SyncImageSettings(mogrify_info,*image);
1741 flags=ParseGeometry(argv[i+1],&geometry_info);
1742 if ((flags & SigmaValue) == 0)
1743 geometry_info.sigma=1.0;
1744 if ((flags & XiValue) == 0)
1745 geometry_info.xi=0.0;
1746 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1747 geometry_info.sigma,geometry_info.xi,exception);
1750 if (LocaleCompare("geometry",option+1) == 0)
1753 Record Image offset, Resize last image.
1755 (void) SyncImageSettings(mogrify_info,*image);
1758 if ((*image)->geometry != (char *) NULL)
1759 (*image)->geometry=DestroyString((*image)->geometry);
1762 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1763 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1764 (void) CloneString(&(*image)->geometry,argv[i+1]);
1766 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1767 (*image)->filter,(*image)->blur,exception);
1770 if (LocaleCompare("gravity",option+1) == 0)
1774 draw_info->gravity=UndefinedGravity;
1777 draw_info->gravity=(GravityType) ParseCommandOption(
1778 MagickGravityOptions,MagickFalse,argv[i+1]);
1785 if (LocaleCompare("highlight-color",option+1) == 0)
1787 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1794 if (LocaleCompare("identify",option+1) == 0)
1799 (void) SyncImageSettings(mogrify_info,*image);
1800 if (format == (char *) NULL)
1802 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1806 text=InterpretImageProperties(mogrify_info,*image,format,
1808 if (text == (char *) NULL)
1810 (void) fputs(text,stdout);
1811 (void) fputc('\n',stdout);
1812 text=DestroyString(text);
1815 if (LocaleCompare("implode",option+1) == 0)
1820 (void) SyncImageSettings(mogrify_info,*image);
1821 (void) ParseGeometry(argv[i+1],&geometry_info);
1822 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1823 interpolate_method,exception);
1826 if (LocaleCompare("interline-spacing",option+1) == 0)
1829 (void) ParseGeometry("0",&geometry_info);
1831 (void) ParseGeometry(argv[i+1],&geometry_info);
1832 draw_info->interline_spacing=geometry_info.rho;
1835 if (LocaleCompare("interpolate",option+1) == 0)
1837 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1838 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1841 if (LocaleCompare("interword-spacing",option+1) == 0)
1844 (void) ParseGeometry("0",&geometry_info);
1846 (void) ParseGeometry(argv[i+1],&geometry_info);
1847 draw_info->interword_spacing=geometry_info.rho;
1854 if (LocaleCompare("kerning",option+1) == 0)
1857 (void) ParseGeometry("0",&geometry_info);
1859 (void) ParseGeometry(argv[i+1],&geometry_info);
1860 draw_info->kerning=geometry_info.rho;
1867 if (LocaleCompare("lat",option+1) == 0)
1870 Local adaptive threshold image.
1872 (void) SyncImageSettings(mogrify_info,*image);
1873 flags=ParseGeometry(argv[i+1],&geometry_info);
1874 if ((flags & PercentValue) != 0)
1875 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1876 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1877 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1878 geometry_info.xi,exception);
1881 if (LocaleCompare("level",option+1) == 0)
1894 (void) SyncImageSettings(mogrify_info,*image);
1895 flags=ParseGeometry(argv[i+1],&geometry_info);
1896 black_point=geometry_info.rho;
1897 white_point=(MagickRealType) QuantumRange;
1898 if ((flags & SigmaValue) != 0)
1899 white_point=geometry_info.sigma;
1901 if ((flags & XiValue) != 0)
1902 gamma=geometry_info.xi;
1903 if ((flags & PercentValue) != 0)
1905 black_point*=(MagickRealType) (QuantumRange/100.0);
1906 white_point*=(MagickRealType) (QuantumRange/100.0);
1908 if ((flags & SigmaValue) == 0)
1909 white_point=(MagickRealType) QuantumRange-black_point;
1910 if ((*option == '+') || ((flags & AspectValue) != 0))
1911 (void) LevelizeImage(*image,black_point,white_point,gamma,
1914 (void) LevelImage(*image,black_point,white_point,gamma,
1916 InheritException(exception,&(*image)->exception);
1919 if (LocaleCompare("level-colors",option+1) == 0)
1922 token[MaxTextExtent];
1931 p=(const char *) argv[i+1];
1932 GetMagickToken(p,&p,token); /* get black point color */
1933 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1934 (void) QueryColorCompliance(token,AllCompliance,
1935 &black_point,exception);
1937 (void) QueryColorCompliance("#000000",AllCompliance,
1938 &black_point,exception);
1939 if (isalpha((int) token[0]) || (token[0] == '#'))
1940 GetMagickToken(p,&p,token);
1942 white_point=black_point; /* set everything to that color */
1945 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1946 GetMagickToken(p,&p,token); /* Get white point color. */
1947 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1948 (void) QueryColorCompliance(token,AllCompliance,
1949 &white_point,exception);
1951 (void) QueryColorCompliance("#ffffff",AllCompliance,
1952 &white_point,exception);
1954 (void) LevelImageColors(*image,&black_point,&white_point,
1955 *option == '+' ? MagickTrue : MagickFalse,exception);
1958 if (LocaleCompare("linear-stretch",option+1) == 0)
1967 (void) SyncImageSettings(mogrify_info,*image);
1968 flags=ParseGeometry(argv[i+1],&geometry_info);
1969 black_point=geometry_info.rho;
1970 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1971 if ((flags & SigmaValue) != 0)
1972 white_point=geometry_info.sigma;
1973 if ((flags & PercentValue) != 0)
1975 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1976 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1978 if ((flags & SigmaValue) == 0)
1979 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1981 (void) LinearStretchImage(*image,black_point,white_point,exception);
1982 InheritException(exception,&(*image)->exception);
1985 if (LocaleCompare("linewidth",option+1) == 0)
1987 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1991 if (LocaleCompare("liquid-rescale",option+1) == 0)
1994 Liquid rescale image.
1996 (void) SyncImageSettings(mogrify_info,*image);
1997 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1998 if ((flags & XValue) == 0)
2000 if ((flags & YValue) == 0)
2002 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2003 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2006 if (LocaleCompare("lowlight-color",option+1) == 0)
2008 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2015 if (LocaleCompare("map",option+1) == 0)
2021 Transform image colors to match this set of colors.
2023 (void) SyncImageSettings(mogrify_info,*image);
2026 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2027 if (remap_image == (Image *) NULL)
2029 (void) RemapImage(quantize_info,*image,remap_image,exception);
2030 remap_image=DestroyImage(remap_image);
2033 if (LocaleCompare("mask",option+1) == 0)
2038 (void) SyncImageSettings(mogrify_info,*image);
2044 (void) SetImageMask(*image,(Image *) NULL,exception);
2050 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2051 if (mask == (Image *) NULL)
2053 (void) SetImageMask(*image,mask,exception);
2054 mask=DestroyImage(mask);
2057 if (LocaleCompare("matte",option+1) == 0)
2059 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2060 SetAlphaChannel : DeactivateAlphaChannel,exception);
2063 if (LocaleCompare("median",option+1) == 0)
2066 Median filter image.
2068 (void) SyncImageSettings(mogrify_info,*image);
2069 flags=ParseGeometry(argv[i+1],&geometry_info);
2070 if ((flags & SigmaValue) == 0)
2071 geometry_info.sigma=geometry_info.rho;
2072 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2073 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2076 if (LocaleCompare("mode",option+1) == 0)
2081 (void) SyncImageSettings(mogrify_info,*image);
2082 flags=ParseGeometry(argv[i+1],&geometry_info);
2083 if ((flags & SigmaValue) == 0)
2084 geometry_info.sigma=geometry_info.rho;
2085 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2086 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2089 if (LocaleCompare("modulate",option+1) == 0)
2091 (void) SyncImageSettings(mogrify_info,*image);
2092 (void) ModulateImage(*image,argv[i+1],exception);
2095 if (LocaleCompare("monitor",option+1) == 0)
2099 (void) SetImageProgressMonitor(*image,
2100 (MagickProgressMonitor) NULL,(void *) NULL);
2103 (void) SetImageProgressMonitor(*image,MonitorProgress,
2107 if (LocaleCompare("monochrome",option+1) == 0)
2109 (void) SyncImageSettings(mogrify_info,*image);
2110 (void) SetImageType(*image,BilevelType,exception);
2113 if (LocaleCompare("morphology",option+1) == 0)
2116 token[MaxTextExtent];
2131 Morphological Image Operation
2133 (void) SyncImageSettings(mogrify_info,*image);
2135 GetMagickToken(p,&p,token);
2136 method=(MorphologyMethod) ParseCommandOption(
2137 MagickMorphologyOptions,MagickFalse,token);
2139 GetMagickToken(p,&p,token);
2140 if ((*p == ':') || (*p == ','))
2141 GetMagickToken(p,&p,token);
2143 iterations=(ssize_t) StringToLong(p);
2144 kernel=AcquireKernelInfo(argv[i+2]);
2145 if (kernel == (KernelInfo *) NULL)
2147 (void) ThrowMagickException(exception,GetMagickModule(),
2148 OptionError,"UnabletoParseKernel","morphology");
2152 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2154 kernel=DestroyKernelInfo(kernel);
2157 if (LocaleCompare("motion-blur",option+1) == 0)
2162 (void) SyncImageSettings(mogrify_info,*image);
2163 flags=ParseGeometry(argv[i+1],&geometry_info);
2164 if ((flags & SigmaValue) == 0)
2165 geometry_info.sigma=1.0;
2166 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2167 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2175 if (LocaleCompare("negate",option+1) == 0)
2177 (void) SyncImageSettings(mogrify_info,*image);
2178 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2179 MagickFalse,exception);
2182 if (LocaleCompare("noise",option+1) == 0)
2184 (void) SyncImageSettings(mogrify_info,*image);
2187 flags=ParseGeometry(argv[i+1],&geometry_info);
2188 if ((flags & SigmaValue) == 0)
2189 geometry_info.sigma=geometry_info.rho;
2190 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2191 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2198 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2199 MagickFalse,argv[i+1]);
2200 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2204 if (LocaleCompare("normalize",option+1) == 0)
2206 (void) SyncImageSettings(mogrify_info,*image);
2207 (void) NormalizeImage(*image,exception);
2214 if (LocaleCompare("opaque",option+1) == 0)
2219 (void) SyncImageSettings(mogrify_info,*image);
2220 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2222 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2223 MagickFalse : MagickTrue,exception);
2226 if (LocaleCompare("ordered-dither",option+1) == 0)
2228 (void) SyncImageSettings(mogrify_info,*image);
2229 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2236 if (LocaleCompare("paint",option+1) == 0)
2238 (void) SyncImageSettings(mogrify_info,*image);
2239 (void) ParseGeometry(argv[i+1],&geometry_info);
2240 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2241 geometry_info.sigma,exception);
2244 if (LocaleCompare("pen",option+1) == 0)
2248 (void) QueryColorCompliance("none",AllCompliance,
2249 &draw_info->fill,exception);
2252 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2253 &draw_info->fill,exception);
2256 if (LocaleCompare("pointsize",option+1) == 0)
2259 (void) ParseGeometry("12",&geometry_info);
2261 (void) ParseGeometry(argv[i+1],&geometry_info);
2262 draw_info->pointsize=geometry_info.rho;
2265 if (LocaleCompare("polaroid",option+1) == 0)
2274 Simulate a Polaroid picture.
2276 (void) SyncImageSettings(mogrify_info,*image);
2277 random_info=AcquireRandomInfo();
2278 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2279 random_info=DestroyRandomInfo(random_info);
2282 SetGeometryInfo(&geometry_info);
2283 flags=ParseGeometry(argv[i+1],&geometry_info);
2284 angle=geometry_info.rho;
2286 mogrify_image=PolaroidImage(*image,draw_info,angle,
2287 interpolate_method,exception);
2290 if (LocaleCompare("posterize",option+1) == 0)
2295 (void) SyncImageSettings(mogrify_info,*image);
2296 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2297 quantize_info->dither,exception);
2300 if (LocaleCompare("preview",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image);
2310 preview_type=UndefinedPreview;
2312 preview_type=(PreviewType) ParseCommandOption(
2313 MagickPreviewOptions,MagickFalse,argv[i+1]);
2314 mogrify_image=PreviewImage(*image,preview_type,exception);
2317 if (LocaleCompare("profile",option+1) == 0)
2331 (void) SyncImageSettings(mogrify_info,*image);
2335 Remove a profile from the image.
2337 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2342 Associate a profile with the image.
2344 profile_info=CloneImageInfo(mogrify_info);
2345 profile=GetImageProfile(*image,"iptc");
2346 if (profile != (StringInfo *) NULL)
2347 profile_info->profile=(void *) CloneStringInfo(profile);
2348 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2349 profile_info=DestroyImageInfo(profile_info);
2350 if (profile_image == (Image *) NULL)
2355 profile_info=CloneImageInfo(mogrify_info);
2356 (void) CopyMagickString(profile_info->filename,argv[i+1],
2358 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2359 if (profile != (StringInfo *) NULL)
2361 (void) ProfileImage(*image,profile_info->magick,
2362 GetStringInfoDatum(profile),(size_t)
2363 GetStringInfoLength(profile),MagickFalse);
2364 profile=DestroyStringInfo(profile);
2366 profile_info=DestroyImageInfo(profile_info);
2369 ResetImageProfileIterator(profile_image);
2370 name=GetNextImageProfile(profile_image);
2371 while (name != (const char *) NULL)
2373 profile=GetImageProfile(profile_image,name);
2374 if (profile != (StringInfo *) NULL)
2375 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2376 (size_t) GetStringInfoLength(profile),MagickFalse);
2377 name=GetNextImageProfile(profile_image);
2379 profile_image=DestroyImage(profile_image);
2386 if (LocaleCompare("quantize",option+1) == 0)
2390 quantize_info->colorspace=UndefinedColorspace;
2393 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2394 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2401 if (LocaleCompare("radial-blur",option+1) == 0)
2406 (void) SyncImageSettings(mogrify_info,*image);
2407 flags=ParseGeometry(argv[i+1],&geometry_info);
2408 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2409 geometry_info.sigma,exception);
2412 if (LocaleCompare("raise",option+1) == 0)
2415 Surround image with a raise of solid color.
2417 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2418 if ((flags & SigmaValue) == 0)
2419 geometry.height=geometry.width;
2420 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2421 MagickFalse,exception);
2424 if (LocaleCompare("random-threshold",option+1) == 0)
2429 (void) SyncImageSettings(mogrify_info,*image);
2430 (void) RandomThresholdImage(*image,argv[i+1],exception);
2433 if (LocaleCompare("recolor",option+1) == 0)
2438 (void) SyncImageSettings(mogrify_info,*image);
2439 kernel=AcquireKernelInfo(argv[i+1]);
2440 if (kernel == (KernelInfo *) NULL)
2442 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2443 kernel=DestroyKernelInfo(kernel);
2446 if (LocaleCompare("region",option+1) == 0)
2448 (void) SyncImageSettings(mogrify_info,*image);
2449 if (region_image != (Image *) NULL)
2454 (void) CompositeImage(region_image,region_image->matte !=
2455 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2456 region_geometry.x,region_geometry.y,exception);
2457 *image=DestroyImage(*image);
2458 *image=region_image;
2459 region_image = (Image *) NULL;
2464 Apply transformations to a selected region of the image.
2466 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2468 mogrify_image=CropImage(*image,®ion_geometry,exception);
2469 if (mogrify_image == (Image *) NULL)
2471 region_image=(*image);
2472 *image=mogrify_image;
2473 mogrify_image=(Image *) NULL;
2476 if (LocaleCompare("render",option+1) == 0)
2478 (void) SyncImageSettings(mogrify_info,*image);
2479 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2482 if (LocaleCompare("remap",option+1) == 0)
2488 Transform image colors to match this set of colors.
2490 (void) SyncImageSettings(mogrify_info,*image);
2493 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2494 if (remap_image == (Image *) NULL)
2496 (void) RemapImage(quantize_info,*image,remap_image,exception);
2497 remap_image=DestroyImage(remap_image);
2500 if (LocaleCompare("repage",option+1) == 0)
2504 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2507 (void) ResetImagePage(*image,argv[i+1]);
2508 InheritException(exception,&(*image)->exception);
2511 if (LocaleCompare("resample",option+1) == 0)
2516 (void) SyncImageSettings(mogrify_info,*image);
2517 flags=ParseGeometry(argv[i+1],&geometry_info);
2518 if ((flags & SigmaValue) == 0)
2519 geometry_info.sigma=geometry_info.rho;
2520 mogrify_image=ResampleImage(*image,geometry_info.rho,
2521 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2524 if (LocaleCompare("resize",option+1) == 0)
2529 (void) SyncImageSettings(mogrify_info,*image);
2530 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2531 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2532 (*image)->filter,(*image)->blur,exception);
2535 if (LocaleCompare("roll",option+1) == 0)
2540 (void) SyncImageSettings(mogrify_info,*image);
2541 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2542 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2545 if (LocaleCompare("rotate",option+1) == 0)
2551 Check for conditional image rotation.
2553 (void) SyncImageSettings(mogrify_info,*image);
2554 if (strchr(argv[i+1],'>') != (char *) NULL)
2555 if ((*image)->columns <= (*image)->rows)
2557 if (strchr(argv[i+1],'<') != (char *) NULL)
2558 if ((*image)->columns >= (*image)->rows)
2563 geometry=ConstantString(argv[i+1]);
2564 (void) SubstituteString(&geometry,">","");
2565 (void) SubstituteString(&geometry,"<","");
2566 (void) ParseGeometry(geometry,&geometry_info);
2567 geometry=DestroyString(geometry);
2568 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2575 if (LocaleCompare("sample",option+1) == 0)
2578 Sample image with pixel replication.
2580 (void) SyncImageSettings(mogrify_info,*image);
2581 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2582 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2586 if (LocaleCompare("scale",option+1) == 0)
2591 (void) SyncImageSettings(mogrify_info,*image);
2592 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2593 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2597 if (LocaleCompare("selective-blur",option+1) == 0)
2600 Selectively blur pixels within a contrast threshold.
2602 (void) SyncImageSettings(mogrify_info,*image);
2603 flags=ParseGeometry(argv[i+1],&geometry_info);
2604 if ((flags & PercentValue) != 0)
2605 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2606 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2607 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2610 if (LocaleCompare("separate",option+1) == 0)
2613 Break channels into separate images.
2615 (void) SyncImageSettings(mogrify_info,*image);
2616 mogrify_image=SeparateImages(*image,exception);
2619 if (LocaleCompare("sepia-tone",option+1) == 0)
2627 (void) SyncImageSettings(mogrify_info,*image);
2628 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2629 mogrify_image=SepiaToneImage(*image,threshold,exception);
2632 if (LocaleCompare("segment",option+1) == 0)
2637 (void) SyncImageSettings(mogrify_info,*image);
2638 flags=ParseGeometry(argv[i+1],&geometry_info);
2639 if ((flags & SigmaValue) == 0)
2640 geometry_info.sigma=1.0;
2641 (void) SegmentImage(*image,(*image)->colorspace,
2642 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2646 if (LocaleCompare("set",option+1) == 0)
2656 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2657 (void) DeleteImageRegistry(argv[i+1]+9);
2659 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2661 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2662 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2665 (void) DeleteImageProperty(*image,argv[i+1]);
2668 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2670 if (value == (char *) NULL)
2672 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2673 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2676 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2678 (void) SetImageOption(image_info,argv[i+1]+7,value);
2679 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2680 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2683 (void) SetImageProperty(*image,argv[i+1],value,exception);
2684 value=DestroyString(value);
2687 if (LocaleCompare("shade",option+1) == 0)
2692 (void) SyncImageSettings(mogrify_info,*image);
2693 flags=ParseGeometry(argv[i+1],&geometry_info);
2694 if ((flags & SigmaValue) == 0)
2695 geometry_info.sigma=1.0;
2696 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2697 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2700 if (LocaleCompare("shadow",option+1) == 0)
2705 (void) SyncImageSettings(mogrify_info,*image);
2706 flags=ParseGeometry(argv[i+1],&geometry_info);
2707 if ((flags & SigmaValue) == 0)
2708 geometry_info.sigma=1.0;
2709 if ((flags & XiValue) == 0)
2710 geometry_info.xi=4.0;
2711 if ((flags & PsiValue) == 0)
2712 geometry_info.psi=4.0;
2713 mogrify_image=ShadowImage(*image,geometry_info.rho,
2714 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2715 ceil(geometry_info.psi-0.5),exception);
2718 if (LocaleCompare("sharpen",option+1) == 0)
2723 (void) SyncImageSettings(mogrify_info,*image);
2724 flags=ParseGeometry(argv[i+1],&geometry_info);
2725 if ((flags & SigmaValue) == 0)
2726 geometry_info.sigma=1.0;
2727 if ((flags & XiValue) == 0)
2728 geometry_info.xi=0.0;
2729 mogrify_image=SharpenImage(*image,geometry_info.rho,
2730 geometry_info.sigma,geometry_info.xi,exception);
2733 if (LocaleCompare("shave",option+1) == 0)
2736 Shave the image edges.
2738 (void) SyncImageSettings(mogrify_info,*image);
2739 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2740 mogrify_image=ShaveImage(*image,&geometry,exception);
2743 if (LocaleCompare("shear",option+1) == 0)
2748 (void) SyncImageSettings(mogrify_info,*image);
2749 flags=ParseGeometry(argv[i+1],&geometry_info);
2750 if ((flags & SigmaValue) == 0)
2751 geometry_info.sigma=geometry_info.rho;
2752 mogrify_image=ShearImage(*image,geometry_info.rho,
2753 geometry_info.sigma,exception);
2756 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2759 Sigmoidal non-linearity contrast control.
2761 (void) SyncImageSettings(mogrify_info,*image);
2762 flags=ParseGeometry(argv[i+1],&geometry_info);
2763 if ((flags & SigmaValue) == 0)
2764 geometry_info.sigma=(double) QuantumRange/2.0;
2765 if ((flags & PercentValue) != 0)
2766 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2768 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2769 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2773 if (LocaleCompare("sketch",option+1) == 0)
2778 (void) SyncImageSettings(mogrify_info,*image);
2779 flags=ParseGeometry(argv[i+1],&geometry_info);
2780 if ((flags & SigmaValue) == 0)
2781 geometry_info.sigma=1.0;
2782 mogrify_image=SketchImage(*image,geometry_info.rho,
2783 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2786 if (LocaleCompare("solarize",option+1) == 0)
2791 (void) SyncImageSettings(mogrify_info,*image);
2792 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2793 (void) SolarizeImage(*image,threshold,exception);
2796 if (LocaleCompare("sparse-color",option+1) == 0)
2805 Sparse Color Interpolated Gradient
2807 (void) SyncImageSettings(mogrify_info,*image);
2808 method=(SparseColorMethod) ParseCommandOption(
2809 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2810 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2812 if (arguments == (char *) NULL)
2814 mogrify_image=SparseColorOption(*image,method,arguments,
2815 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2816 arguments=DestroyString(arguments);
2819 if (LocaleCompare("splice",option+1) == 0)
2822 Splice a solid color into the image.
2824 (void) SyncImageSettings(mogrify_info,*image);
2825 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2826 mogrify_image=SpliceImage(*image,&geometry,exception);
2829 if (LocaleCompare("spread",option+1) == 0)
2834 (void) SyncImageSettings(mogrify_info,*image);
2835 (void) ParseGeometry(argv[i+1],&geometry_info);
2836 mogrify_image=SpreadImage(*image,geometry_info.rho,
2837 interpolate_method,exception);
2840 if (LocaleCompare("statistic",option+1) == 0)
2845 (void) SyncImageSettings(mogrify_info,*image);
2846 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2847 MagickFalse,argv[i+1]);
2848 (void) ParseGeometry(argv[i+2],&geometry_info);
2849 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2850 (size_t) geometry_info.sigma,exception);
2853 if (LocaleCompare("stretch",option+1) == 0)
2857 draw_info->stretch=UndefinedStretch;
2860 draw_info->stretch=(StretchType) ParseCommandOption(
2861 MagickStretchOptions,MagickFalse,argv[i+1]);
2864 if (LocaleCompare("strip",option+1) == 0)
2867 Strip image of profiles and comments.
2869 (void) SyncImageSettings(mogrify_info,*image);
2870 (void) StripImage(*image,exception);
2873 if (LocaleCompare("stroke",option+1) == 0)
2880 (void) QueryColorCompliance("none",AllCompliance,
2881 &draw_info->stroke,exception);
2882 if (draw_info->stroke_pattern != (Image *) NULL)
2883 draw_info->stroke_pattern=DestroyImage(
2884 draw_info->stroke_pattern);
2887 sans=AcquireExceptionInfo();
2888 status=QueryColorCompliance(argv[i+1],AllCompliance,
2889 &draw_info->stroke,sans);
2890 sans=DestroyExceptionInfo(sans);
2891 if (status == MagickFalse)
2892 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2896 if (LocaleCompare("strokewidth",option+1) == 0)
2898 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2902 if (LocaleCompare("style",option+1) == 0)
2906 draw_info->style=UndefinedStyle;
2909 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2910 MagickFalse,argv[i+1]);
2913 if (LocaleCompare("swirl",option+1) == 0)
2918 (void) SyncImageSettings(mogrify_info,*image);
2919 (void) ParseGeometry(argv[i+1],&geometry_info);
2920 mogrify_image=SwirlImage(*image,geometry_info.rho,
2921 interpolate_method,exception);
2928 if (LocaleCompare("threshold",option+1) == 0)
2936 (void) SyncImageSettings(mogrify_info,*image);
2938 threshold=(double) QuantumRange/2;
2940 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2941 (void) BilevelImage(*image,threshold,exception);
2942 InheritException(exception,&(*image)->exception);
2945 if (LocaleCompare("thumbnail",option+1) == 0)
2950 (void) SyncImageSettings(mogrify_info,*image);
2951 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2952 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2956 if (LocaleCompare("tile",option+1) == 0)
2960 if (draw_info->fill_pattern != (Image *) NULL)
2961 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2964 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2968 if (LocaleCompare("tint",option+1) == 0)
2973 (void) SyncImageSettings(mogrify_info,*image);
2974 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2977 if (LocaleCompare("transform",option+1) == 0)
2980 Affine transform image.
2982 (void) SyncImageSettings(mogrify_info,*image);
2983 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2987 if (LocaleCompare("transparent",option+1) == 0)
2992 (void) SyncImageSettings(mogrify_info,*image);
2993 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2995 (void) TransparentPaintImage(*image,&target,(Quantum)
2996 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2997 &(*image)->exception);
3000 if (LocaleCompare("transpose",option+1) == 0)
3003 Transpose image scanlines.
3005 (void) SyncImageSettings(mogrify_info,*image);
3006 mogrify_image=TransposeImage(*image,exception);
3009 if (LocaleCompare("transverse",option+1) == 0)
3012 Transverse image scanlines.
3014 (void) SyncImageSettings(mogrify_info,*image);
3015 mogrify_image=TransverseImage(*image,exception);
3018 if (LocaleCompare("treedepth",option+1) == 0)
3020 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3023 if (LocaleCompare("trim",option+1) == 0)
3028 (void) SyncImageSettings(mogrify_info,*image);
3029 mogrify_image=TrimImage(*image,exception);
3032 if (LocaleCompare("type",option+1) == 0)
3037 (void) SyncImageSettings(mogrify_info,*image);
3041 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3043 (*image)->type=UndefinedType;
3044 (void) SetImageType(*image,type,exception);
3051 if (LocaleCompare("undercolor",option+1) == 0)
3053 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3054 &draw_info->undercolor,exception);
3057 if (LocaleCompare("unique",option+1) == 0)
3061 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3064 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3065 (void) SetImageArtifact(*image,"verbose","true");
3068 if (LocaleCompare("unique-colors",option+1) == 0)
3071 Unique image colors.
3073 (void) SyncImageSettings(mogrify_info,*image);
3074 mogrify_image=UniqueImageColors(*image,exception);
3077 if (LocaleCompare("unsharp",option+1) == 0)
3082 (void) SyncImageSettings(mogrify_info,*image);
3083 flags=ParseGeometry(argv[i+1],&geometry_info);
3084 if ((flags & SigmaValue) == 0)
3085 geometry_info.sigma=1.0;
3086 if ((flags & XiValue) == 0)
3087 geometry_info.xi=1.0;
3088 if ((flags & PsiValue) == 0)
3089 geometry_info.psi=0.05;
3090 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3091 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3098 if (LocaleCompare("verbose",option+1) == 0)
3100 (void) SetImageArtifact(*image,option+1,
3101 *option == '+' ? "false" : "true");
3104 if (LocaleCompare("vignette",option+1) == 0)
3109 (void) SyncImageSettings(mogrify_info,*image);
3110 flags=ParseGeometry(argv[i+1],&geometry_info);
3111 if ((flags & SigmaValue) == 0)
3112 geometry_info.sigma=1.0;
3113 if ((flags & XiValue) == 0)
3114 geometry_info.xi=0.1*(*image)->columns;
3115 if ((flags & PsiValue) == 0)
3116 geometry_info.psi=0.1*(*image)->rows;
3117 mogrify_image=VignetteImage(*image,geometry_info.rho,
3118 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3119 ceil(geometry_info.psi-0.5),exception);
3122 if (LocaleCompare("virtual-pixel",option+1) == 0)
3126 (void) SetImageVirtualPixelMethod(*image,
3127 UndefinedVirtualPixelMethod);
3130 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3131 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3139 if (LocaleCompare("wave",option+1) == 0)
3144 (void) SyncImageSettings(mogrify_info,*image);
3145 flags=ParseGeometry(argv[i+1],&geometry_info);
3146 if ((flags & SigmaValue) == 0)
3147 geometry_info.sigma=1.0;
3148 mogrify_image=WaveImage(*image,geometry_info.rho,
3149 geometry_info.sigma,interpolate_method,exception);
3152 if (LocaleCompare("weight",option+1) == 0)
3154 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3155 if (LocaleCompare(argv[i+1],"all") == 0)
3156 draw_info->weight=0;
3157 if (LocaleCompare(argv[i+1],"bold") == 0)
3158 draw_info->weight=700;
3159 if (LocaleCompare(argv[i+1],"bolder") == 0)
3160 if (draw_info->weight <= 800)
3161 draw_info->weight+=100;
3162 if (LocaleCompare(argv[i+1],"lighter") == 0)
3163 if (draw_info->weight >= 100)
3164 draw_info->weight-=100;
3165 if (LocaleCompare(argv[i+1],"normal") == 0)
3166 draw_info->weight=400;
3169 if (LocaleCompare("white-threshold",option+1) == 0)
3172 White threshold image.
3174 (void) SyncImageSettings(mogrify_info,*image);
3175 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3176 InheritException(exception,&(*image)->exception);
3185 Replace current image with any image that was generated
3187 if (mogrify_image != (Image *) NULL)
3188 ReplaceImageInListReturnLast(image,mogrify_image);
3191 if (region_image != (Image *) NULL)
3194 Composite transformed region onto image.
3196 (void) SyncImageSettings(mogrify_info,*image);
3197 (void) CompositeImage(region_image,region_image->matte !=
3198 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3199 region_geometry.x,region_geometry.y,exception);
3200 *image=DestroyImage(*image);
3201 *image=region_image;
3202 region_image = (Image *) NULL;
3207 quantize_info=DestroyQuantizeInfo(quantize_info);
3208 draw_info=DestroyDrawInfo(draw_info);
3209 mogrify_info=DestroyImageInfo(mogrify_info);
3210 status=(MagickStatusType) ((*image)->exception.severity ==
3211 UndefinedException ? 1 : 0);
3212 return(status == 0 ? MagickFalse : MagickTrue);
3216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 + M o g r i f y I m a g e C o m m a n d %
3224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3226 % MogrifyImageCommand() transforms an image or a sequence of images. These
3227 % transforms include image scaling, image rotation, color reduction, and
3228 % others. The transmogrified image overwrites the original image.
3230 % The format of the MogrifyImageCommand method is:
3232 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3233 % const char **argv,char **metadata,ExceptionInfo *exception)
3235 % A description of each parameter follows:
3237 % o image_info: the image info.
3239 % o argc: the number of elements in the argument vector.
3241 % o argv: A text array containing the command line arguments.
3243 % o metadata: any metadata is returned here.
3245 % o exception: return any errors or warnings in this structure.
3249 static MagickBooleanType MogrifyUsage(void)
3254 "-debug events display copious debugging information",
3255 "-help print program options",
3256 "-list type print a list of supported option arguments",
3257 "-log format format of debugging information",
3258 "-version print version information",
3263 "-adaptive-blur geometry",
3264 " adaptively blur pixels; decrease effect near edges",
3265 "-adaptive-resize geometry",
3266 " adaptively resize image using 'mesh' interpolation",
3267 "-adaptive-sharpen geometry",
3268 " adaptively sharpen pixels; increase effect near edges",
3269 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3270 " transparent, extract, background, or shape",
3271 "-annotate geometry text",
3272 " annotate the image with text",
3273 "-auto-gamma automagically adjust gamma level of image",
3274 "-auto-level automagically adjust color levels of image",
3275 "-auto-orient automagically orient (rotate) image",
3276 "-bench iterations measure performance",
3277 "-black-threshold value",
3278 " force all pixels below the threshold into black",
3279 "-blue-shift simulate a scene at nighttime in the moonlight",
3280 "-blur geometry reduce image noise and reduce detail levels",
3281 "-border geometry surround image with a border of color",
3282 "-bordercolor color border color",
3283 "-brightness-contrast geometry",
3284 " improve brightness / contrast of the image",
3285 "-cdl filename color correct with a color decision list",
3286 "-charcoal geometry simulate a charcoal drawing",
3287 "-chop geometry remove pixels from the image interior",
3288 "-clamp restrict pixel range from 0 to the quantum depth",
3289 "-clip clip along the first path from the 8BIM profile",
3290 "-clip-mask filename associate a clip mask with the image",
3291 "-clip-path id clip along a named path from the 8BIM profile",
3292 "-colorize value colorize the image with the fill color",
3293 "-color-matrix matrix apply color correction to the image",
3294 "-contrast enhance or reduce the image contrast",
3295 "-contrast-stretch geometry",
3296 " improve contrast by `stretching' the intensity range",
3297 "-convolve coefficients",
3298 " apply a convolution kernel to the image",
3299 "-cycle amount cycle the image colormap",
3300 "-decipher filename convert cipher pixels to plain pixels",
3301 "-deskew threshold straighten an image",
3302 "-despeckle reduce the speckles within an image",
3303 "-distort method args",
3304 " distort images according to given method ad args",
3305 "-draw string annotate the image with a graphic primitive",
3306 "-edge radius apply a filter to detect edges in the image",
3307 "-encipher filename convert plain pixels to cipher pixels",
3308 "-emboss radius emboss an image",
3309 "-enhance apply a digital filter to enhance a noisy image",
3310 "-equalize perform histogram equalization to an image",
3311 "-evaluate operator value",
3312 " evaluate an arithmetic, relational, or logical expression",
3313 "-extent geometry set the image size",
3314 "-extract geometry extract area from image",
3315 "-fft implements the discrete Fourier transform (DFT)",
3316 "-flip flip image vertically",
3317 "-floodfill geometry color",
3318 " floodfill the image with color",
3319 "-flop flop image horizontally",
3320 "-frame geometry surround image with an ornamental border",
3321 "-function name parameters",
3322 " apply function over image values",
3323 "-gamma value level of gamma correction",
3324 "-gaussian-blur geometry",
3325 " reduce image noise and reduce detail levels",
3326 "-geometry geometry preferred size or location of the image",
3327 "-identify identify the format and characteristics of the image",
3328 "-ift implements the inverse discrete Fourier transform (DFT)",
3329 "-implode amount implode image pixels about the center",
3330 "-lat geometry local adaptive thresholding",
3331 "-layers method optimize, merge, or compare image layers",
3332 "-level value adjust the level of image contrast",
3333 "-level-colors color,color",
3334 " level image with the given colors",
3335 "-linear-stretch geometry",
3336 " improve contrast by `stretching with saturation'",
3337 "-liquid-rescale geometry",
3338 " rescale image with seam-carving",
3339 "-median geometry apply a median filter to the image",
3340 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3341 "-modulate value vary the brightness, saturation, and hue",
3342 "-monochrome transform image to black and white",
3343 "-morphology method kernel",
3344 " apply a morphology method to the image",
3345 "-motion-blur geometry",
3346 " simulate motion blur",
3347 "-negate replace every pixel with its complementary color ",
3348 "-noise geometry add or reduce noise in an image",
3349 "-normalize transform image to span the full range of colors",
3350 "-opaque color change this color to the fill color",
3351 "-ordered-dither NxN",
3352 " add a noise pattern to the image with specific",
3354 "-paint radius simulate an oil painting",
3355 "-polaroid angle simulate a Polaroid picture",
3356 "-posterize levels reduce the image to a limited number of color levels",
3357 "-profile filename add, delete, or apply an image profile",
3358 "-quantize colorspace reduce colors in this colorspace",
3359 "-radial-blur angle radial blur the image",
3360 "-raise value lighten/darken image edges to create a 3-D effect",
3361 "-random-threshold low,high",
3362 " random threshold the image",
3363 "-region geometry apply options to a portion of the image",
3364 "-render render vector graphics",
3365 "-repage geometry size and location of an image canvas",
3366 "-resample geometry change the resolution of an image",
3367 "-resize geometry resize the image",
3368 "-roll geometry roll an image vertically or horizontally",
3369 "-rotate degrees apply Paeth rotation to the image",
3370 "-sample geometry scale image with pixel sampling",
3371 "-scale geometry scale the image",
3372 "-segment values segment an image",
3373 "-selective-blur geometry",
3374 " selectively blur pixels within a contrast threshold",
3375 "-sepia-tone threshold",
3376 " simulate a sepia-toned photo",
3377 "-set property value set an image property",
3378 "-shade degrees shade the image using a distant light source",
3379 "-shadow geometry simulate an image shadow",
3380 "-sharpen geometry sharpen the image",
3381 "-shave geometry shave pixels from the image edges",
3382 "-shear geometry slide one edge of the image along the X or Y axis",
3383 "-sigmoidal-contrast geometry",
3384 " increase the contrast without saturating highlights or shadows",
3385 "-sketch geometry simulate a pencil sketch",
3386 "-solarize threshold negate all pixels above the threshold level",
3387 "-sparse-color method args",
3388 " fill in a image based on a few color points",
3389 "-splice geometry splice the background color into the image",
3390 "-spread radius displace image pixels by a random amount",
3391 "-statistic type radius",
3392 " replace each pixel with corresponding statistic from the neighborhood",
3393 "-strip strip image of all profiles and comments",
3394 "-swirl degrees swirl image pixels about the center",
3395 "-threshold value threshold the image",
3396 "-thumbnail geometry create a thumbnail of the image",
3397 "-tile filename tile image when filling a graphic primitive",
3398 "-tint value tint the image with the fill color",
3399 "-transform affine transform image",
3400 "-transparent color make this color transparent within the image",
3401 "-transpose flip image vertically and rotate 90 degrees",
3402 "-transverse flop image horizontally and rotate 270 degrees",
3403 "-trim trim image edges",
3404 "-type type image type",
3405 "-unique-colors discard all but one of any pixel color",
3406 "-unsharp geometry sharpen the image",
3407 "-vignette geometry soften the edges of the image in vignette style",
3408 "-wave geometry alter an image along a sine wave",
3409 "-white-threshold value",
3410 " force all pixels above the threshold into white",
3413 *sequence_operators[]=
3415 "-append append an image sequence",
3416 "-clut apply a color lookup table to the image",
3417 "-coalesce merge a sequence of images",
3418 "-combine combine a sequence of images",
3419 "-composite composite image",
3420 "-crop geometry cut out a rectangular region of the image",
3421 "-deconstruct break down an image sequence into constituent parts",
3422 "-evaluate-sequence operator",
3423 " evaluate an arithmetic, relational, or logical expression",
3424 "-flatten flatten a sequence of images",
3425 "-fx expression apply mathematical expression to an image channel(s)",
3426 "-hald-clut apply a Hald color lookup table to the image",
3427 "-morph value morph an image sequence",
3428 "-mosaic create a mosaic from an image sequence",
3429 "-print string interpret string and print to console",
3430 "-process arguments process the image with a custom image filter",
3431 "-separate separate an image channel into a grayscale image",
3432 "-smush geometry smush an image sequence together",
3433 "-write filename write images to this file",
3438 "-adjoin join images into a single multi-image file",
3439 "-affine matrix affine transform matrix",
3440 "-alpha option activate, deactivate, reset, or set the alpha channel",
3441 "-antialias remove pixel-aliasing",
3442 "-authenticate password",
3443 " decipher image with this password",
3444 "-attenuate value lessen (or intensify) when adding noise to an image",
3445 "-background color background color",
3446 "-bias value add bias when convolving an image",
3447 "-black-point-compensation",
3448 " use black point compensation",
3449 "-blue-primary point chromaticity blue primary point",
3450 "-bordercolor color border color",
3451 "-caption string assign a caption to an image",
3452 "-channel type apply option to select image channels",
3453 "-colors value preferred number of colors in the image",
3454 "-colorspace type alternate image colorspace",
3455 "-comment string annotate image with comment",
3456 "-compose operator set image composite operator",
3457 "-compress type type of pixel compression when writing the image",
3458 "-define format:option",
3459 " define one or more image format options",
3460 "-delay value display the next image after pausing",
3461 "-density geometry horizontal and vertical density of the image",
3462 "-depth value image depth",
3463 "-direction type render text right-to-left or left-to-right",
3464 "-display server get image or font from this X server",
3465 "-dispose method layer disposal method",
3466 "-dither method apply error diffusion to image",
3467 "-encoding type text encoding type",
3468 "-endian type endianness (MSB or LSB) of the image",
3469 "-family name render text with this font family",
3470 "-fill color color to use when filling a graphic primitive",
3471 "-filter type use this filter when resizing an image",
3472 "-font name render text with this font",
3473 "-format \"string\" output formatted image characteristics",
3474 "-fuzz distance colors within this distance are considered equal",
3475 "-gravity type horizontal and vertical text placement",
3476 "-green-primary point chromaticity green primary point",
3477 "-intent type type of rendering intent when managing the image color",
3478 "-interlace type type of image interlacing scheme",
3479 "-interline-spacing value",
3480 " set the space between two text lines",
3481 "-interpolate method pixel color interpolation method",
3482 "-interword-spacing value",
3483 " set the space between two words",
3484 "-kerning value set the space between two letters",
3485 "-label string assign a label to an image",
3486 "-limit type value pixel cache resource limit",
3487 "-loop iterations add Netscape loop extension to your GIF animation",
3488 "-mask filename associate a mask with the image",
3489 "-mattecolor color frame color",
3490 "-monitor monitor progress",
3491 "-orient type image orientation",
3492 "-page geometry size and location of an image canvas (setting)",
3493 "-ping efficiently determine image attributes",
3494 "-pointsize value font point size",
3495 "-precision value maximum number of significant digits to print",
3496 "-preview type image preview type",
3497 "-quality value JPEG/MIFF/PNG compression level",
3498 "-quiet suppress all warning messages",
3499 "-red-primary point chromaticity red primary point",
3500 "-regard-warnings pay attention to warning messages",
3501 "-remap filename transform image colors to match this set of colors",
3502 "-respect-parentheses settings remain in effect until parenthesis boundary",
3503 "-sampling-factor geometry",
3504 " horizontal and vertical sampling factor",
3505 "-scene value image scene number",
3506 "-seed value seed a new sequence of pseudo-random numbers",
3507 "-size geometry width and height of image",
3508 "-stretch type render text with this font stretch",
3509 "-stroke color graphic primitive stroke color",
3510 "-strokewidth value graphic primitive stroke width",
3511 "-style type render text with this font style",
3512 "-synchronize synchronize image to storage device",
3513 "-taint declare the image as modified",
3514 "-texture filename name of texture to tile onto the image background",
3515 "-tile-offset geometry",
3517 "-treedepth value color tree depth",
3518 "-transparent-color color",
3519 " transparent color",
3520 "-undercolor color annotation bounding box color",
3521 "-units type the units of image resolution",
3522 "-verbose print detailed information about the image",
3523 "-view FlashPix viewing transforms",
3524 "-virtual-pixel method",
3525 " virtual pixel access method",
3526 "-weight type render text with this font weight",
3527 "-white-point point chromaticity white point",
3532 "-delete indexes delete the image from the image sequence",
3533 "-duplicate count,indexes",
3534 " duplicate an image one or more times",
3535 "-insert index insert last image into the image sequence",
3536 "-reverse reverse image sequence",
3537 "-swap indexes swap two images in the image sequence",
3544 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3545 (void) printf("Copyright: %s\n",GetMagickCopyright());
3546 (void) printf("Features: %s\n\n",GetMagickFeatures());
3547 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3549 (void) printf("\nImage Settings:\n");
3550 for (p=settings; *p != (char *) NULL; p++)
3551 (void) printf(" %s\n",*p);
3552 (void) printf("\nImage Operators:\n");
3553 for (p=operators; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nImage Sequence Operators:\n");
3556 for (p=sequence_operators; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3558 (void) printf("\nImage Stack Operators:\n");
3559 for (p=stack_operators; *p != (char *) NULL; p++)
3560 (void) printf(" %s\n",*p);
3561 (void) printf("\nMiscellaneous Options:\n");
3562 for (p=miscellaneous; *p != (char *) NULL; p++)
3563 (void) printf(" %s\n",*p);
3565 "\nBy default, the image format of `file' is determined by its magic\n");
3567 "number. To specify a particular image format, precede the filename\n");
3569 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3571 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3572 (void) printf("'-' for standard input or output.\n");
3573 return(MagickFalse);
3576 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3577 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3579 #define DestroyMogrify() \
3581 if (format != (char *) NULL) \
3582 format=DestroyString(format); \
3583 if (path != (char *) NULL) \
3584 path=DestroyString(path); \
3585 DestroyImageStack(); \
3586 for (i=0; i < (ssize_t) argc; i++) \
3587 argv[i]=DestroyString(argv[i]); \
3588 argv=(char **) RelinquishMagickMemory(argv); \
3590 #define ThrowMogrifyException(asperity,tag,option) \
3592 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3595 return(MagickFalse); \
3597 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3599 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3600 "InvalidArgument","`%s': %s",argument,option); \
3602 return(MagickFalse); \
3614 image_stack[MaxImageStackDepth+1];
3622 respect_parenthesis;
3637 assert(image_info != (ImageInfo *) NULL);
3638 assert(image_info->signature == MagickSignature);
3639 if (image_info->debug != MagickFalse)
3640 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3641 assert(exception != (ExceptionInfo *) NULL);
3645 if ((LocaleCompare("version",option+1) == 0) ||
3646 (LocaleCompare("-version",option+1) == 0))
3648 (void) FormatLocaleFile(stdout,"Version: %s\n",
3649 GetMagickVersion((size_t *) NULL));
3650 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3651 GetMagickCopyright());
3652 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3653 GetMagickFeatures());
3654 return(MagickFalse);
3658 return(MogrifyUsage());
3659 format=(char *) NULL;
3661 global_colormap=MagickFalse;
3665 option=(char *) NULL;
3667 respect_parenthesis=MagickFalse;
3672 ReadCommandlLine(argc,&argv);
3673 status=ExpandFilenames(&argc,&argv);
3674 if (status == MagickFalse)
3675 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3676 GetExceptionMessage(errno));
3677 for (i=1; i < (ssize_t) argc; i++)
3680 if (LocaleCompare(option,"(") == 0)
3682 FireImageStack(MagickFalse,MagickTrue,pend);
3683 if (k == MaxImageStackDepth)
3684 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3689 if (LocaleCompare(option,")") == 0)
3691 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3693 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3697 if (IsCommandOption(option) == MagickFalse)
3700 backup_filename[MaxTextExtent],
3707 Option is a file name: begin by reading image from specified file.
3709 FireImageStack(MagickFalse,MagickFalse,pend);
3711 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3713 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3714 images=ReadImages(image_info,exception);
3715 status&=(images != (Image *) NULL) &&
3716 (exception->severity < ErrorException);
3717 if (images == (Image *) NULL)
3719 if (format != (char *) NULL)
3720 (void) CopyMagickString(images->filename,images->magick_filename,
3722 if (path != (char *) NULL)
3724 GetPathComponent(option,TailPath,filename);
3725 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3726 path,*DirectorySeparator,filename);
3728 if (format != (char *) NULL)
3729 AppendImageFormat(format,images->filename);
3730 AppendImageStack(images);
3731 FinalizeImageSettings(image_info,image,MagickFalse);
3732 if (global_colormap != MagickFalse)
3737 quantize_info=AcquireQuantizeInfo(image_info);
3738 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3739 quantize_info=DestroyQuantizeInfo(quantize_info);
3741 *backup_filename='\0';
3742 if ((LocaleCompare(image->filename,"-") != 0) &&
3743 (IsPathWritable(image->filename) != MagickFalse))
3749 Rename image file as backup.
3751 (void) CopyMagickString(backup_filename,image->filename,
3753 for (i=0; i < 6; i++)
3755 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3756 if (IsPathAccessible(backup_filename) == MagickFalse)
3759 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3760 (rename_utf8(image->filename,backup_filename) != 0))
3761 *backup_filename='\0';
3764 Write transmogrified image to disk.
3766 image_info->synchronize=MagickTrue;
3767 status&=WriteImages(image_info,image,image->filename,exception);
3768 if ((status == MagickFalse) && (*backup_filename != '\0'))
3769 (void) remove_utf8(backup_filename);
3770 RemoveAllImageStack();
3773 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3774 switch (*(option+1))
3778 if (LocaleCompare("adaptive-blur",option+1) == 0)
3781 if (i == (ssize_t) argc)
3782 ThrowMogrifyException(OptionError,"MissingArgument",option);
3783 if (IsGeometry(argv[i]) == MagickFalse)
3784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3787 if (LocaleCompare("adaptive-resize",option+1) == 0)
3790 if (i == (ssize_t) argc)
3791 ThrowMogrifyException(OptionError,"MissingArgument",option);
3792 if (IsGeometry(argv[i]) == MagickFalse)
3793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3796 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3799 if (i == (ssize_t) argc)
3800 ThrowMogrifyException(OptionError,"MissingArgument",option);
3801 if (IsGeometry(argv[i]) == MagickFalse)
3802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3805 if (LocaleCompare("affine",option+1) == 0)
3810 if (i == (ssize_t) argc)
3811 ThrowMogrifyException(OptionError,"MissingArgument",option);
3814 if (LocaleCompare("alpha",option+1) == 0)
3822 if (i == (ssize_t) argc)
3823 ThrowMogrifyException(OptionError,"MissingArgument",option);
3824 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3826 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3830 if (LocaleCompare("annotate",option+1) == 0)
3835 if (i == (ssize_t) argc)
3836 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (IsGeometry(argv[i]) == MagickFalse)
3838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3839 if (i == (ssize_t) argc)
3840 ThrowMogrifyException(OptionError,"MissingArgument",option);
3844 if (LocaleCompare("antialias",option+1) == 0)
3846 if (LocaleCompare("append",option+1) == 0)
3848 if (LocaleCompare("attenuate",option+1) == 0)
3853 if (i == (ssize_t) (argc-1))
3854 ThrowMogrifyException(OptionError,"MissingArgument",option);
3855 if (IsGeometry(argv[i]) == MagickFalse)
3856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3859 if (LocaleCompare("authenticate",option+1) == 0)
3864 if (i == (ssize_t) argc)
3865 ThrowMogrifyException(OptionError,"MissingArgument",option);
3868 if (LocaleCompare("auto-gamma",option+1) == 0)
3870 if (LocaleCompare("auto-level",option+1) == 0)
3872 if (LocaleCompare("auto-orient",option+1) == 0)
3874 if (LocaleCompare("average",option+1) == 0)
3876 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3880 if (LocaleCompare("background",option+1) == 0)
3885 if (i == (ssize_t) argc)
3886 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 if (LocaleCompare("bias",option+1) == 0)
3894 if (i == (ssize_t) (argc-1))
3895 ThrowMogrifyException(OptionError,"MissingArgument",option);
3896 if (IsGeometry(argv[i]) == MagickFalse)
3897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3900 if (LocaleCompare("black-point-compensation",option+1) == 0)
3902 if (LocaleCompare("black-threshold",option+1) == 0)
3907 if (i == (ssize_t) argc)
3908 ThrowMogrifyException(OptionError,"MissingArgument",option);
3909 if (IsGeometry(argv[i]) == MagickFalse)
3910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3913 if (LocaleCompare("blue-primary",option+1) == 0)
3918 if (i == (ssize_t) argc)
3919 ThrowMogrifyException(OptionError,"MissingArgument",option);
3920 if (IsGeometry(argv[i]) == MagickFalse)
3921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3924 if (LocaleCompare("blue-shift",option+1) == 0)
3927 if (i == (ssize_t) argc)
3928 ThrowMogrifyException(OptionError,"MissingArgument",option);
3929 if (IsGeometry(argv[i]) == MagickFalse)
3930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3933 if (LocaleCompare("blur",option+1) == 0)
3936 if (i == (ssize_t) argc)
3937 ThrowMogrifyException(OptionError,"MissingArgument",option);
3938 if (IsGeometry(argv[i]) == MagickFalse)
3939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3942 if (LocaleCompare("border",option+1) == 0)
3947 if (i == (ssize_t) argc)
3948 ThrowMogrifyException(OptionError,"MissingArgument",option);
3949 if (IsGeometry(argv[i]) == MagickFalse)
3950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 if (LocaleCompare("bordercolor",option+1) == 0)
3958 if (i == (ssize_t) argc)
3959 ThrowMogrifyException(OptionError,"MissingArgument",option);
3962 if (LocaleCompare("box",option+1) == 0)
3967 if (i == (ssize_t) argc)
3968 ThrowMogrifyException(OptionError,"MissingArgument",option);
3971 if (LocaleCompare("brightness-contrast",option+1) == 0)
3974 if (i == (ssize_t) argc)
3975 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (IsGeometry(argv[i]) == MagickFalse)
3977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3980 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3984 if (LocaleCompare("cache",option+1) == 0)
3989 if (i == (ssize_t) argc)
3990 ThrowMogrifyException(OptionError,"MissingArgument",option);
3991 if (IsGeometry(argv[i]) == MagickFalse)
3992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3995 if (LocaleCompare("caption",option+1) == 0)
4000 if (i == (ssize_t) argc)
4001 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 if (LocaleCompare("channel",option+1) == 0)
4012 if (i == (ssize_t) (argc-1))
4013 ThrowMogrifyException(OptionError,"MissingArgument",option);
4014 channel=ParseChannelOption(argv[i]);
4016 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4020 if (LocaleCompare("cdl",option+1) == 0)
4025 if (i == (ssize_t) (argc-1))
4026 ThrowMogrifyException(OptionError,"MissingArgument",option);
4029 if (LocaleCompare("charcoal",option+1) == 0)
4034 if (i == (ssize_t) argc)
4035 ThrowMogrifyException(OptionError,"MissingArgument",option);
4036 if (IsGeometry(argv[i]) == MagickFalse)
4037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4040 if (LocaleCompare("chop",option+1) == 0)
4045 if (i == (ssize_t) argc)
4046 ThrowMogrifyException(OptionError,"MissingArgument",option);
4047 if (IsGeometry(argv[i]) == MagickFalse)
4048 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4051 if (LocaleCompare("clamp",option+1) == 0)
4053 if (LocaleCompare("clip",option+1) == 0)
4055 if (LocaleCompare("clip-mask",option+1) == 0)
4060 if (i == (ssize_t) argc)
4061 ThrowMogrifyException(OptionError,"MissingArgument",option);
4064 if (LocaleCompare("clut",option+1) == 0)
4066 if (LocaleCompare("coalesce",option+1) == 0)
4068 if (LocaleCompare("colorize",option+1) == 0)
4073 if (i == (ssize_t) argc)
4074 ThrowMogrifyException(OptionError,"MissingArgument",option);
4075 if (IsGeometry(argv[i]) == MagickFalse)
4076 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4079 if (LocaleCompare("color-matrix",option+1) == 0)
4087 if (i == (ssize_t) (argc-1))
4088 ThrowMogrifyException(OptionError,"MissingArgument",option);
4089 kernel_info=AcquireKernelInfo(argv[i]);
4090 if (kernel_info == (KernelInfo *) NULL)
4091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4092 kernel_info=DestroyKernelInfo(kernel_info);
4095 if (LocaleCompare("colors",option+1) == 0)
4100 if (i == (ssize_t) argc)
4101 ThrowMogrifyException(OptionError,"MissingArgument",option);
4102 if (IsGeometry(argv[i]) == MagickFalse)
4103 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4106 if (LocaleCompare("colorspace",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4119 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4123 if (LocaleCompare("combine",option+1) == 0)
4125 if (LocaleCompare("comment",option+1) == 0)
4130 if (i == (ssize_t) argc)
4131 ThrowMogrifyException(OptionError,"MissingArgument",option);
4134 if (LocaleCompare("composite",option+1) == 0)
4136 if (LocaleCompare("compress",option+1) == 0)
4144 if (i == (ssize_t) argc)
4145 ThrowMogrifyException(OptionError,"MissingArgument",option);
4146 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4149 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4153 if (LocaleCompare("concurrent",option+1) == 0)
4155 if (LocaleCompare("contrast",option+1) == 0)
4157 if (LocaleCompare("contrast-stretch",option+1) == 0)
4160 if (i == (ssize_t) argc)
4161 ThrowMogrifyException(OptionError,"MissingArgument",option);
4162 if (IsGeometry(argv[i]) == MagickFalse)
4163 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4166 if (LocaleCompare("convolve",option+1) == 0)
4174 if (i == (ssize_t) argc)
4175 ThrowMogrifyException(OptionError,"MissingArgument",option);
4176 kernel_info=AcquireKernelInfo(argv[i]);
4177 if (kernel_info == (KernelInfo *) NULL)
4178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4179 kernel_info=DestroyKernelInfo(kernel_info);
4182 if (LocaleCompare("crop",option+1) == 0)
4187 if (i == (ssize_t) argc)
4188 ThrowMogrifyException(OptionError,"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4193 if (LocaleCompare("cycle",option+1) == 0)
4198 if (i == (ssize_t) argc)
4199 ThrowMogrifyException(OptionError,"MissingArgument",option);
4200 if (IsGeometry(argv[i]) == MagickFalse)
4201 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4204 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4208 if (LocaleCompare("decipher",option+1) == 0)
4213 if (i == (ssize_t) (argc-1))
4214 ThrowMogrifyException(OptionError,"MissingArgument",option);
4217 if (LocaleCompare("deconstruct",option+1) == 0)
4219 if (LocaleCompare("debug",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4229 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4231 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4233 (void) SetLogEventMask(argv[i]);
4236 if (LocaleCompare("define",option+1) == 0)
4239 if (i == (ssize_t) argc)
4240 ThrowMogrifyException(OptionError,"MissingArgument",option);
4246 define=GetImageOption(image_info,argv[i]);
4247 if (define == (const char *) NULL)
4248 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4253 if (LocaleCompare("delay",option+1) == 0)
4258 if (i == (ssize_t) argc)
4259 ThrowMogrifyException(OptionError,"MissingArgument",option);
4260 if (IsGeometry(argv[i]) == MagickFalse)
4261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4264 if (LocaleCompare("delete",option+1) == 0)
4269 if (i == (ssize_t) (argc-1))
4270 ThrowMogrifyException(OptionError,"MissingArgument",option);
4271 if (IsGeometry(argv[i]) == MagickFalse)
4272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4275 if (LocaleCompare("density",option+1) == 0)
4280 if (i == (ssize_t) argc)
4281 ThrowMogrifyException(OptionError,"MissingArgument",option);
4282 if (IsGeometry(argv[i]) == MagickFalse)
4283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4286 if (LocaleCompare("depth",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,"MissingArgument",option);
4293 if (IsGeometry(argv[i]) == MagickFalse)
4294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297 if (LocaleCompare("deskew",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 if (IsGeometry(argv[i]) == MagickFalse)
4305 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308 if (LocaleCompare("despeckle",option+1) == 0)
4310 if (LocaleCompare("dft",option+1) == 0)
4312 if (LocaleCompare("direction",option+1) == 0)
4320 if (i == (ssize_t) argc)
4321 ThrowMogrifyException(OptionError,"MissingArgument",option);
4322 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4325 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4329 if (LocaleCompare("display",option+1) == 0)
4334 if (i == (ssize_t) argc)
4335 ThrowMogrifyException(OptionError,"MissingArgument",option);
4338 if (LocaleCompare("dispose",option+1) == 0)
4346 if (i == (ssize_t) argc)
4347 ThrowMogrifyException(OptionError,"MissingArgument",option);
4348 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4350 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4354 if (LocaleCompare("distort",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4362 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4364 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4367 if (i == (ssize_t) (argc-1))
4368 ThrowMogrifyException(OptionError,"MissingArgument",option);
4371 if (LocaleCompare("dither",option+1) == 0)
4379 if (i == (ssize_t) argc)
4380 ThrowMogrifyException(OptionError,"MissingArgument",option);
4381 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4383 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4387 if (LocaleCompare("draw",option+1) == 0)
4392 if (i == (ssize_t) argc)
4393 ThrowMogrifyException(OptionError,"MissingArgument",option);
4396 if (LocaleCompare("duplicate",option+1) == 0)
4401 if (i == (ssize_t) (argc-1))
4402 ThrowMogrifyException(OptionError,"MissingArgument",option);
4403 if (IsGeometry(argv[i]) == MagickFalse)
4404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4407 if (LocaleCompare("duration",option+1) == 0)
4412 if (i == (ssize_t) (argc-1))
4413 ThrowMogrifyException(OptionError,"MissingArgument",option);
4414 if (IsGeometry(argv[i]) == MagickFalse)
4415 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4418 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4422 if (LocaleCompare("edge",option+1) == 0)
4427 if (i == (ssize_t) argc)
4428 ThrowMogrifyException(OptionError,"MissingArgument",option);
4429 if (IsGeometry(argv[i]) == MagickFalse)
4430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4433 if (LocaleCompare("emboss",option+1) == 0)
4438 if (i == (ssize_t) argc)
4439 ThrowMogrifyException(OptionError,"MissingArgument",option);
4440 if (IsGeometry(argv[i]) == MagickFalse)
4441 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4444 if (LocaleCompare("encipher",option+1) == 0)
4449 if (i == (ssize_t) argc)
4450 ThrowMogrifyException(OptionError,"MissingArgument",option);
4453 if (LocaleCompare("encoding",option+1) == 0)
4458 if (i == (ssize_t) argc)
4459 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 if (LocaleCompare("endian",option+1) == 0)
4470 if (i == (ssize_t) argc)
4471 ThrowMogrifyException(OptionError,"MissingArgument",option);
4472 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4474 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4478 if (LocaleCompare("enhance",option+1) == 0)
4480 if (LocaleCompare("equalize",option+1) == 0)
4482 if (LocaleCompare("evaluate",option+1) == 0)
4490 if (i == (ssize_t) argc)
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4494 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4497 if (i == (ssize_t) (argc-1))
4498 ThrowMogrifyException(OptionError,"MissingArgument",option);
4499 if (IsGeometry(argv[i]) == MagickFalse)
4500 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4503 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4511 if (i == (ssize_t) argc)
4512 ThrowMogrifyException(OptionError,"MissingArgument",option);
4513 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4515 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4519 if (LocaleCompare("extent",option+1) == 0)
4524 if (i == (ssize_t) argc)
4525 ThrowMogrifyException(OptionError,"MissingArgument",option);
4526 if (IsGeometry(argv[i]) == MagickFalse)
4527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4530 if (LocaleCompare("extract",option+1) == 0)
4535 if (i == (ssize_t) argc)
4536 ThrowMogrifyException(OptionError,"MissingArgument",option);
4537 if (IsGeometry(argv[i]) == MagickFalse)
4538 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4541 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4545 if (LocaleCompare("family",option+1) == 0)
4550 if (i == (ssize_t) (argc-1))
4551 ThrowMogrifyException(OptionError,"MissingArgument",option);
4554 if (LocaleCompare("fill",option+1) == 0)
4559 if (i == (ssize_t) argc)
4560 ThrowMogrifyException(OptionError,"MissingArgument",option);
4563 if (LocaleCompare("filter",option+1) == 0)
4571 if (i == (ssize_t) argc)
4572 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4575 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4579 if (LocaleCompare("flatten",option+1) == 0)
4581 if (LocaleCompare("flip",option+1) == 0)
4583 if (LocaleCompare("flop",option+1) == 0)
4585 if (LocaleCompare("floodfill",option+1) == 0)
4590 if (i == (ssize_t) argc)
4591 ThrowMogrifyException(OptionError,"MissingArgument",option);
4592 if (IsGeometry(argv[i]) == MagickFalse)
4593 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4595 if (i == (ssize_t) argc)
4596 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 if (LocaleCompare("font",option+1) == 0)
4604 if (i == (ssize_t) argc)
4605 ThrowMogrifyException(OptionError,"MissingArgument",option);
4608 if (LocaleCompare("format",option+1) == 0)
4610 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4611 (void) CloneString(&format,(char *) NULL);
4615 if (i == (ssize_t) argc)
4616 ThrowMogrifyException(OptionError,"MissingArgument",option);
4617 (void) CloneString(&format,argv[i]);
4618 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4619 (void) ConcatenateMagickString(image_info->filename,":",
4621 (void) SetImageInfo(image_info,0,exception);
4622 if (*image_info->magick == '\0')
4623 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4627 if (LocaleCompare("frame",option+1) == 0)
4632 if (i == (ssize_t) argc)
4633 ThrowMogrifyException(OptionError,"MissingArgument",option);
4634 if (IsGeometry(argv[i]) == MagickFalse)
4635 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4638 if (LocaleCompare("function",option+1) == 0)
4646 if (i == (ssize_t) argc)
4647 ThrowMogrifyException(OptionError,"MissingArgument",option);
4648 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4650 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4652 if (i == (ssize_t) (argc-1))
4653 ThrowMogrifyException(OptionError,"MissingArgument",option);
4656 if (LocaleCompare("fuzz",option+1) == 0)
4661 if (i == (ssize_t) argc)
4662 ThrowMogrifyException(OptionError,"MissingArgument",option);
4663 if (IsGeometry(argv[i]) == MagickFalse)
4664 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4667 if (LocaleCompare("fx",option+1) == 0)
4672 if (i == (ssize_t) (argc-1))
4673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4676 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4680 if (LocaleCompare("gamma",option+1) == 0)
4683 if (i == (ssize_t) argc)
4684 ThrowMogrifyException(OptionError,"MissingArgument",option);
4685 if (IsGeometry(argv[i]) == MagickFalse)
4686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4689 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4690 (LocaleCompare("gaussian",option+1) == 0))
4693 if (i == (ssize_t) argc)
4694 ThrowMogrifyException(OptionError,"MissingArgument",option);
4695 if (IsGeometry(argv[i]) == MagickFalse)
4696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4699 if (LocaleCompare("geometry",option+1) == 0)
4704 if (i == (ssize_t) argc)
4705 ThrowMogrifyException(OptionError,"MissingArgument",option);
4706 if (IsGeometry(argv[i]) == MagickFalse)
4707 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4710 if (LocaleCompare("gravity",option+1) == 0)
4718 if (i == (ssize_t) argc)
4719 ThrowMogrifyException(OptionError,"MissingArgument",option);
4720 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4722 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4726 if (LocaleCompare("green-primary",option+1) == 0)
4731 if (i == (ssize_t) argc)
4732 ThrowMogrifyException(OptionError,"MissingArgument",option);
4733 if (IsGeometry(argv[i]) == MagickFalse)
4734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4737 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4741 if (LocaleCompare("hald-clut",option+1) == 0)
4743 if ((LocaleCompare("help",option+1) == 0) ||
4744 (LocaleCompare("-help",option+1) == 0))
4745 return(MogrifyUsage());
4746 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4750 if (LocaleCompare("identify",option+1) == 0)
4752 if (LocaleCompare("idft",option+1) == 0)
4754 if (LocaleCompare("implode",option+1) == 0)
4759 if (i == (ssize_t) argc)
4760 ThrowMogrifyException(OptionError,"MissingArgument",option);
4761 if (IsGeometry(argv[i]) == MagickFalse)
4762 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4765 if (LocaleCompare("intent",option+1) == 0)
4773 if (i == (ssize_t) (argc-1))
4774 ThrowMogrifyException(OptionError,"MissingArgument",option);
4775 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4777 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4781 if (LocaleCompare("interlace",option+1) == 0)
4789 if (i == (ssize_t) argc)
4790 ThrowMogrifyException(OptionError,"MissingArgument",option);
4791 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4794 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4798 if (LocaleCompare("interline-spacing",option+1) == 0)
4803 if (i == (ssize_t) (argc-1))
4804 ThrowMogrifyException(OptionError,"MissingArgument",option);
4805 if (IsGeometry(argv[i]) == MagickFalse)
4806 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4809 if (LocaleCompare("interpolate",option+1) == 0)
4817 if (i == (ssize_t) argc)
4818 ThrowMogrifyException(OptionError,"MissingArgument",option);
4819 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4821 if (interpolate < 0)
4822 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4826 if (LocaleCompare("interword-spacing",option+1) == 0)
4831 if (i == (ssize_t) (argc-1))
4832 ThrowMogrifyException(OptionError,"MissingArgument",option);
4833 if (IsGeometry(argv[i]) == MagickFalse)
4834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4837 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4841 if (LocaleCompare("kerning",option+1) == 0)
4846 if (i == (ssize_t) (argc-1))
4847 ThrowMogrifyException(OptionError,"MissingArgument",option);
4848 if (IsGeometry(argv[i]) == MagickFalse)
4849 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4852 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4856 if (LocaleCompare("label",option+1) == 0)
4861 if (i == (ssize_t) argc)
4862 ThrowMogrifyException(OptionError,"MissingArgument",option);
4865 if (LocaleCompare("lat",option+1) == 0)
4870 if (i == (ssize_t) argc)
4871 ThrowMogrifyException(OptionError,"MissingArgument",option);
4872 if (IsGeometry(argv[i]) == MagickFalse)
4873 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4875 if (LocaleCompare("layers",option+1) == 0)
4883 if (i == (ssize_t) (argc-1))
4884 ThrowMogrifyException(OptionError,"MissingArgument",option);
4885 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4887 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4891 if (LocaleCompare("level",option+1) == 0)
4894 if (i == (ssize_t) argc)
4895 ThrowMogrifyException(OptionError,"MissingArgument",option);
4896 if (IsGeometry(argv[i]) == MagickFalse)
4897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4900 if (LocaleCompare("level-colors",option+1) == 0)
4903 if (i == (ssize_t) argc)
4904 ThrowMogrifyException(OptionError,"MissingArgument",option);
4907 if (LocaleCompare("linewidth",option+1) == 0)
4912 if (i == (ssize_t) argc)
4913 ThrowMogrifyException(OptionError,"MissingArgument",option);
4914 if (IsGeometry(argv[i]) == MagickFalse)
4915 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4918 if (LocaleCompare("limit",option+1) == 0)
4932 if (i == (ssize_t) argc)
4933 ThrowMogrifyException(OptionError,"MissingArgument",option);
4934 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4937 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4940 if (i == (ssize_t) argc)
4941 ThrowMogrifyException(OptionError,"MissingArgument",option);
4942 value=InterpretLocaleValue(argv[i],&p);
4944 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4945 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4948 if (LocaleCompare("liquid-rescale",option+1) == 0)
4951 if (i == (ssize_t) argc)
4952 ThrowMogrifyException(OptionError,"MissingArgument",option);
4953 if (IsGeometry(argv[i]) == MagickFalse)
4954 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4957 if (LocaleCompare("list",option+1) == 0)
4965 if (i == (ssize_t) argc)
4966 ThrowMogrifyException(OptionError,"MissingArgument",option);
4967 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4969 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4970 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4972 return(status != 0 ? MagickFalse : MagickTrue);
4974 if (LocaleCompare("log",option+1) == 0)
4979 if ((i == (ssize_t) argc) ||
4980 (strchr(argv[i],'%') == (char *) NULL))
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4984 if (LocaleCompare("loop",option+1) == 0)
4989 if (i == (ssize_t) argc)
4990 ThrowMogrifyException(OptionError,"MissingArgument",option);
4991 if (IsGeometry(argv[i]) == MagickFalse)
4992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4995 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4999 if (LocaleCompare("map",option+1) == 0)
5001 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5005 if (i == (ssize_t) argc)
5006 ThrowMogrifyException(OptionError,"MissingArgument",option);
5009 if (LocaleCompare("mask",option+1) == 0)
5014 if (i == (ssize_t) argc)
5015 ThrowMogrifyException(OptionError,"MissingArgument",option);
5018 if (LocaleCompare("matte",option+1) == 0)
5020 if (LocaleCompare("mattecolor",option+1) == 0)
5025 if (i == (ssize_t) argc)
5026 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 if (LocaleCompare("maximum",option+1) == 0)
5031 if (LocaleCompare("minimum",option+1) == 0)
5033 if (LocaleCompare("modulate",option+1) == 0)
5038 if (i == (ssize_t) argc)
5039 ThrowMogrifyException(OptionError,"MissingArgument",option);
5040 if (IsGeometry(argv[i]) == MagickFalse)
5041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5044 if (LocaleCompare("median",option+1) == 0)
5049 if (i == (ssize_t) argc)
5050 ThrowMogrifyException(OptionError,"MissingArgument",option);
5051 if (IsGeometry(argv[i]) == MagickFalse)
5052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5055 if (LocaleCompare("mode",option+1) == 0)
5060 if (i == (ssize_t) argc)
5061 ThrowMogrifyException(OptionError,"MissingArgument",option);
5062 if (IsGeometry(argv[i]) == MagickFalse)
5063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5066 if (LocaleCompare("monitor",option+1) == 0)
5068 if (LocaleCompare("monochrome",option+1) == 0)
5070 if (LocaleCompare("morph",option+1) == 0)
5075 if (i == (ssize_t) (argc-1))
5076 ThrowMogrifyException(OptionError,"MissingArgument",option);
5077 if (IsGeometry(argv[i]) == MagickFalse)
5078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5081 if (LocaleCompare("morphology",option+1) == 0)
5084 token[MaxTextExtent];
5093 if (i == (ssize_t) argc)
5094 ThrowMogrifyException(OptionError,"MissingArgument",option);
5095 GetMagickToken(argv[i],NULL,token);
5096 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5098 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5101 if (i == (ssize_t) (argc-1))
5102 ThrowMogrifyException(OptionError,"MissingArgument",option);
5103 kernel_info=AcquireKernelInfo(argv[i]);
5104 if (kernel_info == (KernelInfo *) NULL)
5105 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5106 kernel_info=DestroyKernelInfo(kernel_info);
5109 if (LocaleCompare("mosaic",option+1) == 0)
5111 if (LocaleCompare("motion-blur",option+1) == 0)
5116 if (i == (ssize_t) argc)
5117 ThrowMogrifyException(OptionError,"MissingArgument",option);
5118 if (IsGeometry(argv[i]) == MagickFalse)
5119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5122 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5126 if (LocaleCompare("negate",option+1) == 0)
5128 if (LocaleCompare("noise",option+1) == 0)
5131 if (i == (ssize_t) argc)
5132 ThrowMogrifyException(OptionError,"MissingArgument",option);
5138 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5140 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5144 if (IsGeometry(argv[i]) == MagickFalse)
5145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5148 if (LocaleCompare("noop",option+1) == 0)
5150 if (LocaleCompare("normalize",option+1) == 0)
5152 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5156 if (LocaleCompare("opaque",option+1) == 0)
5159 if (i == (ssize_t) argc)
5160 ThrowMogrifyException(OptionError,"MissingArgument",option);
5163 if (LocaleCompare("ordered-dither",option+1) == 0)
5168 if (i == (ssize_t) argc)
5169 ThrowMogrifyException(OptionError,"MissingArgument",option);
5172 if (LocaleCompare("orient",option+1) == 0)
5177 orientation=UndefinedOrientation;
5181 if (i == (ssize_t) (argc-1))
5182 ThrowMogrifyException(OptionError,"MissingArgument",option);
5183 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5185 if (orientation < 0)
5186 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5190 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5194 if (LocaleCompare("page",option+1) == 0)
5199 if (i == (ssize_t) argc)
5200 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 if (LocaleCompare("paint",option+1) == 0)
5208 if (i == (ssize_t) argc)
5209 ThrowMogrifyException(OptionError,"MissingArgument",option);
5210 if (IsGeometry(argv[i]) == MagickFalse)
5211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5214 if (LocaleCompare("path",option+1) == 0)
5216 (void) CloneString(&path,(char *) NULL);
5220 if (i == (ssize_t) argc)
5221 ThrowMogrifyException(OptionError,"MissingArgument",option);
5222 (void) CloneString(&path,argv[i]);
5225 if (LocaleCompare("pointsize",option+1) == 0)
5230 if (i == (ssize_t) argc)
5231 ThrowMogrifyException(OptionError,"MissingArgument",option);
5232 if (IsGeometry(argv[i]) == MagickFalse)
5233 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5236 if (LocaleCompare("polaroid",option+1) == 0)
5241 if (i == (ssize_t) argc)
5242 ThrowMogrifyException(OptionError,"MissingArgument",option);
5243 if (IsGeometry(argv[i]) == MagickFalse)
5244 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5247 if (LocaleCompare("posterize",option+1) == 0)
5252 if (i == (ssize_t) argc)
5253 ThrowMogrifyException(OptionError,"MissingArgument",option);
5254 if (IsGeometry(argv[i]) == MagickFalse)
5255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5258 if (LocaleCompare("precision",option+1) == 0)
5263 if (i == (ssize_t) argc)
5264 ThrowMogrifyException(OptionError,"MissingArgument",option);
5265 if (IsGeometry(argv[i]) == MagickFalse)
5266 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5269 if (LocaleCompare("print",option+1) == 0)
5274 if (i == (ssize_t) argc)
5275 ThrowMogrifyException(OptionError,"MissingArgument",option);
5278 if (LocaleCompare("process",option+1) == 0)
5283 if (i == (ssize_t) (argc-1))
5284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 if (LocaleCompare("profile",option+1) == 0)
5290 if (i == (ssize_t) argc)
5291 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5298 if (LocaleCompare("quality",option+1) == 0)
5303 if (i == (ssize_t) argc)
5304 ThrowMogrifyException(OptionError,"MissingArgument",option);
5305 if (IsGeometry(argv[i]) == MagickFalse)
5306 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5309 if (LocaleCompare("quantize",option+1) == 0)
5317 if (i == (ssize_t) (argc-1))
5318 ThrowMogrifyException(OptionError,"MissingArgument",option);
5319 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5322 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5326 if (LocaleCompare("quiet",option+1) == 0)
5328 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5332 if (LocaleCompare("radial-blur",option+1) == 0)
5335 if (i == (ssize_t) argc)
5336 ThrowMogrifyException(OptionError,"MissingArgument",option);
5337 if (IsGeometry(argv[i]) == MagickFalse)
5338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5341 if (LocaleCompare("raise",option+1) == 0)
5344 if (i == (ssize_t) argc)
5345 ThrowMogrifyException(OptionError,"MissingArgument",option);
5346 if (IsGeometry(argv[i]) == MagickFalse)
5347 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5350 if (LocaleCompare("random-threshold",option+1) == 0)
5355 if (i == (ssize_t) argc)
5356 ThrowMogrifyException(OptionError,"MissingArgument",option);
5357 if (IsGeometry(argv[i]) == MagickFalse)
5358 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5361 if (LocaleCompare("recolor",option+1) == 0)
5366 if (i == (ssize_t) (argc-1))
5367 ThrowMogrifyException(OptionError,"MissingArgument",option);
5368 if (IsGeometry(argv[i]) == MagickFalse)
5369 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5372 if (LocaleCompare("red-primary",option+1) == 0)
5377 if (i == (ssize_t) argc)
5378 ThrowMogrifyException(OptionError,"MissingArgument",option);
5379 if (IsGeometry(argv[i]) == MagickFalse)
5380 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5382 if (LocaleCompare("regard-warnings",option+1) == 0)
5384 if (LocaleCompare("region",option+1) == 0)
5389 if (i == (ssize_t) argc)
5390 ThrowMogrifyException(OptionError,"MissingArgument",option);
5391 if (IsGeometry(argv[i]) == MagickFalse)
5392 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5395 if (LocaleCompare("remap",option+1) == 0)
5400 if (i == (ssize_t) (argc-1))
5401 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 if (LocaleCompare("render",option+1) == 0)
5406 if (LocaleCompare("repage",option+1) == 0)
5411 if (i == (ssize_t) argc)
5412 ThrowMogrifyException(OptionError,"MissingArgument",option);
5413 if (IsGeometry(argv[i]) == MagickFalse)
5414 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5417 if (LocaleCompare("resample",option+1) == 0)
5422 if (i == (ssize_t) argc)
5423 ThrowMogrifyException(OptionError,"MissingArgument",option);
5424 if (IsGeometry(argv[i]) == MagickFalse)
5425 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5428 if (LocaleCompare("resize",option+1) == 0)
5433 if (i == (ssize_t) argc)
5434 ThrowMogrifyException(OptionError,"MissingArgument",option);
5435 if (IsGeometry(argv[i]) == MagickFalse)
5436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5439 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5441 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5444 if (LocaleCompare("reverse",option+1) == 0)
5446 if (LocaleCompare("roll",option+1) == 0)
5451 if (i == (ssize_t) argc)
5452 ThrowMogrifyException(OptionError,"MissingArgument",option);
5453 if (IsGeometry(argv[i]) == MagickFalse)
5454 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5457 if (LocaleCompare("rotate",option+1) == 0)
5460 if (i == (ssize_t) argc)
5461 ThrowMogrifyException(OptionError,"MissingArgument",option);
5462 if (IsGeometry(argv[i]) == MagickFalse)
5463 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5466 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5470 if (LocaleCompare("sample",option+1) == 0)
5475 if (i == (ssize_t) argc)
5476 ThrowMogrifyException(OptionError,"MissingArgument",option);
5477 if (IsGeometry(argv[i]) == MagickFalse)
5478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5481 if (LocaleCompare("sampling-factor",option+1) == 0)
5486 if (i == (ssize_t) argc)
5487 ThrowMogrifyException(OptionError,"MissingArgument",option);
5488 if (IsGeometry(argv[i]) == MagickFalse)
5489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5492 if (LocaleCompare("scale",option+1) == 0)
5497 if (i == (ssize_t) argc)
5498 ThrowMogrifyException(OptionError,"MissingArgument",option);
5499 if (IsGeometry(argv[i]) == MagickFalse)
5500 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5503 if (LocaleCompare("scene",option+1) == 0)
5508 if (i == (ssize_t) argc)
5509 ThrowMogrifyException(OptionError,"MissingArgument",option);
5510 if (IsGeometry(argv[i]) == MagickFalse)
5511 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5514 if (LocaleCompare("seed",option+1) == 0)
5519 if (i == (ssize_t) argc)
5520 ThrowMogrifyException(OptionError,"MissingArgument",option);
5521 if (IsGeometry(argv[i]) == MagickFalse)
5522 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5525 if (LocaleCompare("segment",option+1) == 0)
5530 if (i == (ssize_t) argc)
5531 ThrowMogrifyException(OptionError,"MissingArgument",option);
5532 if (IsGeometry(argv[i]) == MagickFalse)
5533 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5536 if (LocaleCompare("selective-blur",option+1) == 0)
5539 if (i == (ssize_t) argc)
5540 ThrowMogrifyException(OptionError,"MissingArgument",option);
5541 if (IsGeometry(argv[i]) == MagickFalse)
5542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5545 if (LocaleCompare("separate",option+1) == 0)
5547 if (LocaleCompare("sepia-tone",option+1) == 0)
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,"MissingArgument",option);
5554 if (IsGeometry(argv[i]) == MagickFalse)
5555 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5558 if (LocaleCompare("set",option+1) == 0)
5561 if (i == (ssize_t) argc)
5562 ThrowMogrifyException(OptionError,"MissingArgument",option);
5566 if (i == (ssize_t) argc)
5567 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 if (LocaleCompare("shade",option+1) == 0)
5573 if (i == (ssize_t) argc)
5574 ThrowMogrifyException(OptionError,"MissingArgument",option);
5575 if (IsGeometry(argv[i]) == MagickFalse)
5576 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5579 if (LocaleCompare("shadow",option+1) == 0)
5584 if (i == (ssize_t) argc)
5585 ThrowMogrifyException(OptionError,"MissingArgument",option);
5586 if (IsGeometry(argv[i]) == MagickFalse)
5587 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5590 if (LocaleCompare("sharpen",option+1) == 0)
5593 if (i == (ssize_t) argc)
5594 ThrowMogrifyException(OptionError,"MissingArgument",option);
5595 if (IsGeometry(argv[i]) == MagickFalse)
5596 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5599 if (LocaleCompare("shave",option+1) == 0)
5604 if (i == (ssize_t) argc)
5605 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 if (IsGeometry(argv[i]) == MagickFalse)
5607 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5610 if (LocaleCompare("shear",option+1) == 0)
5613 if (i == (ssize_t) argc)
5614 ThrowMogrifyException(OptionError,"MissingArgument",option);
5615 if (IsGeometry(argv[i]) == MagickFalse)
5616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5619 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5622 if (i == (ssize_t) (argc-1))
5623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5624 if (IsGeometry(argv[i]) == MagickFalse)
5625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5628 if (LocaleCompare("size",option+1) == 0)
5633 if (i == (ssize_t) argc)
5634 ThrowMogrifyException(OptionError,"MissingArgument",option);
5635 if (IsGeometry(argv[i]) == MagickFalse)
5636 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5639 if (LocaleCompare("sketch",option+1) == 0)
5644 if (i == (ssize_t) argc)
5645 ThrowMogrifyException(OptionError,"MissingArgument",option);
5646 if (IsGeometry(argv[i]) == MagickFalse)
5647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 if (LocaleCompare("smush",option+1) == 0)
5653 if (i == (ssize_t) argc)
5654 ThrowMogrifyException(OptionError,"MissingArgument",option);
5655 if (IsGeometry(argv[i]) == MagickFalse)
5656 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5660 if (LocaleCompare("solarize",option+1) == 0)
5665 if (i == (ssize_t) argc)
5666 ThrowMogrifyException(OptionError,"MissingArgument",option);
5667 if (IsGeometry(argv[i]) == MagickFalse)
5668 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5671 if (LocaleCompare("sparse-color",option+1) == 0)
5677 if (i == (ssize_t) argc)
5678 ThrowMogrifyException(OptionError,"MissingArgument",option);
5679 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5681 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5684 if (i == (ssize_t) (argc-1))
5685 ThrowMogrifyException(OptionError,"MissingArgument",option);
5688 if (LocaleCompare("spread",option+1) == 0)
5693 if (i == (ssize_t) argc)
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 if (IsGeometry(argv[i]) == MagickFalse)
5696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699 if (LocaleCompare("statistic",option+1) == 0)
5707 if (i == (ssize_t) argc)
5708 ThrowMogrifyException(OptionError,"MissingArgument",option);
5709 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5711 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5714 if (i == (ssize_t) (argc-1))
5715 ThrowMogrifyException(OptionError,"MissingArgument",option);
5716 if (IsGeometry(argv[i]) == MagickFalse)
5717 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5720 if (LocaleCompare("stretch",option+1) == 0)
5728 if (i == (ssize_t) (argc-1))
5729 ThrowMogrifyException(OptionError,"MissingArgument",option);
5730 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5732 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5736 if (LocaleCompare("strip",option+1) == 0)
5738 if (LocaleCompare("stroke",option+1) == 0)
5743 if (i == (ssize_t) argc)
5744 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 if (LocaleCompare("strokewidth",option+1) == 0)
5752 if (i == (ssize_t) argc)
5753 ThrowMogrifyException(OptionError,"MissingArgument",option);
5754 if (IsGeometry(argv[i]) == MagickFalse)
5755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5758 if (LocaleCompare("style",option+1) == 0)
5766 if (i == (ssize_t) (argc-1))
5767 ThrowMogrifyException(OptionError,"MissingArgument",option);
5768 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5770 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5774 if (LocaleCompare("swap",option+1) == 0)
5779 if (i == (ssize_t) (argc-1))
5780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5781 if (IsGeometry(argv[i]) == MagickFalse)
5782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5785 if (LocaleCompare("swirl",option+1) == 0)
5790 if (i == (ssize_t) argc)
5791 ThrowMogrifyException(OptionError,"MissingArgument",option);
5792 if (IsGeometry(argv[i]) == MagickFalse)
5793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5796 if (LocaleCompare("synchronize",option+1) == 0)
5798 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5802 if (LocaleCompare("taint",option+1) == 0)
5804 if (LocaleCompare("texture",option+1) == 0)
5809 if (i == (ssize_t) argc)
5810 ThrowMogrifyException(OptionError,"MissingArgument",option);
5813 if (LocaleCompare("tile",option+1) == 0)
5818 if (i == (ssize_t) (argc-1))
5819 ThrowMogrifyException(OptionError,"MissingArgument",option);
5822 if (LocaleCompare("tile-offset",option+1) == 0)
5827 if (i == (ssize_t) argc)
5828 ThrowMogrifyException(OptionError,"MissingArgument",option);
5829 if (IsGeometry(argv[i]) == MagickFalse)
5830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5833 if (LocaleCompare("tint",option+1) == 0)
5838 if (i == (ssize_t) (argc-1))
5839 ThrowMogrifyException(OptionError,"MissingArgument",option);
5840 if (IsGeometry(argv[i]) == MagickFalse)
5841 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5844 if (LocaleCompare("transform",option+1) == 0)
5846 if (LocaleCompare("transpose",option+1) == 0)
5848 if (LocaleCompare("transverse",option+1) == 0)
5850 if (LocaleCompare("threshold",option+1) == 0)
5855 if (i == (ssize_t) argc)
5856 ThrowMogrifyException(OptionError,"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 if (LocaleCompare("thumbnail",option+1) == 0)
5866 if (i == (ssize_t) argc)
5867 ThrowMogrifyException(OptionError,"MissingArgument",option);
5868 if (IsGeometry(argv[i]) == MagickFalse)
5869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 if (LocaleCompare("transparent",option+1) == 0)
5875 if (i == (ssize_t) argc)
5876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5879 if (LocaleCompare("transparent-color",option+1) == 0)
5884 if (i == (ssize_t) (argc-1))
5885 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 if (LocaleCompare("treedepth",option+1) == 0)
5893 if (i == (ssize_t) argc)
5894 ThrowMogrifyException(OptionError,"MissingArgument",option);
5895 if (IsGeometry(argv[i]) == MagickFalse)
5896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5899 if (LocaleCompare("trim",option+1) == 0)
5901 if (LocaleCompare("type",option+1) == 0)
5909 if (i == (ssize_t) argc)
5910 ThrowMogrifyException(OptionError,"MissingArgument",option);
5911 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5913 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5917 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5921 if (LocaleCompare("undercolor",option+1) == 0)
5926 if (i == (ssize_t) argc)
5927 ThrowMogrifyException(OptionError,"MissingArgument",option);
5930 if (LocaleCompare("unique-colors",option+1) == 0)
5932 if (LocaleCompare("units",option+1) == 0)
5940 if (i == (ssize_t) argc)
5941 ThrowMogrifyException(OptionError,"MissingArgument",option);
5942 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5945 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5949 if (LocaleCompare("unsharp",option+1) == 0)
5952 if (i == (ssize_t) argc)
5953 ThrowMogrifyException(OptionError,"MissingArgument",option);
5954 if (IsGeometry(argv[i]) == MagickFalse)
5955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5958 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5962 if (LocaleCompare("verbose",option+1) == 0)
5964 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5967 if ((LocaleCompare("version",option+1) == 0) ||
5968 (LocaleCompare("-version",option+1) == 0))
5970 (void) FormatLocaleFile(stdout,"Version: %s\n",
5971 GetMagickVersion((size_t *) NULL));
5972 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5973 GetMagickCopyright());
5974 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5975 GetMagickFeatures());
5978 if (LocaleCompare("view",option+1) == 0)
5983 if (i == (ssize_t) argc)
5984 ThrowMogrifyException(OptionError,"MissingArgument",option);
5987 if (LocaleCompare("vignette",option+1) == 0)
5992 if (i == (ssize_t) argc)
5993 ThrowMogrifyException(OptionError,"MissingArgument",option);
5994 if (IsGeometry(argv[i]) == MagickFalse)
5995 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5998 if (LocaleCompare("virtual-pixel",option+1) == 0)
6006 if (i == (ssize_t) argc)
6007 ThrowMogrifyException(OptionError,"MissingArgument",option);
6008 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6011 ThrowMogrifyException(OptionError,
6012 "UnrecognizedVirtualPixelMethod",argv[i]);
6015 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6019 if (LocaleCompare("wave",option+1) == 0)
6022 if (i == (ssize_t) argc)
6023 ThrowMogrifyException(OptionError,"MissingArgument",option);
6024 if (IsGeometry(argv[i]) == MagickFalse)
6025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6028 if (LocaleCompare("weight",option+1) == 0)
6033 if (i == (ssize_t) (argc-1))
6034 ThrowMogrifyException(OptionError,"MissingArgument",option);
6037 if (LocaleCompare("white-point",option+1) == 0)
6042 if (i == (ssize_t) argc)
6043 ThrowMogrifyException(OptionError,"MissingArgument",option);
6044 if (IsGeometry(argv[i]) == MagickFalse)
6045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6048 if (LocaleCompare("white-threshold",option+1) == 0)
6053 if (i == (ssize_t) argc)
6054 ThrowMogrifyException(OptionError,"MissingArgument",option);
6055 if (IsGeometry(argv[i]) == MagickFalse)
6056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6059 if (LocaleCompare("write",option+1) == 0)
6062 if (i == (ssize_t) (argc-1))
6063 ThrowMogrifyException(OptionError,"MissingArgument",option);
6066 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6071 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6073 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6074 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6075 if (fire != MagickFalse)
6076 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6079 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6080 if (i != (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6083 return(status != 0 ? MagickTrue : MagickFalse);
6087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6091 + M o g r i f y I m a g e I n f o %
6095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6097 % MogrifyImageInfo() applies image processing settings to the image as
6098 % prescribed by command line options.
6100 % The format of the MogrifyImageInfo method is:
6102 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6103 % const char **argv,ExceptionInfo *exception)
6105 % A description of each parameter follows:
6107 % o image_info: the image info..
6109 % o argc: Specifies a pointer to an integer describing the number of
6110 % elements in the argument vector.
6112 % o argv: Specifies a pointer to a text array containing the command line
6115 % o exception: return any errors or warnings in this structure.
6118 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6119 const int argc,const char **argv,ExceptionInfo *exception)
6134 Initialize method variables.
6136 assert(image_info != (ImageInfo *) NULL);
6137 assert(image_info->signature == MagickSignature);
6138 if (image_info->debug != MagickFalse)
6139 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6140 image_info->filename);
6144 Set the image settings.
6146 for (i=0; i < (ssize_t) argc; i++)
6149 if (IsCommandOption(option) == MagickFalse)
6151 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6152 count=MagickMax(count,0L);
6153 if ((i+count) >= (ssize_t) argc)
6155 switch (*(option+1))
6159 if (LocaleCompare("adjoin",option+1) == 0)
6161 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6164 if (LocaleCompare("antialias",option+1) == 0)
6166 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6169 if (LocaleCompare("authenticate",option+1) == 0)
6172 (void) DeleteImageOption(image_info,option+1);
6174 (void) SetImageOption(image_info,option+1,argv[i+1]);
6181 if (LocaleCompare("background",option+1) == 0)
6185 (void) DeleteImageOption(image_info,option+1);
6186 (void) QueryColorCompliance(MogrifyBackgroundColor,
6187 AllCompliance,&image_info->background_color,exception);
6190 (void) SetImageOption(image_info,option+1,argv[i+1]);
6191 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6192 &image_info->background_color,exception);
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) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6231 &image_info->border_color,exception);
6234 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6235 &image_info->border_color,exception);
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("colorspace",option+1) == 0)
6289 image_info->colorspace=UndefinedColorspace;
6290 (void) SetImageOption(image_info,option+1,"undefined");
6293 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6294 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6295 (void) SetImageOption(image_info,option+1,argv[i+1]);
6298 if (LocaleCompare("comment",option+1) == 0)
6302 (void) DeleteImageOption(image_info,option+1);
6305 (void) SetImageOption(image_info,option+1,argv[i+1]);
6308 if (LocaleCompare("compose",option+1) == 0)
6312 (void) SetImageOption(image_info,option+1,"undefined");
6315 (void) SetImageOption(image_info,option+1,argv[i+1]);
6318 if (LocaleCompare("compress",option+1) == 0)
6322 image_info->compression=UndefinedCompression;
6323 (void) SetImageOption(image_info,option+1,"undefined");
6326 image_info->compression=(CompressionType) ParseCommandOption(
6327 MagickCompressOptions,MagickFalse,argv[i+1]);
6328 (void) SetImageOption(image_info,option+1,argv[i+1]);
6335 if (LocaleCompare("debug",option+1) == 0)
6338 (void) SetLogEventMask("none");
6340 (void) SetLogEventMask(argv[i+1]);
6341 image_info->debug=IsEventLogging();
6344 if (LocaleCompare("define",option+1) == 0)
6348 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6349 (void) DeleteImageRegistry(argv[i+1]+9);
6351 (void) DeleteImageOption(image_info,argv[i+1]);
6354 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6356 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6360 (void) DefineImageOption(image_info,argv[i+1]);
6363 if (LocaleCompare("delay",option+1) == 0)
6367 (void) SetImageOption(image_info,option+1,"0");
6370 (void) SetImageOption(image_info,option+1,argv[i+1]);
6373 if (LocaleCompare("density",option+1) == 0)
6380 if (image_info->density != (char *) NULL)
6381 image_info->density=DestroyString(image_info->density);
6382 (void) SetImageOption(image_info,option+1,"72");
6385 (void) CloneString(&image_info->density,argv[i+1]);
6386 (void) SetImageOption(image_info,option+1,argv[i+1]);
6389 if (LocaleCompare("depth",option+1) == 0)
6393 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6396 image_info->depth=StringToUnsignedLong(argv[i+1]);
6399 if (LocaleCompare("direction",option+1) == 0)
6403 (void) SetImageOption(image_info,option+1,"undefined");
6406 (void) SetImageOption(image_info,option+1,argv[i+1]);
6409 if (LocaleCompare("display",option+1) == 0)
6413 if (image_info->server_name != (char *) NULL)
6414 image_info->server_name=DestroyString(
6415 image_info->server_name);
6418 (void) CloneString(&image_info->server_name,argv[i+1]);
6421 if (LocaleCompare("dispose",option+1) == 0)
6425 (void) SetImageOption(image_info,option+1,"undefined");
6428 (void) SetImageOption(image_info,option+1,argv[i+1]);
6431 if (LocaleCompare("dither",option+1) == 0)
6435 image_info->dither=MagickFalse;
6436 (void) SetImageOption(image_info,option+1,"none");
6439 (void) SetImageOption(image_info,option+1,argv[i+1]);
6440 image_info->dither=MagickTrue;
6447 if (LocaleCompare("encoding",option+1) == 0)
6451 (void) SetImageOption(image_info,option+1,"undefined");
6454 (void) SetImageOption(image_info,option+1,argv[i+1]);
6457 if (LocaleCompare("endian",option+1) == 0)
6461 image_info->endian=UndefinedEndian;
6462 (void) SetImageOption(image_info,option+1,"undefined");
6465 image_info->endian=(EndianType) ParseCommandOption(
6466 MagickEndianOptions,MagickFalse,argv[i+1]);
6467 (void) SetImageOption(image_info,option+1,argv[i+1]);
6470 if (LocaleCompare("extract",option+1) == 0)
6473 Set image extract geometry.
6477 if (image_info->extract != (char *) NULL)
6478 image_info->extract=DestroyString(image_info->extract);
6481 (void) CloneString(&image_info->extract,argv[i+1]);
6488 if (LocaleCompare("fill",option+1) == 0)
6492 (void) SetImageOption(image_info,option+1,"none");
6495 (void) SetImageOption(image_info,option+1,argv[i+1]);
6498 if (LocaleCompare("filter",option+1) == 0)
6502 (void) SetImageOption(image_info,option+1,"undefined");
6505 (void) SetImageOption(image_info,option+1,argv[i+1]);
6508 if (LocaleCompare("font",option+1) == 0)
6512 if (image_info->font != (char *) NULL)
6513 image_info->font=DestroyString(image_info->font);
6516 (void) CloneString(&image_info->font,argv[i+1]);
6519 if (LocaleCompare("format",option+1) == 0)
6524 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6525 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6526 image_info->ping=MagickFalse;
6527 (void) SetImageOption(image_info,option+1,argv[i+1]);
6530 if (LocaleCompare("fuzz",option+1) == 0)
6534 image_info->fuzz=0.0;
6535 (void) SetImageOption(image_info,option+1,"0");
6538 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6540 (void) SetImageOption(image_info,option+1,argv[i+1]);
6547 if (LocaleCompare("gravity",option+1) == 0)
6551 (void) SetImageOption(image_info,option+1,"undefined");
6554 (void) SetImageOption(image_info,option+1,argv[i+1]);
6557 if (LocaleCompare("green-primary",option+1) == 0)
6561 (void) SetImageOption(image_info,option+1,"0.0");
6564 (void) SetImageOption(image_info,option+1,argv[i+1]);
6571 if (LocaleCompare("intent",option+1) == 0)
6575 (void) SetImageOption(image_info,option+1,"undefined");
6578 (void) SetImageOption(image_info,option+1,argv[i+1]);
6581 if (LocaleCompare("interlace",option+1) == 0)
6585 image_info->interlace=UndefinedInterlace;
6586 (void) SetImageOption(image_info,option+1,"undefined");
6589 image_info->interlace=(InterlaceType) ParseCommandOption(
6590 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6591 (void) SetImageOption(image_info,option+1,argv[i+1]);
6594 if (LocaleCompare("interline-spacing",option+1) == 0)
6598 (void) SetImageOption(image_info,option+1,"undefined");
6601 (void) SetImageOption(image_info,option+1,argv[i+1]);
6604 if (LocaleCompare("interpolate",option+1) == 0)
6608 (void) SetImageOption(image_info,option+1,"undefined");
6611 (void) SetImageOption(image_info,option+1,argv[i+1]);
6614 if (LocaleCompare("interword-spacing",option+1) == 0)
6618 (void) SetImageOption(image_info,option+1,"undefined");
6621 (void) SetImageOption(image_info,option+1,argv[i+1]);
6628 if (LocaleCompare("kerning",option+1) == 0)
6632 (void) SetImageOption(image_info,option+1,"undefined");
6635 (void) SetImageOption(image_info,option+1,argv[i+1]);
6642 if (LocaleCompare("label",option+1) == 0)
6646 (void) DeleteImageOption(image_info,option+1);
6649 (void) SetImageOption(image_info,option+1,argv[i+1]);
6652 if (LocaleCompare("limit",option+1) == 0)
6662 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6663 MagickFalse,argv[i+1]);
6664 limit=MagickResourceInfinity;
6665 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6666 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6667 (void) SetMagickResourceLimit(type,limit);
6670 if (LocaleCompare("list",option+1) == 0)
6676 Display configuration list.
6678 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6681 case MagickCoderOptions:
6683 (void) ListCoderInfo((FILE *) NULL,exception);
6686 case MagickColorOptions:
6688 (void) ListColorInfo((FILE *) NULL,exception);
6691 case MagickConfigureOptions:
6693 (void) ListConfigureInfo((FILE *) NULL,exception);
6696 case MagickDelegateOptions:
6698 (void) ListDelegateInfo((FILE *) NULL,exception);
6701 case MagickFontOptions:
6703 (void) ListTypeInfo((FILE *) NULL,exception);
6706 case MagickFormatOptions:
6708 (void) ListMagickInfo((FILE *) NULL,exception);
6711 case MagickLocaleOptions:
6713 (void) ListLocaleInfo((FILE *) NULL,exception);
6716 case MagickLogOptions:
6718 (void) ListLogInfo((FILE *) NULL,exception);
6721 case MagickMagicOptions:
6723 (void) ListMagicInfo((FILE *) NULL,exception);
6726 case MagickMimeOptions:
6728 (void) ListMimeInfo((FILE *) NULL,exception);
6731 case MagickModuleOptions:
6733 (void) ListModuleInfo((FILE *) NULL,exception);
6736 case MagickPolicyOptions:
6738 (void) ListPolicyInfo((FILE *) NULL,exception);
6741 case MagickResourceOptions:
6743 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6746 case MagickThresholdOptions:
6748 (void) ListThresholdMaps((FILE *) NULL,exception);
6753 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6760 if (LocaleCompare("log",option+1) == 0)
6764 (void) SetLogFormat(argv[i+1]);
6767 if (LocaleCompare("loop",option+1) == 0)
6771 (void) SetImageOption(image_info,option+1,"0");
6774 (void) SetImageOption(image_info,option+1,argv[i+1]);
6781 if (LocaleCompare("matte",option+1) == 0)
6785 (void) SetImageOption(image_info,option+1,"false");
6788 (void) SetImageOption(image_info,option+1,"true");
6791 if (LocaleCompare("mattecolor",option+1) == 0)
6795 (void) SetImageOption(image_info,option+1,argv[i+1]);
6796 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6797 &image_info->matte_color,exception);
6800 (void) SetImageOption(image_info,option+1,argv[i+1]);
6801 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6802 &image_info->matte_color,exception);
6805 if (LocaleCompare("monitor",option+1) == 0)
6807 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6811 if (LocaleCompare("monochrome",option+1) == 0)
6813 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6820 if (LocaleCompare("orient",option+1) == 0)
6824 image_info->orientation=UndefinedOrientation;
6825 (void) SetImageOption(image_info,option+1,"undefined");
6828 image_info->orientation=(OrientationType) ParseCommandOption(
6829 MagickOrientationOptions,MagickFalse,argv[i+1]);
6830 (void) SetImageOption(image_info,option+1,argv[i+1]);
6836 if (LocaleCompare("page",option+1) == 0)
6840 page[MaxTextExtent];
6853 (void) DeleteImageOption(image_info,option+1);
6854 (void) CloneString(&image_info->page,(char *) NULL);
6857 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6858 image_option=GetImageOption(image_info,"page");
6859 if (image_option != (const char *) NULL)
6860 flags=ParseAbsoluteGeometry(image_option,&geometry);
6861 canonical_page=GetPageGeometry(argv[i+1]);
6862 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6863 canonical_page=DestroyString(canonical_page);
6864 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6865 (unsigned long) geometry.width,(unsigned long) geometry.height);
6866 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6867 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6868 (unsigned long) geometry.width,(unsigned long) geometry.height,
6869 (long) geometry.x,(long) geometry.y);
6870 (void) SetImageOption(image_info,option+1,page);
6871 (void) CloneString(&image_info->page,page);
6874 if (LocaleCompare("pen",option+1) == 0)
6878 (void) SetImageOption(image_info,option+1,"none");
6881 (void) SetImageOption(image_info,option+1,argv[i+1]);
6884 if (LocaleCompare("ping",option+1) == 0)
6886 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6889 if (LocaleCompare("pointsize",option+1) == 0)
6892 geometry_info.rho=0.0;
6894 (void) ParseGeometry(argv[i+1],&geometry_info);
6895 image_info->pointsize=geometry_info.rho;
6898 if (LocaleCompare("precision",option+1) == 0)
6900 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6903 if (LocaleCompare("preview",option+1) == 0)
6910 image_info->preview_type=UndefinedPreview;
6913 image_info->preview_type=(PreviewType) ParseCommandOption(
6914 MagickPreviewOptions,MagickFalse,argv[i+1]);
6921 if (LocaleCompare("quality",option+1) == 0)
6924 Set image compression quality.
6928 image_info->quality=UndefinedCompressionQuality;
6929 (void) SetImageOption(image_info,option+1,"0");
6932 image_info->quality=StringToUnsignedLong(argv[i+1]);
6933 (void) SetImageOption(image_info,option+1,argv[i+1]);
6936 if (LocaleCompare("quiet",option+1) == 0)
6938 static WarningHandler
6939 warning_handler = (WarningHandler) NULL;
6944 Restore error or warning messages.
6946 warning_handler=SetWarningHandler(warning_handler);
6950 Suppress error or warning messages.
6952 warning_handler=SetWarningHandler((WarningHandler) NULL);
6959 if (LocaleCompare("red-primary",option+1) == 0)
6963 (void) SetImageOption(image_info,option+1,"0.0");
6966 (void) SetImageOption(image_info,option+1,argv[i+1]);
6973 if (LocaleCompare("sampling-factor",option+1) == 0)
6976 Set image sampling factor.
6980 if (image_info->sampling_factor != (char *) NULL)
6981 image_info->sampling_factor=DestroyString(
6982 image_info->sampling_factor);
6985 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6988 if (LocaleCompare("scene",option+1) == 0)
6995 image_info->scene=0;
6996 (void) SetImageOption(image_info,option+1,"0");
6999 image_info->scene=StringToUnsignedLong(argv[i+1]);
7000 (void) SetImageOption(image_info,option+1,argv[i+1]);
7003 if (LocaleCompare("seed",option+1) == 0)
7010 seed=(size_t) time((time_t *) NULL);
7011 SeedPseudoRandomGenerator(seed);
7014 seed=StringToUnsignedLong(argv[i+1]);
7015 SeedPseudoRandomGenerator(seed);
7018 if (LocaleCompare("size",option+1) == 0)
7022 if (image_info->size != (char *) NULL)
7023 image_info->size=DestroyString(image_info->size);
7026 (void) CloneString(&image_info->size,argv[i+1]);
7029 if (LocaleCompare("stroke",option+1) == 0)
7033 (void) SetImageOption(image_info,option+1,"none");
7036 (void) SetImageOption(image_info,option+1,argv[i+1]);
7039 if (LocaleCompare("strokewidth",option+1) == 0)
7043 (void) SetImageOption(image_info,option+1,"0");
7046 (void) SetImageOption(image_info,option+1,argv[i+1]);
7049 if (LocaleCompare("synchronize",option+1) == 0)
7053 image_info->synchronize=MagickFalse;
7056 image_info->synchronize=MagickTrue;
7063 if (LocaleCompare("taint",option+1) == 0)
7067 (void) SetImageOption(image_info,option+1,"false");
7070 (void) SetImageOption(image_info,option+1,"true");
7073 if (LocaleCompare("texture",option+1) == 0)
7077 if (image_info->texture != (char *) NULL)
7078 image_info->texture=DestroyString(image_info->texture);
7081 (void) CloneString(&image_info->texture,argv[i+1]);
7084 if (LocaleCompare("tile-offset",option+1) == 0)
7088 (void) SetImageOption(image_info,option+1,"0");
7091 (void) SetImageOption(image_info,option+1,argv[i+1]);
7094 if (LocaleCompare("transparent-color",option+1) == 0)
7098 (void) QueryColorCompliance("none",AllCompliance,
7099 &image_info->transparent_color,exception);
7100 (void) SetImageOption(image_info,option+1,"none");
7103 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7104 &image_info->transparent_color,exception);
7105 (void) SetImageOption(image_info,option+1,argv[i+1]);
7108 if (LocaleCompare("type",option+1) == 0)
7112 image_info->type=UndefinedType;
7113 (void) SetImageOption(image_info,option+1,"undefined");
7116 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7117 MagickFalse,argv[i+1]);
7118 (void) SetImageOption(image_info,option+1,argv[i+1]);
7125 if (LocaleCompare("undercolor",option+1) == 0)
7129 (void) DeleteImageOption(image_info,option+1);
7132 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 if (LocaleCompare("units",option+1) == 0)
7139 image_info->units=UndefinedResolution;
7140 (void) SetImageOption(image_info,option+1,"undefined");
7143 image_info->units=(ResolutionType) ParseCommandOption(
7144 MagickResolutionOptions,MagickFalse,argv[i+1]);
7145 (void) SetImageOption(image_info,option+1,argv[i+1]);
7152 if (LocaleCompare("verbose",option+1) == 0)
7156 image_info->verbose=MagickFalse;
7159 image_info->verbose=MagickTrue;
7160 image_info->ping=MagickFalse;
7163 if (LocaleCompare("view",option+1) == 0)
7167 if (image_info->view != (char *) NULL)
7168 image_info->view=DestroyString(image_info->view);
7171 (void) CloneString(&image_info->view,argv[i+1]);
7174 if (LocaleCompare("virtual-pixel",option+1) == 0)
7178 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7179 (void) SetImageOption(image_info,option+1,"undefined");
7182 image_info->virtual_pixel_method=(VirtualPixelMethod)
7183 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7185 (void) SetImageOption(image_info,option+1,argv[i+1]);
7192 if (LocaleCompare("white-point",option+1) == 0)
7196 (void) SetImageOption(image_info,option+1,"0.0");
7199 (void) SetImageOption(image_info,option+1,argv[i+1]);
7213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7217 + M o g r i f y I m a g e L i s t %
7221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7223 % MogrifyImageList() applies any command line options that might affect the
7224 % entire image list (e.g. -append, -coalesce, etc.).
7226 % The format of the MogrifyImage method is:
7228 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7229 % const char **argv,Image **images,ExceptionInfo *exception)
7231 % A description of each parameter follows:
7233 % o image_info: the image info..
7235 % o argc: Specifies a pointer to an integer describing the number of
7236 % elements in the argument vector.
7238 % o argv: Specifies a pointer to a text array containing the command line
7241 % o images: pointer to pointer of the first image in image list.
7243 % o exception: return any errors or warnings in this structure.
7246 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7247 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7258 PixelInterpolateMethod
7272 Apply options to the image list.
7274 assert(image_info != (ImageInfo *) NULL);
7275 assert(image_info->signature == MagickSignature);
7276 assert(images != (Image **) NULL);
7277 assert((*images)->previous == (Image *) NULL);
7278 assert((*images)->signature == MagickSignature);
7279 if ((*images)->debug != MagickFalse)
7280 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7281 (*images)->filename);
7282 if ((argc <= 0) || (*argv == (char *) NULL))
7284 interpolate_method=UndefinedInterpolatePixel;
7285 mogrify_info=CloneImageInfo(image_info);
7286 quantize_info=AcquireQuantizeInfo(mogrify_info);
7288 for (i=0; i < (ssize_t) argc; i++)
7290 if (*images == (Image *) NULL)
7293 if (IsCommandOption(option) == MagickFalse)
7295 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7296 count=MagickMax(count,0L);
7297 if ((i+count) >= (ssize_t) argc)
7299 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7300 switch (*(option+1))
7304 if (LocaleCompare("affinity",option+1) == 0)
7306 (void) SyncImagesSettings(mogrify_info,*images);
7309 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7316 if (LocaleCompare("append",option+1) == 0)
7321 (void) SyncImagesSettings(mogrify_info,*images);
7322 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7323 MagickFalse,exception);
7324 if (append_image == (Image *) NULL)
7329 *images=DestroyImageList(*images);
7330 *images=append_image;
7333 if (LocaleCompare("average",option+1) == 0)
7339 Average an image sequence (deprecated).
7341 (void) SyncImagesSettings(mogrify_info,*images);
7342 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7344 if (average_image == (Image *) NULL)
7349 *images=DestroyImageList(*images);
7350 *images=average_image;
7357 if (LocaleCompare("channel",option+1) == 0)
7364 channel=DefaultChannels;
7367 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7368 SetPixelChannelMap(*images,channel);
7371 if (LocaleCompare("clut",option+1) == 0)
7377 (void) SyncImagesSettings(mogrify_info,*images);
7378 image=RemoveFirstImageFromList(images);
7379 clut_image=RemoveFirstImageFromList(images);
7380 if (clut_image == (Image *) NULL)
7385 (void) ClutImage(image,clut_image,interpolate_method,exception);
7386 clut_image=DestroyImage(clut_image);
7387 *images=DestroyImageList(*images);
7391 if (LocaleCompare("coalesce",option+1) == 0)
7396 (void) SyncImagesSettings(mogrify_info,*images);
7397 coalesce_image=CoalesceImages(*images,exception);
7398 if (coalesce_image == (Image *) NULL)
7403 *images=DestroyImageList(*images);
7404 *images=coalesce_image;
7407 if (LocaleCompare("combine",option+1) == 0)
7412 (void) SyncImagesSettings(mogrify_info,*images);
7413 combine_image=CombineImages(*images,exception);
7414 if (combine_image == (Image *) NULL)
7419 *images=DestroyImageList(*images);
7420 *images=combine_image;
7423 if (LocaleCompare("composite",option+1) == 0)
7433 (void) SyncImagesSettings(mogrify_info,*images);
7434 image=RemoveFirstImageFromList(images);
7435 composite_image=RemoveFirstImageFromList(images);
7436 if (composite_image == (Image *) NULL)
7441 (void) TransformImage(&composite_image,(char *) NULL,
7442 composite_image->geometry,exception);
7443 SetGeometry(composite_image,&geometry);
7444 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7445 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7447 mask_image=RemoveFirstImageFromList(images);
7448 if (mask_image != (Image *) NULL)
7450 if ((image->compose == DisplaceCompositeOp) ||
7451 (image->compose == DistortCompositeOp))
7454 Merge Y displacement into X displacement image.
7456 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7457 mask_image,0,0,exception);
7458 mask_image=DestroyImage(mask_image);
7463 Set a blending mask for the composition.
7464 Posible error, what if image->mask already set.
7466 image->mask=mask_image;
7467 (void) NegateImage(image->mask,MagickFalse,exception);
7470 (void) CompositeImage(image,image->compose,composite_image,
7471 geometry.x,geometry.y,exception);
7472 if (mask_image != (Image *) NULL)
7473 mask_image=image->mask=DestroyImage(image->mask);
7474 composite_image=DestroyImage(composite_image);
7475 InheritException(exception,&image->exception);
7476 *images=DestroyImageList(*images);
7484 if (LocaleCompare("deconstruct",option+1) == 0)
7489 (void) SyncImagesSettings(mogrify_info,*images);
7490 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7492 if (deconstruct_image == (Image *) NULL)
7497 *images=DestroyImageList(*images);
7498 *images=deconstruct_image;
7501 if (LocaleCompare("delete",option+1) == 0)
7504 DeleteImages(images,"-1",exception);
7506 DeleteImages(images,argv[i+1],exception);
7509 if (LocaleCompare("dither",option+1) == 0)
7513 quantize_info->dither=MagickFalse;
7516 quantize_info->dither=MagickTrue;
7517 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7518 MagickDitherOptions,MagickFalse,argv[i+1]);
7521 if (LocaleCompare("duplicate",option+1) == 0)
7527 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7536 number_duplicates=(size_t) StringToLong(argv[i+1]);
7537 p=strchr(argv[i+1],',');
7538 if (p == (const char *) NULL)
7539 duplicate_images=DuplicateImages(*images,number_duplicates,
7542 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7545 AppendImageToList(images, duplicate_images);
7546 (void) SyncImagesSettings(mogrify_info,*images);
7553 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7558 MagickEvaluateOperator
7561 (void) SyncImageSettings(mogrify_info,*images);
7562 op=(MagickEvaluateOperator) ParseCommandOption(
7563 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7564 evaluate_image=EvaluateImages(*images,op,exception);
7565 if (evaluate_image == (Image *) NULL)
7570 *images=DestroyImageList(*images);
7571 *images=evaluate_image;
7578 if (LocaleCompare("fft",option+1) == 0)
7584 Implements the discrete Fourier transform (DFT).
7586 (void) SyncImageSettings(mogrify_info,*images);
7587 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7588 MagickTrue : MagickFalse,exception);
7589 if (fourier_image == (Image *) NULL)
7591 *images=DestroyImage(*images);
7592 *images=fourier_image;
7595 if (LocaleCompare("flatten",option+1) == 0)
7600 (void) SyncImagesSettings(mogrify_info,*images);
7601 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7602 if (flatten_image == (Image *) NULL)
7604 *images=DestroyImageList(*images);
7605 *images=flatten_image;
7608 if (LocaleCompare("fx",option+1) == 0)
7613 (void) SyncImagesSettings(mogrify_info,*images);
7614 fx_image=FxImage(*images,argv[i+1],exception);
7615 if (fx_image == (Image *) NULL)
7620 *images=DestroyImageList(*images);
7628 if (LocaleCompare("hald-clut",option+1) == 0)
7634 (void) SyncImagesSettings(mogrify_info,*images);
7635 image=RemoveFirstImageFromList(images);
7636 hald_image=RemoveFirstImageFromList(images);
7637 if (hald_image == (Image *) NULL)
7642 (void) HaldClutImage(image,hald_image,exception);
7643 hald_image=DestroyImage(hald_image);
7644 if (*images != (Image *) NULL)
7645 *images=DestroyImageList(*images);
7653 if (LocaleCompare("ift",option+1) == 0)
7661 Implements the inverse fourier discrete Fourier transform (DFT).
7663 (void) SyncImagesSettings(mogrify_info,*images);
7664 magnitude_image=RemoveFirstImageFromList(images);
7665 phase_image=RemoveFirstImageFromList(images);
7666 if (phase_image == (Image *) NULL)
7671 fourier_image=InverseFourierTransformImage(magnitude_image,
7672 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7673 if (fourier_image == (Image *) NULL)
7675 if (*images != (Image *) NULL)
7676 *images=DestroyImage(*images);
7677 *images=fourier_image;
7680 if (LocaleCompare("insert",option+1) == 0)
7688 index=(ssize_t) StringToLong(argv[i+1]);
7689 p=RemoveLastImageFromList(images);
7690 if (p == (Image *) NULL)
7692 (void) ThrowMagickException(exception,GetMagickModule(),
7693 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7699 PrependImageToList(images,q);
7701 if (index == (ssize_t) GetImageListLength(*images))
7702 AppendImageToList(images,q);
7705 q=GetImageFromList(*images,index-1);
7706 if (q == (Image *) NULL)
7708 (void) ThrowMagickException(exception,GetMagickModule(),
7709 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7713 InsertImageInList(&q,p);
7715 *images=GetFirstImageInList(q);
7718 if (LocaleCompare("interpolate",option+1) == 0)
7720 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7721 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7728 if (LocaleCompare("layers",option+1) == 0)
7736 (void) SyncImagesSettings(mogrify_info,*images);
7737 layers=(Image *) NULL;
7738 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7739 MagickFalse,argv[i+1]);
7744 layers=CoalesceImages(*images,exception);
7747 case CompareAnyLayer:
7748 case CompareClearLayer:
7749 case CompareOverlayLayer:
7752 layers=CompareImagesLayers(*images,method,exception);
7758 case TrimBoundsLayer:
7760 layers=MergeImageLayers(*images,method,exception);
7765 layers=DisposeImages(*images,exception);
7768 case OptimizeImageLayer:
7770 layers=OptimizeImageLayers(*images,exception);
7773 case OptimizePlusLayer:
7775 layers=OptimizePlusImageLayers(*images,exception);
7778 case OptimizeTransLayer:
7780 OptimizeImageTransparency(*images,exception);
7783 case RemoveDupsLayer:
7785 RemoveDuplicateLayers(images,exception);
7788 case RemoveZeroLayer:
7790 RemoveZeroDelayLayers(images,exception);
7796 General Purpose, GIF Animation Optimizer.
7798 layers=CoalesceImages(*images,exception);
7799 if (layers == (Image *) NULL)
7804 *images=DestroyImageList(*images);
7806 layers=OptimizeImageLayers(*images,exception);
7807 if (layers == (Image *) NULL)
7812 *images=DestroyImageList(*images);
7814 layers=(Image *) NULL;
7815 OptimizeImageTransparency(*images,exception);
7816 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7820 case CompositeLayer:
7832 Split image sequence at the first 'NULL:' image.
7835 while (source != (Image *) NULL)
7837 source=GetNextImageInList(source);
7838 if ((source != (Image *) NULL) &&
7839 (LocaleCompare(source->magick,"NULL") == 0))
7842 if (source != (Image *) NULL)
7844 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7845 (GetNextImageInList(source) == (Image *) NULL))
7846 source=(Image *) NULL;
7850 Separate the two lists, junk the null: image.
7852 source=SplitImageList(source->previous);
7853 DeleteImageFromList(&source);
7856 if (source == (Image *) NULL)
7858 (void) ThrowMagickException(exception,GetMagickModule(),
7859 OptionError,"MissingNullSeparator","layers Composite");
7864 Adjust offset with gravity and virtual canvas.
7866 SetGeometry(*images,&geometry);
7867 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7868 geometry.width=source->page.width != 0 ?
7869 source->page.width : source->columns;
7870 geometry.height=source->page.height != 0 ?
7871 source->page.height : source->rows;
7872 GravityAdjustGeometry((*images)->page.width != 0 ?
7873 (*images)->page.width : (*images)->columns,
7874 (*images)->page.height != 0 ? (*images)->page.height :
7875 (*images)->rows,(*images)->gravity,&geometry);
7876 compose=OverCompositeOp;
7877 option=GetImageOption(mogrify_info,"compose");
7878 if (option != (const char *) NULL)
7879 compose=(CompositeOperator) ParseCommandOption(
7880 MagickComposeOptions,MagickFalse,option);
7881 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7883 source=DestroyImageList(source);
7887 if (layers == (Image *) NULL)
7889 InheritException(exception,&layers->exception);
7890 *images=DestroyImageList(*images);
7898 if (LocaleCompare("map",option+1) == 0)
7900 (void) SyncImagesSettings(mogrify_info,*images);
7903 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7910 if (LocaleCompare("maximum",option+1) == 0)
7916 Maximum image sequence (deprecated).
7918 (void) SyncImagesSettings(mogrify_info,*images);
7919 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7920 if (maximum_image == (Image *) NULL)
7925 *images=DestroyImageList(*images);
7926 *images=maximum_image;
7929 if (LocaleCompare("minimum",option+1) == 0)
7935 Minimum image sequence (deprecated).
7937 (void) SyncImagesSettings(mogrify_info,*images);
7938 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7939 if (minimum_image == (Image *) NULL)
7944 *images=DestroyImageList(*images);
7945 *images=minimum_image;
7948 if (LocaleCompare("morph",option+1) == 0)
7953 (void) SyncImagesSettings(mogrify_info,*images);
7954 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7956 if (morph_image == (Image *) NULL)
7961 *images=DestroyImageList(*images);
7962 *images=morph_image;
7965 if (LocaleCompare("mosaic",option+1) == 0)
7970 (void) SyncImagesSettings(mogrify_info,*images);
7971 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7972 if (mosaic_image == (Image *) NULL)
7977 *images=DestroyImageList(*images);
7978 *images=mosaic_image;
7985 if (LocaleCompare("print",option+1) == 0)
7990 (void) SyncImagesSettings(mogrify_info,*images);
7991 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7993 if (string == (char *) NULL)
7995 (void) FormatLocaleFile(stdout,"%s",string);
7996 string=DestroyString(string);
7998 if (LocaleCompare("process",option+1) == 0)
8007 (void) SyncImagesSettings(mogrify_info,*images);
8008 arguments=StringToArgv(argv[i+1],&number_arguments);
8009 if (arguments == (char **) NULL)
8011 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8032 Support old style syntax, filter="-option arg".
8034 length=strlen(argv[i+1]);
8035 token=(char *) NULL;
8036 if (~length >= (MaxTextExtent-1))
8037 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8039 if (token == (char *) NULL)
8042 arguments=argv[i+1];
8043 token_info=AcquireTokenInfo();
8044 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8045 "\"",'\0',&breaker,&next,"e);
8046 token_info=DestroyTokenInfo(token_info);
8052 argv=(&(arguments[next]));
8053 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8056 token=DestroyString(token);
8059 (void) SubstituteString(&arguments[1],"-","");
8060 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8061 number_arguments-2,(const char **) arguments+2,exception);
8062 for (j=0; j < number_arguments; j++)
8063 arguments[j]=DestroyString(arguments[j]);
8064 arguments=(char **) RelinquishMagickMemory(arguments);
8071 if (LocaleCompare("reverse",option+1) == 0)
8073 ReverseImageList(images);
8074 InheritException(exception,&(*images)->exception);
8081 if (LocaleCompare("smush",option+1) == 0)
8089 (void) SyncImagesSettings(mogrify_info,*images);
8090 offset=(ssize_t) StringToLong(argv[i+1]);
8091 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8092 MagickFalse,offset,exception);
8093 if (smush_image == (Image *) NULL)
8098 *images=DestroyImageList(*images);
8099 *images=smush_image;
8102 if (LocaleCompare("swap",option+1) == 0)
8123 flags=ParseGeometry(argv[i+1],&geometry_info);
8124 index=(ssize_t) geometry_info.rho;
8125 if ((flags & SigmaValue) != 0)
8126 swap_index=(ssize_t) geometry_info.sigma;
8128 p=GetImageFromList(*images,index);
8129 q=GetImageFromList(*images,swap_index);
8130 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8132 (void) ThrowMagickException(exception,GetMagickModule(),
8133 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8139 swap=CloneImage(p,0,0,MagickTrue,exception);
8140 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8141 ReplaceImageInList(&q,swap);
8142 *images=GetFirstImageInList(q);
8149 if (LocaleCompare("write",option+1) == 0)
8160 (void) SyncImagesSettings(mogrify_info,*images);
8161 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8162 (void) DeleteImageRegistry(key);
8163 write_images=(*images);
8165 write_images=CloneImageList(*images,exception);
8166 write_info=CloneImageInfo(mogrify_info);
8167 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8168 write_info=DestroyImageInfo(write_info);
8170 write_images=DestroyImageList(write_images);
8180 quantize_info=DestroyQuantizeInfo(quantize_info);
8181 mogrify_info=DestroyImageInfo(mogrify_info);
8182 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8183 return(status != 0 ? MagickTrue : MagickFalse);
8187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8191 + M o g r i f y I m a g e s %
8195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8197 % MogrifyImages() applies image processing options to a sequence of images as
8198 % prescribed by command line options.
8200 % The format of the MogrifyImage method is:
8202 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8203 % const MagickBooleanType post,const int argc,const char **argv,
8204 % Image **images,Exceptioninfo *exception)
8206 % A description of each parameter follows:
8208 % o image_info: the image info..
8210 % o post: If true, post process image list operators otherwise pre-process.
8212 % o argc: Specifies a pointer to an integer describing the number of
8213 % elements in the argument vector.
8215 % o argv: Specifies a pointer to a text array containing the command line
8218 % o images: pointer to a pointer of the first image in image list.
8220 % o exception: return any errors or warnings in this structure.
8223 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8224 const MagickBooleanType post,const int argc,const char **argv,
8225 Image **images,ExceptionInfo *exception)
8227 #define MogrifyImageTag "Mogrify/Image"
8241 assert(image_info != (ImageInfo *) NULL);
8242 assert(image_info->signature == MagickSignature);
8243 if (images == (Image **) NULL)
8244 return(MogrifyImage(image_info,argc,argv,images,exception));
8245 assert((*images)->previous == (Image *) NULL);
8246 assert((*images)->signature == MagickSignature);
8247 if ((*images)->debug != MagickFalse)
8248 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8249 (*images)->filename);
8250 if ((argc <= 0) || (*argv == (char *) NULL))
8252 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8257 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8262 Pre-process multi-image sequence operators
8264 if (post == MagickFalse)
8265 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8267 For each image, process simple single image operators
8270 n=GetImageListLength(*images);
8274 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8275 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8277 status&=MogrifyImage(image_info,argc,argv,images,exception);
8278 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8279 if (proceed == MagickFalse)
8281 if ( (*images)->next == (Image *) NULL )
8283 *images=(*images)->next;
8286 assert( *images != (Image *) NULL );
8288 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8289 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8293 Post-process, multi-image sequence operators
8295 *images=GetFirstImageInList(*images);
8296 if (post != MagickFalse)
8297 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8298 return(status != 0 ? MagickTrue : MagickFalse);