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) QueryMagickColorCompliance(token,AllCompliance,&color,exception);
538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
539 sparse_arguments[x++] = QuantumScale*color.red;
540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
541 sparse_arguments[x++] = QuantumScale*color.green;
542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
543 sparse_arguments[x++] = QuantumScale*color.blue;
544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
545 (image->colorspace == CMYKColorspace))
546 sparse_arguments[x++] = QuantumScale*color.black;
547 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
548 (image->matte != MagickFalse))
549 sparse_arguments[x++] = QuantumScale*color.alpha;
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
554 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
556 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
557 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
559 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
560 token[0] = ','; /* used this token - get another */
562 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
568 token[0] = ','; /* used this token - get another */
570 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
572 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
573 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
575 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
576 token[0] = ','; /* used this token - get another */
578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
579 (image->colorspace == CMYKColorspace))
581 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
582 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
584 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
585 token[0] = ','; /* used this token - get another */
587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
588 (image->matte != MagickFalse))
590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
593 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
594 token[0] = ','; /* used this token - get another */
599 if ( number_arguments != x && !error ) {
600 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
601 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( (Image *)NULL);
606 return( (Image *)NULL);
608 /* Call the Interpolation function with the parsed arguments */
609 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
611 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
612 return( sparse_image );
615 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
616 const char **argv,Image **image,ExceptionInfo *exception)
649 PixelInterpolateMethod
663 Initialize method variables.
665 assert(image_info != (const ImageInfo *) NULL);
666 assert(image_info->signature == MagickSignature);
667 assert(image != (Image **) NULL);
668 assert((*image)->signature == MagickSignature);
669 if ((*image)->debug != MagickFalse)
670 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
673 mogrify_info=CloneImageInfo(image_info);
674 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
675 quantize_info=AcquireQuantizeInfo(mogrify_info);
676 SetGeometryInfo(&geometry_info);
677 GetPixelInfo(*image,&fill);
678 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
679 compose=(*image)->compose;
680 interpolate_method=UndefinedInterpolatePixel;
681 channel=mogrify_info->channel;
682 format=GetImageOption(mogrify_info,"format");
683 SetGeometry(*image,®ion_geometry);
684 region_image=NewImageList();
686 Transmogrify the image.
688 for (i=0; i < (ssize_t) argc; i++)
697 if (IsCommandOption(option) == MagickFalse)
699 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
701 if ((i+count) >= (ssize_t) argc)
703 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
704 mogrify_image=(Image *)NULL;
709 if (LocaleCompare("adaptive-blur",option+1) == 0)
714 (void) SyncImageSettings(mogrify_info,*image);
715 flags=ParseGeometry(argv[i+1],&geometry_info);
716 if ((flags & SigmaValue) == 0)
717 geometry_info.sigma=1.0;
718 if ((flags & XiValue) == 0)
719 geometry_info.xi=0.0;
720 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
721 geometry_info.sigma,geometry_info.xi,exception);
724 if (LocaleCompare("adaptive-resize",option+1) == 0)
727 Adaptive resize image.
729 (void) SyncImageSettings(mogrify_info,*image);
730 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
731 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
732 geometry.height,interpolate_method,exception);
735 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
738 Adaptive sharpen image.
740 (void) SyncImageSettings(mogrify_info,*image);
741 flags=ParseGeometry(argv[i+1],&geometry_info);
742 if ((flags & SigmaValue) == 0)
743 geometry_info.sigma=1.0;
744 if ((flags & XiValue) == 0)
745 geometry_info.xi=0.0;
746 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
747 geometry_info.sigma,geometry_info.xi,exception);
750 if (LocaleCompare("affine",option+1) == 0)
757 GetAffineMatrix(&draw_info->affine);
760 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
763 if (LocaleCompare("alpha",option+1) == 0)
768 (void) SyncImageSettings(mogrify_info,*image);
769 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
770 MagickFalse,argv[i+1]);
771 (void) SetImageAlphaChannel(*image,alpha_type,exception);
774 if (LocaleCompare("annotate",option+1) == 0)
778 geometry[MaxTextExtent];
783 (void) SyncImageSettings(mogrify_info,*image);
784 SetGeometryInfo(&geometry_info);
785 flags=ParseGeometry(argv[i+1],&geometry_info);
786 if ((flags & SigmaValue) == 0)
787 geometry_info.sigma=geometry_info.rho;
788 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
790 if (text == (char *) NULL)
792 (void) CloneString(&draw_info->text,text);
793 text=DestroyString(text);
794 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
795 geometry_info.xi,geometry_info.psi);
796 (void) CloneString(&draw_info->geometry,geometry);
797 draw_info->affine.sx=cos(DegreesToRadians(
798 fmod(geometry_info.rho,360.0)));
799 draw_info->affine.rx=sin(DegreesToRadians(
800 fmod(geometry_info.rho,360.0)));
801 draw_info->affine.ry=(-sin(DegreesToRadians(
802 fmod(geometry_info.sigma,360.0))));
803 draw_info->affine.sy=cos(DegreesToRadians(
804 fmod(geometry_info.sigma,360.0)));
805 (void) AnnotateImage(*image,draw_info,exception);
808 if (LocaleCompare("antialias",option+1) == 0)
810 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
812 draw_info->text_antialias=(*option == '-') ? MagickTrue :
816 if (LocaleCompare("auto-gamma",option+1) == 0)
819 Auto Adjust Gamma of image based on its mean
821 (void) SyncImageSettings(mogrify_info,*image);
822 (void) AutoGammaImage(*image,exception);
825 if (LocaleCompare("auto-level",option+1) == 0)
828 Perfectly Normalize (max/min stretch) the image
830 (void) SyncImageSettings(mogrify_info,*image);
831 (void) AutoLevelImage(*image,exception);
834 if (LocaleCompare("auto-orient",option+1) == 0)
836 (void) SyncImageSettings(mogrify_info,*image);
837 switch ((*image)->orientation)
839 case TopRightOrientation:
841 mogrify_image=FlopImage(*image,exception);
844 case BottomRightOrientation:
846 mogrify_image=RotateImage(*image,180.0,exception);
849 case BottomLeftOrientation:
851 mogrify_image=FlipImage(*image,exception);
854 case LeftTopOrientation:
856 mogrify_image=TransposeImage(*image,exception);
859 case RightTopOrientation:
861 mogrify_image=RotateImage(*image,90.0,exception);
864 case RightBottomOrientation:
866 mogrify_image=TransverseImage(*image,exception);
869 case LeftBottomOrientation:
871 mogrify_image=RotateImage(*image,270.0,exception);
877 if (mogrify_image != (Image *) NULL)
878 mogrify_image->orientation=TopLeftOrientation;
885 if (LocaleCompare("black-threshold",option+1) == 0)
888 Black threshold image.
890 (void) SyncImageSettings(mogrify_info,*image);
891 (void) BlackThresholdImage(*image,argv[i+1],exception);
892 InheritException(exception,&(*image)->exception);
895 if (LocaleCompare("blue-shift",option+1) == 0)
900 (void) SyncImageSettings(mogrify_info,*image);
901 geometry_info.rho=1.5;
903 flags=ParseGeometry(argv[i+1],&geometry_info);
904 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
907 if (LocaleCompare("blur",option+1) == 0)
912 (void) SyncImageSettings(mogrify_info,*image);
913 flags=ParseGeometry(argv[i+1],&geometry_info);
914 if ((flags & SigmaValue) == 0)
915 geometry_info.sigma=1.0;
916 if ((flags & XiValue) == 0)
917 geometry_info.xi=0.0;
918 mogrify_image=BlurImage(*image,geometry_info.rho,
919 geometry_info.sigma,geometry_info.xi,exception);
922 if (LocaleCompare("border",option+1) == 0)
925 Surround image with a border of solid color.
927 (void) SyncImageSettings(mogrify_info,*image);
928 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
929 if ((flags & SigmaValue) == 0)
930 geometry.height=geometry.width;
931 mogrify_image=BorderImage(*image,&geometry,compose,exception);
934 if (LocaleCompare("bordercolor",option+1) == 0)
938 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
939 &draw_info->border_color,exception);
942 (void) QueryColorCompliance(argv[i+1],AllCompliance,
943 &draw_info->border_color,exception);
946 if (LocaleCompare("box",option+1) == 0)
948 (void) QueryColorCompliance(argv[i+1],AllCompliance,
949 &draw_info->undercolor,exception);
952 if (LocaleCompare("brightness-contrast",option+1) == 0)
965 Brightness / contrast image.
967 (void) SyncImageSettings(mogrify_info,*image);
968 flags=ParseGeometry(argv[i+1],&geometry_info);
969 brightness=geometry_info.rho;
971 if ((flags & SigmaValue) != 0)
972 contrast=geometry_info.sigma;
973 (void) BrightnessContrastImage(*image,brightness,contrast,
975 InheritException(exception,&(*image)->exception);
982 if (LocaleCompare("cdl",option+1) == 0)
985 *color_correction_collection;
988 Color correct with a color decision list.
990 (void) SyncImageSettings(mogrify_info,*image);
991 color_correction_collection=FileToString(argv[i+1],~0,exception);
992 if (color_correction_collection == (char *) NULL)
994 (void) ColorDecisionListImage(*image,color_correction_collection,
996 InheritException(exception,&(*image)->exception);
999 if (LocaleCompare("channel",option+1) == 0)
1002 channel=DefaultChannels;
1004 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1005 SetPixelChannelMap(*image,channel);
1008 if (LocaleCompare("charcoal",option+1) == 0)
1013 (void) SyncImageSettings(mogrify_info,*image);
1014 flags=ParseGeometry(argv[i+1],&geometry_info);
1015 if ((flags & SigmaValue) == 0)
1016 geometry_info.sigma=1.0;
1017 if ((flags & XiValue) == 0)
1018 geometry_info.xi=1.0;
1019 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1020 geometry_info.sigma,geometry_info.xi,exception);
1023 if (LocaleCompare("chop",option+1) == 0)
1028 (void) SyncImageSettings(mogrify_info,*image);
1029 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1030 mogrify_image=ChopImage(*image,&geometry,exception);
1033 if (LocaleCompare("clamp",option+1) == 0)
1038 (void) SyncImageSettings(mogrify_info,*image);
1039 (void) ClampImage(*image);
1040 InheritException(exception,&(*image)->exception);
1043 if (LocaleCompare("clip",option+1) == 0)
1045 (void) SyncImageSettings(mogrify_info,*image);
1048 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1051 (void) ClipImage(*image,exception);
1054 if (LocaleCompare("clip-mask",option+1) == 0)
1071 (void) SyncImageSettings(mogrify_info,*image);
1077 (void) SetImageMask(*image,(Image *) NULL,exception);
1082 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1084 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1085 if (mask_image == (Image *) NULL)
1087 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1088 return(MagickFalse);
1089 mask_view=AcquireCacheView(mask_image);
1090 for (y=0; y < (ssize_t) mask_image->rows; y++)
1092 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1094 if (q == (Quantum *) NULL)
1096 for (x=0; x < (ssize_t) mask_image->columns; x++)
1098 if (mask_image->matte == MagickFalse)
1099 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1100 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1101 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1102 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1103 q+=GetPixelChannels(mask_image);
1105 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1108 mask_view=DestroyCacheView(mask_view);
1109 mask_image->matte=MagickTrue;
1110 (void) SetImageClipMask(*image,mask_image,exception);
1111 InheritException(exception,&(*image)->exception);
1114 if (LocaleCompare("clip-path",option+1) == 0)
1116 (void) SyncImageSettings(mogrify_info,*image);
1117 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1118 MagickFalse,exception);
1121 if (LocaleCompare("colorize",option+1) == 0)
1126 (void) SyncImageSettings(mogrify_info,*image);
1127 mogrify_image=ColorizeImage(*image,argv[i+1],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) QueryMagickColorCompliance("none",AllCompliance,&fill,
1557 (void) QueryColorCompliance("none",AllCompliance,
1558 &draw_info->fill,exception);
1559 if (draw_info->fill_pattern != (Image *) NULL)
1560 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1563 sans=AcquireExceptionInfo();
1564 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&fill,
1566 status=QueryColorCompliance(argv[i+1],AllCompliance,
1567 &draw_info->fill,sans);
1568 sans=DestroyExceptionInfo(sans);
1569 if (status == MagickFalse)
1570 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1574 if (LocaleCompare("flip",option+1) == 0)
1577 Flip image scanlines.
1579 (void) SyncImageSettings(mogrify_info,*image);
1580 mogrify_image=FlipImage(*image,exception);
1583 if (LocaleCompare("floodfill",option+1) == 0)
1591 (void) SyncImageSettings(mogrify_info,*image);
1592 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1593 (void) QueryMagickColorCompliance(argv[i+2],AllCompliance,&target,
1595 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1596 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1599 if (LocaleCompare("flop",option+1) == 0)
1602 Flop image scanlines.
1604 (void) SyncImageSettings(mogrify_info,*image);
1605 mogrify_image=FlopImage(*image,exception);
1608 if (LocaleCompare("font",option+1) == 0)
1612 if (draw_info->font != (char *) NULL)
1613 draw_info->font=DestroyString(draw_info->font);
1616 (void) CloneString(&draw_info->font,argv[i+1]);
1619 if (LocaleCompare("format",option+1) == 0)
1624 if (LocaleCompare("frame",option+1) == 0)
1630 Surround image with an ornamental border.
1632 (void) SyncImageSettings(mogrify_info,*image);
1633 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1634 frame_info.width=geometry.width;
1635 frame_info.height=geometry.height;
1636 if ((flags & HeightValue) == 0)
1637 frame_info.height=geometry.width;
1638 frame_info.outer_bevel=geometry.x;
1639 frame_info.inner_bevel=geometry.y;
1640 frame_info.x=(ssize_t) frame_info.width;
1641 frame_info.y=(ssize_t) frame_info.height;
1642 frame_info.width=(*image)->columns+2*frame_info.width;
1643 frame_info.height=(*image)->rows+2*frame_info.height;
1644 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1647 if (LocaleCompare("function",option+1) == 0)
1651 token[MaxTextExtent];
1669 Function Modify Image Values
1671 (void) SyncImageSettings(mogrify_info,*image);
1672 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1673 MagickFalse,argv[i+1]);
1674 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1676 if (arguments == (char *) NULL)
1678 p=(char *) arguments;
1679 for (x=0; *p != '\0'; x++)
1681 GetMagickToken(p,&p,token);
1683 GetMagickToken(p,&p,token);
1685 number_parameters=(size_t) x;
1686 parameters=(double *) AcquireQuantumMemory(number_parameters,
1687 sizeof(*parameters));
1688 if (parameters == (double *) NULL)
1689 ThrowWandFatalException(ResourceLimitFatalError,
1690 "MemoryAllocationFailed",(*image)->filename);
1691 (void) ResetMagickMemory(parameters,0,number_parameters*
1692 sizeof(*parameters));
1693 p=(char *) arguments;
1694 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1696 GetMagickToken(p,&p,token);
1698 GetMagickToken(p,&p,token);
1699 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1701 arguments=DestroyString(arguments);
1702 (void) FunctionImage(*image,function,number_parameters,parameters,
1704 parameters=(double *) RelinquishMagickMemory(parameters);
1711 if (LocaleCompare("gamma",option+1) == 0)
1716 (void) SyncImageSettings(mogrify_info,*image);
1718 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1720 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1721 (char **) NULL),exception);
1724 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1725 (LocaleCompare("gaussian",option+1) == 0))
1728 Gaussian blur image.
1730 (void) SyncImageSettings(mogrify_info,*image);
1731 flags=ParseGeometry(argv[i+1],&geometry_info);
1732 if ((flags & SigmaValue) == 0)
1733 geometry_info.sigma=1.0;
1734 if ((flags & XiValue) == 0)
1735 geometry_info.xi=0.0;
1736 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1737 geometry_info.sigma,geometry_info.xi,exception);
1740 if (LocaleCompare("geometry",option+1) == 0)
1743 Record Image offset, Resize last image.
1745 (void) SyncImageSettings(mogrify_info,*image);
1748 if ((*image)->geometry != (char *) NULL)
1749 (*image)->geometry=DestroyString((*image)->geometry);
1752 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1753 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1754 (void) CloneString(&(*image)->geometry,argv[i+1]);
1756 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1757 (*image)->filter,(*image)->blur,exception);
1760 if (LocaleCompare("gravity",option+1) == 0)
1764 draw_info->gravity=UndefinedGravity;
1767 draw_info->gravity=(GravityType) ParseCommandOption(
1768 MagickGravityOptions,MagickFalse,argv[i+1]);
1775 if (LocaleCompare("highlight-color",option+1) == 0)
1777 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1784 if (LocaleCompare("identify",option+1) == 0)
1789 (void) SyncImageSettings(mogrify_info,*image);
1790 if (format == (char *) NULL)
1792 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1796 text=InterpretImageProperties(mogrify_info,*image,format,
1798 if (text == (char *) NULL)
1800 (void) fputs(text,stdout);
1801 (void) fputc('\n',stdout);
1802 text=DestroyString(text);
1805 if (LocaleCompare("implode",option+1) == 0)
1810 (void) SyncImageSettings(mogrify_info,*image);
1811 (void) ParseGeometry(argv[i+1],&geometry_info);
1812 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1813 interpolate_method,exception);
1816 if (LocaleCompare("interline-spacing",option+1) == 0)
1819 (void) ParseGeometry("0",&geometry_info);
1821 (void) ParseGeometry(argv[i+1],&geometry_info);
1822 draw_info->interline_spacing=geometry_info.rho;
1825 if (LocaleCompare("interpolate",option+1) == 0)
1827 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1828 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1831 if (LocaleCompare("interword-spacing",option+1) == 0)
1834 (void) ParseGeometry("0",&geometry_info);
1836 (void) ParseGeometry(argv[i+1],&geometry_info);
1837 draw_info->interword_spacing=geometry_info.rho;
1844 if (LocaleCompare("kerning",option+1) == 0)
1847 (void) ParseGeometry("0",&geometry_info);
1849 (void) ParseGeometry(argv[i+1],&geometry_info);
1850 draw_info->kerning=geometry_info.rho;
1857 if (LocaleCompare("lat",option+1) == 0)
1860 Local adaptive threshold image.
1862 (void) SyncImageSettings(mogrify_info,*image);
1863 flags=ParseGeometry(argv[i+1],&geometry_info);
1864 if ((flags & PercentValue) != 0)
1865 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1866 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1867 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1868 geometry_info.xi,exception);
1871 if (LocaleCompare("level",option+1) == 0)
1884 (void) SyncImageSettings(mogrify_info,*image);
1885 flags=ParseGeometry(argv[i+1],&geometry_info);
1886 black_point=geometry_info.rho;
1887 white_point=(MagickRealType) QuantumRange;
1888 if ((flags & SigmaValue) != 0)
1889 white_point=geometry_info.sigma;
1891 if ((flags & XiValue) != 0)
1892 gamma=geometry_info.xi;
1893 if ((flags & PercentValue) != 0)
1895 black_point*=(MagickRealType) (QuantumRange/100.0);
1896 white_point*=(MagickRealType) (QuantumRange/100.0);
1898 if ((flags & SigmaValue) == 0)
1899 white_point=(MagickRealType) QuantumRange-black_point;
1900 if ((*option == '+') || ((flags & AspectValue) != 0))
1901 (void) LevelizeImage(*image,black_point,white_point,gamma,
1904 (void) LevelImage(*image,black_point,white_point,gamma,
1906 InheritException(exception,&(*image)->exception);
1909 if (LocaleCompare("level-colors",option+1) == 0)
1912 token[MaxTextExtent];
1921 p=(const char *) argv[i+1];
1922 GetMagickToken(p,&p,token); /* get black point color */
1923 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1924 (void) QueryMagickColorCompliance(token,AllCompliance,
1925 &black_point,exception);
1927 (void) QueryMagickColorCompliance("#000000",AllCompliance,
1928 &black_point,exception);
1929 if (isalpha((int) token[0]) || (token[0] == '#'))
1930 GetMagickToken(p,&p,token);
1932 white_point=black_point; /* set everything to that color */
1935 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1936 GetMagickToken(p,&p,token); /* Get white point color. */
1937 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1938 (void) QueryMagickColorCompliance(token,AllCompliance,
1939 &white_point,exception);
1941 (void) QueryMagickColorCompliance("#ffffff",AllCompliance,
1942 &white_point,exception);
1944 (void) LevelImageColors(*image,&black_point,&white_point,
1945 *option == '+' ? MagickTrue : MagickFalse,exception);
1948 if (LocaleCompare("linear-stretch",option+1) == 0)
1957 (void) SyncImageSettings(mogrify_info,*image);
1958 flags=ParseGeometry(argv[i+1],&geometry_info);
1959 black_point=geometry_info.rho;
1960 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1961 if ((flags & SigmaValue) != 0)
1962 white_point=geometry_info.sigma;
1963 if ((flags & PercentValue) != 0)
1965 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1966 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1968 if ((flags & SigmaValue) == 0)
1969 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1971 (void) LinearStretchImage(*image,black_point,white_point,exception);
1972 InheritException(exception,&(*image)->exception);
1975 if (LocaleCompare("linewidth",option+1) == 0)
1977 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1981 if (LocaleCompare("liquid-rescale",option+1) == 0)
1984 Liquid rescale image.
1986 (void) SyncImageSettings(mogrify_info,*image);
1987 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1988 if ((flags & XValue) == 0)
1990 if ((flags & YValue) == 0)
1992 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1993 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1996 if (LocaleCompare("lowlight-color",option+1) == 0)
1998 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2005 if (LocaleCompare("map",option+1) == 0)
2011 Transform image colors to match this set of colors.
2013 (void) SyncImageSettings(mogrify_info,*image);
2016 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2017 if (remap_image == (Image *) NULL)
2019 (void) RemapImage(quantize_info,*image,remap_image,exception);
2020 remap_image=DestroyImage(remap_image);
2023 if (LocaleCompare("mask",option+1) == 0)
2028 (void) SyncImageSettings(mogrify_info,*image);
2034 (void) SetImageMask(*image,(Image *) NULL,exception);
2040 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2041 if (mask == (Image *) NULL)
2043 (void) SetImageMask(*image,mask,exception);
2044 mask=DestroyImage(mask);
2047 if (LocaleCompare("matte",option+1) == 0)
2049 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2050 SetAlphaChannel : DeactivateAlphaChannel,exception);
2053 if (LocaleCompare("median",option+1) == 0)
2056 Median filter image.
2058 (void) SyncImageSettings(mogrify_info,*image);
2059 flags=ParseGeometry(argv[i+1],&geometry_info);
2060 if ((flags & SigmaValue) == 0)
2061 geometry_info.sigma=geometry_info.rho;
2062 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2063 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2066 if (LocaleCompare("mode",option+1) == 0)
2071 (void) SyncImageSettings(mogrify_info,*image);
2072 flags=ParseGeometry(argv[i+1],&geometry_info);
2073 if ((flags & SigmaValue) == 0)
2074 geometry_info.sigma=geometry_info.rho;
2075 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2076 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2079 if (LocaleCompare("modulate",option+1) == 0)
2081 (void) SyncImageSettings(mogrify_info,*image);
2082 (void) ModulateImage(*image,argv[i+1],exception);
2085 if (LocaleCompare("monitor",option+1) == 0)
2089 (void) SetImageProgressMonitor(*image,
2090 (MagickProgressMonitor) NULL,(void *) NULL);
2093 (void) SetImageProgressMonitor(*image,MonitorProgress,
2097 if (LocaleCompare("monochrome",option+1) == 0)
2099 (void) SyncImageSettings(mogrify_info,*image);
2100 (void) SetImageType(*image,BilevelType,exception);
2103 if (LocaleCompare("morphology",option+1) == 0)
2106 token[MaxTextExtent];
2121 Morphological Image Operation
2123 (void) SyncImageSettings(mogrify_info,*image);
2125 GetMagickToken(p,&p,token);
2126 method=(MorphologyMethod) ParseCommandOption(
2127 MagickMorphologyOptions,MagickFalse,token);
2129 GetMagickToken(p,&p,token);
2130 if ((*p == ':') || (*p == ','))
2131 GetMagickToken(p,&p,token);
2133 iterations=(ssize_t) StringToLong(p);
2134 kernel=AcquireKernelInfo(argv[i+2]);
2135 if (kernel == (KernelInfo *) NULL)
2137 (void) ThrowMagickException(exception,GetMagickModule(),
2138 OptionError,"UnabletoParseKernel","morphology");
2142 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2144 kernel=DestroyKernelInfo(kernel);
2147 if (LocaleCompare("motion-blur",option+1) == 0)
2152 (void) SyncImageSettings(mogrify_info,*image);
2153 flags=ParseGeometry(argv[i+1],&geometry_info);
2154 if ((flags & SigmaValue) == 0)
2155 geometry_info.sigma=1.0;
2156 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2157 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2165 if (LocaleCompare("negate",option+1) == 0)
2167 (void) SyncImageSettings(mogrify_info,*image);
2168 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2169 MagickFalse,exception);
2172 if (LocaleCompare("noise",option+1) == 0)
2174 (void) SyncImageSettings(mogrify_info,*image);
2177 flags=ParseGeometry(argv[i+1],&geometry_info);
2178 if ((flags & SigmaValue) == 0)
2179 geometry_info.sigma=geometry_info.rho;
2180 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2181 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2188 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2189 MagickFalse,argv[i+1]);
2190 mogrify_image=AddNoiseImage(*image,noise,exception);
2194 if (LocaleCompare("normalize",option+1) == 0)
2196 (void) SyncImageSettings(mogrify_info,*image);
2197 (void) NormalizeImage(*image,exception);
2204 if (LocaleCompare("opaque",option+1) == 0)
2209 (void) SyncImageSettings(mogrify_info,*image);
2210 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2212 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2213 MagickFalse : MagickTrue,exception);
2216 if (LocaleCompare("ordered-dither",option+1) == 0)
2218 (void) SyncImageSettings(mogrify_info,*image);
2219 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2226 if (LocaleCompare("paint",option+1) == 0)
2228 (void) SyncImageSettings(mogrify_info,*image);
2229 (void) ParseGeometry(argv[i+1],&geometry_info);
2230 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2231 geometry_info.sigma,exception);
2234 if (LocaleCompare("pen",option+1) == 0)
2238 (void) QueryColorCompliance("none",AllCompliance,
2239 &draw_info->fill,exception);
2242 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2243 &draw_info->fill,exception);
2246 if (LocaleCompare("pointsize",option+1) == 0)
2249 (void) ParseGeometry("12",&geometry_info);
2251 (void) ParseGeometry(argv[i+1],&geometry_info);
2252 draw_info->pointsize=geometry_info.rho;
2255 if (LocaleCompare("polaroid",option+1) == 0)
2264 Simulate a Polaroid picture.
2266 (void) SyncImageSettings(mogrify_info,*image);
2267 random_info=AcquireRandomInfo();
2268 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2269 random_info=DestroyRandomInfo(random_info);
2272 SetGeometryInfo(&geometry_info);
2273 flags=ParseGeometry(argv[i+1],&geometry_info);
2274 angle=geometry_info.rho;
2276 mogrify_image=PolaroidImage(*image,draw_info,angle,
2277 interpolate_method,exception);
2280 if (LocaleCompare("posterize",option+1) == 0)
2285 (void) SyncImageSettings(mogrify_info,*image);
2286 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2287 quantize_info->dither,exception);
2290 if (LocaleCompare("preview",option+1) == 0)
2298 (void) SyncImageSettings(mogrify_info,*image);
2300 preview_type=UndefinedPreview;
2302 preview_type=(PreviewType) ParseCommandOption(
2303 MagickPreviewOptions,MagickFalse,argv[i+1]);
2304 mogrify_image=PreviewImage(*image,preview_type,exception);
2307 if (LocaleCompare("profile",option+1) == 0)
2321 (void) SyncImageSettings(mogrify_info,*image);
2325 Remove a profile from the image.
2327 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2329 InheritException(exception,&(*image)->exception);
2333 Associate a profile with the image.
2335 profile_info=CloneImageInfo(mogrify_info);
2336 profile=GetImageProfile(*image,"iptc");
2337 if (profile != (StringInfo *) NULL)
2338 profile_info->profile=(void *) CloneStringInfo(profile);
2339 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2340 profile_info=DestroyImageInfo(profile_info);
2341 if (profile_image == (Image *) NULL)
2346 profile_info=CloneImageInfo(mogrify_info);
2347 (void) CopyMagickString(profile_info->filename,argv[i+1],
2349 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2350 if (profile != (StringInfo *) NULL)
2352 (void) ProfileImage(*image,profile_info->magick,
2353 GetStringInfoDatum(profile),(size_t)
2354 GetStringInfoLength(profile),MagickFalse);
2355 profile=DestroyStringInfo(profile);
2357 profile_info=DestroyImageInfo(profile_info);
2360 ResetImageProfileIterator(profile_image);
2361 name=GetNextImageProfile(profile_image);
2362 while (name != (const char *) NULL)
2364 profile=GetImageProfile(profile_image,name);
2365 if (profile != (StringInfo *) NULL)
2366 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2367 (size_t) GetStringInfoLength(profile),MagickFalse);
2368 name=GetNextImageProfile(profile_image);
2370 profile_image=DestroyImage(profile_image);
2377 if (LocaleCompare("quantize",option+1) == 0)
2381 quantize_info->colorspace=UndefinedColorspace;
2384 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2385 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2392 if (LocaleCompare("radial-blur",option+1) == 0)
2397 (void) SyncImageSettings(mogrify_info,*image);
2398 flags=ParseGeometry(argv[i+1],&geometry_info);
2399 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2400 geometry_info.sigma,exception);
2403 if (LocaleCompare("raise",option+1) == 0)
2406 Surround image with a raise of solid color.
2408 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2409 if ((flags & SigmaValue) == 0)
2410 geometry.height=geometry.width;
2411 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2412 MagickFalse,exception);
2415 if (LocaleCompare("random-threshold",option+1) == 0)
2420 (void) SyncImageSettings(mogrify_info,*image);
2421 (void) RandomThresholdImage(*image,argv[i+1],exception);
2424 if (LocaleCompare("recolor",option+1) == 0)
2429 (void) SyncImageSettings(mogrify_info,*image);
2430 kernel=AcquireKernelInfo(argv[i+1]);
2431 if (kernel == (KernelInfo *) NULL)
2433 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2434 kernel=DestroyKernelInfo(kernel);
2437 if (LocaleCompare("region",option+1) == 0)
2439 (void) SyncImageSettings(mogrify_info,*image);
2440 if (region_image != (Image *) NULL)
2445 (void) CompositeImage(region_image,region_image->matte !=
2446 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2447 region_geometry.x,region_geometry.y);
2448 InheritException(exception,®ion_image->exception);
2449 *image=DestroyImage(*image);
2450 *image=region_image;
2451 region_image = (Image *) NULL;
2456 Apply transformations to a selected region of the image.
2458 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2460 mogrify_image=CropImage(*image,®ion_geometry,exception);
2461 if (mogrify_image == (Image *) NULL)
2463 region_image=(*image);
2464 *image=mogrify_image;
2465 mogrify_image=(Image *) NULL;
2468 if (LocaleCompare("render",option+1) == 0)
2470 (void) SyncImageSettings(mogrify_info,*image);
2471 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2474 if (LocaleCompare("remap",option+1) == 0)
2480 Transform image colors to match this set of colors.
2482 (void) SyncImageSettings(mogrify_info,*image);
2485 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2486 if (remap_image == (Image *) NULL)
2488 (void) RemapImage(quantize_info,*image,remap_image,exception);
2489 remap_image=DestroyImage(remap_image);
2492 if (LocaleCompare("repage",option+1) == 0)
2496 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2499 (void) ResetImagePage(*image,argv[i+1]);
2500 InheritException(exception,&(*image)->exception);
2503 if (LocaleCompare("resample",option+1) == 0)
2508 (void) SyncImageSettings(mogrify_info,*image);
2509 flags=ParseGeometry(argv[i+1],&geometry_info);
2510 if ((flags & SigmaValue) == 0)
2511 geometry_info.sigma=geometry_info.rho;
2512 mogrify_image=ResampleImage(*image,geometry_info.rho,
2513 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2516 if (LocaleCompare("resize",option+1) == 0)
2521 (void) SyncImageSettings(mogrify_info,*image);
2522 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2523 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2524 (*image)->filter,(*image)->blur,exception);
2527 if (LocaleCompare("roll",option+1) == 0)
2532 (void) SyncImageSettings(mogrify_info,*image);
2533 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2534 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2537 if (LocaleCompare("rotate",option+1) == 0)
2543 Check for conditional image rotation.
2545 (void) SyncImageSettings(mogrify_info,*image);
2546 if (strchr(argv[i+1],'>') != (char *) NULL)
2547 if ((*image)->columns <= (*image)->rows)
2549 if (strchr(argv[i+1],'<') != (char *) NULL)
2550 if ((*image)->columns >= (*image)->rows)
2555 geometry=ConstantString(argv[i+1]);
2556 (void) SubstituteString(&geometry,">","");
2557 (void) SubstituteString(&geometry,"<","");
2558 (void) ParseGeometry(geometry,&geometry_info);
2559 geometry=DestroyString(geometry);
2560 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2567 if (LocaleCompare("sample",option+1) == 0)
2570 Sample image with pixel replication.
2572 (void) SyncImageSettings(mogrify_info,*image);
2573 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2574 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2578 if (LocaleCompare("scale",option+1) == 0)
2583 (void) SyncImageSettings(mogrify_info,*image);
2584 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2585 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2589 if (LocaleCompare("selective-blur",option+1) == 0)
2592 Selectively blur pixels within a contrast threshold.
2594 (void) SyncImageSettings(mogrify_info,*image);
2595 flags=ParseGeometry(argv[i+1],&geometry_info);
2596 if ((flags & PercentValue) != 0)
2597 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2598 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2599 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2602 if (LocaleCompare("separate",option+1) == 0)
2605 Break channels into separate images.
2607 (void) SyncImageSettings(mogrify_info,*image);
2608 mogrify_image=SeparateImages(*image,exception);
2611 if (LocaleCompare("sepia-tone",option+1) == 0)
2619 (void) SyncImageSettings(mogrify_info,*image);
2620 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2621 mogrify_image=SepiaToneImage(*image,threshold,exception);
2624 if (LocaleCompare("segment",option+1) == 0)
2629 (void) SyncImageSettings(mogrify_info,*image);
2630 flags=ParseGeometry(argv[i+1],&geometry_info);
2631 if ((flags & SigmaValue) == 0)
2632 geometry_info.sigma=1.0;
2633 (void) SegmentImage(*image,(*image)->colorspace,
2634 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2638 if (LocaleCompare("set",option+1) == 0)
2648 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2649 (void) DeleteImageRegistry(argv[i+1]+9);
2651 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2653 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2654 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2657 (void) DeleteImageProperty(*image,argv[i+1]);
2660 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2662 if (value == (char *) NULL)
2664 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2665 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2668 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2670 (void) SetImageOption(image_info,argv[i+1]+7,value);
2671 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2672 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2675 (void) SetImageProperty(*image,argv[i+1],value);
2676 value=DestroyString(value);
2679 if (LocaleCompare("shade",option+1) == 0)
2684 (void) SyncImageSettings(mogrify_info,*image);
2685 flags=ParseGeometry(argv[i+1],&geometry_info);
2686 if ((flags & SigmaValue) == 0)
2687 geometry_info.sigma=1.0;
2688 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2689 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2692 if (LocaleCompare("shadow",option+1) == 0)
2697 (void) SyncImageSettings(mogrify_info,*image);
2698 flags=ParseGeometry(argv[i+1],&geometry_info);
2699 if ((flags & SigmaValue) == 0)
2700 geometry_info.sigma=1.0;
2701 if ((flags & XiValue) == 0)
2702 geometry_info.xi=4.0;
2703 if ((flags & PsiValue) == 0)
2704 geometry_info.psi=4.0;
2705 mogrify_image=ShadowImage(*image,geometry_info.rho,
2706 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2707 ceil(geometry_info.psi-0.5),exception);
2710 if (LocaleCompare("sharpen",option+1) == 0)
2715 (void) SyncImageSettings(mogrify_info,*image);
2716 flags=ParseGeometry(argv[i+1],&geometry_info);
2717 if ((flags & SigmaValue) == 0)
2718 geometry_info.sigma=1.0;
2719 if ((flags & XiValue) == 0)
2720 geometry_info.xi=0.0;
2721 mogrify_image=SharpenImage(*image,geometry_info.rho,
2722 geometry_info.sigma,geometry_info.xi,exception);
2725 if (LocaleCompare("shave",option+1) == 0)
2728 Shave the image edges.
2730 (void) SyncImageSettings(mogrify_info,*image);
2731 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2732 mogrify_image=ShaveImage(*image,&geometry,exception);
2735 if (LocaleCompare("shear",option+1) == 0)
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 flags=ParseGeometry(argv[i+1],&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=geometry_info.rho;
2744 mogrify_image=ShearImage(*image,geometry_info.rho,
2745 geometry_info.sigma,exception);
2748 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2751 Sigmoidal non-linearity contrast control.
2753 (void) SyncImageSettings(mogrify_info,*image);
2754 flags=ParseGeometry(argv[i+1],&geometry_info);
2755 if ((flags & SigmaValue) == 0)
2756 geometry_info.sigma=(double) QuantumRange/2.0;
2757 if ((flags & PercentValue) != 0)
2758 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2760 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2761 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2765 if (LocaleCompare("sketch",option+1) == 0)
2770 (void) SyncImageSettings(mogrify_info,*image);
2771 flags=ParseGeometry(argv[i+1],&geometry_info);
2772 if ((flags & SigmaValue) == 0)
2773 geometry_info.sigma=1.0;
2774 mogrify_image=SketchImage(*image,geometry_info.rho,
2775 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2778 if (LocaleCompare("solarize",option+1) == 0)
2783 (void) SyncImageSettings(mogrify_info,*image);
2784 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2785 (void) SolarizeImage(*image,threshold,exception);
2788 if (LocaleCompare("sparse-color",option+1) == 0)
2797 Sparse Color Interpolated Gradient
2799 (void) SyncImageSettings(mogrify_info,*image);
2800 method=(SparseColorMethod) ParseCommandOption(
2801 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2802 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2804 if (arguments == (char *) NULL)
2806 mogrify_image=SparseColorOption(*image,method,arguments,
2807 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2808 arguments=DestroyString(arguments);
2811 if (LocaleCompare("splice",option+1) == 0)
2814 Splice a solid color into the image.
2816 (void) SyncImageSettings(mogrify_info,*image);
2817 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2818 mogrify_image=SpliceImage(*image,&geometry,exception);
2821 if (LocaleCompare("spread",option+1) == 0)
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 (void) ParseGeometry(argv[i+1],&geometry_info);
2828 mogrify_image=SpreadImage(*image,geometry_info.rho,
2829 interpolate_method,exception);
2832 if (LocaleCompare("statistic",option+1) == 0)
2837 (void) SyncImageSettings(mogrify_info,*image);
2838 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2839 MagickFalse,argv[i+1]);
2840 (void) ParseGeometry(argv[i+2],&geometry_info);
2841 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2842 (size_t) geometry_info.sigma,exception);
2845 if (LocaleCompare("stretch",option+1) == 0)
2849 draw_info->stretch=UndefinedStretch;
2852 draw_info->stretch=(StretchType) ParseCommandOption(
2853 MagickStretchOptions,MagickFalse,argv[i+1]);
2856 if (LocaleCompare("strip",option+1) == 0)
2859 Strip image of profiles and comments.
2861 (void) SyncImageSettings(mogrify_info,*image);
2862 (void) StripImage(*image);
2863 InheritException(exception,&(*image)->exception);
2866 if (LocaleCompare("stroke",option+1) == 0)
2873 (void) QueryColorCompliance("none",AllCompliance,
2874 &draw_info->stroke,exception);
2875 if (draw_info->stroke_pattern != (Image *) NULL)
2876 draw_info->stroke_pattern=DestroyImage(
2877 draw_info->stroke_pattern);
2880 sans=AcquireExceptionInfo();
2881 status=QueryColorCompliance(argv[i+1],AllCompliance,
2882 &draw_info->stroke,sans);
2883 sans=DestroyExceptionInfo(sans);
2884 if (status == MagickFalse)
2885 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2889 if (LocaleCompare("strokewidth",option+1) == 0)
2891 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2895 if (LocaleCompare("style",option+1) == 0)
2899 draw_info->style=UndefinedStyle;
2902 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2903 MagickFalse,argv[i+1]);
2906 if (LocaleCompare("swirl",option+1) == 0)
2911 (void) SyncImageSettings(mogrify_info,*image);
2912 (void) ParseGeometry(argv[i+1],&geometry_info);
2913 mogrify_image=SwirlImage(*image,geometry_info.rho,
2914 interpolate_method,exception);
2921 if (LocaleCompare("threshold",option+1) == 0)
2929 (void) SyncImageSettings(mogrify_info,*image);
2931 threshold=(double) QuantumRange/2;
2933 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2934 (void) BilevelImage(*image,threshold);
2935 InheritException(exception,&(*image)->exception);
2938 if (LocaleCompare("thumbnail",option+1) == 0)
2943 (void) SyncImageSettings(mogrify_info,*image);
2944 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2945 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2949 if (LocaleCompare("tile",option+1) == 0)
2953 if (draw_info->fill_pattern != (Image *) NULL)
2954 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2957 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2961 if (LocaleCompare("tint",option+1) == 0)
2966 (void) SyncImageSettings(mogrify_info,*image);
2967 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2970 if (LocaleCompare("transform",option+1) == 0)
2973 Affine transform image.
2975 (void) SyncImageSettings(mogrify_info,*image);
2976 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2980 if (LocaleCompare("transparent",option+1) == 0)
2985 (void) SyncImageSettings(mogrify_info,*image);
2986 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2988 (void) TransparentPaintImage(*image,&target,(Quantum)
2989 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2990 &(*image)->exception);
2993 if (LocaleCompare("transpose",option+1) == 0)
2996 Transpose image scanlines.
2998 (void) SyncImageSettings(mogrify_info,*image);
2999 mogrify_image=TransposeImage(*image,exception);
3002 if (LocaleCompare("transverse",option+1) == 0)
3005 Transverse image scanlines.
3007 (void) SyncImageSettings(mogrify_info,*image);
3008 mogrify_image=TransverseImage(*image,exception);
3011 if (LocaleCompare("treedepth",option+1) == 0)
3013 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3016 if (LocaleCompare("trim",option+1) == 0)
3021 (void) SyncImageSettings(mogrify_info,*image);
3022 mogrify_image=TrimImage(*image,exception);
3025 if (LocaleCompare("type",option+1) == 0)
3030 (void) SyncImageSettings(mogrify_info,*image);
3034 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3036 (*image)->type=UndefinedType;
3037 (void) SetImageType(*image,type,exception);
3044 if (LocaleCompare("undercolor",option+1) == 0)
3046 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3047 &draw_info->undercolor,exception);
3050 if (LocaleCompare("unique",option+1) == 0)
3054 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3057 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3058 (void) SetImageArtifact(*image,"verbose","true");
3061 if (LocaleCompare("unique-colors",option+1) == 0)
3064 Unique image colors.
3066 (void) SyncImageSettings(mogrify_info,*image);
3067 mogrify_image=UniqueImageColors(*image,exception);
3070 if (LocaleCompare("unsharp",option+1) == 0)
3075 (void) SyncImageSettings(mogrify_info,*image);
3076 flags=ParseGeometry(argv[i+1],&geometry_info);
3077 if ((flags & SigmaValue) == 0)
3078 geometry_info.sigma=1.0;
3079 if ((flags & XiValue) == 0)
3080 geometry_info.xi=1.0;
3081 if ((flags & PsiValue) == 0)
3082 geometry_info.psi=0.05;
3083 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3084 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3091 if (LocaleCompare("verbose",option+1) == 0)
3093 (void) SetImageArtifact(*image,option+1,
3094 *option == '+' ? "false" : "true");
3097 if (LocaleCompare("vignette",option+1) == 0)
3102 (void) SyncImageSettings(mogrify_info,*image);
3103 flags=ParseGeometry(argv[i+1],&geometry_info);
3104 if ((flags & SigmaValue) == 0)
3105 geometry_info.sigma=1.0;
3106 if ((flags & XiValue) == 0)
3107 geometry_info.xi=0.1*(*image)->columns;
3108 if ((flags & PsiValue) == 0)
3109 geometry_info.psi=0.1*(*image)->rows;
3110 mogrify_image=VignetteImage(*image,geometry_info.rho,
3111 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3112 ceil(geometry_info.psi-0.5),exception);
3115 if (LocaleCompare("virtual-pixel",option+1) == 0)
3119 (void) SetImageVirtualPixelMethod(*image,
3120 UndefinedVirtualPixelMethod);
3123 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3124 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3132 if (LocaleCompare("wave",option+1) == 0)
3137 (void) SyncImageSettings(mogrify_info,*image);
3138 flags=ParseGeometry(argv[i+1],&geometry_info);
3139 if ((flags & SigmaValue) == 0)
3140 geometry_info.sigma=1.0;
3141 mogrify_image=WaveImage(*image,geometry_info.rho,
3142 geometry_info.sigma,interpolate_method,exception);
3145 if (LocaleCompare("weight",option+1) == 0)
3147 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3148 if (LocaleCompare(argv[i+1],"all") == 0)
3149 draw_info->weight=0;
3150 if (LocaleCompare(argv[i+1],"bold") == 0)
3151 draw_info->weight=700;
3152 if (LocaleCompare(argv[i+1],"bolder") == 0)
3153 if (draw_info->weight <= 800)
3154 draw_info->weight+=100;
3155 if (LocaleCompare(argv[i+1],"lighter") == 0)
3156 if (draw_info->weight >= 100)
3157 draw_info->weight-=100;
3158 if (LocaleCompare(argv[i+1],"normal") == 0)
3159 draw_info->weight=400;
3162 if (LocaleCompare("white-threshold",option+1) == 0)
3165 White threshold image.
3167 (void) SyncImageSettings(mogrify_info,*image);
3168 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3169 InheritException(exception,&(*image)->exception);
3178 Replace current image with any image that was generated
3180 if (mogrify_image != (Image *) NULL)
3181 ReplaceImageInListReturnLast(image,mogrify_image);
3184 if (region_image != (Image *) NULL)
3187 Composite transformed region onto image.
3189 (void) SyncImageSettings(mogrify_info,*image);
3190 (void) CompositeImage(region_image,region_image->matte !=
3191 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3192 region_geometry.x,region_geometry.y);
3193 InheritException(exception,®ion_image->exception);
3194 *image=DestroyImage(*image);
3195 *image=region_image;
3196 region_image = (Image *) NULL;
3201 quantize_info=DestroyQuantizeInfo(quantize_info);
3202 draw_info=DestroyDrawInfo(draw_info);
3203 mogrify_info=DestroyImageInfo(mogrify_info);
3204 status=(MagickStatusType) ((*image)->exception.severity ==
3205 UndefinedException ? 1 : 0);
3206 return(status == 0 ? MagickFalse : MagickTrue);
3210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3214 + M o g r i f y I m a g e C o m m a n d %
3218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 % MogrifyImageCommand() transforms an image or a sequence of images. These
3221 % transforms include image scaling, image rotation, color reduction, and
3222 % others. The transmogrified image overwrites the original image.
3224 % The format of the MogrifyImageCommand method is:
3226 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3227 % const char **argv,char **metadata,ExceptionInfo *exception)
3229 % A description of each parameter follows:
3231 % o image_info: the image info.
3233 % o argc: the number of elements in the argument vector.
3235 % o argv: A text array containing the command line arguments.
3237 % o metadata: any metadata is returned here.
3239 % o exception: return any errors or warnings in this structure.
3243 static MagickBooleanType MogrifyUsage(void)
3248 "-debug events display copious debugging information",
3249 "-help print program options",
3250 "-list type print a list of supported option arguments",
3251 "-log format format of debugging information",
3252 "-version print version information",
3257 "-adaptive-blur geometry",
3258 " adaptively blur pixels; decrease effect near edges",
3259 "-adaptive-resize geometry",
3260 " adaptively resize image using 'mesh' interpolation",
3261 "-adaptive-sharpen geometry",
3262 " adaptively sharpen pixels; increase effect near edges",
3263 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3264 " transparent, extract, background, or shape",
3265 "-annotate geometry text",
3266 " annotate the image with text",
3267 "-auto-gamma automagically adjust gamma level of image",
3268 "-auto-level automagically adjust color levels of image",
3269 "-auto-orient automagically orient (rotate) image",
3270 "-bench iterations measure performance",
3271 "-black-threshold value",
3272 " force all pixels below the threshold into black",
3273 "-blue-shift simulate a scene at nighttime in the moonlight",
3274 "-blur geometry reduce image noise and reduce detail levels",
3275 "-border geometry surround image with a border of color",
3276 "-bordercolor color border color",
3277 "-brightness-contrast geometry",
3278 " improve brightness / contrast of the image",
3279 "-cdl filename color correct with a color decision list",
3280 "-charcoal geometry simulate a charcoal drawing",
3281 "-chop geometry remove pixels from the image interior",
3282 "-clamp restrict pixel range from 0 to the quantum depth",
3283 "-clip clip along the first path from the 8BIM profile",
3284 "-clip-mask filename associate a clip mask with the image",
3285 "-clip-path id clip along a named path from the 8BIM profile",
3286 "-colorize value colorize the image with the fill color",
3287 "-color-matrix matrix apply color correction to the image",
3288 "-contrast enhance or reduce the image contrast",
3289 "-contrast-stretch geometry",
3290 " improve contrast by `stretching' the intensity range",
3291 "-convolve coefficients",
3292 " apply a convolution kernel to the image",
3293 "-cycle amount cycle the image colormap",
3294 "-decipher filename convert cipher pixels to plain pixels",
3295 "-deskew threshold straighten an image",
3296 "-despeckle reduce the speckles within an image",
3297 "-distort method args",
3298 " distort images according to given method ad args",
3299 "-draw string annotate the image with a graphic primitive",
3300 "-edge radius apply a filter to detect edges in the image",
3301 "-encipher filename convert plain pixels to cipher pixels",
3302 "-emboss radius emboss an image",
3303 "-enhance apply a digital filter to enhance a noisy image",
3304 "-equalize perform histogram equalization to an image",
3305 "-evaluate operator value",
3306 " evaluate an arithmetic, relational, or logical expression",
3307 "-extent geometry set the image size",
3308 "-extract geometry extract area from image",
3309 "-fft implements the discrete Fourier transform (DFT)",
3310 "-flip flip image vertically",
3311 "-floodfill geometry color",
3312 " floodfill the image with color",
3313 "-flop flop image horizontally",
3314 "-frame geometry surround image with an ornamental border",
3315 "-function name parameters",
3316 " apply function over image values",
3317 "-gamma value level of gamma correction",
3318 "-gaussian-blur geometry",
3319 " reduce image noise and reduce detail levels",
3320 "-geometry geometry preferred size or location of the image",
3321 "-identify identify the format and characteristics of the image",
3322 "-ift implements the inverse discrete Fourier transform (DFT)",
3323 "-implode amount implode image pixels about the center",
3324 "-lat geometry local adaptive thresholding",
3325 "-layers method optimize, merge, or compare image layers",
3326 "-level value adjust the level of image contrast",
3327 "-level-colors color,color",
3328 " level image with the given colors",
3329 "-linear-stretch geometry",
3330 " improve contrast by `stretching with saturation'",
3331 "-liquid-rescale geometry",
3332 " rescale image with seam-carving",
3333 "-median geometry apply a median filter to the image",
3334 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3335 "-modulate value vary the brightness, saturation, and hue",
3336 "-monochrome transform image to black and white",
3337 "-morphology method kernel",
3338 " apply a morphology method to the image",
3339 "-motion-blur geometry",
3340 " simulate motion blur",
3341 "-negate replace every pixel with its complementary color ",
3342 "-noise geometry add or reduce noise in an image",
3343 "-normalize transform image to span the full range of colors",
3344 "-opaque color change this color to the fill color",
3345 "-ordered-dither NxN",
3346 " add a noise pattern to the image with specific",
3348 "-paint radius simulate an oil painting",
3349 "-polaroid angle simulate a Polaroid picture",
3350 "-posterize levels reduce the image to a limited number of color levels",
3351 "-profile filename add, delete, or apply an image profile",
3352 "-quantize colorspace reduce colors in this colorspace",
3353 "-radial-blur angle radial blur the image",
3354 "-raise value lighten/darken image edges to create a 3-D effect",
3355 "-random-threshold low,high",
3356 " random threshold the image",
3357 "-region geometry apply options to a portion of the image",
3358 "-render render vector graphics",
3359 "-repage geometry size and location of an image canvas",
3360 "-resample geometry change the resolution of an image",
3361 "-resize geometry resize the image",
3362 "-roll geometry roll an image vertically or horizontally",
3363 "-rotate degrees apply Paeth rotation to the image",
3364 "-sample geometry scale image with pixel sampling",
3365 "-scale geometry scale the image",
3366 "-segment values segment an image",
3367 "-selective-blur geometry",
3368 " selectively blur pixels within a contrast threshold",
3369 "-sepia-tone threshold",
3370 " simulate a sepia-toned photo",
3371 "-set property value set an image property",
3372 "-shade degrees shade the image using a distant light source",
3373 "-shadow geometry simulate an image shadow",
3374 "-sharpen geometry sharpen the image",
3375 "-shave geometry shave pixels from the image edges",
3376 "-shear geometry slide one edge of the image along the X or Y axis",
3377 "-sigmoidal-contrast geometry",
3378 " increase the contrast without saturating highlights or shadows",
3379 "-sketch geometry simulate a pencil sketch",
3380 "-solarize threshold negate all pixels above the threshold level",
3381 "-sparse-color method args",
3382 " fill in a image based on a few color points",
3383 "-splice geometry splice the background color into the image",
3384 "-spread radius displace image pixels by a random amount",
3385 "-statistic type radius",
3386 " replace each pixel with corresponding statistic from the neighborhood",
3387 "-strip strip image of all profiles and comments",
3388 "-swirl degrees swirl image pixels about the center",
3389 "-threshold value threshold the image",
3390 "-thumbnail geometry create a thumbnail of the image",
3391 "-tile filename tile image when filling a graphic primitive",
3392 "-tint value tint the image with the fill color",
3393 "-transform affine transform image",
3394 "-transparent color make this color transparent within the image",
3395 "-transpose flip image vertically and rotate 90 degrees",
3396 "-transverse flop image horizontally and rotate 270 degrees",
3397 "-trim trim image edges",
3398 "-type type image type",
3399 "-unique-colors discard all but one of any pixel color",
3400 "-unsharp geometry sharpen the image",
3401 "-vignette geometry soften the edges of the image in vignette style",
3402 "-wave geometry alter an image along a sine wave",
3403 "-white-threshold value",
3404 " force all pixels above the threshold into white",
3407 *sequence_operators[]=
3409 "-append append an image sequence",
3410 "-clut apply a color lookup table to the image",
3411 "-coalesce merge a sequence of images",
3412 "-combine combine a sequence of images",
3413 "-composite composite image",
3414 "-crop geometry cut out a rectangular region of the image",
3415 "-deconstruct break down an image sequence into constituent parts",
3416 "-evaluate-sequence operator",
3417 " evaluate an arithmetic, relational, or logical expression",
3418 "-flatten flatten a sequence of images",
3419 "-fx expression apply mathematical expression to an image channel(s)",
3420 "-hald-clut apply a Hald color lookup table to the image",
3421 "-morph value morph an image sequence",
3422 "-mosaic create a mosaic from an image sequence",
3423 "-print string interpret string and print to console",
3424 "-process arguments process the image with a custom image filter",
3425 "-separate separate an image channel into a grayscale image",
3426 "-smush geometry smush an image sequence together",
3427 "-write filename write images to this file",
3432 "-adjoin join images into a single multi-image file",
3433 "-affine matrix affine transform matrix",
3434 "-alpha option activate, deactivate, reset, or set the alpha channel",
3435 "-antialias remove pixel-aliasing",
3436 "-authenticate password",
3437 " decipher image with this password",
3438 "-attenuate value lessen (or intensify) when adding noise to an image",
3439 "-background color background color",
3440 "-bias value add bias when convolving an image",
3441 "-black-point-compensation",
3442 " use black point compensation",
3443 "-blue-primary point chromaticity blue primary point",
3444 "-bordercolor color border color",
3445 "-caption string assign a caption to an image",
3446 "-channel type apply option to select image channels",
3447 "-colors value preferred number of colors in the image",
3448 "-colorspace type alternate image colorspace",
3449 "-comment string annotate image with comment",
3450 "-compose operator set image composite operator",
3451 "-compress type type of pixel compression when writing the image",
3452 "-define format:option",
3453 " define one or more image format options",
3454 "-delay value display the next image after pausing",
3455 "-density geometry horizontal and vertical density of the image",
3456 "-depth value image depth",
3457 "-direction type render text right-to-left or left-to-right",
3458 "-display server get image or font from this X server",
3459 "-dispose method layer disposal method",
3460 "-dither method apply error diffusion to image",
3461 "-encoding type text encoding type",
3462 "-endian type endianness (MSB or LSB) of the image",
3463 "-family name render text with this font family",
3464 "-fill color color to use when filling a graphic primitive",
3465 "-filter type use this filter when resizing an image",
3466 "-font name render text with this font",
3467 "-format \"string\" output formatted image characteristics",
3468 "-fuzz distance colors within this distance are considered equal",
3469 "-gravity type horizontal and vertical text placement",
3470 "-green-primary point chromaticity green primary point",
3471 "-intent type type of rendering intent when managing the image color",
3472 "-interlace type type of image interlacing scheme",
3473 "-interline-spacing value",
3474 " set the space between two text lines",
3475 "-interpolate method pixel color interpolation method",
3476 "-interword-spacing value",
3477 " set the space between two words",
3478 "-kerning value set the space between two letters",
3479 "-label string assign a label to an image",
3480 "-limit type value pixel cache resource limit",
3481 "-loop iterations add Netscape loop extension to your GIF animation",
3482 "-mask filename associate a mask with the image",
3483 "-mattecolor color frame color",
3484 "-monitor monitor progress",
3485 "-orient type image orientation",
3486 "-page geometry size and location of an image canvas (setting)",
3487 "-ping efficiently determine image attributes",
3488 "-pointsize value font point size",
3489 "-precision value maximum number of significant digits to print",
3490 "-preview type image preview type",
3491 "-quality value JPEG/MIFF/PNG compression level",
3492 "-quiet suppress all warning messages",
3493 "-red-primary point chromaticity red primary point",
3494 "-regard-warnings pay attention to warning messages",
3495 "-remap filename transform image colors to match this set of colors",
3496 "-respect-parentheses settings remain in effect until parenthesis boundary",
3497 "-sampling-factor geometry",
3498 " horizontal and vertical sampling factor",
3499 "-scene value image scene number",
3500 "-seed value seed a new sequence of pseudo-random numbers",
3501 "-size geometry width and height of image",
3502 "-stretch type render text with this font stretch",
3503 "-stroke color graphic primitive stroke color",
3504 "-strokewidth value graphic primitive stroke width",
3505 "-style type render text with this font style",
3506 "-synchronize synchronize image to storage device",
3507 "-taint declare the image as modified",
3508 "-texture filename name of texture to tile onto the image background",
3509 "-tile-offset geometry",
3511 "-treedepth value color tree depth",
3512 "-transparent-color color",
3513 " transparent color",
3514 "-undercolor color annotation bounding box color",
3515 "-units type the units of image resolution",
3516 "-verbose print detailed information about the image",
3517 "-view FlashPix viewing transforms",
3518 "-virtual-pixel method",
3519 " virtual pixel access method",
3520 "-weight type render text with this font weight",
3521 "-white-point point chromaticity white point",
3526 "-delete indexes delete the image from the image sequence",
3527 "-duplicate count,indexes",
3528 " duplicate an image one or more times",
3529 "-insert index insert last image into the image sequence",
3530 "-reverse reverse image sequence",
3531 "-swap indexes swap two images in the image sequence",
3538 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3539 (void) printf("Copyright: %s\n",GetMagickCopyright());
3540 (void) printf("Features: %s\n\n",GetMagickFeatures());
3541 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3543 (void) printf("\nImage Settings:\n");
3544 for (p=settings; *p != (char *) NULL; p++)
3545 (void) printf(" %s\n",*p);
3546 (void) printf("\nImage Operators:\n");
3547 for (p=operators; *p != (char *) NULL; p++)
3548 (void) printf(" %s\n",*p);
3549 (void) printf("\nImage Sequence Operators:\n");
3550 for (p=sequence_operators; *p != (char *) NULL; p++)
3551 (void) printf(" %s\n",*p);
3552 (void) printf("\nImage Stack Operators:\n");
3553 for (p=stack_operators; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nMiscellaneous Options:\n");
3556 for (p=miscellaneous; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3559 "\nBy default, the image format of `file' is determined by its magic\n");
3561 "number. To specify a particular image format, precede the filename\n");
3563 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3565 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3566 (void) printf("'-' for standard input or output.\n");
3567 return(MagickFalse);
3570 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3571 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3573 #define DestroyMogrify() \
3575 if (format != (char *) NULL) \
3576 format=DestroyString(format); \
3577 if (path != (char *) NULL) \
3578 path=DestroyString(path); \
3579 DestroyImageStack(); \
3580 for (i=0; i < (ssize_t) argc; i++) \
3581 argv[i]=DestroyString(argv[i]); \
3582 argv=(char **) RelinquishMagickMemory(argv); \
3584 #define ThrowMogrifyException(asperity,tag,option) \
3586 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3589 return(MagickFalse); \
3591 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3593 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3594 "InvalidArgument","`%s': %s",argument,option); \
3596 return(MagickFalse); \
3608 image_stack[MaxImageStackDepth+1];
3616 respect_parenthesis;
3631 assert(image_info != (ImageInfo *) NULL);
3632 assert(image_info->signature == MagickSignature);
3633 if (image_info->debug != MagickFalse)
3634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3635 assert(exception != (ExceptionInfo *) NULL);
3639 if ((LocaleCompare("version",option+1) == 0) ||
3640 (LocaleCompare("-version",option+1) == 0))
3642 (void) FormatLocaleFile(stdout,"Version: %s\n",
3643 GetMagickVersion((size_t *) NULL));
3644 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3645 GetMagickCopyright());
3646 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3647 GetMagickFeatures());
3648 return(MagickFalse);
3652 return(MogrifyUsage());
3653 format=(char *) NULL;
3655 global_colormap=MagickFalse;
3659 option=(char *) NULL;
3661 respect_parenthesis=MagickFalse;
3666 ReadCommandlLine(argc,&argv);
3667 status=ExpandFilenames(&argc,&argv);
3668 if (status == MagickFalse)
3669 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3670 GetExceptionMessage(errno));
3671 for (i=1; i < (ssize_t) argc; i++)
3674 if (LocaleCompare(option,"(") == 0)
3676 FireImageStack(MagickFalse,MagickTrue,pend);
3677 if (k == MaxImageStackDepth)
3678 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3683 if (LocaleCompare(option,")") == 0)
3685 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3687 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3691 if (IsCommandOption(option) == MagickFalse)
3694 backup_filename[MaxTextExtent],
3701 Option is a file name: begin by reading image from specified file.
3703 FireImageStack(MagickFalse,MagickFalse,pend);
3705 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3707 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3708 images=ReadImages(image_info,exception);
3709 status&=(images != (Image *) NULL) &&
3710 (exception->severity < ErrorException);
3711 if (images == (Image *) NULL)
3713 if (format != (char *) NULL)
3714 (void) CopyMagickString(images->filename,images->magick_filename,
3716 if (path != (char *) NULL)
3718 GetPathComponent(option,TailPath,filename);
3719 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3720 path,*DirectorySeparator,filename);
3722 if (format != (char *) NULL)
3723 AppendImageFormat(format,images->filename);
3724 AppendImageStack(images);
3725 FinalizeImageSettings(image_info,image,MagickFalse);
3726 if (global_colormap != MagickFalse)
3731 quantize_info=AcquireQuantizeInfo(image_info);
3732 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3733 quantize_info=DestroyQuantizeInfo(quantize_info);
3735 *backup_filename='\0';
3736 if ((LocaleCompare(image->filename,"-") != 0) &&
3737 (IsPathWritable(image->filename) != MagickFalse))
3743 Rename image file as backup.
3745 (void) CopyMagickString(backup_filename,image->filename,
3747 for (i=0; i < 6; i++)
3749 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3750 if (IsPathAccessible(backup_filename) == MagickFalse)
3753 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3754 (rename_utf8(image->filename,backup_filename) != 0))
3755 *backup_filename='\0';
3758 Write transmogrified image to disk.
3760 image_info->synchronize=MagickTrue;
3761 status&=WriteImages(image_info,image,image->filename,exception);
3762 if ((status == MagickFalse) && (*backup_filename != '\0'))
3763 (void) remove_utf8(backup_filename);
3764 RemoveAllImageStack();
3767 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3768 switch (*(option+1))
3772 if (LocaleCompare("adaptive-blur",option+1) == 0)
3775 if (i == (ssize_t) argc)
3776 ThrowMogrifyException(OptionError,"MissingArgument",option);
3777 if (IsGeometry(argv[i]) == MagickFalse)
3778 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3781 if (LocaleCompare("adaptive-resize",option+1) == 0)
3784 if (i == (ssize_t) argc)
3785 ThrowMogrifyException(OptionError,"MissingArgument",option);
3786 if (IsGeometry(argv[i]) == MagickFalse)
3787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3790 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3793 if (i == (ssize_t) argc)
3794 ThrowMogrifyException(OptionError,"MissingArgument",option);
3795 if (IsGeometry(argv[i]) == MagickFalse)
3796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3799 if (LocaleCompare("affine",option+1) == 0)
3804 if (i == (ssize_t) argc)
3805 ThrowMogrifyException(OptionError,"MissingArgument",option);
3808 if (LocaleCompare("alpha",option+1) == 0)
3816 if (i == (ssize_t) argc)
3817 ThrowMogrifyException(OptionError,"MissingArgument",option);
3818 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3820 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3824 if (LocaleCompare("annotate",option+1) == 0)
3829 if (i == (ssize_t) argc)
3830 ThrowMogrifyException(OptionError,"MissingArgument",option);
3831 if (IsGeometry(argv[i]) == MagickFalse)
3832 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3833 if (i == (ssize_t) argc)
3834 ThrowMogrifyException(OptionError,"MissingArgument",option);
3838 if (LocaleCompare("antialias",option+1) == 0)
3840 if (LocaleCompare("append",option+1) == 0)
3842 if (LocaleCompare("attenuate",option+1) == 0)
3847 if (i == (ssize_t) (argc-1))
3848 ThrowMogrifyException(OptionError,"MissingArgument",option);
3849 if (IsGeometry(argv[i]) == MagickFalse)
3850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3853 if (LocaleCompare("authenticate",option+1) == 0)
3858 if (i == (ssize_t) argc)
3859 ThrowMogrifyException(OptionError,"MissingArgument",option);
3862 if (LocaleCompare("auto-gamma",option+1) == 0)
3864 if (LocaleCompare("auto-level",option+1) == 0)
3866 if (LocaleCompare("auto-orient",option+1) == 0)
3868 if (LocaleCompare("average",option+1) == 0)
3870 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3874 if (LocaleCompare("background",option+1) == 0)
3879 if (i == (ssize_t) argc)
3880 ThrowMogrifyException(OptionError,"MissingArgument",option);
3883 if (LocaleCompare("bias",option+1) == 0)
3888 if (i == (ssize_t) (argc-1))
3889 ThrowMogrifyException(OptionError,"MissingArgument",option);
3890 if (IsGeometry(argv[i]) == MagickFalse)
3891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3894 if (LocaleCompare("black-point-compensation",option+1) == 0)
3896 if (LocaleCompare("black-threshold",option+1) == 0)
3901 if (i == (ssize_t) argc)
3902 ThrowMogrifyException(OptionError,"MissingArgument",option);
3903 if (IsGeometry(argv[i]) == MagickFalse)
3904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3907 if (LocaleCompare("blue-primary",option+1) == 0)
3912 if (i == (ssize_t) argc)
3913 ThrowMogrifyException(OptionError,"MissingArgument",option);
3914 if (IsGeometry(argv[i]) == MagickFalse)
3915 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3918 if (LocaleCompare("blue-shift",option+1) == 0)
3921 if (i == (ssize_t) argc)
3922 ThrowMogrifyException(OptionError,"MissingArgument",option);
3923 if (IsGeometry(argv[i]) == MagickFalse)
3924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3927 if (LocaleCompare("blur",option+1) == 0)
3930 if (i == (ssize_t) argc)
3931 ThrowMogrifyException(OptionError,"MissingArgument",option);
3932 if (IsGeometry(argv[i]) == MagickFalse)
3933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3936 if (LocaleCompare("border",option+1) == 0)
3941 if (i == (ssize_t) argc)
3942 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (IsGeometry(argv[i]) == MagickFalse)
3944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3947 if (LocaleCompare("bordercolor",option+1) == 0)
3952 if (i == (ssize_t) argc)
3953 ThrowMogrifyException(OptionError,"MissingArgument",option);
3956 if (LocaleCompare("box",option+1) == 0)
3961 if (i == (ssize_t) argc)
3962 ThrowMogrifyException(OptionError,"MissingArgument",option);
3965 if (LocaleCompare("brightness-contrast",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3978 if (LocaleCompare("cache",option+1) == 0)
3983 if (i == (ssize_t) argc)
3984 ThrowMogrifyException(OptionError,"MissingArgument",option);
3985 if (IsGeometry(argv[i]) == MagickFalse)
3986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3989 if (LocaleCompare("caption",option+1) == 0)
3994 if (i == (ssize_t) argc)
3995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3998 if (LocaleCompare("channel",option+1) == 0)
4006 if (i == (ssize_t) (argc-1))
4007 ThrowMogrifyException(OptionError,"MissingArgument",option);
4008 channel=ParseChannelOption(argv[i]);
4010 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4014 if (LocaleCompare("cdl",option+1) == 0)
4019 if (i == (ssize_t) (argc-1))
4020 ThrowMogrifyException(OptionError,"MissingArgument",option);
4023 if (LocaleCompare("charcoal",option+1) == 0)
4028 if (i == (ssize_t) argc)
4029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 if (IsGeometry(argv[i]) == MagickFalse)
4031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4034 if (LocaleCompare("chop",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4041 if (IsGeometry(argv[i]) == MagickFalse)
4042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4045 if (LocaleCompare("clamp",option+1) == 0)
4047 if (LocaleCompare("clip",option+1) == 0)
4049 if (LocaleCompare("clip-mask",option+1) == 0)
4054 if (i == (ssize_t) argc)
4055 ThrowMogrifyException(OptionError,"MissingArgument",option);
4058 if (LocaleCompare("clut",option+1) == 0)
4060 if (LocaleCompare("coalesce",option+1) == 0)
4062 if (LocaleCompare("colorize",option+1) == 0)
4067 if (i == (ssize_t) argc)
4068 ThrowMogrifyException(OptionError,"MissingArgument",option);
4069 if (IsGeometry(argv[i]) == MagickFalse)
4070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4073 if (LocaleCompare("color-matrix",option+1) == 0)
4081 if (i == (ssize_t) (argc-1))
4082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4083 kernel_info=AcquireKernelInfo(argv[i]);
4084 if (kernel_info == (KernelInfo *) NULL)
4085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4086 kernel_info=DestroyKernelInfo(kernel_info);
4089 if (LocaleCompare("colors",option+1) == 0)
4094 if (i == (ssize_t) argc)
4095 ThrowMogrifyException(OptionError,"MissingArgument",option);
4096 if (IsGeometry(argv[i]) == MagickFalse)
4097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4100 if (LocaleCompare("colorspace",option+1) == 0)
4108 if (i == (ssize_t) argc)
4109 ThrowMogrifyException(OptionError,"MissingArgument",option);
4110 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4113 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4117 if (LocaleCompare("combine",option+1) == 0)
4119 if (LocaleCompare("comment",option+1) == 0)
4124 if (i == (ssize_t) argc)
4125 ThrowMogrifyException(OptionError,"MissingArgument",option);
4128 if (LocaleCompare("composite",option+1) == 0)
4130 if (LocaleCompare("compress",option+1) == 0)
4138 if (i == (ssize_t) argc)
4139 ThrowMogrifyException(OptionError,"MissingArgument",option);
4140 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4143 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4147 if (LocaleCompare("concurrent",option+1) == 0)
4149 if (LocaleCompare("contrast",option+1) == 0)
4151 if (LocaleCompare("contrast-stretch",option+1) == 0)
4154 if (i == (ssize_t) argc)
4155 ThrowMogrifyException(OptionError,"MissingArgument",option);
4156 if (IsGeometry(argv[i]) == MagickFalse)
4157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4160 if (LocaleCompare("convolve",option+1) == 0)
4168 if (i == (ssize_t) argc)
4169 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 kernel_info=AcquireKernelInfo(argv[i]);
4171 if (kernel_info == (KernelInfo *) NULL)
4172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4173 kernel_info=DestroyKernelInfo(kernel_info);
4176 if (LocaleCompare("crop",option+1) == 0)
4181 if (i == (ssize_t) argc)
4182 ThrowMogrifyException(OptionError,"MissingArgument",option);
4183 if (IsGeometry(argv[i]) == MagickFalse)
4184 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4187 if (LocaleCompare("cycle",option+1) == 0)
4192 if (i == (ssize_t) argc)
4193 ThrowMogrifyException(OptionError,"MissingArgument",option);
4194 if (IsGeometry(argv[i]) == MagickFalse)
4195 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4198 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4202 if (LocaleCompare("decipher",option+1) == 0)
4207 if (i == (ssize_t) (argc-1))
4208 ThrowMogrifyException(OptionError,"MissingArgument",option);
4211 if (LocaleCompare("deconstruct",option+1) == 0)
4213 if (LocaleCompare("debug",option+1) == 0)
4221 if (i == (ssize_t) argc)
4222 ThrowMogrifyException(OptionError,"MissingArgument",option);
4223 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4225 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4227 (void) SetLogEventMask(argv[i]);
4230 if (LocaleCompare("define",option+1) == 0)
4233 if (i == (ssize_t) argc)
4234 ThrowMogrifyException(OptionError,"MissingArgument",option);
4240 define=GetImageOption(image_info,argv[i]);
4241 if (define == (const char *) NULL)
4242 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4247 if (LocaleCompare("delay",option+1) == 0)
4252 if (i == (ssize_t) argc)
4253 ThrowMogrifyException(OptionError,"MissingArgument",option);
4254 if (IsGeometry(argv[i]) == MagickFalse)
4255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4258 if (LocaleCompare("delete",option+1) == 0)
4263 if (i == (ssize_t) (argc-1))
4264 ThrowMogrifyException(OptionError,"MissingArgument",option);
4265 if (IsGeometry(argv[i]) == MagickFalse)
4266 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4269 if (LocaleCompare("density",option+1) == 0)
4274 if (i == (ssize_t) argc)
4275 ThrowMogrifyException(OptionError,"MissingArgument",option);
4276 if (IsGeometry(argv[i]) == MagickFalse)
4277 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4280 if (LocaleCompare("depth",option+1) == 0)
4285 if (i == (ssize_t) argc)
4286 ThrowMogrifyException(OptionError,"MissingArgument",option);
4287 if (IsGeometry(argv[i]) == MagickFalse)
4288 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4291 if (LocaleCompare("deskew",option+1) == 0)
4296 if (i == (ssize_t) argc)
4297 ThrowMogrifyException(OptionError,"MissingArgument",option);
4298 if (IsGeometry(argv[i]) == MagickFalse)
4299 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4302 if (LocaleCompare("despeckle",option+1) == 0)
4304 if (LocaleCompare("dft",option+1) == 0)
4306 if (LocaleCompare("direction",option+1) == 0)
4314 if (i == (ssize_t) argc)
4315 ThrowMogrifyException(OptionError,"MissingArgument",option);
4316 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4319 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4323 if (LocaleCompare("display",option+1) == 0)
4328 if (i == (ssize_t) argc)
4329 ThrowMogrifyException(OptionError,"MissingArgument",option);
4332 if (LocaleCompare("dispose",option+1) == 0)
4340 if (i == (ssize_t) argc)
4341 ThrowMogrifyException(OptionError,"MissingArgument",option);
4342 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4344 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4348 if (LocaleCompare("distort",option+1) == 0)
4354 if (i == (ssize_t) argc)
4355 ThrowMogrifyException(OptionError,"MissingArgument",option);
4356 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4358 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4361 if (i == (ssize_t) (argc-1))
4362 ThrowMogrifyException(OptionError,"MissingArgument",option);
4365 if (LocaleCompare("dither",option+1) == 0)
4373 if (i == (ssize_t) argc)
4374 ThrowMogrifyException(OptionError,"MissingArgument",option);
4375 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4377 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4381 if (LocaleCompare("draw",option+1) == 0)
4386 if (i == (ssize_t) argc)
4387 ThrowMogrifyException(OptionError,"MissingArgument",option);
4390 if (LocaleCompare("duplicate",option+1) == 0)
4395 if (i == (ssize_t) (argc-1))
4396 ThrowMogrifyException(OptionError,"MissingArgument",option);
4397 if (IsGeometry(argv[i]) == MagickFalse)
4398 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4401 if (LocaleCompare("duration",option+1) == 0)
4406 if (i == (ssize_t) (argc-1))
4407 ThrowMogrifyException(OptionError,"MissingArgument",option);
4408 if (IsGeometry(argv[i]) == MagickFalse)
4409 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4412 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4416 if (LocaleCompare("edge",option+1) == 0)
4421 if (i == (ssize_t) argc)
4422 ThrowMogrifyException(OptionError,"MissingArgument",option);
4423 if (IsGeometry(argv[i]) == MagickFalse)
4424 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4427 if (LocaleCompare("emboss",option+1) == 0)
4432 if (i == (ssize_t) argc)
4433 ThrowMogrifyException(OptionError,"MissingArgument",option);
4434 if (IsGeometry(argv[i]) == MagickFalse)
4435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4438 if (LocaleCompare("encipher",option+1) == 0)
4443 if (i == (ssize_t) argc)
4444 ThrowMogrifyException(OptionError,"MissingArgument",option);
4447 if (LocaleCompare("encoding",option+1) == 0)
4452 if (i == (ssize_t) argc)
4453 ThrowMogrifyException(OptionError,"MissingArgument",option);
4456 if (LocaleCompare("endian",option+1) == 0)
4464 if (i == (ssize_t) argc)
4465 ThrowMogrifyException(OptionError,"MissingArgument",option);
4466 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4468 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4472 if (LocaleCompare("enhance",option+1) == 0)
4474 if (LocaleCompare("equalize",option+1) == 0)
4476 if (LocaleCompare("evaluate",option+1) == 0)
4484 if (i == (ssize_t) argc)
4485 ThrowMogrifyException(OptionError,"MissingArgument",option);
4486 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4488 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4491 if (i == (ssize_t) (argc-1))
4492 ThrowMogrifyException(OptionError,"MissingArgument",option);
4493 if (IsGeometry(argv[i]) == MagickFalse)
4494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4497 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4505 if (i == (ssize_t) argc)
4506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4507 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4509 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4513 if (LocaleCompare("extent",option+1) == 0)
4518 if (i == (ssize_t) argc)
4519 ThrowMogrifyException(OptionError,"MissingArgument",option);
4520 if (IsGeometry(argv[i]) == MagickFalse)
4521 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4524 if (LocaleCompare("extract",option+1) == 0)
4529 if (i == (ssize_t) argc)
4530 ThrowMogrifyException(OptionError,"MissingArgument",option);
4531 if (IsGeometry(argv[i]) == MagickFalse)
4532 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4535 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4539 if (LocaleCompare("family",option+1) == 0)
4544 if (i == (ssize_t) (argc-1))
4545 ThrowMogrifyException(OptionError,"MissingArgument",option);
4548 if (LocaleCompare("fill",option+1) == 0)
4553 if (i == (ssize_t) argc)
4554 ThrowMogrifyException(OptionError,"MissingArgument",option);
4557 if (LocaleCompare("filter",option+1) == 0)
4565 if (i == (ssize_t) argc)
4566 ThrowMogrifyException(OptionError,"MissingArgument",option);
4567 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4569 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4573 if (LocaleCompare("flatten",option+1) == 0)
4575 if (LocaleCompare("flip",option+1) == 0)
4577 if (LocaleCompare("flop",option+1) == 0)
4579 if (LocaleCompare("floodfill",option+1) == 0)
4584 if (i == (ssize_t) argc)
4585 ThrowMogrifyException(OptionError,"MissingArgument",option);
4586 if (IsGeometry(argv[i]) == MagickFalse)
4587 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4589 if (i == (ssize_t) argc)
4590 ThrowMogrifyException(OptionError,"MissingArgument",option);
4593 if (LocaleCompare("font",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4602 if (LocaleCompare("format",option+1) == 0)
4604 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4605 (void) CloneString(&format,(char *) NULL);
4609 if (i == (ssize_t) argc)
4610 ThrowMogrifyException(OptionError,"MissingArgument",option);
4611 (void) CloneString(&format,argv[i]);
4612 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4613 (void) ConcatenateMagickString(image_info->filename,":",
4615 (void) SetImageInfo(image_info,0,exception);
4616 if (*image_info->magick == '\0')
4617 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4621 if (LocaleCompare("frame",option+1) == 0)
4626 if (i == (ssize_t) argc)
4627 ThrowMogrifyException(OptionError,"MissingArgument",option);
4628 if (IsGeometry(argv[i]) == MagickFalse)
4629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4632 if (LocaleCompare("function",option+1) == 0)
4640 if (i == (ssize_t) argc)
4641 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4644 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4646 if (i == (ssize_t) (argc-1))
4647 ThrowMogrifyException(OptionError,"MissingArgument",option);
4650 if (LocaleCompare("fuzz",option+1) == 0)
4655 if (i == (ssize_t) argc)
4656 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 if (IsGeometry(argv[i]) == MagickFalse)
4658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4661 if (LocaleCompare("fx",option+1) == 0)
4666 if (i == (ssize_t) (argc-1))
4667 ThrowMogrifyException(OptionError,"MissingArgument",option);
4670 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4674 if (LocaleCompare("gamma",option+1) == 0)
4677 if (i == (ssize_t) argc)
4678 ThrowMogrifyException(OptionError,"MissingArgument",option);
4679 if (IsGeometry(argv[i]) == MagickFalse)
4680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4683 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4684 (LocaleCompare("gaussian",option+1) == 0))
4687 if (i == (ssize_t) argc)
4688 ThrowMogrifyException(OptionError,"MissingArgument",option);
4689 if (IsGeometry(argv[i]) == MagickFalse)
4690 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4693 if (LocaleCompare("geometry",option+1) == 0)
4698 if (i == (ssize_t) argc)
4699 ThrowMogrifyException(OptionError,"MissingArgument",option);
4700 if (IsGeometry(argv[i]) == MagickFalse)
4701 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4704 if (LocaleCompare("gravity",option+1) == 0)
4712 if (i == (ssize_t) argc)
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4716 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4720 if (LocaleCompare("green-primary",option+1) == 0)
4725 if (i == (ssize_t) argc)
4726 ThrowMogrifyException(OptionError,"MissingArgument",option);
4727 if (IsGeometry(argv[i]) == MagickFalse)
4728 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4731 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4735 if (LocaleCompare("hald-clut",option+1) == 0)
4737 if ((LocaleCompare("help",option+1) == 0) ||
4738 (LocaleCompare("-help",option+1) == 0))
4739 return(MogrifyUsage());
4740 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4744 if (LocaleCompare("identify",option+1) == 0)
4746 if (LocaleCompare("idft",option+1) == 0)
4748 if (LocaleCompare("implode",option+1) == 0)
4753 if (i == (ssize_t) argc)
4754 ThrowMogrifyException(OptionError,"MissingArgument",option);
4755 if (IsGeometry(argv[i]) == MagickFalse)
4756 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4759 if (LocaleCompare("intent",option+1) == 0)
4767 if (i == (ssize_t) (argc-1))
4768 ThrowMogrifyException(OptionError,"MissingArgument",option);
4769 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4771 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4775 if (LocaleCompare("interlace",option+1) == 0)
4783 if (i == (ssize_t) argc)
4784 ThrowMogrifyException(OptionError,"MissingArgument",option);
4785 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4788 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4792 if (LocaleCompare("interline-spacing",option+1) == 0)
4797 if (i == (ssize_t) (argc-1))
4798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 if (IsGeometry(argv[i]) == MagickFalse)
4800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4803 if (LocaleCompare("interpolate",option+1) == 0)
4811 if (i == (ssize_t) argc)
4812 ThrowMogrifyException(OptionError,"MissingArgument",option);
4813 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4815 if (interpolate < 0)
4816 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4820 if (LocaleCompare("interword-spacing",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("kerning",option+1) == 0)
4840 if (i == (ssize_t) (argc-1))
4841 ThrowMogrifyException(OptionError,"MissingArgument",option);
4842 if (IsGeometry(argv[i]) == MagickFalse)
4843 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4846 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4850 if (LocaleCompare("label",option+1) == 0)
4855 if (i == (ssize_t) argc)
4856 ThrowMogrifyException(OptionError,"MissingArgument",option);
4859 if (LocaleCompare("lat",option+1) == 0)
4864 if (i == (ssize_t) argc)
4865 ThrowMogrifyException(OptionError,"MissingArgument",option);
4866 if (IsGeometry(argv[i]) == MagickFalse)
4867 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4869 if (LocaleCompare("layers",option+1) == 0)
4877 if (i == (ssize_t) (argc-1))
4878 ThrowMogrifyException(OptionError,"MissingArgument",option);
4879 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4881 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4885 if (LocaleCompare("level",option+1) == 0)
4888 if (i == (ssize_t) argc)
4889 ThrowMogrifyException(OptionError,"MissingArgument",option);
4890 if (IsGeometry(argv[i]) == MagickFalse)
4891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4894 if (LocaleCompare("level-colors",option+1) == 0)
4897 if (i == (ssize_t) argc)
4898 ThrowMogrifyException(OptionError,"MissingArgument",option);
4901 if (LocaleCompare("linewidth",option+1) == 0)
4906 if (i == (ssize_t) argc)
4907 ThrowMogrifyException(OptionError,"MissingArgument",option);
4908 if (IsGeometry(argv[i]) == MagickFalse)
4909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4912 if (LocaleCompare("limit",option+1) == 0)
4926 if (i == (ssize_t) argc)
4927 ThrowMogrifyException(OptionError,"MissingArgument",option);
4928 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4931 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4934 if (i == (ssize_t) argc)
4935 ThrowMogrifyException(OptionError,"MissingArgument",option);
4936 value=InterpretLocaleValue(argv[i],&p);
4938 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4942 if (LocaleCompare("liquid-rescale",option+1) == 0)
4945 if (i == (ssize_t) argc)
4946 ThrowMogrifyException(OptionError,"MissingArgument",option);
4947 if (IsGeometry(argv[i]) == MagickFalse)
4948 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4951 if (LocaleCompare("list",option+1) == 0)
4959 if (i == (ssize_t) argc)
4960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4961 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4963 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4964 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4966 return(status != 0 ? MagickFalse : MagickTrue);
4968 if (LocaleCompare("log",option+1) == 0)
4973 if ((i == (ssize_t) argc) ||
4974 (strchr(argv[i],'%') == (char *) NULL))
4975 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 if (LocaleCompare("loop",option+1) == 0)
4983 if (i == (ssize_t) argc)
4984 ThrowMogrifyException(OptionError,"MissingArgument",option);
4985 if (IsGeometry(argv[i]) == MagickFalse)
4986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4989 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4993 if (LocaleCompare("map",option+1) == 0)
4995 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4999 if (i == (ssize_t) argc)
5000 ThrowMogrifyException(OptionError,"MissingArgument",option);
5003 if (LocaleCompare("mask",option+1) == 0)
5008 if (i == (ssize_t) argc)
5009 ThrowMogrifyException(OptionError,"MissingArgument",option);
5012 if (LocaleCompare("matte",option+1) == 0)
5014 if (LocaleCompare("mattecolor",option+1) == 0)
5019 if (i == (ssize_t) argc)
5020 ThrowMogrifyException(OptionError,"MissingArgument",option);
5023 if (LocaleCompare("maximum",option+1) == 0)
5025 if (LocaleCompare("minimum",option+1) == 0)
5027 if (LocaleCompare("modulate",option+1) == 0)
5032 if (i == (ssize_t) argc)
5033 ThrowMogrifyException(OptionError,"MissingArgument",option);
5034 if (IsGeometry(argv[i]) == MagickFalse)
5035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5038 if (LocaleCompare("median",option+1) == 0)
5043 if (i == (ssize_t) argc)
5044 ThrowMogrifyException(OptionError,"MissingArgument",option);
5045 if (IsGeometry(argv[i]) == MagickFalse)
5046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5049 if (LocaleCompare("mode",option+1) == 0)
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 if (LocaleCompare("monitor",option+1) == 0)
5062 if (LocaleCompare("monochrome",option+1) == 0)
5064 if (LocaleCompare("morph",option+1) == 0)
5069 if (i == (ssize_t) (argc-1))
5070 ThrowMogrifyException(OptionError,"MissingArgument",option);
5071 if (IsGeometry(argv[i]) == MagickFalse)
5072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5075 if (LocaleCompare("morphology",option+1) == 0)
5078 token[MaxTextExtent];
5087 if (i == (ssize_t) argc)
5088 ThrowMogrifyException(OptionError,"MissingArgument",option);
5089 GetMagickToken(argv[i],NULL,token);
5090 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5092 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5095 if (i == (ssize_t) (argc-1))
5096 ThrowMogrifyException(OptionError,"MissingArgument",option);
5097 kernel_info=AcquireKernelInfo(argv[i]);
5098 if (kernel_info == (KernelInfo *) NULL)
5099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5100 kernel_info=DestroyKernelInfo(kernel_info);
5103 if (LocaleCompare("mosaic",option+1) == 0)
5105 if (LocaleCompare("motion-blur",option+1) == 0)
5110 if (i == (ssize_t) argc)
5111 ThrowMogrifyException(OptionError,"MissingArgument",option);
5112 if (IsGeometry(argv[i]) == MagickFalse)
5113 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5116 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5120 if (LocaleCompare("negate",option+1) == 0)
5122 if (LocaleCompare("noise",option+1) == 0)
5125 if (i == (ssize_t) argc)
5126 ThrowMogrifyException(OptionError,"MissingArgument",option);
5132 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5134 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5138 if (IsGeometry(argv[i]) == MagickFalse)
5139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5142 if (LocaleCompare("noop",option+1) == 0)
5144 if (LocaleCompare("normalize",option+1) == 0)
5146 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5150 if (LocaleCompare("opaque",option+1) == 0)
5153 if (i == (ssize_t) argc)
5154 ThrowMogrifyException(OptionError,"MissingArgument",option);
5157 if (LocaleCompare("ordered-dither",option+1) == 0)
5162 if (i == (ssize_t) argc)
5163 ThrowMogrifyException(OptionError,"MissingArgument",option);
5166 if (LocaleCompare("orient",option+1) == 0)
5171 orientation=UndefinedOrientation;
5175 if (i == (ssize_t) (argc-1))
5176 ThrowMogrifyException(OptionError,"MissingArgument",option);
5177 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5179 if (orientation < 0)
5180 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5184 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5188 if (LocaleCompare("page",option+1) == 0)
5193 if (i == (ssize_t) argc)
5194 ThrowMogrifyException(OptionError,"MissingArgument",option);
5197 if (LocaleCompare("paint",option+1) == 0)
5202 if (i == (ssize_t) argc)
5203 ThrowMogrifyException(OptionError,"MissingArgument",option);
5204 if (IsGeometry(argv[i]) == MagickFalse)
5205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5208 if (LocaleCompare("path",option+1) == 0)
5210 (void) CloneString(&path,(char *) NULL);
5214 if (i == (ssize_t) argc)
5215 ThrowMogrifyException(OptionError,"MissingArgument",option);
5216 (void) CloneString(&path,argv[i]);
5219 if (LocaleCompare("pointsize",option+1) == 0)
5224 if (i == (ssize_t) argc)
5225 ThrowMogrifyException(OptionError,"MissingArgument",option);
5226 if (IsGeometry(argv[i]) == MagickFalse)
5227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5230 if (LocaleCompare("polaroid",option+1) == 0)
5235 if (i == (ssize_t) argc)
5236 ThrowMogrifyException(OptionError,"MissingArgument",option);
5237 if (IsGeometry(argv[i]) == MagickFalse)
5238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5241 if (LocaleCompare("posterize",option+1) == 0)
5246 if (i == (ssize_t) argc)
5247 ThrowMogrifyException(OptionError,"MissingArgument",option);
5248 if (IsGeometry(argv[i]) == MagickFalse)
5249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5252 if (LocaleCompare("precision",option+1) == 0)
5257 if (i == (ssize_t) argc)
5258 ThrowMogrifyException(OptionError,"MissingArgument",option);
5259 if (IsGeometry(argv[i]) == MagickFalse)
5260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5263 if (LocaleCompare("print",option+1) == 0)
5268 if (i == (ssize_t) argc)
5269 ThrowMogrifyException(OptionError,"MissingArgument",option);
5272 if (LocaleCompare("process",option+1) == 0)
5277 if (i == (ssize_t) (argc-1))
5278 ThrowMogrifyException(OptionError,"MissingArgument",option);
5281 if (LocaleCompare("profile",option+1) == 0)
5284 if (i == (ssize_t) argc)
5285 ThrowMogrifyException(OptionError,"MissingArgument",option);
5288 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5292 if (LocaleCompare("quality",option+1) == 0)
5297 if (i == (ssize_t) argc)
5298 ThrowMogrifyException(OptionError,"MissingArgument",option);
5299 if (IsGeometry(argv[i]) == MagickFalse)
5300 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5303 if (LocaleCompare("quantize",option+1) == 0)
5311 if (i == (ssize_t) (argc-1))
5312 ThrowMogrifyException(OptionError,"MissingArgument",option);
5313 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5316 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5320 if (LocaleCompare("quiet",option+1) == 0)
5322 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5326 if (LocaleCompare("radial-blur",option+1) == 0)
5329 if (i == (ssize_t) argc)
5330 ThrowMogrifyException(OptionError,"MissingArgument",option);
5331 if (IsGeometry(argv[i]) == MagickFalse)
5332 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5335 if (LocaleCompare("raise",option+1) == 0)
5338 if (i == (ssize_t) argc)
5339 ThrowMogrifyException(OptionError,"MissingArgument",option);
5340 if (IsGeometry(argv[i]) == MagickFalse)
5341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5344 if (LocaleCompare("random-threshold",option+1) == 0)
5349 if (i == (ssize_t) argc)
5350 ThrowMogrifyException(OptionError,"MissingArgument",option);
5351 if (IsGeometry(argv[i]) == MagickFalse)
5352 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5355 if (LocaleCompare("recolor",option+1) == 0)
5360 if (i == (ssize_t) (argc-1))
5361 ThrowMogrifyException(OptionError,"MissingArgument",option);
5362 if (IsGeometry(argv[i]) == MagickFalse)
5363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5366 if (LocaleCompare("red-primary",option+1) == 0)
5371 if (i == (ssize_t) argc)
5372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5376 if (LocaleCompare("regard-warnings",option+1) == 0)
5378 if (LocaleCompare("region",option+1) == 0)
5383 if (i == (ssize_t) argc)
5384 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (IsGeometry(argv[i]) == MagickFalse)
5386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5389 if (LocaleCompare("remap",option+1) == 0)
5394 if (i == (ssize_t) (argc-1))
5395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5398 if (LocaleCompare("render",option+1) == 0)
5400 if (LocaleCompare("repage",option+1) == 0)
5405 if (i == (ssize_t) argc)
5406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 if (IsGeometry(argv[i]) == MagickFalse)
5408 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5411 if (LocaleCompare("resample",option+1) == 0)
5416 if (i == (ssize_t) argc)
5417 ThrowMogrifyException(OptionError,"MissingArgument",option);
5418 if (IsGeometry(argv[i]) == MagickFalse)
5419 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5422 if (LocaleCompare("resize",option+1) == 0)
5427 if (i == (ssize_t) argc)
5428 ThrowMogrifyException(OptionError,"MissingArgument",option);
5429 if (IsGeometry(argv[i]) == MagickFalse)
5430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5433 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5435 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5438 if (LocaleCompare("reverse",option+1) == 0)
5440 if (LocaleCompare("roll",option+1) == 0)
5445 if (i == (ssize_t) argc)
5446 ThrowMogrifyException(OptionError,"MissingArgument",option);
5447 if (IsGeometry(argv[i]) == MagickFalse)
5448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5451 if (LocaleCompare("rotate",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5464 if (LocaleCompare("sample",option+1) == 0)
5469 if (i == (ssize_t) argc)
5470 ThrowMogrifyException(OptionError,"MissingArgument",option);
5471 if (IsGeometry(argv[i]) == MagickFalse)
5472 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5475 if (LocaleCompare("sampling-factor",option+1) == 0)
5480 if (i == (ssize_t) argc)
5481 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (IsGeometry(argv[i]) == MagickFalse)
5483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5486 if (LocaleCompare("scale",option+1) == 0)
5491 if (i == (ssize_t) argc)
5492 ThrowMogrifyException(OptionError,"MissingArgument",option);
5493 if (IsGeometry(argv[i]) == MagickFalse)
5494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5497 if (LocaleCompare("scene",option+1) == 0)
5502 if (i == (ssize_t) argc)
5503 ThrowMogrifyException(OptionError,"MissingArgument",option);
5504 if (IsGeometry(argv[i]) == MagickFalse)
5505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5508 if (LocaleCompare("seed",option+1) == 0)
5513 if (i == (ssize_t) argc)
5514 ThrowMogrifyException(OptionError,"MissingArgument",option);
5515 if (IsGeometry(argv[i]) == MagickFalse)
5516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5519 if (LocaleCompare("segment",option+1) == 0)
5524 if (i == (ssize_t) argc)
5525 ThrowMogrifyException(OptionError,"MissingArgument",option);
5526 if (IsGeometry(argv[i]) == MagickFalse)
5527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5530 if (LocaleCompare("selective-blur",option+1) == 0)
5533 if (i == (ssize_t) argc)
5534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5539 if (LocaleCompare("separate",option+1) == 0)
5541 if (LocaleCompare("sepia-tone",option+1) == 0)
5546 if (i == (ssize_t) argc)
5547 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 if (IsGeometry(argv[i]) == MagickFalse)
5549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5552 if (LocaleCompare("set",option+1) == 0)
5555 if (i == (ssize_t) argc)
5556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5560 if (i == (ssize_t) argc)
5561 ThrowMogrifyException(OptionError,"MissingArgument",option);
5564 if (LocaleCompare("shade",option+1) == 0)
5567 if (i == (ssize_t) argc)
5568 ThrowMogrifyException(OptionError,"MissingArgument",option);
5569 if (IsGeometry(argv[i]) == MagickFalse)
5570 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5573 if (LocaleCompare("shadow",option+1) == 0)
5578 if (i == (ssize_t) argc)
5579 ThrowMogrifyException(OptionError,"MissingArgument",option);
5580 if (IsGeometry(argv[i]) == MagickFalse)
5581 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5584 if (LocaleCompare("sharpen",option+1) == 0)
5587 if (i == (ssize_t) argc)
5588 ThrowMogrifyException(OptionError,"MissingArgument",option);
5589 if (IsGeometry(argv[i]) == MagickFalse)
5590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5593 if (LocaleCompare("shave",option+1) == 0)
5598 if (i == (ssize_t) argc)
5599 ThrowMogrifyException(OptionError,"MissingArgument",option);
5600 if (IsGeometry(argv[i]) == MagickFalse)
5601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5604 if (LocaleCompare("shear",option+1) == 0)
5607 if (i == (ssize_t) argc)
5608 ThrowMogrifyException(OptionError,"MissingArgument",option);
5609 if (IsGeometry(argv[i]) == MagickFalse)
5610 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5613 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5616 if (i == (ssize_t) (argc-1))
5617 ThrowMogrifyException(OptionError,"MissingArgument",option);
5618 if (IsGeometry(argv[i]) == MagickFalse)
5619 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5622 if (LocaleCompare("size",option+1) == 0)
5627 if (i == (ssize_t) argc)
5628 ThrowMogrifyException(OptionError,"MissingArgument",option);
5629 if (IsGeometry(argv[i]) == MagickFalse)
5630 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5633 if (LocaleCompare("sketch",option+1) == 0)
5638 if (i == (ssize_t) argc)
5639 ThrowMogrifyException(OptionError,"MissingArgument",option);
5640 if (IsGeometry(argv[i]) == MagickFalse)
5641 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644 if (LocaleCompare("smush",option+1) == 0)
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5654 if (LocaleCompare("solarize",option+1) == 0)
5659 if (i == (ssize_t) argc)
5660 ThrowMogrifyException(OptionError,"MissingArgument",option);
5661 if (IsGeometry(argv[i]) == MagickFalse)
5662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5665 if (LocaleCompare("sparse-color",option+1) == 0)
5671 if (i == (ssize_t) argc)
5672 ThrowMogrifyException(OptionError,"MissingArgument",option);
5673 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5675 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5678 if (i == (ssize_t) (argc-1))
5679 ThrowMogrifyException(OptionError,"MissingArgument",option);
5682 if (LocaleCompare("spread",option+1) == 0)
5687 if (i == (ssize_t) argc)
5688 ThrowMogrifyException(OptionError,"MissingArgument",option);
5689 if (IsGeometry(argv[i]) == MagickFalse)
5690 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5693 if (LocaleCompare("statistic",option+1) == 0)
5701 if (i == (ssize_t) argc)
5702 ThrowMogrifyException(OptionError,"MissingArgument",option);
5703 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5705 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5708 if (i == (ssize_t) (argc-1))
5709 ThrowMogrifyException(OptionError,"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5714 if (LocaleCompare("stretch",option+1) == 0)
5722 if (i == (ssize_t) (argc-1))
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5724 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5726 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5730 if (LocaleCompare("strip",option+1) == 0)
5732 if (LocaleCompare("stroke",option+1) == 0)
5737 if (i == (ssize_t) argc)
5738 ThrowMogrifyException(OptionError,"MissingArgument",option);
5741 if (LocaleCompare("strokewidth",option+1) == 0)
5746 if (i == (ssize_t) argc)
5747 ThrowMogrifyException(OptionError,"MissingArgument",option);
5748 if (IsGeometry(argv[i]) == MagickFalse)
5749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5752 if (LocaleCompare("style",option+1) == 0)
5760 if (i == (ssize_t) (argc-1))
5761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5764 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5768 if (LocaleCompare("swap",option+1) == 0)
5773 if (i == (ssize_t) (argc-1))
5774 ThrowMogrifyException(OptionError,"MissingArgument",option);
5775 if (IsGeometry(argv[i]) == MagickFalse)
5776 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5779 if (LocaleCompare("swirl",option+1) == 0)
5784 if (i == (ssize_t) argc)
5785 ThrowMogrifyException(OptionError,"MissingArgument",option);
5786 if (IsGeometry(argv[i]) == MagickFalse)
5787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5790 if (LocaleCompare("synchronize",option+1) == 0)
5792 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5796 if (LocaleCompare("taint",option+1) == 0)
5798 if (LocaleCompare("texture",option+1) == 0)
5803 if (i == (ssize_t) argc)
5804 ThrowMogrifyException(OptionError,"MissingArgument",option);
5807 if (LocaleCompare("tile",option+1) == 0)
5812 if (i == (ssize_t) (argc-1))
5813 ThrowMogrifyException(OptionError,"MissingArgument",option);
5816 if (LocaleCompare("tile-offset",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5827 if (LocaleCompare("tint",option+1) == 0)
5832 if (i == (ssize_t) (argc-1))
5833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 if (IsGeometry(argv[i]) == MagickFalse)
5835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5838 if (LocaleCompare("transform",option+1) == 0)
5840 if (LocaleCompare("transpose",option+1) == 0)
5842 if (LocaleCompare("transverse",option+1) == 0)
5844 if (LocaleCompare("threshold",option+1) == 0)
5849 if (i == (ssize_t) argc)
5850 ThrowMogrifyException(OptionError,"MissingArgument",option);
5851 if (IsGeometry(argv[i]) == MagickFalse)
5852 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5855 if (LocaleCompare("thumbnail",option+1) == 0)
5860 if (i == (ssize_t) argc)
5861 ThrowMogrifyException(OptionError,"MissingArgument",option);
5862 if (IsGeometry(argv[i]) == MagickFalse)
5863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5866 if (LocaleCompare("transparent",option+1) == 0)
5869 if (i == (ssize_t) argc)
5870 ThrowMogrifyException(OptionError,"MissingArgument",option);
5873 if (LocaleCompare("transparent-color",option+1) == 0)
5878 if (i == (ssize_t) (argc-1))
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5882 if (LocaleCompare("treedepth",option+1) == 0)
5887 if (i == (ssize_t) argc)
5888 ThrowMogrifyException(OptionError,"MissingArgument",option);
5889 if (IsGeometry(argv[i]) == MagickFalse)
5890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5893 if (LocaleCompare("trim",option+1) == 0)
5895 if (LocaleCompare("type",option+1) == 0)
5903 if (i == (ssize_t) argc)
5904 ThrowMogrifyException(OptionError,"MissingArgument",option);
5905 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5907 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5911 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5915 if (LocaleCompare("undercolor",option+1) == 0)
5920 if (i == (ssize_t) argc)
5921 ThrowMogrifyException(OptionError,"MissingArgument",option);
5924 if (LocaleCompare("unique-colors",option+1) == 0)
5926 if (LocaleCompare("units",option+1) == 0)
5934 if (i == (ssize_t) argc)
5935 ThrowMogrifyException(OptionError,"MissingArgument",option);
5936 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5939 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5943 if (LocaleCompare("unsharp",option+1) == 0)
5946 if (i == (ssize_t) argc)
5947 ThrowMogrifyException(OptionError,"MissingArgument",option);
5948 if (IsGeometry(argv[i]) == MagickFalse)
5949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5952 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5956 if (LocaleCompare("verbose",option+1) == 0)
5958 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5961 if ((LocaleCompare("version",option+1) == 0) ||
5962 (LocaleCompare("-version",option+1) == 0))
5964 (void) FormatLocaleFile(stdout,"Version: %s\n",
5965 GetMagickVersion((size_t *) NULL));
5966 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5967 GetMagickCopyright());
5968 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5969 GetMagickFeatures());
5972 if (LocaleCompare("view",option+1) == 0)
5977 if (i == (ssize_t) argc)
5978 ThrowMogrifyException(OptionError,"MissingArgument",option);
5981 if (LocaleCompare("vignette",option+1) == 0)
5986 if (i == (ssize_t) argc)
5987 ThrowMogrifyException(OptionError,"MissingArgument",option);
5988 if (IsGeometry(argv[i]) == MagickFalse)
5989 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5992 if (LocaleCompare("virtual-pixel",option+1) == 0)
6000 if (i == (ssize_t) argc)
6001 ThrowMogrifyException(OptionError,"MissingArgument",option);
6002 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6005 ThrowMogrifyException(OptionError,
6006 "UnrecognizedVirtualPixelMethod",argv[i]);
6009 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6013 if (LocaleCompare("wave",option+1) == 0)
6016 if (i == (ssize_t) argc)
6017 ThrowMogrifyException(OptionError,"MissingArgument",option);
6018 if (IsGeometry(argv[i]) == MagickFalse)
6019 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6022 if (LocaleCompare("weight",option+1) == 0)
6027 if (i == (ssize_t) (argc-1))
6028 ThrowMogrifyException(OptionError,"MissingArgument",option);
6031 if (LocaleCompare("white-point",option+1) == 0)
6036 if (i == (ssize_t) argc)
6037 ThrowMogrifyException(OptionError,"MissingArgument",option);
6038 if (IsGeometry(argv[i]) == MagickFalse)
6039 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6042 if (LocaleCompare("white-threshold",option+1) == 0)
6047 if (i == (ssize_t) argc)
6048 ThrowMogrifyException(OptionError,"MissingArgument",option);
6049 if (IsGeometry(argv[i]) == MagickFalse)
6050 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 if (LocaleCompare("write",option+1) == 0)
6056 if (i == (ssize_t) (argc-1))
6057 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6065 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6067 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6068 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6069 if (fire != MagickFalse)
6070 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6073 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6074 if (i != (ssize_t) argc)
6075 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6077 return(status != 0 ? MagickTrue : MagickFalse);
6081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6085 + M o g r i f y I m a g e I n f o %
6089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6091 % MogrifyImageInfo() applies image processing settings to the image as
6092 % prescribed by command line options.
6094 % The format of the MogrifyImageInfo method is:
6096 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6097 % const char **argv,ExceptionInfo *exception)
6099 % A description of each parameter follows:
6101 % o image_info: the image info..
6103 % o argc: Specifies a pointer to an integer describing the number of
6104 % elements in the argument vector.
6106 % o argv: Specifies a pointer to a text array containing the command line
6109 % o exception: return any errors or warnings in this structure.
6112 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6113 const int argc,const char **argv,ExceptionInfo *exception)
6128 Initialize method variables.
6130 assert(image_info != (ImageInfo *) NULL);
6131 assert(image_info->signature == MagickSignature);
6132 if (image_info->debug != MagickFalse)
6133 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6134 image_info->filename);
6138 Set the image settings.
6140 for (i=0; i < (ssize_t) argc; i++)
6143 if (IsCommandOption(option) == MagickFalse)
6145 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6146 count=MagickMax(count,0L);
6147 if ((i+count) >= (ssize_t) argc)
6149 switch (*(option+1))
6153 if (LocaleCompare("adjoin",option+1) == 0)
6155 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6158 if (LocaleCompare("antialias",option+1) == 0)
6160 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6163 if (LocaleCompare("attenuate",option+1) == 0)
6167 (void) DeleteImageOption(image_info,option+1);
6170 (void) SetImageOption(image_info,option+1,argv[i+1]);
6173 if (LocaleCompare("authenticate",option+1) == 0)
6176 (void) CloneString(&image_info->authenticate,(char *) NULL);
6178 (void) CloneString(&image_info->authenticate,argv[i+1]);
6185 if (LocaleCompare("background",option+1) == 0)
6189 (void) DeleteImageOption(image_info,option+1);
6190 (void) QueryColorCompliance(MogrifyBackgroundColor,
6191 AllCompliance,&image_info->background_color,exception);
6194 (void) SetImageOption(image_info,option+1,argv[i+1]);
6195 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6196 &image_info->background_color,exception);
6199 if (LocaleCompare("bias",option+1) == 0)
6203 (void) SetImageOption(image_info,option+1,"0.0");
6206 (void) SetImageOption(image_info,option+1,argv[i+1]);
6209 if (LocaleCompare("black-point-compensation",option+1) == 0)
6213 (void) SetImageOption(image_info,option+1,"false");
6216 (void) SetImageOption(image_info,option+1,"true");
6219 if (LocaleCompare("blue-primary",option+1) == 0)
6223 (void) SetImageOption(image_info,option+1,"0.0");
6226 (void) SetImageOption(image_info,option+1,argv[i+1]);
6229 if (LocaleCompare("bordercolor",option+1) == 0)
6233 (void) DeleteImageOption(image_info,option+1);
6234 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6235 &image_info->border_color,exception);
6238 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6239 &image_info->border_color,exception);
6240 (void) SetImageOption(image_info,option+1,argv[i+1]);
6243 if (LocaleCompare("box",option+1) == 0)
6247 (void) SetImageOption(image_info,"undercolor","none");
6250 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6257 if (LocaleCompare("cache",option+1) == 0)
6262 limit=MagickResourceInfinity;
6263 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6264 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6265 (void) SetMagickResourceLimit(MemoryResource,limit);
6266 (void) SetMagickResourceLimit(MapResource,2*limit);
6269 if (LocaleCompare("caption",option+1) == 0)
6273 (void) DeleteImageOption(image_info,option+1);
6276 (void) SetImageOption(image_info,option+1,argv[i+1]);
6279 if (LocaleCompare("channel",option+1) == 0)
6283 image_info->channel=DefaultChannels;
6286 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6289 if (LocaleCompare("colors",option+1) == 0)
6291 image_info->colors=StringToUnsignedLong(argv[i+1]);
6294 if (LocaleCompare("colorspace",option+1) == 0)
6298 image_info->colorspace=UndefinedColorspace;
6299 (void) SetImageOption(image_info,option+1,"undefined");
6302 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6303 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6304 (void) SetImageOption(image_info,option+1,argv[i+1]);
6307 if (LocaleCompare("comment",option+1) == 0)
6311 (void) DeleteImageOption(image_info,option+1);
6314 (void) SetImageOption(image_info,option+1,argv[i+1]);
6317 if (LocaleCompare("compose",option+1) == 0)
6321 (void) SetImageOption(image_info,option+1,"undefined");
6324 (void) SetImageOption(image_info,option+1,argv[i+1]);
6327 if (LocaleCompare("compress",option+1) == 0)
6331 image_info->compression=UndefinedCompression;
6332 (void) SetImageOption(image_info,option+1,"undefined");
6335 image_info->compression=(CompressionType) ParseCommandOption(
6336 MagickCompressOptions,MagickFalse,argv[i+1]);
6337 (void) SetImageOption(image_info,option+1,argv[i+1]);
6344 if (LocaleCompare("debug",option+1) == 0)
6347 (void) SetLogEventMask("none");
6349 (void) SetLogEventMask(argv[i+1]);
6350 image_info->debug=IsEventLogging();
6353 if (LocaleCompare("define",option+1) == 0)
6357 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6358 (void) DeleteImageRegistry(argv[i+1]+9);
6360 (void) DeleteImageOption(image_info,argv[i+1]);
6363 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6365 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6369 (void) DefineImageOption(image_info,argv[i+1]);
6372 if (LocaleCompare("delay",option+1) == 0)
6376 (void) SetImageOption(image_info,option+1,"0");
6379 (void) SetImageOption(image_info,option+1,argv[i+1]);
6382 if (LocaleCompare("density",option+1) == 0)
6389 if (image_info->density != (char *) NULL)
6390 image_info->density=DestroyString(image_info->density);
6391 (void) SetImageOption(image_info,option+1,"72");
6394 (void) CloneString(&image_info->density,argv[i+1]);
6395 (void) SetImageOption(image_info,option+1,argv[i+1]);
6398 if (LocaleCompare("depth",option+1) == 0)
6402 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6405 image_info->depth=StringToUnsignedLong(argv[i+1]);
6408 if (LocaleCompare("direction",option+1) == 0)
6412 (void) SetImageOption(image_info,option+1,"undefined");
6415 (void) SetImageOption(image_info,option+1,argv[i+1]);
6418 if (LocaleCompare("display",option+1) == 0)
6422 if (image_info->server_name != (char *) NULL)
6423 image_info->server_name=DestroyString(
6424 image_info->server_name);
6427 (void) CloneString(&image_info->server_name,argv[i+1]);
6430 if (LocaleCompare("dispose",option+1) == 0)
6434 (void) SetImageOption(image_info,option+1,"undefined");
6437 (void) SetImageOption(image_info,option+1,argv[i+1]);
6440 if (LocaleCompare("dither",option+1) == 0)
6444 image_info->dither=MagickFalse;
6445 (void) SetImageOption(image_info,option+1,"none");
6448 (void) SetImageOption(image_info,option+1,argv[i+1]);
6449 image_info->dither=MagickTrue;
6456 if (LocaleCompare("encoding",option+1) == 0)
6460 (void) SetImageOption(image_info,option+1,"undefined");
6463 (void) SetImageOption(image_info,option+1,argv[i+1]);
6466 if (LocaleCompare("endian",option+1) == 0)
6470 image_info->endian=UndefinedEndian;
6471 (void) SetImageOption(image_info,option+1,"undefined");
6474 image_info->endian=(EndianType) ParseCommandOption(
6475 MagickEndianOptions,MagickFalse,argv[i+1]);
6476 (void) SetImageOption(image_info,option+1,argv[i+1]);
6479 if (LocaleCompare("extract",option+1) == 0)
6482 Set image extract geometry.
6486 if (image_info->extract != (char *) NULL)
6487 image_info->extract=DestroyString(image_info->extract);
6490 (void) CloneString(&image_info->extract,argv[i+1]);
6497 if (LocaleCompare("fill",option+1) == 0)
6501 (void) SetImageOption(image_info,option+1,"none");
6504 (void) SetImageOption(image_info,option+1,argv[i+1]);
6507 if (LocaleCompare("filter",option+1) == 0)
6511 (void) SetImageOption(image_info,option+1,"undefined");
6514 (void) SetImageOption(image_info,option+1,argv[i+1]);
6517 if (LocaleCompare("font",option+1) == 0)
6521 if (image_info->font != (char *) NULL)
6522 image_info->font=DestroyString(image_info->font);
6525 (void) CloneString(&image_info->font,argv[i+1]);
6528 if (LocaleCompare("format",option+1) == 0)
6533 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6534 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6535 image_info->ping=MagickFalse;
6536 (void) SetImageOption(image_info,option+1,argv[i+1]);
6539 if (LocaleCompare("fuzz",option+1) == 0)
6543 image_info->fuzz=0.0;
6544 (void) SetImageOption(image_info,option+1,"0");
6547 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6549 (void) SetImageOption(image_info,option+1,argv[i+1]);
6556 if (LocaleCompare("gravity",option+1) == 0)
6560 (void) SetImageOption(image_info,option+1,"undefined");
6563 (void) SetImageOption(image_info,option+1,argv[i+1]);
6566 if (LocaleCompare("green-primary",option+1) == 0)
6570 (void) SetImageOption(image_info,option+1,"0.0");
6573 (void) SetImageOption(image_info,option+1,argv[i+1]);
6580 if (LocaleCompare("intent",option+1) == 0)
6584 (void) SetImageOption(image_info,option+1,"undefined");
6587 (void) SetImageOption(image_info,option+1,argv[i+1]);
6590 if (LocaleCompare("interlace",option+1) == 0)
6594 image_info->interlace=UndefinedInterlace;
6595 (void) SetImageOption(image_info,option+1,"undefined");
6598 image_info->interlace=(InterlaceType) ParseCommandOption(
6599 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6600 (void) SetImageOption(image_info,option+1,argv[i+1]);
6603 if (LocaleCompare("interline-spacing",option+1) == 0)
6607 (void) SetImageOption(image_info,option+1,"undefined");
6610 (void) SetImageOption(image_info,option+1,argv[i+1]);
6613 if (LocaleCompare("interpolate",option+1) == 0)
6617 (void) SetImageOption(image_info,option+1,"undefined");
6620 (void) SetImageOption(image_info,option+1,argv[i+1]);
6623 if (LocaleCompare("interword-spacing",option+1) == 0)
6627 (void) SetImageOption(image_info,option+1,"undefined");
6630 (void) SetImageOption(image_info,option+1,argv[i+1]);
6637 if (LocaleCompare("kerning",option+1) == 0)
6641 (void) SetImageOption(image_info,option+1,"undefined");
6644 (void) SetImageOption(image_info,option+1,argv[i+1]);
6651 if (LocaleCompare("label",option+1) == 0)
6655 (void) DeleteImageOption(image_info,option+1);
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6661 if (LocaleCompare("limit",option+1) == 0)
6671 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6672 MagickFalse,argv[i+1]);
6673 limit=MagickResourceInfinity;
6674 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6675 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6676 (void) SetMagickResourceLimit(type,limit);
6679 if (LocaleCompare("list",option+1) == 0)
6685 Display configuration list.
6687 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6690 case MagickCoderOptions:
6692 (void) ListCoderInfo((FILE *) NULL,exception);
6695 case MagickColorOptions:
6697 (void) ListColorInfo((FILE *) NULL,exception);
6700 case MagickConfigureOptions:
6702 (void) ListConfigureInfo((FILE *) NULL,exception);
6705 case MagickDelegateOptions:
6707 (void) ListDelegateInfo((FILE *) NULL,exception);
6710 case MagickFontOptions:
6712 (void) ListTypeInfo((FILE *) NULL,exception);
6715 case MagickFormatOptions:
6717 (void) ListMagickInfo((FILE *) NULL,exception);
6720 case MagickLocaleOptions:
6722 (void) ListLocaleInfo((FILE *) NULL,exception);
6725 case MagickLogOptions:
6727 (void) ListLogInfo((FILE *) NULL,exception);
6730 case MagickMagicOptions:
6732 (void) ListMagicInfo((FILE *) NULL,exception);
6735 case MagickMimeOptions:
6737 (void) ListMimeInfo((FILE *) NULL,exception);
6740 case MagickModuleOptions:
6742 (void) ListModuleInfo((FILE *) NULL,exception);
6745 case MagickPolicyOptions:
6747 (void) ListPolicyInfo((FILE *) NULL,exception);
6750 case MagickResourceOptions:
6752 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6755 case MagickThresholdOptions:
6757 (void) ListThresholdMaps((FILE *) NULL,exception);
6762 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6769 if (LocaleCompare("log",option+1) == 0)
6773 (void) SetLogFormat(argv[i+1]);
6776 if (LocaleCompare("loop",option+1) == 0)
6780 (void) SetImageOption(image_info,option+1,"0");
6783 (void) SetImageOption(image_info,option+1,argv[i+1]);
6790 if (LocaleCompare("matte",option+1) == 0)
6794 (void) SetImageOption(image_info,option+1,"false");
6797 (void) SetImageOption(image_info,option+1,"true");
6800 if (LocaleCompare("mattecolor",option+1) == 0)
6804 (void) SetImageOption(image_info,option+1,argv[i+1]);
6805 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6806 &image_info->matte_color,exception);
6809 (void) SetImageOption(image_info,option+1,argv[i+1]);
6810 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6811 &image_info->matte_color,exception);
6814 if (LocaleCompare("monitor",option+1) == 0)
6816 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6820 if (LocaleCompare("monochrome",option+1) == 0)
6822 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6829 if (LocaleCompare("orient",option+1) == 0)
6833 image_info->orientation=UndefinedOrientation;
6834 (void) SetImageOption(image_info,option+1,"undefined");
6837 image_info->orientation=(OrientationType) ParseCommandOption(
6838 MagickOrientationOptions,MagickFalse,argv[i+1]);
6839 (void) SetImageOption(image_info,option+1,argv[i+1]);
6845 if (LocaleCompare("page",option+1) == 0)
6849 page[MaxTextExtent];
6862 (void) DeleteImageOption(image_info,option+1);
6863 (void) CloneString(&image_info->page,(char *) NULL);
6866 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6867 image_option=GetImageOption(image_info,"page");
6868 if (image_option != (const char *) NULL)
6869 flags=ParseAbsoluteGeometry(image_option,&geometry);
6870 canonical_page=GetPageGeometry(argv[i+1]);
6871 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6872 canonical_page=DestroyString(canonical_page);
6873 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6874 (unsigned long) geometry.width,(unsigned long) geometry.height);
6875 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6876 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6877 (unsigned long) geometry.width,(unsigned long) geometry.height,
6878 (long) geometry.x,(long) geometry.y);
6879 (void) SetImageOption(image_info,option+1,page);
6880 (void) CloneString(&image_info->page,page);
6883 if (LocaleCompare("pen",option+1) == 0)
6887 (void) SetImageOption(image_info,option+1,"none");
6890 (void) SetImageOption(image_info,option+1,argv[i+1]);
6893 if (LocaleCompare("ping",option+1) == 0)
6895 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6898 if (LocaleCompare("pointsize",option+1) == 0)
6901 geometry_info.rho=0.0;
6903 (void) ParseGeometry(argv[i+1],&geometry_info);
6904 image_info->pointsize=geometry_info.rho;
6907 if (LocaleCompare("precision",option+1) == 0)
6909 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6912 if (LocaleCompare("preview",option+1) == 0)
6919 image_info->preview_type=UndefinedPreview;
6922 image_info->preview_type=(PreviewType) ParseCommandOption(
6923 MagickPreviewOptions,MagickFalse,argv[i+1]);
6930 if (LocaleCompare("quality",option+1) == 0)
6933 Set image compression quality.
6937 image_info->quality=UndefinedCompressionQuality;
6938 (void) SetImageOption(image_info,option+1,"0");
6941 image_info->quality=StringToUnsignedLong(argv[i+1]);
6942 (void) SetImageOption(image_info,option+1,argv[i+1]);
6945 if (LocaleCompare("quiet",option+1) == 0)
6947 static WarningHandler
6948 warning_handler = (WarningHandler) NULL;
6953 Restore error or warning messages.
6955 warning_handler=SetWarningHandler(warning_handler);
6959 Suppress error or warning messages.
6961 warning_handler=SetWarningHandler((WarningHandler) NULL);
6968 if (LocaleCompare("red-primary",option+1) == 0)
6972 (void) SetImageOption(image_info,option+1,"0.0");
6975 (void) SetImageOption(image_info,option+1,argv[i+1]);
6982 if (LocaleCompare("sampling-factor",option+1) == 0)
6985 Set image sampling factor.
6989 if (image_info->sampling_factor != (char *) NULL)
6990 image_info->sampling_factor=DestroyString(
6991 image_info->sampling_factor);
6994 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6997 if (LocaleCompare("scene",option+1) == 0)
7004 image_info->scene=0;
7005 (void) SetImageOption(image_info,option+1,"0");
7008 image_info->scene=StringToUnsignedLong(argv[i+1]);
7009 (void) SetImageOption(image_info,option+1,argv[i+1]);
7012 if (LocaleCompare("seed",option+1) == 0)
7019 seed=(size_t) time((time_t *) NULL);
7020 SeedPseudoRandomGenerator(seed);
7023 seed=StringToUnsignedLong(argv[i+1]);
7024 SeedPseudoRandomGenerator(seed);
7027 if (LocaleCompare("size",option+1) == 0)
7031 if (image_info->size != (char *) NULL)
7032 image_info->size=DestroyString(image_info->size);
7035 (void) CloneString(&image_info->size,argv[i+1]);
7038 if (LocaleCompare("stroke",option+1) == 0)
7042 (void) SetImageOption(image_info,option+1,"none");
7045 (void) SetImageOption(image_info,option+1,argv[i+1]);
7048 if (LocaleCompare("strokewidth",option+1) == 0)
7052 (void) SetImageOption(image_info,option+1,"0");
7055 (void) SetImageOption(image_info,option+1,argv[i+1]);
7058 if (LocaleCompare("synchronize",option+1) == 0)
7062 image_info->synchronize=MagickFalse;
7065 image_info->synchronize=MagickTrue;
7072 if (LocaleCompare("taint",option+1) == 0)
7076 (void) SetImageOption(image_info,option+1,"false");
7079 (void) SetImageOption(image_info,option+1,"true");
7082 if (LocaleCompare("texture",option+1) == 0)
7086 if (image_info->texture != (char *) NULL)
7087 image_info->texture=DestroyString(image_info->texture);
7090 (void) CloneString(&image_info->texture,argv[i+1]);
7093 if (LocaleCompare("tile-offset",option+1) == 0)
7097 (void) SetImageOption(image_info,option+1,"0");
7100 (void) SetImageOption(image_info,option+1,argv[i+1]);
7103 if (LocaleCompare("transparent-color",option+1) == 0)
7107 (void) QueryColorCompliance("none",AllCompliance,
7108 &image_info->transparent_color,exception);
7109 (void) SetImageOption(image_info,option+1,"none");
7112 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7113 &image_info->transparent_color,exception);
7114 (void) SetImageOption(image_info,option+1,argv[i+1]);
7117 if (LocaleCompare("type",option+1) == 0)
7121 image_info->type=UndefinedType;
7122 (void) SetImageOption(image_info,option+1,"undefined");
7125 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7126 MagickFalse,argv[i+1]);
7127 (void) SetImageOption(image_info,option+1,argv[i+1]);
7134 if (LocaleCompare("undercolor",option+1) == 0)
7138 (void) DeleteImageOption(image_info,option+1);
7141 (void) SetImageOption(image_info,option+1,argv[i+1]);
7144 if (LocaleCompare("units",option+1) == 0)
7148 image_info->units=UndefinedResolution;
7149 (void) SetImageOption(image_info,option+1,"undefined");
7152 image_info->units=(ResolutionType) ParseCommandOption(
7153 MagickResolutionOptions,MagickFalse,argv[i+1]);
7154 (void) SetImageOption(image_info,option+1,argv[i+1]);
7161 if (LocaleCompare("verbose",option+1) == 0)
7165 image_info->verbose=MagickFalse;
7168 image_info->verbose=MagickTrue;
7169 image_info->ping=MagickFalse;
7172 if (LocaleCompare("view",option+1) == 0)
7176 if (image_info->view != (char *) NULL)
7177 image_info->view=DestroyString(image_info->view);
7180 (void) CloneString(&image_info->view,argv[i+1]);
7183 if (LocaleCompare("virtual-pixel",option+1) == 0)
7187 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7188 (void) SetImageOption(image_info,option+1,"undefined");
7191 image_info->virtual_pixel_method=(VirtualPixelMethod)
7192 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7194 (void) SetImageOption(image_info,option+1,argv[i+1]);
7201 if (LocaleCompare("white-point",option+1) == 0)
7205 (void) SetImageOption(image_info,option+1,"0.0");
7208 (void) SetImageOption(image_info,option+1,argv[i+1]);
7222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7226 + M o g r i f y I m a g e L i s t %
7230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7232 % MogrifyImageList() applies any command line options that might affect the
7233 % entire image list (e.g. -append, -coalesce, etc.).
7235 % The format of the MogrifyImage method is:
7237 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7238 % const char **argv,Image **images,ExceptionInfo *exception)
7240 % A description of each parameter follows:
7242 % o image_info: the image info..
7244 % o argc: Specifies a pointer to an integer describing the number of
7245 % elements in the argument vector.
7247 % o argv: Specifies a pointer to a text array containing the command line
7250 % o images: pointer to pointer of the first image in image list.
7252 % o exception: return any errors or warnings in this structure.
7255 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7256 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7267 PixelInterpolateMethod
7281 Apply options to the image list.
7283 assert(image_info != (ImageInfo *) NULL);
7284 assert(image_info->signature == MagickSignature);
7285 assert(images != (Image **) NULL);
7286 assert((*images)->previous == (Image *) NULL);
7287 assert((*images)->signature == MagickSignature);
7288 if ((*images)->debug != MagickFalse)
7289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7290 (*images)->filename);
7291 if ((argc <= 0) || (*argv == (char *) NULL))
7293 interpolate_method=UndefinedInterpolatePixel;
7294 mogrify_info=CloneImageInfo(image_info);
7295 quantize_info=AcquireQuantizeInfo(mogrify_info);
7297 for (i=0; i < (ssize_t) argc; i++)
7299 if (*images == (Image *) NULL)
7302 if (IsCommandOption(option) == MagickFalse)
7304 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7305 count=MagickMax(count,0L);
7306 if ((i+count) >= (ssize_t) argc)
7308 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7309 switch (*(option+1))
7313 if (LocaleCompare("affinity",option+1) == 0)
7315 (void) SyncImagesSettings(mogrify_info,*images);
7318 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7325 if (LocaleCompare("append",option+1) == 0)
7330 (void) SyncImagesSettings(mogrify_info,*images);
7331 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7332 MagickFalse,exception);
7333 if (append_image == (Image *) NULL)
7338 *images=DestroyImageList(*images);
7339 *images=append_image;
7342 if (LocaleCompare("average",option+1) == 0)
7348 Average an image sequence (deprecated).
7350 (void) SyncImagesSettings(mogrify_info,*images);
7351 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7353 if (average_image == (Image *) NULL)
7358 *images=DestroyImageList(*images);
7359 *images=average_image;
7366 if (LocaleCompare("channel",option+1) == 0)
7373 channel=DefaultChannels;
7376 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7377 SetPixelChannelMap(*images,channel);
7380 if (LocaleCompare("clut",option+1) == 0)
7386 (void) SyncImagesSettings(mogrify_info,*images);
7387 image=RemoveFirstImageFromList(images);
7388 clut_image=RemoveFirstImageFromList(images);
7389 if (clut_image == (Image *) NULL)
7394 (void) ClutImage(image,clut_image,interpolate_method,exception);
7395 clut_image=DestroyImage(clut_image);
7396 *images=DestroyImageList(*images);
7400 if (LocaleCompare("coalesce",option+1) == 0)
7405 (void) SyncImagesSettings(mogrify_info,*images);
7406 coalesce_image=CoalesceImages(*images,exception);
7407 if (coalesce_image == (Image *) NULL)
7412 *images=DestroyImageList(*images);
7413 *images=coalesce_image;
7416 if (LocaleCompare("combine",option+1) == 0)
7421 (void) SyncImagesSettings(mogrify_info,*images);
7422 combine_image=CombineImages(*images,exception);
7423 if (combine_image == (Image *) NULL)
7428 *images=DestroyImageList(*images);
7429 *images=combine_image;
7432 if (LocaleCompare("composite",option+1) == 0)
7442 (void) SyncImagesSettings(mogrify_info,*images);
7443 image=RemoveFirstImageFromList(images);
7444 composite_image=RemoveFirstImageFromList(images);
7445 if (composite_image == (Image *) NULL)
7450 (void) TransformImage(&composite_image,(char *) NULL,
7451 composite_image->geometry);
7452 SetGeometry(composite_image,&geometry);
7453 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7454 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7456 mask_image=RemoveFirstImageFromList(images);
7457 if (mask_image != (Image *) NULL)
7459 if ((image->compose == DisplaceCompositeOp) ||
7460 (image->compose == DistortCompositeOp))
7463 Merge Y displacement into X displacement image.
7465 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7467 mask_image=DestroyImage(mask_image);
7472 Set a blending mask for the composition.
7473 Posible error, what if image->mask already set.
7475 image->mask=mask_image;
7476 (void) NegateImage(image->mask,MagickFalse,exception);
7479 (void) CompositeImage(image,image->compose,composite_image,
7480 geometry.x,geometry.y);
7481 if (mask_image != (Image *) NULL)
7482 mask_image=image->mask=DestroyImage(image->mask);
7483 composite_image=DestroyImage(composite_image);
7484 InheritException(exception,&image->exception);
7485 *images=DestroyImageList(*images);
7493 if (LocaleCompare("deconstruct",option+1) == 0)
7498 (void) SyncImagesSettings(mogrify_info,*images);
7499 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7501 if (deconstruct_image == (Image *) NULL)
7506 *images=DestroyImageList(*images);
7507 *images=deconstruct_image;
7510 if (LocaleCompare("delete",option+1) == 0)
7513 DeleteImages(images,"-1",exception);
7515 DeleteImages(images,argv[i+1],exception);
7518 if (LocaleCompare("dither",option+1) == 0)
7522 quantize_info->dither=MagickFalse;
7525 quantize_info->dither=MagickTrue;
7526 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7527 MagickDitherOptions,MagickFalse,argv[i+1]);
7530 if (LocaleCompare("duplicate",option+1) == 0)
7536 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7545 number_duplicates=(size_t) StringToLong(argv[i+1]);
7546 p=strchr(argv[i+1],',');
7547 if (p == (const char *) NULL)
7548 duplicate_images=DuplicateImages(*images,number_duplicates,
7551 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7554 AppendImageToList(images, duplicate_images);
7555 (void) SyncImagesSettings(mogrify_info,*images);
7562 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7567 MagickEvaluateOperator
7570 (void) SyncImageSettings(mogrify_info,*images);
7571 op=(MagickEvaluateOperator) ParseCommandOption(
7572 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7573 evaluate_image=EvaluateImages(*images,op,exception);
7574 if (evaluate_image == (Image *) NULL)
7579 *images=DestroyImageList(*images);
7580 *images=evaluate_image;
7587 if (LocaleCompare("fft",option+1) == 0)
7593 Implements the discrete Fourier transform (DFT).
7595 (void) SyncImageSettings(mogrify_info,*images);
7596 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7597 MagickTrue : MagickFalse,exception);
7598 if (fourier_image == (Image *) NULL)
7600 *images=DestroyImage(*images);
7601 *images=fourier_image;
7604 if (LocaleCompare("flatten",option+1) == 0)
7609 (void) SyncImagesSettings(mogrify_info,*images);
7610 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7611 if (flatten_image == (Image *) NULL)
7613 *images=DestroyImageList(*images);
7614 *images=flatten_image;
7617 if (LocaleCompare("fx",option+1) == 0)
7622 (void) SyncImagesSettings(mogrify_info,*images);
7623 fx_image=FxImage(*images,argv[i+1],exception);
7624 if (fx_image == (Image *) NULL)
7629 *images=DestroyImageList(*images);
7637 if (LocaleCompare("hald-clut",option+1) == 0)
7643 (void) SyncImagesSettings(mogrify_info,*images);
7644 image=RemoveFirstImageFromList(images);
7645 hald_image=RemoveFirstImageFromList(images);
7646 if (hald_image == (Image *) NULL)
7651 (void) HaldClutImage(image,hald_image,exception);
7652 hald_image=DestroyImage(hald_image);
7653 if (*images != (Image *) NULL)
7654 *images=DestroyImageList(*images);
7662 if (LocaleCompare("ift",option+1) == 0)
7670 Implements the inverse fourier discrete Fourier transform (DFT).
7672 (void) SyncImagesSettings(mogrify_info,*images);
7673 magnitude_image=RemoveFirstImageFromList(images);
7674 phase_image=RemoveFirstImageFromList(images);
7675 if (phase_image == (Image *) NULL)
7680 fourier_image=InverseFourierTransformImage(magnitude_image,
7681 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7682 if (fourier_image == (Image *) NULL)
7684 if (*images != (Image *) NULL)
7685 *images=DestroyImage(*images);
7686 *images=fourier_image;
7689 if (LocaleCompare("insert",option+1) == 0)
7697 index=(ssize_t) StringToLong(argv[i+1]);
7698 p=RemoveLastImageFromList(images);
7699 if (p == (Image *) NULL)
7701 (void) ThrowMagickException(exception,GetMagickModule(),
7702 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7708 PrependImageToList(images,q);
7710 if (index == (ssize_t) GetImageListLength(*images))
7711 AppendImageToList(images,q);
7714 q=GetImageFromList(*images,index-1);
7715 if (q == (Image *) NULL)
7717 (void) ThrowMagickException(exception,GetMagickModule(),
7718 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7722 InsertImageInList(&q,p);
7724 *images=GetFirstImageInList(q);
7727 if (LocaleCompare("interpolate",option+1) == 0)
7729 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7730 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7737 if (LocaleCompare("layers",option+1) == 0)
7745 (void) SyncImagesSettings(mogrify_info,*images);
7746 layers=(Image *) NULL;
7747 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7748 MagickFalse,argv[i+1]);
7753 layers=CoalesceImages(*images,exception);
7756 case CompareAnyLayer:
7757 case CompareClearLayer:
7758 case CompareOverlayLayer:
7761 layers=CompareImagesLayers(*images,method,exception);
7767 case TrimBoundsLayer:
7769 layers=MergeImageLayers(*images,method,exception);
7774 layers=DisposeImages(*images,exception);
7777 case OptimizeImageLayer:
7779 layers=OptimizeImageLayers(*images,exception);
7782 case OptimizePlusLayer:
7784 layers=OptimizePlusImageLayers(*images,exception);
7787 case OptimizeTransLayer:
7789 OptimizeImageTransparency(*images,exception);
7792 case RemoveDupsLayer:
7794 RemoveDuplicateLayers(images,exception);
7797 case RemoveZeroLayer:
7799 RemoveZeroDelayLayers(images,exception);
7805 General Purpose, GIF Animation Optimizer.
7807 layers=CoalesceImages(*images,exception);
7808 if (layers == (Image *) NULL)
7813 *images=DestroyImageList(*images);
7815 layers=OptimizeImageLayers(*images,exception);
7816 if (layers == (Image *) NULL)
7821 *images=DestroyImageList(*images);
7823 layers=(Image *) NULL;
7824 OptimizeImageTransparency(*images,exception);
7825 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7829 case CompositeLayer:
7841 Split image sequence at the first 'NULL:' image.
7844 while (source != (Image *) NULL)
7846 source=GetNextImageInList(source);
7847 if ((source != (Image *) NULL) &&
7848 (LocaleCompare(source->magick,"NULL") == 0))
7851 if (source != (Image *) NULL)
7853 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7854 (GetNextImageInList(source) == (Image *) NULL))
7855 source=(Image *) NULL;
7859 Separate the two lists, junk the null: image.
7861 source=SplitImageList(source->previous);
7862 DeleteImageFromList(&source);
7865 if (source == (Image *) NULL)
7867 (void) ThrowMagickException(exception,GetMagickModule(),
7868 OptionError,"MissingNullSeparator","layers Composite");
7873 Adjust offset with gravity and virtual canvas.
7875 SetGeometry(*images,&geometry);
7876 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7877 geometry.width=source->page.width != 0 ?
7878 source->page.width : source->columns;
7879 geometry.height=source->page.height != 0 ?
7880 source->page.height : source->rows;
7881 GravityAdjustGeometry((*images)->page.width != 0 ?
7882 (*images)->page.width : (*images)->columns,
7883 (*images)->page.height != 0 ? (*images)->page.height :
7884 (*images)->rows,(*images)->gravity,&geometry);
7885 compose=OverCompositeOp;
7886 option=GetImageOption(mogrify_info,"compose");
7887 if (option != (const char *) NULL)
7888 compose=(CompositeOperator) ParseCommandOption(
7889 MagickComposeOptions,MagickFalse,option);
7890 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7892 source=DestroyImageList(source);
7896 if (layers == (Image *) NULL)
7898 InheritException(exception,&layers->exception);
7899 *images=DestroyImageList(*images);
7907 if (LocaleCompare("map",option+1) == 0)
7909 (void) SyncImagesSettings(mogrify_info,*images);
7912 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7919 if (LocaleCompare("maximum",option+1) == 0)
7925 Maximum image sequence (deprecated).
7927 (void) SyncImagesSettings(mogrify_info,*images);
7928 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7929 if (maximum_image == (Image *) NULL)
7934 *images=DestroyImageList(*images);
7935 *images=maximum_image;
7938 if (LocaleCompare("minimum",option+1) == 0)
7944 Minimum image sequence (deprecated).
7946 (void) SyncImagesSettings(mogrify_info,*images);
7947 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7948 if (minimum_image == (Image *) NULL)
7953 *images=DestroyImageList(*images);
7954 *images=minimum_image;
7957 if (LocaleCompare("morph",option+1) == 0)
7962 (void) SyncImagesSettings(mogrify_info,*images);
7963 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7965 if (morph_image == (Image *) NULL)
7970 *images=DestroyImageList(*images);
7971 *images=morph_image;
7974 if (LocaleCompare("mosaic",option+1) == 0)
7979 (void) SyncImagesSettings(mogrify_info,*images);
7980 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7981 if (mosaic_image == (Image *) NULL)
7986 *images=DestroyImageList(*images);
7987 *images=mosaic_image;
7994 if (LocaleCompare("print",option+1) == 0)
7999 (void) SyncImagesSettings(mogrify_info,*images);
8000 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8002 if (string == (char *) NULL)
8004 (void) FormatLocaleFile(stdout,"%s",string);
8005 string=DestroyString(string);
8007 if (LocaleCompare("process",option+1) == 0)
8016 (void) SyncImagesSettings(mogrify_info,*images);
8017 arguments=StringToArgv(argv[i+1],&number_arguments);
8018 if (arguments == (char **) NULL)
8020 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8041 Support old style syntax, filter="-option arg".
8043 length=strlen(argv[i+1]);
8044 token=(char *) NULL;
8045 if (~length >= (MaxTextExtent-1))
8046 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8048 if (token == (char *) NULL)
8051 arguments=argv[i+1];
8052 token_info=AcquireTokenInfo();
8053 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8054 "\"",'\0',&breaker,&next,"e);
8055 token_info=DestroyTokenInfo(token_info);
8061 argv=(&(arguments[next]));
8062 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8065 token=DestroyString(token);
8068 (void) SubstituteString(&arguments[1],"-","");
8069 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8070 number_arguments-2,(const char **) arguments+2,exception);
8071 for (j=0; j < number_arguments; j++)
8072 arguments[j]=DestroyString(arguments[j]);
8073 arguments=(char **) RelinquishMagickMemory(arguments);
8080 if (LocaleCompare("reverse",option+1) == 0)
8082 ReverseImageList(images);
8083 InheritException(exception,&(*images)->exception);
8090 if (LocaleCompare("smush",option+1) == 0)
8098 (void) SyncImagesSettings(mogrify_info,*images);
8099 offset=(ssize_t) StringToLong(argv[i+1]);
8100 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8101 MagickFalse,offset,exception);
8102 if (smush_image == (Image *) NULL)
8107 *images=DestroyImageList(*images);
8108 *images=smush_image;
8111 if (LocaleCompare("swap",option+1) == 0)
8132 flags=ParseGeometry(argv[i+1],&geometry_info);
8133 index=(ssize_t) geometry_info.rho;
8134 if ((flags & SigmaValue) != 0)
8135 swap_index=(ssize_t) geometry_info.sigma;
8137 p=GetImageFromList(*images,index);
8138 q=GetImageFromList(*images,swap_index);
8139 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8141 (void) ThrowMagickException(exception,GetMagickModule(),
8142 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8148 swap=CloneImage(p,0,0,MagickTrue,exception);
8149 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8150 ReplaceImageInList(&q,swap);
8151 *images=GetFirstImageInList(q);
8158 if (LocaleCompare("write",option+1) == 0)
8169 (void) SyncImagesSettings(mogrify_info,*images);
8170 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8171 (void) DeleteImageRegistry(key);
8172 write_images=(*images);
8174 write_images=CloneImageList(*images,exception);
8175 write_info=CloneImageInfo(mogrify_info);
8176 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8177 write_info=DestroyImageInfo(write_info);
8179 write_images=DestroyImageList(write_images);
8189 quantize_info=DestroyQuantizeInfo(quantize_info);
8190 mogrify_info=DestroyImageInfo(mogrify_info);
8191 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8192 return(status != 0 ? MagickTrue : MagickFalse);
8196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8200 + M o g r i f y I m a g e s %
8204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8206 % MogrifyImages() applies image processing options to a sequence of images as
8207 % prescribed by command line options.
8209 % The format of the MogrifyImage method is:
8211 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8212 % const MagickBooleanType post,const int argc,const char **argv,
8213 % Image **images,Exceptioninfo *exception)
8215 % A description of each parameter follows:
8217 % o image_info: the image info..
8219 % o post: If true, post process image list operators otherwise pre-process.
8221 % o argc: Specifies a pointer to an integer describing the number of
8222 % elements in the argument vector.
8224 % o argv: Specifies a pointer to a text array containing the command line
8227 % o images: pointer to a pointer of the first image in image list.
8229 % o exception: return any errors or warnings in this structure.
8232 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8233 const MagickBooleanType post,const int argc,const char **argv,
8234 Image **images,ExceptionInfo *exception)
8236 #define MogrifyImageTag "Mogrify/Image"
8250 assert(image_info != (ImageInfo *) NULL);
8251 assert(image_info->signature == MagickSignature);
8252 if (images == (Image **) NULL)
8253 return(MogrifyImage(image_info,argc,argv,images,exception));
8254 assert((*images)->previous == (Image *) NULL);
8255 assert((*images)->signature == MagickSignature);
8256 if ((*images)->debug != MagickFalse)
8257 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8258 (*images)->filename);
8259 if ((argc <= 0) || (*argv == (char *) NULL))
8261 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8266 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8271 Pre-process multi-image sequence operators
8273 if (post == MagickFalse)
8274 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8276 For each image, process simple single image operators
8279 n=GetImageListLength(*images);
8283 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8284 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8286 status&=MogrifyImage(image_info,argc,argv,images,exception);
8287 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8288 if (proceed == MagickFalse)
8290 if ( (*images)->next == (Image *) NULL )
8292 *images=(*images)->next;
8295 assert( *images != (Image *) NULL );
8297 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8298 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8302 Post-process, multi-image sequence operators
8304 *images=GetFirstImageInList(*images);
8305 if (post != MagickFalse)
8306 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8307 return(status != 0 ? MagickTrue : MagickFalse);