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/thread-private.h"
55 #include "MagickCore/string-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) QueryMagickColorCompliance(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)
649 PixelInterpolateMethod
663 Initialize method variables.
665 assert(image_info != (const ImageInfo *) NULL);
666 assert(image_info->signature == MagickSignature);
667 assert(image != (Image **) NULL);
668 assert((*image)->signature == MagickSignature);
669 if ((*image)->debug != MagickFalse)
670 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
673 mogrify_info=CloneImageInfo(image_info);
674 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
675 quantize_info=AcquireQuantizeInfo(mogrify_info);
676 SetGeometryInfo(&geometry_info);
677 GetPixelInfo(*image,&fill);
678 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
679 compose=(*image)->compose;
680 interpolate_method=UndefinedInterpolatePixel;
681 channel=mogrify_info->channel;
682 format=GetImageOption(mogrify_info,"format");
683 SetGeometry(*image,®ion_geometry);
684 region_image=NewImageList();
686 Transmogrify the image.
688 for (i=0; i < (ssize_t) argc; i++)
697 if (IsCommandOption(option) == MagickFalse)
699 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
701 if ((i+count) >= (ssize_t) argc)
703 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
704 mogrify_image=(Image *)NULL;
709 if (LocaleCompare("adaptive-blur",option+1) == 0)
714 (void) SyncImageSettings(mogrify_info,*image);
715 flags=ParseGeometry(argv[i+1],&geometry_info);
716 if ((flags & SigmaValue) == 0)
717 geometry_info.sigma=1.0;
718 if ((flags & XiValue) == 0)
719 geometry_info.xi=0.0;
720 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
721 geometry_info.sigma,geometry_info.xi,exception);
724 if (LocaleCompare("adaptive-resize",option+1) == 0)
727 Adaptive resize image.
729 (void) SyncImageSettings(mogrify_info,*image);
730 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
731 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
732 geometry.height,interpolate_method,exception);
735 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
738 Adaptive sharpen image.
740 (void) SyncImageSettings(mogrify_info,*image);
741 flags=ParseGeometry(argv[i+1],&geometry_info);
742 if ((flags & SigmaValue) == 0)
743 geometry_info.sigma=1.0;
744 if ((flags & XiValue) == 0)
745 geometry_info.xi=0.0;
746 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
747 geometry_info.sigma,geometry_info.xi,exception);
750 if (LocaleCompare("affine",option+1) == 0)
757 GetAffineMatrix(&draw_info->affine);
760 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
763 if (LocaleCompare("alpha",option+1) == 0)
768 (void) SyncImageSettings(mogrify_info,*image);
769 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
770 MagickFalse,argv[i+1]);
771 (void) SetImageAlphaChannel(*image,alpha_type,exception);
774 if (LocaleCompare("annotate",option+1) == 0)
778 geometry[MaxTextExtent];
783 (void) SyncImageSettings(mogrify_info,*image);
784 SetGeometryInfo(&geometry_info);
785 flags=ParseGeometry(argv[i+1],&geometry_info);
786 if ((flags & SigmaValue) == 0)
787 geometry_info.sigma=geometry_info.rho;
788 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
790 if (text == (char *) NULL)
792 (void) CloneString(&draw_info->text,text);
793 text=DestroyString(text);
794 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
795 geometry_info.xi,geometry_info.psi);
796 (void) CloneString(&draw_info->geometry,geometry);
797 draw_info->affine.sx=cos(DegreesToRadians(
798 fmod(geometry_info.rho,360.0)));
799 draw_info->affine.rx=sin(DegreesToRadians(
800 fmod(geometry_info.rho,360.0)));
801 draw_info->affine.ry=(-sin(DegreesToRadians(
802 fmod(geometry_info.sigma,360.0))));
803 draw_info->affine.sy=cos(DegreesToRadians(
804 fmod(geometry_info.sigma,360.0)));
805 (void) AnnotateImage(*image,draw_info,exception);
808 if (LocaleCompare("antialias",option+1) == 0)
810 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
812 draw_info->text_antialias=(*option == '-') ? MagickTrue :
816 if (LocaleCompare("auto-gamma",option+1) == 0)
819 Auto Adjust Gamma of image based on its mean
821 (void) SyncImageSettings(mogrify_info,*image);
822 (void) AutoGammaImage(*image,exception);
825 if (LocaleCompare("auto-level",option+1) == 0)
828 Perfectly Normalize (max/min stretch) the image
830 (void) SyncImageSettings(mogrify_info,*image);
831 (void) AutoLevelImage(*image,exception);
834 if (LocaleCompare("auto-orient",option+1) == 0)
836 (void) SyncImageSettings(mogrify_info,*image);
837 switch ((*image)->orientation)
839 case TopRightOrientation:
841 mogrify_image=FlopImage(*image,exception);
844 case BottomRightOrientation:
846 mogrify_image=RotateImage(*image,180.0,exception);
849 case BottomLeftOrientation:
851 mogrify_image=FlipImage(*image,exception);
854 case LeftTopOrientation:
856 mogrify_image=TransposeImage(*image,exception);
859 case RightTopOrientation:
861 mogrify_image=RotateImage(*image,90.0,exception);
864 case RightBottomOrientation:
866 mogrify_image=TransverseImage(*image,exception);
869 case LeftBottomOrientation:
871 mogrify_image=RotateImage(*image,270.0,exception);
877 if (mogrify_image != (Image *) NULL)
878 mogrify_image->orientation=TopLeftOrientation;
885 if (LocaleCompare("black-threshold",option+1) == 0)
888 Black threshold image.
890 (void) SyncImageSettings(mogrify_info,*image);
891 (void) BlackThresholdImage(*image,argv[i+1],exception);
892 InheritException(exception,&(*image)->exception);
895 if (LocaleCompare("blue-shift",option+1) == 0)
900 (void) SyncImageSettings(mogrify_info,*image);
901 geometry_info.rho=1.5;
903 flags=ParseGeometry(argv[i+1],&geometry_info);
904 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
907 if (LocaleCompare("blur",option+1) == 0)
912 (void) SyncImageSettings(mogrify_info,*image);
913 flags=ParseGeometry(argv[i+1],&geometry_info);
914 if ((flags & SigmaValue) == 0)
915 geometry_info.sigma=1.0;
916 if ((flags & XiValue) == 0)
917 geometry_info.xi=0.0;
918 mogrify_image=BlurImage(*image,geometry_info.rho,
919 geometry_info.sigma,geometry_info.xi,exception);
922 if (LocaleCompare("border",option+1) == 0)
925 Surround image with a border of solid color.
927 (void) SyncImageSettings(mogrify_info,*image);
928 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
929 if ((flags & SigmaValue) == 0)
930 geometry.height=geometry.width;
931 mogrify_image=BorderImage(*image,&geometry,compose,exception);
934 if (LocaleCompare("bordercolor",option+1) == 0)
938 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
939 &draw_info->border_color,exception);
942 (void) QueryColorCompliance(argv[i+1],AllCompliance,
943 &draw_info->border_color,exception);
946 if (LocaleCompare("box",option+1) == 0)
948 (void) QueryColorCompliance(argv[i+1],AllCompliance,
949 &draw_info->undercolor,exception);
952 if (LocaleCompare("brightness-contrast",option+1) == 0)
965 Brightness / contrast image.
967 (void) SyncImageSettings(mogrify_info,*image);
968 flags=ParseGeometry(argv[i+1],&geometry_info);
969 brightness=geometry_info.rho;
971 if ((flags & SigmaValue) != 0)
972 contrast=geometry_info.sigma;
973 (void) BrightnessContrastImage(*image,brightness,contrast,
975 InheritException(exception,&(*image)->exception);
982 if (LocaleCompare("cdl",option+1) == 0)
985 *color_correction_collection;
988 Color correct with a color decision list.
990 (void) SyncImageSettings(mogrify_info,*image);
991 color_correction_collection=FileToString(argv[i+1],~0,exception);
992 if (color_correction_collection == (char *) NULL)
994 (void) ColorDecisionListImage(*image,color_correction_collection,
996 InheritException(exception,&(*image)->exception);
999 if (LocaleCompare("channel",option+1) == 0)
1002 channel=DefaultChannels;
1004 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1005 SetPixelChannelMap(*image,channel);
1008 if (LocaleCompare("charcoal",option+1) == 0)
1013 (void) SyncImageSettings(mogrify_info,*image);
1014 flags=ParseGeometry(argv[i+1],&geometry_info);
1015 if ((flags & SigmaValue) == 0)
1016 geometry_info.sigma=1.0;
1017 if ((flags & XiValue) == 0)
1018 geometry_info.xi=1.0;
1019 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1020 geometry_info.sigma,geometry_info.xi,exception);
1023 if (LocaleCompare("chop",option+1) == 0)
1028 (void) SyncImageSettings(mogrify_info,*image);
1029 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1030 mogrify_image=ChopImage(*image,&geometry,exception);
1033 if (LocaleCompare("clamp",option+1) == 0)
1038 (void) SyncImageSettings(mogrify_info,*image);
1039 (void) ClampImage(*image);
1040 InheritException(exception,&(*image)->exception);
1043 if (LocaleCompare("clip",option+1) == 0)
1045 (void) SyncImageSettings(mogrify_info,*image);
1048 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1051 (void) ClipImage(*image,exception);
1054 if (LocaleCompare("clip-mask",option+1) == 0)
1071 (void) SyncImageSettings(mogrify_info,*image);
1077 (void) SetImageMask(*image,(Image *) NULL,exception);
1082 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1084 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1085 if (mask_image == (Image *) NULL)
1087 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1088 return(MagickFalse);
1089 mask_view=AcquireCacheView(mask_image);
1090 for (y=0; y < (ssize_t) mask_image->rows; y++)
1092 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1094 if (q == (Quantum *) NULL)
1096 for (x=0; x < (ssize_t) mask_image->columns; x++)
1098 if (mask_image->matte == MagickFalse)
1099 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1100 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1101 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1102 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1103 q+=GetPixelChannels(mask_image);
1105 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1108 mask_view=DestroyCacheView(mask_view);
1109 mask_image->matte=MagickTrue;
1110 (void) SetImageClipMask(*image,mask_image,exception);
1111 InheritException(exception,&(*image)->exception);
1114 if (LocaleCompare("clip-path",option+1) == 0)
1116 (void) SyncImageSettings(mogrify_info,*image);
1117 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1118 MagickFalse,exception);
1121 if (LocaleCompare("colorize",option+1) == 0)
1126 (void) SyncImageSettings(mogrify_info,*image);
1127 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1130 if (LocaleCompare("color-matrix",option+1) == 0)
1135 (void) SyncImageSettings(mogrify_info,*image);
1136 kernel=AcquireKernelInfo(argv[i+1]);
1137 if (kernel == (KernelInfo *) NULL)
1139 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1140 kernel=DestroyKernelInfo(kernel);
1143 if (LocaleCompare("colors",option+1) == 0)
1146 Reduce the number of colors in the image.
1148 (void) SyncImageSettings(mogrify_info,*image);
1149 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1150 if (quantize_info->number_colors == 0)
1152 if (((*image)->storage_class == DirectClass) ||
1153 (*image)->colors > quantize_info->number_colors)
1154 (void) QuantizeImage(quantize_info,*image,exception);
1156 (void) CompressImageColormap(*image,exception);
1159 if (LocaleCompare("colorspace",option+1) == 0)
1164 (void) SyncImageSettings(mogrify_info,*image);
1167 (void) TransformImageColorspace(*image,RGBColorspace);
1168 InheritException(exception,&(*image)->exception);
1171 colorspace=(ColorspaceType) ParseCommandOption(
1172 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1173 (void) TransformImageColorspace(*image,colorspace);
1174 InheritException(exception,&(*image)->exception);
1177 if (LocaleCompare("compose",option+1) == 0)
1179 (void) SyncImageSettings(mogrify_info,*image);
1180 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1181 MagickFalse,argv[i+1]);
1184 if (LocaleCompare("contrast",option+1) == 0)
1186 (void) SyncImageSettings(mogrify_info,*image);
1187 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1188 MagickFalse,exception);
1191 if (LocaleCompare("contrast-stretch",option+1) == 0)
1201 Contrast stretch image.
1203 (void) SyncImageSettings(mogrify_info,*image);
1204 flags=ParseGeometry(argv[i+1],&geometry_info);
1205 black_point=geometry_info.rho;
1206 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1208 if ((flags & PercentValue) != 0)
1210 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1211 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1213 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1215 (void) ContrastStretchImage(*image,black_point,white_point,
1217 InheritException(exception,&(*image)->exception);
1220 if (LocaleCompare("convolve",option+1) == 0)
1225 (void) SyncImageSettings(mogrify_info,*image);
1226 kernel_info=AcquireKernelInfo(argv[i+1]);
1227 if (kernel_info == (KernelInfo *) NULL)
1229 kernel_info->bias=(*image)->bias;
1230 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1231 kernel_info=DestroyKernelInfo(kernel_info);
1234 if (LocaleCompare("crop",option+1) == 0)
1237 Crop a image to a smaller size
1239 (void) SyncImageSettings(mogrify_info,*image);
1240 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1243 if (LocaleCompare("cycle",option+1) == 0)
1246 Cycle an image colormap.
1248 (void) SyncImageSettings(mogrify_info,*image);
1249 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1257 if (LocaleCompare("decipher",option+1) == 0)
1265 (void) SyncImageSettings(mogrify_info,*image);
1266 passkey=FileToStringInfo(argv[i+1],~0,exception);
1267 if (passkey != (StringInfo *) NULL)
1269 (void) PasskeyDecipherImage(*image,passkey,exception);
1270 passkey=DestroyStringInfo(passkey);
1274 if (LocaleCompare("density",option+1) == 0)
1279 (void) CloneString(&draw_info->density,argv[i+1]);
1282 if (LocaleCompare("depth",option+1) == 0)
1284 (void) SyncImageSettings(mogrify_info,*image);
1287 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1290 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1293 if (LocaleCompare("deskew",option+1) == 0)
1299 Straighten the image.
1301 (void) SyncImageSettings(mogrify_info,*image);
1303 threshold=40.0*QuantumRange/100.0;
1305 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1306 mogrify_image=DeskewImage(*image,threshold,exception);
1309 if (LocaleCompare("despeckle",option+1) == 0)
1312 Reduce the speckles within an image.
1314 (void) SyncImageSettings(mogrify_info,*image);
1315 mogrify_image=DespeckleImage(*image,exception);
1318 if (LocaleCompare("display",option+1) == 0)
1320 (void) CloneString(&draw_info->server_name,argv[i+1]);
1323 if (LocaleCompare("distort",option+1) == 0)
1327 token[MaxTextExtent];
1347 (void) SyncImageSettings(mogrify_info,*image);
1348 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1349 MagickFalse,argv[i+1]);
1350 if ( method == ResizeDistortion )
1352 /* Special Case - Argument is actually a resize geometry!
1353 ** Convert that to an appropriate distortion argument array.
1357 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1359 resize_args[0]=(double)geometry.width;
1360 resize_args[1]=(double)geometry.height;
1361 mogrify_image=DistortImage(*image,method,(size_t)2,
1362 resize_args,MagickTrue,exception);
1365 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1367 if (args == (char *) NULL)
1370 for (x=0; *p != '\0'; x++)
1372 GetMagickToken(p,&p,token);
1374 GetMagickToken(p,&p,token);
1376 number_arguments=(size_t) x;
1377 arguments=(double *) AcquireQuantumMemory(number_arguments,
1378 sizeof(*arguments));
1379 if (arguments == (double *) NULL)
1380 ThrowWandFatalException(ResourceLimitFatalError,
1381 "MemoryAllocationFailed",(*image)->filename);
1382 (void) ResetMagickMemory(arguments,0,number_arguments*
1383 sizeof(*arguments));
1385 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1387 GetMagickToken(p,&p,token);
1389 GetMagickToken(p,&p,token);
1390 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1392 args=DestroyString(args);
1393 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1394 (*option == '+') ? MagickTrue : MagickFalse,exception);
1395 arguments=(double *) RelinquishMagickMemory(arguments);
1398 if (LocaleCompare("dither",option+1) == 0)
1402 quantize_info->dither=MagickFalse;
1405 quantize_info->dither=MagickTrue;
1406 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1407 MagickDitherOptions,MagickFalse,argv[i+1]);
1408 if (quantize_info->dither_method == NoDitherMethod)
1409 quantize_info->dither=MagickFalse;
1412 if (LocaleCompare("draw",option+1) == 0)
1417 (void) SyncImageSettings(mogrify_info,*image);
1418 (void) CloneString(&draw_info->primitive,argv[i+1]);
1419 (void) DrawImage(*image,draw_info,exception);
1426 if (LocaleCompare("edge",option+1) == 0)
1429 Enhance edges in the image.
1431 (void) SyncImageSettings(mogrify_info,*image);
1432 flags=ParseGeometry(argv[i+1],&geometry_info);
1433 if ((flags & SigmaValue) == 0)
1434 geometry_info.sigma=1.0;
1435 mogrify_image=EdgeImage(*image,geometry_info.rho,
1436 geometry_info.sigma,exception);
1439 if (LocaleCompare("emboss",option+1) == 0)
1442 Gaussian embossen image.
1444 (void) SyncImageSettings(mogrify_info,*image);
1445 flags=ParseGeometry(argv[i+1],&geometry_info);
1446 if ((flags & SigmaValue) == 0)
1447 geometry_info.sigma=1.0;
1448 mogrify_image=EmbossImage(*image,geometry_info.rho,
1449 geometry_info.sigma,exception);
1452 if (LocaleCompare("encipher",option+1) == 0)
1460 (void) SyncImageSettings(mogrify_info,*image);
1461 passkey=FileToStringInfo(argv[i+1],~0,exception);
1462 if (passkey != (StringInfo *) NULL)
1464 (void) PasskeyEncipherImage(*image,passkey,exception);
1465 passkey=DestroyStringInfo(passkey);
1469 if (LocaleCompare("encoding",option+1) == 0)
1471 (void) CloneString(&draw_info->encoding,argv[i+1]);
1474 if (LocaleCompare("enhance",option+1) == 0)
1479 (void) SyncImageSettings(mogrify_info,*image);
1480 mogrify_image=EnhanceImage(*image,exception);
1483 if (LocaleCompare("equalize",option+1) == 0)
1488 (void) SyncImageSettings(mogrify_info,*image);
1489 (void) EqualizeImage(*image,exception);
1492 if (LocaleCompare("evaluate",option+1) == 0)
1497 MagickEvaluateOperator
1500 (void) SyncImageSettings(mogrify_info,*image);
1501 op=(MagickEvaluateOperator) ParseCommandOption(
1502 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1503 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1504 (void) EvaluateImage(*image,op,constant,exception);
1507 if (LocaleCompare("extent",option+1) == 0)
1510 Set the image extent.
1512 (void) SyncImageSettings(mogrify_info,*image);
1513 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1514 if (geometry.width == 0)
1515 geometry.width=(*image)->columns;
1516 if (geometry.height == 0)
1517 geometry.height=(*image)->rows;
1518 mogrify_image=ExtentImage(*image,&geometry,exception);
1525 if (LocaleCompare("family",option+1) == 0)
1529 if (draw_info->family != (char *) NULL)
1530 draw_info->family=DestroyString(draw_info->family);
1533 (void) CloneString(&draw_info->family,argv[i+1]);
1536 if (LocaleCompare("features",option+1) == 0)
1540 (void) DeleteImageArtifact(*image,"identify:features");
1543 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1546 if (LocaleCompare("fill",option+1) == 0)
1551 GetPixelInfo(*image,&fill);
1554 (void) QueryMagickColorCompliance("none",AllCompliance,&fill,
1556 (void) QueryColorCompliance("none",AllCompliance,
1557 &draw_info->fill,exception);
1558 if (draw_info->fill_pattern != (Image *) NULL)
1559 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1562 sans=AcquireExceptionInfo();
1563 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&fill,
1565 status=QueryColorCompliance(argv[i+1],AllCompliance,
1566 &draw_info->fill,sans);
1567 sans=DestroyExceptionInfo(sans);
1568 if (status == MagickFalse)
1569 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1573 if (LocaleCompare("flip",option+1) == 0)
1576 Flip image scanlines.
1578 (void) SyncImageSettings(mogrify_info,*image);
1579 mogrify_image=FlipImage(*image,exception);
1582 if (LocaleCompare("floodfill",option+1) == 0)
1590 (void) SyncImageSettings(mogrify_info,*image);
1591 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1592 (void) QueryMagickColorCompliance(argv[i+2],AllCompliance,&target,
1594 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1595 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1598 if (LocaleCompare("flop",option+1) == 0)
1601 Flop image scanlines.
1603 (void) SyncImageSettings(mogrify_info,*image);
1604 mogrify_image=FlopImage(*image,exception);
1607 if (LocaleCompare("font",option+1) == 0)
1611 if (draw_info->font != (char *) NULL)
1612 draw_info->font=DestroyString(draw_info->font);
1615 (void) CloneString(&draw_info->font,argv[i+1]);
1618 if (LocaleCompare("format",option+1) == 0)
1623 if (LocaleCompare("frame",option+1) == 0)
1629 Surround image with an ornamental border.
1631 (void) SyncImageSettings(mogrify_info,*image);
1632 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1633 frame_info.width=geometry.width;
1634 frame_info.height=geometry.height;
1635 if ((flags & HeightValue) == 0)
1636 frame_info.height=geometry.width;
1637 frame_info.outer_bevel=geometry.x;
1638 frame_info.inner_bevel=geometry.y;
1639 frame_info.x=(ssize_t) frame_info.width;
1640 frame_info.y=(ssize_t) frame_info.height;
1641 frame_info.width=(*image)->columns+2*frame_info.width;
1642 frame_info.height=(*image)->rows+2*frame_info.height;
1643 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1646 if (LocaleCompare("function",option+1) == 0)
1650 token[MaxTextExtent];
1668 Function Modify Image Values
1670 (void) SyncImageSettings(mogrify_info,*image);
1671 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1672 MagickFalse,argv[i+1]);
1673 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1675 if (arguments == (char *) NULL)
1677 p=(char *) arguments;
1678 for (x=0; *p != '\0'; x++)
1680 GetMagickToken(p,&p,token);
1682 GetMagickToken(p,&p,token);
1684 number_parameters=(size_t) x;
1685 parameters=(double *) AcquireQuantumMemory(number_parameters,
1686 sizeof(*parameters));
1687 if (parameters == (double *) NULL)
1688 ThrowWandFatalException(ResourceLimitFatalError,
1689 "MemoryAllocationFailed",(*image)->filename);
1690 (void) ResetMagickMemory(parameters,0,number_parameters*
1691 sizeof(*parameters));
1692 p=(char *) arguments;
1693 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1695 GetMagickToken(p,&p,token);
1697 GetMagickToken(p,&p,token);
1698 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1700 arguments=DestroyString(arguments);
1701 (void) FunctionImage(*image,function,number_parameters,parameters,
1703 parameters=(double *) RelinquishMagickMemory(parameters);
1710 if (LocaleCompare("gamma",option+1) == 0)
1715 (void) SyncImageSettings(mogrify_info,*image);
1717 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1719 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1720 (char **) NULL),exception);
1723 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1724 (LocaleCompare("gaussian",option+1) == 0))
1727 Gaussian blur image.
1729 (void) SyncImageSettings(mogrify_info,*image);
1730 flags=ParseGeometry(argv[i+1],&geometry_info);
1731 if ((flags & SigmaValue) == 0)
1732 geometry_info.sigma=1.0;
1733 if ((flags & XiValue) == 0)
1734 geometry_info.xi=0.0;
1735 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1736 geometry_info.sigma,geometry_info.xi,exception);
1739 if (LocaleCompare("geometry",option+1) == 0)
1742 Record Image offset, Resize last image.
1744 (void) SyncImageSettings(mogrify_info,*image);
1747 if ((*image)->geometry != (char *) NULL)
1748 (*image)->geometry=DestroyString((*image)->geometry);
1751 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1752 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1753 (void) CloneString(&(*image)->geometry,argv[i+1]);
1755 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1756 (*image)->filter,(*image)->blur,exception);
1759 if (LocaleCompare("gravity",option+1) == 0)
1763 draw_info->gravity=UndefinedGravity;
1766 draw_info->gravity=(GravityType) ParseCommandOption(
1767 MagickGravityOptions,MagickFalse,argv[i+1]);
1774 if (LocaleCompare("highlight-color",option+1) == 0)
1776 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1783 if (LocaleCompare("identify",option+1) == 0)
1788 (void) SyncImageSettings(mogrify_info,*image);
1789 if (format == (char *) NULL)
1791 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1795 text=InterpretImageProperties(mogrify_info,*image,format,
1797 if (text == (char *) NULL)
1799 (void) fputs(text,stdout);
1800 (void) fputc('\n',stdout);
1801 text=DestroyString(text);
1804 if (LocaleCompare("implode",option+1) == 0)
1809 (void) SyncImageSettings(mogrify_info,*image);
1810 (void) ParseGeometry(argv[i+1],&geometry_info);
1811 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1812 interpolate_method,exception);
1815 if (LocaleCompare("interline-spacing",option+1) == 0)
1818 (void) ParseGeometry("0",&geometry_info);
1820 (void) ParseGeometry(argv[i+1],&geometry_info);
1821 draw_info->interline_spacing=geometry_info.rho;
1824 if (LocaleCompare("interpolate",option+1) == 0)
1826 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1827 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1830 if (LocaleCompare("interword-spacing",option+1) == 0)
1833 (void) ParseGeometry("0",&geometry_info);
1835 (void) ParseGeometry(argv[i+1],&geometry_info);
1836 draw_info->interword_spacing=geometry_info.rho;
1843 if (LocaleCompare("kerning",option+1) == 0)
1846 (void) ParseGeometry("0",&geometry_info);
1848 (void) ParseGeometry(argv[i+1],&geometry_info);
1849 draw_info->kerning=geometry_info.rho;
1856 if (LocaleCompare("lat",option+1) == 0)
1859 Local adaptive threshold image.
1861 (void) SyncImageSettings(mogrify_info,*image);
1862 flags=ParseGeometry(argv[i+1],&geometry_info);
1863 if ((flags & PercentValue) != 0)
1864 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1865 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1866 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1867 geometry_info.xi,exception);
1870 if (LocaleCompare("level",option+1) == 0)
1883 (void) SyncImageSettings(mogrify_info,*image);
1884 flags=ParseGeometry(argv[i+1],&geometry_info);
1885 black_point=geometry_info.rho;
1886 white_point=(MagickRealType) QuantumRange;
1887 if ((flags & SigmaValue) != 0)
1888 white_point=geometry_info.sigma;
1890 if ((flags & XiValue) != 0)
1891 gamma=geometry_info.xi;
1892 if ((flags & PercentValue) != 0)
1894 black_point*=(MagickRealType) (QuantumRange/100.0);
1895 white_point*=(MagickRealType) (QuantumRange/100.0);
1897 if ((flags & SigmaValue) == 0)
1898 white_point=(MagickRealType) QuantumRange-black_point;
1899 if ((*option == '+') || ((flags & AspectValue) != 0))
1900 (void) LevelizeImage(*image,black_point,white_point,gamma,
1903 (void) LevelImage(*image,black_point,white_point,gamma,
1905 InheritException(exception,&(*image)->exception);
1908 if (LocaleCompare("level-colors",option+1) == 0)
1911 token[MaxTextExtent];
1920 p=(const char *) argv[i+1];
1921 GetMagickToken(p,&p,token); /* get black point color */
1922 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1923 (void) QueryMagickColorCompliance(token,AllCompliance,
1924 &black_point,exception);
1926 (void) QueryMagickColorCompliance("#000000",AllCompliance,
1927 &black_point,exception);
1928 if (isalpha((int) token[0]) || (token[0] == '#'))
1929 GetMagickToken(p,&p,token);
1931 white_point=black_point; /* set everything to that color */
1934 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1935 GetMagickToken(p,&p,token); /* Get white point color. */
1936 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1937 (void) QueryMagickColorCompliance(token,AllCompliance,
1938 &white_point,exception);
1940 (void) QueryMagickColorCompliance("#ffffff",AllCompliance,
1941 &white_point,exception);
1943 (void) LevelImageColors(*image,&black_point,&white_point,
1944 *option == '+' ? MagickTrue : MagickFalse,exception);
1947 if (LocaleCompare("linear-stretch",option+1) == 0)
1956 (void) SyncImageSettings(mogrify_info,*image);
1957 flags=ParseGeometry(argv[i+1],&geometry_info);
1958 black_point=geometry_info.rho;
1959 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1960 if ((flags & SigmaValue) != 0)
1961 white_point=geometry_info.sigma;
1962 if ((flags & PercentValue) != 0)
1964 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1965 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1967 if ((flags & SigmaValue) == 0)
1968 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1970 (void) LinearStretchImage(*image,black_point,white_point,exception);
1971 InheritException(exception,&(*image)->exception);
1974 if (LocaleCompare("linewidth",option+1) == 0)
1976 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1980 if (LocaleCompare("liquid-rescale",option+1) == 0)
1983 Liquid rescale image.
1985 (void) SyncImageSettings(mogrify_info,*image);
1986 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1987 if ((flags & XValue) == 0)
1989 if ((flags & YValue) == 0)
1991 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1992 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1995 if (LocaleCompare("lowlight-color",option+1) == 0)
1997 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2004 if (LocaleCompare("map",option+1) == 0)
2010 Transform image colors to match this set of colors.
2012 (void) SyncImageSettings(mogrify_info,*image);
2015 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2016 if (remap_image == (Image *) NULL)
2018 (void) RemapImage(quantize_info,*image,remap_image,exception);
2019 remap_image=DestroyImage(remap_image);
2022 if (LocaleCompare("mask",option+1) == 0)
2027 (void) SyncImageSettings(mogrify_info,*image);
2033 (void) SetImageMask(*image,(Image *) NULL,exception);
2039 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2040 if (mask == (Image *) NULL)
2042 (void) SetImageMask(*image,mask,exception);
2043 mask=DestroyImage(mask);
2046 if (LocaleCompare("matte",option+1) == 0)
2048 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2049 SetAlphaChannel : DeactivateAlphaChannel,exception);
2052 if (LocaleCompare("median",option+1) == 0)
2055 Median filter image.
2057 (void) SyncImageSettings(mogrify_info,*image);
2058 flags=ParseGeometry(argv[i+1],&geometry_info);
2059 if ((flags & SigmaValue) == 0)
2060 geometry_info.sigma=geometry_info.rho;
2061 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2062 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2065 if (LocaleCompare("mode",option+1) == 0)
2070 (void) SyncImageSettings(mogrify_info,*image);
2071 flags=ParseGeometry(argv[i+1],&geometry_info);
2072 if ((flags & SigmaValue) == 0)
2073 geometry_info.sigma=geometry_info.rho;
2074 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2075 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2078 if (LocaleCompare("modulate",option+1) == 0)
2080 (void) SyncImageSettings(mogrify_info,*image);
2081 (void) ModulateImage(*image,argv[i+1],exception);
2084 if (LocaleCompare("monitor",option+1) == 0)
2088 (void) SetImageProgressMonitor(*image,
2089 (MagickProgressMonitor) NULL,(void *) NULL);
2092 (void) SetImageProgressMonitor(*image,MonitorProgress,
2096 if (LocaleCompare("monochrome",option+1) == 0)
2098 (void) SyncImageSettings(mogrify_info,*image);
2099 (void) SetImageType(*image,BilevelType,exception);
2102 if (LocaleCompare("morphology",option+1) == 0)
2105 token[MaxTextExtent];
2120 Morphological Image Operation
2122 (void) SyncImageSettings(mogrify_info,*image);
2124 GetMagickToken(p,&p,token);
2125 method=(MorphologyMethod) ParseCommandOption(
2126 MagickMorphologyOptions,MagickFalse,token);
2128 GetMagickToken(p,&p,token);
2129 if ((*p == ':') || (*p == ','))
2130 GetMagickToken(p,&p,token);
2132 iterations=(ssize_t) StringToLong(p);
2133 kernel=AcquireKernelInfo(argv[i+2]);
2134 if (kernel == (KernelInfo *) NULL)
2136 (void) ThrowMagickException(exception,GetMagickModule(),
2137 OptionError,"UnabletoParseKernel","morphology");
2141 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2143 kernel=DestroyKernelInfo(kernel);
2146 if (LocaleCompare("motion-blur",option+1) == 0)
2151 (void) SyncImageSettings(mogrify_info,*image);
2152 flags=ParseGeometry(argv[i+1],&geometry_info);
2153 if ((flags & SigmaValue) == 0)
2154 geometry_info.sigma=1.0;
2155 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2156 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2164 if (LocaleCompare("negate",option+1) == 0)
2166 (void) SyncImageSettings(mogrify_info,*image);
2167 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2168 MagickFalse,exception);
2171 if (LocaleCompare("noise",option+1) == 0)
2173 (void) SyncImageSettings(mogrify_info,*image);
2176 flags=ParseGeometry(argv[i+1],&geometry_info);
2177 if ((flags & SigmaValue) == 0)
2178 geometry_info.sigma=geometry_info.rho;
2179 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2180 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2187 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2188 MagickFalse,argv[i+1]);
2189 mogrify_image=AddNoiseImage(*image,noise,exception);
2193 if (LocaleCompare("normalize",option+1) == 0)
2195 (void) SyncImageSettings(mogrify_info,*image);
2196 (void) NormalizeImage(*image,exception);
2203 if (LocaleCompare("opaque",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image);
2209 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2211 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2212 MagickFalse : MagickTrue,exception);
2215 if (LocaleCompare("ordered-dither",option+1) == 0)
2217 (void) SyncImageSettings(mogrify_info,*image);
2218 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2225 if (LocaleCompare("paint",option+1) == 0)
2227 (void) SyncImageSettings(mogrify_info,*image);
2228 (void) ParseGeometry(argv[i+1],&geometry_info);
2229 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2230 geometry_info.sigma,exception);
2233 if (LocaleCompare("pen",option+1) == 0)
2237 (void) QueryColorCompliance("none",AllCompliance,
2238 &draw_info->fill,exception);
2241 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2242 &draw_info->fill,exception);
2245 if (LocaleCompare("pointsize",option+1) == 0)
2248 (void) ParseGeometry("12",&geometry_info);
2250 (void) ParseGeometry(argv[i+1],&geometry_info);
2251 draw_info->pointsize=geometry_info.rho;
2254 if (LocaleCompare("polaroid",option+1) == 0)
2263 Simulate a Polaroid picture.
2265 (void) SyncImageSettings(mogrify_info,*image);
2266 random_info=AcquireRandomInfo();
2267 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2268 random_info=DestroyRandomInfo(random_info);
2271 SetGeometryInfo(&geometry_info);
2272 flags=ParseGeometry(argv[i+1],&geometry_info);
2273 angle=geometry_info.rho;
2275 mogrify_image=PolaroidImage(*image,draw_info,angle,
2276 interpolate_method,exception);
2279 if (LocaleCompare("posterize",option+1) == 0)
2284 (void) SyncImageSettings(mogrify_info,*image);
2285 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2286 quantize_info->dither,exception);
2289 if (LocaleCompare("preview",option+1) == 0)
2297 (void) SyncImageSettings(mogrify_info,*image);
2299 preview_type=UndefinedPreview;
2301 preview_type=(PreviewType) ParseCommandOption(
2302 MagickPreviewOptions,MagickFalse,argv[i+1]);
2303 mogrify_image=PreviewImage(*image,preview_type,exception);
2306 if (LocaleCompare("profile",option+1) == 0)
2320 (void) SyncImageSettings(mogrify_info,*image);
2324 Remove a profile from the image.
2326 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2328 InheritException(exception,&(*image)->exception);
2332 Associate a profile with the image.
2334 profile_info=CloneImageInfo(mogrify_info);
2335 profile=GetImageProfile(*image,"iptc");
2336 if (profile != (StringInfo *) NULL)
2337 profile_info->profile=(void *) CloneStringInfo(profile);
2338 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2339 profile_info=DestroyImageInfo(profile_info);
2340 if (profile_image == (Image *) NULL)
2345 profile_info=CloneImageInfo(mogrify_info);
2346 (void) CopyMagickString(profile_info->filename,argv[i+1],
2348 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2349 if (profile != (StringInfo *) NULL)
2351 (void) ProfileImage(*image,profile_info->magick,
2352 GetStringInfoDatum(profile),(size_t)
2353 GetStringInfoLength(profile),MagickFalse);
2354 profile=DestroyStringInfo(profile);
2356 profile_info=DestroyImageInfo(profile_info);
2359 ResetImageProfileIterator(profile_image);
2360 name=GetNextImageProfile(profile_image);
2361 while (name != (const char *) NULL)
2363 profile=GetImageProfile(profile_image,name);
2364 if (profile != (StringInfo *) NULL)
2365 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2366 (size_t) GetStringInfoLength(profile),MagickFalse);
2367 name=GetNextImageProfile(profile_image);
2369 profile_image=DestroyImage(profile_image);
2376 if (LocaleCompare("quantize",option+1) == 0)
2380 quantize_info->colorspace=UndefinedColorspace;
2383 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2384 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2391 if (LocaleCompare("radial-blur",option+1) == 0)
2396 (void) SyncImageSettings(mogrify_info,*image);
2397 flags=ParseGeometry(argv[i+1],&geometry_info);
2398 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2399 geometry_info.sigma,exception);
2402 if (LocaleCompare("raise",option+1) == 0)
2405 Surround image with a raise of solid color.
2407 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2408 if ((flags & SigmaValue) == 0)
2409 geometry.height=geometry.width;
2410 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2411 MagickFalse,exception);
2414 if (LocaleCompare("random-threshold",option+1) == 0)
2419 (void) SyncImageSettings(mogrify_info,*image);
2420 (void) RandomThresholdImage(*image,argv[i+1],exception);
2423 if (LocaleCompare("recolor",option+1) == 0)
2428 (void) SyncImageSettings(mogrify_info,*image);
2429 kernel=AcquireKernelInfo(argv[i+1]);
2430 if (kernel == (KernelInfo *) NULL)
2432 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2433 kernel=DestroyKernelInfo(kernel);
2436 if (LocaleCompare("region",option+1) == 0)
2438 (void) SyncImageSettings(mogrify_info,*image);
2439 if (region_image != (Image *) NULL)
2444 (void) CompositeImage(region_image,region_image->matte !=
2445 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2446 region_geometry.x,region_geometry.y);
2447 InheritException(exception,®ion_image->exception);
2448 *image=DestroyImage(*image);
2449 *image=region_image;
2450 region_image = (Image *) NULL;
2455 Apply transformations to a selected region of the image.
2457 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2459 mogrify_image=CropImage(*image,®ion_geometry,exception);
2460 if (mogrify_image == (Image *) NULL)
2462 region_image=(*image);
2463 *image=mogrify_image;
2464 mogrify_image=(Image *) NULL;
2467 if (LocaleCompare("render",option+1) == 0)
2469 (void) SyncImageSettings(mogrify_info,*image);
2470 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2473 if (LocaleCompare("remap",option+1) == 0)
2479 Transform image colors to match this set of colors.
2481 (void) SyncImageSettings(mogrify_info,*image);
2484 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2485 if (remap_image == (Image *) NULL)
2487 (void) RemapImage(quantize_info,*image,remap_image,exception);
2488 remap_image=DestroyImage(remap_image);
2491 if (LocaleCompare("repage",option+1) == 0)
2495 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2498 (void) ResetImagePage(*image,argv[i+1]);
2499 InheritException(exception,&(*image)->exception);
2502 if (LocaleCompare("resample",option+1) == 0)
2507 (void) SyncImageSettings(mogrify_info,*image);
2508 flags=ParseGeometry(argv[i+1],&geometry_info);
2509 if ((flags & SigmaValue) == 0)
2510 geometry_info.sigma=geometry_info.rho;
2511 mogrify_image=ResampleImage(*image,geometry_info.rho,
2512 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2515 if (LocaleCompare("resize",option+1) == 0)
2520 (void) SyncImageSettings(mogrify_info,*image);
2521 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2522 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2523 (*image)->filter,(*image)->blur,exception);
2526 if (LocaleCompare("roll",option+1) == 0)
2531 (void) SyncImageSettings(mogrify_info,*image);
2532 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2533 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2536 if (LocaleCompare("rotate",option+1) == 0)
2542 Check for conditional image rotation.
2544 (void) SyncImageSettings(mogrify_info,*image);
2545 if (strchr(argv[i+1],'>') != (char *) NULL)
2546 if ((*image)->columns <= (*image)->rows)
2548 if (strchr(argv[i+1],'<') != (char *) NULL)
2549 if ((*image)->columns >= (*image)->rows)
2554 geometry=ConstantString(argv[i+1]);
2555 (void) SubstituteString(&geometry,">","");
2556 (void) SubstituteString(&geometry,"<","");
2557 (void) ParseGeometry(geometry,&geometry_info);
2558 geometry=DestroyString(geometry);
2559 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2566 if (LocaleCompare("sample",option+1) == 0)
2569 Sample image with pixel replication.
2571 (void) SyncImageSettings(mogrify_info,*image);
2572 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2573 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2577 if (LocaleCompare("scale",option+1) == 0)
2582 (void) SyncImageSettings(mogrify_info,*image);
2583 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2584 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2588 if (LocaleCompare("selective-blur",option+1) == 0)
2591 Selectively blur pixels within a contrast threshold.
2593 (void) SyncImageSettings(mogrify_info,*image);
2594 flags=ParseGeometry(argv[i+1],&geometry_info);
2595 if ((flags & PercentValue) != 0)
2596 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2597 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2598 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2601 if (LocaleCompare("separate",option+1) == 0)
2604 Break channels into separate images.
2606 (void) SyncImageSettings(mogrify_info,*image);
2607 mogrify_image=SeparateImages(*image,exception);
2610 if (LocaleCompare("sepia-tone",option+1) == 0)
2618 (void) SyncImageSettings(mogrify_info,*image);
2619 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2620 mogrify_image=SepiaToneImage(*image,threshold,exception);
2623 if (LocaleCompare("segment",option+1) == 0)
2628 (void) SyncImageSettings(mogrify_info,*image);
2629 flags=ParseGeometry(argv[i+1],&geometry_info);
2630 if ((flags & SigmaValue) == 0)
2631 geometry_info.sigma=1.0;
2632 (void) SegmentImage(*image,(*image)->colorspace,
2633 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2637 if (LocaleCompare("set",option+1) == 0)
2647 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2648 (void) DeleteImageRegistry(argv[i+1]+9);
2650 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2652 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2653 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2656 (void) DeleteImageProperty(*image,argv[i+1]);
2659 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2661 if (value == (char *) NULL)
2663 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2664 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2667 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2669 (void) SetImageOption(image_info,argv[i+1]+7,value);
2670 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2671 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2674 (void) SetImageProperty(*image,argv[i+1],value);
2675 value=DestroyString(value);
2678 if (LocaleCompare("shade",option+1) == 0)
2683 (void) SyncImageSettings(mogrify_info,*image);
2684 flags=ParseGeometry(argv[i+1],&geometry_info);
2685 if ((flags & SigmaValue) == 0)
2686 geometry_info.sigma=1.0;
2687 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2688 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2691 if (LocaleCompare("shadow",option+1) == 0)
2696 (void) SyncImageSettings(mogrify_info,*image);
2697 flags=ParseGeometry(argv[i+1],&geometry_info);
2698 if ((flags & SigmaValue) == 0)
2699 geometry_info.sigma=1.0;
2700 if ((flags & XiValue) == 0)
2701 geometry_info.xi=4.0;
2702 if ((flags & PsiValue) == 0)
2703 geometry_info.psi=4.0;
2704 mogrify_image=ShadowImage(*image,geometry_info.rho,
2705 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2706 ceil(geometry_info.psi-0.5),exception);
2709 if (LocaleCompare("sharpen",option+1) == 0)
2714 (void) SyncImageSettings(mogrify_info,*image);
2715 flags=ParseGeometry(argv[i+1],&geometry_info);
2716 if ((flags & SigmaValue) == 0)
2717 geometry_info.sigma=1.0;
2718 if ((flags & XiValue) == 0)
2719 geometry_info.xi=0.0;
2720 mogrify_image=SharpenImage(*image,geometry_info.rho,
2721 geometry_info.sigma,geometry_info.xi,exception);
2724 if (LocaleCompare("shave",option+1) == 0)
2727 Shave the image edges.
2729 (void) SyncImageSettings(mogrify_info,*image);
2730 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2731 mogrify_image=ShaveImage(*image,&geometry,exception);
2734 if (LocaleCompare("shear",option+1) == 0)
2739 (void) SyncImageSettings(mogrify_info,*image);
2740 flags=ParseGeometry(argv[i+1],&geometry_info);
2741 if ((flags & SigmaValue) == 0)
2742 geometry_info.sigma=geometry_info.rho;
2743 mogrify_image=ShearImage(*image,geometry_info.rho,
2744 geometry_info.sigma,exception);
2747 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2750 Sigmoidal non-linearity contrast control.
2752 (void) SyncImageSettings(mogrify_info,*image);
2753 flags=ParseGeometry(argv[i+1],&geometry_info);
2754 if ((flags & SigmaValue) == 0)
2755 geometry_info.sigma=(double) QuantumRange/2.0;
2756 if ((flags & PercentValue) != 0)
2757 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2759 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2760 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2764 if (LocaleCompare("sketch",option+1) == 0)
2769 (void) SyncImageSettings(mogrify_info,*image);
2770 flags=ParseGeometry(argv[i+1],&geometry_info);
2771 if ((flags & SigmaValue) == 0)
2772 geometry_info.sigma=1.0;
2773 mogrify_image=SketchImage(*image,geometry_info.rho,
2774 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2777 if (LocaleCompare("solarize",option+1) == 0)
2782 (void) SyncImageSettings(mogrify_info,*image);
2783 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2784 (void) SolarizeImage(*image,threshold,exception);
2787 if (LocaleCompare("sparse-color",option+1) == 0)
2796 Sparse Color Interpolated Gradient
2798 (void) SyncImageSettings(mogrify_info,*image);
2799 method=(SparseColorMethod) ParseCommandOption(
2800 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2801 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2803 if (arguments == (char *) NULL)
2805 mogrify_image=SparseColorOption(*image,method,arguments,
2806 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2807 arguments=DestroyString(arguments);
2810 if (LocaleCompare("splice",option+1) == 0)
2813 Splice a solid color into the image.
2815 (void) SyncImageSettings(mogrify_info,*image);
2816 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2817 mogrify_image=SpliceImage(*image,&geometry,exception);
2820 if (LocaleCompare("spread",option+1) == 0)
2825 (void) SyncImageSettings(mogrify_info,*image);
2826 (void) ParseGeometry(argv[i+1],&geometry_info);
2827 mogrify_image=SpreadImage(*image,geometry_info.rho,
2828 interpolate_method,exception);
2831 if (LocaleCompare("statistic",option+1) == 0)
2836 (void) SyncImageSettings(mogrify_info,*image);
2837 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2838 MagickFalse,argv[i+1]);
2839 (void) ParseGeometry(argv[i+2],&geometry_info);
2840 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2841 (size_t) geometry_info.sigma,exception);
2844 if (LocaleCompare("stretch",option+1) == 0)
2848 draw_info->stretch=UndefinedStretch;
2851 draw_info->stretch=(StretchType) ParseCommandOption(
2852 MagickStretchOptions,MagickFalse,argv[i+1]);
2855 if (LocaleCompare("strip",option+1) == 0)
2858 Strip image of profiles and comments.
2860 (void) SyncImageSettings(mogrify_info,*image);
2861 (void) StripImage(*image);
2862 InheritException(exception,&(*image)->exception);
2865 if (LocaleCompare("stroke",option+1) == 0)
2872 (void) QueryColorCompliance("none",AllCompliance,
2873 &draw_info->stroke,exception);
2874 if (draw_info->stroke_pattern != (Image *) NULL)
2875 draw_info->stroke_pattern=DestroyImage(
2876 draw_info->stroke_pattern);
2879 sans=AcquireExceptionInfo();
2880 status=QueryColorCompliance(argv[i+1],AllCompliance,
2881 &draw_info->stroke,sans);
2882 sans=DestroyExceptionInfo(sans);
2883 if (status == MagickFalse)
2884 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2888 if (LocaleCompare("strokewidth",option+1) == 0)
2890 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2894 if (LocaleCompare("style",option+1) == 0)
2898 draw_info->style=UndefinedStyle;
2901 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2902 MagickFalse,argv[i+1]);
2905 if (LocaleCompare("swirl",option+1) == 0)
2910 (void) SyncImageSettings(mogrify_info,*image);
2911 (void) ParseGeometry(argv[i+1],&geometry_info);
2912 mogrify_image=SwirlImage(*image,geometry_info.rho,
2913 interpolate_method,exception);
2920 if (LocaleCompare("threshold",option+1) == 0)
2928 (void) SyncImageSettings(mogrify_info,*image);
2930 threshold=(double) QuantumRange/2;
2932 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2933 (void) BilevelImage(*image,threshold);
2934 InheritException(exception,&(*image)->exception);
2937 if (LocaleCompare("thumbnail",option+1) == 0)
2942 (void) SyncImageSettings(mogrify_info,*image);
2943 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2944 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2948 if (LocaleCompare("tile",option+1) == 0)
2952 if (draw_info->fill_pattern != (Image *) NULL)
2953 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2956 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2960 if (LocaleCompare("tint",option+1) == 0)
2965 (void) SyncImageSettings(mogrify_info,*image);
2966 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2969 if (LocaleCompare("transform",option+1) == 0)
2972 Affine transform image.
2974 (void) SyncImageSettings(mogrify_info,*image);
2975 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2979 if (LocaleCompare("transparent",option+1) == 0)
2984 (void) SyncImageSettings(mogrify_info,*image);
2985 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2987 (void) TransparentPaintImage(*image,&target,(Quantum)
2988 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2989 &(*image)->exception);
2992 if (LocaleCompare("transpose",option+1) == 0)
2995 Transpose image scanlines.
2997 (void) SyncImageSettings(mogrify_info,*image);
2998 mogrify_image=TransposeImage(*image,exception);
3001 if (LocaleCompare("transverse",option+1) == 0)
3004 Transverse image scanlines.
3006 (void) SyncImageSettings(mogrify_info,*image);
3007 mogrify_image=TransverseImage(*image,exception);
3010 if (LocaleCompare("treedepth",option+1) == 0)
3012 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3015 if (LocaleCompare("trim",option+1) == 0)
3020 (void) SyncImageSettings(mogrify_info,*image);
3021 mogrify_image=TrimImage(*image,exception);
3024 if (LocaleCompare("type",option+1) == 0)
3029 (void) SyncImageSettings(mogrify_info,*image);
3033 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3035 (*image)->type=UndefinedType;
3036 (void) SetImageType(*image,type,exception);
3043 if (LocaleCompare("undercolor",option+1) == 0)
3045 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3046 &draw_info->undercolor,exception);
3049 if (LocaleCompare("unique",option+1) == 0)
3053 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3056 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3057 (void) SetImageArtifact(*image,"verbose","true");
3060 if (LocaleCompare("unique-colors",option+1) == 0)
3063 Unique image colors.
3065 (void) SyncImageSettings(mogrify_info,*image);
3066 mogrify_image=UniqueImageColors(*image,exception);
3069 if (LocaleCompare("unsharp",option+1) == 0)
3074 (void) SyncImageSettings(mogrify_info,*image);
3075 flags=ParseGeometry(argv[i+1],&geometry_info);
3076 if ((flags & SigmaValue) == 0)
3077 geometry_info.sigma=1.0;
3078 if ((flags & XiValue) == 0)
3079 geometry_info.xi=1.0;
3080 if ((flags & PsiValue) == 0)
3081 geometry_info.psi=0.05;
3082 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3083 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3090 if (LocaleCompare("verbose",option+1) == 0)
3092 (void) SetImageArtifact(*image,option+1,
3093 *option == '+' ? "false" : "true");
3096 if (LocaleCompare("vignette",option+1) == 0)
3101 (void) SyncImageSettings(mogrify_info,*image);
3102 flags=ParseGeometry(argv[i+1],&geometry_info);
3103 if ((flags & SigmaValue) == 0)
3104 geometry_info.sigma=1.0;
3105 if ((flags & XiValue) == 0)
3106 geometry_info.xi=0.1*(*image)->columns;
3107 if ((flags & PsiValue) == 0)
3108 geometry_info.psi=0.1*(*image)->rows;
3109 mogrify_image=VignetteImage(*image,geometry_info.rho,
3110 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3111 ceil(geometry_info.psi-0.5),exception);
3114 if (LocaleCompare("virtual-pixel",option+1) == 0)
3118 (void) SetImageVirtualPixelMethod(*image,
3119 UndefinedVirtualPixelMethod);
3122 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3123 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3131 if (LocaleCompare("wave",option+1) == 0)
3136 (void) SyncImageSettings(mogrify_info,*image);
3137 flags=ParseGeometry(argv[i+1],&geometry_info);
3138 if ((flags & SigmaValue) == 0)
3139 geometry_info.sigma=1.0;
3140 mogrify_image=WaveImage(*image,geometry_info.rho,
3141 geometry_info.sigma,interpolate_method,exception);
3144 if (LocaleCompare("weight",option+1) == 0)
3146 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3147 if (LocaleCompare(argv[i+1],"all") == 0)
3148 draw_info->weight=0;
3149 if (LocaleCompare(argv[i+1],"bold") == 0)
3150 draw_info->weight=700;
3151 if (LocaleCompare(argv[i+1],"bolder") == 0)
3152 if (draw_info->weight <= 800)
3153 draw_info->weight+=100;
3154 if (LocaleCompare(argv[i+1],"lighter") == 0)
3155 if (draw_info->weight >= 100)
3156 draw_info->weight-=100;
3157 if (LocaleCompare(argv[i+1],"normal") == 0)
3158 draw_info->weight=400;
3161 if (LocaleCompare("white-threshold",option+1) == 0)
3164 White threshold image.
3166 (void) SyncImageSettings(mogrify_info,*image);
3167 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3168 InheritException(exception,&(*image)->exception);
3177 Replace current image with any image that was generated
3179 if (mogrify_image != (Image *) NULL)
3180 ReplaceImageInListReturnLast(image,mogrify_image);
3183 if (region_image != (Image *) NULL)
3186 Composite transformed region onto image.
3188 (void) SyncImageSettings(mogrify_info,*image);
3189 (void) CompositeImage(region_image,region_image->matte !=
3190 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3191 region_geometry.x,region_geometry.y);
3192 InheritException(exception,®ion_image->exception);
3193 *image=DestroyImage(*image);
3194 *image=region_image;
3195 region_image = (Image *) NULL;
3200 quantize_info=DestroyQuantizeInfo(quantize_info);
3201 draw_info=DestroyDrawInfo(draw_info);
3202 mogrify_info=DestroyImageInfo(mogrify_info);
3203 status=(MagickStatusType) ((*image)->exception.severity ==
3204 UndefinedException ? 1 : 0);
3205 return(status == 0 ? MagickFalse : MagickTrue);
3209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3213 + M o g r i f y I m a g e C o m m a n d %
3217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3219 % MogrifyImageCommand() transforms an image or a sequence of images. These
3220 % transforms include image scaling, image rotation, color reduction, and
3221 % others. The transmogrified image overwrites the original image.
3223 % The format of the MogrifyImageCommand method is:
3225 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3226 % const char **argv,char **metadata,ExceptionInfo *exception)
3228 % A description of each parameter follows:
3230 % o image_info: the image info.
3232 % o argc: the number of elements in the argument vector.
3234 % o argv: A text array containing the command line arguments.
3236 % o metadata: any metadata is returned here.
3238 % o exception: return any errors or warnings in this structure.
3242 static MagickBooleanType MogrifyUsage(void)
3247 "-debug events display copious debugging information",
3248 "-help print program options",
3249 "-list type print a list of supported option arguments",
3250 "-log format format of debugging information",
3251 "-version print version information",
3256 "-adaptive-blur geometry",
3257 " adaptively blur pixels; decrease effect near edges",
3258 "-adaptive-resize geometry",
3259 " adaptively resize image using 'mesh' interpolation",
3260 "-adaptive-sharpen geometry",
3261 " adaptively sharpen pixels; increase effect near edges",
3262 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3263 " transparent, extract, background, or shape",
3264 "-annotate geometry text",
3265 " annotate the image with text",
3266 "-auto-gamma automagically adjust gamma level of image",
3267 "-auto-level automagically adjust color levels of image",
3268 "-auto-orient automagically orient (rotate) image",
3269 "-bench iterations measure performance",
3270 "-black-threshold value",
3271 " force all pixels below the threshold into black",
3272 "-blue-shift simulate a scene at nighttime in the moonlight",
3273 "-blur geometry reduce image noise and reduce detail levels",
3274 "-border geometry surround image with a border of color",
3275 "-bordercolor color border color",
3276 "-brightness-contrast geometry",
3277 " improve brightness / contrast of the image",
3278 "-cdl filename color correct with a color decision list",
3279 "-charcoal geometry simulate a charcoal drawing",
3280 "-chop geometry remove pixels from the image interior",
3281 "-clamp restrict pixel range from 0 to the quantum depth",
3282 "-clip clip along the first path from the 8BIM profile",
3283 "-clip-mask filename associate a clip mask with the image",
3284 "-clip-path id clip along a named path from the 8BIM profile",
3285 "-colorize value colorize the image with the fill color",
3286 "-color-matrix matrix apply color correction to the image",
3287 "-contrast enhance or reduce the image contrast",
3288 "-contrast-stretch geometry",
3289 " improve contrast by `stretching' the intensity range",
3290 "-convolve coefficients",
3291 " apply a convolution kernel to the image",
3292 "-cycle amount cycle the image colormap",
3293 "-decipher filename convert cipher pixels to plain pixels",
3294 "-deskew threshold straighten an image",
3295 "-despeckle reduce the speckles within an image",
3296 "-distort method args",
3297 " distort images according to given method ad args",
3298 "-draw string annotate the image with a graphic primitive",
3299 "-edge radius apply a filter to detect edges in the image",
3300 "-encipher filename convert plain pixels to cipher pixels",
3301 "-emboss radius emboss an image",
3302 "-enhance apply a digital filter to enhance a noisy image",
3303 "-equalize perform histogram equalization to an image",
3304 "-evaluate operator value",
3305 " evaluate an arithmetic, relational, or logical expression",
3306 "-extent geometry set the image size",
3307 "-extract geometry extract area from image",
3308 "-fft implements the discrete Fourier transform (DFT)",
3309 "-flip flip image vertically",
3310 "-floodfill geometry color",
3311 " floodfill the image with color",
3312 "-flop flop image horizontally",
3313 "-frame geometry surround image with an ornamental border",
3314 "-function name parameters",
3315 " apply function over image values",
3316 "-gamma value level of gamma correction",
3317 "-gaussian-blur geometry",
3318 " reduce image noise and reduce detail levels",
3319 "-geometry geometry preferred size or location of the image",
3320 "-identify identify the format and characteristics of the image",
3321 "-ift implements the inverse discrete Fourier transform (DFT)",
3322 "-implode amount implode image pixels about the center",
3323 "-lat geometry local adaptive thresholding",
3324 "-layers method optimize, merge, or compare image layers",
3325 "-level value adjust the level of image contrast",
3326 "-level-colors color,color",
3327 " level image with the given colors",
3328 "-linear-stretch geometry",
3329 " improve contrast by `stretching with saturation'",
3330 "-liquid-rescale geometry",
3331 " rescale image with seam-carving",
3332 "-median geometry apply a median filter to the image",
3333 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3334 "-modulate value vary the brightness, saturation, and hue",
3335 "-monochrome transform image to black and white",
3336 "-morphology method kernel",
3337 " apply a morphology method to the image",
3338 "-motion-blur geometry",
3339 " simulate motion blur",
3340 "-negate replace every pixel with its complementary color ",
3341 "-noise geometry add or reduce noise in an image",
3342 "-normalize transform image to span the full range of colors",
3343 "-opaque color change this color to the fill color",
3344 "-ordered-dither NxN",
3345 " add a noise pattern to the image with specific",
3347 "-paint radius simulate an oil painting",
3348 "-polaroid angle simulate a Polaroid picture",
3349 "-posterize levels reduce the image to a limited number of color levels",
3350 "-profile filename add, delete, or apply an image profile",
3351 "-quantize colorspace reduce colors in this colorspace",
3352 "-radial-blur angle radial blur the image",
3353 "-raise value lighten/darken image edges to create a 3-D effect",
3354 "-random-threshold low,high",
3355 " random threshold the image",
3356 "-region geometry apply options to a portion of the image",
3357 "-render render vector graphics",
3358 "-repage geometry size and location of an image canvas",
3359 "-resample geometry change the resolution of an image",
3360 "-resize geometry resize the image",
3361 "-roll geometry roll an image vertically or horizontally",
3362 "-rotate degrees apply Paeth rotation to the image",
3363 "-sample geometry scale image with pixel sampling",
3364 "-scale geometry scale the image",
3365 "-segment values segment an image",
3366 "-selective-blur geometry",
3367 " selectively blur pixels within a contrast threshold",
3368 "-sepia-tone threshold",
3369 " simulate a sepia-toned photo",
3370 "-set property value set an image property",
3371 "-shade degrees shade the image using a distant light source",
3372 "-shadow geometry simulate an image shadow",
3373 "-sharpen geometry sharpen the image",
3374 "-shave geometry shave pixels from the image edges",
3375 "-shear geometry slide one edge of the image along the X or Y axis",
3376 "-sigmoidal-contrast geometry",
3377 " increase the contrast without saturating highlights or shadows",
3378 "-sketch geometry simulate a pencil sketch",
3379 "-solarize threshold negate all pixels above the threshold level",
3380 "-sparse-color method args",
3381 " fill in a image based on a few color points",
3382 "-splice geometry splice the background color into the image",
3383 "-spread radius displace image pixels by a random amount",
3384 "-statistic type radius",
3385 " replace each pixel with corresponding statistic from the neighborhood",
3386 "-strip strip image of all profiles and comments",
3387 "-swirl degrees swirl image pixels about the center",
3388 "-threshold value threshold the image",
3389 "-thumbnail geometry create a thumbnail of the image",
3390 "-tile filename tile image when filling a graphic primitive",
3391 "-tint value tint the image with the fill color",
3392 "-transform affine transform image",
3393 "-transparent color make this color transparent within the image",
3394 "-transpose flip image vertically and rotate 90 degrees",
3395 "-transverse flop image horizontally and rotate 270 degrees",
3396 "-trim trim image edges",
3397 "-type type image type",
3398 "-unique-colors discard all but one of any pixel color",
3399 "-unsharp geometry sharpen the image",
3400 "-vignette geometry soften the edges of the image in vignette style",
3401 "-wave geometry alter an image along a sine wave",
3402 "-white-threshold value",
3403 " force all pixels above the threshold into white",
3406 *sequence_operators[]=
3408 "-append append an image sequence",
3409 "-clut apply a color lookup table to the image",
3410 "-coalesce merge a sequence of images",
3411 "-combine combine a sequence of images",
3412 "-composite composite image",
3413 "-crop geometry cut out a rectangular region of the image",
3414 "-deconstruct break down an image sequence into constituent parts",
3415 "-evaluate-sequence operator",
3416 " evaluate an arithmetic, relational, or logical expression",
3417 "-flatten flatten a sequence of images",
3418 "-fx expression apply mathematical expression to an image channel(s)",
3419 "-hald-clut apply a Hald color lookup table to the image",
3420 "-morph value morph an image sequence",
3421 "-mosaic create a mosaic from an image sequence",
3422 "-print string interpret string and print to console",
3423 "-process arguments process the image with a custom image filter",
3424 "-separate separate an image channel into a grayscale image",
3425 "-smush geometry smush an image sequence together",
3426 "-write filename write images to this file",
3431 "-adjoin join images into a single multi-image file",
3432 "-affine matrix affine transform matrix",
3433 "-alpha option activate, deactivate, reset, or set the alpha channel",
3434 "-antialias remove pixel-aliasing",
3435 "-authenticate password",
3436 " decipher image with this password",
3437 "-attenuate value lessen (or intensify) when adding noise to an image",
3438 "-background color background color",
3439 "-bias value add bias when convolving an image",
3440 "-black-point-compensation",
3441 " use black point compensation",
3442 "-blue-primary point chromaticity blue primary point",
3443 "-bordercolor color border color",
3444 "-caption string assign a caption to an image",
3445 "-channel type apply option to select image channels",
3446 "-colors value preferred number of colors in the image",
3447 "-colorspace type alternate image colorspace",
3448 "-comment string annotate image with comment",
3449 "-compose operator set image composite operator",
3450 "-compress type type of pixel compression when writing the image",
3451 "-define format:option",
3452 " define one or more image format options",
3453 "-delay value display the next image after pausing",
3454 "-density geometry horizontal and vertical density of the image",
3455 "-depth value image depth",
3456 "-direction type render text right-to-left or left-to-right",
3457 "-display server get image or font from this X server",
3458 "-dispose method layer disposal method",
3459 "-dither method apply error diffusion to image",
3460 "-encoding type text encoding type",
3461 "-endian type endianness (MSB or LSB) of the image",
3462 "-family name render text with this font family",
3463 "-fill color color to use when filling a graphic primitive",
3464 "-filter type use this filter when resizing an image",
3465 "-font name render text with this font",
3466 "-format \"string\" output formatted image characteristics",
3467 "-fuzz distance colors within this distance are considered equal",
3468 "-gravity type horizontal and vertical text placement",
3469 "-green-primary point chromaticity green primary point",
3470 "-intent type type of rendering intent when managing the image color",
3471 "-interlace type type of image interlacing scheme",
3472 "-interline-spacing value",
3473 " set the space between two text lines",
3474 "-interpolate method pixel color interpolation method",
3475 "-interword-spacing value",
3476 " set the space between two words",
3477 "-kerning value set the space between two letters",
3478 "-label string assign a label to an image",
3479 "-limit type value pixel cache resource limit",
3480 "-loop iterations add Netscape loop extension to your GIF animation",
3481 "-mask filename associate a mask with the image",
3482 "-mattecolor color frame color",
3483 "-monitor monitor progress",
3484 "-orient type image orientation",
3485 "-page geometry size and location of an image canvas (setting)",
3486 "-ping efficiently determine image attributes",
3487 "-pointsize value font point size",
3488 "-precision value maximum number of significant digits to print",
3489 "-preview type image preview type",
3490 "-quality value JPEG/MIFF/PNG compression level",
3491 "-quiet suppress all warning messages",
3492 "-red-primary point chromaticity red primary point",
3493 "-regard-warnings pay attention to warning messages",
3494 "-remap filename transform image colors to match this set of colors",
3495 "-respect-parentheses settings remain in effect until parenthesis boundary",
3496 "-sampling-factor geometry",
3497 " horizontal and vertical sampling factor",
3498 "-scene value image scene number",
3499 "-seed value seed a new sequence of pseudo-random numbers",
3500 "-size geometry width and height of image",
3501 "-stretch type render text with this font stretch",
3502 "-stroke color graphic primitive stroke color",
3503 "-strokewidth value graphic primitive stroke width",
3504 "-style type render text with this font style",
3505 "-synchronize synchronize image to storage device",
3506 "-taint declare the image as modified",
3507 "-texture filename name of texture to tile onto the image background",
3508 "-tile-offset geometry",
3510 "-treedepth value color tree depth",
3511 "-transparent-color color",
3512 " transparent color",
3513 "-undercolor color annotation bounding box color",
3514 "-units type the units of image resolution",
3515 "-verbose print detailed information about the image",
3516 "-view FlashPix viewing transforms",
3517 "-virtual-pixel method",
3518 " virtual pixel access method",
3519 "-weight type render text with this font weight",
3520 "-white-point point chromaticity white point",
3525 "-delete indexes delete the image from the image sequence",
3526 "-duplicate count,indexes",
3527 " duplicate an image one or more times",
3528 "-insert index insert last image into the image sequence",
3529 "-reverse reverse image sequence",
3530 "-swap indexes swap two images in the image sequence",
3537 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3538 (void) printf("Copyright: %s\n",GetMagickCopyright());
3539 (void) printf("Features: %s\n\n",GetMagickFeatures());
3540 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3542 (void) printf("\nImage Settings:\n");
3543 for (p=settings; *p != (char *) NULL; p++)
3544 (void) printf(" %s\n",*p);
3545 (void) printf("\nImage Operators:\n");
3546 for (p=operators; *p != (char *) NULL; p++)
3547 (void) printf(" %s\n",*p);
3548 (void) printf("\nImage Sequence Operators:\n");
3549 for (p=sequence_operators; *p != (char *) NULL; p++)
3550 (void) printf(" %s\n",*p);
3551 (void) printf("\nImage Stack Operators:\n");
3552 for (p=stack_operators; *p != (char *) NULL; p++)
3553 (void) printf(" %s\n",*p);
3554 (void) printf("\nMiscellaneous Options:\n");
3555 for (p=miscellaneous; *p != (char *) NULL; p++)
3556 (void) printf(" %s\n",*p);
3558 "\nBy default, the image format of `file' is determined by its magic\n");
3560 "number. To specify a particular image format, precede the filename\n");
3562 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3564 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3565 (void) printf("'-' for standard input or output.\n");
3566 return(MagickFalse);
3569 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3570 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3572 #define DestroyMogrify() \
3574 if (format != (char *) NULL) \
3575 format=DestroyString(format); \
3576 if (path != (char *) NULL) \
3577 path=DestroyString(path); \
3578 DestroyImageStack(); \
3579 for (i=0; i < (ssize_t) argc; i++) \
3580 argv[i]=DestroyString(argv[i]); \
3581 argv=(char **) RelinquishMagickMemory(argv); \
3583 #define ThrowMogrifyException(asperity,tag,option) \
3585 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3588 return(MagickFalse); \
3590 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3592 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3593 "InvalidArgument","`%s': %s",argument,option); \
3595 return(MagickFalse); \
3607 image_stack[MaxImageStackDepth+1];
3615 respect_parenthesis;
3630 assert(image_info != (ImageInfo *) NULL);
3631 assert(image_info->signature == MagickSignature);
3632 if (image_info->debug != MagickFalse)
3633 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3634 assert(exception != (ExceptionInfo *) NULL);
3638 if ((LocaleCompare("version",option+1) == 0) ||
3639 (LocaleCompare("-version",option+1) == 0))
3641 (void) FormatLocaleFile(stdout,"Version: %s\n",
3642 GetMagickVersion((size_t *) NULL));
3643 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3644 GetMagickCopyright());
3645 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3646 GetMagickFeatures());
3647 return(MagickFalse);
3651 return(MogrifyUsage());
3652 format=(char *) NULL;
3654 global_colormap=MagickFalse;
3658 option=(char *) NULL;
3660 respect_parenthesis=MagickFalse;
3665 ReadCommandlLine(argc,&argv);
3666 status=ExpandFilenames(&argc,&argv);
3667 if (status == MagickFalse)
3668 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3669 GetExceptionMessage(errno));
3670 for (i=1; i < (ssize_t) argc; i++)
3673 if (LocaleCompare(option,"(") == 0)
3675 FireImageStack(MagickFalse,MagickTrue,pend);
3676 if (k == MaxImageStackDepth)
3677 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3682 if (LocaleCompare(option,")") == 0)
3684 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3686 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3690 if (IsCommandOption(option) == MagickFalse)
3693 backup_filename[MaxTextExtent],
3700 Option is a file name: begin by reading image from specified file.
3702 FireImageStack(MagickFalse,MagickFalse,pend);
3704 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3706 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3707 images=ReadImages(image_info,exception);
3708 status&=(images != (Image *) NULL) &&
3709 (exception->severity < ErrorException);
3710 if (images == (Image *) NULL)
3712 if (format != (char *) NULL)
3713 (void) CopyMagickString(images->filename,images->magick_filename,
3715 if (path != (char *) NULL)
3717 GetPathComponent(option,TailPath,filename);
3718 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3719 path,*DirectorySeparator,filename);
3721 if (format != (char *) NULL)
3722 AppendImageFormat(format,images->filename);
3723 AppendImageStack(images);
3724 FinalizeImageSettings(image_info,image,MagickFalse);
3725 if (global_colormap != MagickFalse)
3730 quantize_info=AcquireQuantizeInfo(image_info);
3731 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3732 quantize_info=DestroyQuantizeInfo(quantize_info);
3734 *backup_filename='\0';
3735 if ((LocaleCompare(image->filename,"-") != 0) &&
3736 (IsPathWritable(image->filename) != MagickFalse))
3742 Rename image file as backup.
3744 (void) CopyMagickString(backup_filename,image->filename,
3746 for (i=0; i < 6; i++)
3748 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3749 if (IsPathAccessible(backup_filename) == MagickFalse)
3752 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3753 (rename_utf8(image->filename,backup_filename) != 0))
3754 *backup_filename='\0';
3757 Write transmogrified image to disk.
3759 image_info->synchronize=MagickTrue;
3760 status&=WriteImages(image_info,image,image->filename,exception);
3761 if ((status == MagickFalse) && (*backup_filename != '\0'))
3762 (void) remove_utf8(backup_filename);
3763 RemoveAllImageStack();
3766 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3767 switch (*(option+1))
3771 if (LocaleCompare("adaptive-blur",option+1) == 0)
3774 if (i == (ssize_t) argc)
3775 ThrowMogrifyException(OptionError,"MissingArgument",option);
3776 if (IsGeometry(argv[i]) == MagickFalse)
3777 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3780 if (LocaleCompare("adaptive-resize",option+1) == 0)
3783 if (i == (ssize_t) argc)
3784 ThrowMogrifyException(OptionError,"MissingArgument",option);
3785 if (IsGeometry(argv[i]) == MagickFalse)
3786 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3789 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3792 if (i == (ssize_t) argc)
3793 ThrowMogrifyException(OptionError,"MissingArgument",option);
3794 if (IsGeometry(argv[i]) == MagickFalse)
3795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3798 if (LocaleCompare("affine",option+1) == 0)
3803 if (i == (ssize_t) argc)
3804 ThrowMogrifyException(OptionError,"MissingArgument",option);
3807 if (LocaleCompare("alpha",option+1) == 0)
3815 if (i == (ssize_t) argc)
3816 ThrowMogrifyException(OptionError,"MissingArgument",option);
3817 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3819 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3823 if (LocaleCompare("annotate",option+1) == 0)
3828 if (i == (ssize_t) argc)
3829 ThrowMogrifyException(OptionError,"MissingArgument",option);
3830 if (IsGeometry(argv[i]) == MagickFalse)
3831 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3832 if (i == (ssize_t) argc)
3833 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (LocaleCompare("antialias",option+1) == 0)
3839 if (LocaleCompare("append",option+1) == 0)
3841 if (LocaleCompare("attenuate",option+1) == 0)
3846 if (i == (ssize_t) (argc-1))
3847 ThrowMogrifyException(OptionError,"MissingArgument",option);
3848 if (IsGeometry(argv[i]) == MagickFalse)
3849 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3852 if (LocaleCompare("authenticate",option+1) == 0)
3857 if (i == (ssize_t) argc)
3858 ThrowMogrifyException(OptionError,"MissingArgument",option);
3861 if (LocaleCompare("auto-gamma",option+1) == 0)
3863 if (LocaleCompare("auto-level",option+1) == 0)
3865 if (LocaleCompare("auto-orient",option+1) == 0)
3867 if (LocaleCompare("average",option+1) == 0)
3869 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3873 if (LocaleCompare("background",option+1) == 0)
3878 if (i == (ssize_t) argc)
3879 ThrowMogrifyException(OptionError,"MissingArgument",option);
3882 if (LocaleCompare("bias",option+1) == 0)
3887 if (i == (ssize_t) (argc-1))
3888 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 if (IsGeometry(argv[i]) == MagickFalse)
3890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3893 if (LocaleCompare("black-point-compensation",option+1) == 0)
3895 if (LocaleCompare("black-threshold",option+1) == 0)
3900 if (i == (ssize_t) argc)
3901 ThrowMogrifyException(OptionError,"MissingArgument",option);
3902 if (IsGeometry(argv[i]) == MagickFalse)
3903 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3906 if (LocaleCompare("blue-primary",option+1) == 0)
3911 if (i == (ssize_t) argc)
3912 ThrowMogrifyException(OptionError,"MissingArgument",option);
3913 if (IsGeometry(argv[i]) == MagickFalse)
3914 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3917 if (LocaleCompare("blue-shift",option+1) == 0)
3920 if (i == (ssize_t) argc)
3921 ThrowMogrifyException(OptionError,"MissingArgument",option);
3922 if (IsGeometry(argv[i]) == MagickFalse)
3923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3926 if (LocaleCompare("blur",option+1) == 0)
3929 if (i == (ssize_t) argc)
3930 ThrowMogrifyException(OptionError,"MissingArgument",option);
3931 if (IsGeometry(argv[i]) == MagickFalse)
3932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3935 if (LocaleCompare("border",option+1) == 0)
3940 if (i == (ssize_t) argc)
3941 ThrowMogrifyException(OptionError,"MissingArgument",option);
3942 if (IsGeometry(argv[i]) == MagickFalse)
3943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3946 if (LocaleCompare("bordercolor",option+1) == 0)
3951 if (i == (ssize_t) argc)
3952 ThrowMogrifyException(OptionError,"MissingArgument",option);
3955 if (LocaleCompare("box",option+1) == 0)
3960 if (i == (ssize_t) argc)
3961 ThrowMogrifyException(OptionError,"MissingArgument",option);
3964 if (LocaleCompare("brightness-contrast",option+1) == 0)
3967 if (i == (ssize_t) argc)
3968 ThrowMogrifyException(OptionError,"MissingArgument",option);
3969 if (IsGeometry(argv[i]) == MagickFalse)
3970 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3973 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3977 if (LocaleCompare("cache",option+1) == 0)
3982 if (i == (ssize_t) argc)
3983 ThrowMogrifyException(OptionError,"MissingArgument",option);
3984 if (IsGeometry(argv[i]) == MagickFalse)
3985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3988 if (LocaleCompare("caption",option+1) == 0)
3993 if (i == (ssize_t) argc)
3994 ThrowMogrifyException(OptionError,"MissingArgument",option);
3997 if (LocaleCompare("channel",option+1) == 0)
4005 if (i == (ssize_t) (argc-1))
4006 ThrowMogrifyException(OptionError,"MissingArgument",option);
4007 channel=ParseChannelOption(argv[i]);
4009 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4013 if (LocaleCompare("cdl",option+1) == 0)
4018 if (i == (ssize_t) (argc-1))
4019 ThrowMogrifyException(OptionError,"MissingArgument",option);
4022 if (LocaleCompare("charcoal",option+1) == 0)
4027 if (i == (ssize_t) argc)
4028 ThrowMogrifyException(OptionError,"MissingArgument",option);
4029 if (IsGeometry(argv[i]) == MagickFalse)
4030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4033 if (LocaleCompare("chop",option+1) == 0)
4038 if (i == (ssize_t) argc)
4039 ThrowMogrifyException(OptionError,"MissingArgument",option);
4040 if (IsGeometry(argv[i]) == MagickFalse)
4041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4044 if (LocaleCompare("clamp",option+1) == 0)
4046 if (LocaleCompare("clip",option+1) == 0)
4048 if (LocaleCompare("clip-mask",option+1) == 0)
4053 if (i == (ssize_t) argc)
4054 ThrowMogrifyException(OptionError,"MissingArgument",option);
4057 if (LocaleCompare("clut",option+1) == 0)
4059 if (LocaleCompare("coalesce",option+1) == 0)
4061 if (LocaleCompare("colorize",option+1) == 0)
4066 if (i == (ssize_t) argc)
4067 ThrowMogrifyException(OptionError,"MissingArgument",option);
4068 if (IsGeometry(argv[i]) == MagickFalse)
4069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4072 if (LocaleCompare("color-matrix",option+1) == 0)
4080 if (i == (ssize_t) (argc-1))
4081 ThrowMogrifyException(OptionError,"MissingArgument",option);
4082 kernel_info=AcquireKernelInfo(argv[i]);
4083 if (kernel_info == (KernelInfo *) NULL)
4084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4085 kernel_info=DestroyKernelInfo(kernel_info);
4088 if (LocaleCompare("colors",option+1) == 0)
4093 if (i == (ssize_t) argc)
4094 ThrowMogrifyException(OptionError,"MissingArgument",option);
4095 if (IsGeometry(argv[i]) == MagickFalse)
4096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4099 if (LocaleCompare("colorspace",option+1) == 0)
4107 if (i == (ssize_t) argc)
4108 ThrowMogrifyException(OptionError,"MissingArgument",option);
4109 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4112 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4116 if (LocaleCompare("combine",option+1) == 0)
4118 if (LocaleCompare("comment",option+1) == 0)
4123 if (i == (ssize_t) argc)
4124 ThrowMogrifyException(OptionError,"MissingArgument",option);
4127 if (LocaleCompare("composite",option+1) == 0)
4129 if (LocaleCompare("compress",option+1) == 0)
4137 if (i == (ssize_t) argc)
4138 ThrowMogrifyException(OptionError,"MissingArgument",option);
4139 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4142 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4146 if (LocaleCompare("concurrent",option+1) == 0)
4148 if (LocaleCompare("contrast",option+1) == 0)
4150 if (LocaleCompare("contrast-stretch",option+1) == 0)
4153 if (i == (ssize_t) argc)
4154 ThrowMogrifyException(OptionError,"MissingArgument",option);
4155 if (IsGeometry(argv[i]) == MagickFalse)
4156 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4159 if (LocaleCompare("convolve",option+1) == 0)
4167 if (i == (ssize_t) argc)
4168 ThrowMogrifyException(OptionError,"MissingArgument",option);
4169 kernel_info=AcquireKernelInfo(argv[i]);
4170 if (kernel_info == (KernelInfo *) NULL)
4171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172 kernel_info=DestroyKernelInfo(kernel_info);
4175 if (LocaleCompare("crop",option+1) == 0)
4180 if (i == (ssize_t) argc)
4181 ThrowMogrifyException(OptionError,"MissingArgument",option);
4182 if (IsGeometry(argv[i]) == MagickFalse)
4183 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4186 if (LocaleCompare("cycle",option+1) == 0)
4191 if (i == (ssize_t) argc)
4192 ThrowMogrifyException(OptionError,"MissingArgument",option);
4193 if (IsGeometry(argv[i]) == MagickFalse)
4194 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4197 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4201 if (LocaleCompare("decipher",option+1) == 0)
4206 if (i == (ssize_t) (argc-1))
4207 ThrowMogrifyException(OptionError,"MissingArgument",option);
4210 if (LocaleCompare("deconstruct",option+1) == 0)
4212 if (LocaleCompare("debug",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4222 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4224 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4226 (void) SetLogEventMask(argv[i]);
4229 if (LocaleCompare("define",option+1) == 0)
4232 if (i == (ssize_t) argc)
4233 ThrowMogrifyException(OptionError,"MissingArgument",option);
4239 define=GetImageOption(image_info,argv[i]);
4240 if (define == (const char *) NULL)
4241 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4246 if (LocaleCompare("delay",option+1) == 0)
4251 if (i == (ssize_t) argc)
4252 ThrowMogrifyException(OptionError,"MissingArgument",option);
4253 if (IsGeometry(argv[i]) == MagickFalse)
4254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4257 if (LocaleCompare("delete",option+1) == 0)
4262 if (i == (ssize_t) (argc-1))
4263 ThrowMogrifyException(OptionError,"MissingArgument",option);
4264 if (IsGeometry(argv[i]) == MagickFalse)
4265 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4268 if (LocaleCompare("density",option+1) == 0)
4273 if (i == (ssize_t) argc)
4274 ThrowMogrifyException(OptionError,"MissingArgument",option);
4275 if (IsGeometry(argv[i]) == MagickFalse)
4276 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4279 if (LocaleCompare("depth",option+1) == 0)
4284 if (i == (ssize_t) argc)
4285 ThrowMogrifyException(OptionError,"MissingArgument",option);
4286 if (IsGeometry(argv[i]) == MagickFalse)
4287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4290 if (LocaleCompare("deskew",option+1) == 0)
4295 if (i == (ssize_t) argc)
4296 ThrowMogrifyException(OptionError,"MissingArgument",option);
4297 if (IsGeometry(argv[i]) == MagickFalse)
4298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4301 if (LocaleCompare("despeckle",option+1) == 0)
4303 if (LocaleCompare("dft",option+1) == 0)
4305 if (LocaleCompare("direction",option+1) == 0)
4313 if (i == (ssize_t) argc)
4314 ThrowMogrifyException(OptionError,"MissingArgument",option);
4315 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4318 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4322 if (LocaleCompare("display",option+1) == 0)
4327 if (i == (ssize_t) argc)
4328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4331 if (LocaleCompare("dispose",option+1) == 0)
4339 if (i == (ssize_t) argc)
4340 ThrowMogrifyException(OptionError,"MissingArgument",option);
4341 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4343 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4347 if (LocaleCompare("distort",option+1) == 0)
4353 if (i == (ssize_t) argc)
4354 ThrowMogrifyException(OptionError,"MissingArgument",option);
4355 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4357 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4360 if (i == (ssize_t) (argc-1))
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4364 if (LocaleCompare("dither",option+1) == 0)
4372 if (i == (ssize_t) argc)
4373 ThrowMogrifyException(OptionError,"MissingArgument",option);
4374 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4376 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4380 if (LocaleCompare("draw",option+1) == 0)
4385 if (i == (ssize_t) argc)
4386 ThrowMogrifyException(OptionError,"MissingArgument",option);
4389 if (LocaleCompare("duplicate",option+1) == 0)
4394 if (i == (ssize_t) (argc-1))
4395 ThrowMogrifyException(OptionError,"MissingArgument",option);
4396 if (IsGeometry(argv[i]) == MagickFalse)
4397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4400 if (LocaleCompare("duration",option+1) == 0)
4405 if (i == (ssize_t) (argc-1))
4406 ThrowMogrifyException(OptionError,"MissingArgument",option);
4407 if (IsGeometry(argv[i]) == MagickFalse)
4408 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4411 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4415 if (LocaleCompare("edge",option+1) == 0)
4420 if (i == (ssize_t) argc)
4421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (IsGeometry(argv[i]) == MagickFalse)
4423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4426 if (LocaleCompare("emboss",option+1) == 0)
4431 if (i == (ssize_t) argc)
4432 ThrowMogrifyException(OptionError,"MissingArgument",option);
4433 if (IsGeometry(argv[i]) == MagickFalse)
4434 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4437 if (LocaleCompare("encipher",option+1) == 0)
4442 if (i == (ssize_t) argc)
4443 ThrowMogrifyException(OptionError,"MissingArgument",option);
4446 if (LocaleCompare("encoding",option+1) == 0)
4451 if (i == (ssize_t) argc)
4452 ThrowMogrifyException(OptionError,"MissingArgument",option);
4455 if (LocaleCompare("endian",option+1) == 0)
4463 if (i == (ssize_t) argc)
4464 ThrowMogrifyException(OptionError,"MissingArgument",option);
4465 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4467 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4471 if (LocaleCompare("enhance",option+1) == 0)
4473 if (LocaleCompare("equalize",option+1) == 0)
4475 if (LocaleCompare("evaluate",option+1) == 0)
4483 if (i == (ssize_t) argc)
4484 ThrowMogrifyException(OptionError,"MissingArgument",option);
4485 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4487 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4490 if (i == (ssize_t) (argc-1))
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 if (IsGeometry(argv[i]) == MagickFalse)
4493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4496 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4504 if (i == (ssize_t) argc)
4505 ThrowMogrifyException(OptionError,"MissingArgument",option);
4506 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4508 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4512 if (LocaleCompare("extent",option+1) == 0)
4517 if (i == (ssize_t) argc)
4518 ThrowMogrifyException(OptionError,"MissingArgument",option);
4519 if (IsGeometry(argv[i]) == MagickFalse)
4520 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4523 if (LocaleCompare("extract",option+1) == 0)
4528 if (i == (ssize_t) argc)
4529 ThrowMogrifyException(OptionError,"MissingArgument",option);
4530 if (IsGeometry(argv[i]) == MagickFalse)
4531 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4534 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4538 if (LocaleCompare("family",option+1) == 0)
4543 if (i == (ssize_t) (argc-1))
4544 ThrowMogrifyException(OptionError,"MissingArgument",option);
4547 if (LocaleCompare("fill",option+1) == 0)
4552 if (i == (ssize_t) argc)
4553 ThrowMogrifyException(OptionError,"MissingArgument",option);
4556 if (LocaleCompare("filter",option+1) == 0)
4564 if (i == (ssize_t) argc)
4565 ThrowMogrifyException(OptionError,"MissingArgument",option);
4566 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4568 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4572 if (LocaleCompare("flatten",option+1) == 0)
4574 if (LocaleCompare("flip",option+1) == 0)
4576 if (LocaleCompare("flop",option+1) == 0)
4578 if (LocaleCompare("floodfill",option+1) == 0)
4583 if (i == (ssize_t) argc)
4584 ThrowMogrifyException(OptionError,"MissingArgument",option);
4585 if (IsGeometry(argv[i]) == MagickFalse)
4586 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4588 if (i == (ssize_t) argc)
4589 ThrowMogrifyException(OptionError,"MissingArgument",option);
4592 if (LocaleCompare("font",option+1) == 0)
4597 if (i == (ssize_t) argc)
4598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4601 if (LocaleCompare("format",option+1) == 0)
4603 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4604 (void) CloneString(&format,(char *) NULL);
4608 if (i == (ssize_t) argc)
4609 ThrowMogrifyException(OptionError,"MissingArgument",option);
4610 (void) CloneString(&format,argv[i]);
4611 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4612 (void) ConcatenateMagickString(image_info->filename,":",
4614 (void) SetImageInfo(image_info,0,exception);
4615 if (*image_info->magick == '\0')
4616 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4620 if (LocaleCompare("frame",option+1) == 0)
4625 if (i == (ssize_t) argc)
4626 ThrowMogrifyException(OptionError,"MissingArgument",option);
4627 if (IsGeometry(argv[i]) == MagickFalse)
4628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4631 if (LocaleCompare("function",option+1) == 0)
4639 if (i == (ssize_t) argc)
4640 ThrowMogrifyException(OptionError,"MissingArgument",option);
4641 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4643 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4645 if (i == (ssize_t) (argc-1))
4646 ThrowMogrifyException(OptionError,"MissingArgument",option);
4649 if (LocaleCompare("fuzz",option+1) == 0)
4654 if (i == (ssize_t) argc)
4655 ThrowMogrifyException(OptionError,"MissingArgument",option);
4656 if (IsGeometry(argv[i]) == MagickFalse)
4657 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4660 if (LocaleCompare("fx",option+1) == 0)
4665 if (i == (ssize_t) (argc-1))
4666 ThrowMogrifyException(OptionError,"MissingArgument",option);
4669 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4673 if (LocaleCompare("gamma",option+1) == 0)
4676 if (i == (ssize_t) argc)
4677 ThrowMogrifyException(OptionError,"MissingArgument",option);
4678 if (IsGeometry(argv[i]) == MagickFalse)
4679 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4682 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4683 (LocaleCompare("gaussian",option+1) == 0))
4686 if (i == (ssize_t) argc)
4687 ThrowMogrifyException(OptionError,"MissingArgument",option);
4688 if (IsGeometry(argv[i]) == MagickFalse)
4689 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4692 if (LocaleCompare("geometry",option+1) == 0)
4697 if (i == (ssize_t) argc)
4698 ThrowMogrifyException(OptionError,"MissingArgument",option);
4699 if (IsGeometry(argv[i]) == MagickFalse)
4700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4703 if (LocaleCompare("gravity",option+1) == 0)
4711 if (i == (ssize_t) argc)
4712 ThrowMogrifyException(OptionError,"MissingArgument",option);
4713 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4715 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4719 if (LocaleCompare("green-primary",option+1) == 0)
4724 if (i == (ssize_t) argc)
4725 ThrowMogrifyException(OptionError,"MissingArgument",option);
4726 if (IsGeometry(argv[i]) == MagickFalse)
4727 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4730 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4734 if (LocaleCompare("hald-clut",option+1) == 0)
4736 if ((LocaleCompare("help",option+1) == 0) ||
4737 (LocaleCompare("-help",option+1) == 0))
4738 return(MogrifyUsage());
4739 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4743 if (LocaleCompare("identify",option+1) == 0)
4745 if (LocaleCompare("idft",option+1) == 0)
4747 if (LocaleCompare("implode",option+1) == 0)
4752 if (i == (ssize_t) argc)
4753 ThrowMogrifyException(OptionError,"MissingArgument",option);
4754 if (IsGeometry(argv[i]) == MagickFalse)
4755 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4758 if (LocaleCompare("intent",option+1) == 0)
4766 if (i == (ssize_t) (argc-1))
4767 ThrowMogrifyException(OptionError,"MissingArgument",option);
4768 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4770 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4774 if (LocaleCompare("interlace",option+1) == 0)
4782 if (i == (ssize_t) argc)
4783 ThrowMogrifyException(OptionError,"MissingArgument",option);
4784 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4787 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4791 if (LocaleCompare("interline-spacing",option+1) == 0)
4796 if (i == (ssize_t) (argc-1))
4797 ThrowMogrifyException(OptionError,"MissingArgument",option);
4798 if (IsGeometry(argv[i]) == MagickFalse)
4799 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4802 if (LocaleCompare("interpolate",option+1) == 0)
4810 if (i == (ssize_t) argc)
4811 ThrowMogrifyException(OptionError,"MissingArgument",option);
4812 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4814 if (interpolate < 0)
4815 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4819 if (LocaleCompare("interword-spacing",option+1) == 0)
4824 if (i == (ssize_t) (argc-1))
4825 ThrowMogrifyException(OptionError,"MissingArgument",option);
4826 if (IsGeometry(argv[i]) == MagickFalse)
4827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4830 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4834 if (LocaleCompare("kerning",option+1) == 0)
4839 if (i == (ssize_t) (argc-1))
4840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4845 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4849 if (LocaleCompare("label",option+1) == 0)
4854 if (i == (ssize_t) argc)
4855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4858 if (LocaleCompare("lat",option+1) == 0)
4863 if (i == (ssize_t) argc)
4864 ThrowMogrifyException(OptionError,"MissingArgument",option);
4865 if (IsGeometry(argv[i]) == MagickFalse)
4866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4868 if (LocaleCompare("layers",option+1) == 0)
4876 if (i == (ssize_t) (argc-1))
4877 ThrowMogrifyException(OptionError,"MissingArgument",option);
4878 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4880 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4884 if (LocaleCompare("level",option+1) == 0)
4887 if (i == (ssize_t) argc)
4888 ThrowMogrifyException(OptionError,"MissingArgument",option);
4889 if (IsGeometry(argv[i]) == MagickFalse)
4890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4893 if (LocaleCompare("level-colors",option+1) == 0)
4896 if (i == (ssize_t) argc)
4897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4900 if (LocaleCompare("linewidth",option+1) == 0)
4905 if (i == (ssize_t) argc)
4906 ThrowMogrifyException(OptionError,"MissingArgument",option);
4907 if (IsGeometry(argv[i]) == MagickFalse)
4908 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4911 if (LocaleCompare("limit",option+1) == 0)
4925 if (i == (ssize_t) argc)
4926 ThrowMogrifyException(OptionError,"MissingArgument",option);
4927 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4930 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4933 if (i == (ssize_t) argc)
4934 ThrowMogrifyException(OptionError,"MissingArgument",option);
4935 value=InterpretLocaleValue(argv[i],&p);
4937 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4941 if (LocaleCompare("liquid-rescale",option+1) == 0)
4944 if (i == (ssize_t) argc)
4945 ThrowMogrifyException(OptionError,"MissingArgument",option);
4946 if (IsGeometry(argv[i]) == MagickFalse)
4947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4950 if (LocaleCompare("list",option+1) == 0)
4958 if (i == (ssize_t) argc)
4959 ThrowMogrifyException(OptionError,"MissingArgument",option);
4960 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4962 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4963 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4965 return(status != 0 ? MagickFalse : MagickTrue);
4967 if (LocaleCompare("log",option+1) == 0)
4972 if ((i == (ssize_t) argc) ||
4973 (strchr(argv[i],'%') == (char *) NULL))
4974 ThrowMogrifyException(OptionError,"MissingArgument",option);
4977 if (LocaleCompare("loop",option+1) == 0)
4982 if (i == (ssize_t) argc)
4983 ThrowMogrifyException(OptionError,"MissingArgument",option);
4984 if (IsGeometry(argv[i]) == MagickFalse)
4985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4988 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4992 if (LocaleCompare("map",option+1) == 0)
4994 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4998 if (i == (ssize_t) argc)
4999 ThrowMogrifyException(OptionError,"MissingArgument",option);
5002 if (LocaleCompare("mask",option+1) == 0)
5007 if (i == (ssize_t) argc)
5008 ThrowMogrifyException(OptionError,"MissingArgument",option);
5011 if (LocaleCompare("matte",option+1) == 0)
5013 if (LocaleCompare("mattecolor",option+1) == 0)
5018 if (i == (ssize_t) argc)
5019 ThrowMogrifyException(OptionError,"MissingArgument",option);
5022 if (LocaleCompare("maximum",option+1) == 0)
5024 if (LocaleCompare("minimum",option+1) == 0)
5026 if (LocaleCompare("modulate",option+1) == 0)
5031 if (i == (ssize_t) argc)
5032 ThrowMogrifyException(OptionError,"MissingArgument",option);
5033 if (IsGeometry(argv[i]) == MagickFalse)
5034 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5037 if (LocaleCompare("median",option+1) == 0)
5042 if (i == (ssize_t) argc)
5043 ThrowMogrifyException(OptionError,"MissingArgument",option);
5044 if (IsGeometry(argv[i]) == MagickFalse)
5045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5048 if (LocaleCompare("mode",option+1) == 0)
5053 if (i == (ssize_t) argc)
5054 ThrowMogrifyException(OptionError,"MissingArgument",option);
5055 if (IsGeometry(argv[i]) == MagickFalse)
5056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5059 if (LocaleCompare("monitor",option+1) == 0)
5061 if (LocaleCompare("monochrome",option+1) == 0)
5063 if (LocaleCompare("morph",option+1) == 0)
5068 if (i == (ssize_t) (argc-1))
5069 ThrowMogrifyException(OptionError,"MissingArgument",option);
5070 if (IsGeometry(argv[i]) == MagickFalse)
5071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5074 if (LocaleCompare("morphology",option+1) == 0)
5077 token[MaxTextExtent];
5086 if (i == (ssize_t) argc)
5087 ThrowMogrifyException(OptionError,"MissingArgument",option);
5088 GetMagickToken(argv[i],NULL,token);
5089 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5091 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5094 if (i == (ssize_t) (argc-1))
5095 ThrowMogrifyException(OptionError,"MissingArgument",option);
5096 kernel_info=AcquireKernelInfo(argv[i]);
5097 if (kernel_info == (KernelInfo *) NULL)
5098 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5099 kernel_info=DestroyKernelInfo(kernel_info);
5102 if (LocaleCompare("mosaic",option+1) == 0)
5104 if (LocaleCompare("motion-blur",option+1) == 0)
5109 if (i == (ssize_t) argc)
5110 ThrowMogrifyException(OptionError,"MissingArgument",option);
5111 if (IsGeometry(argv[i]) == MagickFalse)
5112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5115 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5119 if (LocaleCompare("negate",option+1) == 0)
5121 if (LocaleCompare("noise",option+1) == 0)
5124 if (i == (ssize_t) argc)
5125 ThrowMogrifyException(OptionError,"MissingArgument",option);
5131 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5133 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5137 if (IsGeometry(argv[i]) == MagickFalse)
5138 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5141 if (LocaleCompare("noop",option+1) == 0)
5143 if (LocaleCompare("normalize",option+1) == 0)
5145 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5149 if (LocaleCompare("opaque",option+1) == 0)
5152 if (i == (ssize_t) argc)
5153 ThrowMogrifyException(OptionError,"MissingArgument",option);
5156 if (LocaleCompare("ordered-dither",option+1) == 0)
5161 if (i == (ssize_t) argc)
5162 ThrowMogrifyException(OptionError,"MissingArgument",option);
5165 if (LocaleCompare("orient",option+1) == 0)
5170 orientation=UndefinedOrientation;
5174 if (i == (ssize_t) (argc-1))
5175 ThrowMogrifyException(OptionError,"MissingArgument",option);
5176 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5178 if (orientation < 0)
5179 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5183 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5187 if (LocaleCompare("page",option+1) == 0)
5192 if (i == (ssize_t) argc)
5193 ThrowMogrifyException(OptionError,"MissingArgument",option);
5196 if (LocaleCompare("paint",option+1) == 0)
5201 if (i == (ssize_t) argc)
5202 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 if (IsGeometry(argv[i]) == MagickFalse)
5204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5207 if (LocaleCompare("path",option+1) == 0)
5209 (void) CloneString(&path,(char *) NULL);
5213 if (i == (ssize_t) argc)
5214 ThrowMogrifyException(OptionError,"MissingArgument",option);
5215 (void) CloneString(&path,argv[i]);
5218 if (LocaleCompare("pointsize",option+1) == 0)
5223 if (i == (ssize_t) argc)
5224 ThrowMogrifyException(OptionError,"MissingArgument",option);
5225 if (IsGeometry(argv[i]) == MagickFalse)
5226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5229 if (LocaleCompare("polaroid",option+1) == 0)
5234 if (i == (ssize_t) argc)
5235 ThrowMogrifyException(OptionError,"MissingArgument",option);
5236 if (IsGeometry(argv[i]) == MagickFalse)
5237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5240 if (LocaleCompare("posterize",option+1) == 0)
5245 if (i == (ssize_t) argc)
5246 ThrowMogrifyException(OptionError,"MissingArgument",option);
5247 if (IsGeometry(argv[i]) == MagickFalse)
5248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5251 if (LocaleCompare("precision",option+1) == 0)
5256 if (i == (ssize_t) argc)
5257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5258 if (IsGeometry(argv[i]) == MagickFalse)
5259 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5262 if (LocaleCompare("print",option+1) == 0)
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,"MissingArgument",option);
5271 if (LocaleCompare("process",option+1) == 0)
5276 if (i == (ssize_t) (argc-1))
5277 ThrowMogrifyException(OptionError,"MissingArgument",option);
5280 if (LocaleCompare("profile",option+1) == 0)
5283 if (i == (ssize_t) argc)
5284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5291 if (LocaleCompare("quality",option+1) == 0)
5296 if (i == (ssize_t) argc)
5297 ThrowMogrifyException(OptionError,"MissingArgument",option);
5298 if (IsGeometry(argv[i]) == MagickFalse)
5299 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5302 if (LocaleCompare("quantize",option+1) == 0)
5310 if (i == (ssize_t) (argc-1))
5311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5312 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5315 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5319 if (LocaleCompare("quiet",option+1) == 0)
5321 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5325 if (LocaleCompare("radial-blur",option+1) == 0)
5328 if (i == (ssize_t) argc)
5329 ThrowMogrifyException(OptionError,"MissingArgument",option);
5330 if (IsGeometry(argv[i]) == MagickFalse)
5331 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5334 if (LocaleCompare("raise",option+1) == 0)
5337 if (i == (ssize_t) argc)
5338 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 if (IsGeometry(argv[i]) == MagickFalse)
5340 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5343 if (LocaleCompare("random-threshold",option+1) == 0)
5348 if (i == (ssize_t) argc)
5349 ThrowMogrifyException(OptionError,"MissingArgument",option);
5350 if (IsGeometry(argv[i]) == MagickFalse)
5351 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5354 if (LocaleCompare("recolor",option+1) == 0)
5359 if (i == (ssize_t) (argc-1))
5360 ThrowMogrifyException(OptionError,"MissingArgument",option);
5361 if (IsGeometry(argv[i]) == MagickFalse)
5362 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5365 if (LocaleCompare("red-primary",option+1) == 0)
5370 if (i == (ssize_t) argc)
5371 ThrowMogrifyException(OptionError,"MissingArgument",option);
5372 if (IsGeometry(argv[i]) == MagickFalse)
5373 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5375 if (LocaleCompare("regard-warnings",option+1) == 0)
5377 if (LocaleCompare("region",option+1) == 0)
5382 if (i == (ssize_t) argc)
5383 ThrowMogrifyException(OptionError,"MissingArgument",option);
5384 if (IsGeometry(argv[i]) == MagickFalse)
5385 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5388 if (LocaleCompare("remap",option+1) == 0)
5393 if (i == (ssize_t) (argc-1))
5394 ThrowMogrifyException(OptionError,"MissingArgument",option);
5397 if (LocaleCompare("render",option+1) == 0)
5399 if (LocaleCompare("repage",option+1) == 0)
5404 if (i == (ssize_t) argc)
5405 ThrowMogrifyException(OptionError,"MissingArgument",option);
5406 if (IsGeometry(argv[i]) == MagickFalse)
5407 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5410 if (LocaleCompare("resample",option+1) == 0)
5415 if (i == (ssize_t) argc)
5416 ThrowMogrifyException(OptionError,"MissingArgument",option);
5417 if (IsGeometry(argv[i]) == MagickFalse)
5418 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5421 if (LocaleCompare("resize",option+1) == 0)
5426 if (i == (ssize_t) argc)
5427 ThrowMogrifyException(OptionError,"MissingArgument",option);
5428 if (IsGeometry(argv[i]) == MagickFalse)
5429 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5432 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5434 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5437 if (LocaleCompare("reverse",option+1) == 0)
5439 if (LocaleCompare("roll",option+1) == 0)
5444 if (i == (ssize_t) argc)
5445 ThrowMogrifyException(OptionError,"MissingArgument",option);
5446 if (IsGeometry(argv[i]) == MagickFalse)
5447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5450 if (LocaleCompare("rotate",option+1) == 0)
5453 if (i == (ssize_t) argc)
5454 ThrowMogrifyException(OptionError,"MissingArgument",option);
5455 if (IsGeometry(argv[i]) == MagickFalse)
5456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5459 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5463 if (LocaleCompare("sample",option+1) == 0)
5468 if (i == (ssize_t) argc)
5469 ThrowMogrifyException(OptionError,"MissingArgument",option);
5470 if (IsGeometry(argv[i]) == MagickFalse)
5471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5474 if (LocaleCompare("sampling-factor",option+1) == 0)
5479 if (i == (ssize_t) argc)
5480 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (IsGeometry(argv[i]) == MagickFalse)
5482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5485 if (LocaleCompare("scale",option+1) == 0)
5490 if (i == (ssize_t) argc)
5491 ThrowMogrifyException(OptionError,"MissingArgument",option);
5492 if (IsGeometry(argv[i]) == MagickFalse)
5493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5496 if (LocaleCompare("scene",option+1) == 0)
5501 if (i == (ssize_t) argc)
5502 ThrowMogrifyException(OptionError,"MissingArgument",option);
5503 if (IsGeometry(argv[i]) == MagickFalse)
5504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5507 if (LocaleCompare("seed",option+1) == 0)
5512 if (i == (ssize_t) argc)
5513 ThrowMogrifyException(OptionError,"MissingArgument",option);
5514 if (IsGeometry(argv[i]) == MagickFalse)
5515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5518 if (LocaleCompare("segment",option+1) == 0)
5523 if (i == (ssize_t) argc)
5524 ThrowMogrifyException(OptionError,"MissingArgument",option);
5525 if (IsGeometry(argv[i]) == MagickFalse)
5526 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5529 if (LocaleCompare("selective-blur",option+1) == 0)
5532 if (i == (ssize_t) argc)
5533 ThrowMogrifyException(OptionError,"MissingArgument",option);
5534 if (IsGeometry(argv[i]) == MagickFalse)
5535 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5538 if (LocaleCompare("separate",option+1) == 0)
5540 if (LocaleCompare("sepia-tone",option+1) == 0)
5545 if (i == (ssize_t) argc)
5546 ThrowMogrifyException(OptionError,"MissingArgument",option);
5547 if (IsGeometry(argv[i]) == MagickFalse)
5548 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5551 if (LocaleCompare("set",option+1) == 0)
5554 if (i == (ssize_t) argc)
5555 ThrowMogrifyException(OptionError,"MissingArgument",option);
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5563 if (LocaleCompare("shade",option+1) == 0)
5566 if (i == (ssize_t) argc)
5567 ThrowMogrifyException(OptionError,"MissingArgument",option);
5568 if (IsGeometry(argv[i]) == MagickFalse)
5569 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5572 if (LocaleCompare("shadow",option+1) == 0)
5577 if (i == (ssize_t) argc)
5578 ThrowMogrifyException(OptionError,"MissingArgument",option);
5579 if (IsGeometry(argv[i]) == MagickFalse)
5580 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5583 if (LocaleCompare("sharpen",option+1) == 0)
5586 if (i == (ssize_t) argc)
5587 ThrowMogrifyException(OptionError,"MissingArgument",option);
5588 if (IsGeometry(argv[i]) == MagickFalse)
5589 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5592 if (LocaleCompare("shave",option+1) == 0)
5597 if (i == (ssize_t) argc)
5598 ThrowMogrifyException(OptionError,"MissingArgument",option);
5599 if (IsGeometry(argv[i]) == MagickFalse)
5600 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5603 if (LocaleCompare("shear",option+1) == 0)
5606 if (i == (ssize_t) argc)
5607 ThrowMogrifyException(OptionError,"MissingArgument",option);
5608 if (IsGeometry(argv[i]) == MagickFalse)
5609 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5612 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5615 if (i == (ssize_t) (argc-1))
5616 ThrowMogrifyException(OptionError,"MissingArgument",option);
5617 if (IsGeometry(argv[i]) == MagickFalse)
5618 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5621 if (LocaleCompare("size",option+1) == 0)
5626 if (i == (ssize_t) argc)
5627 ThrowMogrifyException(OptionError,"MissingArgument",option);
5628 if (IsGeometry(argv[i]) == MagickFalse)
5629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5632 if (LocaleCompare("sketch",option+1) == 0)
5637 if (i == (ssize_t) argc)
5638 ThrowMogrifyException(OptionError,"MissingArgument",option);
5639 if (IsGeometry(argv[i]) == MagickFalse)
5640 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5643 if (LocaleCompare("smush",option+1) == 0)
5646 if (i == (ssize_t) argc)
5647 ThrowMogrifyException(OptionError,"MissingArgument",option);
5648 if (IsGeometry(argv[i]) == MagickFalse)
5649 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 if (LocaleCompare("solarize",option+1) == 0)
5658 if (i == (ssize_t) argc)
5659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 if (IsGeometry(argv[i]) == MagickFalse)
5661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5664 if (LocaleCompare("sparse-color",option+1) == 0)
5670 if (i == (ssize_t) argc)
5671 ThrowMogrifyException(OptionError,"MissingArgument",option);
5672 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5674 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5677 if (i == (ssize_t) (argc-1))
5678 ThrowMogrifyException(OptionError,"MissingArgument",option);
5681 if (LocaleCompare("spread",option+1) == 0)
5686 if (i == (ssize_t) argc)
5687 ThrowMogrifyException(OptionError,"MissingArgument",option);
5688 if (IsGeometry(argv[i]) == MagickFalse)
5689 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5692 if (LocaleCompare("statistic",option+1) == 0)
5700 if (i == (ssize_t) argc)
5701 ThrowMogrifyException(OptionError,"MissingArgument",option);
5702 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5704 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5707 if (i == (ssize_t) (argc-1))
5708 ThrowMogrifyException(OptionError,"MissingArgument",option);
5709 if (IsGeometry(argv[i]) == MagickFalse)
5710 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5713 if (LocaleCompare("stretch",option+1) == 0)
5721 if (i == (ssize_t) (argc-1))
5722 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5725 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5729 if (LocaleCompare("strip",option+1) == 0)
5731 if (LocaleCompare("stroke",option+1) == 0)
5736 if (i == (ssize_t) argc)
5737 ThrowMogrifyException(OptionError,"MissingArgument",option);
5740 if (LocaleCompare("strokewidth",option+1) == 0)
5745 if (i == (ssize_t) argc)
5746 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 if (IsGeometry(argv[i]) == MagickFalse)
5748 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5751 if (LocaleCompare("style",option+1) == 0)
5759 if (i == (ssize_t) (argc-1))
5760 ThrowMogrifyException(OptionError,"MissingArgument",option);
5761 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5763 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5767 if (LocaleCompare("swap",option+1) == 0)
5772 if (i == (ssize_t) (argc-1))
5773 ThrowMogrifyException(OptionError,"MissingArgument",option);
5774 if (IsGeometry(argv[i]) == MagickFalse)
5775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5778 if (LocaleCompare("swirl",option+1) == 0)
5783 if (i == (ssize_t) argc)
5784 ThrowMogrifyException(OptionError,"MissingArgument",option);
5785 if (IsGeometry(argv[i]) == MagickFalse)
5786 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5789 if (LocaleCompare("synchronize",option+1) == 0)
5791 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5795 if (LocaleCompare("taint",option+1) == 0)
5797 if (LocaleCompare("texture",option+1) == 0)
5802 if (i == (ssize_t) argc)
5803 ThrowMogrifyException(OptionError,"MissingArgument",option);
5806 if (LocaleCompare("tile",option+1) == 0)
5811 if (i == (ssize_t) (argc-1))
5812 ThrowMogrifyException(OptionError,"MissingArgument",option);
5815 if (LocaleCompare("tile-offset",option+1) == 0)
5820 if (i == (ssize_t) argc)
5821 ThrowMogrifyException(OptionError,"MissingArgument",option);
5822 if (IsGeometry(argv[i]) == MagickFalse)
5823 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 if (LocaleCompare("tint",option+1) == 0)
5831 if (i == (ssize_t) (argc-1))
5832 ThrowMogrifyException(OptionError,"MissingArgument",option);
5833 if (IsGeometry(argv[i]) == MagickFalse)
5834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5837 if (LocaleCompare("transform",option+1) == 0)
5839 if (LocaleCompare("transpose",option+1) == 0)
5841 if (LocaleCompare("transverse",option+1) == 0)
5843 if (LocaleCompare("threshold",option+1) == 0)
5848 if (i == (ssize_t) argc)
5849 ThrowMogrifyException(OptionError,"MissingArgument",option);
5850 if (IsGeometry(argv[i]) == MagickFalse)
5851 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5854 if (LocaleCompare("thumbnail",option+1) == 0)
5859 if (i == (ssize_t) argc)
5860 ThrowMogrifyException(OptionError,"MissingArgument",option);
5861 if (IsGeometry(argv[i]) == MagickFalse)
5862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5865 if (LocaleCompare("transparent",option+1) == 0)
5868 if (i == (ssize_t) argc)
5869 ThrowMogrifyException(OptionError,"MissingArgument",option);
5872 if (LocaleCompare("transparent-color",option+1) == 0)
5877 if (i == (ssize_t) (argc-1))
5878 ThrowMogrifyException(OptionError,"MissingArgument",option);
5881 if (LocaleCompare("treedepth",option+1) == 0)
5886 if (i == (ssize_t) argc)
5887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 if (IsGeometry(argv[i]) == MagickFalse)
5889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5892 if (LocaleCompare("trim",option+1) == 0)
5894 if (LocaleCompare("type",option+1) == 0)
5902 if (i == (ssize_t) argc)
5903 ThrowMogrifyException(OptionError,"MissingArgument",option);
5904 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5906 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5910 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5914 if (LocaleCompare("undercolor",option+1) == 0)
5919 if (i == (ssize_t) argc)
5920 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 if (LocaleCompare("unique-colors",option+1) == 0)
5925 if (LocaleCompare("units",option+1) == 0)
5933 if (i == (ssize_t) argc)
5934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5938 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5942 if (LocaleCompare("unsharp",option+1) == 0)
5945 if (i == (ssize_t) argc)
5946 ThrowMogrifyException(OptionError,"MissingArgument",option);
5947 if (IsGeometry(argv[i]) == MagickFalse)
5948 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5951 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5955 if (LocaleCompare("verbose",option+1) == 0)
5957 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5960 if ((LocaleCompare("version",option+1) == 0) ||
5961 (LocaleCompare("-version",option+1) == 0))
5963 (void) FormatLocaleFile(stdout,"Version: %s\n",
5964 GetMagickVersion((size_t *) NULL));
5965 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5966 GetMagickCopyright());
5967 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5968 GetMagickFeatures());
5971 if (LocaleCompare("view",option+1) == 0)
5976 if (i == (ssize_t) argc)
5977 ThrowMogrifyException(OptionError,"MissingArgument",option);
5980 if (LocaleCompare("vignette",option+1) == 0)
5985 if (i == (ssize_t) argc)
5986 ThrowMogrifyException(OptionError,"MissingArgument",option);
5987 if (IsGeometry(argv[i]) == MagickFalse)
5988 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5991 if (LocaleCompare("virtual-pixel",option+1) == 0)
5999 if (i == (ssize_t) argc)
6000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6001 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6004 ThrowMogrifyException(OptionError,
6005 "UnrecognizedVirtualPixelMethod",argv[i]);
6008 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6012 if (LocaleCompare("wave",option+1) == 0)
6015 if (i == (ssize_t) argc)
6016 ThrowMogrifyException(OptionError,"MissingArgument",option);
6017 if (IsGeometry(argv[i]) == MagickFalse)
6018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6021 if (LocaleCompare("weight",option+1) == 0)
6026 if (i == (ssize_t) (argc-1))
6027 ThrowMogrifyException(OptionError,"MissingArgument",option);
6030 if (LocaleCompare("white-point",option+1) == 0)
6035 if (i == (ssize_t) argc)
6036 ThrowMogrifyException(OptionError,"MissingArgument",option);
6037 if (IsGeometry(argv[i]) == MagickFalse)
6038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6041 if (LocaleCompare("white-threshold",option+1) == 0)
6046 if (i == (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 if (IsGeometry(argv[i]) == MagickFalse)
6049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6052 if (LocaleCompare("write",option+1) == 0)
6055 if (i == (ssize_t) (argc-1))
6056 ThrowMogrifyException(OptionError,"MissingArgument",option);
6059 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6064 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6066 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6067 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6068 if (fire != MagickFalse)
6069 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6072 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6073 if (i != (ssize_t) argc)
6074 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6076 return(status != 0 ? MagickTrue : MagickFalse);
6080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6084 + M o g r i f y I m a g e I n f o %
6088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6090 % MogrifyImageInfo() applies image processing settings to the image as
6091 % prescribed by command line options.
6093 % The format of the MogrifyImageInfo method is:
6095 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6096 % const char **argv,ExceptionInfo *exception)
6098 % A description of each parameter follows:
6100 % o image_info: the image info..
6102 % o argc: Specifies a pointer to an integer describing the number of
6103 % elements in the argument vector.
6105 % o argv: Specifies a pointer to a text array containing the command line
6108 % o exception: return any errors or warnings in this structure.
6111 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6112 const int argc,const char **argv,ExceptionInfo *exception)
6127 Initialize method variables.
6129 assert(image_info != (ImageInfo *) NULL);
6130 assert(image_info->signature == MagickSignature);
6131 if (image_info->debug != MagickFalse)
6132 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6133 image_info->filename);
6137 Set the image settings.
6139 for (i=0; i < (ssize_t) argc; i++)
6142 if (IsCommandOption(option) == MagickFalse)
6144 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6145 count=MagickMax(count,0L);
6146 if ((i+count) >= (ssize_t) argc)
6148 switch (*(option+1))
6152 if (LocaleCompare("adjoin",option+1) == 0)
6154 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6157 if (LocaleCompare("antialias",option+1) == 0)
6159 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6162 if (LocaleCompare("attenuate",option+1) == 0)
6165 (void) DeleteImageOption(image_info,option+1);
6167 (void) SetImageOption(image_info,option+1,argv[i+1]);
6170 if (LocaleCompare("authenticate",option+1) == 0)
6173 (void) DeleteImageOption(image_info,option+1);
6175 (void) SetImageOption(image_info,option+1,argv[i+1]);
6182 if (LocaleCompare("background",option+1) == 0)
6186 (void) DeleteImageOption(image_info,option+1);
6187 (void) QueryColorCompliance(MogrifyBackgroundColor,
6188 AllCompliance,&image_info->background_color,exception);
6191 (void) SetImageOption(image_info,option+1,argv[i+1]);
6192 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6193 &image_info->background_color,exception);
6196 if (LocaleCompare("bias",option+1) == 0)
6200 (void) SetImageOption(image_info,option+1,"0.0");
6203 (void) SetImageOption(image_info,option+1,argv[i+1]);
6206 if (LocaleCompare("black-point-compensation",option+1) == 0)
6210 (void) SetImageOption(image_info,option+1,"false");
6213 (void) SetImageOption(image_info,option+1,"true");
6216 if (LocaleCompare("blue-primary",option+1) == 0)
6220 (void) SetImageOption(image_info,option+1,"0.0");
6223 (void) SetImageOption(image_info,option+1,argv[i+1]);
6226 if (LocaleCompare("bordercolor",option+1) == 0)
6230 (void) DeleteImageOption(image_info,option+1);
6231 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6232 &image_info->border_color,exception);
6235 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6236 &image_info->border_color,exception);
6237 (void) SetImageOption(image_info,option+1,argv[i+1]);
6240 if (LocaleCompare("box",option+1) == 0)
6244 (void) SetImageOption(image_info,"undercolor","none");
6247 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6254 if (LocaleCompare("cache",option+1) == 0)
6259 limit=MagickResourceInfinity;
6260 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6261 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6262 (void) SetMagickResourceLimit(MemoryResource,limit);
6263 (void) SetMagickResourceLimit(MapResource,2*limit);
6266 if (LocaleCompare("caption",option+1) == 0)
6270 (void) DeleteImageOption(image_info,option+1);
6273 (void) SetImageOption(image_info,option+1,argv[i+1]);
6276 if (LocaleCompare("channel",option+1) == 0)
6280 image_info->channel=DefaultChannels;
6283 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6286 if (LocaleCompare("colorspace",option+1) == 0)
6290 image_info->colorspace=UndefinedColorspace;
6291 (void) SetImageOption(image_info,option+1,"undefined");
6294 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6295 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6296 (void) SetImageOption(image_info,option+1,argv[i+1]);
6299 if (LocaleCompare("comment",option+1) == 0)
6303 (void) DeleteImageOption(image_info,option+1);
6306 (void) SetImageOption(image_info,option+1,argv[i+1]);
6309 if (LocaleCompare("compose",option+1) == 0)
6313 (void) SetImageOption(image_info,option+1,"undefined");
6316 (void) SetImageOption(image_info,option+1,argv[i+1]);
6319 if (LocaleCompare("compress",option+1) == 0)
6323 image_info->compression=UndefinedCompression;
6324 (void) SetImageOption(image_info,option+1,"undefined");
6327 image_info->compression=(CompressionType) ParseCommandOption(
6328 MagickCompressOptions,MagickFalse,argv[i+1]);
6329 (void) SetImageOption(image_info,option+1,argv[i+1]);
6336 if (LocaleCompare("debug",option+1) == 0)
6339 (void) SetLogEventMask("none");
6341 (void) SetLogEventMask(argv[i+1]);
6342 image_info->debug=IsEventLogging();
6345 if (LocaleCompare("define",option+1) == 0)
6349 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6350 (void) DeleteImageRegistry(argv[i+1]+9);
6352 (void) DeleteImageOption(image_info,argv[i+1]);
6355 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6357 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6361 (void) DefineImageOption(image_info,argv[i+1]);
6364 if (LocaleCompare("delay",option+1) == 0)
6368 (void) SetImageOption(image_info,option+1,"0");
6371 (void) SetImageOption(image_info,option+1,argv[i+1]);
6374 if (LocaleCompare("density",option+1) == 0)
6381 if (image_info->density != (char *) NULL)
6382 image_info->density=DestroyString(image_info->density);
6383 (void) SetImageOption(image_info,option+1,"72");
6386 (void) CloneString(&image_info->density,argv[i+1]);
6387 (void) SetImageOption(image_info,option+1,argv[i+1]);
6390 if (LocaleCompare("depth",option+1) == 0)
6394 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6397 image_info->depth=StringToUnsignedLong(argv[i+1]);
6400 if (LocaleCompare("direction",option+1) == 0)
6404 (void) SetImageOption(image_info,option+1,"undefined");
6407 (void) SetImageOption(image_info,option+1,argv[i+1]);
6410 if (LocaleCompare("display",option+1) == 0)
6414 if (image_info->server_name != (char *) NULL)
6415 image_info->server_name=DestroyString(
6416 image_info->server_name);
6419 (void) CloneString(&image_info->server_name,argv[i+1]);
6422 if (LocaleCompare("dispose",option+1) == 0)
6426 (void) SetImageOption(image_info,option+1,"undefined");
6429 (void) SetImageOption(image_info,option+1,argv[i+1]);
6432 if (LocaleCompare("dither",option+1) == 0)
6436 image_info->dither=MagickFalse;
6437 (void) SetImageOption(image_info,option+1,"none");
6440 (void) SetImageOption(image_info,option+1,argv[i+1]);
6441 image_info->dither=MagickTrue;
6448 if (LocaleCompare("encoding",option+1) == 0)
6452 (void) SetImageOption(image_info,option+1,"undefined");
6455 (void) SetImageOption(image_info,option+1,argv[i+1]);
6458 if (LocaleCompare("endian",option+1) == 0)
6462 image_info->endian=UndefinedEndian;
6463 (void) SetImageOption(image_info,option+1,"undefined");
6466 image_info->endian=(EndianType) ParseCommandOption(
6467 MagickEndianOptions,MagickFalse,argv[i+1]);
6468 (void) SetImageOption(image_info,option+1,argv[i+1]);
6471 if (LocaleCompare("extract",option+1) == 0)
6474 Set image extract geometry.
6478 if (image_info->extract != (char *) NULL)
6479 image_info->extract=DestroyString(image_info->extract);
6482 (void) CloneString(&image_info->extract,argv[i+1]);
6489 if (LocaleCompare("fill",option+1) == 0)
6493 (void) SetImageOption(image_info,option+1,"none");
6496 (void) SetImageOption(image_info,option+1,argv[i+1]);
6499 if (LocaleCompare("filter",option+1) == 0)
6503 (void) SetImageOption(image_info,option+1,"undefined");
6506 (void) SetImageOption(image_info,option+1,argv[i+1]);
6509 if (LocaleCompare("font",option+1) == 0)
6513 if (image_info->font != (char *) NULL)
6514 image_info->font=DestroyString(image_info->font);
6517 (void) CloneString(&image_info->font,argv[i+1]);
6520 if (LocaleCompare("format",option+1) == 0)
6525 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6526 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6527 image_info->ping=MagickFalse;
6528 (void) SetImageOption(image_info,option+1,argv[i+1]);
6531 if (LocaleCompare("fuzz",option+1) == 0)
6535 image_info->fuzz=0.0;
6536 (void) SetImageOption(image_info,option+1,"0");
6539 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6541 (void) SetImageOption(image_info,option+1,argv[i+1]);
6548 if (LocaleCompare("gravity",option+1) == 0)
6552 (void) SetImageOption(image_info,option+1,"undefined");
6555 (void) SetImageOption(image_info,option+1,argv[i+1]);
6558 if (LocaleCompare("green-primary",option+1) == 0)
6562 (void) SetImageOption(image_info,option+1,"0.0");
6565 (void) SetImageOption(image_info,option+1,argv[i+1]);
6572 if (LocaleCompare("intent",option+1) == 0)
6576 (void) SetImageOption(image_info,option+1,"undefined");
6579 (void) SetImageOption(image_info,option+1,argv[i+1]);
6582 if (LocaleCompare("interlace",option+1) == 0)
6586 image_info->interlace=UndefinedInterlace;
6587 (void) SetImageOption(image_info,option+1,"undefined");
6590 image_info->interlace=(InterlaceType) ParseCommandOption(
6591 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6592 (void) SetImageOption(image_info,option+1,argv[i+1]);
6595 if (LocaleCompare("interline-spacing",option+1) == 0)
6599 (void) SetImageOption(image_info,option+1,"undefined");
6602 (void) SetImageOption(image_info,option+1,argv[i+1]);
6605 if (LocaleCompare("interpolate",option+1) == 0)
6609 (void) SetImageOption(image_info,option+1,"undefined");
6612 (void) SetImageOption(image_info,option+1,argv[i+1]);
6615 if (LocaleCompare("interword-spacing",option+1) == 0)
6619 (void) SetImageOption(image_info,option+1,"undefined");
6622 (void) SetImageOption(image_info,option+1,argv[i+1]);
6629 if (LocaleCompare("kerning",option+1) == 0)
6633 (void) SetImageOption(image_info,option+1,"undefined");
6636 (void) SetImageOption(image_info,option+1,argv[i+1]);
6643 if (LocaleCompare("label",option+1) == 0)
6647 (void) DeleteImageOption(image_info,option+1);
6650 (void) SetImageOption(image_info,option+1,argv[i+1]);
6653 if (LocaleCompare("limit",option+1) == 0)
6663 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6664 MagickFalse,argv[i+1]);
6665 limit=MagickResourceInfinity;
6666 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6667 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6668 (void) SetMagickResourceLimit(type,limit);
6671 if (LocaleCompare("list",option+1) == 0)
6677 Display configuration list.
6679 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6682 case MagickCoderOptions:
6684 (void) ListCoderInfo((FILE *) NULL,exception);
6687 case MagickColorOptions:
6689 (void) ListColorInfo((FILE *) NULL,exception);
6692 case MagickConfigureOptions:
6694 (void) ListConfigureInfo((FILE *) NULL,exception);
6697 case MagickDelegateOptions:
6699 (void) ListDelegateInfo((FILE *) NULL,exception);
6702 case MagickFontOptions:
6704 (void) ListTypeInfo((FILE *) NULL,exception);
6707 case MagickFormatOptions:
6709 (void) ListMagickInfo((FILE *) NULL,exception);
6712 case MagickLocaleOptions:
6714 (void) ListLocaleInfo((FILE *) NULL,exception);
6717 case MagickLogOptions:
6719 (void) ListLogInfo((FILE *) NULL,exception);
6722 case MagickMagicOptions:
6724 (void) ListMagicInfo((FILE *) NULL,exception);
6727 case MagickMimeOptions:
6729 (void) ListMimeInfo((FILE *) NULL,exception);
6732 case MagickModuleOptions:
6734 (void) ListModuleInfo((FILE *) NULL,exception);
6737 case MagickPolicyOptions:
6739 (void) ListPolicyInfo((FILE *) NULL,exception);
6742 case MagickResourceOptions:
6744 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6747 case MagickThresholdOptions:
6749 (void) ListThresholdMaps((FILE *) NULL,exception);
6754 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6761 if (LocaleCompare("log",option+1) == 0)
6765 (void) SetLogFormat(argv[i+1]);
6768 if (LocaleCompare("loop",option+1) == 0)
6772 (void) SetImageOption(image_info,option+1,"0");
6775 (void) SetImageOption(image_info,option+1,argv[i+1]);
6782 if (LocaleCompare("matte",option+1) == 0)
6786 (void) SetImageOption(image_info,option+1,"false");
6789 (void) SetImageOption(image_info,option+1,"true");
6792 if (LocaleCompare("mattecolor",option+1) == 0)
6796 (void) SetImageOption(image_info,option+1,argv[i+1]);
6797 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6798 &image_info->matte_color,exception);
6801 (void) SetImageOption(image_info,option+1,argv[i+1]);
6802 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6803 &image_info->matte_color,exception);
6806 if (LocaleCompare("monitor",option+1) == 0)
6808 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6812 if (LocaleCompare("monochrome",option+1) == 0)
6814 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6821 if (LocaleCompare("orient",option+1) == 0)
6825 image_info->orientation=UndefinedOrientation;
6826 (void) SetImageOption(image_info,option+1,"undefined");
6829 image_info->orientation=(OrientationType) ParseCommandOption(
6830 MagickOrientationOptions,MagickFalse,argv[i+1]);
6831 (void) SetImageOption(image_info,option+1,argv[i+1]);
6837 if (LocaleCompare("page",option+1) == 0)
6841 page[MaxTextExtent];
6854 (void) DeleteImageOption(image_info,option+1);
6855 (void) CloneString(&image_info->page,(char *) NULL);
6858 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6859 image_option=GetImageOption(image_info,"page");
6860 if (image_option != (const char *) NULL)
6861 flags=ParseAbsoluteGeometry(image_option,&geometry);
6862 canonical_page=GetPageGeometry(argv[i+1]);
6863 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6864 canonical_page=DestroyString(canonical_page);
6865 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6866 (unsigned long) geometry.width,(unsigned long) geometry.height);
6867 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6868 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6869 (unsigned long) geometry.width,(unsigned long) geometry.height,
6870 (long) geometry.x,(long) geometry.y);
6871 (void) SetImageOption(image_info,option+1,page);
6872 (void) CloneString(&image_info->page,page);
6875 if (LocaleCompare("pen",option+1) == 0)
6879 (void) SetImageOption(image_info,option+1,"none");
6882 (void) SetImageOption(image_info,option+1,argv[i+1]);
6885 if (LocaleCompare("ping",option+1) == 0)
6887 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6890 if (LocaleCompare("pointsize",option+1) == 0)
6893 geometry_info.rho=0.0;
6895 (void) ParseGeometry(argv[i+1],&geometry_info);
6896 image_info->pointsize=geometry_info.rho;
6899 if (LocaleCompare("precision",option+1) == 0)
6901 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6904 if (LocaleCompare("preview",option+1) == 0)
6911 image_info->preview_type=UndefinedPreview;
6914 image_info->preview_type=(PreviewType) ParseCommandOption(
6915 MagickPreviewOptions,MagickFalse,argv[i+1]);
6922 if (LocaleCompare("quality",option+1) == 0)
6925 Set image compression quality.
6929 image_info->quality=UndefinedCompressionQuality;
6930 (void) SetImageOption(image_info,option+1,"0");
6933 image_info->quality=StringToUnsignedLong(argv[i+1]);
6934 (void) SetImageOption(image_info,option+1,argv[i+1]);
6937 if (LocaleCompare("quiet",option+1) == 0)
6939 static WarningHandler
6940 warning_handler = (WarningHandler) NULL;
6945 Restore error or warning messages.
6947 warning_handler=SetWarningHandler(warning_handler);
6951 Suppress error or warning messages.
6953 warning_handler=SetWarningHandler((WarningHandler) NULL);
6960 if (LocaleCompare("red-primary",option+1) == 0)
6964 (void) SetImageOption(image_info,option+1,"0.0");
6967 (void) SetImageOption(image_info,option+1,argv[i+1]);
6974 if (LocaleCompare("sampling-factor",option+1) == 0)
6977 Set image sampling factor.
6981 if (image_info->sampling_factor != (char *) NULL)
6982 image_info->sampling_factor=DestroyString(
6983 image_info->sampling_factor);
6986 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6989 if (LocaleCompare("scene",option+1) == 0)
6996 image_info->scene=0;
6997 (void) SetImageOption(image_info,option+1,"0");
7000 image_info->scene=StringToUnsignedLong(argv[i+1]);
7001 (void) SetImageOption(image_info,option+1,argv[i+1]);
7004 if (LocaleCompare("seed",option+1) == 0)
7011 seed=(size_t) time((time_t *) NULL);
7012 SeedPseudoRandomGenerator(seed);
7015 seed=StringToUnsignedLong(argv[i+1]);
7016 SeedPseudoRandomGenerator(seed);
7019 if (LocaleCompare("size",option+1) == 0)
7023 if (image_info->size != (char *) NULL)
7024 image_info->size=DestroyString(image_info->size);
7027 (void) CloneString(&image_info->size,argv[i+1]);
7030 if (LocaleCompare("stroke",option+1) == 0)
7034 (void) SetImageOption(image_info,option+1,"none");
7037 (void) SetImageOption(image_info,option+1,argv[i+1]);
7040 if (LocaleCompare("strokewidth",option+1) == 0)
7044 (void) SetImageOption(image_info,option+1,"0");
7047 (void) SetImageOption(image_info,option+1,argv[i+1]);
7050 if (LocaleCompare("synchronize",option+1) == 0)
7054 image_info->synchronize=MagickFalse;
7057 image_info->synchronize=MagickTrue;
7064 if (LocaleCompare("taint",option+1) == 0)
7068 (void) SetImageOption(image_info,option+1,"false");
7071 (void) SetImageOption(image_info,option+1,"true");
7074 if (LocaleCompare("texture",option+1) == 0)
7078 if (image_info->texture != (char *) NULL)
7079 image_info->texture=DestroyString(image_info->texture);
7082 (void) CloneString(&image_info->texture,argv[i+1]);
7085 if (LocaleCompare("tile-offset",option+1) == 0)
7089 (void) SetImageOption(image_info,option+1,"0");
7092 (void) SetImageOption(image_info,option+1,argv[i+1]);
7095 if (LocaleCompare("transparent-color",option+1) == 0)
7099 (void) QueryColorCompliance("none",AllCompliance,
7100 &image_info->transparent_color,exception);
7101 (void) SetImageOption(image_info,option+1,"none");
7104 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7105 &image_info->transparent_color,exception);
7106 (void) SetImageOption(image_info,option+1,argv[i+1]);
7109 if (LocaleCompare("type",option+1) == 0)
7113 image_info->type=UndefinedType;
7114 (void) SetImageOption(image_info,option+1,"undefined");
7117 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7118 MagickFalse,argv[i+1]);
7119 (void) SetImageOption(image_info,option+1,argv[i+1]);
7126 if (LocaleCompare("undercolor",option+1) == 0)
7130 (void) DeleteImageOption(image_info,option+1);
7133 (void) SetImageOption(image_info,option+1,argv[i+1]);
7136 if (LocaleCompare("units",option+1) == 0)
7140 image_info->units=UndefinedResolution;
7141 (void) SetImageOption(image_info,option+1,"undefined");
7144 image_info->units=(ResolutionType) ParseCommandOption(
7145 MagickResolutionOptions,MagickFalse,argv[i+1]);
7146 (void) SetImageOption(image_info,option+1,argv[i+1]);
7153 if (LocaleCompare("verbose",option+1) == 0)
7157 image_info->verbose=MagickFalse;
7160 image_info->verbose=MagickTrue;
7161 image_info->ping=MagickFalse;
7164 if (LocaleCompare("view",option+1) == 0)
7168 if (image_info->view != (char *) NULL)
7169 image_info->view=DestroyString(image_info->view);
7172 (void) CloneString(&image_info->view,argv[i+1]);
7175 if (LocaleCompare("virtual-pixel",option+1) == 0)
7179 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7180 (void) SetImageOption(image_info,option+1,"undefined");
7183 image_info->virtual_pixel_method=(VirtualPixelMethod)
7184 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7186 (void) SetImageOption(image_info,option+1,argv[i+1]);
7193 if (LocaleCompare("white-point",option+1) == 0)
7197 (void) SetImageOption(image_info,option+1,"0.0");
7200 (void) SetImageOption(image_info,option+1,argv[i+1]);
7214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7218 + M o g r i f y I m a g e L i s t %
7222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7224 % MogrifyImageList() applies any command line options that might affect the
7225 % entire image list (e.g. -append, -coalesce, etc.).
7227 % The format of the MogrifyImage method is:
7229 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7230 % const char **argv,Image **images,ExceptionInfo *exception)
7232 % A description of each parameter follows:
7234 % o image_info: the image info..
7236 % o argc: Specifies a pointer to an integer describing the number of
7237 % elements in the argument vector.
7239 % o argv: Specifies a pointer to a text array containing the command line
7242 % o images: pointer to pointer of the first image in image list.
7244 % o exception: return any errors or warnings in this structure.
7247 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7248 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7259 PixelInterpolateMethod
7273 Apply options to the image list.
7275 assert(image_info != (ImageInfo *) NULL);
7276 assert(image_info->signature == MagickSignature);
7277 assert(images != (Image **) NULL);
7278 assert((*images)->previous == (Image *) NULL);
7279 assert((*images)->signature == MagickSignature);
7280 if ((*images)->debug != MagickFalse)
7281 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7282 (*images)->filename);
7283 if ((argc <= 0) || (*argv == (char *) NULL))
7285 interpolate_method=UndefinedInterpolatePixel;
7286 mogrify_info=CloneImageInfo(image_info);
7287 quantize_info=AcquireQuantizeInfo(mogrify_info);
7289 for (i=0; i < (ssize_t) argc; i++)
7291 if (*images == (Image *) NULL)
7294 if (IsCommandOption(option) == MagickFalse)
7296 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7297 count=MagickMax(count,0L);
7298 if ((i+count) >= (ssize_t) argc)
7300 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7301 switch (*(option+1))
7305 if (LocaleCompare("affinity",option+1) == 0)
7307 (void) SyncImagesSettings(mogrify_info,*images);
7310 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7317 if (LocaleCompare("append",option+1) == 0)
7322 (void) SyncImagesSettings(mogrify_info,*images);
7323 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7324 MagickFalse,exception);
7325 if (append_image == (Image *) NULL)
7330 *images=DestroyImageList(*images);
7331 *images=append_image;
7334 if (LocaleCompare("average",option+1) == 0)
7340 Average an image sequence (deprecated).
7342 (void) SyncImagesSettings(mogrify_info,*images);
7343 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7345 if (average_image == (Image *) NULL)
7350 *images=DestroyImageList(*images);
7351 *images=average_image;
7358 if (LocaleCompare("channel",option+1) == 0)
7365 channel=DefaultChannels;
7368 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7369 SetPixelChannelMap(*images,channel);
7372 if (LocaleCompare("clut",option+1) == 0)
7378 (void) SyncImagesSettings(mogrify_info,*images);
7379 image=RemoveFirstImageFromList(images);
7380 clut_image=RemoveFirstImageFromList(images);
7381 if (clut_image == (Image *) NULL)
7386 (void) ClutImage(image,clut_image,interpolate_method,exception);
7387 clut_image=DestroyImage(clut_image);
7388 *images=DestroyImageList(*images);
7392 if (LocaleCompare("coalesce",option+1) == 0)
7397 (void) SyncImagesSettings(mogrify_info,*images);
7398 coalesce_image=CoalesceImages(*images,exception);
7399 if (coalesce_image == (Image *) NULL)
7404 *images=DestroyImageList(*images);
7405 *images=coalesce_image;
7408 if (LocaleCompare("combine",option+1) == 0)
7413 (void) SyncImagesSettings(mogrify_info,*images);
7414 combine_image=CombineImages(*images,exception);
7415 if (combine_image == (Image *) NULL)
7420 *images=DestroyImageList(*images);
7421 *images=combine_image;
7424 if (LocaleCompare("composite",option+1) == 0)
7434 (void) SyncImagesSettings(mogrify_info,*images);
7435 image=RemoveFirstImageFromList(images);
7436 composite_image=RemoveFirstImageFromList(images);
7437 if (composite_image == (Image *) NULL)
7442 (void) TransformImage(&composite_image,(char *) NULL,
7443 composite_image->geometry);
7444 SetGeometry(composite_image,&geometry);
7445 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7446 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7448 mask_image=RemoveFirstImageFromList(images);
7449 if (mask_image != (Image *) NULL)
7451 if ((image->compose == DisplaceCompositeOp) ||
7452 (image->compose == DistortCompositeOp))
7455 Merge Y displacement into X displacement image.
7457 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7459 mask_image=DestroyImage(mask_image);
7464 Set a blending mask for the composition.
7465 Posible error, what if image->mask already set.
7467 image->mask=mask_image;
7468 (void) NegateImage(image->mask,MagickFalse,exception);
7471 (void) CompositeImage(image,image->compose,composite_image,
7472 geometry.x,geometry.y);
7473 if (mask_image != (Image *) NULL)
7474 mask_image=image->mask=DestroyImage(image->mask);
7475 composite_image=DestroyImage(composite_image);
7476 InheritException(exception,&image->exception);
7477 *images=DestroyImageList(*images);
7485 if (LocaleCompare("deconstruct",option+1) == 0)
7490 (void) SyncImagesSettings(mogrify_info,*images);
7491 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7493 if (deconstruct_image == (Image *) NULL)
7498 *images=DestroyImageList(*images);
7499 *images=deconstruct_image;
7502 if (LocaleCompare("delete",option+1) == 0)
7505 DeleteImages(images,"-1",exception);
7507 DeleteImages(images,argv[i+1],exception);
7510 if (LocaleCompare("dither",option+1) == 0)
7514 quantize_info->dither=MagickFalse;
7517 quantize_info->dither=MagickTrue;
7518 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7519 MagickDitherOptions,MagickFalse,argv[i+1]);
7522 if (LocaleCompare("duplicate",option+1) == 0)
7528 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7537 number_duplicates=(size_t) StringToLong(argv[i+1]);
7538 p=strchr(argv[i+1],',');
7539 if (p == (const char *) NULL)
7540 duplicate_images=DuplicateImages(*images,number_duplicates,
7543 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7546 AppendImageToList(images, duplicate_images);
7547 (void) SyncImagesSettings(mogrify_info,*images);
7554 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7559 MagickEvaluateOperator
7562 (void) SyncImageSettings(mogrify_info,*images);
7563 op=(MagickEvaluateOperator) ParseCommandOption(
7564 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7565 evaluate_image=EvaluateImages(*images,op,exception);
7566 if (evaluate_image == (Image *) NULL)
7571 *images=DestroyImageList(*images);
7572 *images=evaluate_image;
7579 if (LocaleCompare("fft",option+1) == 0)
7585 Implements the discrete Fourier transform (DFT).
7587 (void) SyncImageSettings(mogrify_info,*images);
7588 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7589 MagickTrue : MagickFalse,exception);
7590 if (fourier_image == (Image *) NULL)
7592 *images=DestroyImage(*images);
7593 *images=fourier_image;
7596 if (LocaleCompare("flatten",option+1) == 0)
7601 (void) SyncImagesSettings(mogrify_info,*images);
7602 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7603 if (flatten_image == (Image *) NULL)
7605 *images=DestroyImageList(*images);
7606 *images=flatten_image;
7609 if (LocaleCompare("fx",option+1) == 0)
7614 (void) SyncImagesSettings(mogrify_info,*images);
7615 fx_image=FxImage(*images,argv[i+1],exception);
7616 if (fx_image == (Image *) NULL)
7621 *images=DestroyImageList(*images);
7629 if (LocaleCompare("hald-clut",option+1) == 0)
7635 (void) SyncImagesSettings(mogrify_info,*images);
7636 image=RemoveFirstImageFromList(images);
7637 hald_image=RemoveFirstImageFromList(images);
7638 if (hald_image == (Image *) NULL)
7643 (void) HaldClutImage(image,hald_image,exception);
7644 hald_image=DestroyImage(hald_image);
7645 if (*images != (Image *) NULL)
7646 *images=DestroyImageList(*images);
7654 if (LocaleCompare("ift",option+1) == 0)
7662 Implements the inverse fourier discrete Fourier transform (DFT).
7664 (void) SyncImagesSettings(mogrify_info,*images);
7665 magnitude_image=RemoveFirstImageFromList(images);
7666 phase_image=RemoveFirstImageFromList(images);
7667 if (phase_image == (Image *) NULL)
7672 fourier_image=InverseFourierTransformImage(magnitude_image,
7673 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7674 if (fourier_image == (Image *) NULL)
7676 if (*images != (Image *) NULL)
7677 *images=DestroyImage(*images);
7678 *images=fourier_image;
7681 if (LocaleCompare("insert",option+1) == 0)
7689 index=(ssize_t) StringToLong(argv[i+1]);
7690 p=RemoveLastImageFromList(images);
7691 if (p == (Image *) NULL)
7693 (void) ThrowMagickException(exception,GetMagickModule(),
7694 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7700 PrependImageToList(images,q);
7702 if (index == (ssize_t) GetImageListLength(*images))
7703 AppendImageToList(images,q);
7706 q=GetImageFromList(*images,index-1);
7707 if (q == (Image *) NULL)
7709 (void) ThrowMagickException(exception,GetMagickModule(),
7710 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7714 InsertImageInList(&q,p);
7716 *images=GetFirstImageInList(q);
7719 if (LocaleCompare("interpolate",option+1) == 0)
7721 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7722 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7729 if (LocaleCompare("layers",option+1) == 0)
7737 (void) SyncImagesSettings(mogrify_info,*images);
7738 layers=(Image *) NULL;
7739 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7740 MagickFalse,argv[i+1]);
7745 layers=CoalesceImages(*images,exception);
7748 case CompareAnyLayer:
7749 case CompareClearLayer:
7750 case CompareOverlayLayer:
7753 layers=CompareImagesLayers(*images,method,exception);
7759 case TrimBoundsLayer:
7761 layers=MergeImageLayers(*images,method,exception);
7766 layers=DisposeImages(*images,exception);
7769 case OptimizeImageLayer:
7771 layers=OptimizeImageLayers(*images,exception);
7774 case OptimizePlusLayer:
7776 layers=OptimizePlusImageLayers(*images,exception);
7779 case OptimizeTransLayer:
7781 OptimizeImageTransparency(*images,exception);
7784 case RemoveDupsLayer:
7786 RemoveDuplicateLayers(images,exception);
7789 case RemoveZeroLayer:
7791 RemoveZeroDelayLayers(images,exception);
7797 General Purpose, GIF Animation Optimizer.
7799 layers=CoalesceImages(*images,exception);
7800 if (layers == (Image *) NULL)
7805 *images=DestroyImageList(*images);
7807 layers=OptimizeImageLayers(*images,exception);
7808 if (layers == (Image *) NULL)
7813 *images=DestroyImageList(*images);
7815 layers=(Image *) NULL;
7816 OptimizeImageTransparency(*images,exception);
7817 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7821 case CompositeLayer:
7833 Split image sequence at the first 'NULL:' image.
7836 while (source != (Image *) NULL)
7838 source=GetNextImageInList(source);
7839 if ((source != (Image *) NULL) &&
7840 (LocaleCompare(source->magick,"NULL") == 0))
7843 if (source != (Image *) NULL)
7845 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7846 (GetNextImageInList(source) == (Image *) NULL))
7847 source=(Image *) NULL;
7851 Separate the two lists, junk the null: image.
7853 source=SplitImageList(source->previous);
7854 DeleteImageFromList(&source);
7857 if (source == (Image *) NULL)
7859 (void) ThrowMagickException(exception,GetMagickModule(),
7860 OptionError,"MissingNullSeparator","layers Composite");
7865 Adjust offset with gravity and virtual canvas.
7867 SetGeometry(*images,&geometry);
7868 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7869 geometry.width=source->page.width != 0 ?
7870 source->page.width : source->columns;
7871 geometry.height=source->page.height != 0 ?
7872 source->page.height : source->rows;
7873 GravityAdjustGeometry((*images)->page.width != 0 ?
7874 (*images)->page.width : (*images)->columns,
7875 (*images)->page.height != 0 ? (*images)->page.height :
7876 (*images)->rows,(*images)->gravity,&geometry);
7877 compose=OverCompositeOp;
7878 option=GetImageOption(mogrify_info,"compose");
7879 if (option != (const char *) NULL)
7880 compose=(CompositeOperator) ParseCommandOption(
7881 MagickComposeOptions,MagickFalse,option);
7882 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7884 source=DestroyImageList(source);
7888 if (layers == (Image *) NULL)
7890 InheritException(exception,&layers->exception);
7891 *images=DestroyImageList(*images);
7899 if (LocaleCompare("map",option+1) == 0)
7901 (void) SyncImagesSettings(mogrify_info,*images);
7904 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7911 if (LocaleCompare("maximum",option+1) == 0)
7917 Maximum image sequence (deprecated).
7919 (void) SyncImagesSettings(mogrify_info,*images);
7920 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7921 if (maximum_image == (Image *) NULL)
7926 *images=DestroyImageList(*images);
7927 *images=maximum_image;
7930 if (LocaleCompare("minimum",option+1) == 0)
7936 Minimum image sequence (deprecated).
7938 (void) SyncImagesSettings(mogrify_info,*images);
7939 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7940 if (minimum_image == (Image *) NULL)
7945 *images=DestroyImageList(*images);
7946 *images=minimum_image;
7949 if (LocaleCompare("morph",option+1) == 0)
7954 (void) SyncImagesSettings(mogrify_info,*images);
7955 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7957 if (morph_image == (Image *) NULL)
7962 *images=DestroyImageList(*images);
7963 *images=morph_image;
7966 if (LocaleCompare("mosaic",option+1) == 0)
7971 (void) SyncImagesSettings(mogrify_info,*images);
7972 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7973 if (mosaic_image == (Image *) NULL)
7978 *images=DestroyImageList(*images);
7979 *images=mosaic_image;
7986 if (LocaleCompare("print",option+1) == 0)
7991 (void) SyncImagesSettings(mogrify_info,*images);
7992 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7994 if (string == (char *) NULL)
7996 (void) FormatLocaleFile(stdout,"%s",string);
7997 string=DestroyString(string);
7999 if (LocaleCompare("process",option+1) == 0)
8008 (void) SyncImagesSettings(mogrify_info,*images);
8009 arguments=StringToArgv(argv[i+1],&number_arguments);
8010 if (arguments == (char **) NULL)
8012 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8033 Support old style syntax, filter="-option arg".
8035 length=strlen(argv[i+1]);
8036 token=(char *) NULL;
8037 if (~length >= (MaxTextExtent-1))
8038 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8040 if (token == (char *) NULL)
8043 arguments=argv[i+1];
8044 token_info=AcquireTokenInfo();
8045 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8046 "\"",'\0',&breaker,&next,"e);
8047 token_info=DestroyTokenInfo(token_info);
8053 argv=(&(arguments[next]));
8054 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8057 token=DestroyString(token);
8060 (void) SubstituteString(&arguments[1],"-","");
8061 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8062 number_arguments-2,(const char **) arguments+2,exception);
8063 for (j=0; j < number_arguments; j++)
8064 arguments[j]=DestroyString(arguments[j]);
8065 arguments=(char **) RelinquishMagickMemory(arguments);
8072 if (LocaleCompare("reverse",option+1) == 0)
8074 ReverseImageList(images);
8075 InheritException(exception,&(*images)->exception);
8082 if (LocaleCompare("smush",option+1) == 0)
8090 (void) SyncImagesSettings(mogrify_info,*images);
8091 offset=(ssize_t) StringToLong(argv[i+1]);
8092 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8093 MagickFalse,offset,exception);
8094 if (smush_image == (Image *) NULL)
8099 *images=DestroyImageList(*images);
8100 *images=smush_image;
8103 if (LocaleCompare("swap",option+1) == 0)
8124 flags=ParseGeometry(argv[i+1],&geometry_info);
8125 index=(ssize_t) geometry_info.rho;
8126 if ((flags & SigmaValue) != 0)
8127 swap_index=(ssize_t) geometry_info.sigma;
8129 p=GetImageFromList(*images,index);
8130 q=GetImageFromList(*images,swap_index);
8131 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8133 (void) ThrowMagickException(exception,GetMagickModule(),
8134 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8140 swap=CloneImage(p,0,0,MagickTrue,exception);
8141 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8142 ReplaceImageInList(&q,swap);
8143 *images=GetFirstImageInList(q);
8150 if (LocaleCompare("write",option+1) == 0)
8161 (void) SyncImagesSettings(mogrify_info,*images);
8162 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8163 (void) DeleteImageRegistry(key);
8164 write_images=(*images);
8166 write_images=CloneImageList(*images,exception);
8167 write_info=CloneImageInfo(mogrify_info);
8168 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8169 write_info=DestroyImageInfo(write_info);
8171 write_images=DestroyImageList(write_images);
8181 quantize_info=DestroyQuantizeInfo(quantize_info);
8182 mogrify_info=DestroyImageInfo(mogrify_info);
8183 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8184 return(status != 0 ? MagickTrue : MagickFalse);
8188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8192 + M o g r i f y I m a g e s %
8196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8198 % MogrifyImages() applies image processing options to a sequence of images as
8199 % prescribed by command line options.
8201 % The format of the MogrifyImage method is:
8203 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8204 % const MagickBooleanType post,const int argc,const char **argv,
8205 % Image **images,Exceptioninfo *exception)
8207 % A description of each parameter follows:
8209 % o image_info: the image info..
8211 % o post: If true, post process image list operators otherwise pre-process.
8213 % o argc: Specifies a pointer to an integer describing the number of
8214 % elements in the argument vector.
8216 % o argv: Specifies a pointer to a text array containing the command line
8219 % o images: pointer to a pointer of the first image in image list.
8221 % o exception: return any errors or warnings in this structure.
8224 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8225 const MagickBooleanType post,const int argc,const char **argv,
8226 Image **images,ExceptionInfo *exception)
8228 #define MogrifyImageTag "Mogrify/Image"
8242 assert(image_info != (ImageInfo *) NULL);
8243 assert(image_info->signature == MagickSignature);
8244 if (images == (Image **) NULL)
8245 return(MogrifyImage(image_info,argc,argv,images,exception));
8246 assert((*images)->previous == (Image *) NULL);
8247 assert((*images)->signature == MagickSignature);
8248 if ((*images)->debug != MagickFalse)
8249 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8250 (*images)->filename);
8251 if ((argc <= 0) || (*argv == (char *) NULL))
8253 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8258 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8263 Pre-process multi-image sequence operators
8265 if (post == MagickFalse)
8266 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8268 For each image, process simple single image operators
8271 n=GetImageListLength(*images);
8275 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8276 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8278 status&=MogrifyImage(image_info,argc,argv,images,exception);
8279 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8280 if (proceed == MagickFalse)
8282 if ( (*images)->next == (Image *) NULL )
8284 *images=(*images)->next;
8287 assert( *images != (Image *) NULL );
8289 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8290 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8294 Post-process, multi-image sequence operators
8296 *images=GetFirstImageInList(*images);
8297 if (post != MagickFalse)
8298 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8299 return(status != 0 ? MagickTrue : MagickFalse);