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);
388 static Image *SparseColorOption(const Image *image,
389 const SparseColorMethod method,const char *arguments,
390 const MagickBooleanType color_from_image,ExceptionInfo *exception)
393 token[MaxTextExtent];
418 SparseColorOption() parses the complex -sparse-color argument into an
419 an array of floating point values then calls SparseColorImage().
420 Argument is a complex mix of floating-point pixel coodinates, and color
421 specifications (or direct floating point numbers). The number of floats
422 needed to represent a color varies depending on the current channel
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) QueryMagickColor(token,&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) QueryColorDatabase(MogrifyBorderColor,
939 &draw_info->border_color,exception);
942 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
946 if (LocaleCompare("box",option+1) == 0)
948 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
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],draw_info->fill,
1131 if (LocaleCompare("color-matrix",option+1) == 0)
1136 (void) SyncImageSettings(mogrify_info,*image);
1137 kernel=AcquireKernelInfo(argv[i+1]);
1138 if (kernel == (KernelInfo *) NULL)
1140 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1141 kernel=DestroyKernelInfo(kernel);
1144 if (LocaleCompare("colors",option+1) == 0)
1147 Reduce the number of colors in the image.
1149 (void) SyncImageSettings(mogrify_info,*image);
1150 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1151 if (quantize_info->number_colors == 0)
1153 if (((*image)->storage_class == DirectClass) ||
1154 (*image)->colors > quantize_info->number_colors)
1155 (void) QuantizeImage(quantize_info,*image,exception);
1157 (void) CompressImageColormap(*image,exception);
1160 if (LocaleCompare("colorspace",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image);
1168 (void) TransformImageColorspace(*image,RGBColorspace);
1169 InheritException(exception,&(*image)->exception);
1172 colorspace=(ColorspaceType) ParseCommandOption(
1173 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1174 (void) TransformImageColorspace(*image,colorspace);
1175 InheritException(exception,&(*image)->exception);
1178 if (LocaleCompare("compose",option+1) == 0)
1180 (void) SyncImageSettings(mogrify_info,*image);
1181 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1182 MagickFalse,argv[i+1]);
1185 if (LocaleCompare("contrast",option+1) == 0)
1187 (void) SyncImageSettings(mogrify_info,*image);
1188 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1189 MagickFalse,exception);
1192 if (LocaleCompare("contrast-stretch",option+1) == 0)
1202 Contrast stretch image.
1204 (void) SyncImageSettings(mogrify_info,*image);
1205 flags=ParseGeometry(argv[i+1],&geometry_info);
1206 black_point=geometry_info.rho;
1207 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1209 if ((flags & PercentValue) != 0)
1211 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1212 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1214 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1216 (void) ContrastStretchImage(*image,black_point,white_point,
1218 InheritException(exception,&(*image)->exception);
1221 if (LocaleCompare("convolve",option+1) == 0)
1226 (void) SyncImageSettings(mogrify_info,*image);
1227 kernel_info=AcquireKernelInfo(argv[i+1]);
1228 if (kernel_info == (KernelInfo *) NULL)
1230 kernel_info->bias=(*image)->bias;
1231 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1232 kernel_info=DestroyKernelInfo(kernel_info);
1235 if (LocaleCompare("crop",option+1) == 0)
1238 Crop a image to a smaller size
1240 (void) SyncImageSettings(mogrify_info,*image);
1241 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1244 if (LocaleCompare("cycle",option+1) == 0)
1247 Cycle an image colormap.
1249 (void) SyncImageSettings(mogrify_info,*image);
1250 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1258 if (LocaleCompare("decipher",option+1) == 0)
1266 (void) SyncImageSettings(mogrify_info,*image);
1267 passkey=FileToStringInfo(argv[i+1],~0,exception);
1268 if (passkey != (StringInfo *) NULL)
1270 (void) PasskeyDecipherImage(*image,passkey,exception);
1271 passkey=DestroyStringInfo(passkey);
1275 if (LocaleCompare("density",option+1) == 0)
1280 (void) CloneString(&draw_info->density,argv[i+1]);
1283 if (LocaleCompare("depth",option+1) == 0)
1285 (void) SyncImageSettings(mogrify_info,*image);
1288 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1291 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1294 if (LocaleCompare("deskew",option+1) == 0)
1300 Straighten the image.
1302 (void) SyncImageSettings(mogrify_info,*image);
1304 threshold=40.0*QuantumRange/100.0;
1306 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1307 mogrify_image=DeskewImage(*image,threshold,exception);
1310 if (LocaleCompare("despeckle",option+1) == 0)
1313 Reduce the speckles within an image.
1315 (void) SyncImageSettings(mogrify_info,*image);
1316 mogrify_image=DespeckleImage(*image,exception);
1319 if (LocaleCompare("display",option+1) == 0)
1321 (void) CloneString(&draw_info->server_name,argv[i+1]);
1324 if (LocaleCompare("distort",option+1) == 0)
1328 token[MaxTextExtent];
1348 (void) SyncImageSettings(mogrify_info,*image);
1349 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1350 MagickFalse,argv[i+1]);
1351 if ( method == ResizeDistortion )
1353 /* Special Case - Argument is actually a resize geometry!
1354 ** Convert that to an appropriate distortion argument array.
1358 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1360 resize_args[0]=(double)geometry.width;
1361 resize_args[1]=(double)geometry.height;
1362 mogrify_image=DistortImage(*image,method,(size_t)2,
1363 resize_args,MagickTrue,exception);
1366 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1368 if (args == (char *) NULL)
1371 for (x=0; *p != '\0'; x++)
1373 GetMagickToken(p,&p,token);
1375 GetMagickToken(p,&p,token);
1377 number_arguments=(size_t) x;
1378 arguments=(double *) AcquireQuantumMemory(number_arguments,
1379 sizeof(*arguments));
1380 if (arguments == (double *) NULL)
1381 ThrowWandFatalException(ResourceLimitFatalError,
1382 "MemoryAllocationFailed",(*image)->filename);
1383 (void) ResetMagickMemory(arguments,0,number_arguments*
1384 sizeof(*arguments));
1386 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1388 GetMagickToken(p,&p,token);
1390 GetMagickToken(p,&p,token);
1391 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1393 args=DestroyString(args);
1394 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1395 (*option == '+') ? MagickTrue : MagickFalse,exception);
1396 arguments=(double *) RelinquishMagickMemory(arguments);
1399 if (LocaleCompare("dither",option+1) == 0)
1403 quantize_info->dither=MagickFalse;
1406 quantize_info->dither=MagickTrue;
1407 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1408 MagickDitherOptions,MagickFalse,argv[i+1]);
1409 if (quantize_info->dither_method == NoDitherMethod)
1410 quantize_info->dither=MagickFalse;
1413 if (LocaleCompare("draw",option+1) == 0)
1418 (void) SyncImageSettings(mogrify_info,*image);
1419 (void) CloneString(&draw_info->primitive,argv[i+1]);
1420 (void) DrawImage(*image,draw_info,exception);
1427 if (LocaleCompare("edge",option+1) == 0)
1430 Enhance edges in the image.
1432 (void) SyncImageSettings(mogrify_info,*image);
1433 flags=ParseGeometry(argv[i+1],&geometry_info);
1434 if ((flags & SigmaValue) == 0)
1435 geometry_info.sigma=1.0;
1436 mogrify_image=EdgeImage(*image,geometry_info.rho,
1437 geometry_info.sigma,exception);
1440 if (LocaleCompare("emboss",option+1) == 0)
1443 Gaussian embossen image.
1445 (void) SyncImageSettings(mogrify_info,*image);
1446 flags=ParseGeometry(argv[i+1],&geometry_info);
1447 if ((flags & SigmaValue) == 0)
1448 geometry_info.sigma=1.0;
1449 mogrify_image=EmbossImage(*image,geometry_info.rho,
1450 geometry_info.sigma,exception);
1453 if (LocaleCompare("encipher",option+1) == 0)
1461 (void) SyncImageSettings(mogrify_info,*image);
1462 passkey=FileToStringInfo(argv[i+1],~0,exception);
1463 if (passkey != (StringInfo *) NULL)
1465 (void) PasskeyEncipherImage(*image,passkey,exception);
1466 passkey=DestroyStringInfo(passkey);
1470 if (LocaleCompare("encoding",option+1) == 0)
1472 (void) CloneString(&draw_info->encoding,argv[i+1]);
1475 if (LocaleCompare("enhance",option+1) == 0)
1480 (void) SyncImageSettings(mogrify_info,*image);
1481 mogrify_image=EnhanceImage(*image,exception);
1484 if (LocaleCompare("equalize",option+1) == 0)
1489 (void) SyncImageSettings(mogrify_info,*image);
1490 (void) EqualizeImage(*image,exception);
1493 if (LocaleCompare("evaluate",option+1) == 0)
1498 MagickEvaluateOperator
1501 (void) SyncImageSettings(mogrify_info,*image);
1502 op=(MagickEvaluateOperator) ParseCommandOption(
1503 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1504 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1505 (void) EvaluateImage(*image,op,constant,exception);
1508 if (LocaleCompare("extent",option+1) == 0)
1511 Set the image extent.
1513 (void) SyncImageSettings(mogrify_info,*image);
1514 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1515 if (geometry.width == 0)
1516 geometry.width=(*image)->columns;
1517 if (geometry.height == 0)
1518 geometry.height=(*image)->rows;
1519 mogrify_image=ExtentImage(*image,&geometry,exception);
1526 if (LocaleCompare("family",option+1) == 0)
1530 if (draw_info->family != (char *) NULL)
1531 draw_info->family=DestroyString(draw_info->family);
1534 (void) CloneString(&draw_info->family,argv[i+1]);
1537 if (LocaleCompare("features",option+1) == 0)
1541 (void) DeleteImageArtifact(*image,"identify:features");
1544 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1547 if (LocaleCompare("fill",option+1) == 0)
1552 GetPixelInfo(*image,&fill);
1555 (void) QueryMagickColor("none",&fill,exception);
1556 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1557 if (draw_info->fill_pattern != (Image *) NULL)
1558 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1561 sans=AcquireExceptionInfo();
1562 (void) QueryMagickColor(argv[i+1],&fill,sans);
1563 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1564 sans=DestroyExceptionInfo(sans);
1565 if (status == MagickFalse)
1566 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1570 if (LocaleCompare("flip",option+1) == 0)
1573 Flip image scanlines.
1575 (void) SyncImageSettings(mogrify_info,*image);
1576 mogrify_image=FlipImage(*image,exception);
1579 if (LocaleCompare("floodfill",option+1) == 0)
1587 (void) SyncImageSettings(mogrify_info,*image);
1588 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1589 (void) QueryMagickColor(argv[i+2],&target,exception);
1590 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1591 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1594 if (LocaleCompare("flop",option+1) == 0)
1597 Flop image scanlines.
1599 (void) SyncImageSettings(mogrify_info,*image);
1600 mogrify_image=FlopImage(*image,exception);
1603 if (LocaleCompare("font",option+1) == 0)
1607 if (draw_info->font != (char *) NULL)
1608 draw_info->font=DestroyString(draw_info->font);
1611 (void) CloneString(&draw_info->font,argv[i+1]);
1614 if (LocaleCompare("format",option+1) == 0)
1619 if (LocaleCompare("frame",option+1) == 0)
1625 Surround image with an ornamental border.
1627 (void) SyncImageSettings(mogrify_info,*image);
1628 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1629 frame_info.width=geometry.width;
1630 frame_info.height=geometry.height;
1631 if ((flags & HeightValue) == 0)
1632 frame_info.height=geometry.width;
1633 frame_info.outer_bevel=geometry.x;
1634 frame_info.inner_bevel=geometry.y;
1635 frame_info.x=(ssize_t) frame_info.width;
1636 frame_info.y=(ssize_t) frame_info.height;
1637 frame_info.width=(*image)->columns+2*frame_info.width;
1638 frame_info.height=(*image)->rows+2*frame_info.height;
1639 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1642 if (LocaleCompare("function",option+1) == 0)
1646 token[MaxTextExtent];
1664 Function Modify Image Values
1666 (void) SyncImageSettings(mogrify_info,*image);
1667 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1668 MagickFalse,argv[i+1]);
1669 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1671 if (arguments == (char *) NULL)
1673 p=(char *) arguments;
1674 for (x=0; *p != '\0'; x++)
1676 GetMagickToken(p,&p,token);
1678 GetMagickToken(p,&p,token);
1680 number_parameters=(size_t) x;
1681 parameters=(double *) AcquireQuantumMemory(number_parameters,
1682 sizeof(*parameters));
1683 if (parameters == (double *) NULL)
1684 ThrowWandFatalException(ResourceLimitFatalError,
1685 "MemoryAllocationFailed",(*image)->filename);
1686 (void) ResetMagickMemory(parameters,0,number_parameters*
1687 sizeof(*parameters));
1688 p=(char *) arguments;
1689 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1691 GetMagickToken(p,&p,token);
1693 GetMagickToken(p,&p,token);
1694 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1696 arguments=DestroyString(arguments);
1697 (void) FunctionImage(*image,function,number_parameters,parameters,
1699 parameters=(double *) RelinquishMagickMemory(parameters);
1706 if (LocaleCompare("gamma",option+1) == 0)
1711 (void) SyncImageSettings(mogrify_info,*image);
1713 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1715 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1716 (char **) NULL),exception);
1719 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1720 (LocaleCompare("gaussian",option+1) == 0))
1723 Gaussian blur image.
1725 (void) SyncImageSettings(mogrify_info,*image);
1726 flags=ParseGeometry(argv[i+1],&geometry_info);
1727 if ((flags & SigmaValue) == 0)
1728 geometry_info.sigma=1.0;
1729 if ((flags & XiValue) == 0)
1730 geometry_info.xi=0.0;
1731 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1732 geometry_info.sigma,geometry_info.xi,exception);
1735 if (LocaleCompare("geometry",option+1) == 0)
1738 Record Image offset, Resize last image.
1740 (void) SyncImageSettings(mogrify_info,*image);
1743 if ((*image)->geometry != (char *) NULL)
1744 (*image)->geometry=DestroyString((*image)->geometry);
1747 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1748 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1749 (void) CloneString(&(*image)->geometry,argv[i+1]);
1751 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1752 (*image)->filter,(*image)->blur,exception);
1755 if (LocaleCompare("gravity",option+1) == 0)
1759 draw_info->gravity=UndefinedGravity;
1762 draw_info->gravity=(GravityType) ParseCommandOption(
1763 MagickGravityOptions,MagickFalse,argv[i+1]);
1770 if (LocaleCompare("highlight-color",option+1) == 0)
1772 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1779 if (LocaleCompare("identify",option+1) == 0)
1784 (void) SyncImageSettings(mogrify_info,*image);
1785 if (format == (char *) NULL)
1787 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1791 text=InterpretImageProperties(mogrify_info,*image,format,
1793 if (text == (char *) NULL)
1795 (void) fputs(text,stdout);
1796 (void) fputc('\n',stdout);
1797 text=DestroyString(text);
1800 if (LocaleCompare("implode",option+1) == 0)
1805 (void) SyncImageSettings(mogrify_info,*image);
1806 (void) ParseGeometry(argv[i+1],&geometry_info);
1807 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1808 interpolate_method,exception);
1811 if (LocaleCompare("interline-spacing",option+1) == 0)
1814 (void) ParseGeometry("0",&geometry_info);
1816 (void) ParseGeometry(argv[i+1],&geometry_info);
1817 draw_info->interline_spacing=geometry_info.rho;
1820 if (LocaleCompare("interpolate",option+1) == 0)
1822 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1823 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1826 if (LocaleCompare("interword-spacing",option+1) == 0)
1829 (void) ParseGeometry("0",&geometry_info);
1831 (void) ParseGeometry(argv[i+1],&geometry_info);
1832 draw_info->interword_spacing=geometry_info.rho;
1839 if (LocaleCompare("kerning",option+1) == 0)
1842 (void) ParseGeometry("0",&geometry_info);
1844 (void) ParseGeometry(argv[i+1],&geometry_info);
1845 draw_info->kerning=geometry_info.rho;
1852 if (LocaleCompare("lat",option+1) == 0)
1855 Local adaptive threshold image.
1857 (void) SyncImageSettings(mogrify_info,*image);
1858 flags=ParseGeometry(argv[i+1],&geometry_info);
1859 if ((flags & PercentValue) != 0)
1860 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1861 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1862 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1863 geometry_info.xi,exception);
1866 if (LocaleCompare("level",option+1) == 0)
1879 (void) SyncImageSettings(mogrify_info,*image);
1880 flags=ParseGeometry(argv[i+1],&geometry_info);
1881 black_point=geometry_info.rho;
1882 white_point=(MagickRealType) QuantumRange;
1883 if ((flags & SigmaValue) != 0)
1884 white_point=geometry_info.sigma;
1886 if ((flags & XiValue) != 0)
1887 gamma=geometry_info.xi;
1888 if ((flags & PercentValue) != 0)
1890 black_point*=(MagickRealType) (QuantumRange/100.0);
1891 white_point*=(MagickRealType) (QuantumRange/100.0);
1893 if ((flags & SigmaValue) == 0)
1894 white_point=(MagickRealType) QuantumRange-black_point;
1895 if ((*option == '+') || ((flags & AspectValue) != 0))
1896 (void) LevelizeImage(*image,black_point,white_point,gamma,
1899 (void) LevelImage(*image,black_point,white_point,gamma,
1901 InheritException(exception,&(*image)->exception);
1904 if (LocaleCompare("level-colors",option+1) == 0)
1907 token[MaxTextExtent];
1916 p=(const char *) argv[i+1];
1917 GetMagickToken(p,&p,token); /* get black point color */
1918 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1919 (void) QueryMagickColor(token,&black_point,exception);
1921 (void) QueryMagickColor("#000000",&black_point,exception);
1922 if (isalpha((int) token[0]) || (token[0] == '#'))
1923 GetMagickToken(p,&p,token);
1925 white_point=black_point; /* set everything to that color */
1928 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1929 GetMagickToken(p,&p,token); /* Get white point color. */
1930 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1931 (void) QueryMagickColor(token,&white_point,exception);
1933 (void) QueryMagickColor("#ffffff",&white_point,exception);
1935 (void) LevelImageColors(*image,&black_point,&white_point,
1936 *option == '+' ? MagickTrue : MagickFalse,exception);
1939 if (LocaleCompare("linear-stretch",option+1) == 0)
1948 (void) SyncImageSettings(mogrify_info,*image);
1949 flags=ParseGeometry(argv[i+1],&geometry_info);
1950 black_point=geometry_info.rho;
1951 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1952 if ((flags & SigmaValue) != 0)
1953 white_point=geometry_info.sigma;
1954 if ((flags & PercentValue) != 0)
1956 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1957 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1959 if ((flags & SigmaValue) == 0)
1960 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1962 (void) LinearStretchImage(*image,black_point,white_point,exception);
1963 InheritException(exception,&(*image)->exception);
1966 if (LocaleCompare("linewidth",option+1) == 0)
1968 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1972 if (LocaleCompare("liquid-rescale",option+1) == 0)
1975 Liquid rescale image.
1977 (void) SyncImageSettings(mogrify_info,*image);
1978 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1979 if ((flags & XValue) == 0)
1981 if ((flags & YValue) == 0)
1983 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1984 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1987 if (LocaleCompare("lowlight-color",option+1) == 0)
1989 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1996 if (LocaleCompare("map",option+1) == 0)
2002 Transform image colors to match this set of colors.
2004 (void) SyncImageSettings(mogrify_info,*image);
2007 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2008 if (remap_image == (Image *) NULL)
2010 (void) RemapImage(quantize_info,*image,remap_image,exception);
2011 remap_image=DestroyImage(remap_image);
2014 if (LocaleCompare("mask",option+1) == 0)
2019 (void) SyncImageSettings(mogrify_info,*image);
2025 (void) SetImageMask(*image,(Image *) NULL,exception);
2031 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2032 if (mask == (Image *) NULL)
2034 (void) SetImageMask(*image,mask,exception);
2035 mask=DestroyImage(mask);
2038 if (LocaleCompare("matte",option+1) == 0)
2040 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2041 SetAlphaChannel : DeactivateAlphaChannel,exception);
2044 if (LocaleCompare("median",option+1) == 0)
2047 Median filter image.
2049 (void) SyncImageSettings(mogrify_info,*image);
2050 flags=ParseGeometry(argv[i+1],&geometry_info);
2051 if ((flags & SigmaValue) == 0)
2052 geometry_info.sigma=geometry_info.rho;
2053 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2054 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2057 if (LocaleCompare("mode",option+1) == 0)
2062 (void) SyncImageSettings(mogrify_info,*image);
2063 flags=ParseGeometry(argv[i+1],&geometry_info);
2064 if ((flags & SigmaValue) == 0)
2065 geometry_info.sigma=geometry_info.rho;
2066 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2067 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2070 if (LocaleCompare("modulate",option+1) == 0)
2072 (void) SyncImageSettings(mogrify_info,*image);
2073 (void) ModulateImage(*image,argv[i+1],exception);
2076 if (LocaleCompare("monitor",option+1) == 0)
2080 (void) SetImageProgressMonitor(*image,
2081 (MagickProgressMonitor) NULL,(void *) NULL);
2084 (void) SetImageProgressMonitor(*image,MonitorProgress,
2088 if (LocaleCompare("monochrome",option+1) == 0)
2090 (void) SyncImageSettings(mogrify_info,*image);
2091 (void) SetImageType(*image,BilevelType,exception);
2094 if (LocaleCompare("morphology",option+1) == 0)
2097 token[MaxTextExtent];
2112 Morphological Image Operation
2114 (void) SyncImageSettings(mogrify_info,*image);
2116 GetMagickToken(p,&p,token);
2117 method=(MorphologyMethod) ParseCommandOption(
2118 MagickMorphologyOptions,MagickFalse,token);
2120 GetMagickToken(p,&p,token);
2121 if ((*p == ':') || (*p == ','))
2122 GetMagickToken(p,&p,token);
2124 iterations=(ssize_t) StringToLong(p);
2125 kernel=AcquireKernelInfo(argv[i+2]);
2126 if (kernel == (KernelInfo *) NULL)
2128 (void) ThrowMagickException(exception,GetMagickModule(),
2129 OptionError,"UnabletoParseKernel","morphology");
2133 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2135 kernel=DestroyKernelInfo(kernel);
2138 if (LocaleCompare("motion-blur",option+1) == 0)
2143 (void) SyncImageSettings(mogrify_info,*image);
2144 flags=ParseGeometry(argv[i+1],&geometry_info);
2145 if ((flags & SigmaValue) == 0)
2146 geometry_info.sigma=1.0;
2147 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2148 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2156 if (LocaleCompare("negate",option+1) == 0)
2158 (void) SyncImageSettings(mogrify_info,*image);
2159 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2160 MagickFalse,exception);
2163 if (LocaleCompare("noise",option+1) == 0)
2165 (void) SyncImageSettings(mogrify_info,*image);
2168 flags=ParseGeometry(argv[i+1],&geometry_info);
2169 if ((flags & SigmaValue) == 0)
2170 geometry_info.sigma=geometry_info.rho;
2171 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2172 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2179 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2180 MagickFalse,argv[i+1]);
2181 mogrify_image=AddNoiseImage(*image,noise,exception);
2185 if (LocaleCompare("normalize",option+1) == 0)
2187 (void) SyncImageSettings(mogrify_info,*image);
2188 (void) NormalizeImage(*image,exception);
2195 if (LocaleCompare("opaque",option+1) == 0)
2200 (void) SyncImageSettings(mogrify_info,*image);
2201 (void) QueryMagickColor(argv[i+1],&target,exception);
2202 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2203 MagickFalse : MagickTrue,exception);
2206 if (LocaleCompare("ordered-dither",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image);
2209 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2216 if (LocaleCompare("paint",option+1) == 0)
2218 (void) SyncImageSettings(mogrify_info,*image);
2219 (void) ParseGeometry(argv[i+1],&geometry_info);
2220 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2221 geometry_info.sigma,exception);
2224 if (LocaleCompare("pen",option+1) == 0)
2228 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2231 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2234 if (LocaleCompare("pointsize",option+1) == 0)
2237 (void) ParseGeometry("12",&geometry_info);
2239 (void) ParseGeometry(argv[i+1],&geometry_info);
2240 draw_info->pointsize=geometry_info.rho;
2243 if (LocaleCompare("polaroid",option+1) == 0)
2252 Simulate a Polaroid picture.
2254 (void) SyncImageSettings(mogrify_info,*image);
2255 random_info=AcquireRandomInfo();
2256 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2257 random_info=DestroyRandomInfo(random_info);
2260 SetGeometryInfo(&geometry_info);
2261 flags=ParseGeometry(argv[i+1],&geometry_info);
2262 angle=geometry_info.rho;
2264 mogrify_image=PolaroidImage(*image,draw_info,angle,
2265 interpolate_method,exception);
2268 if (LocaleCompare("posterize",option+1) == 0)
2273 (void) SyncImageSettings(mogrify_info,*image);
2274 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2275 quantize_info->dither,exception);
2278 if (LocaleCompare("preview",option+1) == 0)
2286 (void) SyncImageSettings(mogrify_info,*image);
2288 preview_type=UndefinedPreview;
2290 preview_type=(PreviewType) ParseCommandOption(
2291 MagickPreviewOptions,MagickFalse,argv[i+1]);
2292 mogrify_image=PreviewImage(*image,preview_type,exception);
2295 if (LocaleCompare("profile",option+1) == 0)
2309 (void) SyncImageSettings(mogrify_info,*image);
2313 Remove a profile from the image.
2315 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2317 InheritException(exception,&(*image)->exception);
2321 Associate a profile with the image.
2323 profile_info=CloneImageInfo(mogrify_info);
2324 profile=GetImageProfile(*image,"iptc");
2325 if (profile != (StringInfo *) NULL)
2326 profile_info->profile=(void *) CloneStringInfo(profile);
2327 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2328 profile_info=DestroyImageInfo(profile_info);
2329 if (profile_image == (Image *) NULL)
2334 profile_info=CloneImageInfo(mogrify_info);
2335 (void) CopyMagickString(profile_info->filename,argv[i+1],
2337 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2338 if (profile != (StringInfo *) NULL)
2340 (void) ProfileImage(*image,profile_info->magick,
2341 GetStringInfoDatum(profile),(size_t)
2342 GetStringInfoLength(profile),MagickFalse);
2343 profile=DestroyStringInfo(profile);
2345 profile_info=DestroyImageInfo(profile_info);
2348 ResetImageProfileIterator(profile_image);
2349 name=GetNextImageProfile(profile_image);
2350 while (name != (const char *) NULL)
2352 profile=GetImageProfile(profile_image,name);
2353 if (profile != (StringInfo *) NULL)
2354 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2355 (size_t) GetStringInfoLength(profile),MagickFalse);
2356 name=GetNextImageProfile(profile_image);
2358 profile_image=DestroyImage(profile_image);
2365 if (LocaleCompare("quantize",option+1) == 0)
2369 quantize_info->colorspace=UndefinedColorspace;
2372 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2373 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2380 if (LocaleCompare("radial-blur",option+1) == 0)
2385 (void) SyncImageSettings(mogrify_info,*image);
2386 flags=ParseGeometry(argv[i+1],&geometry_info);
2387 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2388 geometry_info.sigma,exception);
2391 if (LocaleCompare("raise",option+1) == 0)
2394 Surround image with a raise of solid color.
2396 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2397 if ((flags & SigmaValue) == 0)
2398 geometry.height=geometry.width;
2399 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2400 MagickFalse,exception);
2403 if (LocaleCompare("random-threshold",option+1) == 0)
2408 (void) SyncImageSettings(mogrify_info,*image);
2409 (void) RandomThresholdImage(*image,argv[i+1],exception);
2412 if (LocaleCompare("recolor",option+1) == 0)
2417 (void) SyncImageSettings(mogrify_info,*image);
2418 kernel=AcquireKernelInfo(argv[i+1]);
2419 if (kernel == (KernelInfo *) NULL)
2421 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2422 kernel=DestroyKernelInfo(kernel);
2425 if (LocaleCompare("region",option+1) == 0)
2427 (void) SyncImageSettings(mogrify_info,*image);
2428 if (region_image != (Image *) NULL)
2433 (void) CompositeImage(region_image,region_image->matte !=
2434 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2435 region_geometry.x,region_geometry.y);
2436 InheritException(exception,®ion_image->exception);
2437 *image=DestroyImage(*image);
2438 *image=region_image;
2439 region_image = (Image *) NULL;
2444 Apply transformations to a selected region of the image.
2446 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2448 mogrify_image=CropImage(*image,®ion_geometry,exception);
2449 if (mogrify_image == (Image *) NULL)
2451 region_image=(*image);
2452 *image=mogrify_image;
2453 mogrify_image=(Image *) NULL;
2456 if (LocaleCompare("render",option+1) == 0)
2458 (void) SyncImageSettings(mogrify_info,*image);
2459 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2462 if (LocaleCompare("remap",option+1) == 0)
2468 Transform image colors to match this set of colors.
2470 (void) SyncImageSettings(mogrify_info,*image);
2473 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2474 if (remap_image == (Image *) NULL)
2476 (void) RemapImage(quantize_info,*image,remap_image,exception);
2477 remap_image=DestroyImage(remap_image);
2480 if (LocaleCompare("repage",option+1) == 0)
2484 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2487 (void) ResetImagePage(*image,argv[i+1]);
2488 InheritException(exception,&(*image)->exception);
2491 if (LocaleCompare("resample",option+1) == 0)
2496 (void) SyncImageSettings(mogrify_info,*image);
2497 flags=ParseGeometry(argv[i+1],&geometry_info);
2498 if ((flags & SigmaValue) == 0)
2499 geometry_info.sigma=geometry_info.rho;
2500 mogrify_image=ResampleImage(*image,geometry_info.rho,
2501 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2504 if (LocaleCompare("resize",option+1) == 0)
2509 (void) SyncImageSettings(mogrify_info,*image);
2510 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2511 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2512 (*image)->filter,(*image)->blur,exception);
2515 if (LocaleCompare("roll",option+1) == 0)
2520 (void) SyncImageSettings(mogrify_info,*image);
2521 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2522 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2525 if (LocaleCompare("rotate",option+1) == 0)
2531 Check for conditional image rotation.
2533 (void) SyncImageSettings(mogrify_info,*image);
2534 if (strchr(argv[i+1],'>') != (char *) NULL)
2535 if ((*image)->columns <= (*image)->rows)
2537 if (strchr(argv[i+1],'<') != (char *) NULL)
2538 if ((*image)->columns >= (*image)->rows)
2543 geometry=ConstantString(argv[i+1]);
2544 (void) SubstituteString(&geometry,">","");
2545 (void) SubstituteString(&geometry,"<","");
2546 (void) ParseGeometry(geometry,&geometry_info);
2547 geometry=DestroyString(geometry);
2548 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2555 if (LocaleCompare("sample",option+1) == 0)
2558 Sample image with pixel replication.
2560 (void) SyncImageSettings(mogrify_info,*image);
2561 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2562 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2566 if (LocaleCompare("scale",option+1) == 0)
2571 (void) SyncImageSettings(mogrify_info,*image);
2572 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2573 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2577 if (LocaleCompare("selective-blur",option+1) == 0)
2580 Selectively blur pixels within a contrast threshold.
2582 (void) SyncImageSettings(mogrify_info,*image);
2583 flags=ParseGeometry(argv[i+1],&geometry_info);
2584 if ((flags & PercentValue) != 0)
2585 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2586 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2587 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2590 if (LocaleCompare("separate",option+1) == 0)
2593 Break channels into separate images.
2595 (void) SyncImageSettings(mogrify_info,*image);
2596 mogrify_image=SeparateImages(*image,exception);
2599 if (LocaleCompare("sepia-tone",option+1) == 0)
2607 (void) SyncImageSettings(mogrify_info,*image);
2608 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2609 mogrify_image=SepiaToneImage(*image,threshold,exception);
2612 if (LocaleCompare("segment",option+1) == 0)
2617 (void) SyncImageSettings(mogrify_info,*image);
2618 flags=ParseGeometry(argv[i+1],&geometry_info);
2619 if ((flags & SigmaValue) == 0)
2620 geometry_info.sigma=1.0;
2621 (void) SegmentImage(*image,(*image)->colorspace,
2622 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2626 if (LocaleCompare("set",option+1) == 0)
2636 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2637 (void) DeleteImageRegistry(argv[i+1]+9);
2639 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2641 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2642 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2645 (void) DeleteImageProperty(*image,argv[i+1]);
2648 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2650 if (value == (char *) NULL)
2652 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2653 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2656 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2658 (void) SetImageOption(image_info,argv[i+1]+7,value);
2659 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2660 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2663 (void) SetImageProperty(*image,argv[i+1],value);
2664 value=DestroyString(value);
2667 if (LocaleCompare("shade",option+1) == 0)
2672 (void) SyncImageSettings(mogrify_info,*image);
2673 flags=ParseGeometry(argv[i+1],&geometry_info);
2674 if ((flags & SigmaValue) == 0)
2675 geometry_info.sigma=1.0;
2676 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2677 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2680 if (LocaleCompare("shadow",option+1) == 0)
2685 (void) SyncImageSettings(mogrify_info,*image);
2686 flags=ParseGeometry(argv[i+1],&geometry_info);
2687 if ((flags & SigmaValue) == 0)
2688 geometry_info.sigma=1.0;
2689 if ((flags & XiValue) == 0)
2690 geometry_info.xi=4.0;
2691 if ((flags & PsiValue) == 0)
2692 geometry_info.psi=4.0;
2693 mogrify_image=ShadowImage(*image,geometry_info.rho,
2694 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2695 ceil(geometry_info.psi-0.5),exception);
2698 if (LocaleCompare("sharpen",option+1) == 0)
2703 (void) SyncImageSettings(mogrify_info,*image);
2704 flags=ParseGeometry(argv[i+1],&geometry_info);
2705 if ((flags & SigmaValue) == 0)
2706 geometry_info.sigma=1.0;
2707 if ((flags & XiValue) == 0)
2708 geometry_info.xi=0.0;
2709 mogrify_image=SharpenImage(*image,geometry_info.rho,
2710 geometry_info.sigma,geometry_info.xi,exception);
2713 if (LocaleCompare("shave",option+1) == 0)
2716 Shave the image edges.
2718 (void) SyncImageSettings(mogrify_info,*image);
2719 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2720 mogrify_image=ShaveImage(*image,&geometry,exception);
2723 if (LocaleCompare("shear",option+1) == 0)
2728 (void) SyncImageSettings(mogrify_info,*image);
2729 flags=ParseGeometry(argv[i+1],&geometry_info);
2730 if ((flags & SigmaValue) == 0)
2731 geometry_info.sigma=geometry_info.rho;
2732 mogrify_image=ShearImage(*image,geometry_info.rho,
2733 geometry_info.sigma,exception);
2736 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2739 Sigmoidal non-linearity contrast control.
2741 (void) SyncImageSettings(mogrify_info,*image);
2742 flags=ParseGeometry(argv[i+1],&geometry_info);
2743 if ((flags & SigmaValue) == 0)
2744 geometry_info.sigma=(double) QuantumRange/2.0;
2745 if ((flags & PercentValue) != 0)
2746 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2748 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2749 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2753 if (LocaleCompare("sketch",option+1) == 0)
2758 (void) SyncImageSettings(mogrify_info,*image);
2759 flags=ParseGeometry(argv[i+1],&geometry_info);
2760 if ((flags & SigmaValue) == 0)
2761 geometry_info.sigma=1.0;
2762 mogrify_image=SketchImage(*image,geometry_info.rho,
2763 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2766 if (LocaleCompare("solarize",option+1) == 0)
2771 (void) SyncImageSettings(mogrify_info,*image);
2772 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2773 (void) SolarizeImage(*image,threshold,exception);
2776 if (LocaleCompare("sparse-color",option+1) == 0)
2785 Sparse Color Interpolated Gradient
2787 (void) SyncImageSettings(mogrify_info,*image);
2788 method=(SparseColorMethod) ParseCommandOption(
2789 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2790 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2792 if (arguments == (char *) NULL)
2794 mogrify_image=SparseColorOption(*image,method,arguments,
2795 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2796 arguments=DestroyString(arguments);
2799 if (LocaleCompare("splice",option+1) == 0)
2802 Splice a solid color into the image.
2804 (void) SyncImageSettings(mogrify_info,*image);
2805 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2806 mogrify_image=SpliceImage(*image,&geometry,exception);
2809 if (LocaleCompare("spread",option+1) == 0)
2814 (void) SyncImageSettings(mogrify_info,*image);
2815 (void) ParseGeometry(argv[i+1],&geometry_info);
2816 mogrify_image=SpreadImage(*image,geometry_info.rho,
2817 interpolate_method,exception);
2820 if (LocaleCompare("statistic",option+1) == 0)
2825 (void) SyncImageSettings(mogrify_info,*image);
2826 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2827 MagickFalse,argv[i+1]);
2828 (void) ParseGeometry(argv[i+2],&geometry_info);
2829 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2830 (size_t) geometry_info.sigma,exception);
2833 if (LocaleCompare("stretch",option+1) == 0)
2837 draw_info->stretch=UndefinedStretch;
2840 draw_info->stretch=(StretchType) ParseCommandOption(
2841 MagickStretchOptions,MagickFalse,argv[i+1]);
2844 if (LocaleCompare("strip",option+1) == 0)
2847 Strip image of profiles and comments.
2849 (void) SyncImageSettings(mogrify_info,*image);
2850 (void) StripImage(*image);
2851 InheritException(exception,&(*image)->exception);
2854 if (LocaleCompare("stroke",option+1) == 0)
2861 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2862 if (draw_info->stroke_pattern != (Image *) NULL)
2863 draw_info->stroke_pattern=DestroyImage(
2864 draw_info->stroke_pattern);
2867 sans=AcquireExceptionInfo();
2868 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2869 sans=DestroyExceptionInfo(sans);
2870 if (status == MagickFalse)
2871 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2875 if (LocaleCompare("strokewidth",option+1) == 0)
2877 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2881 if (LocaleCompare("style",option+1) == 0)
2885 draw_info->style=UndefinedStyle;
2888 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2889 MagickFalse,argv[i+1]);
2892 if (LocaleCompare("swirl",option+1) == 0)
2897 (void) SyncImageSettings(mogrify_info,*image);
2898 (void) ParseGeometry(argv[i+1],&geometry_info);
2899 mogrify_image=SwirlImage(*image,geometry_info.rho,
2900 interpolate_method,exception);
2907 if (LocaleCompare("threshold",option+1) == 0)
2915 (void) SyncImageSettings(mogrify_info,*image);
2917 threshold=(double) QuantumRange/2;
2919 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2920 (void) BilevelImage(*image,threshold);
2921 InheritException(exception,&(*image)->exception);
2924 if (LocaleCompare("thumbnail",option+1) == 0)
2929 (void) SyncImageSettings(mogrify_info,*image);
2930 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2931 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2935 if (LocaleCompare("tile",option+1) == 0)
2939 if (draw_info->fill_pattern != (Image *) NULL)
2940 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2943 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2947 if (LocaleCompare("tint",option+1) == 0)
2952 (void) SyncImageSettings(mogrify_info,*image);
2953 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2956 if (LocaleCompare("transform",option+1) == 0)
2959 Affine transform image.
2961 (void) SyncImageSettings(mogrify_info,*image);
2962 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2966 if (LocaleCompare("transparent",option+1) == 0)
2971 (void) SyncImageSettings(mogrify_info,*image);
2972 (void) QueryMagickColor(argv[i+1],&target,exception);
2973 (void) TransparentPaintImage(*image,&target,(Quantum)
2974 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2975 &(*image)->exception);
2978 if (LocaleCompare("transpose",option+1) == 0)
2981 Transpose image scanlines.
2983 (void) SyncImageSettings(mogrify_info,*image);
2984 mogrify_image=TransposeImage(*image,exception);
2987 if (LocaleCompare("transverse",option+1) == 0)
2990 Transverse image scanlines.
2992 (void) SyncImageSettings(mogrify_info,*image);
2993 mogrify_image=TransverseImage(*image,exception);
2996 if (LocaleCompare("treedepth",option+1) == 0)
2998 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3001 if (LocaleCompare("trim",option+1) == 0)
3006 (void) SyncImageSettings(mogrify_info,*image);
3007 mogrify_image=TrimImage(*image,exception);
3010 if (LocaleCompare("type",option+1) == 0)
3015 (void) SyncImageSettings(mogrify_info,*image);
3019 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3021 (*image)->type=UndefinedType;
3022 (void) SetImageType(*image,type,exception);
3029 if (LocaleCompare("undercolor",option+1) == 0)
3031 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3035 if (LocaleCompare("unique",option+1) == 0)
3039 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3042 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3043 (void) SetImageArtifact(*image,"verbose","true");
3046 if (LocaleCompare("unique-colors",option+1) == 0)
3049 Unique image colors.
3051 (void) SyncImageSettings(mogrify_info,*image);
3052 mogrify_image=UniqueImageColors(*image,exception);
3055 if (LocaleCompare("unsharp",option+1) == 0)
3060 (void) SyncImageSettings(mogrify_info,*image);
3061 flags=ParseGeometry(argv[i+1],&geometry_info);
3062 if ((flags & SigmaValue) == 0)
3063 geometry_info.sigma=1.0;
3064 if ((flags & XiValue) == 0)
3065 geometry_info.xi=1.0;
3066 if ((flags & PsiValue) == 0)
3067 geometry_info.psi=0.05;
3068 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3069 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3076 if (LocaleCompare("verbose",option+1) == 0)
3078 (void) SetImageArtifact(*image,option+1,
3079 *option == '+' ? "false" : "true");
3082 if (LocaleCompare("vignette",option+1) == 0)
3087 (void) SyncImageSettings(mogrify_info,*image);
3088 flags=ParseGeometry(argv[i+1],&geometry_info);
3089 if ((flags & SigmaValue) == 0)
3090 geometry_info.sigma=1.0;
3091 if ((flags & XiValue) == 0)
3092 geometry_info.xi=0.1*(*image)->columns;
3093 if ((flags & PsiValue) == 0)
3094 geometry_info.psi=0.1*(*image)->rows;
3095 mogrify_image=VignetteImage(*image,geometry_info.rho,
3096 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3097 ceil(geometry_info.psi-0.5),exception);
3100 if (LocaleCompare("virtual-pixel",option+1) == 0)
3104 (void) SetImageVirtualPixelMethod(*image,
3105 UndefinedVirtualPixelMethod);
3108 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3109 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3117 if (LocaleCompare("wave",option+1) == 0)
3122 (void) SyncImageSettings(mogrify_info,*image);
3123 flags=ParseGeometry(argv[i+1],&geometry_info);
3124 if ((flags & SigmaValue) == 0)
3125 geometry_info.sigma=1.0;
3126 mogrify_image=WaveImage(*image,geometry_info.rho,
3127 geometry_info.sigma,interpolate_method,exception);
3130 if (LocaleCompare("weight",option+1) == 0)
3132 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3133 if (LocaleCompare(argv[i+1],"all") == 0)
3134 draw_info->weight=0;
3135 if (LocaleCompare(argv[i+1],"bold") == 0)
3136 draw_info->weight=700;
3137 if (LocaleCompare(argv[i+1],"bolder") == 0)
3138 if (draw_info->weight <= 800)
3139 draw_info->weight+=100;
3140 if (LocaleCompare(argv[i+1],"lighter") == 0)
3141 if (draw_info->weight >= 100)
3142 draw_info->weight-=100;
3143 if (LocaleCompare(argv[i+1],"normal") == 0)
3144 draw_info->weight=400;
3147 if (LocaleCompare("white-threshold",option+1) == 0)
3150 White threshold image.
3152 (void) SyncImageSettings(mogrify_info,*image);
3153 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3154 InheritException(exception,&(*image)->exception);
3163 Replace current image with any image that was generated
3165 if (mogrify_image != (Image *) NULL)
3166 ReplaceImageInListReturnLast(image,mogrify_image);
3169 if (region_image != (Image *) NULL)
3172 Composite transformed region onto image.
3174 (void) SyncImageSettings(mogrify_info,*image);
3175 (void) CompositeImage(region_image,region_image->matte !=
3176 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3177 region_geometry.x,region_geometry.y);
3178 InheritException(exception,®ion_image->exception);
3179 *image=DestroyImage(*image);
3180 *image=region_image;
3181 region_image = (Image *) NULL;
3186 quantize_info=DestroyQuantizeInfo(quantize_info);
3187 draw_info=DestroyDrawInfo(draw_info);
3188 mogrify_info=DestroyImageInfo(mogrify_info);
3189 status=(MagickStatusType) ((*image)->exception.severity ==
3190 UndefinedException ? 1 : 0);
3191 return(status == 0 ? MagickFalse : MagickTrue);
3195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3199 + M o g r i f y I m a g e C o m m a n d %
3203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3205 % MogrifyImageCommand() transforms an image or a sequence of images. These
3206 % transforms include image scaling, image rotation, color reduction, and
3207 % others. The transmogrified image overwrites the original image.
3209 % The format of the MogrifyImageCommand method is:
3211 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3212 % const char **argv,char **metadata,ExceptionInfo *exception)
3214 % A description of each parameter follows:
3216 % o image_info: the image info.
3218 % o argc: the number of elements in the argument vector.
3220 % o argv: A text array containing the command line arguments.
3222 % o metadata: any metadata is returned here.
3224 % o exception: return any errors or warnings in this structure.
3228 static MagickBooleanType MogrifyUsage(void)
3233 "-debug events display copious debugging information",
3234 "-help print program options",
3235 "-list type print a list of supported option arguments",
3236 "-log format format of debugging information",
3237 "-version print version information",
3242 "-adaptive-blur geometry",
3243 " adaptively blur pixels; decrease effect near edges",
3244 "-adaptive-resize geometry",
3245 " adaptively resize image using 'mesh' interpolation",
3246 "-adaptive-sharpen geometry",
3247 " adaptively sharpen pixels; increase effect near edges",
3248 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3249 " transparent, extract, background, or shape",
3250 "-annotate geometry text",
3251 " annotate the image with text",
3252 "-auto-gamma automagically adjust gamma level of image",
3253 "-auto-level automagically adjust color levels of image",
3254 "-auto-orient automagically orient (rotate) image",
3255 "-bench iterations measure performance",
3256 "-black-threshold value",
3257 " force all pixels below the threshold into black",
3258 "-blue-shift simulate a scene at nighttime in the moonlight",
3259 "-blur geometry reduce image noise and reduce detail levels",
3260 "-border geometry surround image with a border of color",
3261 "-bordercolor color border color",
3262 "-brightness-contrast geometry",
3263 " improve brightness / contrast of the image",
3264 "-cdl filename color correct with a color decision list",
3265 "-charcoal geometry simulate a charcoal drawing",
3266 "-chop geometry remove pixels from the image interior",
3267 "-clamp restrict pixel range from 0 to the quantum depth",
3268 "-clip clip along the first path from the 8BIM profile",
3269 "-clip-mask filename associate a clip mask with the image",
3270 "-clip-path id clip along a named path from the 8BIM profile",
3271 "-colorize value colorize the image with the fill color",
3272 "-color-matrix matrix apply color correction to the image",
3273 "-contrast enhance or reduce the image contrast",
3274 "-contrast-stretch geometry",
3275 " improve contrast by `stretching' the intensity range",
3276 "-convolve coefficients",
3277 " apply a convolution kernel to the image",
3278 "-cycle amount cycle the image colormap",
3279 "-decipher filename convert cipher pixels to plain pixels",
3280 "-deskew threshold straighten an image",
3281 "-despeckle reduce the speckles within an image",
3282 "-distort method args",
3283 " distort images according to given method ad args",
3284 "-draw string annotate the image with a graphic primitive",
3285 "-edge radius apply a filter to detect edges in the image",
3286 "-encipher filename convert plain pixels to cipher pixels",
3287 "-emboss radius emboss an image",
3288 "-enhance apply a digital filter to enhance a noisy image",
3289 "-equalize perform histogram equalization to an image",
3290 "-evaluate operator value",
3291 " evaluate an arithmetic, relational, or logical expression",
3292 "-extent geometry set the image size",
3293 "-extract geometry extract area from image",
3294 "-fft implements the discrete Fourier transform (DFT)",
3295 "-flip flip image vertically",
3296 "-floodfill geometry color",
3297 " floodfill the image with color",
3298 "-flop flop image horizontally",
3299 "-frame geometry surround image with an ornamental border",
3300 "-function name parameters",
3301 " apply function over image values",
3302 "-gamma value level of gamma correction",
3303 "-gaussian-blur geometry",
3304 " reduce image noise and reduce detail levels",
3305 "-geometry geometry preferred size or location of the image",
3306 "-identify identify the format and characteristics of the image",
3307 "-ift implements the inverse discrete Fourier transform (DFT)",
3308 "-implode amount implode image pixels about the center",
3309 "-lat geometry local adaptive thresholding",
3310 "-layers method optimize, merge, or compare image layers",
3311 "-level value adjust the level of image contrast",
3312 "-level-colors color,color",
3313 " level image with the given colors",
3314 "-linear-stretch geometry",
3315 " improve contrast by `stretching with saturation'",
3316 "-liquid-rescale geometry",
3317 " rescale image with seam-carving",
3318 "-median geometry apply a median filter to the image",
3319 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3320 "-modulate value vary the brightness, saturation, and hue",
3321 "-monochrome transform image to black and white",
3322 "-morphology method kernel",
3323 " apply a morphology method to the image",
3324 "-motion-blur geometry",
3325 " simulate motion blur",
3326 "-negate replace every pixel with its complementary color ",
3327 "-noise geometry add or reduce noise in an image",
3328 "-normalize transform image to span the full range of colors",
3329 "-opaque color change this color to the fill color",
3330 "-ordered-dither NxN",
3331 " add a noise pattern to the image with specific",
3333 "-paint radius simulate an oil painting",
3334 "-polaroid angle simulate a Polaroid picture",
3335 "-posterize levels reduce the image to a limited number of color levels",
3336 "-profile filename add, delete, or apply an image profile",
3337 "-quantize colorspace reduce colors in this colorspace",
3338 "-radial-blur angle radial blur the image",
3339 "-raise value lighten/darken image edges to create a 3-D effect",
3340 "-random-threshold low,high",
3341 " random threshold the image",
3342 "-region geometry apply options to a portion of the image",
3343 "-render render vector graphics",
3344 "-repage geometry size and location of an image canvas",
3345 "-resample geometry change the resolution of an image",
3346 "-resize geometry resize the image",
3347 "-roll geometry roll an image vertically or horizontally",
3348 "-rotate degrees apply Paeth rotation to the image",
3349 "-sample geometry scale image with pixel sampling",
3350 "-scale geometry scale the image",
3351 "-segment values segment an image",
3352 "-selective-blur geometry",
3353 " selectively blur pixels within a contrast threshold",
3354 "-sepia-tone threshold",
3355 " simulate a sepia-toned photo",
3356 "-set property value set an image property",
3357 "-shade degrees shade the image using a distant light source",
3358 "-shadow geometry simulate an image shadow",
3359 "-sharpen geometry sharpen the image",
3360 "-shave geometry shave pixels from the image edges",
3361 "-shear geometry slide one edge of the image along the X or Y axis",
3362 "-sigmoidal-contrast geometry",
3363 " increase the contrast without saturating highlights or shadows",
3364 "-sketch geometry simulate a pencil sketch",
3365 "-solarize threshold negate all pixels above the threshold level",
3366 "-sparse-color method args",
3367 " fill in a image based on a few color points",
3368 "-splice geometry splice the background color into the image",
3369 "-spread radius displace image pixels by a random amount",
3370 "-statistic type radius",
3371 " replace each pixel with corresponding statistic from the neighborhood",
3372 "-strip strip image of all profiles and comments",
3373 "-swirl degrees swirl image pixels about the center",
3374 "-threshold value threshold the image",
3375 "-thumbnail geometry create a thumbnail of the image",
3376 "-tile filename tile image when filling a graphic primitive",
3377 "-tint value tint the image with the fill color",
3378 "-transform affine transform image",
3379 "-transparent color make this color transparent within the image",
3380 "-transpose flip image vertically and rotate 90 degrees",
3381 "-transverse flop image horizontally and rotate 270 degrees",
3382 "-trim trim image edges",
3383 "-type type image type",
3384 "-unique-colors discard all but one of any pixel color",
3385 "-unsharp geometry sharpen the image",
3386 "-vignette geometry soften the edges of the image in vignette style",
3387 "-wave geometry alter an image along a sine wave",
3388 "-white-threshold value",
3389 " force all pixels above the threshold into white",
3392 *sequence_operators[]=
3394 "-append append an image sequence",
3395 "-clut apply a color lookup table to the image",
3396 "-coalesce merge a sequence of images",
3397 "-combine combine a sequence of images",
3398 "-composite composite image",
3399 "-crop geometry cut out a rectangular region of the image",
3400 "-deconstruct break down an image sequence into constituent parts",
3401 "-evaluate-sequence operator",
3402 " evaluate an arithmetic, relational, or logical expression",
3403 "-flatten flatten a sequence of images",
3404 "-fx expression apply mathematical expression to an image channel(s)",
3405 "-hald-clut apply a Hald color lookup table to the image",
3406 "-morph value morph an image sequence",
3407 "-mosaic create a mosaic from an image sequence",
3408 "-print string interpret string and print to console",
3409 "-process arguments process the image with a custom image filter",
3410 "-separate separate an image channel into a grayscale image",
3411 "-smush geometry smush an image sequence together",
3412 "-write filename write images to this file",
3417 "-adjoin join images into a single multi-image file",
3418 "-affine matrix affine transform matrix",
3419 "-alpha option activate, deactivate, reset, or set the alpha channel",
3420 "-antialias remove pixel-aliasing",
3421 "-authenticate password",
3422 " decipher image with this password",
3423 "-attenuate value lessen (or intensify) when adding noise to an image",
3424 "-background color background color",
3425 "-bias value add bias when convolving an image",
3426 "-black-point-compensation",
3427 " use black point compensation",
3428 "-blue-primary point chromaticity blue primary point",
3429 "-bordercolor color border color",
3430 "-caption string assign a caption to an image",
3431 "-channel type apply option to select image channels",
3432 "-colors value preferred number of colors in the image",
3433 "-colorspace type alternate image colorspace",
3434 "-comment string annotate image with comment",
3435 "-compose operator set image composite operator",
3436 "-compress type type of pixel compression when writing the image",
3437 "-define format:option",
3438 " define one or more image format options",
3439 "-delay value display the next image after pausing",
3440 "-density geometry horizontal and vertical density of the image",
3441 "-depth value image depth",
3442 "-direction type render text right-to-left or left-to-right",
3443 "-display server get image or font from this X server",
3444 "-dispose method layer disposal method",
3445 "-dither method apply error diffusion to image",
3446 "-encoding type text encoding type",
3447 "-endian type endianness (MSB or LSB) of the image",
3448 "-family name render text with this font family",
3449 "-fill color color to use when filling a graphic primitive",
3450 "-filter type use this filter when resizing an image",
3451 "-font name render text with this font",
3452 "-format \"string\" output formatted image characteristics",
3453 "-fuzz distance colors within this distance are considered equal",
3454 "-gravity type horizontal and vertical text placement",
3455 "-green-primary point chromaticity green primary point",
3456 "-intent type type of rendering intent when managing the image color",
3457 "-interlace type type of image interlacing scheme",
3458 "-interline-spacing value",
3459 " set the space between two text lines",
3460 "-interpolate method pixel color interpolation method",
3461 "-interword-spacing value",
3462 " set the space between two words",
3463 "-kerning value set the space between two letters",
3464 "-label string assign a label to an image",
3465 "-limit type value pixel cache resource limit",
3466 "-loop iterations add Netscape loop extension to your GIF animation",
3467 "-mask filename associate a mask with the image",
3468 "-mattecolor color frame color",
3469 "-monitor monitor progress",
3470 "-orient type image orientation",
3471 "-page geometry size and location of an image canvas (setting)",
3472 "-ping efficiently determine image attributes",
3473 "-pointsize value font point size",
3474 "-precision value maximum number of significant digits to print",
3475 "-preview type image preview type",
3476 "-quality value JPEG/MIFF/PNG compression level",
3477 "-quiet suppress all warning messages",
3478 "-red-primary point chromaticity red primary point",
3479 "-regard-warnings pay attention to warning messages",
3480 "-remap filename transform image colors to match this set of colors",
3481 "-respect-parentheses settings remain in effect until parenthesis boundary",
3482 "-sampling-factor geometry",
3483 " horizontal and vertical sampling factor",
3484 "-scene value image scene number",
3485 "-seed value seed a new sequence of pseudo-random numbers",
3486 "-size geometry width and height of image",
3487 "-stretch type render text with this font stretch",
3488 "-stroke color graphic primitive stroke color",
3489 "-strokewidth value graphic primitive stroke width",
3490 "-style type render text with this font style",
3491 "-synchronize synchronize image to storage device",
3492 "-taint declare the image as modified",
3493 "-texture filename name of texture to tile onto the image background",
3494 "-tile-offset geometry",
3496 "-treedepth value color tree depth",
3497 "-transparent-color color",
3498 " transparent color",
3499 "-undercolor color annotation bounding box color",
3500 "-units type the units of image resolution",
3501 "-verbose print detailed information about the image",
3502 "-view FlashPix viewing transforms",
3503 "-virtual-pixel method",
3504 " virtual pixel access method",
3505 "-weight type render text with this font weight",
3506 "-white-point point chromaticity white point",
3511 "-delete indexes delete the image from the image sequence",
3512 "-duplicate count,indexes",
3513 " duplicate an image one or more times",
3514 "-insert index insert last image into the image sequence",
3515 "-reverse reverse image sequence",
3516 "-swap indexes swap two images in the image sequence",
3523 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3524 (void) printf("Copyright: %s\n",GetMagickCopyright());
3525 (void) printf("Features: %s\n\n",GetMagickFeatures());
3526 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3528 (void) printf("\nImage Settings:\n");
3529 for (p=settings; *p != (char *) NULL; p++)
3530 (void) printf(" %s\n",*p);
3531 (void) printf("\nImage Operators:\n");
3532 for (p=operators; *p != (char *) NULL; p++)
3533 (void) printf(" %s\n",*p);
3534 (void) printf("\nImage Sequence Operators:\n");
3535 for (p=sequence_operators; *p != (char *) NULL; p++)
3536 (void) printf(" %s\n",*p);
3537 (void) printf("\nImage Stack Operators:\n");
3538 for (p=stack_operators; *p != (char *) NULL; p++)
3539 (void) printf(" %s\n",*p);
3540 (void) printf("\nMiscellaneous Options:\n");
3541 for (p=miscellaneous; *p != (char *) NULL; p++)
3542 (void) printf(" %s\n",*p);
3544 "\nBy default, the image format of `file' is determined by its magic\n");
3546 "number. To specify a particular image format, precede the filename\n");
3548 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3550 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3551 (void) printf("'-' for standard input or output.\n");
3552 return(MagickFalse);
3555 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3556 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3558 #define DestroyMogrify() \
3560 if (format != (char *) NULL) \
3561 format=DestroyString(format); \
3562 if (path != (char *) NULL) \
3563 path=DestroyString(path); \
3564 DestroyImageStack(); \
3565 for (i=0; i < (ssize_t) argc; i++) \
3566 argv[i]=DestroyString(argv[i]); \
3567 argv=(char **) RelinquishMagickMemory(argv); \
3569 #define ThrowMogrifyException(asperity,tag,option) \
3571 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3574 return(MagickFalse); \
3576 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3578 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3579 "InvalidArgument","`%s': %s",argument,option); \
3581 return(MagickFalse); \
3593 image_stack[MaxImageStackDepth+1];
3601 respect_parenthesis;
3616 assert(image_info != (ImageInfo *) NULL);
3617 assert(image_info->signature == MagickSignature);
3618 if (image_info->debug != MagickFalse)
3619 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3620 assert(exception != (ExceptionInfo *) NULL);
3624 if ((LocaleCompare("version",option+1) == 0) ||
3625 (LocaleCompare("-version",option+1) == 0))
3627 (void) FormatLocaleFile(stdout,"Version: %s\n",
3628 GetMagickVersion((size_t *) NULL));
3629 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3630 GetMagickCopyright());
3631 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3632 GetMagickFeatures());
3633 return(MagickFalse);
3637 return(MogrifyUsage());
3638 format=(char *) NULL;
3640 global_colormap=MagickFalse;
3644 option=(char *) NULL;
3646 respect_parenthesis=MagickFalse;
3651 ReadCommandlLine(argc,&argv);
3652 status=ExpandFilenames(&argc,&argv);
3653 if (status == MagickFalse)
3654 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3655 GetExceptionMessage(errno));
3656 for (i=1; i < (ssize_t) argc; i++)
3659 if (LocaleCompare(option,"(") == 0)
3661 FireImageStack(MagickFalse,MagickTrue,pend);
3662 if (k == MaxImageStackDepth)
3663 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3668 if (LocaleCompare(option,")") == 0)
3670 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3672 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3676 if (IsCommandOption(option) == MagickFalse)
3679 backup_filename[MaxTextExtent],
3686 Option is a file name: begin by reading image from specified file.
3688 FireImageStack(MagickFalse,MagickFalse,pend);
3690 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3692 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3693 images=ReadImages(image_info,exception);
3694 status&=(images != (Image *) NULL) &&
3695 (exception->severity < ErrorException);
3696 if (images == (Image *) NULL)
3698 if (format != (char *) NULL)
3699 (void) CopyMagickString(images->filename,images->magick_filename,
3701 if (path != (char *) NULL)
3703 GetPathComponent(option,TailPath,filename);
3704 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3705 path,*DirectorySeparator,filename);
3707 if (format != (char *) NULL)
3708 AppendImageFormat(format,images->filename);
3709 AppendImageStack(images);
3710 FinalizeImageSettings(image_info,image,MagickFalse);
3711 if (global_colormap != MagickFalse)
3716 quantize_info=AcquireQuantizeInfo(image_info);
3717 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3718 quantize_info=DestroyQuantizeInfo(quantize_info);
3720 *backup_filename='\0';
3721 if ((LocaleCompare(image->filename,"-") != 0) &&
3722 (IsPathWritable(image->filename) != MagickFalse))
3728 Rename image file as backup.
3730 (void) CopyMagickString(backup_filename,image->filename,
3732 for (i=0; i < 6; i++)
3734 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3735 if (IsPathAccessible(backup_filename) == MagickFalse)
3738 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3739 (rename_utf8(image->filename,backup_filename) != 0))
3740 *backup_filename='\0';
3743 Write transmogrified image to disk.
3745 image_info->synchronize=MagickTrue;
3746 status&=WriteImages(image_info,image,image->filename,exception);
3747 if ((status == MagickFalse) && (*backup_filename != '\0'))
3748 (void) remove_utf8(backup_filename);
3749 RemoveAllImageStack();
3752 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3753 switch (*(option+1))
3757 if (LocaleCompare("adaptive-blur",option+1) == 0)
3760 if (i == (ssize_t) argc)
3761 ThrowMogrifyException(OptionError,"MissingArgument",option);
3762 if (IsGeometry(argv[i]) == MagickFalse)
3763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3766 if (LocaleCompare("adaptive-resize",option+1) == 0)
3769 if (i == (ssize_t) argc)
3770 ThrowMogrifyException(OptionError,"MissingArgument",option);
3771 if (IsGeometry(argv[i]) == MagickFalse)
3772 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3775 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3778 if (i == (ssize_t) argc)
3779 ThrowMogrifyException(OptionError,"MissingArgument",option);
3780 if (IsGeometry(argv[i]) == MagickFalse)
3781 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3784 if (LocaleCompare("affine",option+1) == 0)
3789 if (i == (ssize_t) argc)
3790 ThrowMogrifyException(OptionError,"MissingArgument",option);
3793 if (LocaleCompare("alpha",option+1) == 0)
3801 if (i == (ssize_t) argc)
3802 ThrowMogrifyException(OptionError,"MissingArgument",option);
3803 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3805 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3809 if (LocaleCompare("annotate",option+1) == 0)
3814 if (i == (ssize_t) argc)
3815 ThrowMogrifyException(OptionError,"MissingArgument",option);
3816 if (IsGeometry(argv[i]) == MagickFalse)
3817 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3818 if (i == (ssize_t) argc)
3819 ThrowMogrifyException(OptionError,"MissingArgument",option);
3823 if (LocaleCompare("antialias",option+1) == 0)
3825 if (LocaleCompare("append",option+1) == 0)
3827 if (LocaleCompare("attenuate",option+1) == 0)
3832 if (i == (ssize_t) (argc-1))
3833 ThrowMogrifyException(OptionError,"MissingArgument",option);
3834 if (IsGeometry(argv[i]) == MagickFalse)
3835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3838 if (LocaleCompare("authenticate",option+1) == 0)
3843 if (i == (ssize_t) argc)
3844 ThrowMogrifyException(OptionError,"MissingArgument",option);
3847 if (LocaleCompare("auto-gamma",option+1) == 0)
3849 if (LocaleCompare("auto-level",option+1) == 0)
3851 if (LocaleCompare("auto-orient",option+1) == 0)
3853 if (LocaleCompare("average",option+1) == 0)
3855 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3859 if (LocaleCompare("background",option+1) == 0)
3864 if (i == (ssize_t) argc)
3865 ThrowMogrifyException(OptionError,"MissingArgument",option);
3868 if (LocaleCompare("bias",option+1) == 0)
3873 if (i == (ssize_t) (argc-1))
3874 ThrowMogrifyException(OptionError,"MissingArgument",option);
3875 if (IsGeometry(argv[i]) == MagickFalse)
3876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3879 if (LocaleCompare("black-point-compensation",option+1) == 0)
3881 if (LocaleCompare("black-threshold",option+1) == 0)
3886 if (i == (ssize_t) argc)
3887 ThrowMogrifyException(OptionError,"MissingArgument",option);
3888 if (IsGeometry(argv[i]) == MagickFalse)
3889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3892 if (LocaleCompare("blue-primary",option+1) == 0)
3897 if (i == (ssize_t) argc)
3898 ThrowMogrifyException(OptionError,"MissingArgument",option);
3899 if (IsGeometry(argv[i]) == MagickFalse)
3900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3903 if (LocaleCompare("blue-shift",option+1) == 0)
3906 if (i == (ssize_t) argc)
3907 ThrowMogrifyException(OptionError,"MissingArgument",option);
3908 if (IsGeometry(argv[i]) == MagickFalse)
3909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3912 if (LocaleCompare("blur",option+1) == 0)
3915 if (i == (ssize_t) argc)
3916 ThrowMogrifyException(OptionError,"MissingArgument",option);
3917 if (IsGeometry(argv[i]) == MagickFalse)
3918 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3921 if (LocaleCompare("border",option+1) == 0)
3926 if (i == (ssize_t) argc)
3927 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (IsGeometry(argv[i]) == MagickFalse)
3929 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3932 if (LocaleCompare("bordercolor",option+1) == 0)
3937 if (i == (ssize_t) argc)
3938 ThrowMogrifyException(OptionError,"MissingArgument",option);
3941 if (LocaleCompare("box",option+1) == 0)
3946 if (i == (ssize_t) argc)
3947 ThrowMogrifyException(OptionError,"MissingArgument",option);
3950 if (LocaleCompare("brightness-contrast",option+1) == 0)
3953 if (i == (ssize_t) argc)
3954 ThrowMogrifyException(OptionError,"MissingArgument",option);
3955 if (IsGeometry(argv[i]) == MagickFalse)
3956 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3959 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3963 if (LocaleCompare("cache",option+1) == 0)
3968 if (i == (ssize_t) argc)
3969 ThrowMogrifyException(OptionError,"MissingArgument",option);
3970 if (IsGeometry(argv[i]) == MagickFalse)
3971 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3974 if (LocaleCompare("caption",option+1) == 0)
3979 if (i == (ssize_t) argc)
3980 ThrowMogrifyException(OptionError,"MissingArgument",option);
3983 if (LocaleCompare("channel",option+1) == 0)
3991 if (i == (ssize_t) (argc-1))
3992 ThrowMogrifyException(OptionError,"MissingArgument",option);
3993 channel=ParseChannelOption(argv[i]);
3995 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
3999 if (LocaleCompare("cdl",option+1) == 0)
4004 if (i == (ssize_t) (argc-1))
4005 ThrowMogrifyException(OptionError,"MissingArgument",option);
4008 if (LocaleCompare("charcoal",option+1) == 0)
4013 if (i == (ssize_t) argc)
4014 ThrowMogrifyException(OptionError,"MissingArgument",option);
4015 if (IsGeometry(argv[i]) == MagickFalse)
4016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4019 if (LocaleCompare("chop",option+1) == 0)
4024 if (i == (ssize_t) argc)
4025 ThrowMogrifyException(OptionError,"MissingArgument",option);
4026 if (IsGeometry(argv[i]) == MagickFalse)
4027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4030 if (LocaleCompare("clamp",option+1) == 0)
4032 if (LocaleCompare("clip",option+1) == 0)
4034 if (LocaleCompare("clip-mask",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (LocaleCompare("clut",option+1) == 0)
4045 if (LocaleCompare("coalesce",option+1) == 0)
4047 if (LocaleCompare("colorize",option+1) == 0)
4052 if (i == (ssize_t) argc)
4053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4054 if (IsGeometry(argv[i]) == MagickFalse)
4055 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4058 if (LocaleCompare("color-matrix",option+1) == 0)
4066 if (i == (ssize_t) (argc-1))
4067 ThrowMogrifyException(OptionError,"MissingArgument",option);
4068 kernel_info=AcquireKernelInfo(argv[i]);
4069 if (kernel_info == (KernelInfo *) NULL)
4070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4071 kernel_info=DestroyKernelInfo(kernel_info);
4074 if (LocaleCompare("colors",option+1) == 0)
4079 if (i == (ssize_t) argc)
4080 ThrowMogrifyException(OptionError,"MissingArgument",option);
4081 if (IsGeometry(argv[i]) == MagickFalse)
4082 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4085 if (LocaleCompare("colorspace",option+1) == 0)
4093 if (i == (ssize_t) argc)
4094 ThrowMogrifyException(OptionError,"MissingArgument",option);
4095 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4098 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4102 if (LocaleCompare("combine",option+1) == 0)
4104 if (LocaleCompare("comment",option+1) == 0)
4109 if (i == (ssize_t) argc)
4110 ThrowMogrifyException(OptionError,"MissingArgument",option);
4113 if (LocaleCompare("composite",option+1) == 0)
4115 if (LocaleCompare("compress",option+1) == 0)
4123 if (i == (ssize_t) argc)
4124 ThrowMogrifyException(OptionError,"MissingArgument",option);
4125 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4128 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4132 if (LocaleCompare("concurrent",option+1) == 0)
4134 if (LocaleCompare("contrast",option+1) == 0)
4136 if (LocaleCompare("contrast-stretch",option+1) == 0)
4139 if (i == (ssize_t) argc)
4140 ThrowMogrifyException(OptionError,"MissingArgument",option);
4141 if (IsGeometry(argv[i]) == MagickFalse)
4142 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4145 if (LocaleCompare("convolve",option+1) == 0)
4153 if (i == (ssize_t) argc)
4154 ThrowMogrifyException(OptionError,"MissingArgument",option);
4155 kernel_info=AcquireKernelInfo(argv[i]);
4156 if (kernel_info == (KernelInfo *) NULL)
4157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4158 kernel_info=DestroyKernelInfo(kernel_info);
4161 if (LocaleCompare("crop",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4168 if (IsGeometry(argv[i]) == MagickFalse)
4169 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172 if (LocaleCompare("cycle",option+1) == 0)
4177 if (i == (ssize_t) argc)
4178 ThrowMogrifyException(OptionError,"MissingArgument",option);
4179 if (IsGeometry(argv[i]) == MagickFalse)
4180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4183 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4187 if (LocaleCompare("decipher",option+1) == 0)
4192 if (i == (ssize_t) (argc-1))
4193 ThrowMogrifyException(OptionError,"MissingArgument",option);
4196 if (LocaleCompare("deconstruct",option+1) == 0)
4198 if (LocaleCompare("debug",option+1) == 0)
4206 if (i == (ssize_t) argc)
4207 ThrowMogrifyException(OptionError,"MissingArgument",option);
4208 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4210 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4212 (void) SetLogEventMask(argv[i]);
4215 if (LocaleCompare("define",option+1) == 0)
4218 if (i == (ssize_t) argc)
4219 ThrowMogrifyException(OptionError,"MissingArgument",option);
4225 define=GetImageOption(image_info,argv[i]);
4226 if (define == (const char *) NULL)
4227 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4232 if (LocaleCompare("delay",option+1) == 0)
4237 if (i == (ssize_t) argc)
4238 ThrowMogrifyException(OptionError,"MissingArgument",option);
4239 if (IsGeometry(argv[i]) == MagickFalse)
4240 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4243 if (LocaleCompare("delete",option+1) == 0)
4248 if (i == (ssize_t) (argc-1))
4249 ThrowMogrifyException(OptionError,"MissingArgument",option);
4250 if (IsGeometry(argv[i]) == MagickFalse)
4251 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4254 if (LocaleCompare("density",option+1) == 0)
4259 if (i == (ssize_t) argc)
4260 ThrowMogrifyException(OptionError,"MissingArgument",option);
4261 if (IsGeometry(argv[i]) == MagickFalse)
4262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4265 if (LocaleCompare("depth",option+1) == 0)
4270 if (i == (ssize_t) argc)
4271 ThrowMogrifyException(OptionError,"MissingArgument",option);
4272 if (IsGeometry(argv[i]) == MagickFalse)
4273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4276 if (LocaleCompare("deskew",option+1) == 0)
4281 if (i == (ssize_t) argc)
4282 ThrowMogrifyException(OptionError,"MissingArgument",option);
4283 if (IsGeometry(argv[i]) == MagickFalse)
4284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4287 if (LocaleCompare("despeckle",option+1) == 0)
4289 if (LocaleCompare("dft",option+1) == 0)
4291 if (LocaleCompare("direction",option+1) == 0)
4299 if (i == (ssize_t) argc)
4300 ThrowMogrifyException(OptionError,"MissingArgument",option);
4301 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4304 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4308 if (LocaleCompare("display",option+1) == 0)
4313 if (i == (ssize_t) argc)
4314 ThrowMogrifyException(OptionError,"MissingArgument",option);
4317 if (LocaleCompare("dispose",option+1) == 0)
4325 if (i == (ssize_t) argc)
4326 ThrowMogrifyException(OptionError,"MissingArgument",option);
4327 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4329 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4333 if (LocaleCompare("distort",option+1) == 0)
4339 if (i == (ssize_t) argc)
4340 ThrowMogrifyException(OptionError,"MissingArgument",option);
4341 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4343 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4346 if (i == (ssize_t) (argc-1))
4347 ThrowMogrifyException(OptionError,"MissingArgument",option);
4350 if (LocaleCompare("dither",option+1) == 0)
4358 if (i == (ssize_t) argc)
4359 ThrowMogrifyException(OptionError,"MissingArgument",option);
4360 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4362 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4366 if (LocaleCompare("draw",option+1) == 0)
4371 if (i == (ssize_t) argc)
4372 ThrowMogrifyException(OptionError,"MissingArgument",option);
4375 if (LocaleCompare("duplicate",option+1) == 0)
4380 if (i == (ssize_t) (argc-1))
4381 ThrowMogrifyException(OptionError,"MissingArgument",option);
4382 if (IsGeometry(argv[i]) == MagickFalse)
4383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4386 if (LocaleCompare("duration",option+1) == 0)
4391 if (i == (ssize_t) (argc-1))
4392 ThrowMogrifyException(OptionError,"MissingArgument",option);
4393 if (IsGeometry(argv[i]) == MagickFalse)
4394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4397 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4401 if (LocaleCompare("edge",option+1) == 0)
4406 if (i == (ssize_t) argc)
4407 ThrowMogrifyException(OptionError,"MissingArgument",option);
4408 if (IsGeometry(argv[i]) == MagickFalse)
4409 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4412 if (LocaleCompare("emboss",option+1) == 0)
4417 if (i == (ssize_t) argc)
4418 ThrowMogrifyException(OptionError,"MissingArgument",option);
4419 if (IsGeometry(argv[i]) == MagickFalse)
4420 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4423 if (LocaleCompare("encipher",option+1) == 0)
4428 if (i == (ssize_t) argc)
4429 ThrowMogrifyException(OptionError,"MissingArgument",option);
4432 if (LocaleCompare("encoding",option+1) == 0)
4437 if (i == (ssize_t) argc)
4438 ThrowMogrifyException(OptionError,"MissingArgument",option);
4441 if (LocaleCompare("endian",option+1) == 0)
4449 if (i == (ssize_t) argc)
4450 ThrowMogrifyException(OptionError,"MissingArgument",option);
4451 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4453 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4457 if (LocaleCompare("enhance",option+1) == 0)
4459 if (LocaleCompare("equalize",option+1) == 0)
4461 if (LocaleCompare("evaluate",option+1) == 0)
4469 if (i == (ssize_t) argc)
4470 ThrowMogrifyException(OptionError,"MissingArgument",option);
4471 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4473 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4476 if (i == (ssize_t) (argc-1))
4477 ThrowMogrifyException(OptionError,"MissingArgument",option);
4478 if (IsGeometry(argv[i]) == MagickFalse)
4479 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4482 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4490 if (i == (ssize_t) argc)
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4494 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4498 if (LocaleCompare("extent",option+1) == 0)
4503 if (i == (ssize_t) argc)
4504 ThrowMogrifyException(OptionError,"MissingArgument",option);
4505 if (IsGeometry(argv[i]) == MagickFalse)
4506 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4509 if (LocaleCompare("extract",option+1) == 0)
4514 if (i == (ssize_t) argc)
4515 ThrowMogrifyException(OptionError,"MissingArgument",option);
4516 if (IsGeometry(argv[i]) == MagickFalse)
4517 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4520 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4524 if (LocaleCompare("family",option+1) == 0)
4529 if (i == (ssize_t) (argc-1))
4530 ThrowMogrifyException(OptionError,"MissingArgument",option);
4533 if (LocaleCompare("fill",option+1) == 0)
4538 if (i == (ssize_t) argc)
4539 ThrowMogrifyException(OptionError,"MissingArgument",option);
4542 if (LocaleCompare("filter",option+1) == 0)
4550 if (i == (ssize_t) argc)
4551 ThrowMogrifyException(OptionError,"MissingArgument",option);
4552 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4554 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4558 if (LocaleCompare("flatten",option+1) == 0)
4560 if (LocaleCompare("flip",option+1) == 0)
4562 if (LocaleCompare("flop",option+1) == 0)
4564 if (LocaleCompare("floodfill",option+1) == 0)
4569 if (i == (ssize_t) argc)
4570 ThrowMogrifyException(OptionError,"MissingArgument",option);
4571 if (IsGeometry(argv[i]) == MagickFalse)
4572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4574 if (i == (ssize_t) argc)
4575 ThrowMogrifyException(OptionError,"MissingArgument",option);
4578 if (LocaleCompare("font",option+1) == 0)
4583 if (i == (ssize_t) argc)
4584 ThrowMogrifyException(OptionError,"MissingArgument",option);
4587 if (LocaleCompare("format",option+1) == 0)
4589 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4590 (void) CloneString(&format,(char *) NULL);
4594 if (i == (ssize_t) argc)
4595 ThrowMogrifyException(OptionError,"MissingArgument",option);
4596 (void) CloneString(&format,argv[i]);
4597 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4598 (void) ConcatenateMagickString(image_info->filename,":",
4600 (void) SetImageInfo(image_info,0,exception);
4601 if (*image_info->magick == '\0')
4602 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4606 if (LocaleCompare("frame",option+1) == 0)
4611 if (i == (ssize_t) argc)
4612 ThrowMogrifyException(OptionError,"MissingArgument",option);
4613 if (IsGeometry(argv[i]) == MagickFalse)
4614 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4617 if (LocaleCompare("function",option+1) == 0)
4625 if (i == (ssize_t) argc)
4626 ThrowMogrifyException(OptionError,"MissingArgument",option);
4627 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4629 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4631 if (i == (ssize_t) (argc-1))
4632 ThrowMogrifyException(OptionError,"MissingArgument",option);
4635 if (LocaleCompare("fuzz",option+1) == 0)
4640 if (i == (ssize_t) argc)
4641 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4646 if (LocaleCompare("fx",option+1) == 0)
4651 if (i == (ssize_t) (argc-1))
4652 ThrowMogrifyException(OptionError,"MissingArgument",option);
4655 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4659 if (LocaleCompare("gamma",option+1) == 0)
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4664 if (IsGeometry(argv[i]) == MagickFalse)
4665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4668 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4669 (LocaleCompare("gaussian",option+1) == 0))
4672 if (i == (ssize_t) argc)
4673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4674 if (IsGeometry(argv[i]) == MagickFalse)
4675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4678 if (LocaleCompare("geometry",option+1) == 0)
4683 if (i == (ssize_t) argc)
4684 ThrowMogrifyException(OptionError,"MissingArgument",option);
4685 if (IsGeometry(argv[i]) == MagickFalse)
4686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4689 if (LocaleCompare("gravity",option+1) == 0)
4697 if (i == (ssize_t) argc)
4698 ThrowMogrifyException(OptionError,"MissingArgument",option);
4699 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4701 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4705 if (LocaleCompare("green-primary",option+1) == 0)
4710 if (i == (ssize_t) argc)
4711 ThrowMogrifyException(OptionError,"MissingArgument",option);
4712 if (IsGeometry(argv[i]) == MagickFalse)
4713 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4716 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4720 if (LocaleCompare("hald-clut",option+1) == 0)
4722 if ((LocaleCompare("help",option+1) == 0) ||
4723 (LocaleCompare("-help",option+1) == 0))
4724 return(MogrifyUsage());
4725 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4729 if (LocaleCompare("identify",option+1) == 0)
4731 if (LocaleCompare("idft",option+1) == 0)
4733 if (LocaleCompare("implode",option+1) == 0)
4738 if (i == (ssize_t) argc)
4739 ThrowMogrifyException(OptionError,"MissingArgument",option);
4740 if (IsGeometry(argv[i]) == MagickFalse)
4741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4744 if (LocaleCompare("intent",option+1) == 0)
4752 if (i == (ssize_t) (argc-1))
4753 ThrowMogrifyException(OptionError,"MissingArgument",option);
4754 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4756 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4760 if (LocaleCompare("interlace",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,"MissingArgument",option);
4770 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4773 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4777 if (LocaleCompare("interline-spacing",option+1) == 0)
4782 if (i == (ssize_t) (argc-1))
4783 ThrowMogrifyException(OptionError,"MissingArgument",option);
4784 if (IsGeometry(argv[i]) == MagickFalse)
4785 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4788 if (LocaleCompare("interpolate",option+1) == 0)
4796 if (i == (ssize_t) argc)
4797 ThrowMogrifyException(OptionError,"MissingArgument",option);
4798 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4800 if (interpolate < 0)
4801 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4805 if (LocaleCompare("interword-spacing",option+1) == 0)
4810 if (i == (ssize_t) (argc-1))
4811 ThrowMogrifyException(OptionError,"MissingArgument",option);
4812 if (IsGeometry(argv[i]) == MagickFalse)
4813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4820 if (LocaleCompare("kerning",option+1) == 0)
4825 if (i == (ssize_t) (argc-1))
4826 ThrowMogrifyException(OptionError,"MissingArgument",option);
4827 if (IsGeometry(argv[i]) == MagickFalse)
4828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4831 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4835 if (LocaleCompare("label",option+1) == 0)
4840 if (i == (ssize_t) argc)
4841 ThrowMogrifyException(OptionError,"MissingArgument",option);
4844 if (LocaleCompare("lat",option+1) == 0)
4849 if (i == (ssize_t) argc)
4850 ThrowMogrifyException(OptionError,"MissingArgument",option);
4851 if (IsGeometry(argv[i]) == MagickFalse)
4852 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4854 if (LocaleCompare("layers",option+1) == 0)
4862 if (i == (ssize_t) (argc-1))
4863 ThrowMogrifyException(OptionError,"MissingArgument",option);
4864 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4866 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4870 if (LocaleCompare("level",option+1) == 0)
4873 if (i == (ssize_t) argc)
4874 ThrowMogrifyException(OptionError,"MissingArgument",option);
4875 if (IsGeometry(argv[i]) == MagickFalse)
4876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4879 if (LocaleCompare("level-colors",option+1) == 0)
4882 if (i == (ssize_t) argc)
4883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4886 if (LocaleCompare("linewidth",option+1) == 0)
4891 if (i == (ssize_t) argc)
4892 ThrowMogrifyException(OptionError,"MissingArgument",option);
4893 if (IsGeometry(argv[i]) == MagickFalse)
4894 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4897 if (LocaleCompare("limit",option+1) == 0)
4911 if (i == (ssize_t) argc)
4912 ThrowMogrifyException(OptionError,"MissingArgument",option);
4913 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4916 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4919 if (i == (ssize_t) argc)
4920 ThrowMogrifyException(OptionError,"MissingArgument",option);
4921 value=InterpretLocaleValue(argv[i],&p);
4923 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4927 if (LocaleCompare("liquid-rescale",option+1) == 0)
4930 if (i == (ssize_t) argc)
4931 ThrowMogrifyException(OptionError,"MissingArgument",option);
4932 if (IsGeometry(argv[i]) == MagickFalse)
4933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4936 if (LocaleCompare("list",option+1) == 0)
4944 if (i == (ssize_t) argc)
4945 ThrowMogrifyException(OptionError,"MissingArgument",option);
4946 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4948 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4949 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4951 return(status != 0 ? MagickFalse : MagickTrue);
4953 if (LocaleCompare("log",option+1) == 0)
4958 if ((i == (ssize_t) argc) ||
4959 (strchr(argv[i],'%') == (char *) NULL))
4960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4963 if (LocaleCompare("loop",option+1) == 0)
4968 if (i == (ssize_t) argc)
4969 ThrowMogrifyException(OptionError,"MissingArgument",option);
4970 if (IsGeometry(argv[i]) == MagickFalse)
4971 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4974 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4978 if (LocaleCompare("map",option+1) == 0)
4980 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4984 if (i == (ssize_t) argc)
4985 ThrowMogrifyException(OptionError,"MissingArgument",option);
4988 if (LocaleCompare("mask",option+1) == 0)
4993 if (i == (ssize_t) argc)
4994 ThrowMogrifyException(OptionError,"MissingArgument",option);
4997 if (LocaleCompare("matte",option+1) == 0)
4999 if (LocaleCompare("mattecolor",option+1) == 0)
5004 if (i == (ssize_t) argc)
5005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5008 if (LocaleCompare("maximum",option+1) == 0)
5010 if (LocaleCompare("minimum",option+1) == 0)
5012 if (LocaleCompare("modulate",option+1) == 0)
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,"MissingArgument",option);
5019 if (IsGeometry(argv[i]) == MagickFalse)
5020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 if (LocaleCompare("median",option+1) == 0)
5028 if (i == (ssize_t) argc)
5029 ThrowMogrifyException(OptionError,"MissingArgument",option);
5030 if (IsGeometry(argv[i]) == MagickFalse)
5031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5034 if (LocaleCompare("mode",option+1) == 0)
5039 if (i == (ssize_t) argc)
5040 ThrowMogrifyException(OptionError,"MissingArgument",option);
5041 if (IsGeometry(argv[i]) == MagickFalse)
5042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5045 if (LocaleCompare("monitor",option+1) == 0)
5047 if (LocaleCompare("monochrome",option+1) == 0)
5049 if (LocaleCompare("morph",option+1) == 0)
5054 if (i == (ssize_t) (argc-1))
5055 ThrowMogrifyException(OptionError,"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 if (LocaleCompare("morphology",option+1) == 0)
5063 token[MaxTextExtent];
5072 if (i == (ssize_t) argc)
5073 ThrowMogrifyException(OptionError,"MissingArgument",option);
5074 GetMagickToken(argv[i],NULL,token);
5075 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5077 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5080 if (i == (ssize_t) (argc-1))
5081 ThrowMogrifyException(OptionError,"MissingArgument",option);
5082 kernel_info=AcquireKernelInfo(argv[i]);
5083 if (kernel_info == (KernelInfo *) NULL)
5084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5085 kernel_info=DestroyKernelInfo(kernel_info);
5088 if (LocaleCompare("mosaic",option+1) == 0)
5090 if (LocaleCompare("motion-blur",option+1) == 0)
5095 if (i == (ssize_t) argc)
5096 ThrowMogrifyException(OptionError,"MissingArgument",option);
5097 if (IsGeometry(argv[i]) == MagickFalse)
5098 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5101 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5105 if (LocaleCompare("negate",option+1) == 0)
5107 if (LocaleCompare("noise",option+1) == 0)
5110 if (i == (ssize_t) argc)
5111 ThrowMogrifyException(OptionError,"MissingArgument",option);
5117 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5119 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5123 if (IsGeometry(argv[i]) == MagickFalse)
5124 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5127 if (LocaleCompare("noop",option+1) == 0)
5129 if (LocaleCompare("normalize",option+1) == 0)
5131 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5135 if (LocaleCompare("opaque",option+1) == 0)
5138 if (i == (ssize_t) argc)
5139 ThrowMogrifyException(OptionError,"MissingArgument",option);
5142 if (LocaleCompare("ordered-dither",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5151 if (LocaleCompare("orient",option+1) == 0)
5156 orientation=UndefinedOrientation;
5160 if (i == (ssize_t) (argc-1))
5161 ThrowMogrifyException(OptionError,"MissingArgument",option);
5162 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5164 if (orientation < 0)
5165 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5169 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5173 if (LocaleCompare("page",option+1) == 0)
5178 if (i == (ssize_t) argc)
5179 ThrowMogrifyException(OptionError,"MissingArgument",option);
5182 if (LocaleCompare("paint",option+1) == 0)
5187 if (i == (ssize_t) argc)
5188 ThrowMogrifyException(OptionError,"MissingArgument",option);
5189 if (IsGeometry(argv[i]) == MagickFalse)
5190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5193 if (LocaleCompare("path",option+1) == 0)
5195 (void) CloneString(&path,(char *) NULL);
5199 if (i == (ssize_t) argc)
5200 ThrowMogrifyException(OptionError,"MissingArgument",option);
5201 (void) CloneString(&path,argv[i]);
5204 if (LocaleCompare("pointsize",option+1) == 0)
5209 if (i == (ssize_t) argc)
5210 ThrowMogrifyException(OptionError,"MissingArgument",option);
5211 if (IsGeometry(argv[i]) == MagickFalse)
5212 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5215 if (LocaleCompare("polaroid",option+1) == 0)
5220 if (i == (ssize_t) argc)
5221 ThrowMogrifyException(OptionError,"MissingArgument",option);
5222 if (IsGeometry(argv[i]) == MagickFalse)
5223 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5226 if (LocaleCompare("posterize",option+1) == 0)
5231 if (i == (ssize_t) argc)
5232 ThrowMogrifyException(OptionError,"MissingArgument",option);
5233 if (IsGeometry(argv[i]) == MagickFalse)
5234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5237 if (LocaleCompare("precision",option+1) == 0)
5242 if (i == (ssize_t) argc)
5243 ThrowMogrifyException(OptionError,"MissingArgument",option);
5244 if (IsGeometry(argv[i]) == MagickFalse)
5245 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5248 if (LocaleCompare("print",option+1) == 0)
5253 if (i == (ssize_t) argc)
5254 ThrowMogrifyException(OptionError,"MissingArgument",option);
5257 if (LocaleCompare("process",option+1) == 0)
5262 if (i == (ssize_t) (argc-1))
5263 ThrowMogrifyException(OptionError,"MissingArgument",option);
5266 if (LocaleCompare("profile",option+1) == 0)
5269 if (i == (ssize_t) argc)
5270 ThrowMogrifyException(OptionError,"MissingArgument",option);
5273 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5277 if (LocaleCompare("quality",option+1) == 0)
5282 if (i == (ssize_t) argc)
5283 ThrowMogrifyException(OptionError,"MissingArgument",option);
5284 if (IsGeometry(argv[i]) == MagickFalse)
5285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5288 if (LocaleCompare("quantize",option+1) == 0)
5296 if (i == (ssize_t) (argc-1))
5297 ThrowMogrifyException(OptionError,"MissingArgument",option);
5298 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5301 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5305 if (LocaleCompare("quiet",option+1) == 0)
5307 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5311 if (LocaleCompare("radial-blur",option+1) == 0)
5314 if (i == (ssize_t) argc)
5315 ThrowMogrifyException(OptionError,"MissingArgument",option);
5316 if (IsGeometry(argv[i]) == MagickFalse)
5317 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5320 if (LocaleCompare("raise",option+1) == 0)
5323 if (i == (ssize_t) argc)
5324 ThrowMogrifyException(OptionError,"MissingArgument",option);
5325 if (IsGeometry(argv[i]) == MagickFalse)
5326 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5329 if (LocaleCompare("random-threshold",option+1) == 0)
5334 if (i == (ssize_t) argc)
5335 ThrowMogrifyException(OptionError,"MissingArgument",option);
5336 if (IsGeometry(argv[i]) == MagickFalse)
5337 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5340 if (LocaleCompare("recolor",option+1) == 0)
5345 if (i == (ssize_t) (argc-1))
5346 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 if (IsGeometry(argv[i]) == MagickFalse)
5348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351 if (LocaleCompare("red-primary",option+1) == 0)
5356 if (i == (ssize_t) argc)
5357 ThrowMogrifyException(OptionError,"MissingArgument",option);
5358 if (IsGeometry(argv[i]) == MagickFalse)
5359 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5361 if (LocaleCompare("regard-warnings",option+1) == 0)
5363 if (LocaleCompare("region",option+1) == 0)
5368 if (i == (ssize_t) argc)
5369 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (IsGeometry(argv[i]) == MagickFalse)
5371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5374 if (LocaleCompare("remap",option+1) == 0)
5379 if (i == (ssize_t) (argc-1))
5380 ThrowMogrifyException(OptionError,"MissingArgument",option);
5383 if (LocaleCompare("render",option+1) == 0)
5385 if (LocaleCompare("repage",option+1) == 0)
5390 if (i == (ssize_t) argc)
5391 ThrowMogrifyException(OptionError,"MissingArgument",option);
5392 if (IsGeometry(argv[i]) == MagickFalse)
5393 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5396 if (LocaleCompare("resample",option+1) == 0)
5401 if (i == (ssize_t) argc)
5402 ThrowMogrifyException(OptionError,"MissingArgument",option);
5403 if (IsGeometry(argv[i]) == MagickFalse)
5404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5407 if (LocaleCompare("resize",option+1) == 0)
5412 if (i == (ssize_t) argc)
5413 ThrowMogrifyException(OptionError,"MissingArgument",option);
5414 if (IsGeometry(argv[i]) == MagickFalse)
5415 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5418 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5420 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5423 if (LocaleCompare("reverse",option+1) == 0)
5425 if (LocaleCompare("roll",option+1) == 0)
5430 if (i == (ssize_t) argc)
5431 ThrowMogrifyException(OptionError,"MissingArgument",option);
5432 if (IsGeometry(argv[i]) == MagickFalse)
5433 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5436 if (LocaleCompare("rotate",option+1) == 0)
5439 if (i == (ssize_t) argc)
5440 ThrowMogrifyException(OptionError,"MissingArgument",option);
5441 if (IsGeometry(argv[i]) == MagickFalse)
5442 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5445 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5449 if (LocaleCompare("sample",option+1) == 0)
5454 if (i == (ssize_t) argc)
5455 ThrowMogrifyException(OptionError,"MissingArgument",option);
5456 if (IsGeometry(argv[i]) == MagickFalse)
5457 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5460 if (LocaleCompare("sampling-factor",option+1) == 0)
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,"MissingArgument",option);
5467 if (IsGeometry(argv[i]) == MagickFalse)
5468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5471 if (LocaleCompare("scale",option+1) == 0)
5476 if (i == (ssize_t) argc)
5477 ThrowMogrifyException(OptionError,"MissingArgument",option);
5478 if (IsGeometry(argv[i]) == MagickFalse)
5479 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5482 if (LocaleCompare("scene",option+1) == 0)
5487 if (i == (ssize_t) argc)
5488 ThrowMogrifyException(OptionError,"MissingArgument",option);
5489 if (IsGeometry(argv[i]) == MagickFalse)
5490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5493 if (LocaleCompare("seed",option+1) == 0)
5498 if (i == (ssize_t) argc)
5499 ThrowMogrifyException(OptionError,"MissingArgument",option);
5500 if (IsGeometry(argv[i]) == MagickFalse)
5501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5504 if (LocaleCompare("segment",option+1) == 0)
5509 if (i == (ssize_t) argc)
5510 ThrowMogrifyException(OptionError,"MissingArgument",option);
5511 if (IsGeometry(argv[i]) == MagickFalse)
5512 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5515 if (LocaleCompare("selective-blur",option+1) == 0)
5518 if (i == (ssize_t) argc)
5519 ThrowMogrifyException(OptionError,"MissingArgument",option);
5520 if (IsGeometry(argv[i]) == MagickFalse)
5521 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5524 if (LocaleCompare("separate",option+1) == 0)
5526 if (LocaleCompare("sepia-tone",option+1) == 0)
5531 if (i == (ssize_t) argc)
5532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 if (IsGeometry(argv[i]) == MagickFalse)
5534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 if (LocaleCompare("set",option+1) == 0)
5540 if (i == (ssize_t) argc)
5541 ThrowMogrifyException(OptionError,"MissingArgument",option);
5545 if (i == (ssize_t) argc)
5546 ThrowMogrifyException(OptionError,"MissingArgument",option);
5549 if (LocaleCompare("shade",option+1) == 0)
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,"MissingArgument",option);
5554 if (IsGeometry(argv[i]) == MagickFalse)
5555 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5558 if (LocaleCompare("shadow",option+1) == 0)
5563 if (i == (ssize_t) argc)
5564 ThrowMogrifyException(OptionError,"MissingArgument",option);
5565 if (IsGeometry(argv[i]) == MagickFalse)
5566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5569 if (LocaleCompare("sharpen",option+1) == 0)
5572 if (i == (ssize_t) argc)
5573 ThrowMogrifyException(OptionError,"MissingArgument",option);
5574 if (IsGeometry(argv[i]) == MagickFalse)
5575 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5578 if (LocaleCompare("shave",option+1) == 0)
5583 if (i == (ssize_t) argc)
5584 ThrowMogrifyException(OptionError,"MissingArgument",option);
5585 if (IsGeometry(argv[i]) == MagickFalse)
5586 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5589 if (LocaleCompare("shear",option+1) == 0)
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (IsGeometry(argv[i]) == MagickFalse)
5595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5598 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5601 if (i == (ssize_t) (argc-1))
5602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5603 if (IsGeometry(argv[i]) == MagickFalse)
5604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5607 if (LocaleCompare("size",option+1) == 0)
5612 if (i == (ssize_t) argc)
5613 ThrowMogrifyException(OptionError,"MissingArgument",option);
5614 if (IsGeometry(argv[i]) == MagickFalse)
5615 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5618 if (LocaleCompare("sketch",option+1) == 0)
5623 if (i == (ssize_t) argc)
5624 ThrowMogrifyException(OptionError,"MissingArgument",option);
5625 if (IsGeometry(argv[i]) == MagickFalse)
5626 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5629 if (LocaleCompare("smush",option+1) == 0)
5632 if (i == (ssize_t) argc)
5633 ThrowMogrifyException(OptionError,"MissingArgument",option);
5634 if (IsGeometry(argv[i]) == MagickFalse)
5635 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5639 if (LocaleCompare("solarize",option+1) == 0)
5644 if (i == (ssize_t) argc)
5645 ThrowMogrifyException(OptionError,"MissingArgument",option);
5646 if (IsGeometry(argv[i]) == MagickFalse)
5647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 if (LocaleCompare("sparse-color",option+1) == 0)
5656 if (i == (ssize_t) argc)
5657 ThrowMogrifyException(OptionError,"MissingArgument",option);
5658 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5660 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5663 if (i == (ssize_t) (argc-1))
5664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5667 if (LocaleCompare("spread",option+1) == 0)
5672 if (i == (ssize_t) argc)
5673 ThrowMogrifyException(OptionError,"MissingArgument",option);
5674 if (IsGeometry(argv[i]) == MagickFalse)
5675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5678 if (LocaleCompare("statistic",option+1) == 0)
5686 if (i == (ssize_t) argc)
5687 ThrowMogrifyException(OptionError,"MissingArgument",option);
5688 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5690 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5693 if (i == (ssize_t) (argc-1))
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 if (IsGeometry(argv[i]) == MagickFalse)
5696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699 if (LocaleCompare("stretch",option+1) == 0)
5707 if (i == (ssize_t) (argc-1))
5708 ThrowMogrifyException(OptionError,"MissingArgument",option);
5709 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5711 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5715 if (LocaleCompare("strip",option+1) == 0)
5717 if (LocaleCompare("stroke",option+1) == 0)
5722 if (i == (ssize_t) argc)
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5726 if (LocaleCompare("strokewidth",option+1) == 0)
5731 if (i == (ssize_t) argc)
5732 ThrowMogrifyException(OptionError,"MissingArgument",option);
5733 if (IsGeometry(argv[i]) == MagickFalse)
5734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5737 if (LocaleCompare("style",option+1) == 0)
5745 if (i == (ssize_t) (argc-1))
5746 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5749 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5753 if (LocaleCompare("swap",option+1) == 0)
5758 if (i == (ssize_t) (argc-1))
5759 ThrowMogrifyException(OptionError,"MissingArgument",option);
5760 if (IsGeometry(argv[i]) == MagickFalse)
5761 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5764 if (LocaleCompare("swirl",option+1) == 0)
5769 if (i == (ssize_t) argc)
5770 ThrowMogrifyException(OptionError,"MissingArgument",option);
5771 if (IsGeometry(argv[i]) == MagickFalse)
5772 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5775 if (LocaleCompare("synchronize",option+1) == 0)
5777 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5781 if (LocaleCompare("taint",option+1) == 0)
5783 if (LocaleCompare("texture",option+1) == 0)
5788 if (i == (ssize_t) argc)
5789 ThrowMogrifyException(OptionError,"MissingArgument",option);
5792 if (LocaleCompare("tile",option+1) == 0)
5797 if (i == (ssize_t) (argc-1))
5798 ThrowMogrifyException(OptionError,"MissingArgument",option);
5801 if (LocaleCompare("tile-offset",option+1) == 0)
5806 if (i == (ssize_t) argc)
5807 ThrowMogrifyException(OptionError,"MissingArgument",option);
5808 if (IsGeometry(argv[i]) == MagickFalse)
5809 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5812 if (LocaleCompare("tint",option+1) == 0)
5817 if (i == (ssize_t) (argc-1))
5818 ThrowMogrifyException(OptionError,"MissingArgument",option);
5819 if (IsGeometry(argv[i]) == MagickFalse)
5820 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5823 if (LocaleCompare("transform",option+1) == 0)
5825 if (LocaleCompare("transpose",option+1) == 0)
5827 if (LocaleCompare("transverse",option+1) == 0)
5829 if (LocaleCompare("threshold",option+1) == 0)
5834 if (i == (ssize_t) argc)
5835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5836 if (IsGeometry(argv[i]) == MagickFalse)
5837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5840 if (LocaleCompare("thumbnail",option+1) == 0)
5845 if (i == (ssize_t) argc)
5846 ThrowMogrifyException(OptionError,"MissingArgument",option);
5847 if (IsGeometry(argv[i]) == MagickFalse)
5848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5851 if (LocaleCompare("transparent",option+1) == 0)
5854 if (i == (ssize_t) argc)
5855 ThrowMogrifyException(OptionError,"MissingArgument",option);
5858 if (LocaleCompare("transparent-color",option+1) == 0)
5863 if (i == (ssize_t) (argc-1))
5864 ThrowMogrifyException(OptionError,"MissingArgument",option);
5867 if (LocaleCompare("treedepth",option+1) == 0)
5872 if (i == (ssize_t) argc)
5873 ThrowMogrifyException(OptionError,"MissingArgument",option);
5874 if (IsGeometry(argv[i]) == MagickFalse)
5875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5878 if (LocaleCompare("trim",option+1) == 0)
5880 if (LocaleCompare("type",option+1) == 0)
5888 if (i == (ssize_t) argc)
5889 ThrowMogrifyException(OptionError,"MissingArgument",option);
5890 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5892 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5896 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5900 if (LocaleCompare("undercolor",option+1) == 0)
5905 if (i == (ssize_t) argc)
5906 ThrowMogrifyException(OptionError,"MissingArgument",option);
5909 if (LocaleCompare("unique-colors",option+1) == 0)
5911 if (LocaleCompare("units",option+1) == 0)
5919 if (i == (ssize_t) argc)
5920 ThrowMogrifyException(OptionError,"MissingArgument",option);
5921 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5924 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5928 if (LocaleCompare("unsharp",option+1) == 0)
5931 if (i == (ssize_t) argc)
5932 ThrowMogrifyException(OptionError,"MissingArgument",option);
5933 if (IsGeometry(argv[i]) == MagickFalse)
5934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5937 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5941 if (LocaleCompare("verbose",option+1) == 0)
5943 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5946 if ((LocaleCompare("version",option+1) == 0) ||
5947 (LocaleCompare("-version",option+1) == 0))
5949 (void) FormatLocaleFile(stdout,"Version: %s\n",
5950 GetMagickVersion((size_t *) NULL));
5951 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5952 GetMagickCopyright());
5953 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5954 GetMagickFeatures());
5957 if (LocaleCompare("view",option+1) == 0)
5962 if (i == (ssize_t) argc)
5963 ThrowMogrifyException(OptionError,"MissingArgument",option);
5966 if (LocaleCompare("vignette",option+1) == 0)
5971 if (i == (ssize_t) argc)
5972 ThrowMogrifyException(OptionError,"MissingArgument",option);
5973 if (IsGeometry(argv[i]) == MagickFalse)
5974 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5977 if (LocaleCompare("virtual-pixel",option+1) == 0)
5985 if (i == (ssize_t) argc)
5986 ThrowMogrifyException(OptionError,"MissingArgument",option);
5987 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5990 ThrowMogrifyException(OptionError,
5991 "UnrecognizedVirtualPixelMethod",argv[i]);
5994 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5998 if (LocaleCompare("wave",option+1) == 0)
6001 if (i == (ssize_t) argc)
6002 ThrowMogrifyException(OptionError,"MissingArgument",option);
6003 if (IsGeometry(argv[i]) == MagickFalse)
6004 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6007 if (LocaleCompare("weight",option+1) == 0)
6012 if (i == (ssize_t) (argc-1))
6013 ThrowMogrifyException(OptionError,"MissingArgument",option);
6016 if (LocaleCompare("white-point",option+1) == 0)
6021 if (i == (ssize_t) argc)
6022 ThrowMogrifyException(OptionError,"MissingArgument",option);
6023 if (IsGeometry(argv[i]) == MagickFalse)
6024 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6027 if (LocaleCompare("white-threshold",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6034 if (IsGeometry(argv[i]) == MagickFalse)
6035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6038 if (LocaleCompare("write",option+1) == 0)
6041 if (i == (ssize_t) (argc-1))
6042 ThrowMogrifyException(OptionError,"MissingArgument",option);
6045 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6050 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6052 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6053 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6054 if (fire != MagickFalse)
6055 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6058 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6059 if (i != (ssize_t) argc)
6060 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6062 return(status != 0 ? MagickTrue : MagickFalse);
6066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6070 + M o g r i f y I m a g e I n f o %
6074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6076 % MogrifyImageInfo() applies image processing settings to the image as
6077 % prescribed by command line options.
6079 % The format of the MogrifyImageInfo method is:
6081 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6082 % const char **argv,ExceptionInfo *exception)
6084 % A description of each parameter follows:
6086 % o image_info: the image info..
6088 % o argc: Specifies a pointer to an integer describing the number of
6089 % elements in the argument vector.
6091 % o argv: Specifies a pointer to a text array containing the command line
6094 % o exception: return any errors or warnings in this structure.
6097 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6098 const int argc,const char **argv,ExceptionInfo *exception)
6113 Initialize method variables.
6115 assert(image_info != (ImageInfo *) NULL);
6116 assert(image_info->signature == MagickSignature);
6117 if (image_info->debug != MagickFalse)
6118 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6119 image_info->filename);
6123 Set the image settings.
6125 for (i=0; i < (ssize_t) argc; i++)
6128 if (IsCommandOption(option) == MagickFalse)
6130 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6131 count=MagickMax(count,0L);
6132 if ((i+count) >= (ssize_t) argc)
6134 switch (*(option+1))
6138 if (LocaleCompare("adjoin",option+1) == 0)
6140 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6143 if (LocaleCompare("antialias",option+1) == 0)
6145 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6148 if (LocaleCompare("attenuate",option+1) == 0)
6152 (void) DeleteImageOption(image_info,option+1);
6155 (void) SetImageOption(image_info,option+1,argv[i+1]);
6158 if (LocaleCompare("authenticate",option+1) == 0)
6161 (void) CloneString(&image_info->authenticate,(char *) NULL);
6163 (void) CloneString(&image_info->authenticate,argv[i+1]);
6170 if (LocaleCompare("background",option+1) == 0)
6174 (void) DeleteImageOption(image_info,option+1);
6175 (void) QueryColorDatabase(MogrifyBackgroundColor,
6176 &image_info->background_color,exception);
6179 (void) SetImageOption(image_info,option+1,argv[i+1]);
6180 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6184 if (LocaleCompare("bias",option+1) == 0)
6188 (void) SetImageOption(image_info,option+1,"0.0");
6191 (void) SetImageOption(image_info,option+1,argv[i+1]);
6194 if (LocaleCompare("black-point-compensation",option+1) == 0)
6198 (void) SetImageOption(image_info,option+1,"false");
6201 (void) SetImageOption(image_info,option+1,"true");
6204 if (LocaleCompare("blue-primary",option+1) == 0)
6208 (void) SetImageOption(image_info,option+1,"0.0");
6211 (void) SetImageOption(image_info,option+1,argv[i+1]);
6214 if (LocaleCompare("bordercolor",option+1) == 0)
6218 (void) DeleteImageOption(image_info,option+1);
6219 (void) QueryColorDatabase(MogrifyBorderColor,
6220 &image_info->border_color,exception);
6223 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6225 (void) SetImageOption(image_info,option+1,argv[i+1]);
6228 if (LocaleCompare("box",option+1) == 0)
6232 (void) SetImageOption(image_info,"undercolor","none");
6235 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6242 if (LocaleCompare("cache",option+1) == 0)
6247 limit=MagickResourceInfinity;
6248 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6249 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6250 (void) SetMagickResourceLimit(MemoryResource,limit);
6251 (void) SetMagickResourceLimit(MapResource,2*limit);
6254 if (LocaleCompare("caption",option+1) == 0)
6258 (void) DeleteImageOption(image_info,option+1);
6261 (void) SetImageOption(image_info,option+1,argv[i+1]);
6264 if (LocaleCompare("channel",option+1) == 0)
6268 image_info->channel=DefaultChannels;
6271 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6274 if (LocaleCompare("colors",option+1) == 0)
6276 image_info->colors=StringToUnsignedLong(argv[i+1]);
6279 if (LocaleCompare("colorspace",option+1) == 0)
6283 image_info->colorspace=UndefinedColorspace;
6284 (void) SetImageOption(image_info,option+1,"undefined");
6287 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6288 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6289 (void) SetImageOption(image_info,option+1,argv[i+1]);
6292 if (LocaleCompare("comment",option+1) == 0)
6296 (void) DeleteImageOption(image_info,option+1);
6299 (void) SetImageOption(image_info,option+1,argv[i+1]);
6302 if (LocaleCompare("compose",option+1) == 0)
6306 (void) SetImageOption(image_info,option+1,"undefined");
6309 (void) SetImageOption(image_info,option+1,argv[i+1]);
6312 if (LocaleCompare("compress",option+1) == 0)
6316 image_info->compression=UndefinedCompression;
6317 (void) SetImageOption(image_info,option+1,"undefined");
6320 image_info->compression=(CompressionType) ParseCommandOption(
6321 MagickCompressOptions,MagickFalse,argv[i+1]);
6322 (void) SetImageOption(image_info,option+1,argv[i+1]);
6329 if (LocaleCompare("debug",option+1) == 0)
6332 (void) SetLogEventMask("none");
6334 (void) SetLogEventMask(argv[i+1]);
6335 image_info->debug=IsEventLogging();
6338 if (LocaleCompare("define",option+1) == 0)
6342 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6343 (void) DeleteImageRegistry(argv[i+1]+9);
6345 (void) DeleteImageOption(image_info,argv[i+1]);
6348 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6350 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6354 (void) DefineImageOption(image_info,argv[i+1]);
6357 if (LocaleCompare("delay",option+1) == 0)
6361 (void) SetImageOption(image_info,option+1,"0");
6364 (void) SetImageOption(image_info,option+1,argv[i+1]);
6367 if (LocaleCompare("density",option+1) == 0)
6374 if (image_info->density != (char *) NULL)
6375 image_info->density=DestroyString(image_info->density);
6376 (void) SetImageOption(image_info,option+1,"72");
6379 (void) CloneString(&image_info->density,argv[i+1]);
6380 (void) SetImageOption(image_info,option+1,argv[i+1]);
6383 if (LocaleCompare("depth",option+1) == 0)
6387 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6390 image_info->depth=StringToUnsignedLong(argv[i+1]);
6393 if (LocaleCompare("direction",option+1) == 0)
6397 (void) SetImageOption(image_info,option+1,"undefined");
6400 (void) SetImageOption(image_info,option+1,argv[i+1]);
6403 if (LocaleCompare("display",option+1) == 0)
6407 if (image_info->server_name != (char *) NULL)
6408 image_info->server_name=DestroyString(
6409 image_info->server_name);
6412 (void) CloneString(&image_info->server_name,argv[i+1]);
6415 if (LocaleCompare("dispose",option+1) == 0)
6419 (void) SetImageOption(image_info,option+1,"undefined");
6422 (void) SetImageOption(image_info,option+1,argv[i+1]);
6425 if (LocaleCompare("dither",option+1) == 0)
6429 image_info->dither=MagickFalse;
6430 (void) SetImageOption(image_info,option+1,"none");
6433 (void) SetImageOption(image_info,option+1,argv[i+1]);
6434 image_info->dither=MagickTrue;
6441 if (LocaleCompare("encoding",option+1) == 0)
6445 (void) SetImageOption(image_info,option+1,"undefined");
6448 (void) SetImageOption(image_info,option+1,argv[i+1]);
6451 if (LocaleCompare("endian",option+1) == 0)
6455 image_info->endian=UndefinedEndian;
6456 (void) SetImageOption(image_info,option+1,"undefined");
6459 image_info->endian=(EndianType) ParseCommandOption(
6460 MagickEndianOptions,MagickFalse,argv[i+1]);
6461 (void) SetImageOption(image_info,option+1,argv[i+1]);
6464 if (LocaleCompare("extract",option+1) == 0)
6467 Set image extract geometry.
6471 if (image_info->extract != (char *) NULL)
6472 image_info->extract=DestroyString(image_info->extract);
6475 (void) CloneString(&image_info->extract,argv[i+1]);
6482 if (LocaleCompare("fill",option+1) == 0)
6486 (void) SetImageOption(image_info,option+1,"none");
6489 (void) SetImageOption(image_info,option+1,argv[i+1]);
6492 if (LocaleCompare("filter",option+1) == 0)
6496 (void) SetImageOption(image_info,option+1,"undefined");
6499 (void) SetImageOption(image_info,option+1,argv[i+1]);
6502 if (LocaleCompare("font",option+1) == 0)
6506 if (image_info->font != (char *) NULL)
6507 image_info->font=DestroyString(image_info->font);
6510 (void) CloneString(&image_info->font,argv[i+1]);
6513 if (LocaleCompare("format",option+1) == 0)
6518 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6519 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6520 image_info->ping=MagickFalse;
6521 (void) SetImageOption(image_info,option+1,argv[i+1]);
6524 if (LocaleCompare("fuzz",option+1) == 0)
6528 image_info->fuzz=0.0;
6529 (void) SetImageOption(image_info,option+1,"0");
6532 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6534 (void) SetImageOption(image_info,option+1,argv[i+1]);
6541 if (LocaleCompare("gravity",option+1) == 0)
6545 (void) SetImageOption(image_info,option+1,"undefined");
6548 (void) SetImageOption(image_info,option+1,argv[i+1]);
6551 if (LocaleCompare("green-primary",option+1) == 0)
6555 (void) SetImageOption(image_info,option+1,"0.0");
6558 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 if (LocaleCompare("intent",option+1) == 0)
6569 (void) SetImageOption(image_info,option+1,"undefined");
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("interlace",option+1) == 0)
6579 image_info->interlace=UndefinedInterlace;
6580 (void) SetImageOption(image_info,option+1,"undefined");
6583 image_info->interlace=(InterlaceType) ParseCommandOption(
6584 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 if (LocaleCompare("interline-spacing",option+1) == 0)
6592 (void) SetImageOption(image_info,option+1,"undefined");
6595 (void) SetImageOption(image_info,option+1,argv[i+1]);
6598 if (LocaleCompare("interpolate",option+1) == 0)
6602 (void) SetImageOption(image_info,option+1,"undefined");
6605 (void) SetImageOption(image_info,option+1,argv[i+1]);
6608 if (LocaleCompare("interword-spacing",option+1) == 0)
6612 (void) SetImageOption(image_info,option+1,"undefined");
6615 (void) SetImageOption(image_info,option+1,argv[i+1]);
6622 if (LocaleCompare("kerning",option+1) == 0)
6626 (void) SetImageOption(image_info,option+1,"undefined");
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6636 if (LocaleCompare("label",option+1) == 0)
6640 (void) DeleteImageOption(image_info,option+1);
6643 (void) SetImageOption(image_info,option+1,argv[i+1]);
6646 if (LocaleCompare("limit",option+1) == 0)
6656 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6657 MagickFalse,argv[i+1]);
6658 limit=MagickResourceInfinity;
6659 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6660 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6661 (void) SetMagickResourceLimit(type,limit);
6664 if (LocaleCompare("list",option+1) == 0)
6670 Display configuration list.
6672 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6675 case MagickCoderOptions:
6677 (void) ListCoderInfo((FILE *) NULL,exception);
6680 case MagickColorOptions:
6682 (void) ListColorInfo((FILE *) NULL,exception);
6685 case MagickConfigureOptions:
6687 (void) ListConfigureInfo((FILE *) NULL,exception);
6690 case MagickDelegateOptions:
6692 (void) ListDelegateInfo((FILE *) NULL,exception);
6695 case MagickFontOptions:
6697 (void) ListTypeInfo((FILE *) NULL,exception);
6700 case MagickFormatOptions:
6702 (void) ListMagickInfo((FILE *) NULL,exception);
6705 case MagickLocaleOptions:
6707 (void) ListLocaleInfo((FILE *) NULL,exception);
6710 case MagickLogOptions:
6712 (void) ListLogInfo((FILE *) NULL,exception);
6715 case MagickMagicOptions:
6717 (void) ListMagicInfo((FILE *) NULL,exception);
6720 case MagickMimeOptions:
6722 (void) ListMimeInfo((FILE *) NULL,exception);
6725 case MagickModuleOptions:
6727 (void) ListModuleInfo((FILE *) NULL,exception);
6730 case MagickPolicyOptions:
6732 (void) ListPolicyInfo((FILE *) NULL,exception);
6735 case MagickResourceOptions:
6737 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6740 case MagickThresholdOptions:
6742 (void) ListThresholdMaps((FILE *) NULL,exception);
6747 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6754 if (LocaleCompare("log",option+1) == 0)
6758 (void) SetLogFormat(argv[i+1]);
6761 if (LocaleCompare("loop",option+1) == 0)
6765 (void) SetImageOption(image_info,option+1,"0");
6768 (void) SetImageOption(image_info,option+1,argv[i+1]);
6775 if (LocaleCompare("matte",option+1) == 0)
6779 (void) SetImageOption(image_info,option+1,"false");
6782 (void) SetImageOption(image_info,option+1,"true");
6785 if (LocaleCompare("mattecolor",option+1) == 0)
6789 (void) SetImageOption(image_info,option+1,argv[i+1]);
6790 (void) QueryColorDatabase(MogrifyMatteColor,
6791 &image_info->matte_color,exception);
6794 (void) SetImageOption(image_info,option+1,argv[i+1]);
6795 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6799 if (LocaleCompare("monitor",option+1) == 0)
6801 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6805 if (LocaleCompare("monochrome",option+1) == 0)
6807 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6814 if (LocaleCompare("orient",option+1) == 0)
6818 image_info->orientation=UndefinedOrientation;
6819 (void) SetImageOption(image_info,option+1,"undefined");
6822 image_info->orientation=(OrientationType) ParseCommandOption(
6823 MagickOrientationOptions,MagickFalse,argv[i+1]);
6824 (void) SetImageOption(image_info,option+1,argv[i+1]);
6830 if (LocaleCompare("page",option+1) == 0)
6834 page[MaxTextExtent];
6847 (void) DeleteImageOption(image_info,option+1);
6848 (void) CloneString(&image_info->page,(char *) NULL);
6851 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6852 image_option=GetImageOption(image_info,"page");
6853 if (image_option != (const char *) NULL)
6854 flags=ParseAbsoluteGeometry(image_option,&geometry);
6855 canonical_page=GetPageGeometry(argv[i+1]);
6856 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6857 canonical_page=DestroyString(canonical_page);
6858 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6859 (unsigned long) geometry.width,(unsigned long) geometry.height);
6860 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6861 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6862 (unsigned long) geometry.width,(unsigned long) geometry.height,
6863 (long) geometry.x,(long) geometry.y);
6864 (void) SetImageOption(image_info,option+1,page);
6865 (void) CloneString(&image_info->page,page);
6868 if (LocaleCompare("pen",option+1) == 0)
6872 (void) SetImageOption(image_info,option+1,"none");
6875 (void) SetImageOption(image_info,option+1,argv[i+1]);
6878 if (LocaleCompare("ping",option+1) == 0)
6880 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6883 if (LocaleCompare("pointsize",option+1) == 0)
6886 geometry_info.rho=0.0;
6888 (void) ParseGeometry(argv[i+1],&geometry_info);
6889 image_info->pointsize=geometry_info.rho;
6892 if (LocaleCompare("precision",option+1) == 0)
6894 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6897 if (LocaleCompare("preview",option+1) == 0)
6904 image_info->preview_type=UndefinedPreview;
6907 image_info->preview_type=(PreviewType) ParseCommandOption(
6908 MagickPreviewOptions,MagickFalse,argv[i+1]);
6915 if (LocaleCompare("quality",option+1) == 0)
6918 Set image compression quality.
6922 image_info->quality=UndefinedCompressionQuality;
6923 (void) SetImageOption(image_info,option+1,"0");
6926 image_info->quality=StringToUnsignedLong(argv[i+1]);
6927 (void) SetImageOption(image_info,option+1,argv[i+1]);
6930 if (LocaleCompare("quiet",option+1) == 0)
6932 static WarningHandler
6933 warning_handler = (WarningHandler) NULL;
6938 Restore error or warning messages.
6940 warning_handler=SetWarningHandler(warning_handler);
6944 Suppress error or warning messages.
6946 warning_handler=SetWarningHandler((WarningHandler) NULL);
6953 if (LocaleCompare("red-primary",option+1) == 0)
6957 (void) SetImageOption(image_info,option+1,"0.0");
6960 (void) SetImageOption(image_info,option+1,argv[i+1]);
6967 if (LocaleCompare("sampling-factor",option+1) == 0)
6970 Set image sampling factor.
6974 if (image_info->sampling_factor != (char *) NULL)
6975 image_info->sampling_factor=DestroyString(
6976 image_info->sampling_factor);
6979 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6982 if (LocaleCompare("scene",option+1) == 0)
6989 image_info->scene=0;
6990 (void) SetImageOption(image_info,option+1,"0");
6993 image_info->scene=StringToUnsignedLong(argv[i+1]);
6994 (void) SetImageOption(image_info,option+1,argv[i+1]);
6997 if (LocaleCompare("seed",option+1) == 0)
7004 seed=(size_t) time((time_t *) NULL);
7005 SeedPseudoRandomGenerator(seed);
7008 seed=StringToUnsignedLong(argv[i+1]);
7009 SeedPseudoRandomGenerator(seed);
7012 if (LocaleCompare("size",option+1) == 0)
7016 if (image_info->size != (char *) NULL)
7017 image_info->size=DestroyString(image_info->size);
7020 (void) CloneString(&image_info->size,argv[i+1]);
7023 if (LocaleCompare("stroke",option+1) == 0)
7027 (void) SetImageOption(image_info,option+1,"none");
7030 (void) SetImageOption(image_info,option+1,argv[i+1]);
7033 if (LocaleCompare("strokewidth",option+1) == 0)
7037 (void) SetImageOption(image_info,option+1,"0");
7040 (void) SetImageOption(image_info,option+1,argv[i+1]);
7043 if (LocaleCompare("synchronize",option+1) == 0)
7047 image_info->synchronize=MagickFalse;
7050 image_info->synchronize=MagickTrue;
7057 if (LocaleCompare("taint",option+1) == 0)
7061 (void) SetImageOption(image_info,option+1,"false");
7064 (void) SetImageOption(image_info,option+1,"true");
7067 if (LocaleCompare("texture",option+1) == 0)
7071 if (image_info->texture != (char *) NULL)
7072 image_info->texture=DestroyString(image_info->texture);
7075 (void) CloneString(&image_info->texture,argv[i+1]);
7078 if (LocaleCompare("tile-offset",option+1) == 0)
7082 (void) SetImageOption(image_info,option+1,"0");
7085 (void) SetImageOption(image_info,option+1,argv[i+1]);
7088 if (LocaleCompare("transparent-color",option+1) == 0)
7092 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7093 (void) SetImageOption(image_info,option+1,"none");
7096 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7098 (void) SetImageOption(image_info,option+1,argv[i+1]);
7101 if (LocaleCompare("type",option+1) == 0)
7105 image_info->type=UndefinedType;
7106 (void) SetImageOption(image_info,option+1,"undefined");
7109 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7110 MagickFalse,argv[i+1]);
7111 (void) SetImageOption(image_info,option+1,argv[i+1]);
7118 if (LocaleCompare("undercolor",option+1) == 0)
7122 (void) DeleteImageOption(image_info,option+1);
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7128 if (LocaleCompare("units",option+1) == 0)
7132 image_info->units=UndefinedResolution;
7133 (void) SetImageOption(image_info,option+1,"undefined");
7136 image_info->units=(ResolutionType) ParseCommandOption(
7137 MagickResolutionOptions,MagickFalse,argv[i+1]);
7138 (void) SetImageOption(image_info,option+1,argv[i+1]);
7145 if (LocaleCompare("verbose",option+1) == 0)
7149 image_info->verbose=MagickFalse;
7152 image_info->verbose=MagickTrue;
7153 image_info->ping=MagickFalse;
7156 if (LocaleCompare("view",option+1) == 0)
7160 if (image_info->view != (char *) NULL)
7161 image_info->view=DestroyString(image_info->view);
7164 (void) CloneString(&image_info->view,argv[i+1]);
7167 if (LocaleCompare("virtual-pixel",option+1) == 0)
7171 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7172 (void) SetImageOption(image_info,option+1,"undefined");
7175 image_info->virtual_pixel_method=(VirtualPixelMethod)
7176 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7178 (void) SetImageOption(image_info,option+1,argv[i+1]);
7185 if (LocaleCompare("white-point",option+1) == 0)
7189 (void) SetImageOption(image_info,option+1,"0.0");
7192 (void) SetImageOption(image_info,option+1,argv[i+1]);
7206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7210 + M o g r i f y I m a g e L i s t %
7214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7216 % MogrifyImageList() applies any command line options that might affect the
7217 % entire image list (e.g. -append, -coalesce, etc.).
7219 % The format of the MogrifyImage method is:
7221 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7222 % const char **argv,Image **images,ExceptionInfo *exception)
7224 % A description of each parameter follows:
7226 % o image_info: the image info..
7228 % o argc: Specifies a pointer to an integer describing the number of
7229 % elements in the argument vector.
7231 % o argv: Specifies a pointer to a text array containing the command line
7234 % o images: pointer to pointer of the first image in image list.
7236 % o exception: return any errors or warnings in this structure.
7239 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7240 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7251 PixelInterpolateMethod
7265 Apply options to the image list.
7267 assert(image_info != (ImageInfo *) NULL);
7268 assert(image_info->signature == MagickSignature);
7269 assert(images != (Image **) NULL);
7270 assert((*images)->previous == (Image *) NULL);
7271 assert((*images)->signature == MagickSignature);
7272 if ((*images)->debug != MagickFalse)
7273 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7274 (*images)->filename);
7275 if ((argc <= 0) || (*argv == (char *) NULL))
7277 interpolate_method=UndefinedInterpolatePixel;
7278 mogrify_info=CloneImageInfo(image_info);
7279 quantize_info=AcquireQuantizeInfo(mogrify_info);
7281 for (i=0; i < (ssize_t) argc; i++)
7283 if (*images == (Image *) NULL)
7286 if (IsCommandOption(option) == MagickFalse)
7288 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7289 count=MagickMax(count,0L);
7290 if ((i+count) >= (ssize_t) argc)
7292 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7293 switch (*(option+1))
7297 if (LocaleCompare("affinity",option+1) == 0)
7299 (void) SyncImagesSettings(mogrify_info,*images);
7302 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7309 if (LocaleCompare("append",option+1) == 0)
7314 (void) SyncImagesSettings(mogrify_info,*images);
7315 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7316 MagickFalse,exception);
7317 if (append_image == (Image *) NULL)
7322 *images=DestroyImageList(*images);
7323 *images=append_image;
7326 if (LocaleCompare("average",option+1) == 0)
7332 Average an image sequence (deprecated).
7334 (void) SyncImagesSettings(mogrify_info,*images);
7335 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7337 if (average_image == (Image *) NULL)
7342 *images=DestroyImageList(*images);
7343 *images=average_image;
7350 if (LocaleCompare("channel",option+1) == 0)
7357 channel=DefaultChannels;
7360 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7361 SetPixelChannelMap(*images,channel);
7364 if (LocaleCompare("clut",option+1) == 0)
7370 (void) SyncImagesSettings(mogrify_info,*images);
7371 image=RemoveFirstImageFromList(images);
7372 clut_image=RemoveFirstImageFromList(images);
7373 if (clut_image == (Image *) NULL)
7378 (void) ClutImage(image,clut_image,interpolate_method,exception);
7379 clut_image=DestroyImage(clut_image);
7380 *images=DestroyImageList(*images);
7384 if (LocaleCompare("coalesce",option+1) == 0)
7389 (void) SyncImagesSettings(mogrify_info,*images);
7390 coalesce_image=CoalesceImages(*images,exception);
7391 if (coalesce_image == (Image *) NULL)
7396 *images=DestroyImageList(*images);
7397 *images=coalesce_image;
7400 if (LocaleCompare("combine",option+1) == 0)
7405 (void) SyncImagesSettings(mogrify_info,*images);
7406 combine_image=CombineImages(*images,exception);
7407 if (combine_image == (Image *) NULL)
7412 *images=DestroyImageList(*images);
7413 *images=combine_image;
7416 if (LocaleCompare("composite",option+1) == 0)
7426 (void) SyncImagesSettings(mogrify_info,*images);
7427 image=RemoveFirstImageFromList(images);
7428 composite_image=RemoveFirstImageFromList(images);
7429 if (composite_image == (Image *) NULL)
7434 (void) TransformImage(&composite_image,(char *) NULL,
7435 composite_image->geometry);
7436 SetGeometry(composite_image,&geometry);
7437 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7438 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7440 mask_image=RemoveFirstImageFromList(images);
7441 if (mask_image != (Image *) NULL)
7443 if ((image->compose == DisplaceCompositeOp) ||
7444 (image->compose == DistortCompositeOp))
7447 Merge Y displacement into X displacement image.
7449 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7451 mask_image=DestroyImage(mask_image);
7456 Set a blending mask for the composition.
7457 Posible error, what if image->mask already set.
7459 image->mask=mask_image;
7460 (void) NegateImage(image->mask,MagickFalse,exception);
7463 (void) CompositeImage(image,image->compose,composite_image,
7464 geometry.x,geometry.y);
7465 if (mask_image != (Image *) NULL)
7466 mask_image=image->mask=DestroyImage(image->mask);
7467 composite_image=DestroyImage(composite_image);
7468 InheritException(exception,&image->exception);
7469 *images=DestroyImageList(*images);
7477 if (LocaleCompare("deconstruct",option+1) == 0)
7482 (void) SyncImagesSettings(mogrify_info,*images);
7483 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7485 if (deconstruct_image == (Image *) NULL)
7490 *images=DestroyImageList(*images);
7491 *images=deconstruct_image;
7494 if (LocaleCompare("delete",option+1) == 0)
7497 DeleteImages(images,"-1",exception);
7499 DeleteImages(images,argv[i+1],exception);
7502 if (LocaleCompare("dither",option+1) == 0)
7506 quantize_info->dither=MagickFalse;
7509 quantize_info->dither=MagickTrue;
7510 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7511 MagickDitherOptions,MagickFalse,argv[i+1]);
7514 if (LocaleCompare("duplicate",option+1) == 0)
7520 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7529 number_duplicates=(size_t) StringToLong(argv[i+1]);
7530 p=strchr(argv[i+1],',');
7531 if (p == (const char *) NULL)
7532 duplicate_images=DuplicateImages(*images,number_duplicates,
7535 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7538 AppendImageToList(images, duplicate_images);
7539 (void) SyncImagesSettings(mogrify_info,*images);
7546 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7551 MagickEvaluateOperator
7554 (void) SyncImageSettings(mogrify_info,*images);
7555 op=(MagickEvaluateOperator) ParseCommandOption(
7556 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7557 evaluate_image=EvaluateImages(*images,op,exception);
7558 if (evaluate_image == (Image *) NULL)
7563 *images=DestroyImageList(*images);
7564 *images=evaluate_image;
7571 if (LocaleCompare("fft",option+1) == 0)
7577 Implements the discrete Fourier transform (DFT).
7579 (void) SyncImageSettings(mogrify_info,*images);
7580 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7581 MagickTrue : MagickFalse,exception);
7582 if (fourier_image == (Image *) NULL)
7584 *images=DestroyImage(*images);
7585 *images=fourier_image;
7588 if (LocaleCompare("flatten",option+1) == 0)
7593 (void) SyncImagesSettings(mogrify_info,*images);
7594 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7595 if (flatten_image == (Image *) NULL)
7597 *images=DestroyImageList(*images);
7598 *images=flatten_image;
7601 if (LocaleCompare("fx",option+1) == 0)
7606 (void) SyncImagesSettings(mogrify_info,*images);
7607 fx_image=FxImage(*images,argv[i+1],exception);
7608 if (fx_image == (Image *) NULL)
7613 *images=DestroyImageList(*images);
7621 if (LocaleCompare("hald-clut",option+1) == 0)
7627 (void) SyncImagesSettings(mogrify_info,*images);
7628 image=RemoveFirstImageFromList(images);
7629 hald_image=RemoveFirstImageFromList(images);
7630 if (hald_image == (Image *) NULL)
7635 (void) HaldClutImage(image,hald_image,exception);
7636 hald_image=DestroyImage(hald_image);
7637 if (*images != (Image *) NULL)
7638 *images=DestroyImageList(*images);
7646 if (LocaleCompare("ift",option+1) == 0)
7654 Implements the inverse fourier discrete Fourier transform (DFT).
7656 (void) SyncImagesSettings(mogrify_info,*images);
7657 magnitude_image=RemoveFirstImageFromList(images);
7658 phase_image=RemoveFirstImageFromList(images);
7659 if (phase_image == (Image *) NULL)
7664 fourier_image=InverseFourierTransformImage(magnitude_image,
7665 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7666 if (fourier_image == (Image *) NULL)
7668 if (*images != (Image *) NULL)
7669 *images=DestroyImage(*images);
7670 *images=fourier_image;
7673 if (LocaleCompare("insert",option+1) == 0)
7681 index=(ssize_t) StringToLong(argv[i+1]);
7682 p=RemoveLastImageFromList(images);
7683 if (p == (Image *) NULL)
7685 (void) ThrowMagickException(exception,GetMagickModule(),
7686 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7692 PrependImageToList(images,q);
7694 if (index == (ssize_t) GetImageListLength(*images))
7695 AppendImageToList(images,q);
7698 q=GetImageFromList(*images,index-1);
7699 if (q == (Image *) NULL)
7701 (void) ThrowMagickException(exception,GetMagickModule(),
7702 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7706 InsertImageInList(&q,p);
7708 *images=GetFirstImageInList(q);
7711 if (LocaleCompare("interpolate",option+1) == 0)
7713 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7714 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7721 if (LocaleCompare("layers",option+1) == 0)
7729 (void) SyncImagesSettings(mogrify_info,*images);
7730 layers=(Image *) NULL;
7731 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7732 MagickFalse,argv[i+1]);
7737 layers=CoalesceImages(*images,exception);
7740 case CompareAnyLayer:
7741 case CompareClearLayer:
7742 case CompareOverlayLayer:
7745 layers=CompareImagesLayers(*images,method,exception);
7751 case TrimBoundsLayer:
7753 layers=MergeImageLayers(*images,method,exception);
7758 layers=DisposeImages(*images,exception);
7761 case OptimizeImageLayer:
7763 layers=OptimizeImageLayers(*images,exception);
7766 case OptimizePlusLayer:
7768 layers=OptimizePlusImageLayers(*images,exception);
7771 case OptimizeTransLayer:
7773 OptimizeImageTransparency(*images,exception);
7776 case RemoveDupsLayer:
7778 RemoveDuplicateLayers(images,exception);
7781 case RemoveZeroLayer:
7783 RemoveZeroDelayLayers(images,exception);
7789 General Purpose, GIF Animation Optimizer.
7791 layers=CoalesceImages(*images,exception);
7792 if (layers == (Image *) NULL)
7797 *images=DestroyImageList(*images);
7799 layers=OptimizeImageLayers(*images,exception);
7800 if (layers == (Image *) NULL)
7805 *images=DestroyImageList(*images);
7807 layers=(Image *) NULL;
7808 OptimizeImageTransparency(*images,exception);
7809 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7813 case CompositeLayer:
7825 Split image sequence at the first 'NULL:' image.
7828 while (source != (Image *) NULL)
7830 source=GetNextImageInList(source);
7831 if ((source != (Image *) NULL) &&
7832 (LocaleCompare(source->magick,"NULL") == 0))
7835 if (source != (Image *) NULL)
7837 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7838 (GetNextImageInList(source) == (Image *) NULL))
7839 source=(Image *) NULL;
7843 Separate the two lists, junk the null: image.
7845 source=SplitImageList(source->previous);
7846 DeleteImageFromList(&source);
7849 if (source == (Image *) NULL)
7851 (void) ThrowMagickException(exception,GetMagickModule(),
7852 OptionError,"MissingNullSeparator","layers Composite");
7857 Adjust offset with gravity and virtual canvas.
7859 SetGeometry(*images,&geometry);
7860 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7861 geometry.width=source->page.width != 0 ?
7862 source->page.width : source->columns;
7863 geometry.height=source->page.height != 0 ?
7864 source->page.height : source->rows;
7865 GravityAdjustGeometry((*images)->page.width != 0 ?
7866 (*images)->page.width : (*images)->columns,
7867 (*images)->page.height != 0 ? (*images)->page.height :
7868 (*images)->rows,(*images)->gravity,&geometry);
7869 compose=OverCompositeOp;
7870 option=GetImageOption(mogrify_info,"compose");
7871 if (option != (const char *) NULL)
7872 compose=(CompositeOperator) ParseCommandOption(
7873 MagickComposeOptions,MagickFalse,option);
7874 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7876 source=DestroyImageList(source);
7880 if (layers == (Image *) NULL)
7882 InheritException(exception,&layers->exception);
7883 *images=DestroyImageList(*images);
7891 if (LocaleCompare("map",option+1) == 0)
7893 (void) SyncImagesSettings(mogrify_info,*images);
7896 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7903 if (LocaleCompare("maximum",option+1) == 0)
7909 Maximum image sequence (deprecated).
7911 (void) SyncImagesSettings(mogrify_info,*images);
7912 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7913 if (maximum_image == (Image *) NULL)
7918 *images=DestroyImageList(*images);
7919 *images=maximum_image;
7922 if (LocaleCompare("minimum",option+1) == 0)
7928 Minimum image sequence (deprecated).
7930 (void) SyncImagesSettings(mogrify_info,*images);
7931 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7932 if (minimum_image == (Image *) NULL)
7937 *images=DestroyImageList(*images);
7938 *images=minimum_image;
7941 if (LocaleCompare("morph",option+1) == 0)
7946 (void) SyncImagesSettings(mogrify_info,*images);
7947 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7949 if (morph_image == (Image *) NULL)
7954 *images=DestroyImageList(*images);
7955 *images=morph_image;
7958 if (LocaleCompare("mosaic",option+1) == 0)
7963 (void) SyncImagesSettings(mogrify_info,*images);
7964 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7965 if (mosaic_image == (Image *) NULL)
7970 *images=DestroyImageList(*images);
7971 *images=mosaic_image;
7978 if (LocaleCompare("print",option+1) == 0)
7983 (void) SyncImagesSettings(mogrify_info,*images);
7984 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7986 if (string == (char *) NULL)
7988 (void) FormatLocaleFile(stdout,"%s",string);
7989 string=DestroyString(string);
7991 if (LocaleCompare("process",option+1) == 0)
8000 (void) SyncImagesSettings(mogrify_info,*images);
8001 arguments=StringToArgv(argv[i+1],&number_arguments);
8002 if (arguments == (char **) NULL)
8004 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8025 Support old style syntax, filter="-option arg".
8027 length=strlen(argv[i+1]);
8028 token=(char *) NULL;
8029 if (~length >= (MaxTextExtent-1))
8030 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8032 if (token == (char *) NULL)
8035 arguments=argv[i+1];
8036 token_info=AcquireTokenInfo();
8037 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8038 "\"",'\0',&breaker,&next,"e);
8039 token_info=DestroyTokenInfo(token_info);
8045 argv=(&(arguments[next]));
8046 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8049 token=DestroyString(token);
8052 (void) SubstituteString(&arguments[1],"-","");
8053 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8054 number_arguments-2,(const char **) arguments+2,exception);
8055 for (j=0; j < number_arguments; j++)
8056 arguments[j]=DestroyString(arguments[j]);
8057 arguments=(char **) RelinquishMagickMemory(arguments);
8064 if (LocaleCompare("reverse",option+1) == 0)
8066 ReverseImageList(images);
8067 InheritException(exception,&(*images)->exception);
8074 if (LocaleCompare("smush",option+1) == 0)
8082 (void) SyncImagesSettings(mogrify_info,*images);
8083 offset=(ssize_t) StringToLong(argv[i+1]);
8084 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8085 MagickFalse,offset,exception);
8086 if (smush_image == (Image *) NULL)
8091 *images=DestroyImageList(*images);
8092 *images=smush_image;
8095 if (LocaleCompare("swap",option+1) == 0)
8116 flags=ParseGeometry(argv[i+1],&geometry_info);
8117 index=(ssize_t) geometry_info.rho;
8118 if ((flags & SigmaValue) != 0)
8119 swap_index=(ssize_t) geometry_info.sigma;
8121 p=GetImageFromList(*images,index);
8122 q=GetImageFromList(*images,swap_index);
8123 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8125 (void) ThrowMagickException(exception,GetMagickModule(),
8126 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8132 swap=CloneImage(p,0,0,MagickTrue,exception);
8133 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8134 ReplaceImageInList(&q,swap);
8135 *images=GetFirstImageInList(q);
8142 if (LocaleCompare("write",option+1) == 0)
8153 (void) SyncImagesSettings(mogrify_info,*images);
8154 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8155 (void) DeleteImageRegistry(key);
8156 write_images=(*images);
8158 write_images=CloneImageList(*images,exception);
8159 write_info=CloneImageInfo(mogrify_info);
8160 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8161 write_info=DestroyImageInfo(write_info);
8163 write_images=DestroyImageList(write_images);
8173 quantize_info=DestroyQuantizeInfo(quantize_info);
8174 mogrify_info=DestroyImageInfo(mogrify_info);
8175 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8176 return(status != 0 ? MagickTrue : MagickFalse);
8180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8184 + M o g r i f y I m a g e s %
8188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8190 % MogrifyImages() applies image processing options to a sequence of images as
8191 % prescribed by command line options.
8193 % The format of the MogrifyImage method is:
8195 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8196 % const MagickBooleanType post,const int argc,const char **argv,
8197 % Image **images,Exceptioninfo *exception)
8199 % A description of each parameter follows:
8201 % o image_info: the image info..
8203 % o post: If true, post process image list operators otherwise pre-process.
8205 % o argc: Specifies a pointer to an integer describing the number of
8206 % elements in the argument vector.
8208 % o argv: Specifies a pointer to a text array containing the command line
8211 % o images: pointer to a pointer of the first image in image list.
8213 % o exception: return any errors or warnings in this structure.
8216 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8217 const MagickBooleanType post,const int argc,const char **argv,
8218 Image **images,ExceptionInfo *exception)
8220 #define MogrifyImageTag "Mogrify/Image"
8234 assert(image_info != (ImageInfo *) NULL);
8235 assert(image_info->signature == MagickSignature);
8236 if (images == (Image **) NULL)
8237 return(MogrifyImage(image_info,argc,argv,images,exception));
8238 assert((*images)->previous == (Image *) NULL);
8239 assert((*images)->signature == MagickSignature);
8240 if ((*images)->debug != MagickFalse)
8241 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8242 (*images)->filename);
8243 if ((argc <= 0) || (*argv == (char *) NULL))
8245 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8250 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8255 Pre-process multi-image sequence operators
8257 if (post == MagickFalse)
8258 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8260 For each image, process simple single image operators
8263 n=GetImageListLength(*images);
8267 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8268 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8270 status&=MogrifyImage(image_info,argc,argv,images,exception);
8271 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8272 if (proceed == MagickFalse)
8274 if ( (*images)->next == (Image *) NULL )
8276 *images=(*images)->next;
8279 assert( *images != (Image *) NULL );
8281 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8282 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8286 Post-process, multi-image sequence operators
8288 *images=GetFirstImageInList(*images);
8289 if (post != MagickFalse)
8290 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8291 return(status != 0 ? MagickTrue : MagickFalse);