2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
13 % MagickWand Module Methods %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/string-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/utility-private.h"
62 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
69 #define UndefinedCompressionQuality 0UL
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % M a g i c k C o m m a n d G e n e s i s %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % MagickCommandGenesis() applies image processing options to an image as
83 % prescribed by command line options.
85 % The format of the MagickCommandGenesis method is:
87 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
88 % MagickCommand command,int argc,char **argv,char **metadata,
89 % ExceptionInfo *exception)
91 % A description of each parameter follows:
93 % o image_info: the image info.
95 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
96 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
97 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98 % DisplayImageCommand, or AnimateImageCommand.
100 % o argc: Specifies a pointer to an integer describing the number of
101 % elements in the argument vector.
103 % o argv: Specifies a pointer to a text array containing the command line
106 % o metadata: any metadata is returned here.
108 % o exception: return any errors or warnings in this structure.
111 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
139 concurrent=MagickFalse;
143 regard_warnings=MagickFalse;
144 for (i=1; i < (ssize_t) (argc-1); i++)
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
149 if (LocaleCompare("bench",option+1) == 0)
150 iterations=StringToUnsignedLong(argv[++i]);
151 if (LocaleCompare("concurrent",option+1) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("debug",option+1) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("duration",option+1) == 0)
156 duration=StringToDouble(argv[++i],(char **) NULL);
157 if (LocaleCompare("regard-warnings",option+1) == 0)
158 regard_warnings=MagickTrue;
160 timer=AcquireTimerInfo();
161 if (concurrent == MagickFalse)
163 for (i=0; i < (ssize_t) iterations; i++)
165 if (status != MagickFalse)
169 if (GetElapsedTime(timer) > duration)
171 (void) ContinueTimer(timer);
173 status=command(image_info,argc,argv,metadata,exception);
174 if (exception->severity != UndefinedException)
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
179 CatchException(exception);
181 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
183 (void) fputs(*metadata,stdout);
184 (void) fputc('\n',stdout);
185 *metadata=DestroyString(*metadata);
192 #if defined(MAGICKCORE_OPENMP_SUPPORT)
193 # pragma omp parallel for shared(status)
195 for (i=0; i < (ssize_t) iterations; i++)
197 if (status != MagickFalse)
201 if (GetElapsedTime(timer) > duration)
203 (void) ContinueTimer(timer);
205 status=command(image_info,argc,argv,metadata,exception);
206 #if defined(MAGICKCORE_OPENMP_SUPPORT)
207 # pragma omp critical (MagickCore_CommandGenesis)
210 if (exception->severity != UndefinedException)
212 if ((exception->severity > ErrorException) ||
213 (regard_warnings != MagickFalse))
215 CatchException(exception);
217 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
219 (void) fputs(*metadata,stdout);
220 (void) fputc('\n',stdout);
221 *metadata=DestroyString(*metadata);
228 elapsed_time=GetElapsedTime(timer);
229 user_time=GetUserTime(timer);
230 (void) FormatLocaleFile(stderr,
231 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
232 iterations,1.0*iterations/elapsed_time,user_time,(double)
233 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
234 (1000.0*(elapsed_time-floor(elapsed_time))));
235 (void) fflush(stderr);
237 timer=DestroyTimerInfo(timer);
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 + M o g r i f y I m a g e %
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 % MogrifyImage() applies simple single image processing options to a single
253 % image that may be part of a large list, but also handles any 'region'
256 % The image in the list may be modified in three different ways...
258 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
259 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
260 % * replace by a list of images (only the -separate option!)
262 % In each case the result is returned into the list, and a pointer to the
263 % modified image (last image added if replaced by a list of images) is
266 % ASIDE: The -crop is present but restricted to non-tile single image crops
268 % This means if all the images are being processed (such as by
269 % MogrifyImages(), next image to be processed will be as per the pointer
270 % (*image)->next. Also the image list may grow as a result of some specific
271 % operations but as images are never merged or deleted, it will never shrink
272 % in length. Typically the list will remain the same length.
274 % WARNING: As the image pointed to may be replaced, the first image in the
275 % list may also change. GetFirstImageInList() should be used by caller if
276 % they wish return the Image pointer to the first image in list.
279 % The format of the MogrifyImage method is:
281 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
282 % const char **argv,Image **image)
284 % A description of each parameter follows:
286 % o image_info: the image info..
288 % o argc: Specifies a pointer to an integer describing the number of
289 % elements in the argument vector.
291 % o argv: Specifies a pointer to a text array containing the command line
294 % o image: the image.
296 % o exception: return any errors or warnings in this structure.
301 GetImageCache() will read an image into a image cache if not already
302 present then return the image that is in the cache under that filename.
304 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
305 ExceptionInfo *exception)
319 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
320 sans_exception=AcquireExceptionInfo();
321 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
322 sans_exception=DestroyExceptionInfo(sans_exception);
323 if (image != (Image *) NULL)
325 read_info=CloneImageInfo(image_info);
326 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
327 image=ReadImage(read_info,exception);
328 read_info=DestroyImageInfo(read_info);
329 if (image != (Image *) NULL)
330 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
334 static MagickBooleanType IsPathWritable(const char *path)
336 if (IsPathAccessible(path) == MagickFalse)
338 if (access_utf8(path,W_OK) != 0)
343 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
350 static MagickBooleanType MonitorProgress(const char *text,
351 const MagickOffsetType offset,const MagickSizeType extent,
352 void *wand_unused(client_data))
355 message[MaxTextExtent],
366 (void) CopyMagickMemory(tag,text,MaxTextExtent);
368 if (p != (char *) NULL)
370 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
371 locale_message=GetLocaleMessage(message);
372 if (locale_message == message)
374 if (p == (char *) NULL)
375 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
376 locale_message,(long) offset,(unsigned long) extent,(long)
377 (100L*offset/(extent-1)));
379 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
380 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
381 (100L*offset/(extent-1)));
382 if (offset == (MagickOffsetType) (extent-1))
383 (void) FormatLocaleFile(stderr,"\n");
384 (void) fflush(stderr);
389 SparseColorOption() parses the complex -sparse-color argument into an
390 an array of floating point values then calls SparseColorImage().
391 Argument is a complex mix of floating-point pixel coodinates, and color
392 specifications (or direct floating point numbers). The number of floats
393 needed to represent a color varies depending on the current channel
396 static Image *SparseColorOption(const Image *image,
397 const SparseColorMethod method,const char *arguments,
398 const MagickBooleanType color_from_image,ExceptionInfo *exception)
401 token[MaxTextExtent];
425 assert(image != (Image *) NULL);
426 assert(image->signature == MagickSignature);
427 if (image->debug != MagickFalse)
428 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
429 assert(exception != (ExceptionInfo *) NULL);
430 assert(exception->signature == MagickSignature);
432 Limit channels according to image - and add up number of color channel.
435 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
437 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
439 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
441 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
442 (image->colorspace == CMYKColorspace))
444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
445 (image->matte != MagickFalse))
449 Read string, to determine number of arguments needed,
455 GetMagickToken(p,&p,token);
456 if ( token[0] == ',' ) continue;
457 if ( isalpha((int) token[0]) || token[0] == '#' ) {
458 if ( color_from_image ) {
459 (void) ThrowMagickException(exception,GetMagickModule(),
460 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
461 "Color arg given, when colors are coming from image");
462 return( (Image *)NULL);
464 x += number_colors; /* color argument */
467 x++; /* floating point argument */
471 if ( color_from_image ) {
472 /* just the control points are being given */
473 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
474 number_arguments=(x/2)*(2+number_colors);
477 /* control points and color values */
478 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Invalid number of Arguments");
485 return( (Image *)NULL);
488 /* Allocate and fill in the floating point arguments */
489 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
490 sizeof(*sparse_arguments));
491 if (sparse_arguments == (double *) NULL) {
492 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
493 "MemoryAllocationFailed","%s","SparseColorOption");
494 return( (Image *)NULL);
496 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
497 sizeof(*sparse_arguments));
500 while( *p != '\0' && x < number_arguments ) {
502 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
503 if ( token[0] == '\0' ) break;
504 if ( isalpha((int) token[0]) || token[0] == '#' ) {
505 (void) ThrowMagickException(exception,GetMagickModule(),
506 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
507 "Color found, instead of X-coord");
511 sparse_arguments[x++]=StringToDouble(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++]=StringToDouble(token,(char **) NULL);
523 /* color values for this control point */
525 if ( (color_from_image ) {
526 /* get color from image */
532 /* color name or function given in string argument */
533 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
534 if ( token[0] == '\0' ) break;
535 if ( isalpha((int) token[0]) || token[0] == '#' ) {
536 /* Color string given */
537 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
539 sparse_arguments[x++] = QuantumScale*color.red;
540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
541 sparse_arguments[x++] = QuantumScale*color.green;
542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
543 sparse_arguments[x++] = QuantumScale*color.blue;
544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
545 (image->colorspace == CMYKColorspace))
546 sparse_arguments[x++] = QuantumScale*color.black;
547 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
548 (image->matte != MagickFalse))
549 sparse_arguments[x++] = QuantumScale*color.alpha;
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
554 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
556 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
557 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
559 sparse_arguments[x++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(token,(char **) NULL);
594 token[0] = ','; /* used this token - get another */
599 if ( number_arguments != x && !error ) {
600 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
601 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( (Image *)NULL);
606 return( (Image *)NULL);
608 /* Call the Interpolation function with the parsed arguments */
609 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
611 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
612 return( sparse_image );
615 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
616 const char **argv,Image **image,ExceptionInfo *exception)
652 PixelInterpolateMethod
666 Initialize method variables.
668 assert(image_info != (const ImageInfo *) NULL);
669 assert(image_info->signature == MagickSignature);
670 assert(image != (Image **) NULL);
671 assert((*image)->signature == MagickSignature);
672 if ((*image)->debug != MagickFalse)
673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
676 mogrify_info=CloneImageInfo(image_info);
677 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
678 quantize_info=AcquireQuantizeInfo(mogrify_info);
679 SetGeometryInfo(&geometry_info);
680 GetPixelInfo(*image,&fill);
681 fill=(*image)->background_color;
683 compose=(*image)->compose;
684 interpolate_method=UndefinedInterpolatePixel;
685 channel=mogrify_info->channel;
686 format=GetImageOption(mogrify_info,"format");
687 SetGeometry(*image,®ion_geometry);
688 region_image=NewImageList();
690 Transmogrify the image.
692 for (i=0; i < (ssize_t) argc; i++)
701 if (IsCommandOption(option) == MagickFalse)
703 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
705 if ((i+count) >= (ssize_t) argc)
707 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
708 mogrify_image=(Image *)NULL;
713 if (LocaleCompare("adaptive-blur",option+1) == 0)
718 (void) SyncImageSettings(mogrify_info,*image,exception);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
722 if ((flags & XiValue) == 0)
723 geometry_info.xi=0.0;
724 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
725 geometry_info.sigma,geometry_info.xi,exception);
728 if (LocaleCompare("adaptive-resize",option+1) == 0)
731 Adaptive resize image.
733 (void) SyncImageSettings(mogrify_info,*image,exception);
734 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
735 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
736 geometry.height,interpolate_method,exception);
739 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
742 Adaptive sharpen image.
744 (void) SyncImageSettings(mogrify_info,*image,exception);
745 flags=ParseGeometry(argv[i+1],&geometry_info);
746 if ((flags & SigmaValue) == 0)
747 geometry_info.sigma=1.0;
748 if ((flags & XiValue) == 0)
749 geometry_info.xi=0.0;
750 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
751 geometry_info.sigma,geometry_info.xi,exception);
754 if (LocaleCompare("affine",option+1) == 0)
761 GetAffineMatrix(&draw_info->affine);
764 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
767 if (LocaleCompare("alpha",option+1) == 0)
772 (void) SyncImageSettings(mogrify_info,*image,exception);
773 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
774 MagickFalse,argv[i+1]);
775 (void) SetImageAlphaChannel(*image,alpha_type,exception);
778 if (LocaleCompare("annotate",option+1) == 0)
782 geometry[MaxTextExtent];
787 (void) SyncImageSettings(mogrify_info,*image,exception);
788 SetGeometryInfo(&geometry_info);
789 flags=ParseGeometry(argv[i+1],&geometry_info);
790 if ((flags & SigmaValue) == 0)
791 geometry_info.sigma=geometry_info.rho;
792 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
794 if (text == (char *) NULL)
796 (void) CloneString(&draw_info->text,text);
797 text=DestroyString(text);
798 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
799 geometry_info.xi,geometry_info.psi);
800 (void) CloneString(&draw_info->geometry,geometry);
801 draw_info->affine.sx=cos(DegreesToRadians(
802 fmod(geometry_info.rho,360.0)));
803 draw_info->affine.rx=sin(DegreesToRadians(
804 fmod(geometry_info.rho,360.0)));
805 draw_info->affine.ry=(-sin(DegreesToRadians(
806 fmod(geometry_info.sigma,360.0))));
807 draw_info->affine.sy=cos(DegreesToRadians(
808 fmod(geometry_info.sigma,360.0)));
809 (void) AnnotateImage(*image,draw_info,exception);
812 if (LocaleCompare("antialias",option+1) == 0)
814 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
816 draw_info->text_antialias=(*option == '-') ? MagickTrue :
820 if (LocaleCompare("attenuate",option+1) == 0)
827 attenuate=StringToDouble(argv[i+1],(char **) NULL);
830 if (LocaleCompare("auto-gamma",option+1) == 0)
833 Auto Adjust Gamma of image based on its mean
835 (void) SyncImageSettings(mogrify_info,*image,exception);
836 (void) AutoGammaImage(*image,exception);
839 if (LocaleCompare("auto-level",option+1) == 0)
842 Perfectly Normalize (max/min stretch) the image
844 (void) SyncImageSettings(mogrify_info,*image,exception);
845 (void) AutoLevelImage(*image,exception);
848 if (LocaleCompare("auto-orient",option+1) == 0)
850 (void) SyncImageSettings(mogrify_info,*image,exception);
851 switch ((*image)->orientation)
853 case TopRightOrientation:
855 mogrify_image=FlopImage(*image,exception);
858 case BottomRightOrientation:
860 mogrify_image=RotateImage(*image,180.0,exception);
863 case BottomLeftOrientation:
865 mogrify_image=FlipImage(*image,exception);
868 case LeftTopOrientation:
870 mogrify_image=TransposeImage(*image,exception);
873 case RightTopOrientation:
875 mogrify_image=RotateImage(*image,90.0,exception);
878 case RightBottomOrientation:
880 mogrify_image=TransverseImage(*image,exception);
883 case LeftBottomOrientation:
885 mogrify_image=RotateImage(*image,270.0,exception);
891 if (mogrify_image != (Image *) NULL)
892 mogrify_image->orientation=TopLeftOrientation;
899 if (LocaleCompare("black-threshold",option+1) == 0)
902 Black threshold image.
904 (void) SyncImageSettings(mogrify_info,*image,exception);
905 (void) BlackThresholdImage(*image,argv[i+1],exception);
908 if (LocaleCompare("blue-shift",option+1) == 0)
913 (void) SyncImageSettings(mogrify_info,*image,exception);
914 geometry_info.rho=1.5;
916 flags=ParseGeometry(argv[i+1],&geometry_info);
917 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
920 if (LocaleCompare("blur",option+1) == 0)
925 (void) SyncImageSettings(mogrify_info,*image,exception);
926 flags=ParseGeometry(argv[i+1],&geometry_info);
927 if ((flags & SigmaValue) == 0)
928 geometry_info.sigma=1.0;
929 if ((flags & XiValue) == 0)
930 geometry_info.xi=0.0;
931 mogrify_image=BlurImage(*image,geometry_info.rho,
932 geometry_info.sigma,geometry_info.xi,exception);
935 if (LocaleCompare("border",option+1) == 0)
938 Surround image with a border of solid color.
940 (void) SyncImageSettings(mogrify_info,*image,exception);
941 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
942 if ((flags & SigmaValue) == 0)
943 geometry.height=geometry.width;
944 mogrify_image=BorderImage(*image,&geometry,compose,exception);
947 if (LocaleCompare("bordercolor",option+1) == 0)
951 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
952 &draw_info->border_color,exception);
955 (void) QueryColorCompliance(argv[i+1],AllCompliance,
956 &draw_info->border_color,exception);
959 if (LocaleCompare("box",option+1) == 0)
961 (void) QueryColorCompliance(argv[i+1],AllCompliance,
962 &draw_info->undercolor,exception);
965 if (LocaleCompare("brightness-contrast",option+1) == 0)
978 Brightness / contrast image.
980 (void) SyncImageSettings(mogrify_info,*image,exception);
981 flags=ParseGeometry(argv[i+1],&geometry_info);
982 brightness=geometry_info.rho;
984 if ((flags & SigmaValue) != 0)
985 contrast=geometry_info.sigma;
986 (void) BrightnessContrastImage(*image,brightness,contrast,
994 if (LocaleCompare("cdl",option+1) == 0)
997 *color_correction_collection;
1000 Color correct with a color decision list.
1002 (void) SyncImageSettings(mogrify_info,*image,exception);
1003 color_correction_collection=FileToString(argv[i+1],~0,exception);
1004 if (color_correction_collection == (char *) NULL)
1006 (void) ColorDecisionListImage(*image,color_correction_collection,
1010 if (LocaleCompare("channel",option+1) == 0)
1013 channel=DefaultChannels;
1015 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1016 SetPixelChannelMap(*image,channel);
1019 if (LocaleCompare("charcoal",option+1) == 0)
1024 (void) SyncImageSettings(mogrify_info,*image,exception);
1025 flags=ParseGeometry(argv[i+1],&geometry_info);
1026 if ((flags & SigmaValue) == 0)
1027 geometry_info.sigma=1.0;
1028 if ((flags & XiValue) == 0)
1029 geometry_info.xi=1.0;
1030 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1031 geometry_info.sigma,geometry_info.xi,exception);
1034 if (LocaleCompare("chop",option+1) == 0)
1039 (void) SyncImageSettings(mogrify_info,*image,exception);
1040 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1041 mogrify_image=ChopImage(*image,&geometry,exception);
1044 if (LocaleCompare("clamp",option+1) == 0)
1049 (void) SyncImageSettings(mogrify_info,*image,exception);
1050 (void) ClampImage(*image,exception);
1053 if (LocaleCompare("clip",option+1) == 0)
1055 (void) SyncImageSettings(mogrify_info,*image,exception);
1058 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1061 (void) ClipImage(*image,exception);
1064 if (LocaleCompare("clip-mask",option+1) == 0)
1081 (void) SyncImageSettings(mogrify_info,*image,exception);
1087 (void) SetImageMask(*image,(Image *) NULL,exception);
1092 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1094 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1095 if (mask_image == (Image *) NULL)
1097 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1098 return(MagickFalse);
1099 mask_view=AcquireCacheView(mask_image);
1100 for (y=0; y < (ssize_t) mask_image->rows; y++)
1102 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1104 if (q == (Quantum *) NULL)
1106 for (x=0; x < (ssize_t) mask_image->columns; x++)
1108 if (mask_image->matte == MagickFalse)
1109 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1110 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1111 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1112 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1113 q+=GetPixelChannels(mask_image);
1115 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1118 mask_view=DestroyCacheView(mask_view);
1119 mask_image->matte=MagickTrue;
1120 (void) SetImageClipMask(*image,mask_image,exception);
1123 if (LocaleCompare("clip-path",option+1) == 0)
1125 (void) SyncImageSettings(mogrify_info,*image,exception);
1126 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1127 MagickFalse,exception);
1130 if (LocaleCompare("colorize",option+1) == 0)
1135 (void) SyncImageSettings(mogrify_info,*image,exception);
1136 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1139 if (LocaleCompare("color-matrix",option+1) == 0)
1144 (void) SyncImageSettings(mogrify_info,*image,exception);
1145 kernel=AcquireKernelInfo(argv[i+1]);
1146 if (kernel == (KernelInfo *) NULL)
1148 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1149 kernel=DestroyKernelInfo(kernel);
1152 if (LocaleCompare("colors",option+1) == 0)
1155 Reduce the number of colors in the image.
1157 (void) SyncImageSettings(mogrify_info,*image,exception);
1158 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1159 if (quantize_info->number_colors == 0)
1161 if (((*image)->storage_class == DirectClass) ||
1162 (*image)->colors > quantize_info->number_colors)
1163 (void) QuantizeImage(quantize_info,*image,exception);
1165 (void) CompressImageColormap(*image,exception);
1168 if (LocaleCompare("colorspace",option+1) == 0)
1173 (void) SyncImageSettings(mogrify_info,*image,exception);
1176 (void) TransformImageColorspace(*image,RGBColorspace,exception);
1179 colorspace=(ColorspaceType) ParseCommandOption(
1180 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1181 (void) TransformImageColorspace(*image,colorspace,exception);
1184 if (LocaleCompare("compose",option+1) == 0)
1186 (void) SyncImageSettings(mogrify_info,*image,exception);
1187 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1188 MagickFalse,argv[i+1]);
1191 if (LocaleCompare("contrast",option+1) == 0)
1193 (void) SyncImageSettings(mogrify_info,*image,exception);
1194 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1195 MagickFalse,exception);
1198 if (LocaleCompare("contrast-stretch",option+1) == 0)
1208 Contrast stretch image.
1210 (void) SyncImageSettings(mogrify_info,*image,exception);
1211 flags=ParseGeometry(argv[i+1],&geometry_info);
1212 black_point=geometry_info.rho;
1213 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1215 if ((flags & PercentValue) != 0)
1217 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1218 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1220 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1222 (void) ContrastStretchImage(*image,black_point,white_point,
1226 if (LocaleCompare("convolve",option+1) == 0)
1231 (void) SyncImageSettings(mogrify_info,*image,exception);
1232 kernel_info=AcquireKernelInfo(argv[i+1]);
1233 if (kernel_info == (KernelInfo *) NULL)
1235 kernel_info->bias=(*image)->bias;
1236 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1237 kernel_info=DestroyKernelInfo(kernel_info);
1240 if (LocaleCompare("crop",option+1) == 0)
1243 Crop a image to a smaller size
1245 (void) SyncImageSettings(mogrify_info,*image,exception);
1246 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1249 if (LocaleCompare("cycle",option+1) == 0)
1252 Cycle an image colormap.
1254 (void) SyncImageSettings(mogrify_info,*image,exception);
1255 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1263 if (LocaleCompare("decipher",option+1) == 0)
1271 (void) SyncImageSettings(mogrify_info,*image,exception);
1272 passkey=FileToStringInfo(argv[i+1],~0,exception);
1273 if (passkey != (StringInfo *) NULL)
1275 (void) PasskeyDecipherImage(*image,passkey,exception);
1276 passkey=DestroyStringInfo(passkey);
1280 if (LocaleCompare("density",option+1) == 0)
1285 (void) CloneString(&draw_info->density,argv[i+1]);
1288 if (LocaleCompare("depth",option+1) == 0)
1290 (void) SyncImageSettings(mogrify_info,*image,exception);
1293 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1296 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1300 if (LocaleCompare("deskew",option+1) == 0)
1306 Straighten the image.
1308 (void) SyncImageSettings(mogrify_info,*image,exception);
1310 threshold=40.0*QuantumRange/100.0;
1312 threshold=StringToDoubleInterval(argv[i+1],QuantumRange);
1313 mogrify_image=DeskewImage(*image,threshold,exception);
1316 if (LocaleCompare("despeckle",option+1) == 0)
1319 Reduce the speckles within an image.
1321 (void) SyncImageSettings(mogrify_info,*image,exception);
1322 mogrify_image=DespeckleImage(*image,exception);
1325 if (LocaleCompare("display",option+1) == 0)
1327 (void) CloneString(&draw_info->server_name,argv[i+1]);
1330 if (LocaleCompare("distort",option+1) == 0)
1334 token[MaxTextExtent];
1354 (void) SyncImageSettings(mogrify_info,*image,exception);
1355 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1356 MagickFalse,argv[i+1]);
1357 if ( method == ResizeDistortion )
1359 /* Special Case - Argument is actually a resize geometry!
1360 ** Convert that to an appropriate distortion argument array.
1364 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1366 resize_args[0]=(double)geometry.width;
1367 resize_args[1]=(double)geometry.height;
1368 mogrify_image=DistortImage(*image,method,(size_t)2,
1369 resize_args,MagickTrue,exception);
1372 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1374 if (args == (char *) NULL)
1377 for (x=0; *p != '\0'; x++)
1379 GetMagickToken(p,&p,token);
1381 GetMagickToken(p,&p,token);
1383 number_arguments=(size_t) x;
1384 arguments=(double *) AcquireQuantumMemory(number_arguments,
1385 sizeof(*arguments));
1386 if (arguments == (double *) NULL)
1387 ThrowWandFatalException(ResourceLimitFatalError,
1388 "MemoryAllocationFailed",(*image)->filename);
1389 (void) ResetMagickMemory(arguments,0,number_arguments*
1390 sizeof(*arguments));
1392 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1394 GetMagickToken(p,&p,token);
1396 GetMagickToken(p,&p,token);
1397 arguments[x]=StringToDouble(token,(char **) NULL);
1399 args=DestroyString(args);
1400 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1401 (*option == '+') ? MagickTrue : MagickFalse,exception);
1402 arguments=(double *) RelinquishMagickMemory(arguments);
1405 if (LocaleCompare("dither",option+1) == 0)
1409 quantize_info->dither=MagickFalse;
1412 quantize_info->dither=MagickTrue;
1413 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1414 MagickDitherOptions,MagickFalse,argv[i+1]);
1415 if (quantize_info->dither_method == NoDitherMethod)
1416 quantize_info->dither=MagickFalse;
1419 if (LocaleCompare("draw",option+1) == 0)
1424 (void) SyncImageSettings(mogrify_info,*image,exception);
1425 (void) CloneString(&draw_info->primitive,argv[i+1]);
1426 (void) DrawImage(*image,draw_info,exception);
1433 if (LocaleCompare("edge",option+1) == 0)
1436 Enhance edges in the image.
1438 (void) SyncImageSettings(mogrify_info,*image,exception);
1439 flags=ParseGeometry(argv[i+1],&geometry_info);
1440 if ((flags & SigmaValue) == 0)
1441 geometry_info.sigma=1.0;
1442 mogrify_image=EdgeImage(*image,geometry_info.rho,
1443 geometry_info.sigma,exception);
1446 if (LocaleCompare("emboss",option+1) == 0)
1449 Gaussian embossen image.
1451 (void) SyncImageSettings(mogrify_info,*image,exception);
1452 flags=ParseGeometry(argv[i+1],&geometry_info);
1453 if ((flags & SigmaValue) == 0)
1454 geometry_info.sigma=1.0;
1455 mogrify_image=EmbossImage(*image,geometry_info.rho,
1456 geometry_info.sigma,exception);
1459 if (LocaleCompare("encipher",option+1) == 0)
1467 (void) SyncImageSettings(mogrify_info,*image,exception);
1468 passkey=FileToStringInfo(argv[i+1],~0,exception);
1469 if (passkey != (StringInfo *) NULL)
1471 (void) PasskeyEncipherImage(*image,passkey,exception);
1472 passkey=DestroyStringInfo(passkey);
1476 if (LocaleCompare("encoding",option+1) == 0)
1478 (void) CloneString(&draw_info->encoding,argv[i+1]);
1481 if (LocaleCompare("enhance",option+1) == 0)
1486 (void) SyncImageSettings(mogrify_info,*image,exception);
1487 mogrify_image=EnhanceImage(*image,exception);
1490 if (LocaleCompare("equalize",option+1) == 0)
1495 (void) SyncImageSettings(mogrify_info,*image,exception);
1496 (void) EqualizeImage(*image,exception);
1499 if (LocaleCompare("evaluate",option+1) == 0)
1504 MagickEvaluateOperator
1507 (void) SyncImageSettings(mogrify_info,*image,exception);
1508 op=(MagickEvaluateOperator) ParseCommandOption(
1509 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1510 constant=StringToDoubleInterval(argv[i+2],QuantumRange);
1511 (void) EvaluateImage(*image,op,constant,exception);
1514 if (LocaleCompare("extent",option+1) == 0)
1517 Set the image extent.
1519 (void) SyncImageSettings(mogrify_info,*image,exception);
1520 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1521 if (geometry.width == 0)
1522 geometry.width=(*image)->columns;
1523 if (geometry.height == 0)
1524 geometry.height=(*image)->rows;
1525 mogrify_image=ExtentImage(*image,&geometry,exception);
1532 if (LocaleCompare("family",option+1) == 0)
1536 if (draw_info->family != (char *) NULL)
1537 draw_info->family=DestroyString(draw_info->family);
1540 (void) CloneString(&draw_info->family,argv[i+1]);
1543 if (LocaleCompare("features",option+1) == 0)
1547 (void) DeleteImageArtifact(*image,"identify:features");
1550 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1553 if (LocaleCompare("fill",option+1) == 0)
1558 GetPixelInfo(*image,&fill);
1561 (void) QueryColorCompliance("none",AllCompliance,&fill,
1563 (void) QueryColorCompliance("none",AllCompliance,
1564 &draw_info->fill,exception);
1565 if (draw_info->fill_pattern != (Image *) NULL)
1566 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1569 sans=AcquireExceptionInfo();
1570 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
1572 status=QueryColorCompliance(argv[i+1],AllCompliance,
1573 &draw_info->fill,sans);
1574 sans=DestroyExceptionInfo(sans);
1575 if (status == MagickFalse)
1576 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1580 if (LocaleCompare("flip",option+1) == 0)
1583 Flip image scanlines.
1585 (void) SyncImageSettings(mogrify_info,*image,exception);
1586 mogrify_image=FlipImage(*image,exception);
1589 if (LocaleCompare("floodfill",option+1) == 0)
1597 (void) SyncImageSettings(mogrify_info,*image,exception);
1598 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1599 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1601 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1602 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1605 if (LocaleCompare("flop",option+1) == 0)
1608 Flop image scanlines.
1610 (void) SyncImageSettings(mogrify_info,*image,exception);
1611 mogrify_image=FlopImage(*image,exception);
1614 if (LocaleCompare("font",option+1) == 0)
1618 if (draw_info->font != (char *) NULL)
1619 draw_info->font=DestroyString(draw_info->font);
1622 (void) CloneString(&draw_info->font,argv[i+1]);
1625 if (LocaleCompare("format",option+1) == 0)
1630 if (LocaleCompare("frame",option+1) == 0)
1636 Surround image with an ornamental border.
1638 (void) SyncImageSettings(mogrify_info,*image,exception);
1639 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1640 frame_info.width=geometry.width;
1641 frame_info.height=geometry.height;
1642 if ((flags & HeightValue) == 0)
1643 frame_info.height=geometry.width;
1644 frame_info.outer_bevel=geometry.x;
1645 frame_info.inner_bevel=geometry.y;
1646 frame_info.x=(ssize_t) frame_info.width;
1647 frame_info.y=(ssize_t) frame_info.height;
1648 frame_info.width=(*image)->columns+2*frame_info.width;
1649 frame_info.height=(*image)->rows+2*frame_info.height;
1650 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1653 if (LocaleCompare("function",option+1) == 0)
1657 token[MaxTextExtent];
1675 Function Modify Image Values
1677 (void) SyncImageSettings(mogrify_info,*image,exception);
1678 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1679 MagickFalse,argv[i+1]);
1680 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1682 if (arguments == (char *) NULL)
1684 p=(char *) arguments;
1685 for (x=0; *p != '\0'; x++)
1687 GetMagickToken(p,&p,token);
1689 GetMagickToken(p,&p,token);
1691 number_parameters=(size_t) x;
1692 parameters=(double *) AcquireQuantumMemory(number_parameters,
1693 sizeof(*parameters));
1694 if (parameters == (double *) NULL)
1695 ThrowWandFatalException(ResourceLimitFatalError,
1696 "MemoryAllocationFailed",(*image)->filename);
1697 (void) ResetMagickMemory(parameters,0,number_parameters*
1698 sizeof(*parameters));
1699 p=(char *) arguments;
1700 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1702 GetMagickToken(p,&p,token);
1704 GetMagickToken(p,&p,token);
1705 parameters[x]=StringToDouble(token,(char **) NULL);
1707 arguments=DestroyString(arguments);
1708 (void) FunctionImage(*image,function,number_parameters,parameters,
1710 parameters=(double *) RelinquishMagickMemory(parameters);
1717 if (LocaleCompare("gamma",option+1) == 0)
1722 (void) SyncImageSettings(mogrify_info,*image,exception);
1724 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1726 (void) GammaImage(*image,StringToDouble(argv[i+1],
1727 (char **) NULL),exception);
1730 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1731 (LocaleCompare("gaussian",option+1) == 0))
1734 Gaussian blur image.
1736 (void) SyncImageSettings(mogrify_info,*image,exception);
1737 flags=ParseGeometry(argv[i+1],&geometry_info);
1738 if ((flags & SigmaValue) == 0)
1739 geometry_info.sigma=1.0;
1740 if ((flags & XiValue) == 0)
1741 geometry_info.xi=0.0;
1742 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1743 geometry_info.sigma,geometry_info.xi,exception);
1746 if (LocaleCompare("geometry",option+1) == 0)
1749 Record Image offset, Resize last image.
1751 (void) SyncImageSettings(mogrify_info,*image,exception);
1754 if ((*image)->geometry != (char *) NULL)
1755 (*image)->geometry=DestroyString((*image)->geometry);
1758 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1759 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1760 (void) CloneString(&(*image)->geometry,argv[i+1]);
1762 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1763 (*image)->filter,(*image)->blur,exception);
1766 if (LocaleCompare("gravity",option+1) == 0)
1770 draw_info->gravity=UndefinedGravity;
1773 draw_info->gravity=(GravityType) ParseCommandOption(
1774 MagickGravityOptions,MagickFalse,argv[i+1]);
1781 if (LocaleCompare("highlight-color",option+1) == 0)
1783 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1790 if (LocaleCompare("identify",option+1) == 0)
1795 (void) SyncImageSettings(mogrify_info,*image,exception);
1796 if (format == (char *) NULL)
1798 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1802 text=InterpretImageProperties(mogrify_info,*image,format,
1804 if (text == (char *) NULL)
1806 (void) fputs(text,stdout);
1807 (void) fputc('\n',stdout);
1808 text=DestroyString(text);
1811 if (LocaleCompare("implode",option+1) == 0)
1816 (void) SyncImageSettings(mogrify_info,*image,exception);
1817 (void) ParseGeometry(argv[i+1],&geometry_info);
1818 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1819 interpolate_method,exception);
1822 if (LocaleCompare("interline-spacing",option+1) == 0)
1825 (void) ParseGeometry("0",&geometry_info);
1827 (void) ParseGeometry(argv[i+1],&geometry_info);
1828 draw_info->interline_spacing=geometry_info.rho;
1831 if (LocaleCompare("interpolate",option+1) == 0)
1833 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1834 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1837 if (LocaleCompare("interword-spacing",option+1) == 0)
1840 (void) ParseGeometry("0",&geometry_info);
1842 (void) ParseGeometry(argv[i+1],&geometry_info);
1843 draw_info->interword_spacing=geometry_info.rho;
1850 if (LocaleCompare("kerning",option+1) == 0)
1853 (void) ParseGeometry("0",&geometry_info);
1855 (void) ParseGeometry(argv[i+1],&geometry_info);
1856 draw_info->kerning=geometry_info.rho;
1863 if (LocaleCompare("lat",option+1) == 0)
1866 Local adaptive threshold image.
1868 (void) SyncImageSettings(mogrify_info,*image,exception);
1869 flags=ParseGeometry(argv[i+1],&geometry_info);
1870 if ((flags & PercentValue) != 0)
1871 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1872 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1873 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1874 geometry_info.xi,exception);
1877 if (LocaleCompare("level",option+1) == 0)
1890 (void) SyncImageSettings(mogrify_info,*image,exception);
1891 flags=ParseGeometry(argv[i+1],&geometry_info);
1892 black_point=geometry_info.rho;
1893 white_point=(MagickRealType) QuantumRange;
1894 if ((flags & SigmaValue) != 0)
1895 white_point=geometry_info.sigma;
1897 if ((flags & XiValue) != 0)
1898 gamma=geometry_info.xi;
1899 if ((flags & PercentValue) != 0)
1901 black_point*=(MagickRealType) (QuantumRange/100.0);
1902 white_point*=(MagickRealType) (QuantumRange/100.0);
1904 if ((flags & SigmaValue) == 0)
1905 white_point=(MagickRealType) QuantumRange-black_point;
1906 if ((*option == '+') || ((flags & AspectValue) != 0))
1907 (void) LevelizeImage(*image,black_point,white_point,gamma,
1910 (void) LevelImage(*image,black_point,white_point,gamma,
1914 if (LocaleCompare("level-colors",option+1) == 0)
1917 token[MaxTextExtent];
1926 p=(const char *) argv[i+1];
1927 GetMagickToken(p,&p,token); /* get black point color */
1928 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1929 (void) QueryColorCompliance(token,AllCompliance,
1930 &black_point,exception);
1932 (void) QueryColorCompliance("#000000",AllCompliance,
1933 &black_point,exception);
1934 if (isalpha((int) token[0]) || (token[0] == '#'))
1935 GetMagickToken(p,&p,token);
1937 white_point=black_point; /* set everything to that color */
1940 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1941 GetMagickToken(p,&p,token); /* Get white point color. */
1942 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1943 (void) QueryColorCompliance(token,AllCompliance,
1944 &white_point,exception);
1946 (void) QueryColorCompliance("#ffffff",AllCompliance,
1947 &white_point,exception);
1949 (void) LevelImageColors(*image,&black_point,&white_point,
1950 *option == '+' ? MagickTrue : MagickFalse,exception);
1953 if (LocaleCompare("linear-stretch",option+1) == 0)
1962 (void) SyncImageSettings(mogrify_info,*image,exception);
1963 flags=ParseGeometry(argv[i+1],&geometry_info);
1964 black_point=geometry_info.rho;
1965 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1966 if ((flags & SigmaValue) != 0)
1967 white_point=geometry_info.sigma;
1968 if ((flags & PercentValue) != 0)
1970 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1971 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1973 if ((flags & SigmaValue) == 0)
1974 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1976 (void) LinearStretchImage(*image,black_point,white_point,exception);
1979 if (LocaleCompare("linewidth",option+1) == 0)
1981 draw_info->stroke_width=StringToDouble(argv[i+1],
1985 if (LocaleCompare("liquid-rescale",option+1) == 0)
1988 Liquid rescale image.
1990 (void) SyncImageSettings(mogrify_info,*image,exception);
1991 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1992 if ((flags & XValue) == 0)
1994 if ((flags & YValue) == 0)
1996 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1997 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2000 if (LocaleCompare("lowlight-color",option+1) == 0)
2002 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2009 if (LocaleCompare("map",option+1) == 0)
2015 Transform image colors to match this set of colors.
2017 (void) SyncImageSettings(mogrify_info,*image,exception);
2020 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2021 if (remap_image == (Image *) NULL)
2023 (void) RemapImage(quantize_info,*image,remap_image,exception);
2024 remap_image=DestroyImage(remap_image);
2027 if (LocaleCompare("mask",option+1) == 0)
2032 (void) SyncImageSettings(mogrify_info,*image,exception);
2038 (void) SetImageMask(*image,(Image *) NULL,exception);
2044 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2045 if (mask == (Image *) NULL)
2047 (void) SetImageMask(*image,mask,exception);
2048 mask=DestroyImage(mask);
2051 if (LocaleCompare("matte",option+1) == 0)
2053 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2054 SetAlphaChannel : DeactivateAlphaChannel,exception);
2057 if (LocaleCompare("median",option+1) == 0)
2060 Median filter image.
2062 (void) SyncImageSettings(mogrify_info,*image,exception);
2063 flags=ParseGeometry(argv[i+1],&geometry_info);
2064 if ((flags & SigmaValue) == 0)
2065 geometry_info.sigma=geometry_info.rho;
2066 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2067 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2070 if (LocaleCompare("mode",option+1) == 0)
2075 (void) SyncImageSettings(mogrify_info,*image,exception);
2076 flags=ParseGeometry(argv[i+1],&geometry_info);
2077 if ((flags & SigmaValue) == 0)
2078 geometry_info.sigma=geometry_info.rho;
2079 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2080 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2083 if (LocaleCompare("modulate",option+1) == 0)
2085 (void) SyncImageSettings(mogrify_info,*image,exception);
2086 (void) ModulateImage(*image,argv[i+1],exception);
2089 if (LocaleCompare("monitor",option+1) == 0)
2093 (void) SetImageProgressMonitor(*image,
2094 (MagickProgressMonitor) NULL,(void *) NULL);
2097 (void) SetImageProgressMonitor(*image,MonitorProgress,
2101 if (LocaleCompare("monochrome",option+1) == 0)
2103 (void) SyncImageSettings(mogrify_info,*image,exception);
2104 (void) SetImageType(*image,BilevelType,exception);
2107 if (LocaleCompare("morphology",option+1) == 0)
2110 token[MaxTextExtent];
2125 Morphological Image Operation
2127 (void) SyncImageSettings(mogrify_info,*image,exception);
2129 GetMagickToken(p,&p,token);
2130 method=(MorphologyMethod) ParseCommandOption(
2131 MagickMorphologyOptions,MagickFalse,token);
2133 GetMagickToken(p,&p,token);
2134 if ((*p == ':') || (*p == ','))
2135 GetMagickToken(p,&p,token);
2137 iterations=(ssize_t) StringToLong(p);
2138 kernel=AcquireKernelInfo(argv[i+2]);
2139 if (kernel == (KernelInfo *) NULL)
2141 (void) ThrowMagickException(exception,GetMagickModule(),
2142 OptionError,"UnabletoParseKernel","morphology");
2146 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2148 kernel=DestroyKernelInfo(kernel);
2151 if (LocaleCompare("motion-blur",option+1) == 0)
2156 (void) SyncImageSettings(mogrify_info,*image,exception);
2157 flags=ParseGeometry(argv[i+1],&geometry_info);
2158 if ((flags & SigmaValue) == 0)
2159 geometry_info.sigma=1.0;
2160 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2161 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2169 if (LocaleCompare("negate",option+1) == 0)
2171 (void) SyncImageSettings(mogrify_info,*image,exception);
2172 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2173 MagickFalse,exception);
2176 if (LocaleCompare("noise",option+1) == 0)
2178 (void) SyncImageSettings(mogrify_info,*image,exception);
2181 flags=ParseGeometry(argv[i+1],&geometry_info);
2182 if ((flags & SigmaValue) == 0)
2183 geometry_info.sigma=geometry_info.rho;
2184 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2185 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2192 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2193 MagickFalse,argv[i+1]);
2194 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2198 if (LocaleCompare("normalize",option+1) == 0)
2200 (void) SyncImageSettings(mogrify_info,*image,exception);
2201 (void) NormalizeImage(*image,exception);
2208 if (LocaleCompare("opaque",option+1) == 0)
2213 (void) SyncImageSettings(mogrify_info,*image,exception);
2214 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2216 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2217 MagickFalse : MagickTrue,exception);
2220 if (LocaleCompare("ordered-dither",option+1) == 0)
2222 (void) SyncImageSettings(mogrify_info,*image,exception);
2223 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2230 if (LocaleCompare("paint",option+1) == 0)
2232 (void) SyncImageSettings(mogrify_info,*image,exception);
2233 (void) ParseGeometry(argv[i+1],&geometry_info);
2234 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2235 geometry_info.sigma,exception);
2238 if (LocaleCompare("pen",option+1) == 0)
2242 (void) QueryColorCompliance("none",AllCompliance,
2243 &draw_info->fill,exception);
2246 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2247 &draw_info->fill,exception);
2250 if (LocaleCompare("pointsize",option+1) == 0)
2253 (void) ParseGeometry("12",&geometry_info);
2255 (void) ParseGeometry(argv[i+1],&geometry_info);
2256 draw_info->pointsize=geometry_info.rho;
2259 if (LocaleCompare("polaroid",option+1) == 0)
2268 Simulate a Polaroid picture.
2270 (void) SyncImageSettings(mogrify_info,*image,exception);
2271 random_info=AcquireRandomInfo();
2272 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2273 random_info=DestroyRandomInfo(random_info);
2276 SetGeometryInfo(&geometry_info);
2277 flags=ParseGeometry(argv[i+1],&geometry_info);
2278 angle=geometry_info.rho;
2280 mogrify_image=PolaroidImage(*image,draw_info,angle,
2281 interpolate_method,exception);
2284 if (LocaleCompare("posterize",option+1) == 0)
2289 (void) SyncImageSettings(mogrify_info,*image,exception);
2290 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2291 quantize_info->dither,exception);
2294 if (LocaleCompare("preview",option+1) == 0)
2302 (void) SyncImageSettings(mogrify_info,*image,exception);
2304 preview_type=UndefinedPreview;
2306 preview_type=(PreviewType) ParseCommandOption(
2307 MagickPreviewOptions,MagickFalse,argv[i+1]);
2308 mogrify_image=PreviewImage(*image,preview_type,exception);
2311 if (LocaleCompare("profile",option+1) == 0)
2325 (void) SyncImageSettings(mogrify_info,*image,exception);
2329 Remove a profile from the image.
2331 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2336 Associate a profile with the image.
2338 profile_info=CloneImageInfo(mogrify_info);
2339 profile=GetImageProfile(*image,"iptc");
2340 if (profile != (StringInfo *) NULL)
2341 profile_info->profile=(void *) CloneStringInfo(profile);
2342 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2343 profile_info=DestroyImageInfo(profile_info);
2344 if (profile_image == (Image *) NULL)
2349 profile_info=CloneImageInfo(mogrify_info);
2350 (void) CopyMagickString(profile_info->filename,argv[i+1],
2352 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2353 if (profile != (StringInfo *) NULL)
2355 (void) ProfileImage(*image,profile_info->magick,
2356 GetStringInfoDatum(profile),(size_t)
2357 GetStringInfoLength(profile),MagickFalse);
2358 profile=DestroyStringInfo(profile);
2360 profile_info=DestroyImageInfo(profile_info);
2363 ResetImageProfileIterator(profile_image);
2364 name=GetNextImageProfile(profile_image);
2365 while (name != (const char *) NULL)
2367 profile=GetImageProfile(profile_image,name);
2368 if (profile != (StringInfo *) NULL)
2369 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2370 (size_t) GetStringInfoLength(profile),MagickFalse);
2371 name=GetNextImageProfile(profile_image);
2373 profile_image=DestroyImage(profile_image);
2380 if (LocaleCompare("quantize",option+1) == 0)
2384 quantize_info->colorspace=UndefinedColorspace;
2387 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2388 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2395 if (LocaleCompare("radial-blur",option+1) == 0)
2400 (void) SyncImageSettings(mogrify_info,*image,exception);
2401 flags=ParseGeometry(argv[i+1],&geometry_info);
2402 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2403 geometry_info.sigma,exception);
2406 if (LocaleCompare("raise",option+1) == 0)
2409 Surround image with a raise of solid color.
2411 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2412 if ((flags & SigmaValue) == 0)
2413 geometry.height=geometry.width;
2414 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2415 MagickFalse,exception);
2418 if (LocaleCompare("random-threshold",option+1) == 0)
2423 (void) SyncImageSettings(mogrify_info,*image,exception);
2424 (void) RandomThresholdImage(*image,argv[i+1],exception);
2427 if (LocaleCompare("recolor",option+1) == 0)
2432 (void) SyncImageSettings(mogrify_info,*image,exception);
2433 kernel=AcquireKernelInfo(argv[i+1]);
2434 if (kernel == (KernelInfo *) NULL)
2436 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2437 kernel=DestroyKernelInfo(kernel);
2440 if (LocaleCompare("region",option+1) == 0)
2442 (void) SyncImageSettings(mogrify_info,*image,exception);
2443 if (region_image != (Image *) NULL)
2448 (void) CompositeImage(region_image,region_image->matte !=
2449 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2450 region_geometry.x,region_geometry.y,exception);
2451 *image=DestroyImage(*image);
2452 *image=region_image;
2453 region_image = (Image *) NULL;
2458 Apply transformations to a selected region of the image.
2460 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2462 mogrify_image=CropImage(*image,®ion_geometry,exception);
2463 if (mogrify_image == (Image *) NULL)
2465 region_image=(*image);
2466 *image=mogrify_image;
2467 mogrify_image=(Image *) NULL;
2470 if (LocaleCompare("render",option+1) == 0)
2472 (void) SyncImageSettings(mogrify_info,*image,exception);
2473 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2476 if (LocaleCompare("remap",option+1) == 0)
2482 Transform image colors to match this set of colors.
2484 (void) SyncImageSettings(mogrify_info,*image,exception);
2487 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2488 if (remap_image == (Image *) NULL)
2490 (void) RemapImage(quantize_info,*image,remap_image,exception);
2491 remap_image=DestroyImage(remap_image);
2494 if (LocaleCompare("repage",option+1) == 0)
2498 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2501 (void) ResetImagePage(*image,argv[i+1]);
2504 if (LocaleCompare("resample",option+1) == 0)
2509 (void) SyncImageSettings(mogrify_info,*image,exception);
2510 flags=ParseGeometry(argv[i+1],&geometry_info);
2511 if ((flags & SigmaValue) == 0)
2512 geometry_info.sigma=geometry_info.rho;
2513 mogrify_image=ResampleImage(*image,geometry_info.rho,
2514 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2517 if (LocaleCompare("resize",option+1) == 0)
2522 (void) SyncImageSettings(mogrify_info,*image,exception);
2523 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2524 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2525 (*image)->filter,(*image)->blur,exception);
2528 if (LocaleCompare("roll",option+1) == 0)
2533 (void) SyncImageSettings(mogrify_info,*image,exception);
2534 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2535 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2538 if (LocaleCompare("rotate",option+1) == 0)
2544 Check for conditional image rotation.
2546 (void) SyncImageSettings(mogrify_info,*image,exception);
2547 if (strchr(argv[i+1],'>') != (char *) NULL)
2548 if ((*image)->columns <= (*image)->rows)
2550 if (strchr(argv[i+1],'<') != (char *) NULL)
2551 if ((*image)->columns >= (*image)->rows)
2556 geometry=ConstantString(argv[i+1]);
2557 (void) SubstituteString(&geometry,">","");
2558 (void) SubstituteString(&geometry,"<","");
2559 (void) ParseGeometry(geometry,&geometry_info);
2560 geometry=DestroyString(geometry);
2561 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2568 if (LocaleCompare("sample",option+1) == 0)
2571 Sample image with pixel replication.
2573 (void) SyncImageSettings(mogrify_info,*image,exception);
2574 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2575 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2579 if (LocaleCompare("scale",option+1) == 0)
2584 (void) SyncImageSettings(mogrify_info,*image,exception);
2585 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2586 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2590 if (LocaleCompare("selective-blur",option+1) == 0)
2593 Selectively blur pixels within a contrast threshold.
2595 (void) SyncImageSettings(mogrify_info,*image,exception);
2596 flags=ParseGeometry(argv[i+1],&geometry_info);
2597 if ((flags & PercentValue) != 0)
2598 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2599 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2600 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2603 if (LocaleCompare("separate",option+1) == 0)
2606 Break channels into separate images.
2608 (void) SyncImageSettings(mogrify_info,*image,exception);
2609 mogrify_image=SeparateImages(*image,exception);
2612 if (LocaleCompare("sepia-tone",option+1) == 0)
2620 (void) SyncImageSettings(mogrify_info,*image,exception);
2621 threshold=StringToDoubleInterval(argv[i+1],QuantumRange);
2622 mogrify_image=SepiaToneImage(*image,threshold,exception);
2625 if (LocaleCompare("segment",option+1) == 0)
2630 (void) SyncImageSettings(mogrify_info,*image,exception);
2631 flags=ParseGeometry(argv[i+1],&geometry_info);
2632 if ((flags & SigmaValue) == 0)
2633 geometry_info.sigma=1.0;
2634 (void) SegmentImage(*image,(*image)->colorspace,
2635 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2639 if (LocaleCompare("set",option+1) == 0)
2649 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2650 (void) DeleteImageRegistry(argv[i+1]+9);
2652 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2654 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2655 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2658 (void) DeleteImageProperty(*image,argv[i+1]);
2661 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2663 if (value == (char *) NULL)
2665 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2666 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2669 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2671 (void) SetImageOption(image_info,argv[i+1]+7,value);
2672 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2673 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2676 (void) SetImageProperty(*image,argv[i+1],value,exception);
2677 value=DestroyString(value);
2680 if (LocaleCompare("shade",option+1) == 0)
2685 (void) SyncImageSettings(mogrify_info,*image,exception);
2686 flags=ParseGeometry(argv[i+1],&geometry_info);
2687 if ((flags & SigmaValue) == 0)
2688 geometry_info.sigma=1.0;
2689 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2690 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2693 if (LocaleCompare("shadow",option+1) == 0)
2698 (void) SyncImageSettings(mogrify_info,*image,exception);
2699 flags=ParseGeometry(argv[i+1],&geometry_info);
2700 if ((flags & SigmaValue) == 0)
2701 geometry_info.sigma=1.0;
2702 if ((flags & XiValue) == 0)
2703 geometry_info.xi=4.0;
2704 if ((flags & PsiValue) == 0)
2705 geometry_info.psi=4.0;
2706 mogrify_image=ShadowImage(*image,geometry_info.rho,
2707 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2708 ceil(geometry_info.psi-0.5),exception);
2711 if (LocaleCompare("sharpen",option+1) == 0)
2716 (void) SyncImageSettings(mogrify_info,*image,exception);
2717 flags=ParseGeometry(argv[i+1],&geometry_info);
2718 if ((flags & SigmaValue) == 0)
2719 geometry_info.sigma=1.0;
2720 if ((flags & XiValue) == 0)
2721 geometry_info.xi=0.0;
2722 mogrify_image=SharpenImage(*image,geometry_info.rho,
2723 geometry_info.sigma,geometry_info.xi,exception);
2726 if (LocaleCompare("shave",option+1) == 0)
2729 Shave the image edges.
2731 (void) SyncImageSettings(mogrify_info,*image,exception);
2732 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2733 mogrify_image=ShaveImage(*image,&geometry,exception);
2736 if (LocaleCompare("shear",option+1) == 0)
2741 (void) SyncImageSettings(mogrify_info,*image,exception);
2742 flags=ParseGeometry(argv[i+1],&geometry_info);
2743 if ((flags & SigmaValue) == 0)
2744 geometry_info.sigma=geometry_info.rho;
2745 mogrify_image=ShearImage(*image,geometry_info.rho,
2746 geometry_info.sigma,exception);
2749 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2752 Sigmoidal non-linearity contrast control.
2754 (void) SyncImageSettings(mogrify_info,*image,exception);
2755 flags=ParseGeometry(argv[i+1],&geometry_info);
2756 if ((flags & SigmaValue) == 0)
2757 geometry_info.sigma=(double) QuantumRange/2.0;
2758 if ((flags & PercentValue) != 0)
2759 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2761 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2762 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2766 if (LocaleCompare("sketch",option+1) == 0)
2771 (void) SyncImageSettings(mogrify_info,*image,exception);
2772 flags=ParseGeometry(argv[i+1],&geometry_info);
2773 if ((flags & SigmaValue) == 0)
2774 geometry_info.sigma=1.0;
2775 mogrify_image=SketchImage(*image,geometry_info.rho,
2776 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2779 if (LocaleCompare("solarize",option+1) == 0)
2784 (void) SyncImageSettings(mogrify_info,*image,exception);
2785 threshold=StringToDoubleInterval(argv[i+1],QuantumRange);
2786 (void) SolarizeImage(*image,threshold,exception);
2789 if (LocaleCompare("sparse-color",option+1) == 0)
2798 Sparse Color Interpolated Gradient
2800 (void) SyncImageSettings(mogrify_info,*image,exception);
2801 method=(SparseColorMethod) ParseCommandOption(
2802 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2803 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2805 if (arguments == (char *) NULL)
2807 mogrify_image=SparseColorOption(*image,method,arguments,
2808 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2809 arguments=DestroyString(arguments);
2812 if (LocaleCompare("splice",option+1) == 0)
2815 Splice a solid color into the image.
2817 (void) SyncImageSettings(mogrify_info,*image,exception);
2818 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2819 mogrify_image=SpliceImage(*image,&geometry,exception);
2822 if (LocaleCompare("spread",option+1) == 0)
2827 (void) SyncImageSettings(mogrify_info,*image,exception);
2828 (void) ParseGeometry(argv[i+1],&geometry_info);
2829 mogrify_image=SpreadImage(*image,geometry_info.rho,
2830 interpolate_method,exception);
2833 if (LocaleCompare("statistic",option+1) == 0)
2838 (void) SyncImageSettings(mogrify_info,*image,exception);
2839 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2840 MagickFalse,argv[i+1]);
2841 (void) ParseGeometry(argv[i+2],&geometry_info);
2842 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2843 (size_t) geometry_info.sigma,exception);
2846 if (LocaleCompare("stretch",option+1) == 0)
2850 draw_info->stretch=UndefinedStretch;
2853 draw_info->stretch=(StretchType) ParseCommandOption(
2854 MagickStretchOptions,MagickFalse,argv[i+1]);
2857 if (LocaleCompare("strip",option+1) == 0)
2860 Strip image of profiles and comments.
2862 (void) SyncImageSettings(mogrify_info,*image,exception);
2863 (void) StripImage(*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=StringToDouble(argv[i+1],
2895 if (LocaleCompare("style",option+1) == 0)
2899 draw_info->style=UndefinedStyle;
2902 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2903 MagickFalse,argv[i+1]);
2906 if (LocaleCompare("swirl",option+1) == 0)
2911 (void) SyncImageSettings(mogrify_info,*image,exception);
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,exception);
2931 threshold=(double) QuantumRange/2;
2933 threshold=StringToDoubleInterval(argv[i+1],QuantumRange);
2934 (void) BilevelImage(*image,threshold,exception);
2937 if (LocaleCompare("thumbnail",option+1) == 0)
2942 (void) SyncImageSettings(mogrify_info,*image,exception);
2943 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2944 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2948 if (LocaleCompare("tile",option+1) == 0)
2952 if (draw_info->fill_pattern != (Image *) NULL)
2953 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2956 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2960 if (LocaleCompare("tint",option+1) == 0)
2965 (void) SyncImageSettings(mogrify_info,*image,exception);
2966 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2969 if (LocaleCompare("transform",option+1) == 0)
2972 Affine transform image.
2974 (void) SyncImageSettings(mogrify_info,*image,exception);
2975 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2979 if (LocaleCompare("transparent",option+1) == 0)
2984 (void) SyncImageSettings(mogrify_info,*image,exception);
2985 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2987 (void) TransparentPaintImage(*image,&target,(Quantum)
2988 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2992 if (LocaleCompare("transpose",option+1) == 0)
2995 Transpose image scanlines.
2997 (void) SyncImageSettings(mogrify_info,*image,exception);
2998 mogrify_image=TransposeImage(*image,exception);
3001 if (LocaleCompare("transverse",option+1) == 0)
3004 Transverse image scanlines.
3006 (void) SyncImageSettings(mogrify_info,*image,exception);
3007 mogrify_image=TransverseImage(*image,exception);
3010 if (LocaleCompare("treedepth",option+1) == 0)
3012 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3015 if (LocaleCompare("trim",option+1) == 0)
3020 (void) SyncImageSettings(mogrify_info,*image,exception);
3021 mogrify_image=TrimImage(*image,exception);
3024 if (LocaleCompare("type",option+1) == 0)
3029 (void) SyncImageSettings(mogrify_info,*image,exception);
3033 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3035 (*image)->type=UndefinedType;
3036 (void) SetImageType(*image,type,exception);
3043 if (LocaleCompare("undercolor",option+1) == 0)
3045 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3046 &draw_info->undercolor,exception);
3049 if (LocaleCompare("unique",option+1) == 0)
3053 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3056 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3057 (void) SetImageArtifact(*image,"verbose","true");
3060 if (LocaleCompare("unique-colors",option+1) == 0)
3063 Unique image colors.
3065 (void) SyncImageSettings(mogrify_info,*image,exception);
3066 mogrify_image=UniqueImageColors(*image,exception);
3069 if (LocaleCompare("unsharp",option+1) == 0)
3074 (void) SyncImageSettings(mogrify_info,*image,exception);
3075 flags=ParseGeometry(argv[i+1],&geometry_info);
3076 if ((flags & SigmaValue) == 0)
3077 geometry_info.sigma=1.0;
3078 if ((flags & XiValue) == 0)
3079 geometry_info.xi=1.0;
3080 if ((flags & PsiValue) == 0)
3081 geometry_info.psi=0.05;
3082 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3083 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3090 if (LocaleCompare("verbose",option+1) == 0)
3092 (void) SetImageArtifact(*image,option+1,
3093 *option == '+' ? "false" : "true");
3096 if (LocaleCompare("vignette",option+1) == 0)
3101 (void) SyncImageSettings(mogrify_info,*image,exception);
3102 flags=ParseGeometry(argv[i+1],&geometry_info);
3103 if ((flags & SigmaValue) == 0)
3104 geometry_info.sigma=1.0;
3105 if ((flags & XiValue) == 0)
3106 geometry_info.xi=0.1*(*image)->columns;
3107 if ((flags & PsiValue) == 0)
3108 geometry_info.psi=0.1*(*image)->rows;
3109 mogrify_image=VignetteImage(*image,geometry_info.rho,
3110 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3111 ceil(geometry_info.psi-0.5),exception);
3114 if (LocaleCompare("virtual-pixel",option+1) == 0)
3118 (void) SetImageVirtualPixelMethod(*image,
3119 UndefinedVirtualPixelMethod);
3122 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3123 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3131 if (LocaleCompare("wave",option+1) == 0)
3136 (void) SyncImageSettings(mogrify_info,*image,exception);
3137 flags=ParseGeometry(argv[i+1],&geometry_info);
3138 if ((flags & SigmaValue) == 0)
3139 geometry_info.sigma=1.0;
3140 mogrify_image=WaveImage(*image,geometry_info.rho,
3141 geometry_info.sigma,interpolate_method,exception);
3144 if (LocaleCompare("weight",option+1) == 0)
3146 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3147 if (LocaleCompare(argv[i+1],"all") == 0)
3148 draw_info->weight=0;
3149 if (LocaleCompare(argv[i+1],"bold") == 0)
3150 draw_info->weight=700;
3151 if (LocaleCompare(argv[i+1],"bolder") == 0)
3152 if (draw_info->weight <= 800)
3153 draw_info->weight+=100;
3154 if (LocaleCompare(argv[i+1],"lighter") == 0)
3155 if (draw_info->weight >= 100)
3156 draw_info->weight-=100;
3157 if (LocaleCompare(argv[i+1],"normal") == 0)
3158 draw_info->weight=400;
3161 if (LocaleCompare("white-threshold",option+1) == 0)
3164 White threshold image.
3166 (void) SyncImageSettings(mogrify_info,*image,exception);
3167 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3176 Replace current image with any image that was generated
3178 if (mogrify_image != (Image *) NULL)
3179 ReplaceImageInListReturnLast(image,mogrify_image);
3182 if (region_image != (Image *) NULL)
3185 Composite transformed region onto image.
3187 (void) SyncImageSettings(mogrify_info,*image,exception);
3188 (void) CompositeImage(region_image,region_image->matte !=
3189 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3190 region_geometry.x,region_geometry.y,exception);
3191 *image=DestroyImage(*image);
3192 *image=region_image;
3193 region_image = (Image *) NULL;
3198 quantize_info=DestroyQuantizeInfo(quantize_info);
3199 draw_info=DestroyDrawInfo(draw_info);
3200 mogrify_info=DestroyImageInfo(mogrify_info);
3201 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3202 return(status == 0 ? MagickFalse : MagickTrue);
3206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3210 + M o g r i f y I m a g e C o m m a n d %
3214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3216 % MogrifyImageCommand() transforms an image or a sequence of images. These
3217 % transforms include image scaling, image rotation, color reduction, and
3218 % others. The transmogrified image overwrites the original image.
3220 % The format of the MogrifyImageCommand method is:
3222 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3223 % const char **argv,char **metadata,ExceptionInfo *exception)
3225 % A description of each parameter follows:
3227 % o image_info: the image info.
3229 % o argc: the number of elements in the argument vector.
3231 % o argv: A text array containing the command line arguments.
3233 % o metadata: any metadata is returned here.
3235 % o exception: return any errors or warnings in this structure.
3239 static MagickBooleanType MogrifyUsage(void)
3244 "-debug events display copious debugging information",
3245 "-help print program options",
3246 "-list type print a list of supported option arguments",
3247 "-log format format of debugging information",
3248 "-version print version information",
3253 "-adaptive-blur geometry",
3254 " adaptively blur pixels; decrease effect near edges",
3255 "-adaptive-resize geometry",
3256 " adaptively resize image using 'mesh' interpolation",
3257 "-adaptive-sharpen geometry",
3258 " adaptively sharpen pixels; increase effect near edges",
3259 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3260 " transparent, extract, background, or shape",
3261 "-annotate geometry text",
3262 " annotate the image with text",
3263 "-auto-gamma automagically adjust gamma level of image",
3264 "-auto-level automagically adjust color levels of image",
3265 "-auto-orient automagically orient (rotate) image",
3266 "-bench iterations measure performance",
3267 "-black-threshold value",
3268 " force all pixels below the threshold into black",
3269 "-blue-shift simulate a scene at nighttime in the moonlight",
3270 "-blur geometry reduce image noise and reduce detail levels",
3271 "-border geometry surround image with a border of color",
3272 "-bordercolor color border color",
3273 "-brightness-contrast geometry",
3274 " improve brightness / contrast of the image",
3275 "-cdl filename color correct with a color decision list",
3276 "-charcoal geometry simulate a charcoal drawing",
3277 "-chop geometry remove pixels from the image interior",
3278 "-clamp restrict pixel range from 0 to the quantum depth",
3279 "-clip clip along the first path from the 8BIM profile",
3280 "-clip-mask filename associate a clip mask with the image",
3281 "-clip-path id clip along a named path from the 8BIM profile",
3282 "-colorize value colorize the image with the fill color",
3283 "-color-matrix matrix apply color correction to the image",
3284 "-contrast enhance or reduce the image contrast",
3285 "-contrast-stretch geometry",
3286 " improve contrast by `stretching' the intensity range",
3287 "-convolve coefficients",
3288 " apply a convolution kernel to the image",
3289 "-cycle amount cycle the image colormap",
3290 "-decipher filename convert cipher pixels to plain pixels",
3291 "-deskew threshold straighten an image",
3292 "-despeckle reduce the speckles within an image",
3293 "-distort method args",
3294 " distort images according to given method ad args",
3295 "-draw string annotate the image with a graphic primitive",
3296 "-edge radius apply a filter to detect edges in the image",
3297 "-encipher filename convert plain pixels to cipher pixels",
3298 "-emboss radius emboss an image",
3299 "-enhance apply a digital filter to enhance a noisy image",
3300 "-equalize perform histogram equalization to an image",
3301 "-evaluate operator value",
3302 " evaluate an arithmetic, relational, or logical expression",
3303 "-extent geometry set the image size",
3304 "-extract geometry extract area from image",
3305 "-fft implements the discrete Fourier transform (DFT)",
3306 "-flip flip image vertically",
3307 "-floodfill geometry color",
3308 " floodfill the image with color",
3309 "-flop flop image horizontally",
3310 "-frame geometry surround image with an ornamental border",
3311 "-function name parameters",
3312 " apply function over image values",
3313 "-gamma value level of gamma correction",
3314 "-gaussian-blur geometry",
3315 " reduce image noise and reduce detail levels",
3316 "-geometry geometry preferred size or location of the image",
3317 "-identify identify the format and characteristics of the image",
3318 "-ift implements the inverse discrete Fourier transform (DFT)",
3319 "-implode amount implode image pixels about the center",
3320 "-lat geometry local adaptive thresholding",
3321 "-layers method optimize, merge, or compare image layers",
3322 "-level value adjust the level of image contrast",
3323 "-level-colors color,color",
3324 " level image with the given colors",
3325 "-linear-stretch geometry",
3326 " improve contrast by `stretching with saturation'",
3327 "-liquid-rescale geometry",
3328 " rescale image with seam-carving",
3329 "-median geometry apply a median filter to the image",
3330 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3331 "-modulate value vary the brightness, saturation, and hue",
3332 "-monochrome transform image to black and white",
3333 "-morphology method kernel",
3334 " apply a morphology method to the image",
3335 "-motion-blur geometry",
3336 " simulate motion blur",
3337 "-negate replace every pixel with its complementary color ",
3338 "-noise geometry add or reduce noise in an image",
3339 "-normalize transform image to span the full range of colors",
3340 "-opaque color change this color to the fill color",
3341 "-ordered-dither NxN",
3342 " add a noise pattern to the image with specific",
3344 "-paint radius simulate an oil painting",
3345 "-polaroid angle simulate a Polaroid picture",
3346 "-posterize levels reduce the image to a limited number of color levels",
3347 "-profile filename add, delete, or apply an image profile",
3348 "-quantize colorspace reduce colors in this colorspace",
3349 "-radial-blur angle radial blur the image",
3350 "-raise value lighten/darken image edges to create a 3-D effect",
3351 "-random-threshold low,high",
3352 " random threshold the image",
3353 "-region geometry apply options to a portion of the image",
3354 "-render render vector graphics",
3355 "-repage geometry size and location of an image canvas",
3356 "-resample geometry change the resolution of an image",
3357 "-resize geometry resize the image",
3358 "-roll geometry roll an image vertically or horizontally",
3359 "-rotate degrees apply Paeth rotation to the image",
3360 "-sample geometry scale image with pixel sampling",
3361 "-scale geometry scale the image",
3362 "-segment values segment an image",
3363 "-selective-blur geometry",
3364 " selectively blur pixels within a contrast threshold",
3365 "-sepia-tone threshold",
3366 " simulate a sepia-toned photo",
3367 "-set property value set an image property",
3368 "-shade degrees shade the image using a distant light source",
3369 "-shadow geometry simulate an image shadow",
3370 "-sharpen geometry sharpen the image",
3371 "-shave geometry shave pixels from the image edges",
3372 "-shear geometry slide one edge of the image along the X or Y axis",
3373 "-sigmoidal-contrast geometry",
3374 " increase the contrast without saturating highlights or shadows",
3375 "-sketch geometry simulate a pencil sketch",
3376 "-solarize threshold negate all pixels above the threshold level",
3377 "-sparse-color method args",
3378 " fill in a image based on a few color points",
3379 "-splice geometry splice the background color into the image",
3380 "-spread radius displace image pixels by a random amount",
3381 "-statistic type radius",
3382 " replace each pixel with corresponding statistic from the neighborhood",
3383 "-strip strip image of all profiles and comments",
3384 "-swirl degrees swirl image pixels about the center",
3385 "-threshold value threshold the image",
3386 "-thumbnail geometry create a thumbnail of the image",
3387 "-tile filename tile image when filling a graphic primitive",
3388 "-tint value tint the image with the fill color",
3389 "-transform affine transform image",
3390 "-transparent color make this color transparent within the image",
3391 "-transpose flip image vertically and rotate 90 degrees",
3392 "-transverse flop image horizontally and rotate 270 degrees",
3393 "-trim trim image edges",
3394 "-type type image type",
3395 "-unique-colors discard all but one of any pixel color",
3396 "-unsharp geometry sharpen the image",
3397 "-vignette geometry soften the edges of the image in vignette style",
3398 "-wave geometry alter an image along a sine wave",
3399 "-white-threshold value",
3400 " force all pixels above the threshold into white",
3403 *sequence_operators[]=
3405 "-append append an image sequence",
3406 "-clut apply a color lookup table to the image",
3407 "-coalesce merge a sequence of images",
3408 "-combine combine a sequence of images",
3409 "-composite composite image",
3410 "-crop geometry cut out a rectangular region of the image",
3411 "-deconstruct break down an image sequence into constituent parts",
3412 "-evaluate-sequence operator",
3413 " evaluate an arithmetic, relational, or logical expression",
3414 "-flatten flatten a sequence of images",
3415 "-fx expression apply mathematical expression to an image channel(s)",
3416 "-hald-clut apply a Hald color lookup table to the image",
3417 "-morph value morph an image sequence",
3418 "-mosaic create a mosaic from an image sequence",
3419 "-print string interpret string and print to console",
3420 "-process arguments process the image with a custom image filter",
3421 "-separate separate an image channel into a grayscale image",
3422 "-smush geometry smush an image sequence together",
3423 "-write filename write images to this file",
3428 "-adjoin join images into a single multi-image file",
3429 "-affine matrix affine transform matrix",
3430 "-alpha option activate, deactivate, reset, or set the alpha channel",
3431 "-antialias remove pixel-aliasing",
3432 "-authenticate password",
3433 " decipher image with this password",
3434 "-attenuate value lessen (or intensify) when adding noise to an image",
3435 "-background color background color",
3436 "-bias value add bias when convolving an image",
3437 "-black-point-compensation",
3438 " use black point compensation",
3439 "-blue-primary point chromaticity blue primary point",
3440 "-bordercolor color border color",
3441 "-caption string assign a caption to an image",
3442 "-channel type apply option to select image channels",
3443 "-colors value preferred number of colors in the image",
3444 "-colorspace type alternate image colorspace",
3445 "-comment string annotate image with comment",
3446 "-compose operator set image composite operator",
3447 "-compress type type of pixel compression when writing the image",
3448 "-define format:option",
3449 " define one or more image format options",
3450 "-delay value display the next image after pausing",
3451 "-density geometry horizontal and vertical density of the image",
3452 "-depth value image depth",
3453 "-direction type render text right-to-left or left-to-right",
3454 "-display server get image or font from this X server",
3455 "-dispose method layer disposal method",
3456 "-dither method apply error diffusion to image",
3457 "-encoding type text encoding type",
3458 "-endian type endianness (MSB or LSB) of the image",
3459 "-family name render text with this font family",
3460 "-fill color color to use when filling a graphic primitive",
3461 "-filter type use this filter when resizing an image",
3462 "-font name render text with this font",
3463 "-format \"string\" output formatted image characteristics",
3464 "-fuzz distance colors within this distance are considered equal",
3465 "-gravity type horizontal and vertical text placement",
3466 "-green-primary point chromaticity green primary point",
3467 "-intent type type of rendering intent when managing the image color",
3468 "-interlace type type of image interlacing scheme",
3469 "-interline-spacing value",
3470 " set the space between two text lines",
3471 "-interpolate method pixel color interpolation method",
3472 "-interword-spacing value",
3473 " set the space between two words",
3474 "-kerning value set the space between two letters",
3475 "-label string assign a label to an image",
3476 "-limit type value pixel cache resource limit",
3477 "-loop iterations add Netscape loop extension to your GIF animation",
3478 "-mask filename associate a mask with the image",
3479 "-mattecolor color frame color",
3480 "-monitor monitor progress",
3481 "-orient type image orientation",
3482 "-page geometry size and location of an image canvas (setting)",
3483 "-ping efficiently determine image attributes",
3484 "-pointsize value font point size",
3485 "-precision value maximum number of significant digits to print",
3486 "-preview type image preview type",
3487 "-quality value JPEG/MIFF/PNG compression level",
3488 "-quiet suppress all warning messages",
3489 "-red-primary point chromaticity red primary point",
3490 "-regard-warnings pay attention to warning messages",
3491 "-remap filename transform image colors to match this set of colors",
3492 "-respect-parentheses settings remain in effect until parenthesis boundary",
3493 "-sampling-factor geometry",
3494 " horizontal and vertical sampling factor",
3495 "-scene value image scene number",
3496 "-seed value seed a new sequence of pseudo-random numbers",
3497 "-size geometry width and height of image",
3498 "-stretch type render text with this font stretch",
3499 "-stroke color graphic primitive stroke color",
3500 "-strokewidth value graphic primitive stroke width",
3501 "-style type render text with this font style",
3502 "-synchronize synchronize image to storage device",
3503 "-taint declare the image as modified",
3504 "-texture filename name of texture to tile onto the image background",
3505 "-tile-offset geometry",
3507 "-treedepth value color tree depth",
3508 "-transparent-color color",
3509 " transparent color",
3510 "-undercolor color annotation bounding box color",
3511 "-units type the units of image resolution",
3512 "-verbose print detailed information about the image",
3513 "-view FlashPix viewing transforms",
3514 "-virtual-pixel method",
3515 " virtual pixel access method",
3516 "-weight type render text with this font weight",
3517 "-white-point point chromaticity white point",
3522 "-delete indexes delete the image from the image sequence",
3523 "-duplicate count,indexes",
3524 " duplicate an image one or more times",
3525 "-insert index insert last image into the image sequence",
3526 "-reverse reverse image sequence",
3527 "-swap indexes swap two images in the image sequence",
3534 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3535 (void) printf("Copyright: %s\n",GetMagickCopyright());
3536 (void) printf("Features: %s\n\n",GetMagickFeatures());
3537 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3539 (void) printf("\nImage Settings:\n");
3540 for (p=settings; *p != (char *) NULL; p++)
3541 (void) printf(" %s\n",*p);
3542 (void) printf("\nImage Operators:\n");
3543 for (p=operators; *p != (char *) NULL; p++)
3544 (void) printf(" %s\n",*p);
3545 (void) printf("\nImage Sequence Operators:\n");
3546 for (p=sequence_operators; *p != (char *) NULL; p++)
3547 (void) printf(" %s\n",*p);
3548 (void) printf("\nImage Stack Operators:\n");
3549 for (p=stack_operators; *p != (char *) NULL; p++)
3550 (void) printf(" %s\n",*p);
3551 (void) printf("\nMiscellaneous Options:\n");
3552 for (p=miscellaneous; *p != (char *) NULL; p++)
3553 (void) printf(" %s\n",*p);
3555 "\nBy default, the image format of `file' is determined by its magic\n");
3557 "number. To specify a particular image format, precede the filename\n");
3559 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3561 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3562 (void) printf("'-' for standard input or output.\n");
3563 return(MagickFalse);
3566 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3567 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3569 #define DestroyMogrify() \
3571 if (format != (char *) NULL) \
3572 format=DestroyString(format); \
3573 if (path != (char *) NULL) \
3574 path=DestroyString(path); \
3575 DestroyImageStack(); \
3576 for (i=0; i < (ssize_t) argc; i++) \
3577 argv[i]=DestroyString(argv[i]); \
3578 argv=(char **) RelinquishMagickMemory(argv); \
3580 #define ThrowMogrifyException(asperity,tag,option) \
3582 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3585 return(MagickFalse); \
3587 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3589 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3590 "InvalidArgument","`%s': %s",argument,option); \
3592 return(MagickFalse); \
3604 image_stack[MaxImageStackDepth+1];
3612 respect_parenthesis;
3627 assert(image_info != (ImageInfo *) NULL);
3628 assert(image_info->signature == MagickSignature);
3629 if (image_info->debug != MagickFalse)
3630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3631 assert(exception != (ExceptionInfo *) NULL);
3635 if ((LocaleCompare("version",option+1) == 0) ||
3636 (LocaleCompare("-version",option+1) == 0))
3638 (void) FormatLocaleFile(stdout,"Version: %s\n",
3639 GetMagickVersion((size_t *) NULL));
3640 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3641 GetMagickCopyright());
3642 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3643 GetMagickFeatures());
3644 return(MagickFalse);
3648 return(MogrifyUsage());
3649 format=(char *) NULL;
3651 global_colormap=MagickFalse;
3655 option=(char *) NULL;
3657 respect_parenthesis=MagickFalse;
3662 ReadCommandlLine(argc,&argv);
3663 status=ExpandFilenames(&argc,&argv);
3664 if (status == MagickFalse)
3665 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3666 GetExceptionMessage(errno));
3667 for (i=1; i < (ssize_t) argc; i++)
3670 if (LocaleCompare(option,"(") == 0)
3672 FireImageStack(MagickFalse,MagickTrue,pend);
3673 if (k == MaxImageStackDepth)
3674 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3679 if (LocaleCompare(option,")") == 0)
3681 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3683 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3687 if (IsCommandOption(option) == MagickFalse)
3690 backup_filename[MaxTextExtent],
3697 Option is a file name: begin by reading image from specified file.
3699 FireImageStack(MagickFalse,MagickFalse,pend);
3701 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3703 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3704 images=ReadImages(image_info,exception);
3705 status&=(images != (Image *) NULL) &&
3706 (exception->severity < ErrorException);
3707 if (images == (Image *) NULL)
3709 if (format != (char *) NULL)
3710 (void) CopyMagickString(images->filename,images->magick_filename,
3712 if (path != (char *) NULL)
3714 GetPathComponent(option,TailPath,filename);
3715 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3716 path,*DirectorySeparator,filename);
3718 if (format != (char *) NULL)
3719 AppendImageFormat(format,images->filename);
3720 AppendImageStack(images);
3721 FinalizeImageSettings(image_info,image,MagickFalse);
3722 if (global_colormap != MagickFalse)
3727 quantize_info=AcquireQuantizeInfo(image_info);
3728 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3729 quantize_info=DestroyQuantizeInfo(quantize_info);
3731 *backup_filename='\0';
3732 if ((LocaleCompare(image->filename,"-") != 0) &&
3733 (IsPathWritable(image->filename) != MagickFalse))
3739 Rename image file as backup.
3741 (void) CopyMagickString(backup_filename,image->filename,
3743 for (i=0; i < 6; i++)
3745 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3746 if (IsPathAccessible(backup_filename) == MagickFalse)
3749 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3750 (rename_utf8(image->filename,backup_filename) != 0))
3751 *backup_filename='\0';
3754 Write transmogrified image to disk.
3756 image_info->synchronize=MagickTrue;
3757 status&=WriteImages(image_info,image,image->filename,exception);
3758 if ((status == MagickFalse) && (*backup_filename != '\0'))
3759 (void) remove_utf8(backup_filename);
3760 RemoveAllImageStack();
3763 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3764 switch (*(option+1))
3768 if (LocaleCompare("adaptive-blur",option+1) == 0)
3771 if (i == (ssize_t) argc)
3772 ThrowMogrifyException(OptionError,"MissingArgument",option);
3773 if (IsGeometry(argv[i]) == MagickFalse)
3774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3777 if (LocaleCompare("adaptive-resize",option+1) == 0)
3780 if (i == (ssize_t) argc)
3781 ThrowMogrifyException(OptionError,"MissingArgument",option);
3782 if (IsGeometry(argv[i]) == MagickFalse)
3783 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3786 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3789 if (i == (ssize_t) argc)
3790 ThrowMogrifyException(OptionError,"MissingArgument",option);
3791 if (IsGeometry(argv[i]) == MagickFalse)
3792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3795 if (LocaleCompare("affine",option+1) == 0)
3800 if (i == (ssize_t) argc)
3801 ThrowMogrifyException(OptionError,"MissingArgument",option);
3804 if (LocaleCompare("alpha",option+1) == 0)
3812 if (i == (ssize_t) argc)
3813 ThrowMogrifyException(OptionError,"MissingArgument",option);
3814 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3816 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3820 if (LocaleCompare("annotate",option+1) == 0)
3825 if (i == (ssize_t) argc)
3826 ThrowMogrifyException(OptionError,"MissingArgument",option);
3827 if (IsGeometry(argv[i]) == MagickFalse)
3828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3829 if (i == (ssize_t) argc)
3830 ThrowMogrifyException(OptionError,"MissingArgument",option);
3834 if (LocaleCompare("antialias",option+1) == 0)
3836 if (LocaleCompare("append",option+1) == 0)
3838 if (LocaleCompare("attenuate",option+1) == 0)
3843 if (i == (ssize_t) (argc-1))
3844 ThrowMogrifyException(OptionError,"MissingArgument",option);
3845 if (IsGeometry(argv[i]) == MagickFalse)
3846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3849 if (LocaleCompare("authenticate",option+1) == 0)
3854 if (i == (ssize_t) argc)
3855 ThrowMogrifyException(OptionError,"MissingArgument",option);
3858 if (LocaleCompare("auto-gamma",option+1) == 0)
3860 if (LocaleCompare("auto-level",option+1) == 0)
3862 if (LocaleCompare("auto-orient",option+1) == 0)
3864 if (LocaleCompare("average",option+1) == 0)
3866 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3870 if (LocaleCompare("background",option+1) == 0)
3875 if (i == (ssize_t) argc)
3876 ThrowMogrifyException(OptionError,"MissingArgument",option);
3879 if (LocaleCompare("bias",option+1) == 0)
3884 if (i == (ssize_t) (argc-1))
3885 ThrowMogrifyException(OptionError,"MissingArgument",option);
3886 if (IsGeometry(argv[i]) == MagickFalse)
3887 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3890 if (LocaleCompare("black-point-compensation",option+1) == 0)
3892 if (LocaleCompare("black-threshold",option+1) == 0)
3897 if (i == (ssize_t) argc)
3898 ThrowMogrifyException(OptionError,"MissingArgument",option);
3899 if (IsGeometry(argv[i]) == MagickFalse)
3900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3903 if (LocaleCompare("blue-primary",option+1) == 0)
3908 if (i == (ssize_t) argc)
3909 ThrowMogrifyException(OptionError,"MissingArgument",option);
3910 if (IsGeometry(argv[i]) == MagickFalse)
3911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3914 if (LocaleCompare("blue-shift",option+1) == 0)
3917 if (i == (ssize_t) argc)
3918 ThrowMogrifyException(OptionError,"MissingArgument",option);
3919 if (IsGeometry(argv[i]) == MagickFalse)
3920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3923 if (LocaleCompare("blur",option+1) == 0)
3926 if (i == (ssize_t) argc)
3927 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (IsGeometry(argv[i]) == MagickFalse)
3929 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3932 if (LocaleCompare("border",option+1) == 0)
3937 if (i == (ssize_t) argc)
3938 ThrowMogrifyException(OptionError,"MissingArgument",option);
3939 if (IsGeometry(argv[i]) == MagickFalse)
3940 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3943 if (LocaleCompare("bordercolor",option+1) == 0)
3948 if (i == (ssize_t) argc)
3949 ThrowMogrifyException(OptionError,"MissingArgument",option);
3952 if (LocaleCompare("box",option+1) == 0)
3957 if (i == (ssize_t) argc)
3958 ThrowMogrifyException(OptionError,"MissingArgument",option);
3961 if (LocaleCompare("brightness-contrast",option+1) == 0)
3964 if (i == (ssize_t) argc)
3965 ThrowMogrifyException(OptionError,"MissingArgument",option);
3966 if (IsGeometry(argv[i]) == MagickFalse)
3967 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3970 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3974 if (LocaleCompare("cache",option+1) == 0)
3979 if (i == (ssize_t) argc)
3980 ThrowMogrifyException(OptionError,"MissingArgument",option);
3981 if (IsGeometry(argv[i]) == MagickFalse)
3982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3985 if (LocaleCompare("caption",option+1) == 0)
3990 if (i == (ssize_t) argc)
3991 ThrowMogrifyException(OptionError,"MissingArgument",option);
3994 if (LocaleCompare("channel",option+1) == 0)
4002 if (i == (ssize_t) (argc-1))
4003 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 channel=ParseChannelOption(argv[i]);
4006 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4010 if (LocaleCompare("cdl",option+1) == 0)
4015 if (i == (ssize_t) (argc-1))
4016 ThrowMogrifyException(OptionError,"MissingArgument",option);
4019 if (LocaleCompare("charcoal",option+1) == 0)
4024 if (i == (ssize_t) argc)
4025 ThrowMogrifyException(OptionError,"MissingArgument",option);
4026 if (IsGeometry(argv[i]) == MagickFalse)
4027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4030 if (LocaleCompare("chop",option+1) == 0)
4035 if (i == (ssize_t) argc)
4036 ThrowMogrifyException(OptionError,"MissingArgument",option);
4037 if (IsGeometry(argv[i]) == MagickFalse)
4038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4041 if (LocaleCompare("clamp",option+1) == 0)
4043 if (LocaleCompare("clip",option+1) == 0)
4045 if (LocaleCompare("clip-mask",option+1) == 0)
4050 if (i == (ssize_t) argc)
4051 ThrowMogrifyException(OptionError,"MissingArgument",option);
4054 if (LocaleCompare("clut",option+1) == 0)
4056 if (LocaleCompare("coalesce",option+1) == 0)
4058 if (LocaleCompare("colorize",option+1) == 0)
4063 if (i == (ssize_t) argc)
4064 ThrowMogrifyException(OptionError,"MissingArgument",option);
4065 if (IsGeometry(argv[i]) == MagickFalse)
4066 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4069 if (LocaleCompare("color-matrix",option+1) == 0)
4077 if (i == (ssize_t) (argc-1))
4078 ThrowMogrifyException(OptionError,"MissingArgument",option);
4079 kernel_info=AcquireKernelInfo(argv[i]);
4080 if (kernel_info == (KernelInfo *) NULL)
4081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4082 kernel_info=DestroyKernelInfo(kernel_info);
4085 if (LocaleCompare("colors",option+1) == 0)
4090 if (i == (ssize_t) argc)
4091 ThrowMogrifyException(OptionError,"MissingArgument",option);
4092 if (IsGeometry(argv[i]) == MagickFalse)
4093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4096 if (LocaleCompare("colorspace",option+1) == 0)
4104 if (i == (ssize_t) argc)
4105 ThrowMogrifyException(OptionError,"MissingArgument",option);
4106 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4109 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4113 if (LocaleCompare("combine",option+1) == 0)
4115 if (LocaleCompare("comment",option+1) == 0)
4120 if (i == (ssize_t) argc)
4121 ThrowMogrifyException(OptionError,"MissingArgument",option);
4124 if (LocaleCompare("composite",option+1) == 0)
4126 if (LocaleCompare("compress",option+1) == 0)
4134 if (i == (ssize_t) argc)
4135 ThrowMogrifyException(OptionError,"MissingArgument",option);
4136 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4139 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4143 if (LocaleCompare("concurrent",option+1) == 0)
4145 if (LocaleCompare("contrast",option+1) == 0)
4147 if (LocaleCompare("contrast-stretch",option+1) == 0)
4150 if (i == (ssize_t) argc)
4151 ThrowMogrifyException(OptionError,"MissingArgument",option);
4152 if (IsGeometry(argv[i]) == MagickFalse)
4153 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4156 if (LocaleCompare("convolve",option+1) == 0)
4164 if (i == (ssize_t) argc)
4165 ThrowMogrifyException(OptionError,"MissingArgument",option);
4166 kernel_info=AcquireKernelInfo(argv[i]);
4167 if (kernel_info == (KernelInfo *) NULL)
4168 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4169 kernel_info=DestroyKernelInfo(kernel_info);
4172 if (LocaleCompare("crop",option+1) == 0)
4177 if (i == (ssize_t) argc)
4178 ThrowMogrifyException(OptionError,"MissingArgument",option);
4179 if (IsGeometry(argv[i]) == MagickFalse)
4180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4183 if (LocaleCompare("cycle",option+1) == 0)
4188 if (i == (ssize_t) argc)
4189 ThrowMogrifyException(OptionError,"MissingArgument",option);
4190 if (IsGeometry(argv[i]) == MagickFalse)
4191 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4198 if (LocaleCompare("decipher",option+1) == 0)
4203 if (i == (ssize_t) (argc-1))
4204 ThrowMogrifyException(OptionError,"MissingArgument",option);
4207 if (LocaleCompare("deconstruct",option+1) == 0)
4209 if (LocaleCompare("debug",option+1) == 0)
4217 if (i == (ssize_t) argc)
4218 ThrowMogrifyException(OptionError,"MissingArgument",option);
4219 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4221 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4223 (void) SetLogEventMask(argv[i]);
4226 if (LocaleCompare("define",option+1) == 0)
4229 if (i == (ssize_t) argc)
4230 ThrowMogrifyException(OptionError,"MissingArgument",option);
4236 define=GetImageOption(image_info,argv[i]);
4237 if (define == (const char *) NULL)
4238 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4243 if (LocaleCompare("delay",option+1) == 0)
4248 if (i == (ssize_t) argc)
4249 ThrowMogrifyException(OptionError,"MissingArgument",option);
4250 if (IsGeometry(argv[i]) == MagickFalse)
4251 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4254 if (LocaleCompare("delete",option+1) == 0)
4259 if (i == (ssize_t) (argc-1))
4260 ThrowMogrifyException(OptionError,"MissingArgument",option);
4261 if (IsGeometry(argv[i]) == MagickFalse)
4262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4265 if (LocaleCompare("density",option+1) == 0)
4270 if (i == (ssize_t) argc)
4271 ThrowMogrifyException(OptionError,"MissingArgument",option);
4272 if (IsGeometry(argv[i]) == MagickFalse)
4273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4276 if (LocaleCompare("depth",option+1) == 0)
4281 if (i == (ssize_t) argc)
4282 ThrowMogrifyException(OptionError,"MissingArgument",option);
4283 if (IsGeometry(argv[i]) == MagickFalse)
4284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4287 if (LocaleCompare("deskew",option+1) == 0)
4292 if (i == (ssize_t) argc)
4293 ThrowMogrifyException(OptionError,"MissingArgument",option);
4294 if (IsGeometry(argv[i]) == MagickFalse)
4295 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4298 if (LocaleCompare("despeckle",option+1) == 0)
4300 if (LocaleCompare("dft",option+1) == 0)
4302 if (LocaleCompare("direction",option+1) == 0)
4310 if (i == (ssize_t) argc)
4311 ThrowMogrifyException(OptionError,"MissingArgument",option);
4312 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4315 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4319 if (LocaleCompare("display",option+1) == 0)
4324 if (i == (ssize_t) argc)
4325 ThrowMogrifyException(OptionError,"MissingArgument",option);
4328 if (LocaleCompare("dispose",option+1) == 0)
4336 if (i == (ssize_t) argc)
4337 ThrowMogrifyException(OptionError,"MissingArgument",option);
4338 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4340 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4344 if (LocaleCompare("distort",option+1) == 0)
4350 if (i == (ssize_t) argc)
4351 ThrowMogrifyException(OptionError,"MissingArgument",option);
4352 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4354 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4357 if (i == (ssize_t) (argc-1))
4358 ThrowMogrifyException(OptionError,"MissingArgument",option);
4361 if (LocaleCompare("dither",option+1) == 0)
4369 if (i == (ssize_t) argc)
4370 ThrowMogrifyException(OptionError,"MissingArgument",option);
4371 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4373 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4377 if (LocaleCompare("draw",option+1) == 0)
4382 if (i == (ssize_t) argc)
4383 ThrowMogrifyException(OptionError,"MissingArgument",option);
4386 if (LocaleCompare("duplicate",option+1) == 0)
4391 if (i == (ssize_t) (argc-1))
4392 ThrowMogrifyException(OptionError,"MissingArgument",option);
4393 if (IsGeometry(argv[i]) == MagickFalse)
4394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4397 if (LocaleCompare("duration",option+1) == 0)
4402 if (i == (ssize_t) (argc-1))
4403 ThrowMogrifyException(OptionError,"MissingArgument",option);
4404 if (IsGeometry(argv[i]) == MagickFalse)
4405 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4408 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4412 if (LocaleCompare("edge",option+1) == 0)
4417 if (i == (ssize_t) argc)
4418 ThrowMogrifyException(OptionError,"MissingArgument",option);
4419 if (IsGeometry(argv[i]) == MagickFalse)
4420 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4423 if (LocaleCompare("emboss",option+1) == 0)
4428 if (i == (ssize_t) argc)
4429 ThrowMogrifyException(OptionError,"MissingArgument",option);
4430 if (IsGeometry(argv[i]) == MagickFalse)
4431 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4434 if (LocaleCompare("encipher",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4443 if (LocaleCompare("encoding",option+1) == 0)
4448 if (i == (ssize_t) argc)
4449 ThrowMogrifyException(OptionError,"MissingArgument",option);
4452 if (LocaleCompare("endian",option+1) == 0)
4460 if (i == (ssize_t) argc)
4461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4464 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4468 if (LocaleCompare("enhance",option+1) == 0)
4470 if (LocaleCompare("equalize",option+1) == 0)
4472 if (LocaleCompare("evaluate",option+1) == 0)
4480 if (i == (ssize_t) argc)
4481 ThrowMogrifyException(OptionError,"MissingArgument",option);
4482 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4484 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4487 if (i == (ssize_t) (argc-1))
4488 ThrowMogrifyException(OptionError,"MissingArgument",option);
4489 if (IsGeometry(argv[i]) == MagickFalse)
4490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4493 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4501 if (i == (ssize_t) argc)
4502 ThrowMogrifyException(OptionError,"MissingArgument",option);
4503 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4505 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4509 if (LocaleCompare("extent",option+1) == 0)
4514 if (i == (ssize_t) argc)
4515 ThrowMogrifyException(OptionError,"MissingArgument",option);
4516 if (IsGeometry(argv[i]) == MagickFalse)
4517 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4520 if (LocaleCompare("extract",option+1) == 0)
4525 if (i == (ssize_t) argc)
4526 ThrowMogrifyException(OptionError,"MissingArgument",option);
4527 if (IsGeometry(argv[i]) == MagickFalse)
4528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4531 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4535 if (LocaleCompare("family",option+1) == 0)
4540 if (i == (ssize_t) (argc-1))
4541 ThrowMogrifyException(OptionError,"MissingArgument",option);
4544 if (LocaleCompare("fill",option+1) == 0)
4549 if (i == (ssize_t) argc)
4550 ThrowMogrifyException(OptionError,"MissingArgument",option);
4553 if (LocaleCompare("filter",option+1) == 0)
4561 if (i == (ssize_t) argc)
4562 ThrowMogrifyException(OptionError,"MissingArgument",option);
4563 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4565 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4569 if (LocaleCompare("flatten",option+1) == 0)
4571 if (LocaleCompare("flip",option+1) == 0)
4573 if (LocaleCompare("flop",option+1) == 0)
4575 if (LocaleCompare("floodfill",option+1) == 0)
4580 if (i == (ssize_t) argc)
4581 ThrowMogrifyException(OptionError,"MissingArgument",option);
4582 if (IsGeometry(argv[i]) == MagickFalse)
4583 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4585 if (i == (ssize_t) argc)
4586 ThrowMogrifyException(OptionError,"MissingArgument",option);
4589 if (LocaleCompare("font",option+1) == 0)
4594 if (i == (ssize_t) argc)
4595 ThrowMogrifyException(OptionError,"MissingArgument",option);
4598 if (LocaleCompare("format",option+1) == 0)
4600 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4601 (void) CloneString(&format,(char *) NULL);
4605 if (i == (ssize_t) argc)
4606 ThrowMogrifyException(OptionError,"MissingArgument",option);
4607 (void) CloneString(&format,argv[i]);
4608 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4609 (void) ConcatenateMagickString(image_info->filename,":",
4611 (void) SetImageInfo(image_info,0,exception);
4612 if (*image_info->magick == '\0')
4613 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4617 if (LocaleCompare("frame",option+1) == 0)
4622 if (i == (ssize_t) argc)
4623 ThrowMogrifyException(OptionError,"MissingArgument",option);
4624 if (IsGeometry(argv[i]) == MagickFalse)
4625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4628 if (LocaleCompare("function",option+1) == 0)
4636 if (i == (ssize_t) argc)
4637 ThrowMogrifyException(OptionError,"MissingArgument",option);
4638 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4640 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4642 if (i == (ssize_t) (argc-1))
4643 ThrowMogrifyException(OptionError,"MissingArgument",option);
4646 if (LocaleCompare("fuzz",option+1) == 0)
4651 if (i == (ssize_t) argc)
4652 ThrowMogrifyException(OptionError,"MissingArgument",option);
4653 if (IsGeometry(argv[i]) == MagickFalse)
4654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4657 if (LocaleCompare("fx",option+1) == 0)
4662 if (i == (ssize_t) (argc-1))
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4666 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4670 if (LocaleCompare("gamma",option+1) == 0)
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,"MissingArgument",option);
4675 if (IsGeometry(argv[i]) == MagickFalse)
4676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4679 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4680 (LocaleCompare("gaussian",option+1) == 0))
4683 if (i == (ssize_t) argc)
4684 ThrowMogrifyException(OptionError,"MissingArgument",option);
4685 if (IsGeometry(argv[i]) == MagickFalse)
4686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4689 if (LocaleCompare("geometry",option+1) == 0)
4694 if (i == (ssize_t) argc)
4695 ThrowMogrifyException(OptionError,"MissingArgument",option);
4696 if (IsGeometry(argv[i]) == MagickFalse)
4697 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4700 if (LocaleCompare("gravity",option+1) == 0)
4708 if (i == (ssize_t) argc)
4709 ThrowMogrifyException(OptionError,"MissingArgument",option);
4710 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4712 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4716 if (LocaleCompare("green-primary",option+1) == 0)
4721 if (i == (ssize_t) argc)
4722 ThrowMogrifyException(OptionError,"MissingArgument",option);
4723 if (IsGeometry(argv[i]) == MagickFalse)
4724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4727 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4731 if (LocaleCompare("hald-clut",option+1) == 0)
4733 if ((LocaleCompare("help",option+1) == 0) ||
4734 (LocaleCompare("-help",option+1) == 0))
4735 return(MogrifyUsage());
4736 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4740 if (LocaleCompare("identify",option+1) == 0)
4742 if (LocaleCompare("idft",option+1) == 0)
4744 if (LocaleCompare("implode",option+1) == 0)
4749 if (i == (ssize_t) argc)
4750 ThrowMogrifyException(OptionError,"MissingArgument",option);
4751 if (IsGeometry(argv[i]) == MagickFalse)
4752 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4755 if (LocaleCompare("intent",option+1) == 0)
4763 if (i == (ssize_t) (argc-1))
4764 ThrowMogrifyException(OptionError,"MissingArgument",option);
4765 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4767 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4771 if (LocaleCompare("interlace",option+1) == 0)
4779 if (i == (ssize_t) argc)
4780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4781 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4784 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4788 if (LocaleCompare("interline-spacing",option+1) == 0)
4793 if (i == (ssize_t) (argc-1))
4794 ThrowMogrifyException(OptionError,"MissingArgument",option);
4795 if (IsGeometry(argv[i]) == MagickFalse)
4796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4799 if (LocaleCompare("interpolate",option+1) == 0)
4807 if (i == (ssize_t) argc)
4808 ThrowMogrifyException(OptionError,"MissingArgument",option);
4809 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4811 if (interpolate < 0)
4812 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4816 if (LocaleCompare("interword-spacing",option+1) == 0)
4821 if (i == (ssize_t) (argc-1))
4822 ThrowMogrifyException(OptionError,"MissingArgument",option);
4823 if (IsGeometry(argv[i]) == MagickFalse)
4824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4827 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4831 if (LocaleCompare("kerning",option+1) == 0)
4836 if (i == (ssize_t) (argc-1))
4837 ThrowMogrifyException(OptionError,"MissingArgument",option);
4838 if (IsGeometry(argv[i]) == MagickFalse)
4839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4842 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4846 if (LocaleCompare("label",option+1) == 0)
4851 if (i == (ssize_t) argc)
4852 ThrowMogrifyException(OptionError,"MissingArgument",option);
4855 if (LocaleCompare("lat",option+1) == 0)
4860 if (i == (ssize_t) argc)
4861 ThrowMogrifyException(OptionError,"MissingArgument",option);
4862 if (IsGeometry(argv[i]) == MagickFalse)
4863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4865 if (LocaleCompare("layers",option+1) == 0)
4873 if (i == (ssize_t) (argc-1))
4874 ThrowMogrifyException(OptionError,"MissingArgument",option);
4875 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4877 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4881 if (LocaleCompare("level",option+1) == 0)
4884 if (i == (ssize_t) argc)
4885 ThrowMogrifyException(OptionError,"MissingArgument",option);
4886 if (IsGeometry(argv[i]) == MagickFalse)
4887 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4890 if (LocaleCompare("level-colors",option+1) == 0)
4893 if (i == (ssize_t) argc)
4894 ThrowMogrifyException(OptionError,"MissingArgument",option);
4897 if (LocaleCompare("linewidth",option+1) == 0)
4902 if (i == (ssize_t) argc)
4903 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 if (IsGeometry(argv[i]) == MagickFalse)
4905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4908 if (LocaleCompare("limit",option+1) == 0)
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,"MissingArgument",option);
4924 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4927 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4930 if (i == (ssize_t) argc)
4931 ThrowMogrifyException(OptionError,"MissingArgument",option);
4932 value=StringToDouble(argv[i],&p);
4934 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4938 if (LocaleCompare("liquid-rescale",option+1) == 0)
4941 if (i == (ssize_t) argc)
4942 ThrowMogrifyException(OptionError,"MissingArgument",option);
4943 if (IsGeometry(argv[i]) == MagickFalse)
4944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4947 if (LocaleCompare("list",option+1) == 0)
4955 if (i == (ssize_t) argc)
4956 ThrowMogrifyException(OptionError,"MissingArgument",option);
4957 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4959 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4960 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4962 return(status != 0 ? MagickFalse : MagickTrue);
4964 if (LocaleCompare("log",option+1) == 0)
4969 if ((i == (ssize_t) argc) ||
4970 (strchr(argv[i],'%') == (char *) NULL))
4971 ThrowMogrifyException(OptionError,"MissingArgument",option);
4974 if (LocaleCompare("loop",option+1) == 0)
4979 if (i == (ssize_t) argc)
4980 ThrowMogrifyException(OptionError,"MissingArgument",option);
4981 if (IsGeometry(argv[i]) == MagickFalse)
4982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4985 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4989 if (LocaleCompare("map",option+1) == 0)
4991 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4999 if (LocaleCompare("mask",option+1) == 0)
5004 if (i == (ssize_t) argc)
5005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5008 if (LocaleCompare("matte",option+1) == 0)
5010 if (LocaleCompare("mattecolor",option+1) == 0)
5015 if (i == (ssize_t) argc)
5016 ThrowMogrifyException(OptionError,"MissingArgument",option);
5019 if (LocaleCompare("maximum",option+1) == 0)
5021 if (LocaleCompare("minimum",option+1) == 0)
5023 if (LocaleCompare("modulate",option+1) == 0)
5028 if (i == (ssize_t) argc)
5029 ThrowMogrifyException(OptionError,"MissingArgument",option);
5030 if (IsGeometry(argv[i]) == MagickFalse)
5031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5034 if (LocaleCompare("median",option+1) == 0)
5039 if (i == (ssize_t) argc)
5040 ThrowMogrifyException(OptionError,"MissingArgument",option);
5041 if (IsGeometry(argv[i]) == MagickFalse)
5042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5045 if (LocaleCompare("mode",option+1) == 0)
5050 if (i == (ssize_t) argc)
5051 ThrowMogrifyException(OptionError,"MissingArgument",option);
5052 if (IsGeometry(argv[i]) == MagickFalse)
5053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5056 if (LocaleCompare("monitor",option+1) == 0)
5058 if (LocaleCompare("monochrome",option+1) == 0)
5060 if (LocaleCompare("morph",option+1) == 0)
5065 if (i == (ssize_t) (argc-1))
5066 ThrowMogrifyException(OptionError,"MissingArgument",option);
5067 if (IsGeometry(argv[i]) == MagickFalse)
5068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5071 if (LocaleCompare("morphology",option+1) == 0)
5074 token[MaxTextExtent];
5083 if (i == (ssize_t) argc)
5084 ThrowMogrifyException(OptionError,"MissingArgument",option);
5085 GetMagickToken(argv[i],NULL,token);
5086 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5088 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5091 if (i == (ssize_t) (argc-1))
5092 ThrowMogrifyException(OptionError,"MissingArgument",option);
5093 kernel_info=AcquireKernelInfo(argv[i]);
5094 if (kernel_info == (KernelInfo *) NULL)
5095 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5096 kernel_info=DestroyKernelInfo(kernel_info);
5099 if (LocaleCompare("mosaic",option+1) == 0)
5101 if (LocaleCompare("motion-blur",option+1) == 0)
5106 if (i == (ssize_t) argc)
5107 ThrowMogrifyException(OptionError,"MissingArgument",option);
5108 if (IsGeometry(argv[i]) == MagickFalse)
5109 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5112 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5116 if (LocaleCompare("negate",option+1) == 0)
5118 if (LocaleCompare("noise",option+1) == 0)
5121 if (i == (ssize_t) argc)
5122 ThrowMogrifyException(OptionError,"MissingArgument",option);
5128 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5130 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5134 if (IsGeometry(argv[i]) == MagickFalse)
5135 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5138 if (LocaleCompare("noop",option+1) == 0)
5140 if (LocaleCompare("normalize",option+1) == 0)
5142 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5146 if (LocaleCompare("opaque",option+1) == 0)
5149 if (i == (ssize_t) argc)
5150 ThrowMogrifyException(OptionError,"MissingArgument",option);
5153 if (LocaleCompare("ordered-dither",option+1) == 0)
5158 if (i == (ssize_t) argc)
5159 ThrowMogrifyException(OptionError,"MissingArgument",option);
5162 if (LocaleCompare("orient",option+1) == 0)
5167 orientation=UndefinedOrientation;
5171 if (i == (ssize_t) (argc-1))
5172 ThrowMogrifyException(OptionError,"MissingArgument",option);
5173 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5175 if (orientation < 0)
5176 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5180 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5184 if (LocaleCompare("page",option+1) == 0)
5189 if (i == (ssize_t) argc)
5190 ThrowMogrifyException(OptionError,"MissingArgument",option);
5193 if (LocaleCompare("paint",option+1) == 0)
5198 if (i == (ssize_t) argc)
5199 ThrowMogrifyException(OptionError,"MissingArgument",option);
5200 if (IsGeometry(argv[i]) == MagickFalse)
5201 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5204 if (LocaleCompare("path",option+1) == 0)
5206 (void) CloneString(&path,(char *) NULL);
5210 if (i == (ssize_t) argc)
5211 ThrowMogrifyException(OptionError,"MissingArgument",option);
5212 (void) CloneString(&path,argv[i]);
5215 if (LocaleCompare("pointsize",option+1) == 0)
5220 if (i == (ssize_t) argc)
5221 ThrowMogrifyException(OptionError,"MissingArgument",option);
5222 if (IsGeometry(argv[i]) == MagickFalse)
5223 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5226 if (LocaleCompare("polaroid",option+1) == 0)
5231 if (i == (ssize_t) argc)
5232 ThrowMogrifyException(OptionError,"MissingArgument",option);
5233 if (IsGeometry(argv[i]) == MagickFalse)
5234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5237 if (LocaleCompare("posterize",option+1) == 0)
5242 if (i == (ssize_t) argc)
5243 ThrowMogrifyException(OptionError,"MissingArgument",option);
5244 if (IsGeometry(argv[i]) == MagickFalse)
5245 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5248 if (LocaleCompare("precision",option+1) == 0)
5253 if (i == (ssize_t) argc)
5254 ThrowMogrifyException(OptionError,"MissingArgument",option);
5255 if (IsGeometry(argv[i]) == MagickFalse)
5256 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5259 if (LocaleCompare("print",option+1) == 0)
5264 if (i == (ssize_t) argc)
5265 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 if (LocaleCompare("process",option+1) == 0)
5273 if (i == (ssize_t) (argc-1))
5274 ThrowMogrifyException(OptionError,"MissingArgument",option);
5277 if (LocaleCompare("profile",option+1) == 0)
5280 if (i == (ssize_t) argc)
5281 ThrowMogrifyException(OptionError,"MissingArgument",option);
5284 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5288 if (LocaleCompare("quality",option+1) == 0)
5293 if (i == (ssize_t) argc)
5294 ThrowMogrifyException(OptionError,"MissingArgument",option);
5295 if (IsGeometry(argv[i]) == MagickFalse)
5296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5299 if (LocaleCompare("quantize",option+1) == 0)
5307 if (i == (ssize_t) (argc-1))
5308 ThrowMogrifyException(OptionError,"MissingArgument",option);
5309 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5312 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5316 if (LocaleCompare("quiet",option+1) == 0)
5318 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5322 if (LocaleCompare("radial-blur",option+1) == 0)
5325 if (i == (ssize_t) argc)
5326 ThrowMogrifyException(OptionError,"MissingArgument",option);
5327 if (IsGeometry(argv[i]) == MagickFalse)
5328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5331 if (LocaleCompare("raise",option+1) == 0)
5334 if (i == (ssize_t) argc)
5335 ThrowMogrifyException(OptionError,"MissingArgument",option);
5336 if (IsGeometry(argv[i]) == MagickFalse)
5337 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5340 if (LocaleCompare("random-threshold",option+1) == 0)
5345 if (i == (ssize_t) argc)
5346 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 if (IsGeometry(argv[i]) == MagickFalse)
5348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351 if (LocaleCompare("recolor",option+1) == 0)
5356 if (i == (ssize_t) (argc-1))
5357 ThrowMogrifyException(OptionError,"MissingArgument",option);
5358 if (IsGeometry(argv[i]) == MagickFalse)
5359 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5362 if (LocaleCompare("red-primary",option+1) == 0)
5367 if (i == (ssize_t) argc)
5368 ThrowMogrifyException(OptionError,"MissingArgument",option);
5369 if (IsGeometry(argv[i]) == MagickFalse)
5370 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5372 if (LocaleCompare("regard-warnings",option+1) == 0)
5374 if (LocaleCompare("region",option+1) == 0)
5379 if (i == (ssize_t) argc)
5380 ThrowMogrifyException(OptionError,"MissingArgument",option);
5381 if (IsGeometry(argv[i]) == MagickFalse)
5382 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5385 if (LocaleCompare("remap",option+1) == 0)
5390 if (i == (ssize_t) (argc-1))
5391 ThrowMogrifyException(OptionError,"MissingArgument",option);
5394 if (LocaleCompare("render",option+1) == 0)
5396 if (LocaleCompare("repage",option+1) == 0)
5401 if (i == (ssize_t) argc)
5402 ThrowMogrifyException(OptionError,"MissingArgument",option);
5403 if (IsGeometry(argv[i]) == MagickFalse)
5404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5407 if (LocaleCompare("resample",option+1) == 0)
5412 if (i == (ssize_t) argc)
5413 ThrowMogrifyException(OptionError,"MissingArgument",option);
5414 if (IsGeometry(argv[i]) == MagickFalse)
5415 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5418 if (LocaleCompare("resize",option+1) == 0)
5423 if (i == (ssize_t) argc)
5424 ThrowMogrifyException(OptionError,"MissingArgument",option);
5425 if (IsGeometry(argv[i]) == MagickFalse)
5426 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5429 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5431 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5434 if (LocaleCompare("reverse",option+1) == 0)
5436 if (LocaleCompare("roll",option+1) == 0)
5441 if (i == (ssize_t) argc)
5442 ThrowMogrifyException(OptionError,"MissingArgument",option);
5443 if (IsGeometry(argv[i]) == MagickFalse)
5444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5447 if (LocaleCompare("rotate",option+1) == 0)
5450 if (i == (ssize_t) argc)
5451 ThrowMogrifyException(OptionError,"MissingArgument",option);
5452 if (IsGeometry(argv[i]) == MagickFalse)
5453 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5456 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5460 if (LocaleCompare("sample",option+1) == 0)
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,"MissingArgument",option);
5467 if (IsGeometry(argv[i]) == MagickFalse)
5468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5471 if (LocaleCompare("sampling-factor",option+1) == 0)
5476 if (i == (ssize_t) argc)
5477 ThrowMogrifyException(OptionError,"MissingArgument",option);
5478 if (IsGeometry(argv[i]) == MagickFalse)
5479 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5482 if (LocaleCompare("scale",option+1) == 0)
5487 if (i == (ssize_t) argc)
5488 ThrowMogrifyException(OptionError,"MissingArgument",option);
5489 if (IsGeometry(argv[i]) == MagickFalse)
5490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5493 if (LocaleCompare("scene",option+1) == 0)
5498 if (i == (ssize_t) argc)
5499 ThrowMogrifyException(OptionError,"MissingArgument",option);
5500 if (IsGeometry(argv[i]) == MagickFalse)
5501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5504 if (LocaleCompare("seed",option+1) == 0)
5509 if (i == (ssize_t) argc)
5510 ThrowMogrifyException(OptionError,"MissingArgument",option);
5511 if (IsGeometry(argv[i]) == MagickFalse)
5512 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5515 if (LocaleCompare("segment",option+1) == 0)
5520 if (i == (ssize_t) argc)
5521 ThrowMogrifyException(OptionError,"MissingArgument",option);
5522 if (IsGeometry(argv[i]) == MagickFalse)
5523 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5526 if (LocaleCompare("selective-blur",option+1) == 0)
5529 if (i == (ssize_t) argc)
5530 ThrowMogrifyException(OptionError,"MissingArgument",option);
5531 if (IsGeometry(argv[i]) == MagickFalse)
5532 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5535 if (LocaleCompare("separate",option+1) == 0)
5537 if (LocaleCompare("sepia-tone",option+1) == 0)
5542 if (i == (ssize_t) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5544 if (IsGeometry(argv[i]) == MagickFalse)
5545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5548 if (LocaleCompare("set",option+1) == 0)
5551 if (i == (ssize_t) argc)
5552 ThrowMogrifyException(OptionError,"MissingArgument",option);
5556 if (i == (ssize_t) argc)
5557 ThrowMogrifyException(OptionError,"MissingArgument",option);
5560 if (LocaleCompare("shade",option+1) == 0)
5563 if (i == (ssize_t) argc)
5564 ThrowMogrifyException(OptionError,"MissingArgument",option);
5565 if (IsGeometry(argv[i]) == MagickFalse)
5566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5569 if (LocaleCompare("shadow",option+1) == 0)
5574 if (i == (ssize_t) argc)
5575 ThrowMogrifyException(OptionError,"MissingArgument",option);
5576 if (IsGeometry(argv[i]) == MagickFalse)
5577 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5580 if (LocaleCompare("sharpen",option+1) == 0)
5583 if (i == (ssize_t) argc)
5584 ThrowMogrifyException(OptionError,"MissingArgument",option);
5585 if (IsGeometry(argv[i]) == MagickFalse)
5586 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5589 if (LocaleCompare("shave",option+1) == 0)
5594 if (i == (ssize_t) argc)
5595 ThrowMogrifyException(OptionError,"MissingArgument",option);
5596 if (IsGeometry(argv[i]) == MagickFalse)
5597 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5600 if (LocaleCompare("shear",option+1) == 0)
5603 if (i == (ssize_t) argc)
5604 ThrowMogrifyException(OptionError,"MissingArgument",option);
5605 if (IsGeometry(argv[i]) == MagickFalse)
5606 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5609 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5612 if (i == (ssize_t) (argc-1))
5613 ThrowMogrifyException(OptionError,"MissingArgument",option);
5614 if (IsGeometry(argv[i]) == MagickFalse)
5615 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5618 if (LocaleCompare("size",option+1) == 0)
5623 if (i == (ssize_t) argc)
5624 ThrowMogrifyException(OptionError,"MissingArgument",option);
5625 if (IsGeometry(argv[i]) == MagickFalse)
5626 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5629 if (LocaleCompare("sketch",option+1) == 0)
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,"MissingArgument",option);
5636 if (IsGeometry(argv[i]) == MagickFalse)
5637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5640 if (LocaleCompare("smush",option+1) == 0)
5643 if (i == (ssize_t) argc)
5644 ThrowMogrifyException(OptionError,"MissingArgument",option);
5645 if (IsGeometry(argv[i]) == MagickFalse)
5646 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 if (LocaleCompare("solarize",option+1) == 0)
5655 if (i == (ssize_t) argc)
5656 ThrowMogrifyException(OptionError,"MissingArgument",option);
5657 if (IsGeometry(argv[i]) == MagickFalse)
5658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5661 if (LocaleCompare("sparse-color",option+1) == 0)
5667 if (i == (ssize_t) argc)
5668 ThrowMogrifyException(OptionError,"MissingArgument",option);
5669 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5671 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5674 if (i == (ssize_t) (argc-1))
5675 ThrowMogrifyException(OptionError,"MissingArgument",option);
5678 if (LocaleCompare("spread",option+1) == 0)
5683 if (i == (ssize_t) argc)
5684 ThrowMogrifyException(OptionError,"MissingArgument",option);
5685 if (IsGeometry(argv[i]) == MagickFalse)
5686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5689 if (LocaleCompare("statistic",option+1) == 0)
5697 if (i == (ssize_t) argc)
5698 ThrowMogrifyException(OptionError,"MissingArgument",option);
5699 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5701 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5704 if (i == (ssize_t) (argc-1))
5705 ThrowMogrifyException(OptionError,"MissingArgument",option);
5706 if (IsGeometry(argv[i]) == MagickFalse)
5707 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5710 if (LocaleCompare("stretch",option+1) == 0)
5718 if (i == (ssize_t) (argc-1))
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5722 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5726 if (LocaleCompare("strip",option+1) == 0)
5728 if (LocaleCompare("stroke",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 if (LocaleCompare("strokewidth",option+1) == 0)
5742 if (i == (ssize_t) argc)
5743 ThrowMogrifyException(OptionError,"MissingArgument",option);
5744 if (IsGeometry(argv[i]) == MagickFalse)
5745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 if (LocaleCompare("style",option+1) == 0)
5756 if (i == (ssize_t) (argc-1))
5757 ThrowMogrifyException(OptionError,"MissingArgument",option);
5758 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5760 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5764 if (LocaleCompare("swap",option+1) == 0)
5769 if (i == (ssize_t) (argc-1))
5770 ThrowMogrifyException(OptionError,"MissingArgument",option);
5771 if (IsGeometry(argv[i]) == MagickFalse)
5772 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5775 if (LocaleCompare("swirl",option+1) == 0)
5780 if (i == (ssize_t) argc)
5781 ThrowMogrifyException(OptionError,"MissingArgument",option);
5782 if (IsGeometry(argv[i]) == MagickFalse)
5783 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5786 if (LocaleCompare("synchronize",option+1) == 0)
5788 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5792 if (LocaleCompare("taint",option+1) == 0)
5794 if (LocaleCompare("texture",option+1) == 0)
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5803 if (LocaleCompare("tile",option+1) == 0)
5808 if (i == (ssize_t) (argc-1))
5809 ThrowMogrifyException(OptionError,"MissingArgument",option);
5812 if (LocaleCompare("tile-offset",option+1) == 0)
5817 if (i == (ssize_t) argc)
5818 ThrowMogrifyException(OptionError,"MissingArgument",option);
5819 if (IsGeometry(argv[i]) == MagickFalse)
5820 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5823 if (LocaleCompare("tint",option+1) == 0)
5828 if (i == (ssize_t) (argc-1))
5829 ThrowMogrifyException(OptionError,"MissingArgument",option);
5830 if (IsGeometry(argv[i]) == MagickFalse)
5831 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5834 if (LocaleCompare("transform",option+1) == 0)
5836 if (LocaleCompare("transpose",option+1) == 0)
5838 if (LocaleCompare("transverse",option+1) == 0)
5840 if (LocaleCompare("threshold",option+1) == 0)
5845 if (i == (ssize_t) argc)
5846 ThrowMogrifyException(OptionError,"MissingArgument",option);
5847 if (IsGeometry(argv[i]) == MagickFalse)
5848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5851 if (LocaleCompare("thumbnail",option+1) == 0)
5856 if (i == (ssize_t) argc)
5857 ThrowMogrifyException(OptionError,"MissingArgument",option);
5858 if (IsGeometry(argv[i]) == MagickFalse)
5859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5862 if (LocaleCompare("transparent",option+1) == 0)
5865 if (i == (ssize_t) argc)
5866 ThrowMogrifyException(OptionError,"MissingArgument",option);
5869 if (LocaleCompare("transparent-color",option+1) == 0)
5874 if (i == (ssize_t) (argc-1))
5875 ThrowMogrifyException(OptionError,"MissingArgument",option);
5878 if (LocaleCompare("treedepth",option+1) == 0)
5883 if (i == (ssize_t) argc)
5884 ThrowMogrifyException(OptionError,"MissingArgument",option);
5885 if (IsGeometry(argv[i]) == MagickFalse)
5886 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5889 if (LocaleCompare("trim",option+1) == 0)
5891 if (LocaleCompare("type",option+1) == 0)
5899 if (i == (ssize_t) argc)
5900 ThrowMogrifyException(OptionError,"MissingArgument",option);
5901 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5903 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5907 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5911 if (LocaleCompare("undercolor",option+1) == 0)
5916 if (i == (ssize_t) argc)
5917 ThrowMogrifyException(OptionError,"MissingArgument",option);
5920 if (LocaleCompare("unique-colors",option+1) == 0)
5922 if (LocaleCompare("units",option+1) == 0)
5930 if (i == (ssize_t) argc)
5931 ThrowMogrifyException(OptionError,"MissingArgument",option);
5932 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5935 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5939 if (LocaleCompare("unsharp",option+1) == 0)
5942 if (i == (ssize_t) argc)
5943 ThrowMogrifyException(OptionError,"MissingArgument",option);
5944 if (IsGeometry(argv[i]) == MagickFalse)
5945 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5948 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5952 if (LocaleCompare("verbose",option+1) == 0)
5954 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5957 if ((LocaleCompare("version",option+1) == 0) ||
5958 (LocaleCompare("-version",option+1) == 0))
5960 (void) FormatLocaleFile(stdout,"Version: %s\n",
5961 GetMagickVersion((size_t *) NULL));
5962 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5963 GetMagickCopyright());
5964 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5965 GetMagickFeatures());
5968 if (LocaleCompare("view",option+1) == 0)
5973 if (i == (ssize_t) argc)
5974 ThrowMogrifyException(OptionError,"MissingArgument",option);
5977 if (LocaleCompare("vignette",option+1) == 0)
5982 if (i == (ssize_t) argc)
5983 ThrowMogrifyException(OptionError,"MissingArgument",option);
5984 if (IsGeometry(argv[i]) == MagickFalse)
5985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5988 if (LocaleCompare("virtual-pixel",option+1) == 0)
5996 if (i == (ssize_t) argc)
5997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5998 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6001 ThrowMogrifyException(OptionError,
6002 "UnrecognizedVirtualPixelMethod",argv[i]);
6005 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6009 if (LocaleCompare("wave",option+1) == 0)
6012 if (i == (ssize_t) argc)
6013 ThrowMogrifyException(OptionError,"MissingArgument",option);
6014 if (IsGeometry(argv[i]) == MagickFalse)
6015 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6018 if (LocaleCompare("weight",option+1) == 0)
6023 if (i == (ssize_t) (argc-1))
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6027 if (LocaleCompare("white-point",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6034 if (IsGeometry(argv[i]) == MagickFalse)
6035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6038 if (LocaleCompare("white-threshold",option+1) == 0)
6043 if (i == (ssize_t) argc)
6044 ThrowMogrifyException(OptionError,"MissingArgument",option);
6045 if (IsGeometry(argv[i]) == MagickFalse)
6046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6049 if (LocaleCompare("write",option+1) == 0)
6052 if (i == (ssize_t) (argc-1))
6053 ThrowMogrifyException(OptionError,"MissingArgument",option);
6056 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6061 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6063 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6064 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6065 if (fire != MagickFalse)
6066 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6069 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6070 if (i != (ssize_t) argc)
6071 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6073 return(status != 0 ? MagickTrue : MagickFalse);
6077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6081 + M o g r i f y I m a g e I n f o %
6085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6087 % MogrifyImageInfo() applies image processing settings to the image as
6088 % prescribed by command line options.
6090 % The format of the MogrifyImageInfo method is:
6092 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6093 % const char **argv,ExceptionInfo *exception)
6095 % A description of each parameter follows:
6097 % o image_info: the image info..
6099 % o argc: Specifies a pointer to an integer describing the number of
6100 % elements in the argument vector.
6102 % o argv: Specifies a pointer to a text array containing the command line
6105 % o exception: return any errors or warnings in this structure.
6108 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6109 const int argc,const char **argv,ExceptionInfo *exception)
6124 Initialize method variables.
6126 assert(image_info != (ImageInfo *) NULL);
6127 assert(image_info->signature == MagickSignature);
6128 if (image_info->debug != MagickFalse)
6129 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6130 image_info->filename);
6134 Set the image settings.
6136 for (i=0; i < (ssize_t) argc; i++)
6139 if (IsCommandOption(option) == MagickFalse)
6141 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6142 count=MagickMax(count,0L);
6143 if ((i+count) >= (ssize_t) argc)
6145 switch (*(option+1))
6149 if (LocaleCompare("adjoin",option+1) == 0)
6151 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6154 if (LocaleCompare("antialias",option+1) == 0)
6156 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6159 if (LocaleCompare("authenticate",option+1) == 0)
6162 (void) DeleteImageOption(image_info,option+1);
6164 (void) SetImageOption(image_info,option+1,argv[i+1]);
6171 if (LocaleCompare("background",option+1) == 0)
6175 (void) DeleteImageOption(image_info,option+1);
6176 (void) QueryColorCompliance(MogrifyBackgroundColor,
6177 AllCompliance,&image_info->background_color,exception);
6180 (void) SetImageOption(image_info,option+1,argv[i+1]);
6181 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6182 &image_info->background_color,exception);
6185 if (LocaleCompare("bias",option+1) == 0)
6189 (void) SetImageOption(image_info,option+1,"0.0");
6192 (void) SetImageOption(image_info,option+1,argv[i+1]);
6195 if (LocaleCompare("black-point-compensation",option+1) == 0)
6199 (void) SetImageOption(image_info,option+1,"false");
6202 (void) SetImageOption(image_info,option+1,"true");
6205 if (LocaleCompare("blue-primary",option+1) == 0)
6209 (void) SetImageOption(image_info,option+1,"0.0");
6212 (void) SetImageOption(image_info,option+1,argv[i+1]);
6215 if (LocaleCompare("bordercolor",option+1) == 0)
6219 (void) DeleteImageOption(image_info,option+1);
6220 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6221 &image_info->border_color,exception);
6224 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6225 &image_info->border_color,exception);
6226 (void) SetImageOption(image_info,option+1,argv[i+1]);
6229 if (LocaleCompare("box",option+1) == 0)
6233 (void) SetImageOption(image_info,"undercolor","none");
6236 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6243 if (LocaleCompare("cache",option+1) == 0)
6248 limit=MagickResourceInfinity;
6249 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6250 limit=(MagickSizeType) StringToDoubleInterval(argv[i+1],100.0);
6251 (void) SetMagickResourceLimit(MemoryResource,limit);
6252 (void) SetMagickResourceLimit(MapResource,2*limit);
6255 if (LocaleCompare("caption",option+1) == 0)
6259 (void) DeleteImageOption(image_info,option+1);
6262 (void) SetImageOption(image_info,option+1,argv[i+1]);
6265 if (LocaleCompare("channel",option+1) == 0)
6269 image_info->channel=DefaultChannels;
6272 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6275 if (LocaleCompare("colorspace",option+1) == 0)
6279 image_info->colorspace=UndefinedColorspace;
6280 (void) SetImageOption(image_info,option+1,"undefined");
6283 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6284 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6285 (void) SetImageOption(image_info,option+1,argv[i+1]);
6288 if (LocaleCompare("comment",option+1) == 0)
6292 (void) DeleteImageOption(image_info,option+1);
6295 (void) SetImageOption(image_info,option+1,argv[i+1]);
6298 if (LocaleCompare("compose",option+1) == 0)
6302 (void) SetImageOption(image_info,option+1,"undefined");
6305 (void) SetImageOption(image_info,option+1,argv[i+1]);
6308 if (LocaleCompare("compress",option+1) == 0)
6312 image_info->compression=UndefinedCompression;
6313 (void) SetImageOption(image_info,option+1,"undefined");
6316 image_info->compression=(CompressionType) ParseCommandOption(
6317 MagickCompressOptions,MagickFalse,argv[i+1]);
6318 (void) SetImageOption(image_info,option+1,argv[i+1]);
6325 if (LocaleCompare("debug",option+1) == 0)
6328 (void) SetLogEventMask("none");
6330 (void) SetLogEventMask(argv[i+1]);
6331 image_info->debug=IsEventLogging();
6334 if (LocaleCompare("define",option+1) == 0)
6338 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6339 (void) DeleteImageRegistry(argv[i+1]+9);
6341 (void) DeleteImageOption(image_info,argv[i+1]);
6344 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6346 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6350 (void) DefineImageOption(image_info,argv[i+1]);
6353 if (LocaleCompare("delay",option+1) == 0)
6357 (void) SetImageOption(image_info,option+1,"0");
6360 (void) SetImageOption(image_info,option+1,argv[i+1]);
6363 if (LocaleCompare("density",option+1) == 0)
6370 if (image_info->density != (char *) NULL)
6371 image_info->density=DestroyString(image_info->density);
6372 (void) SetImageOption(image_info,option+1,"72");
6375 (void) CloneString(&image_info->density,argv[i+1]);
6376 (void) SetImageOption(image_info,option+1,argv[i+1]);
6379 if (LocaleCompare("depth",option+1) == 0)
6383 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6386 image_info->depth=StringToUnsignedLong(argv[i+1]);
6389 if (LocaleCompare("direction",option+1) == 0)
6393 (void) SetImageOption(image_info,option+1,"undefined");
6396 (void) SetImageOption(image_info,option+1,argv[i+1]);
6399 if (LocaleCompare("display",option+1) == 0)
6403 if (image_info->server_name != (char *) NULL)
6404 image_info->server_name=DestroyString(
6405 image_info->server_name);
6408 (void) CloneString(&image_info->server_name,argv[i+1]);
6411 if (LocaleCompare("dispose",option+1) == 0)
6415 (void) SetImageOption(image_info,option+1,"undefined");
6418 (void) SetImageOption(image_info,option+1,argv[i+1]);
6421 if (LocaleCompare("dither",option+1) == 0)
6425 image_info->dither=MagickFalse;
6426 (void) SetImageOption(image_info,option+1,"none");
6429 (void) SetImageOption(image_info,option+1,argv[i+1]);
6430 image_info->dither=MagickTrue;
6437 if (LocaleCompare("encoding",option+1) == 0)
6441 (void) SetImageOption(image_info,option+1,"undefined");
6444 (void) SetImageOption(image_info,option+1,argv[i+1]);
6447 if (LocaleCompare("endian",option+1) == 0)
6451 image_info->endian=UndefinedEndian;
6452 (void) SetImageOption(image_info,option+1,"undefined");
6455 image_info->endian=(EndianType) ParseCommandOption(
6456 MagickEndianOptions,MagickFalse,argv[i+1]);
6457 (void) SetImageOption(image_info,option+1,argv[i+1]);
6460 if (LocaleCompare("extract",option+1) == 0)
6463 Set image extract geometry.
6467 if (image_info->extract != (char *) NULL)
6468 image_info->extract=DestroyString(image_info->extract);
6471 (void) CloneString(&image_info->extract,argv[i+1]);
6478 if (LocaleCompare("fill",option+1) == 0)
6482 (void) SetImageOption(image_info,option+1,"none");
6485 (void) SetImageOption(image_info,option+1,argv[i+1]);
6488 if (LocaleCompare("filter",option+1) == 0)
6492 (void) SetImageOption(image_info,option+1,"undefined");
6495 (void) SetImageOption(image_info,option+1,argv[i+1]);
6498 if (LocaleCompare("font",option+1) == 0)
6502 if (image_info->font != (char *) NULL)
6503 image_info->font=DestroyString(image_info->font);
6506 (void) CloneString(&image_info->font,argv[i+1]);
6509 if (LocaleCompare("format",option+1) == 0)
6514 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6515 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6516 image_info->ping=MagickFalse;
6517 (void) SetImageOption(image_info,option+1,argv[i+1]);
6520 if (LocaleCompare("fuzz",option+1) == 0)
6524 image_info->fuzz=0.0;
6525 (void) SetImageOption(image_info,option+1,"0");
6528 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6530 (void) SetImageOption(image_info,option+1,argv[i+1]);
6537 if (LocaleCompare("gravity",option+1) == 0)
6541 (void) SetImageOption(image_info,option+1,"undefined");
6544 (void) SetImageOption(image_info,option+1,argv[i+1]);
6547 if (LocaleCompare("green-primary",option+1) == 0)
6551 (void) SetImageOption(image_info,option+1,"0.0");
6554 (void) SetImageOption(image_info,option+1,argv[i+1]);
6561 if (LocaleCompare("intent",option+1) == 0)
6565 (void) SetImageOption(image_info,option+1,"undefined");
6568 (void) SetImageOption(image_info,option+1,argv[i+1]);
6571 if (LocaleCompare("interlace",option+1) == 0)
6575 image_info->interlace=UndefinedInterlace;
6576 (void) SetImageOption(image_info,option+1,"undefined");
6579 image_info->interlace=(InterlaceType) ParseCommandOption(
6580 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6581 (void) SetImageOption(image_info,option+1,argv[i+1]);
6584 if (LocaleCompare("interline-spacing",option+1) == 0)
6588 (void) SetImageOption(image_info,option+1,"undefined");
6591 (void) SetImageOption(image_info,option+1,argv[i+1]);
6594 if (LocaleCompare("interpolate",option+1) == 0)
6598 (void) SetImageOption(image_info,option+1,"undefined");
6601 (void) SetImageOption(image_info,option+1,argv[i+1]);
6604 if (LocaleCompare("interword-spacing",option+1) == 0)
6608 (void) SetImageOption(image_info,option+1,"undefined");
6611 (void) SetImageOption(image_info,option+1,argv[i+1]);
6618 if (LocaleCompare("kerning",option+1) == 0)
6622 (void) SetImageOption(image_info,option+1,"undefined");
6625 (void) SetImageOption(image_info,option+1,argv[i+1]);
6632 if (LocaleCompare("label",option+1) == 0)
6636 (void) DeleteImageOption(image_info,option+1);
6639 (void) SetImageOption(image_info,option+1,argv[i+1]);
6642 if (LocaleCompare("limit",option+1) == 0)
6652 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6653 MagickFalse,argv[i+1]);
6654 limit=MagickResourceInfinity;
6655 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6656 limit=(MagickSizeType) StringToDoubleInterval(argv[i+2],100.0);
6657 (void) SetMagickResourceLimit(type,limit);
6660 if (LocaleCompare("list",option+1) == 0)
6666 Display configuration list.
6668 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6671 case MagickCoderOptions:
6673 (void) ListCoderInfo((FILE *) NULL,exception);
6676 case MagickColorOptions:
6678 (void) ListColorInfo((FILE *) NULL,exception);
6681 case MagickConfigureOptions:
6683 (void) ListConfigureInfo((FILE *) NULL,exception);
6686 case MagickDelegateOptions:
6688 (void) ListDelegateInfo((FILE *) NULL,exception);
6691 case MagickFontOptions:
6693 (void) ListTypeInfo((FILE *) NULL,exception);
6696 case MagickFormatOptions:
6698 (void) ListMagickInfo((FILE *) NULL,exception);
6701 case MagickLocaleOptions:
6703 (void) ListLocaleInfo((FILE *) NULL,exception);
6706 case MagickLogOptions:
6708 (void) ListLogInfo((FILE *) NULL,exception);
6711 case MagickMagicOptions:
6713 (void) ListMagicInfo((FILE *) NULL,exception);
6716 case MagickMimeOptions:
6718 (void) ListMimeInfo((FILE *) NULL,exception);
6721 case MagickModuleOptions:
6723 (void) ListModuleInfo((FILE *) NULL,exception);
6726 case MagickPolicyOptions:
6728 (void) ListPolicyInfo((FILE *) NULL,exception);
6731 case MagickResourceOptions:
6733 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6736 case MagickThresholdOptions:
6738 (void) ListThresholdMaps((FILE *) NULL,exception);
6743 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6750 if (LocaleCompare("log",option+1) == 0)
6754 (void) SetLogFormat(argv[i+1]);
6757 if (LocaleCompare("loop",option+1) == 0)
6761 (void) SetImageOption(image_info,option+1,"0");
6764 (void) SetImageOption(image_info,option+1,argv[i+1]);
6771 if (LocaleCompare("matte",option+1) == 0)
6775 (void) SetImageOption(image_info,option+1,"false");
6778 (void) SetImageOption(image_info,option+1,"true");
6781 if (LocaleCompare("mattecolor",option+1) == 0)
6785 (void) SetImageOption(image_info,option+1,argv[i+1]);
6786 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6787 &image_info->matte_color,exception);
6790 (void) SetImageOption(image_info,option+1,argv[i+1]);
6791 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6792 &image_info->matte_color,exception);
6795 if (LocaleCompare("monitor",option+1) == 0)
6797 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6801 if (LocaleCompare("monochrome",option+1) == 0)
6803 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6810 if (LocaleCompare("orient",option+1) == 0)
6814 image_info->orientation=UndefinedOrientation;
6815 (void) SetImageOption(image_info,option+1,"undefined");
6818 image_info->orientation=(OrientationType) ParseCommandOption(
6819 MagickOrientationOptions,MagickFalse,argv[i+1]);
6820 (void) SetImageOption(image_info,option+1,argv[i+1]);
6826 if (LocaleCompare("page",option+1) == 0)
6830 page[MaxTextExtent];
6843 (void) DeleteImageOption(image_info,option+1);
6844 (void) CloneString(&image_info->page,(char *) NULL);
6847 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6848 image_option=GetImageOption(image_info,"page");
6849 if (image_option != (const char *) NULL)
6850 flags=ParseAbsoluteGeometry(image_option,&geometry);
6851 canonical_page=GetPageGeometry(argv[i+1]);
6852 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6853 canonical_page=DestroyString(canonical_page);
6854 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6855 (unsigned long) geometry.width,(unsigned long) geometry.height);
6856 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6857 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6858 (unsigned long) geometry.width,(unsigned long) geometry.height,
6859 (long) geometry.x,(long) geometry.y);
6860 (void) SetImageOption(image_info,option+1,page);
6861 (void) CloneString(&image_info->page,page);
6864 if (LocaleCompare("pen",option+1) == 0)
6868 (void) SetImageOption(image_info,option+1,"none");
6871 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 if (LocaleCompare("ping",option+1) == 0)
6876 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6879 if (LocaleCompare("pointsize",option+1) == 0)
6882 geometry_info.rho=0.0;
6884 (void) ParseGeometry(argv[i+1],&geometry_info);
6885 image_info->pointsize=geometry_info.rho;
6888 if (LocaleCompare("precision",option+1) == 0)
6890 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6893 if (LocaleCompare("preview",option+1) == 0)
6900 image_info->preview_type=UndefinedPreview;
6903 image_info->preview_type=(PreviewType) ParseCommandOption(
6904 MagickPreviewOptions,MagickFalse,argv[i+1]);
6911 if (LocaleCompare("quality",option+1) == 0)
6914 Set image compression quality.
6918 image_info->quality=UndefinedCompressionQuality;
6919 (void) SetImageOption(image_info,option+1,"0");
6922 image_info->quality=StringToUnsignedLong(argv[i+1]);
6923 (void) SetImageOption(image_info,option+1,argv[i+1]);
6926 if (LocaleCompare("quiet",option+1) == 0)
6928 static WarningHandler
6929 warning_handler = (WarningHandler) NULL;
6934 Restore error or warning messages.
6936 warning_handler=SetWarningHandler(warning_handler);
6940 Suppress error or warning messages.
6942 warning_handler=SetWarningHandler((WarningHandler) NULL);
6949 if (LocaleCompare("red-primary",option+1) == 0)
6953 (void) SetImageOption(image_info,option+1,"0.0");
6956 (void) SetImageOption(image_info,option+1,argv[i+1]);
6963 if (LocaleCompare("sampling-factor",option+1) == 0)
6966 Set image sampling factor.
6970 if (image_info->sampling_factor != (char *) NULL)
6971 image_info->sampling_factor=DestroyString(
6972 image_info->sampling_factor);
6975 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6978 if (LocaleCompare("scene",option+1) == 0)
6985 image_info->scene=0;
6986 (void) SetImageOption(image_info,option+1,"0");
6989 image_info->scene=StringToUnsignedLong(argv[i+1]);
6990 (void) SetImageOption(image_info,option+1,argv[i+1]);
6993 if (LocaleCompare("seed",option+1) == 0)
7000 seed=(size_t) time((time_t *) NULL);
7001 SeedPseudoRandomGenerator(seed);
7004 seed=StringToUnsignedLong(argv[i+1]);
7005 SeedPseudoRandomGenerator(seed);
7008 if (LocaleCompare("size",option+1) == 0)
7012 if (image_info->size != (char *) NULL)
7013 image_info->size=DestroyString(image_info->size);
7016 (void) CloneString(&image_info->size,argv[i+1]);
7019 if (LocaleCompare("stroke",option+1) == 0)
7023 (void) SetImageOption(image_info,option+1,"none");
7026 (void) SetImageOption(image_info,option+1,argv[i+1]);
7029 if (LocaleCompare("strokewidth",option+1) == 0)
7033 (void) SetImageOption(image_info,option+1,"0");
7036 (void) SetImageOption(image_info,option+1,argv[i+1]);
7039 if (LocaleCompare("synchronize",option+1) == 0)
7043 image_info->synchronize=MagickFalse;
7046 image_info->synchronize=MagickTrue;
7053 if (LocaleCompare("taint",option+1) == 0)
7057 (void) SetImageOption(image_info,option+1,"false");
7060 (void) SetImageOption(image_info,option+1,"true");
7063 if (LocaleCompare("texture",option+1) == 0)
7067 if (image_info->texture != (char *) NULL)
7068 image_info->texture=DestroyString(image_info->texture);
7071 (void) CloneString(&image_info->texture,argv[i+1]);
7074 if (LocaleCompare("tile-offset",option+1) == 0)
7078 (void) SetImageOption(image_info,option+1,"0");
7081 (void) SetImageOption(image_info,option+1,argv[i+1]);
7084 if (LocaleCompare("transparent-color",option+1) == 0)
7088 (void) QueryColorCompliance("none",AllCompliance,
7089 &image_info->transparent_color,exception);
7090 (void) SetImageOption(image_info,option+1,"none");
7093 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7094 &image_info->transparent_color,exception);
7095 (void) SetImageOption(image_info,option+1,argv[i+1]);
7098 if (LocaleCompare("type",option+1) == 0)
7102 image_info->type=UndefinedType;
7103 (void) SetImageOption(image_info,option+1,"undefined");
7106 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7107 MagickFalse,argv[i+1]);
7108 (void) SetImageOption(image_info,option+1,argv[i+1]);
7115 if (LocaleCompare("undercolor",option+1) == 0)
7119 (void) DeleteImageOption(image_info,option+1);
7122 (void) SetImageOption(image_info,option+1,argv[i+1]);
7125 if (LocaleCompare("units",option+1) == 0)
7129 image_info->units=UndefinedResolution;
7130 (void) SetImageOption(image_info,option+1,"undefined");
7133 image_info->units=(ResolutionType) ParseCommandOption(
7134 MagickResolutionOptions,MagickFalse,argv[i+1]);
7135 (void) SetImageOption(image_info,option+1,argv[i+1]);
7142 if (LocaleCompare("verbose",option+1) == 0)
7146 image_info->verbose=MagickFalse;
7149 image_info->verbose=MagickTrue;
7150 image_info->ping=MagickFalse;
7153 if (LocaleCompare("view",option+1) == 0)
7157 if (image_info->view != (char *) NULL)
7158 image_info->view=DestroyString(image_info->view);
7161 (void) CloneString(&image_info->view,argv[i+1]);
7164 if (LocaleCompare("virtual-pixel",option+1) == 0)
7168 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7169 (void) SetImageOption(image_info,option+1,"undefined");
7172 image_info->virtual_pixel_method=(VirtualPixelMethod)
7173 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7175 (void) SetImageOption(image_info,option+1,argv[i+1]);
7182 if (LocaleCompare("white-point",option+1) == 0)
7186 (void) SetImageOption(image_info,option+1,"0.0");
7189 (void) SetImageOption(image_info,option+1,argv[i+1]);
7203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7207 + M o g r i f y I m a g e L i s t %
7211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7213 % MogrifyImageList() applies any command line options that might affect the
7214 % entire image list (e.g. -append, -coalesce, etc.).
7216 % The format of the MogrifyImage method is:
7218 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7219 % const char **argv,Image **images,ExceptionInfo *exception)
7221 % A description of each parameter follows:
7223 % o image_info: the image info..
7225 % o argc: Specifies a pointer to an integer describing the number of
7226 % elements in the argument vector.
7228 % o argv: Specifies a pointer to a text array containing the command line
7231 % o images: pointer to pointer of the first image in image list.
7233 % o exception: return any errors or warnings in this structure.
7236 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7237 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7248 PixelInterpolateMethod
7262 Apply options to the image list.
7264 assert(image_info != (ImageInfo *) NULL);
7265 assert(image_info->signature == MagickSignature);
7266 assert(images != (Image **) NULL);
7267 assert((*images)->previous == (Image *) NULL);
7268 assert((*images)->signature == MagickSignature);
7269 if ((*images)->debug != MagickFalse)
7270 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7271 (*images)->filename);
7272 if ((argc <= 0) || (*argv == (char *) NULL))
7274 interpolate_method=UndefinedInterpolatePixel;
7275 mogrify_info=CloneImageInfo(image_info);
7276 quantize_info=AcquireQuantizeInfo(mogrify_info);
7278 for (i=0; i < (ssize_t) argc; i++)
7280 if (*images == (Image *) NULL)
7283 if (IsCommandOption(option) == MagickFalse)
7285 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7286 count=MagickMax(count,0L);
7287 if ((i+count) >= (ssize_t) argc)
7289 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7290 switch (*(option+1))
7294 if (LocaleCompare("affinity",option+1) == 0)
7296 (void) SyncImagesSettings(mogrify_info,*images,exception);
7299 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7306 if (LocaleCompare("append",option+1) == 0)
7311 (void) SyncImagesSettings(mogrify_info,*images,exception);
7312 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7313 MagickFalse,exception);
7314 if (append_image == (Image *) NULL)
7319 *images=DestroyImageList(*images);
7320 *images=append_image;
7323 if (LocaleCompare("average",option+1) == 0)
7329 Average an image sequence (deprecated).
7331 (void) SyncImagesSettings(mogrify_info,*images,exception);
7332 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7334 if (average_image == (Image *) NULL)
7339 *images=DestroyImageList(*images);
7340 *images=average_image;
7347 if (LocaleCompare("channel",option+1) == 0)
7354 channel=DefaultChannels;
7357 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7358 SetPixelChannelMap(*images,channel);
7361 if (LocaleCompare("clut",option+1) == 0)
7367 (void) SyncImagesSettings(mogrify_info,*images,exception);
7368 image=RemoveFirstImageFromList(images);
7369 clut_image=RemoveFirstImageFromList(images);
7370 if (clut_image == (Image *) NULL)
7375 (void) ClutImage(image,clut_image,interpolate_method,exception);
7376 clut_image=DestroyImage(clut_image);
7377 *images=DestroyImageList(*images);
7381 if (LocaleCompare("coalesce",option+1) == 0)
7386 (void) SyncImagesSettings(mogrify_info,*images,exception);
7387 coalesce_image=CoalesceImages(*images,exception);
7388 if (coalesce_image == (Image *) NULL)
7393 *images=DestroyImageList(*images);
7394 *images=coalesce_image;
7397 if (LocaleCompare("combine",option+1) == 0)
7402 (void) SyncImagesSettings(mogrify_info,*images,exception);
7403 combine_image=CombineImages(*images,exception);
7404 if (combine_image == (Image *) NULL)
7409 *images=DestroyImageList(*images);
7410 *images=combine_image;
7413 if (LocaleCompare("composite",option+1) == 0)
7423 (void) SyncImagesSettings(mogrify_info,*images,exception);
7424 image=RemoveFirstImageFromList(images);
7425 composite_image=RemoveFirstImageFromList(images);
7426 if (composite_image == (Image *) NULL)
7431 (void) TransformImage(&composite_image,(char *) NULL,
7432 composite_image->geometry,exception);
7433 SetGeometry(composite_image,&geometry);
7434 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7435 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7437 mask_image=RemoveFirstImageFromList(images);
7438 if (mask_image != (Image *) NULL)
7440 if ((image->compose == DisplaceCompositeOp) ||
7441 (image->compose == DistortCompositeOp))
7444 Merge Y displacement into X displacement image.
7446 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7447 mask_image,0,0,exception);
7448 mask_image=DestroyImage(mask_image);
7453 Set a blending mask for the composition.
7454 Posible error, what if image->mask already set.
7456 image->mask=mask_image;
7457 (void) NegateImage(image->mask,MagickFalse,exception);
7460 (void) CompositeImage(image,image->compose,composite_image,
7461 geometry.x,geometry.y,exception);
7462 if (mask_image != (Image *) NULL)
7463 mask_image=image->mask=DestroyImage(image->mask);
7464 composite_image=DestroyImage(composite_image);
7465 *images=DestroyImageList(*images);
7473 if (LocaleCompare("deconstruct",option+1) == 0)
7478 (void) SyncImagesSettings(mogrify_info,*images,exception);
7479 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7481 if (deconstruct_image == (Image *) NULL)
7486 *images=DestroyImageList(*images);
7487 *images=deconstruct_image;
7490 if (LocaleCompare("delete",option+1) == 0)
7493 DeleteImages(images,"-1",exception);
7495 DeleteImages(images,argv[i+1],exception);
7498 if (LocaleCompare("dither",option+1) == 0)
7502 quantize_info->dither=MagickFalse;
7505 quantize_info->dither=MagickTrue;
7506 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7507 MagickDitherOptions,MagickFalse,argv[i+1]);
7510 if (LocaleCompare("duplicate",option+1) == 0)
7516 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7525 number_duplicates=(size_t) StringToLong(argv[i+1]);
7526 p=strchr(argv[i+1],',');
7527 if (p == (const char *) NULL)
7528 duplicate_images=DuplicateImages(*images,number_duplicates,
7531 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7534 AppendImageToList(images, duplicate_images);
7535 (void) SyncImagesSettings(mogrify_info,*images,exception);
7542 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7547 MagickEvaluateOperator
7550 (void) SyncImageSettings(mogrify_info,*images,exception);
7551 op=(MagickEvaluateOperator) ParseCommandOption(
7552 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7553 evaluate_image=EvaluateImages(*images,op,exception);
7554 if (evaluate_image == (Image *) NULL)
7559 *images=DestroyImageList(*images);
7560 *images=evaluate_image;
7567 if (LocaleCompare("fft",option+1) == 0)
7573 Implements the discrete Fourier transform (DFT).
7575 (void) SyncImageSettings(mogrify_info,*images,exception);
7576 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7577 MagickTrue : MagickFalse,exception);
7578 if (fourier_image == (Image *) NULL)
7580 *images=DestroyImage(*images);
7581 *images=fourier_image;
7584 if (LocaleCompare("flatten",option+1) == 0)
7589 (void) SyncImagesSettings(mogrify_info,*images,exception);
7590 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7591 if (flatten_image == (Image *) NULL)
7593 *images=DestroyImageList(*images);
7594 *images=flatten_image;
7597 if (LocaleCompare("fx",option+1) == 0)
7602 (void) SyncImagesSettings(mogrify_info,*images,exception);
7603 fx_image=FxImage(*images,argv[i+1],exception);
7604 if (fx_image == (Image *) NULL)
7609 *images=DestroyImageList(*images);
7617 if (LocaleCompare("hald-clut",option+1) == 0)
7623 (void) SyncImagesSettings(mogrify_info,*images,exception);
7624 image=RemoveFirstImageFromList(images);
7625 hald_image=RemoveFirstImageFromList(images);
7626 if (hald_image == (Image *) NULL)
7631 (void) HaldClutImage(image,hald_image,exception);
7632 hald_image=DestroyImage(hald_image);
7633 if (*images != (Image *) NULL)
7634 *images=DestroyImageList(*images);
7642 if (LocaleCompare("ift",option+1) == 0)
7650 Implements the inverse fourier discrete Fourier transform (DFT).
7652 (void) SyncImagesSettings(mogrify_info,*images,exception);
7653 magnitude_image=RemoveFirstImageFromList(images);
7654 phase_image=RemoveFirstImageFromList(images);
7655 if (phase_image == (Image *) NULL)
7660 fourier_image=InverseFourierTransformImage(magnitude_image,
7661 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7662 if (fourier_image == (Image *) NULL)
7664 if (*images != (Image *) NULL)
7665 *images=DestroyImage(*images);
7666 *images=fourier_image;
7669 if (LocaleCompare("insert",option+1) == 0)
7677 index=(ssize_t) StringToLong(argv[i+1]);
7678 p=RemoveLastImageFromList(images);
7679 if (p == (Image *) NULL)
7681 (void) ThrowMagickException(exception,GetMagickModule(),
7682 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7688 PrependImageToList(images,q);
7690 if (index == (ssize_t) GetImageListLength(*images))
7691 AppendImageToList(images,q);
7694 q=GetImageFromList(*images,index-1);
7695 if (q == (Image *) NULL)
7697 (void) ThrowMagickException(exception,GetMagickModule(),
7698 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7702 InsertImageInList(&q,p);
7704 *images=GetFirstImageInList(q);
7707 if (LocaleCompare("interpolate",option+1) == 0)
7709 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7710 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7717 if (LocaleCompare("layers",option+1) == 0)
7725 (void) SyncImagesSettings(mogrify_info,*images,exception);
7726 layers=(Image *) NULL;
7727 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7728 MagickFalse,argv[i+1]);
7733 layers=CoalesceImages(*images,exception);
7736 case CompareAnyLayer:
7737 case CompareClearLayer:
7738 case CompareOverlayLayer:
7741 layers=CompareImagesLayers(*images,method,exception);
7747 case TrimBoundsLayer:
7749 layers=MergeImageLayers(*images,method,exception);
7754 layers=DisposeImages(*images,exception);
7757 case OptimizeImageLayer:
7759 layers=OptimizeImageLayers(*images,exception);
7762 case OptimizePlusLayer:
7764 layers=OptimizePlusImageLayers(*images,exception);
7767 case OptimizeTransLayer:
7769 OptimizeImageTransparency(*images,exception);
7772 case RemoveDupsLayer:
7774 RemoveDuplicateLayers(images,exception);
7777 case RemoveZeroLayer:
7779 RemoveZeroDelayLayers(images,exception);
7785 General Purpose, GIF Animation Optimizer.
7787 layers=CoalesceImages(*images,exception);
7788 if (layers == (Image *) NULL)
7793 *images=DestroyImageList(*images);
7795 layers=OptimizeImageLayers(*images,exception);
7796 if (layers == (Image *) NULL)
7801 *images=DestroyImageList(*images);
7803 layers=(Image *) NULL;
7804 OptimizeImageTransparency(*images,exception);
7805 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7809 case CompositeLayer:
7821 Split image sequence at the first 'NULL:' image.
7824 while (source != (Image *) NULL)
7826 source=GetNextImageInList(source);
7827 if ((source != (Image *) NULL) &&
7828 (LocaleCompare(source->magick,"NULL") == 0))
7831 if (source != (Image *) NULL)
7833 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7834 (GetNextImageInList(source) == (Image *) NULL))
7835 source=(Image *) NULL;
7839 Separate the two lists, junk the null: image.
7841 source=SplitImageList(source->previous);
7842 DeleteImageFromList(&source);
7845 if (source == (Image *) NULL)
7847 (void) ThrowMagickException(exception,GetMagickModule(),
7848 OptionError,"MissingNullSeparator","layers Composite");
7853 Adjust offset with gravity and virtual canvas.
7855 SetGeometry(*images,&geometry);
7856 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7857 geometry.width=source->page.width != 0 ?
7858 source->page.width : source->columns;
7859 geometry.height=source->page.height != 0 ?
7860 source->page.height : source->rows;
7861 GravityAdjustGeometry((*images)->page.width != 0 ?
7862 (*images)->page.width : (*images)->columns,
7863 (*images)->page.height != 0 ? (*images)->page.height :
7864 (*images)->rows,(*images)->gravity,&geometry);
7865 compose=OverCompositeOp;
7866 option=GetImageOption(mogrify_info,"compose");
7867 if (option != (const char *) NULL)
7868 compose=(CompositeOperator) ParseCommandOption(
7869 MagickComposeOptions,MagickFalse,option);
7870 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7872 source=DestroyImageList(source);
7876 if (layers == (Image *) NULL)
7878 *images=DestroyImageList(*images);
7886 if (LocaleCompare("map",option+1) == 0)
7888 (void) SyncImagesSettings(mogrify_info,*images,exception);
7891 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7898 if (LocaleCompare("maximum",option+1) == 0)
7904 Maximum image sequence (deprecated).
7906 (void) SyncImagesSettings(mogrify_info,*images,exception);
7907 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7908 if (maximum_image == (Image *) NULL)
7913 *images=DestroyImageList(*images);
7914 *images=maximum_image;
7917 if (LocaleCompare("minimum",option+1) == 0)
7923 Minimum image sequence (deprecated).
7925 (void) SyncImagesSettings(mogrify_info,*images,exception);
7926 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7927 if (minimum_image == (Image *) NULL)
7932 *images=DestroyImageList(*images);
7933 *images=minimum_image;
7936 if (LocaleCompare("morph",option+1) == 0)
7941 (void) SyncImagesSettings(mogrify_info,*images,exception);
7942 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7944 if (morph_image == (Image *) NULL)
7949 *images=DestroyImageList(*images);
7950 *images=morph_image;
7953 if (LocaleCompare("mosaic",option+1) == 0)
7958 (void) SyncImagesSettings(mogrify_info,*images,exception);
7959 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7960 if (mosaic_image == (Image *) NULL)
7965 *images=DestroyImageList(*images);
7966 *images=mosaic_image;
7973 if (LocaleCompare("print",option+1) == 0)
7978 (void) SyncImagesSettings(mogrify_info,*images,exception);
7979 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7981 if (string == (char *) NULL)
7983 (void) FormatLocaleFile(stdout,"%s",string);
7984 string=DestroyString(string);
7986 if (LocaleCompare("process",option+1) == 0)
7995 (void) SyncImagesSettings(mogrify_info,*images,exception);
7996 arguments=StringToArgv(argv[i+1],&number_arguments);
7997 if (arguments == (char **) NULL)
7999 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8020 Support old style syntax, filter="-option arg".
8022 length=strlen(argv[i+1]);
8023 token=(char *) NULL;
8024 if (~length >= (MaxTextExtent-1))
8025 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8027 if (token == (char *) NULL)
8030 arguments=argv[i+1];
8031 token_info=AcquireTokenInfo();
8032 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8033 "\"",'\0',&breaker,&next,"e);
8034 token_info=DestroyTokenInfo(token_info);
8040 argv=(&(arguments[next]));
8041 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8044 token=DestroyString(token);
8047 (void) SubstituteString(&arguments[1],"-","");
8048 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8049 number_arguments-2,(const char **) arguments+2,exception);
8050 for (j=0; j < number_arguments; j++)
8051 arguments[j]=DestroyString(arguments[j]);
8052 arguments=(char **) RelinquishMagickMemory(arguments);
8059 if (LocaleCompare("reverse",option+1) == 0)
8061 ReverseImageList(images);
8068 if (LocaleCompare("smush",option+1) == 0)
8076 (void) SyncImagesSettings(mogrify_info,*images,exception);
8077 offset=(ssize_t) StringToLong(argv[i+1]);
8078 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8079 MagickFalse,offset,exception);
8080 if (smush_image == (Image *) NULL)
8085 *images=DestroyImageList(*images);
8086 *images=smush_image;
8089 if (LocaleCompare("swap",option+1) == 0)
8110 flags=ParseGeometry(argv[i+1],&geometry_info);
8111 index=(ssize_t) geometry_info.rho;
8112 if ((flags & SigmaValue) != 0)
8113 swap_index=(ssize_t) geometry_info.sigma;
8115 p=GetImageFromList(*images,index);
8116 q=GetImageFromList(*images,swap_index);
8117 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8119 (void) ThrowMagickException(exception,GetMagickModule(),
8120 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8126 swap=CloneImage(p,0,0,MagickTrue,exception);
8127 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8128 ReplaceImageInList(&q,swap);
8129 *images=GetFirstImageInList(q);
8136 if (LocaleCompare("write",option+1) == 0)
8147 (void) SyncImagesSettings(mogrify_info,*images,exception);
8148 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8149 (void) DeleteImageRegistry(key);
8150 write_images=(*images);
8152 write_images=CloneImageList(*images,exception);
8153 write_info=CloneImageInfo(mogrify_info);
8154 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8155 write_info=DestroyImageInfo(write_info);
8157 write_images=DestroyImageList(write_images);
8167 quantize_info=DestroyQuantizeInfo(quantize_info);
8168 mogrify_info=DestroyImageInfo(mogrify_info);
8169 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8170 return(status != 0 ? MagickTrue : MagickFalse);
8174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8178 + M o g r i f y I m a g e s %
8182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8184 % MogrifyImages() applies image processing options to a sequence of images as
8185 % prescribed by command line options.
8187 % The format of the MogrifyImage method is:
8189 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8190 % const MagickBooleanType post,const int argc,const char **argv,
8191 % Image **images,Exceptioninfo *exception)
8193 % A description of each parameter follows:
8195 % o image_info: the image info..
8197 % o post: If true, post process image list operators otherwise pre-process.
8199 % o argc: Specifies a pointer to an integer describing the number of
8200 % elements in the argument vector.
8202 % o argv: Specifies a pointer to a text array containing the command line
8205 % o images: pointer to a pointer of the first image in image list.
8207 % o exception: return any errors or warnings in this structure.
8210 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8211 const MagickBooleanType post,const int argc,const char **argv,
8212 Image **images,ExceptionInfo *exception)
8214 #define MogrifyImageTag "Mogrify/Image"
8228 assert(image_info != (ImageInfo *) NULL);
8229 assert(image_info->signature == MagickSignature);
8230 if (images == (Image **) NULL)
8231 return(MogrifyImage(image_info,argc,argv,images,exception));
8232 assert((*images)->previous == (Image *) NULL);
8233 assert((*images)->signature == MagickSignature);
8234 if ((*images)->debug != MagickFalse)
8235 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8236 (*images)->filename);
8237 if ((argc <= 0) || (*argv == (char *) NULL))
8239 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8244 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8249 Pre-process multi-image sequence operators
8251 if (post == MagickFalse)
8252 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8254 For each image, process simple single image operators
8257 n=GetImageListLength(*images);
8261 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8262 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8264 status&=MogrifyImage(image_info,argc,argv,images,exception);
8265 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8266 if (proceed == MagickFalse)
8268 if ( (*images)->next == (Image *) NULL )
8270 *images=(*images)->next;
8273 assert( *images != (Image *) NULL );
8275 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8276 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8280 Post-process, multi-image sequence operators
8282 *images=GetFirstImageInList(*images);
8283 if (post != MagickFalse)
8284 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8285 return(status != 0 ? MagickTrue : MagickFalse);