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-2010 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 "wand/studio.h"
48 #include "wand/MagickWand.h"
49 #include "wand/mogrify-private.h"
50 #include "magick/monitor-private.h"
51 #include "magick/thread-private.h"
52 #include "magick/string-private.h"
57 #define UndefinedCompressionQuality 0UL
63 BackgroundColor[] = "#fff", /* white */
64 BorderColor[] = "#dfdfdf", /* gray */
65 MatteColor[] = "#bdbdbd"; /* gray */
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 % M a g i c k C o m m a n d G e n e s i s %
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 % MagickCommandGenesis() applies image processing options to an image as
79 % prescribed by command line options.
81 % The format of the MagickCommandGenesis method is:
83 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
84 % MagickCommand command,int argc,char **argv,char **metadata,
85 % ExceptionInfo *exception)
87 % A description of each parameter follows:
89 % o image_info: the image info.
91 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
92 % MogrifyImageCommand, CompositeImageCommand, CompareImageCommand,
93 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
94 % DisplayImageCommand, or AnimateImageCommand.
96 % o argc: Specifies a pointer to an integer describing the number of
97 % elements in the argument vector.
99 % o argv: Specifies a pointer to a text array containing the command line
102 % o metadata: any metadata is returned here.
104 % o exception: return any errors or warnings in this structure.
107 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
108 MagickCommand command,int argc,char **argv,char **metadata,
109 ExceptionInfo *exception)
133 (void) setlocale(LC_ALL,"");
134 (void) setlocale(LC_NUMERIC,"C");
135 concurrent=MagickFalse;
139 regard_warnings=MagickFalse;
140 for (i=1; i < (ssize_t) (argc-1); i++)
143 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
145 if (LocaleCompare("bench",option+1) == 0)
146 iterations=StringToUnsignedLong(argv[++i]);
147 if (LocaleCompare("concurrent",option+1) == 0)
148 concurrent=MagickTrue;
149 if (LocaleCompare("debug",option+1) == 0)
150 (void) SetLogEventMask(argv[++i]);
151 if (LocaleCompare("duration",option+1) == 0)
152 duration=StringToDouble(argv[++i]);
153 if (LocaleCompare("regard-warnings",option+1) == 0)
154 regard_warnings=MagickTrue;
156 timer=AcquireTimerInfo();
157 if (concurrent == MagickFalse)
159 for (i=0; i < (ssize_t) iterations; i++)
161 if (status != MagickFalse)
165 if (GetElapsedTime(timer) > duration)
167 (void) ContinueTimer(timer);
169 status=command(image_info,argc,argv,metadata,exception);
170 if (exception->severity != UndefinedException)
172 if ((exception->severity > ErrorException) ||
173 (regard_warnings != MagickFalse))
175 CatchException(exception);
177 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
179 (void) fputs(*metadata,stdout);
180 (void) fputc('\n',stdout);
181 *metadata=DestroyString(*metadata);
188 #if defined(MAGICKCORE_OPENMP_SUPPORT)
189 # pragma omp parallel for shared(status)
191 for (i=0; i < (ssize_t) iterations; i++)
193 if (status != MagickFalse)
197 if (GetElapsedTime(timer) > duration)
199 (void) ContinueTimer(timer);
201 status=command(image_info,argc,argv,metadata,exception);
202 #if defined(MAGICKCORE_OPENMP_SUPPORT)
203 # pragma omp critical (MagickCore_CommandGenesis)
206 if (exception->severity != UndefinedException)
208 if ((exception->severity > ErrorException) ||
209 (regard_warnings != MagickFalse))
211 CatchException(exception);
213 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
215 (void) fputs(*metadata,stdout);
216 (void) fputc('\n',stdout);
217 *metadata=DestroyString(*metadata);
224 elapsed_time=GetElapsedTime(timer);
225 user_time=GetUserTime(timer);
226 (void) fprintf(stderr,
227 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
228 iterations,1.0*iterations/elapsed_time,user_time,(double)
229 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
230 (1000.0*(elapsed_time-floor(elapsed_time))));
231 (void) fflush(stderr);
233 timer=DestroyTimerInfo(timer);
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 + M o g r i f y I m a g e %
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 % MogrifyImage() applies image processing options to an image as prescribed
249 % by command line options.
251 % The format of the MogrifyImage method is:
253 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
254 % const char **argv,Image **image)
256 % A description of each parameter follows:
258 % o image_info: the image info..
260 % o argc: Specifies a pointer to an integer describing the number of
261 % elements in the argument vector.
263 % o argv: Specifies a pointer to a text array containing the command line
266 % o image: the image.
268 % o exception: return any errors or warnings in this structure.
272 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
273 ExceptionInfo *exception)
287 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
288 sans_exception=AcquireExceptionInfo();
289 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
290 sans_exception=DestroyExceptionInfo(sans_exception);
291 if (image != (Image *) NULL)
293 read_info=CloneImageInfo(image_info);
294 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
295 image=ReadImage(read_info,exception);
296 read_info=DestroyImageInfo(read_info);
297 if (image != (Image *) NULL)
298 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
302 static MagickBooleanType IsPathWritable(const char *path)
304 if (IsPathAccessible(path) == MagickFalse)
306 if (access(path,W_OK) != 0)
311 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
318 static MagickBooleanType MonitorProgress(const char *text,
319 const MagickOffsetType offset,const MagickSizeType extent,
320 void *wand_unused(client_data))
323 message[MaxTextExtent],
334 (void) CopyMagickMemory(tag,text,MaxTextExtent);
336 if (p != (char *) NULL)
338 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
339 locale_message=GetLocaleMessage(message);
340 if (locale_message == message)
342 if (p == (char *) NULL)
343 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
344 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
346 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
347 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
348 (100L*offset/(extent-1)));
349 if (offset == (MagickOffsetType) (extent-1))
350 (void) fprintf(stderr,"\n");
351 (void) fflush(stderr);
355 static Image *SparseColorOption(const Image *image,const ChannelType channel,
356 const SparseColorMethod method,const char *arguments,
357 const MagickBooleanType color_from_image,ExceptionInfo *exception)
363 token[MaxTextExtent];
389 assert(image != (Image *) NULL);
390 assert(image->signature == MagickSignature);
391 if (image->debug != MagickFalse)
392 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
393 assert(exception != (ExceptionInfo *) NULL);
394 assert(exception->signature == MagickSignature);
396 Limit channels according to image - and add up number of color channel.
399 if (image->colorspace != CMYKColorspace)
400 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
401 if (image->matte == MagickFalse)
402 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
404 if ((channels & RedChannel) != 0)
406 if ((channels & GreenChannel) != 0)
408 if ((channels & BlueChannel) != 0)
410 if ((channels & IndexChannel) != 0)
412 if ((channels & OpacityChannel) != 0)
415 Read string, to determine number of arguments needed,
421 GetMagickToken(p,&p,token);
422 if ( token[0] == ',' ) continue;
423 if ( isalpha((int) token[0]) || token[0] == '#' ) {
424 if ( color_from_image ) {
425 (void) ThrowMagickException(exception,GetMagickModule(),
426 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
427 "Color arg given, when colors are coming from image");
428 return( (Image *)NULL);
430 x += number_colors; /* color argument */
433 x++; /* floating point argument */
437 if ( color_from_image ) {
438 /* just the control points are being given */
439 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
440 number_arguments=(x/2)*(2+number_colors);
443 /* control points and color values */
444 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
448 (void) ThrowMagickException(exception,GetMagickModule(),
449 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
450 "Invalid number of Arguments");
451 return( (Image *)NULL);
454 /* Allocate and fill in the floating point arguments */
455 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
456 sizeof(*sparse_arguments));
457 if (sparse_arguments == (double *) NULL) {
458 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
459 "MemoryAllocationFailed","%s","SparseColorOption");
460 return( (Image *)NULL);
462 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
463 sizeof(*sparse_arguments));
466 while( *p != '\0' && x < number_arguments ) {
468 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
469 if ( token[0] == '\0' ) break;
470 if ( isalpha((int) token[0]) || token[0] == '#' ) {
471 (void) ThrowMagickException(exception,GetMagickModule(),
472 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
473 "Color found, instead of X-coord");
477 sparse_arguments[x++]=StringToDouble(token);
479 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
480 if ( token[0] == '\0' ) break;
481 if ( isalpha((int) token[0]) || token[0] == '#' ) {
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Color found, instead of Y-coord");
488 sparse_arguments[x++]=StringToDouble(token);
489 /* color values for this control point */
491 if ( (color_from_image ) {
492 /* get color from image */
498 /* color name or function given in string argument */
499 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
500 if ( token[0] == '\0' ) break;
501 if ( isalpha((int) token[0]) || token[0] == '#' ) {
502 /* Color string given */
503 (void) QueryMagickColor(token,&color,exception);
504 if ( channels & RedChannel )
505 sparse_arguments[x++] = QuantumScale*color.red;
506 if ( channels & GreenChannel )
507 sparse_arguments[x++] = QuantumScale*color.green;
508 if ( channels & BlueChannel )
509 sparse_arguments[x++] = QuantumScale*color.blue;
510 if ( channels & IndexChannel )
511 sparse_arguments[x++] = QuantumScale*color.index;
512 if ( channels & OpacityChannel )
513 sparse_arguments[x++] = QuantumScale*color.opacity;
517 /* the color name/function/value was not found - error */
520 /* Colors given as a set of floating point values - experimental */
521 /* NB: token contains the first floating point value to use! */
522 if ( channels & RedChannel ) {
523 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
524 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
526 sparse_arguments[x++]=StringToDouble(token);
527 token[0] = ','; /* used this token - get another */
529 if ( channels & GreenChannel ) {
530 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
531 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
533 sparse_arguments[x++]=StringToDouble(token);
534 token[0] = ','; /* used this token - get another */
536 if ( channels & BlueChannel ) {
537 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
538 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
540 sparse_arguments[x++]=StringToDouble(token);
541 token[0] = ','; /* used this token - get another */
543 if ( channels & IndexChannel ) {
544 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
545 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
547 sparse_arguments[x++]=StringToDouble(token);
548 token[0] = ','; /* used this token - get another */
550 if ( channels & OpacityChannel ) {
551 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
552 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
554 sparse_arguments[x++]=StringToDouble(token);
555 token[0] = ','; /* used this token - get another */
561 if ( number_arguments != x && !error ) {
562 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
563 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
564 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
565 return( (Image *)NULL);
568 return( (Image *)NULL);
570 /* Call the Interpolation function with the parsed arguments */
571 sparse_image=SparseColorImage(image,channels,method,number_arguments,
572 sparse_arguments,exception);
573 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
574 return( sparse_image );
577 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
578 const char **argv,Image **image,ExceptionInfo *exception)
622 Initialize method variables.
624 assert(image_info != (const ImageInfo *) NULL);
625 assert(image_info->signature == MagickSignature);
626 assert(image != (Image **) NULL);
627 assert((*image)->signature == MagickSignature);
628 if ((*image)->debug != MagickFalse)
629 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
632 mogrify_info=CloneImageInfo(image_info);
633 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
634 quantize_info=AcquireQuantizeInfo(mogrify_info);
635 SetGeometryInfo(&geometry_info);
636 GetMagickPixelPacket(*image,&fill);
637 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
639 channel=mogrify_info->channel;
640 format=GetImageOption(mogrify_info,"format");
641 SetGeometry(*image,®ion_geometry);
642 region_image=NewImageList();
644 Transmogrify the image.
646 for (i=0; i < (ssize_t) argc; i++)
649 if (IsMagickOption(option) == MagickFalse)
651 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
653 if ((i+count) >= (ssize_t) argc)
655 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
660 if (LocaleCompare("adaptive-blur",option+1) == 0)
668 (void) SyncImageSettings(mogrify_info,*image);
669 flags=ParseGeometry(argv[i+1],&geometry_info);
670 if ((flags & SigmaValue) == 0)
671 geometry_info.sigma=1.0;
672 blur_image=AdaptiveBlurImageChannel(*image,channel,
673 geometry_info.rho,geometry_info.sigma,exception);
674 if (blur_image == (Image *) NULL)
676 *image=DestroyImage(*image);
680 if (LocaleCompare("adaptive-resize",option+1) == 0)
686 Adaptive resize image.
688 (void) SyncImageSettings(mogrify_info,*image);
689 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
690 resize_image=AdaptiveResizeImage(*image,geometry.width,
691 geometry.height,exception);
692 if (resize_image == (Image *) NULL)
694 *image=DestroyImage(*image);
698 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
704 Adaptive sharpen image.
706 (void) SyncImageSettings(mogrify_info,*image);
707 flags=ParseGeometry(argv[i+1],&geometry_info);
708 if ((flags & SigmaValue) == 0)
709 geometry_info.sigma=1.0;
710 sharp_image=AdaptiveSharpenImageChannel(*image,channel,
711 geometry_info.rho,geometry_info.sigma,exception);
712 if (sharp_image == (Image *) NULL)
714 *image=DestroyImage(*image);
718 if (LocaleCompare("affine",option+1) == 0)
725 GetAffineMatrix(&draw_info->affine);
728 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
731 if (LocaleCompare("alpha",option+1) == 0)
736 (void) SyncImageSettings(mogrify_info,*image);
737 alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
738 MagickFalse,argv[i+1]);
739 (void) SetImageAlphaChannel(*image,alpha_type);
740 InheritException(exception,&(*image)->exception);
743 if (LocaleCompare("annotate",option+1) == 0)
747 geometry[MaxTextExtent];
752 (void) SyncImageSettings(mogrify_info,*image);
753 SetGeometryInfo(&geometry_info);
754 flags=ParseGeometry(argv[i+1],&geometry_info);
755 if ((flags & SigmaValue) == 0)
756 geometry_info.sigma=geometry_info.rho;
757 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
758 InheritException(exception,&(*image)->exception);
759 if (text == (char *) NULL)
761 (void) CloneString(&draw_info->text,text);
762 text=DestroyString(text);
763 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
764 geometry_info.xi,geometry_info.psi);
765 (void) CloneString(&draw_info->geometry,geometry);
766 draw_info->affine.sx=cos(DegreesToRadians(
767 fmod(geometry_info.rho,360.0)));
768 draw_info->affine.rx=sin(DegreesToRadians(
769 fmod(geometry_info.rho,360.0)));
770 draw_info->affine.ry=(-sin(DegreesToRadians(
771 fmod(geometry_info.sigma,360.0))));
772 draw_info->affine.sy=cos(DegreesToRadians(
773 fmod(geometry_info.sigma,360.0)));
774 (void) AnnotateImage(*image,draw_info);
775 InheritException(exception,&(*image)->exception);
778 if (LocaleCompare("antialias",option+1) == 0)
780 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
782 draw_info->text_antialias=(*option == '-') ? MagickTrue :
786 if (LocaleCompare("auto-gamma",option+1) == 0)
789 Auto Adjust Gamma of image based on its mean
791 (void) SyncImageSettings(mogrify_info,*image);
792 (void) AutoGammaImageChannel(*image,channel);
795 if (LocaleCompare("auto-level",option+1) == 0)
798 Perfectly Normalize (max/min stretch) the image
800 (void) SyncImageSettings(mogrify_info,*image);
801 (void) AutoLevelImageChannel(*image,channel);
804 if (LocaleCompare("auto-orient",option+1) == 0)
809 (void) SyncImageSettings(mogrify_info,*image);
810 orient_image=NewImageList();
811 switch ((*image)->orientation)
813 case TopRightOrientation:
815 orient_image=FlopImage(*image,exception);
818 case BottomRightOrientation:
820 orient_image=RotateImage(*image,180.0,exception);
823 case BottomLeftOrientation:
825 orient_image=FlipImage(*image,exception);
828 case LeftTopOrientation:
830 orient_image=TransposeImage(*image,exception);
833 case RightTopOrientation:
835 orient_image=RotateImage(*image,90.0,exception);
838 case RightBottomOrientation:
840 orient_image=TransverseImage(*image,exception);
843 case LeftBottomOrientation:
845 orient_image=RotateImage(*image,270.0,exception);
851 if (orient_image == (Image *) NULL)
853 orient_image->orientation=TopLeftOrientation;
854 *image=DestroyImage(*image);
862 if (LocaleCompare("black-threshold",option+1) == 0)
865 Black threshold image.
867 (void) SyncImageSettings(mogrify_info,*image);
868 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
870 InheritException(exception,&(*image)->exception);
873 if (LocaleCompare("blue-shift",option+1) == 0)
881 (void) SyncImageSettings(mogrify_info,*image);
882 geometry_info.rho=1.5;
884 flags=ParseGeometry(argv[i+1],&geometry_info);
885 shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
886 if (shift_image == (Image *) NULL)
888 *image=DestroyImage(*image);
892 if (LocaleCompare("blur",option+1) == 0)
900 (void) SyncImageSettings(mogrify_info,*image);
901 flags=ParseGeometry(argv[i+1],&geometry_info);
902 if ((flags & SigmaValue) == 0)
903 geometry_info.sigma=1.0;
904 blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
905 geometry_info.sigma,exception);
906 if (blur_image == (Image *) NULL)
908 *image=DestroyImage(*image);
912 if (LocaleCompare("border",option+1) == 0)
918 Surround image with a border of solid color.
920 (void) SyncImageSettings(mogrify_info,*image);
921 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
922 if ((flags & SigmaValue) == 0)
923 geometry.height=geometry.width;
924 border_image=BorderImage(*image,&geometry,exception);
925 if (border_image == (Image *) NULL)
927 *image=DestroyImage(*image);
931 if (LocaleCompare("bordercolor",option+1) == 0)
935 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
939 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
943 if (LocaleCompare("box",option+1) == 0)
945 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
949 if (LocaleCompare("brightness-contrast",option+1) == 0)
962 Brightness / contrast image.
964 (void) SyncImageSettings(mogrify_info,*image);
965 flags=ParseGeometry(argv[i+1],&geometry_info);
966 brightness=geometry_info.rho;
968 if ((flags & SigmaValue) != 0)
969 contrast=geometry_info.sigma;
970 (void) BrightnessContrastImageChannel(*image,channel,brightness,
972 InheritException(exception,&(*image)->exception);
979 if (LocaleCompare("cdl",option+1) == 0)
982 *color_correction_collection;
985 Color correct with a color decision list.
987 (void) SyncImageSettings(mogrify_info,*image);
988 color_correction_collection=FileToString(argv[i+1],~0,exception);
989 if (color_correction_collection == (char *) NULL)
991 (void) ColorDecisionListImage(*image,color_correction_collection);
992 InheritException(exception,&(*image)->exception);
995 if (LocaleCompare("channel",option+1) == 0)
999 channel=DefaultChannels;
1002 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1005 if (LocaleCompare("charcoal",option+1) == 0)
1013 (void) SyncImageSettings(mogrify_info,*image);
1014 flags=ParseGeometry(argv[i+1],&geometry_info);
1015 if ((flags & SigmaValue) == 0)
1016 geometry_info.sigma=1.0;
1017 charcoal_image=CharcoalImage(*image,geometry_info.rho,
1018 geometry_info.sigma,exception);
1019 if (charcoal_image == (Image *) NULL)
1021 *image=DestroyImage(*image);
1022 *image=charcoal_image;
1025 if (LocaleCompare("chop",option+1) == 0)
1033 (void) SyncImageSettings(mogrify_info,*image);
1034 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1035 chop_image=ChopImage(*image,&geometry,exception);
1036 if (chop_image == (Image *) NULL)
1038 *image=DestroyImage(*image);
1042 if (LocaleCompare("clamp",option+1) == 0)
1047 (void) SyncImageSettings(mogrify_info,*image);
1048 (void) ClampImageChannel(*image,channel);
1049 InheritException(exception,&(*image)->exception);
1052 if (LocaleCompare("clip",option+1) == 0)
1054 (void) SyncImageSettings(mogrify_info,*image);
1057 (void) SetImageClipMask(*image,(Image *) NULL);
1058 InheritException(exception,&(*image)->exception);
1061 (void) ClipImage(*image);
1062 InheritException(exception,&(*image)->exception);
1065 if (LocaleCompare("clip-mask",option+1) == 0)
1079 register PixelPacket
1082 (void) SyncImageSettings(mogrify_info,*image);
1088 (void) SetImageMask(*image,(Image *) NULL);
1089 InheritException(exception,&(*image)->exception);
1095 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1096 if (mask_image == (Image *) NULL)
1098 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1099 return(MagickFalse);
1100 mask_view=AcquireCacheView(mask_image);
1101 for (y=0; y < (ssize_t) mask_image->rows; y++)
1103 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1105 if (q == (PixelPacket *) NULL)
1107 for (x=0; x < (ssize_t) mask_image->columns; x++)
1109 if (mask_image->matte == MagickFalse)
1110 q->opacity=PixelIntensityToQuantum(q);
1112 q->green=q->opacity;
1116 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1119 mask_view=DestroyCacheView(mask_view);
1120 mask_image->matte=MagickTrue;
1121 (void) SetImageClipMask(*image,mask_image);
1122 mask_image=DestroyImage(mask_image);
1123 InheritException(exception,&(*image)->exception);
1126 if (LocaleCompare("clip-path",option+1) == 0)
1128 (void) SyncImageSettings(mogrify_info,*image);
1129 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1131 InheritException(exception,&(*image)->exception);
1134 if (LocaleCompare("colorize",option+1) == 0)
1142 (void) SyncImageSettings(mogrify_info,*image);
1143 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1145 if (colorize_image == (Image *) NULL)
1147 *image=DestroyImage(*image);
1148 *image=colorize_image;
1151 if (LocaleCompare("color-matrix",option+1) == 0)
1159 (void) SyncImageSettings(mogrify_info,*image);
1160 kernel=AcquireKernelInfo(argv[i+1]);
1161 if (kernel == (KernelInfo *) NULL)
1163 color_image=ColorMatrixImage(*image,kernel,exception);
1164 kernel=DestroyKernelInfo(kernel);
1165 if (color_image == (Image *) NULL)
1167 *image=DestroyImage(*image);
1171 if (LocaleCompare("colors",option+1) == 0)
1174 Reduce the number of colors in the image.
1176 (void) SyncImageSettings(mogrify_info,*image);
1177 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1178 if (quantize_info->number_colors == 0)
1180 if (((*image)->storage_class == DirectClass) ||
1181 (*image)->colors > quantize_info->number_colors)
1182 (void) QuantizeImage(quantize_info,*image);
1184 (void) CompressImageColormap(*image);
1185 InheritException(exception,&(*image)->exception);
1188 if (LocaleCompare("colorspace",option+1) == 0)
1193 (void) SyncImageSettings(mogrify_info,*image);
1196 (void) TransformImageColorspace(*image,RGBColorspace);
1197 InheritException(exception,&(*image)->exception);
1200 colorspace=(ColorspaceType) ParseMagickOption(
1201 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1202 (void) TransformImageColorspace(*image,colorspace);
1203 InheritException(exception,&(*image)->exception);
1206 if (LocaleCompare("contrast",option+1) == 0)
1208 (void) SyncImageSettings(mogrify_info,*image);
1209 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1211 InheritException(exception,&(*image)->exception);
1214 if (LocaleCompare("contrast-stretch",option+1) == 0)
1224 Contrast stretch image.
1226 (void) SyncImageSettings(mogrify_info,*image);
1227 flags=ParseGeometry(argv[i+1],&geometry_info);
1228 black_point=geometry_info.rho;
1229 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1231 if ((flags & PercentValue) != 0)
1233 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1234 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1236 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1238 (void) ContrastStretchImageChannel(*image,channel,black_point,
1240 InheritException(exception,&(*image)->exception);
1243 if (LocaleCompare("convolve",option+1) == 0)
1257 (void) SyncImageSettings(mogrify_info,*image);
1258 kernel=AcquireKernelInfo(argv[i+1]);
1259 if (kernel == (KernelInfo *) NULL)
1262 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1263 gamma+=kernel->values[j];
1264 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1265 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1266 kernel->values[j]*=gamma;
1267 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
1268 kernel=DestroyKernelInfo(kernel);
1269 if (convolve_image == (Image *) NULL)
1271 *image=DestroyImage(*image);
1272 *image=convolve_image;
1275 if (LocaleCompare("crop",option+1) == 0)
1277 (void) SyncImageSettings(mogrify_info,*image);
1278 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1279 if (((geometry.width != 0) || (geometry.height != 0)) &&
1280 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1282 (void) TransformImage(image,argv[i+1],(char *) NULL);
1283 InheritException(exception,&(*image)->exception);
1286 if (LocaleCompare("cycle",option+1) == 0)
1289 Cycle an image colormap.
1291 (void) SyncImageSettings(mogrify_info,*image);
1292 (void) CycleColormapImage(*image,StringToLong(argv[i+1]));
1293 InheritException(exception,&(*image)->exception);
1300 if (LocaleCompare("decipher",option+1) == 0)
1308 (void) SyncImageSettings(mogrify_info,*image);
1309 passkey=FileToStringInfo(argv[i+1],~0,exception);
1310 if (passkey != (StringInfo *) NULL)
1312 (void) PasskeyDecipherImage(*image,passkey,exception);
1313 passkey=DestroyStringInfo(passkey);
1317 if (LocaleCompare("density",option+1) == 0)
1322 (void) CloneString(&draw_info->density,argv[i+1]);
1325 if (LocaleCompare("depth",option+1) == 0)
1327 (void) SyncImageSettings(mogrify_info,*image);
1330 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1333 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1336 if (LocaleCompare("deskew",option+1) == 0)
1345 Straighten the image.
1347 (void) SyncImageSettings(mogrify_info,*image);
1349 threshold=40.0*QuantumRange/100.0;
1351 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1352 deskew_image=DeskewImage(*image,threshold,exception);
1353 if (deskew_image == (Image *) NULL)
1355 *image=DestroyImage(*image);
1356 *image=deskew_image;
1359 if (LocaleCompare("despeckle",option+1) == 0)
1365 Reduce the speckles within an image.
1367 (void) SyncImageSettings(mogrify_info,*image);
1368 despeckle_image=DespeckleImage(*image,exception);
1369 if (despeckle_image == (Image *) NULL)
1371 *image=DestroyImage(*image);
1372 *image=despeckle_image;
1375 if (LocaleCompare("display",option+1) == 0)
1377 (void) CloneString(&draw_info->server_name,argv[i+1]);
1380 if (LocaleCompare("distort",option+1) == 0)
1384 token[MaxTextExtent];
1407 (void) SyncImageSettings(mogrify_info,*image);
1408 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1409 MagickFalse,argv[i+1]);
1410 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1411 InheritException(exception,&(*image)->exception);
1412 if (args == (char *) NULL)
1415 for (x=0; *p != '\0'; x++)
1417 GetMagickToken(p,&p,token);
1419 GetMagickToken(p,&p,token);
1421 number_arguments=(size_t) x;
1422 arguments=(double *) AcquireQuantumMemory(number_arguments,
1423 sizeof(*arguments));
1424 if (arguments == (double *) NULL)
1425 ThrowWandFatalException(ResourceLimitFatalError,
1426 "MemoryAllocationFailed",(*image)->filename);
1427 (void) ResetMagickMemory(arguments,0,number_arguments*
1428 sizeof(*arguments));
1430 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1432 GetMagickToken(p,&p,token);
1434 GetMagickToken(p,&p,token);
1435 arguments[x]=StringToDouble(token);
1437 args=DestroyString(args);
1438 distort_image=DistortImage(*image,method,number_arguments,arguments,
1439 (*option == '+') ? MagickTrue : MagickFalse,exception);
1440 arguments=(double *) RelinquishMagickMemory(arguments);
1441 if (distort_image == (Image *) NULL)
1443 *image=DestroyImage(*image);
1444 *image=distort_image;
1447 if (LocaleCompare("dither",option+1) == 0)
1451 quantize_info->dither=MagickFalse;
1454 quantize_info->dither=MagickTrue;
1455 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
1456 MagickDitherOptions,MagickFalse,argv[i+1]);
1457 if (quantize_info->dither_method == NoDitherMethod)
1458 quantize_info->dither=MagickFalse;
1461 if (LocaleCompare("draw",option+1) == 0)
1466 (void) SyncImageSettings(mogrify_info,*image);
1467 (void) CloneString(&draw_info->primitive,argv[i+1]);
1468 (void) DrawImage(*image,draw_info);
1469 InheritException(exception,&(*image)->exception);
1476 if (LocaleCompare("edge",option+1) == 0)
1482 Enhance edges in the image.
1484 (void) SyncImageSettings(mogrify_info,*image);
1485 flags=ParseGeometry(argv[i+1],&geometry_info);
1486 if ((flags & SigmaValue) == 0)
1487 geometry_info.sigma=1.0;
1488 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1489 if (edge_image == (Image *) NULL)
1491 *image=DestroyImage(*image);
1495 if (LocaleCompare("emboss",option+1) == 0)
1501 Gaussian embossen image.
1503 (void) SyncImageSettings(mogrify_info,*image);
1504 flags=ParseGeometry(argv[i+1],&geometry_info);
1505 if ((flags & SigmaValue) == 0)
1506 geometry_info.sigma=1.0;
1507 emboss_image=EmbossImage(*image,geometry_info.rho,
1508 geometry_info.sigma,exception);
1509 if (emboss_image == (Image *) NULL)
1511 *image=DestroyImage(*image);
1512 *image=emboss_image;
1515 if (LocaleCompare("encipher",option+1) == 0)
1523 (void) SyncImageSettings(mogrify_info,*image);
1524 passkey=FileToStringInfo(argv[i+1],~0,exception);
1525 if (passkey != (StringInfo *) NULL)
1527 (void) PasskeyEncipherImage(*image,passkey,exception);
1528 passkey=DestroyStringInfo(passkey);
1532 if (LocaleCompare("encoding",option+1) == 0)
1534 (void) CloneString(&draw_info->encoding,argv[i+1]);
1537 if (LocaleCompare("enhance",option+1) == 0)
1545 (void) SyncImageSettings(mogrify_info,*image);
1546 enhance_image=EnhanceImage(*image,exception);
1547 if (enhance_image == (Image *) NULL)
1549 *image=DestroyImage(*image);
1550 *image=enhance_image;
1553 if (LocaleCompare("equalize",option+1) == 0)
1558 (void) SyncImageSettings(mogrify_info,*image);
1559 (void) EqualizeImageChannel(*image,channel);
1560 InheritException(exception,&(*image)->exception);
1563 if (LocaleCompare("evaluate",option+1) == 0)
1568 MagickEvaluateOperator
1571 (void) SyncImageSettings(mogrify_info,*image);
1572 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1573 MagickFalse,argv[i+1]);
1574 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1575 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1578 if (LocaleCompare("extent",option+1) == 0)
1584 Set the image extent.
1586 (void) SyncImageSettings(mogrify_info,*image);
1587 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1588 if (geometry.width == 0)
1589 geometry.width=(*image)->columns;
1590 if (geometry.height == 0)
1591 geometry.height=(*image)->rows;
1592 extent_image=ExtentImage(*image,&geometry,exception);
1593 if (extent_image == (Image *) NULL)
1595 *image=DestroyImage(*image);
1596 *image=extent_image;
1603 if (LocaleCompare("family",option+1) == 0)
1607 if (draw_info->family != (char *) NULL)
1608 draw_info->family=DestroyString(draw_info->family);
1611 (void) CloneString(&draw_info->family,argv[i+1]);
1614 if (LocaleCompare("features",option+1) == 0)
1618 (void) DeleteImageArtifact(*image,"identify:features");
1621 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1624 if (LocaleCompare("fill",option+1) == 0)
1629 GetMagickPixelPacket(*image,&fill);
1632 (void) QueryMagickColor("none",&fill,exception);
1633 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1634 if (draw_info->fill_pattern != (Image *) NULL)
1635 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1638 sans=AcquireExceptionInfo();
1639 (void) QueryMagickColor(argv[i+1],&fill,sans);
1640 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1641 sans=DestroyExceptionInfo(sans);
1642 if (status == MagickFalse)
1643 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1647 if (LocaleCompare("flip",option+1) == 0)
1653 Flip image scanlines.
1655 (void) SyncImageSettings(mogrify_info,*image);
1656 flip_image=FlipImage(*image,exception);
1657 if (flip_image == (Image *) NULL)
1659 *image=DestroyImage(*image);
1663 if (LocaleCompare("flop",option+1) == 0)
1669 Flop image scanlines.
1671 (void) SyncImageSettings(mogrify_info,*image);
1672 flop_image=FlopImage(*image,exception);
1673 if (flop_image == (Image *) NULL)
1675 *image=DestroyImage(*image);
1679 if (LocaleCompare("floodfill",option+1) == 0)
1687 (void) SyncImageSettings(mogrify_info,*image);
1688 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1689 (void) QueryMagickColor(argv[i+2],&target,exception);
1690 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1691 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1692 InheritException(exception,&(*image)->exception);
1695 if (LocaleCompare("font",option+1) == 0)
1699 if (draw_info->font != (char *) NULL)
1700 draw_info->font=DestroyString(draw_info->font);
1703 (void) CloneString(&draw_info->font,argv[i+1]);
1706 if (LocaleCompare("format",option+1) == 0)
1711 if (LocaleCompare("frame",option+1) == 0)
1720 Surround image with an ornamental border.
1722 (void) SyncImageSettings(mogrify_info,*image);
1723 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1724 frame_info.width=geometry.width;
1725 frame_info.height=geometry.height;
1726 if ((flags & HeightValue) == 0)
1727 frame_info.height=geometry.width;
1728 frame_info.outer_bevel=geometry.x;
1729 frame_info.inner_bevel=geometry.y;
1730 frame_info.x=(ssize_t) frame_info.width;
1731 frame_info.y=(ssize_t) frame_info.height;
1732 frame_info.width=(*image)->columns+2*frame_info.width;
1733 frame_info.height=(*image)->rows+2*frame_info.height;
1734 frame_image=FrameImage(*image,&frame_info,exception);
1735 if (frame_image == (Image *) NULL)
1737 *image=DestroyImage(*image);
1741 if (LocaleCompare("function",option+1) == 0)
1745 token[MaxTextExtent];
1763 Function Modify Image Values
1765 (void) SyncImageSettings(mogrify_info,*image);
1766 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1767 MagickFalse,argv[i+1]);
1768 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1769 InheritException(exception,&(*image)->exception);
1770 if (arguments == (char *) NULL)
1772 p=(char *) arguments;
1773 for (x=0; *p != '\0'; x++)
1775 GetMagickToken(p,&p,token);
1777 GetMagickToken(p,&p,token);
1779 number_parameters=(size_t) x;
1780 parameters=(double *) AcquireQuantumMemory(number_parameters,
1781 sizeof(*parameters));
1782 if (parameters == (double *) NULL)
1783 ThrowWandFatalException(ResourceLimitFatalError,
1784 "MemoryAllocationFailed",(*image)->filename);
1785 (void) ResetMagickMemory(parameters,0,number_parameters*
1786 sizeof(*parameters));
1787 p=(char *) arguments;
1788 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1790 GetMagickToken(p,&p,token);
1792 GetMagickToken(p,&p,token);
1793 parameters[x]=StringToDouble(token);
1795 arguments=DestroyString(arguments);
1796 (void) FunctionImageChannel(*image,channel,function,
1797 number_parameters,parameters,exception);
1798 parameters=(double *) RelinquishMagickMemory(parameters);
1805 if (LocaleCompare("gamma",option+1) == 0)
1810 (void) SyncImageSettings(mogrify_info,*image);
1812 (*image)->gamma=StringToDouble(argv[i+1]);
1815 if (strchr(argv[i+1],',') != (char *) NULL)
1816 (void) GammaImage(*image,argv[i+1]);
1818 (void) GammaImageChannel(*image,channel,
1819 StringToDouble(argv[i+1]));
1820 InheritException(exception,&(*image)->exception);
1824 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1825 (LocaleCompare("gaussian",option+1) == 0))
1831 Gaussian blur image.
1833 (void) SyncImageSettings(mogrify_info,*image);
1834 flags=ParseGeometry(argv[i+1],&geometry_info);
1835 if ((flags & SigmaValue) == 0)
1836 geometry_info.sigma=1.0;
1837 gaussian_image=GaussianBlurImageChannel(*image,channel,
1838 geometry_info.rho,geometry_info.sigma,exception);
1839 if (gaussian_image == (Image *) NULL)
1841 *image=DestroyImage(*image);
1842 *image=gaussian_image;
1845 if (LocaleCompare("geometry",option+1) == 0)
1847 (void) SyncImageSettings(mogrify_info,*image);
1850 if ((*image)->geometry != (char *) NULL)
1851 (*image)->geometry=DestroyString((*image)->geometry);
1854 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1855 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1856 (void) CloneString(&(*image)->geometry,argv[i+1]);
1865 resize_image=ResizeImage(*image,geometry.width,geometry.height,
1866 (*image)->filter,(*image)->blur,exception);
1867 if (resize_image == (Image *) NULL)
1869 *image=DestroyImage(*image);
1870 *image=resize_image;
1874 if (LocaleCompare("gravity",option+1) == 0)
1878 draw_info->gravity=UndefinedGravity;
1881 draw_info->gravity=(GravityType) ParseMagickOption(
1882 MagickGravityOptions,MagickFalse,argv[i+1]);
1889 if (LocaleCompare("highlight-color",option+1) == 0)
1891 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1898 if (LocaleCompare("identify",option+1) == 0)
1903 (void) SyncImageSettings(mogrify_info,*image);
1904 if (format == (char *) NULL)
1906 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1907 InheritException(exception,&(*image)->exception);
1910 text=InterpretImageProperties(mogrify_info,*image,format);
1911 InheritException(exception,&(*image)->exception);
1912 if (text == (char *) NULL)
1914 (void) fputs(text,stdout);
1915 (void) fputc('\n',stdout);
1916 text=DestroyString(text);
1919 if (LocaleCompare("implode",option+1) == 0)
1927 (void) SyncImageSettings(mogrify_info,*image);
1928 (void) ParseGeometry(argv[i+1],&geometry_info);
1929 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1930 if (implode_image == (Image *) NULL)
1932 *image=DestroyImage(*image);
1933 *image=implode_image;
1936 if (LocaleCompare("interline-spacing",option+1) == 0)
1939 (void) ParseGeometry("0",&geometry_info);
1941 (void) ParseGeometry(argv[i+1],&geometry_info);
1942 draw_info->interline_spacing=geometry_info.rho;
1945 if (LocaleCompare("interword-spacing",option+1) == 0)
1948 (void) ParseGeometry("0",&geometry_info);
1950 (void) ParseGeometry(argv[i+1],&geometry_info);
1951 draw_info->interword_spacing=geometry_info.rho;
1958 if (LocaleCompare("kerning",option+1) == 0)
1961 (void) ParseGeometry("0",&geometry_info);
1963 (void) ParseGeometry(argv[i+1],&geometry_info);
1964 draw_info->kerning=geometry_info.rho;
1971 if (LocaleCompare("lat",option+1) == 0)
1977 Local adaptive threshold image.
1979 (void) SyncImageSettings(mogrify_info,*image);
1980 flags=ParseGeometry(argv[i+1],&geometry_info);
1981 if ((flags & PercentValue) != 0)
1982 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1983 threshold_image=AdaptiveThresholdImage(*image,(size_t)
1984 geometry_info.rho,(size_t) geometry_info.sigma,
1985 (ssize_t) geometry_info.xi,exception);
1986 if (threshold_image == (Image *) NULL)
1988 *image=DestroyImage(*image);
1989 *image=threshold_image;
1992 if (LocaleCompare("level",option+1) == 0)
2005 (void) SyncImageSettings(mogrify_info,*image);
2006 flags=ParseGeometry(argv[i+1],&geometry_info);
2007 black_point=geometry_info.rho;
2008 white_point=(MagickRealType) QuantumRange;
2009 if ((flags & SigmaValue) != 0)
2010 white_point=geometry_info.sigma;
2012 if ((flags & XiValue) != 0)
2013 gamma=geometry_info.xi;
2014 if ((flags & PercentValue) != 0)
2016 black_point*=(MagickRealType) (QuantumRange/100.0);
2017 white_point*=(MagickRealType) (QuantumRange/100.0);
2019 if ((flags & SigmaValue) == 0)
2020 white_point=(MagickRealType) QuantumRange-black_point;
2021 if ((*option == '+') || ((flags & AspectValue) != 0))
2022 (void) LevelizeImageChannel(*image,channel,black_point,
2025 (void) LevelImageChannel(*image,channel,black_point,white_point,
2027 InheritException(exception,&(*image)->exception);
2030 if (LocaleCompare("level-colors",option+1) == 0)
2033 token[MaxTextExtent];
2042 p=(const char *) argv[i+1];
2043 GetMagickToken(p,&p,token); /* get black point color */
2044 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2045 (void) QueryMagickColor(token,&black_point,exception);
2047 (void) QueryMagickColor("#000000",&black_point,exception);
2048 if (isalpha((int) token[0]) || (token[0] == '#'))
2049 GetMagickToken(p,&p,token);
2051 white_point=black_point; /* set everything to that color */
2055 Get white point color.
2057 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2058 GetMagickToken(p,&p,token);
2059 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2060 (void) QueryMagickColor(token,&white_point,exception);
2062 (void) QueryMagickColor("#ffffff",&white_point,exception);
2064 (void) LevelColorsImageChannel(*image,channel,&black_point,
2065 &white_point,*option == '+' ? MagickTrue : MagickFalse);
2068 if (LocaleCompare("linear-stretch",option+1) == 0)
2077 (void) SyncImageSettings(mogrify_info,*image);
2078 flags=ParseGeometry(argv[i+1],&geometry_info);
2079 black_point=geometry_info.rho;
2080 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2081 if ((flags & SigmaValue) != 0)
2082 white_point=geometry_info.sigma;
2083 if ((flags & PercentValue) != 0)
2085 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2086 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2088 if ((flags & SigmaValue) == 0)
2089 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2091 (void) LinearStretchImage(*image,black_point,white_point);
2092 InheritException(exception,&(*image)->exception);
2095 if (LocaleCompare("linewidth",option+1) == 0)
2097 draw_info->stroke_width=StringToDouble(argv[i+1]);
2100 if (LocaleCompare("liquid-rescale",option+1) == 0)
2106 Liquid rescale image.
2108 (void) SyncImageSettings(mogrify_info,*image);
2109 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2110 if ((flags & XValue) == 0)
2112 if ((flags & YValue) == 0)
2114 resize_image=LiquidRescaleImage(*image,geometry.width,
2115 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2116 if (resize_image == (Image *) NULL)
2118 *image=DestroyImage(*image);
2119 *image=resize_image;
2122 if (LocaleCompare("lowlight-color",option+1) == 0)
2124 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2131 if (LocaleCompare("map",option+1) == 0)
2137 Transform image colors to match this set of colors.
2139 (void) SyncImageSettings(mogrify_info,*image);
2142 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2143 if (remap_image == (Image *) NULL)
2145 (void) RemapImage(quantize_info,*image,remap_image);
2146 InheritException(exception,&(*image)->exception);
2147 remap_image=DestroyImage(remap_image);
2150 if (LocaleCompare("mask",option+1) == 0)
2155 (void) SyncImageSettings(mogrify_info,*image);
2161 (void) SetImageMask(*image,(Image *) NULL);
2162 InheritException(exception,&(*image)->exception);
2168 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2169 if (mask == (Image *) NULL)
2171 (void) SetImageMask(*image,mask);
2172 mask=DestroyImage(mask);
2173 InheritException(exception,&(*image)->exception);
2176 if (LocaleCompare("matte",option+1) == 0)
2178 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2179 SetAlphaChannel : DeactivateAlphaChannel );
2180 InheritException(exception,&(*image)->exception);
2183 if (LocaleCompare("median",option+1) == 0)
2189 Median filter image.
2191 (void) SyncImageSettings(mogrify_info,*image);
2192 (void) ParseGeometry(argv[i+1],&geometry_info);
2193 median_image=MedianFilterImage(*image,geometry_info.rho,exception);
2194 if (median_image == (Image *) NULL)
2196 *image=DestroyImage(*image);
2197 *image=median_image;
2200 if (LocaleCompare("modulate",option+1) == 0)
2202 (void) SyncImageSettings(mogrify_info,*image);
2203 (void) ModulateImage(*image,argv[i+1]);
2204 InheritException(exception,&(*image)->exception);
2207 if (LocaleCompare("monitor",option+1) == 0)
2211 (void) SetImageProgressMonitor(*image,
2212 (MagickProgressMonitor) NULL,(void *) NULL);
2215 (void) SetImageProgressMonitor(*image,MonitorProgress,
2219 if (LocaleCompare("monochrome",option+1) == 0)
2221 (void) SyncImageSettings(mogrify_info,*image);
2222 (void) SetImageType(*image,BilevelType);
2223 InheritException(exception,&(*image)->exception);
2226 if (LocaleCompare("morphology",option+1) == 0)
2229 token[MaxTextExtent];
2247 Morphological Image Operation
2249 (void) SyncImageSettings(mogrify_info,*image);
2251 GetMagickToken(p,&p,token);
2252 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
2255 GetMagickToken(p,&p,token);
2256 if ((*p == ':') || (*p == ','))
2257 GetMagickToken(p,&p,token);
2259 iterations=StringToLong(p);
2260 kernel=AcquireKernelInfo(argv[i+2]);
2261 if (kernel == (KernelInfo *) NULL)
2263 (void) ThrowMagickException(exception,GetMagickModule(),
2264 OptionError,"UnabletoParseKernel","morphology");
2268 morphology_image=MorphologyImageChannel(*image,channel,method,
2269 iterations,kernel,exception);
2270 kernel=DestroyKernelInfo(kernel);
2271 if (morphology_image == (Image *) NULL)
2273 *image=DestroyImage(*image);
2274 *image=morphology_image;
2277 if (LocaleCompare("motion-blur",option+1) == 0)
2285 (void) SyncImageSettings(mogrify_info,*image);
2286 flags=ParseGeometry(argv[i+1],&geometry_info);
2287 if ((flags & SigmaValue) == 0)
2288 geometry_info.sigma=1.0;
2289 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2290 geometry_info.sigma,geometry_info.xi,exception);
2291 if (blur_image == (Image *) NULL)
2293 *image=DestroyImage(*image);
2301 if (LocaleCompare("negate",option+1) == 0)
2303 (void) SyncImageSettings(mogrify_info,*image);
2304 (void) NegateImageChannel(*image,channel,*option == '+' ?
2305 MagickTrue : MagickFalse);
2306 InheritException(exception,&(*image)->exception);
2309 if (LocaleCompare("noise",option+1) == 0)
2314 (void) SyncImageSettings(mogrify_info,*image);
2317 (void) ParseGeometry(argv[i+1],&geometry_info);
2318 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
2326 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2327 MagickFalse,argv[i+1]);
2328 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2331 if (noisy_image == (Image *) NULL)
2333 *image=DestroyImage(*image);
2337 if (LocaleCompare("normalize",option+1) == 0)
2339 (void) SyncImageSettings(mogrify_info,*image);
2340 (void) NormalizeImageChannel(*image,channel);
2341 InheritException(exception,&(*image)->exception);
2348 if (LocaleCompare("opaque",option+1) == 0)
2353 (void) SyncImageSettings(mogrify_info,*image);
2354 (void) QueryMagickColor(argv[i+1],&target,exception);
2355 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2356 *option == '-' ? MagickFalse : MagickTrue);
2359 if (LocaleCompare("ordered-dither",option+1) == 0)
2361 (void) SyncImageSettings(mogrify_info,*image);
2362 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2370 if (LocaleCompare("paint",option+1) == 0)
2378 (void) SyncImageSettings(mogrify_info,*image);
2379 (void) ParseGeometry(argv[i+1],&geometry_info);
2380 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2381 if (paint_image == (Image *) NULL)
2383 *image=DestroyImage(*image);
2387 if (LocaleCompare("pen",option+1) == 0)
2391 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2394 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2397 if (LocaleCompare("pointsize",option+1) == 0)
2400 (void) ParseGeometry("12",&geometry_info);
2402 (void) ParseGeometry(argv[i+1],&geometry_info);
2403 draw_info->pointsize=geometry_info.rho;
2406 if (LocaleCompare("polaroid",option+1) == 0)
2418 Simulate a Polaroid picture.
2420 (void) SyncImageSettings(mogrify_info,*image);
2421 random_info=AcquireRandomInfo();
2422 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2423 random_info=DestroyRandomInfo(random_info);
2426 SetGeometryInfo(&geometry_info);
2427 flags=ParseGeometry(argv[i+1],&geometry_info);
2428 angle=geometry_info.rho;
2430 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2431 if (polaroid_image == (Image *) NULL)
2433 *image=DestroyImage(*image);
2434 *image=polaroid_image;
2437 if (LocaleCompare("posterize",option+1) == 0)
2442 (void) SyncImageSettings(mogrify_info,*image);
2443 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2444 quantize_info->dither);
2445 InheritException(exception,&(*image)->exception);
2448 if (LocaleCompare("preview",option+1) == 0)
2459 (void) SyncImageSettings(mogrify_info,*image);
2461 preview_type=UndefinedPreview;
2463 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2464 MagickFalse,argv[i+1]);
2465 preview_image=PreviewImage(*image,preview_type,exception);
2466 if (preview_image == (Image *) NULL)
2468 *image=DestroyImage(*image);
2469 *image=preview_image;
2472 if (LocaleCompare("profile",option+1) == 0)
2486 (void) SyncImageSettings(mogrify_info,*image);
2490 Remove a profile from the image.
2492 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2494 InheritException(exception,&(*image)->exception);
2498 Associate a profile with the image.
2500 profile_info=CloneImageInfo(mogrify_info);
2501 profile=GetImageProfile(*image,"iptc");
2502 if (profile != (StringInfo *) NULL)
2503 profile_info->profile=(void *) CloneStringInfo(profile);
2504 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2505 profile_info=DestroyImageInfo(profile_info);
2506 if (profile_image == (Image *) NULL)
2511 profile_info=CloneImageInfo(mogrify_info);
2512 (void) CopyMagickString(profile_info->filename,argv[i+1],
2514 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2515 if (profile != (StringInfo *) NULL)
2517 (void) ProfileImage(*image,profile_info->magick,
2518 GetStringInfoDatum(profile),(size_t)
2519 GetStringInfoLength(profile),MagickFalse);
2520 profile=DestroyStringInfo(profile);
2522 profile_info=DestroyImageInfo(profile_info);
2525 ResetImageProfileIterator(profile_image);
2526 name=GetNextImageProfile(profile_image);
2527 while (name != (const char *) NULL)
2529 profile=GetImageProfile(profile_image,name);
2530 if (profile != (StringInfo *) NULL)
2531 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2532 (size_t) GetStringInfoLength(profile),MagickFalse);
2533 name=GetNextImageProfile(profile_image);
2535 profile_image=DestroyImage(profile_image);
2542 if (LocaleCompare("quantize",option+1) == 0)
2546 quantize_info->colorspace=UndefinedColorspace;
2549 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2550 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2557 if (LocaleCompare("radial-blur",option+1) == 0)
2565 (void) SyncImageSettings(mogrify_info,*image);
2566 blur_image=RadialBlurImageChannel(*image,channel,
2567 StringToDouble(argv[i+1]),exception);
2568 if (blur_image == (Image *) NULL)
2570 *image=DestroyImage(*image);
2574 if (LocaleCompare("raise",option+1) == 0)
2577 Surround image with a raise of solid color.
2579 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2580 if ((flags & SigmaValue) == 0)
2581 geometry.height=geometry.width;
2582 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2584 InheritException(exception,&(*image)->exception);
2587 if (LocaleCompare("random-threshold",option+1) == 0)
2592 (void) SyncImageSettings(mogrify_info,*image);
2593 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2597 if (LocaleCompare("recolor",option+1) == 0)
2605 (void) SyncImageSettings(mogrify_info,*image);
2606 kernel=AcquireKernelInfo(argv[i+1]);
2607 if (kernel == (KernelInfo *) NULL)
2609 color_image=ColorMatrixImage(*image,kernel,exception);
2610 kernel=DestroyKernelInfo(kernel);
2611 if (color_image == (Image *) NULL)
2613 *image=DestroyImage(*image);
2617 if (LocaleCompare("region",option+1) == 0)
2622 (void) SyncImageSettings(mogrify_info,*image);
2623 if (region_image != (Image *) NULL)
2628 (void) CompositeImage(region_image,(*image)->matte !=
2629 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2630 region_geometry.x,region_geometry.y);
2631 InheritException(exception,®ion_image->exception);
2632 *image=DestroyImage(*image);
2633 *image=region_image;
2637 if (region_image != (Image *) NULL)
2638 region_image=(Image *) NULL;
2642 Apply transformations to a selected region of the image.
2644 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2646 crop_image=CropImage(*image,®ion_geometry,exception);
2647 if (crop_image == (Image *) NULL)
2649 region_image=(*image);
2653 if (LocaleCompare("render",option+1) == 0)
2655 (void) SyncImageSettings(mogrify_info,*image);
2656 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2659 if (LocaleCompare("remap",option+1) == 0)
2665 Transform image colors to match this set of colors.
2667 (void) SyncImageSettings(mogrify_info,*image);
2670 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2671 if (remap_image == (Image *) NULL)
2673 (void) RemapImage(quantize_info,*image,remap_image);
2674 InheritException(exception,&(*image)->exception);
2675 remap_image=DestroyImage(remap_image);
2678 if (LocaleCompare("repage",option+1) == 0)
2682 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2685 (void) ResetImagePage(*image,argv[i+1]);
2686 InheritException(exception,&(*image)->exception);
2689 if (LocaleCompare("resample",option+1) == 0)
2697 (void) SyncImageSettings(mogrify_info,*image);
2698 flags=ParseGeometry(argv[i+1],&geometry_info);
2699 if ((flags & SigmaValue) == 0)
2700 geometry_info.sigma=geometry_info.rho;
2701 resample_image=ResampleImage(*image,geometry_info.rho,
2702 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2703 if (resample_image == (Image *) NULL)
2705 *image=DestroyImage(*image);
2706 *image=resample_image;
2709 if (LocaleCompare("resize",option+1) == 0)
2717 (void) SyncImageSettings(mogrify_info,*image);
2718 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2719 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2720 (*image)->filter,(*image)->blur,exception);
2721 if (resize_image == (Image *) NULL)
2723 *image=DestroyImage(*image);
2724 *image=resize_image;
2727 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2729 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2732 if (LocaleCompare("roll",option+1) == 0)
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2742 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2743 if (roll_image == (Image *) NULL)
2745 *image=DestroyImage(*image);
2749 if (LocaleCompare("rotate",option+1) == 0)
2758 Check for conditional image rotation.
2760 (void) SyncImageSettings(mogrify_info,*image);
2761 if (strchr(argv[i+1],'>') != (char *) NULL)
2762 if ((*image)->columns <= (*image)->rows)
2764 if (strchr(argv[i+1],'<') != (char *) NULL)
2765 if ((*image)->columns >= (*image)->rows)
2770 geometry=ConstantString(argv[i+1]);
2771 (void) SubstituteString(&geometry,">","");
2772 (void) SubstituteString(&geometry,"<","");
2773 (void) ParseGeometry(geometry,&geometry_info);
2774 geometry=DestroyString(geometry);
2775 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2776 if (rotate_image == (Image *) NULL)
2778 *image=DestroyImage(*image);
2779 *image=rotate_image;
2786 if (LocaleCompare("sample",option+1) == 0)
2792 Sample image with pixel replication.
2794 (void) SyncImageSettings(mogrify_info,*image);
2795 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2796 sample_image=SampleImage(*image,geometry.width,geometry.height,
2798 if (sample_image == (Image *) NULL)
2800 *image=DestroyImage(*image);
2801 *image=sample_image;
2804 if (LocaleCompare("scale",option+1) == 0)
2812 (void) SyncImageSettings(mogrify_info,*image);
2813 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2814 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2816 if (scale_image == (Image *) NULL)
2818 *image=DestroyImage(*image);
2822 if (LocaleCompare("selective-blur",option+1) == 0)
2828 Selectively blur pixels within a contrast threshold.
2830 (void) SyncImageSettings(mogrify_info,*image);
2831 flags=ParseGeometry(argv[i+1],&geometry_info);
2832 if ((flags & PercentValue) != 0)
2833 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2834 blur_image=SelectiveBlurImageChannel(*image,channel,
2835 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2836 if (blur_image == (Image *) NULL)
2838 *image=DestroyImage(*image);
2842 if (LocaleCompare("separate",option+1) == 0)
2848 Break channels into separate images.
2850 (void) SyncImageSettings(mogrify_info,*image);
2851 separate_images=SeparateImages(*image,channel,exception);
2852 if (separate_images == (Image *) NULL)
2854 *image=DestroyImage(*image);
2855 *image=separate_images;
2858 if (LocaleCompare("sepia-tone",option+1) == 0)
2869 (void) SyncImageSettings(mogrify_info,*image);
2870 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2871 sepia_image=SepiaToneImage(*image,threshold,exception);
2872 if (sepia_image == (Image *) NULL)
2874 *image=DestroyImage(*image);
2878 if (LocaleCompare("segment",option+1) == 0)
2883 (void) SyncImageSettings(mogrify_info,*image);
2884 flags=ParseGeometry(argv[i+1],&geometry_info);
2885 if ((flags & SigmaValue) == 0)
2886 geometry_info.sigma=1.0;
2887 (void) SegmentImage(*image,(*image)->colorspace,
2888 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2889 InheritException(exception,&(*image)->exception);
2892 if (LocaleCompare("set",option+1) == 0)
2902 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2903 (void) DeleteImageRegistry(argv[i+1]+9);
2905 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2907 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2908 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2911 (void) DeleteImageProperty(*image,argv[i+1]);
2914 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2915 if (value == (char *) NULL)
2917 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2918 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2921 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2923 (void) SetImageOption(image_info,argv[i+1]+7,value);
2924 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2925 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2928 (void) SetImageProperty(*image,argv[i+1],value);
2929 value=DestroyString(value);
2932 if (LocaleCompare("shade",option+1) == 0)
2940 (void) SyncImageSettings(mogrify_info,*image);
2941 flags=ParseGeometry(argv[i+1],&geometry_info);
2942 if ((flags & SigmaValue) == 0)
2943 geometry_info.sigma=1.0;
2944 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2945 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2946 if (shade_image == (Image *) NULL)
2948 *image=DestroyImage(*image);
2952 if (LocaleCompare("shadow",option+1) == 0)
2960 (void) SyncImageSettings(mogrify_info,*image);
2961 flags=ParseGeometry(argv[i+1],&geometry_info);
2962 if ((flags & SigmaValue) == 0)
2963 geometry_info.sigma=1.0;
2964 if ((flags & XiValue) == 0)
2965 geometry_info.xi=4.0;
2966 if ((flags & PsiValue) == 0)
2967 geometry_info.psi=4.0;
2968 shadow_image=ShadowImage(*image,geometry_info.rho,
2969 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2970 ceil(geometry_info.psi-0.5),exception);
2971 if (shadow_image == (Image *) NULL)
2973 *image=DestroyImage(*image);
2974 *image=shadow_image;
2977 if (LocaleCompare("sharpen",option+1) == 0)
2985 (void) SyncImageSettings(mogrify_info,*image);
2986 flags=ParseGeometry(argv[i+1],&geometry_info);
2987 if ((flags & SigmaValue) == 0)
2988 geometry_info.sigma=1.0;
2989 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
2990 geometry_info.sigma,exception);
2991 if (sharp_image == (Image *) NULL)
2993 *image=DestroyImage(*image);
2997 if (LocaleCompare("shave",option+1) == 0)
3003 Shave the image edges.
3005 (void) SyncImageSettings(mogrify_info,*image);
3006 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
3007 shave_image=ShaveImage(*image,&geometry,exception);
3008 if (shave_image == (Image *) NULL)
3010 *image=DestroyImage(*image);
3014 if (LocaleCompare("shear",option+1) == 0)
3022 (void) SyncImageSettings(mogrify_info,*image);
3023 flags=ParseGeometry(argv[i+1],&geometry_info);
3024 if ((flags & SigmaValue) == 0)
3025 geometry_info.sigma=geometry_info.rho;
3026 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3028 if (shear_image == (Image *) NULL)
3030 *image=DestroyImage(*image);
3034 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3037 Sigmoidal non-linearity contrast control.
3039 (void) SyncImageSettings(mogrify_info,*image);
3040 flags=ParseGeometry(argv[i+1],&geometry_info);
3041 if ((flags & SigmaValue) == 0)
3042 geometry_info.sigma=(double) QuantumRange/2.0;
3043 if ((flags & PercentValue) != 0)
3044 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3046 (void) SigmoidalContrastImageChannel(*image,channel,
3047 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3048 geometry_info.sigma);
3049 InheritException(exception,&(*image)->exception);
3052 if (LocaleCompare("sketch",option+1) == 0)
3060 (void) SyncImageSettings(mogrify_info,*image);
3061 flags=ParseGeometry(argv[i+1],&geometry_info);
3062 if ((flags & SigmaValue) == 0)
3063 geometry_info.sigma=1.0;
3064 sketch_image=SketchImage(*image,geometry_info.rho,
3065 geometry_info.sigma,geometry_info.xi,exception);
3066 if (sketch_image == (Image *) NULL)
3068 *image=DestroyImage(*image);
3069 *image=sketch_image;
3072 if (LocaleCompare("solarize",option+1) == 0)
3077 (void) SyncImageSettings(mogrify_info,*image);
3078 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3079 (void) SolarizeImage(*image,threshold);
3080 InheritException(exception,&(*image)->exception);
3083 if (LocaleCompare("sparse-color",option+1) == 0)
3095 Sparse Color Interpolated Gradient
3097 (void) SyncImageSettings(mogrify_info,*image);
3098 method=(SparseColorMethod) ParseMagickOption(
3099 MagickSparseColorOptions,MagickFalse,argv[i+1]);
3100 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
3101 InheritException(exception,&(*image)->exception);
3102 if (arguments == (char *) NULL)
3104 sparse_image=SparseColorOption(*image,channel,method,arguments,
3105 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3106 arguments=DestroyString(arguments);
3107 if (sparse_image == (Image *) NULL)
3109 *image=DestroyImage(*image);
3110 *image=sparse_image;
3113 if (LocaleCompare("splice",option+1) == 0)
3119 Splice a solid color into the image.
3121 (void) SyncImageSettings(mogrify_info,*image);
3122 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3123 splice_image=SpliceImage(*image,&geometry,exception);
3124 if (splice_image == (Image *) NULL)
3126 *image=DestroyImage(*image);
3127 *image=splice_image;
3130 if (LocaleCompare("spread",option+1) == 0)
3138 (void) SyncImageSettings(mogrify_info,*image);
3139 (void) ParseGeometry(argv[i+1],&geometry_info);
3140 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3141 if (spread_image == (Image *) NULL)
3143 *image=DestroyImage(*image);
3144 *image=spread_image;
3147 if (LocaleCompare("stretch",option+1) == 0)
3151 draw_info->stretch=UndefinedStretch;
3154 draw_info->stretch=(StretchType) ParseMagickOption(
3155 MagickStretchOptions,MagickFalse,argv[i+1]);
3158 if (LocaleCompare("strip",option+1) == 0)
3161 Strip image of profiles and comments.
3163 (void) SyncImageSettings(mogrify_info,*image);
3164 (void) StripImage(*image);
3165 InheritException(exception,&(*image)->exception);
3168 if (LocaleCompare("stroke",option+1) == 0)
3175 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3176 if (draw_info->stroke_pattern != (Image *) NULL)
3177 draw_info->stroke_pattern=DestroyImage(
3178 draw_info->stroke_pattern);
3181 sans=AcquireExceptionInfo();
3182 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3183 sans=DestroyExceptionInfo(sans);
3184 if (status == MagickFalse)
3185 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3189 if (LocaleCompare("strokewidth",option+1) == 0)
3191 draw_info->stroke_width=StringToDouble(argv[i+1]);
3194 if (LocaleCompare("style",option+1) == 0)
3198 draw_info->style=UndefinedStyle;
3201 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3202 MagickFalse,argv[i+1]);
3205 if (LocaleCompare("swirl",option+1) == 0)
3213 (void) SyncImageSettings(mogrify_info,*image);
3214 (void) ParseGeometry(argv[i+1],&geometry_info);
3215 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3216 if (swirl_image == (Image *) NULL)
3218 *image=DestroyImage(*image);
3226 if (LocaleCompare("threshold",option+1) == 0)
3234 (void) SyncImageSettings(mogrify_info,*image);
3236 threshold=(double) QuantumRange/2.5;
3238 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
3239 (void) BilevelImageChannel(*image,channel,threshold);
3240 InheritException(exception,&(*image)->exception);
3243 if (LocaleCompare("thumbnail",option+1) == 0)
3251 (void) SyncImageSettings(mogrify_info,*image);
3252 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3253 thumbnail_image=ThumbnailImage(*image,geometry.width,
3254 geometry.height,exception);
3255 if (thumbnail_image == (Image *) NULL)
3257 *image=DestroyImage(*image);
3258 *image=thumbnail_image;
3261 if (LocaleCompare("tile",option+1) == 0)
3265 if (draw_info->fill_pattern != (Image *) NULL)
3266 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3269 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3273 if (LocaleCompare("tint",option+1) == 0)
3281 (void) SyncImageSettings(mogrify_info,*image);
3282 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3283 if (tint_image == (Image *) NULL)
3285 *image=DestroyImage(*image);
3289 if (LocaleCompare("transform",option+1) == 0)
3295 Affine transform image.
3297 (void) SyncImageSettings(mogrify_info,*image);
3298 transform_image=AffineTransformImage(*image,&draw_info->affine,
3300 if (transform_image == (Image *) NULL)
3302 *image=DestroyImage(*image);
3303 *image=transform_image;
3306 if (LocaleCompare("transparent",option+1) == 0)
3311 (void) SyncImageSettings(mogrify_info,*image);
3312 (void) QueryMagickColor(argv[i+1],&target,exception);
3313 (void) TransparentPaintImage(*image,&target,(Quantum)
3314 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3315 InheritException(exception,&(*image)->exception);
3318 if (LocaleCompare("transpose",option+1) == 0)
3324 Transpose image scanlines.
3326 (void) SyncImageSettings(mogrify_info,*image);
3327 transpose_image=TransposeImage(*image,exception);
3328 if (transpose_image == (Image *) NULL)
3330 *image=DestroyImage(*image);
3331 *image=transpose_image;
3334 if (LocaleCompare("transverse",option+1) == 0)
3340 Transverse image scanlines.
3342 (void) SyncImageSettings(mogrify_info,*image);
3343 transverse_image=TransverseImage(*image,exception);
3344 if (transverse_image == (Image *) NULL)
3346 *image=DestroyImage(*image);
3347 *image=transverse_image;
3350 if (LocaleCompare("treedepth",option+1) == 0)
3352 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3355 if (LocaleCompare("trim",option+1) == 0)
3363 (void) SyncImageSettings(mogrify_info,*image);
3364 trim_image=TrimImage(*image,exception);
3365 if (trim_image == (Image *) NULL)
3367 *image=DestroyImage(*image);
3371 if (LocaleCompare("type",option+1) == 0)
3376 (void) SyncImageSettings(mogrify_info,*image);
3380 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3382 (*image)->type=UndefinedType;
3383 (void) SetImageType(*image,type);
3384 InheritException(exception,&(*image)->exception);
3391 if (LocaleCompare("undercolor",option+1) == 0)
3393 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3397 if (LocaleCompare("unique",option+1) == 0)
3401 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3404 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3405 (void) SetImageArtifact(*image,"identify:verbose","true");
3408 if (LocaleCompare("unique-colors",option+1) == 0)
3414 Unique image colors.
3416 (void) SyncImageSettings(mogrify_info,*image);
3417 unique_image=UniqueImageColors(*image,exception);
3418 if (unique_image == (Image *) NULL)
3420 *image=DestroyImage(*image);
3421 *image=unique_image;
3424 if (LocaleCompare("unsharp",option+1) == 0)
3432 (void) SyncImageSettings(mogrify_info,*image);
3433 flags=ParseGeometry(argv[i+1],&geometry_info);
3434 if ((flags & SigmaValue) == 0)
3435 geometry_info.sigma=1.0;
3436 if ((flags & XiValue) == 0)
3437 geometry_info.xi=1.0;
3438 if ((flags & PsiValue) == 0)
3439 geometry_info.psi=0.05;
3440 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3441 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3442 geometry_info.psi,exception);
3443 if (unsharp_image == (Image *) NULL)
3445 *image=DestroyImage(*image);
3446 *image=unsharp_image;
3453 if (LocaleCompare("verbose",option+1) == 0)
3455 (void) SetImageArtifact(*image,option+1,
3456 *option == '+' ? "false" : "true");
3459 if (LocaleCompare("vignette",option+1) == 0)
3467 (void) SyncImageSettings(mogrify_info,*image);
3468 flags=ParseGeometry(argv[i+1],&geometry_info);
3469 if ((flags & SigmaValue) == 0)
3470 geometry_info.sigma=1.0;
3471 if ((flags & XiValue) == 0)
3472 geometry_info.xi=0.1*(*image)->columns;
3473 if ((flags & PsiValue) == 0)
3474 geometry_info.psi=0.1*(*image)->rows;
3475 vignette_image=VignetteImage(*image,geometry_info.rho,
3476 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3477 ceil(geometry_info.psi-0.5),exception);
3478 if (vignette_image == (Image *) NULL)
3480 *image=DestroyImage(*image);
3481 *image=vignette_image;
3484 if (LocaleCompare("virtual-pixel",option+1) == 0)
3488 (void) SetImageVirtualPixelMethod(*image,
3489 UndefinedVirtualPixelMethod);
3492 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3493 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3501 if (LocaleCompare("wave",option+1) == 0)
3509 (void) SyncImageSettings(mogrify_info,*image);
3510 flags=ParseGeometry(argv[i+1],&geometry_info);
3511 if ((flags & SigmaValue) == 0)
3512 geometry_info.sigma=1.0;
3513 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3515 if (wave_image == (Image *) NULL)
3517 *image=DestroyImage(*image);
3521 if (LocaleCompare("weight",option+1) == 0)
3523 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3524 if (LocaleCompare(argv[i+1],"all") == 0)
3525 draw_info->weight=0;
3526 if (LocaleCompare(argv[i+1],"bold") == 0)
3527 draw_info->weight=700;
3528 if (LocaleCompare(argv[i+1],"bolder") == 0)
3529 if (draw_info->weight <= 800)
3530 draw_info->weight+=100;
3531 if (LocaleCompare(argv[i+1],"lighter") == 0)
3532 if (draw_info->weight >= 100)
3533 draw_info->weight-=100;
3534 if (LocaleCompare(argv[i+1],"normal") == 0)
3535 draw_info->weight=400;
3538 if (LocaleCompare("white-threshold",option+1) == 0)
3541 White threshold image.
3543 (void) SyncImageSettings(mogrify_info,*image);
3544 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3546 InheritException(exception,&(*image)->exception);
3556 if (region_image != (Image *) NULL)
3559 Composite transformed region onto image.
3561 (void) SyncImageSettings(mogrify_info,*image);
3562 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3563 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3565 InheritException(exception,®ion_image->exception);
3566 *image=DestroyImage(*image);
3567 *image=region_image;
3572 quantize_info=DestroyQuantizeInfo(quantize_info);
3573 draw_info=DestroyDrawInfo(draw_info);
3574 mogrify_info=DestroyImageInfo(mogrify_info);
3575 status=(*image)->exception.severity == UndefinedException ? MagickTrue :
3581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3585 + M o g r i f y I m a g e C o m m a n d %
3589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3591 % MogrifyImageCommand() transforms an image or a sequence of images. These
3592 % transforms include image scaling, image rotation, color reduction, and
3593 % others. The transmogrified image overwrites the original image.
3595 % The format of the MogrifyImageCommand method is:
3597 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3598 % const char **argv,char **metadata,ExceptionInfo *exception)
3600 % A description of each parameter follows:
3602 % o image_info: the image info.
3604 % o argc: the number of elements in the argument vector.
3606 % o argv: A text array containing the command line arguments.
3608 % o metadata: any metadata is returned here.
3610 % o exception: return any errors or warnings in this structure.
3614 static MagickBooleanType MogrifyUsage(void)
3619 "-debug events display copious debugging information",
3620 "-help print program options",
3621 "-list type print a list of supported option arguments",
3622 "-log format format of debugging information",
3623 "-version print version information",
3628 "-adaptive-blur geometry",
3629 " adaptively blur pixels; decrease effect near edges",
3630 "-adaptive-resize geometry",
3631 " adaptively resize image using 'mesh' interpolation",
3632 "-adaptive-sharpen geometry",
3633 " adaptively sharpen pixels; increase effect near edges",
3634 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3635 " transparent, extract, background, or shape",
3636 "-annotate geometry text",
3637 " annotate the image with text",
3638 "-auto-gamma automagically adjust gamma level of image",
3639 "-auto-level automagically adjust color levels of image",
3640 "-auto-orient automagically orient (rotate) image",
3641 "-bench iterations measure performance",
3642 "-black-threshold value",
3643 " force all pixels below the threshold into black",
3644 "-blue-shift simulate a scene at nighttime in the moonlight",
3645 "-blur geometry reduce image noise and reduce detail levels",
3646 "-border geometry surround image with a border of color",
3647 "-bordercolor color border color",
3648 "-brightness-contrast geometry",
3649 " improve brightness / contrast of the image",
3650 "-cdl filename color correct with a color decision list",
3651 "-charcoal radius simulate a charcoal drawing",
3652 "-chop geometry remove pixels from the image interior",
3653 "-clamp restrict pixel range from 0 to the quantum depth",
3654 "-clip clip along the first path from the 8BIM profile",
3655 "-clip-mask filename associate a clip mask with the image",
3656 "-clip-path id clip along a named path from the 8BIM profile",
3657 "-colorize value colorize the image with the fill color",
3658 "-color-matrix matrix apply color correction to the image",
3659 "-contrast enhance or reduce the image contrast",
3660 "-contrast-stretch geometry",
3661 " improve contrast by `stretching' the intensity range",
3662 "-convolve coefficients",
3663 " apply a convolution kernel to the image",
3664 "-cycle amount cycle the image colormap",
3665 "-decipher filename convert cipher pixels to plain pixels",
3666 "-deskew threshold straighten an image",
3667 "-despeckle reduce the speckles within an image",
3668 "-distort method args",
3669 " distort images according to given method ad args",
3670 "-draw string annotate the image with a graphic primitive",
3671 "-edge radius apply a filter to detect edges in the image",
3672 "-encipher filename convert plain pixels to cipher pixels",
3673 "-emboss radius emboss an image",
3674 "-enhance apply a digital filter to enhance a noisy image",
3675 "-equalize perform histogram equalization to an image",
3676 "-evaluate operator value",
3677 " evaluate an arithmetic, relational, or logical expression",
3678 "-extent geometry set the image size",
3679 "-extract geometry extract area from image",
3680 "-fft implements the discrete Fourier transform (DFT)",
3681 "-flip flip image vertically",
3682 "-floodfill geometry color",
3683 " floodfill the image with color",
3684 "-flop flop image horizontally",
3685 "-frame geometry surround image with an ornamental border",
3686 "-function name parameters",
3687 " apply function over image values",
3688 "-gamma value level of gamma correction",
3689 "-gaussian-blur geometry",
3690 " reduce image noise and reduce detail levels",
3691 "-geometry geometry preferred size or location of the image",
3692 "-identify identify the format and characteristics of the image",
3693 "-ift implements the inverse discrete Fourier transform (DFT)",
3694 "-implode amount implode image pixels about the center",
3695 "-lat geometry local adaptive thresholding",
3696 "-layers method optimize, merge, or compare image layers",
3697 "-level value adjust the level of image contrast",
3698 "-level-colors color,color",
3699 " level image with the given colors",
3700 "-linear-stretch geometry",
3701 " improve contrast by `stretching with saturation'",
3702 "-liquid-rescale geometry",
3703 " rescale image with seam-carving",
3704 "-median radius apply a median filter to the image",
3705 "-modulate value vary the brightness, saturation, and hue",
3706 "-monochrome transform image to black and white",
3707 "-morphology method kernel",
3708 " apply a morphology method to the image",
3709 "-motion-blur geometry",
3710 " simulate motion blur",
3711 "-negate replace every pixel with its complementary color ",
3712 "-noise radius add or reduce noise in an image",
3713 "-normalize transform image to span the full range of colors",
3714 "-opaque color change this color to the fill color",
3715 "-ordered-dither NxN",
3716 " add a noise pattern to the image with specific",
3718 "-paint radius simulate an oil painting",
3719 "-polaroid angle simulate a Polaroid picture",
3720 "-posterize levels reduce the image to a limited number of color levels",
3721 "-profile filename add, delete, or apply an image profile",
3722 "-quantize colorspace reduce colors in this colorspace",
3723 "-radial-blur angle radial blur the image",
3724 "-raise value lighten/darken image edges to create a 3-D effect",
3725 "-random-threshold low,high",
3726 " random threshold the image",
3727 "-region geometry apply options to a portion of the image",
3728 "-render render vector graphics",
3729 "-repage geometry size and location of an image canvas",
3730 "-resample geometry change the resolution of an image",
3731 "-resize geometry resize the image",
3732 "-roll geometry roll an image vertically or horizontally",
3733 "-rotate degrees apply Paeth rotation to the image",
3734 "-sample geometry scale image with pixel sampling",
3735 "-scale geometry scale the image",
3736 "-segment values segment an image",
3737 "-selective-blur geometry",
3738 " selectively blur pixels within a contrast threshold",
3739 "-sepia-tone threshold",
3740 " simulate a sepia-toned photo",
3741 "-set property value set an image property",
3742 "-shade degrees shade the image using a distant light source",
3743 "-shadow geometry simulate an image shadow",
3744 "-sharpen geometry sharpen the image",
3745 "-shave geometry shave pixels from the image edges",
3746 "-shear geometry slide one edge of the image along the X or Y axis",
3747 "-sigmoidal-contrast geometry",
3748 " increase the contrast without saturating highlights or shadows",
3749 "-sketch geometry simulate a pencil sketch",
3750 "-solarize threshold negate all pixels above the threshold level",
3751 "-sparse-color method args",
3752 " fill in a image based on a few color points",
3753 "-splice geometry splice the background color into the image",
3754 "-spread radius displace image pixels by a random amount",
3755 "-strip strip image of all profiles and comments",
3756 "-swirl degrees swirl image pixels about the center",
3757 "-threshold value threshold the image",
3758 "-thumbnail geometry create a thumbnail of the image",
3759 "-tile filename tile image when filling a graphic primitive",
3760 "-tint value tint the image with the fill color",
3761 "-transform affine transform image",
3762 "-transparent color make this color transparent within the image",
3763 "-transpose flip image vertically and rotate 90 degrees",
3764 "-transverse flop image horizontally and rotate 270 degrees",
3765 "-trim trim image edges",
3766 "-type type image type",
3767 "-unique-colors discard all but one of any pixel color",
3768 "-unsharp geometry sharpen the image",
3769 "-vignette geometry soften the edges of the image in vignette style",
3770 "-wave geometry alter an image along a sine wave",
3771 "-white-threshold value",
3772 " force all pixels above the threshold into white",
3775 *sequence_operators[]=
3777 "-append append an image sequence top to bottom",
3778 "-clut apply a color lookup table to the image",
3779 "-coalesce merge a sequence of images",
3780 "-combine combine a sequence of images",
3781 "-composite composite image",
3782 "-crop geometry cut out a rectangular region of the image",
3783 "-deconstruct break down an image sequence into constituent parts",
3784 "-evaluate-sequence operator",
3785 " evaluate an arithmetic, relational, or logical expression",
3786 "-flatten flatten a sequence of images",
3787 "-fx expression apply mathematical expression to an image channel(s)",
3788 "-hald-clut apply a Hald color lookup table to the image",
3789 "-morph value morph an image sequence",
3790 "-mosaic create a mosaic from an image sequence",
3791 "-print string interpret string and print to console",
3792 "-process arguments process the image with a custom image filter",
3793 "-reverse reverse image sequence",
3794 "-separate separate an image channel into a grayscale image",
3795 "-write filename write images to this file",
3800 "-adjoin join images into a single multi-image file",
3801 "-affine matrix affine transform matrix",
3802 "-alpha option activate, deactivate, reset, or set the alpha channel",
3803 "-antialias remove pixel-aliasing",
3804 "-authenticate password",
3805 " decipher image with this password",
3806 "-attenuate value lessen (or intensify) when adding noise to an image",
3807 "-background color background color",
3808 "-bias value add bias when convolving an image",
3809 "-black-point-compensation",
3810 " use black point compensation",
3811 "-blue-primary point chromaticity blue primary point",
3812 "-bordercolor color border color",
3813 "-caption string assign a caption to an image",
3814 "-channel type apply option to select image channels",
3815 "-colors value preferred number of colors in the image",
3816 "-colorspace type alternate image colorspace",
3817 "-comment string annotate image with comment",
3818 "-compose operator set image composite operator",
3819 "-compress type type of pixel compression when writing the image",
3820 "-define format:option",
3821 " define one or more image format options",
3822 "-delay value display the next image after pausing",
3823 "-density geometry horizontal and vertical density of the image",
3824 "-depth value image depth",
3825 "-direction type render text right-to-left or left-to-right",
3826 "-display server get image or font from this X server",
3827 "-dispose method layer disposal method",
3828 "-dither method apply error diffusion to image",
3829 "-encoding type text encoding type",
3830 "-endian type endianness (MSB or LSB) of the image",
3831 "-family name render text with this font family",
3832 "-fill color color to use when filling a graphic primitive",
3833 "-filter type use this filter when resizing an image",
3834 "-font name render text with this font",
3835 "-format \"string\" output formatted image characteristics",
3836 "-fuzz distance colors within this distance are considered equal",
3837 "-gravity type horizontal and vertical text placement",
3838 "-green-primary point chromaticity green primary point",
3839 "-intent type type of rendering intent when managing the image color",
3840 "-interlace type type of image interlacing scheme",
3841 "-interline-spacing value",
3842 " set the space between two text lines",
3843 "-interpolate method pixel color interpolation method",
3844 "-interword-spacing value",
3845 " set the space between two words",
3846 "-kerning value set the space between two letters",
3847 "-label string assign a label to an image",
3848 "-limit type value pixel cache resource limit",
3849 "-loop iterations add Netscape loop extension to your GIF animation",
3850 "-mask filename associate a mask with the image",
3851 "-mattecolor color frame color",
3852 "-monitor monitor progress",
3853 "-orient type image orientation",
3854 "-page geometry size and location of an image canvas (setting)",
3855 "-ping efficiently determine image attributes",
3856 "-pointsize value font point size",
3857 "-precision value maximum number of significant digits to print",
3858 "-preview type image preview type",
3859 "-quality value JPEG/MIFF/PNG compression level",
3860 "-quiet suppress all warning messages",
3861 "-red-primary point chromaticity red primary point",
3862 "-regard-warnings pay attention to warning messages",
3863 "-remap filename transform image colors to match this set of colors",
3864 "-respect-parentheses settings remain in effect until parenthesis boundary",
3865 "-sampling-factor geometry",
3866 " horizontal and vertical sampling factor",
3867 "-scene value image scene number",
3868 "-seed value seed a new sequence of pseudo-random numbers",
3869 "-size geometry width and height of image",
3870 "-stretch type render text with this font stretch",
3871 "-stroke color graphic primitive stroke color",
3872 "-strokewidth value graphic primitive stroke width",
3873 "-style type render text with this font style",
3874 "-synchronize synchronize image to storage device",
3875 "-taint declare the image as modified",
3876 "-texture filename name of texture to tile onto the image background",
3877 "-tile-offset geometry",
3879 "-treedepth value color tree depth",
3880 "-transparent-color color",
3881 " transparent color",
3882 "-undercolor color annotation bounding box color",
3883 "-units type the units of image resolution",
3884 "-verbose print detailed information about the image",
3885 "-view FlashPix viewing transforms",
3886 "-virtual-pixel method",
3887 " virtual pixel access method",
3888 "-weight type render text with this font weight",
3889 "-white-point point chromaticity white point",
3894 "-clone index clone an image",
3895 "-delete index delete the image from the image sequence",
3896 "-insert index insert last image into the image sequence",
3897 "-swap indexes swap two images in the image sequence",
3904 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3905 (void) printf("Copyright: %s\n",GetMagickCopyright());
3906 (void) printf("Features: %s\n\n",GetMagickFeatures());
3907 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3909 (void) printf("\nImage Settings:\n");
3910 for (p=settings; *p != (char *) NULL; p++)
3911 (void) printf(" %s\n",*p);
3912 (void) printf("\nImage Operators:\n");
3913 for (p=operators; *p != (char *) NULL; p++)
3914 (void) printf(" %s\n",*p);
3915 (void) printf("\nImage Sequence Operators:\n");
3916 for (p=sequence_operators; *p != (char *) NULL; p++)
3917 (void) printf(" %s\n",*p);
3918 (void) printf("\nImage Stack Operators:\n");
3919 for (p=stack_operators; *p != (char *) NULL; p++)
3920 (void) printf(" %s\n",*p);
3921 (void) printf("\nMiscellaneous Options:\n");
3922 for (p=miscellaneous; *p != (char *) NULL; p++)
3923 (void) printf(" %s\n",*p);
3925 "\nBy default, the image format of `file' is determined by its magic\n");
3927 "number. To specify a particular image format, precede the filename\n");
3929 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3931 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3932 (void) printf("'-' for standard input or output.\n");
3933 return(MagickFalse);
3936 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3937 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3939 #define DestroyMogrify() \
3941 if (format != (char *) NULL) \
3942 format=DestroyString(format); \
3943 if (path != (char *) NULL) \
3944 path=DestroyString(path); \
3945 DestroyImageStack(); \
3946 for (i=0; i < (ssize_t) argc; i++) \
3947 argv[i]=DestroyString(argv[i]); \
3948 argv=(char **) RelinquishMagickMemory(argv); \
3950 #define ThrowMogrifyException(asperity,tag,option) \
3952 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3955 return(MagickFalse); \
3957 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3959 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3960 "InvalidArgument","`%s': %s",argument,option); \
3962 return(MagickFalse); \
3974 image_stack[MaxImageStackDepth+1];
3996 assert(image_info != (ImageInfo *) NULL);
3997 assert(image_info->signature == MagickSignature);
3998 if (image_info->debug != MagickFalse)
3999 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
4000 assert(exception != (ExceptionInfo *) NULL);
4004 if ((LocaleCompare("version",option+1) == 0) ||
4005 (LocaleCompare("-version",option+1) == 0))
4007 (void) fprintf(stdout,"Version: %s\n",
4008 GetMagickVersion((size_t *) NULL));
4009 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
4010 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
4011 return(MagickFalse);
4015 return(MogrifyUsage());
4016 format=(char *) NULL;
4018 global_colormap=MagickFalse;
4022 option=(char *) NULL;
4028 ReadCommandlLine(argc,&argv);
4029 status=ExpandFilenames(&argc,&argv);
4030 if (status == MagickFalse)
4031 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4032 GetExceptionMessage(errno));
4033 for (i=1; i < (ssize_t) argc; i++)
4036 if (LocaleCompare(option,"(") == 0)
4038 FireImageStack(MagickFalse,MagickTrue,pend);
4039 if (k == MaxImageStackDepth)
4040 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4045 if (LocaleCompare(option,")") == 0)
4047 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4049 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4053 if (IsMagickOption(option) == MagickFalse)
4056 backup_filename[MaxTextExtent],
4063 Option is a file name: begin by reading image from specified file.
4065 FireImageStack(MagickFalse,MagickFalse,pend);
4067 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
4069 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4070 images=ReadImages(image_info,exception);
4071 status&=(images != (Image *) NULL) &&
4072 (exception->severity < ErrorException);
4073 if (images == (Image *) NULL)
4075 if (format != (char *) NULL)
4076 (void) CopyMagickString(images->filename,images->magick_filename,
4078 if (path != (char *) NULL)
4080 GetPathComponent(option,TailPath,filename);
4081 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4082 path,*DirectorySeparator,filename);
4084 if (format != (char *) NULL)
4085 AppendImageFormat(format,images->filename);
4086 AppendImageStack(images);
4087 FinalizeImageSettings(image_info,image,MagickFalse);
4088 if (global_colormap != MagickFalse)
4093 quantize_info=AcquireQuantizeInfo(image_info);
4094 (void) RemapImages(quantize_info,images,(Image *) NULL);
4095 quantize_info=DestroyQuantizeInfo(quantize_info);
4097 *backup_filename='\0';
4098 if ((LocaleCompare(image->filename,"-") != 0) &&
4099 (IsPathWritable(image->filename) != MagickFalse))
4105 Rename image file as backup.
4107 (void) CopyMagickString(backup_filename,image->filename,
4109 for (i=0; i < 6; i++)
4111 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4112 if (IsPathAccessible(backup_filename) == MagickFalse)
4115 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4116 (rename(image->filename,backup_filename) != 0))
4117 *backup_filename='\0';
4120 Write transmogrified image to disk.
4122 image_info->synchronize=MagickTrue;
4123 status&=WriteImages(image_info,image,image->filename,exception);
4124 if ((status == MagickFalse) && (*backup_filename != '\0'))
4125 (void) remove(backup_filename);
4126 RemoveAllImageStack();
4129 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4130 switch (*(option+1))
4134 if (LocaleCompare("adaptive-blur",option+1) == 0)
4137 if (i == (ssize_t) argc)
4138 ThrowMogrifyException(OptionError,"MissingArgument",option);
4139 if (IsGeometry(argv[i]) == MagickFalse)
4140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4143 if (LocaleCompare("adaptive-resize",option+1) == 0)
4146 if (i == (ssize_t) argc)
4147 ThrowMogrifyException(OptionError,"MissingArgument",option);
4148 if (IsGeometry(argv[i]) == MagickFalse)
4149 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4152 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4155 if (i == (ssize_t) argc)
4156 ThrowMogrifyException(OptionError,"MissingArgument",option);
4157 if (IsGeometry(argv[i]) == MagickFalse)
4158 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4161 if (LocaleCompare("affine",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (LocaleCompare("alpha",option+1) == 0)
4178 if (i == (ssize_t) argc)
4179 ThrowMogrifyException(OptionError,"MissingArgument",option);
4180 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4182 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4186 if (LocaleCompare("annotate",option+1) == 0)
4191 if (i == (ssize_t) argc)
4192 ThrowMogrifyException(OptionError,"MissingArgument",option);
4193 if (IsGeometry(argv[i]) == MagickFalse)
4194 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4195 if (i == (ssize_t) argc)
4196 ThrowMogrifyException(OptionError,"MissingArgument",option);
4200 if (LocaleCompare("antialias",option+1) == 0)
4202 if (LocaleCompare("append",option+1) == 0)
4204 if (LocaleCompare("attenuate",option+1) == 0)
4209 if (i == (ssize_t) (argc-1))
4210 ThrowMogrifyException(OptionError,"MissingArgument",option);
4211 if (IsGeometry(argv[i]) == MagickFalse)
4212 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4215 if (LocaleCompare("authenticate",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4224 if (LocaleCompare("auto-gamma",option+1) == 0)
4226 if (LocaleCompare("auto-level",option+1) == 0)
4228 if (LocaleCompare("auto-orient",option+1) == 0)
4230 if (LocaleCompare("average",option+1) == 0)
4232 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4236 if (LocaleCompare("background",option+1) == 0)
4241 if (i == (ssize_t) argc)
4242 ThrowMogrifyException(OptionError,"MissingArgument",option);
4245 if (LocaleCompare("bias",option+1) == 0)
4250 if (i == (ssize_t) (argc-1))
4251 ThrowMogrifyException(OptionError,"MissingArgument",option);
4252 if (IsGeometry(argv[i]) == MagickFalse)
4253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4256 if (LocaleCompare("black-point-compensation",option+1) == 0)
4258 if (LocaleCompare("black-threshold",option+1) == 0)
4263 if (i == (ssize_t) argc)
4264 ThrowMogrifyException(OptionError,"MissingArgument",option);
4265 if (IsGeometry(argv[i]) == MagickFalse)
4266 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4269 if (LocaleCompare("blue-primary",option+1) == 0)
4274 if (i == (ssize_t) argc)
4275 ThrowMogrifyException(OptionError,"MissingArgument",option);
4276 if (IsGeometry(argv[i]) == MagickFalse)
4277 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4280 if (LocaleCompare("blue-shift",option+1) == 0)
4283 if (i == (ssize_t) argc)
4284 ThrowMogrifyException(OptionError,"MissingArgument",option);
4285 if (IsGeometry(argv[i]) == MagickFalse)
4286 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4289 if (LocaleCompare("blur",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("border",option+1) == 0)
4303 if (i == (ssize_t) argc)
4304 ThrowMogrifyException(OptionError,"MissingArgument",option);
4305 if (IsGeometry(argv[i]) == MagickFalse)
4306 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4309 if (LocaleCompare("bordercolor",option+1) == 0)
4314 if (i == (ssize_t) argc)
4315 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 if (LocaleCompare("box",option+1) == 0)
4323 if (i == (ssize_t) argc)
4324 ThrowMogrifyException(OptionError,"MissingArgument",option);
4327 if (LocaleCompare("brightness-contrast",option+1) == 0)
4330 if (i == (ssize_t) argc)
4331 ThrowMogrifyException(OptionError,"MissingArgument",option);
4332 if (IsGeometry(argv[i]) == MagickFalse)
4333 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4336 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4340 if (LocaleCompare("cache",option+1) == 0)
4345 if (i == (ssize_t) argc)
4346 ThrowMogrifyException(OptionError,"MissingArgument",option);
4347 if (IsGeometry(argv[i]) == MagickFalse)
4348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4351 if (LocaleCompare("caption",option+1) == 0)
4356 if (i == (ssize_t) argc)
4357 ThrowMogrifyException(OptionError,"MissingArgument",option);
4360 if (LocaleCompare("channel",option+1) == 0)
4368 if (i == (ssize_t) (argc-1))
4369 ThrowMogrifyException(OptionError,"MissingArgument",option);
4370 channel=ParseChannelOption(argv[i]);
4372 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4376 if (LocaleCompare("cdl",option+1) == 0)
4381 if (i == (ssize_t) (argc-1))
4382 ThrowMogrifyException(OptionError,"MissingArgument",option);
4385 if (LocaleCompare("charcoal",option+1) == 0)
4390 if (i == (ssize_t) argc)
4391 ThrowMogrifyException(OptionError,"MissingArgument",option);
4392 if (IsGeometry(argv[i]) == MagickFalse)
4393 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4396 if (LocaleCompare("chop",option+1) == 0)
4401 if (i == (ssize_t) argc)
4402 ThrowMogrifyException(OptionError,"MissingArgument",option);
4403 if (IsGeometry(argv[i]) == MagickFalse)
4404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4407 if (LocaleCompare("clamp",option+1) == 0)
4409 if (LocaleCompare("clip",option+1) == 0)
4411 if (LocaleCompare("clip-mask",option+1) == 0)
4416 if (i == (ssize_t) argc)
4417 ThrowMogrifyException(OptionError,"MissingArgument",option);
4420 if (LocaleCompare("clut",option+1) == 0)
4422 if (LocaleCompare("coalesce",option+1) == 0)
4424 if (LocaleCompare("colorize",option+1) == 0)
4429 if (i == (ssize_t) argc)
4430 ThrowMogrifyException(OptionError,"MissingArgument",option);
4431 if (IsGeometry(argv[i]) == MagickFalse)
4432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4435 if (LocaleCompare("color-matrix",option+1) == 0)
4443 if (i == (ssize_t) (argc-1))
4444 ThrowMogrifyException(OptionError,"MissingArgument",option);
4445 kernel_info=AcquireKernelInfo(argv[i]);
4446 if (kernel_info == (KernelInfo *) NULL)
4447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4448 kernel_info=DestroyKernelInfo(kernel_info);
4451 if (LocaleCompare("colors",option+1) == 0)
4456 if (i == (ssize_t) argc)
4457 ThrowMogrifyException(OptionError,"MissingArgument",option);
4458 if (IsGeometry(argv[i]) == MagickFalse)
4459 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4462 if (LocaleCompare("colorspace",option+1) == 0)
4470 if (i == (ssize_t) argc)
4471 ThrowMogrifyException(OptionError,"MissingArgument",option);
4472 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4475 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4479 if (LocaleCompare("combine",option+1) == 0)
4481 if (LocaleCompare("comment",option+1) == 0)
4486 if (i == (ssize_t) argc)
4487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4490 if (LocaleCompare("composite",option+1) == 0)
4492 if (LocaleCompare("compress",option+1) == 0)
4500 if (i == (ssize_t) argc)
4501 ThrowMogrifyException(OptionError,"MissingArgument",option);
4502 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4505 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4509 if (LocaleCompare("concurrent",option+1) == 0)
4511 if (LocaleCompare("contrast",option+1) == 0)
4513 if (LocaleCompare("contrast-stretch",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4518 if (IsGeometry(argv[i]) == MagickFalse)
4519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4522 if (LocaleCompare("convolve",option+1) == 0)
4530 if (i == (ssize_t) argc)
4531 ThrowMogrifyException(OptionError,"MissingArgument",option);
4532 kernel_info=AcquireKernelInfo(argv[i]);
4533 if (kernel_info == (KernelInfo *) NULL)
4534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4535 kernel_info=DestroyKernelInfo(kernel_info);
4538 if (LocaleCompare("crop",option+1) == 0)
4543 if (i == (ssize_t) argc)
4544 ThrowMogrifyException(OptionError,"MissingArgument",option);
4545 if (IsGeometry(argv[i]) == MagickFalse)
4546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4549 if (LocaleCompare("cycle",option+1) == 0)
4554 if (i == (ssize_t) argc)
4555 ThrowMogrifyException(OptionError,"MissingArgument",option);
4556 if (IsGeometry(argv[i]) == MagickFalse)
4557 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4560 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4564 if (LocaleCompare("decipher",option+1) == 0)
4569 if (i == (ssize_t) (argc-1))
4570 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 if (LocaleCompare("deconstruct",option+1) == 0)
4575 if (LocaleCompare("debug",option+1) == 0)
4583 if (i == (ssize_t) argc)
4584 ThrowMogrifyException(OptionError,"MissingArgument",option);
4585 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4587 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4589 (void) SetLogEventMask(argv[i]);
4592 if (LocaleCompare("define",option+1) == 0)
4595 if (i == (ssize_t) argc)
4596 ThrowMogrifyException(OptionError,"MissingArgument",option);
4602 define=GetImageOption(image_info,argv[i]);
4603 if (define == (const char *) NULL)
4604 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4609 if (LocaleCompare("delay",option+1) == 0)
4614 if (i == (ssize_t) argc)
4615 ThrowMogrifyException(OptionError,"MissingArgument",option);
4616 if (IsGeometry(argv[i]) == MagickFalse)
4617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4620 if (LocaleCompare("density",option+1) == 0)
4625 if (i == (ssize_t) argc)
4626 ThrowMogrifyException(OptionError,"MissingArgument",option);
4627 if (IsGeometry(argv[i]) == MagickFalse)
4628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4631 if (LocaleCompare("depth",option+1) == 0)
4636 if (i == (ssize_t) argc)
4637 ThrowMogrifyException(OptionError,"MissingArgument",option);
4638 if (IsGeometry(argv[i]) == MagickFalse)
4639 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4642 if (LocaleCompare("deskew",option+1) == 0)
4647 if (i == (ssize_t) argc)
4648 ThrowMogrifyException(OptionError,"MissingArgument",option);
4649 if (IsGeometry(argv[i]) == MagickFalse)
4650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4653 if (LocaleCompare("despeckle",option+1) == 0)
4655 if (LocaleCompare("dft",option+1) == 0)
4657 if (LocaleCompare("direction",option+1) == 0)
4665 if (i == (ssize_t) argc)
4666 ThrowMogrifyException(OptionError,"MissingArgument",option);
4667 direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
4670 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4674 if (LocaleCompare("display",option+1) == 0)
4679 if (i == (ssize_t) argc)
4680 ThrowMogrifyException(OptionError,"MissingArgument",option);
4683 if (LocaleCompare("dispose",option+1) == 0)
4691 if (i == (ssize_t) argc)
4692 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4695 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4699 if (LocaleCompare("distort",option+1) == 0)
4705 if (i == (ssize_t) argc)
4706 ThrowMogrifyException(OptionError,"MissingArgument",option);
4707 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4709 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4712 if (i == (ssize_t) (argc-1))
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4716 if (LocaleCompare("dither",option+1) == 0)
4724 if (i == (ssize_t) argc)
4725 ThrowMogrifyException(OptionError,"MissingArgument",option);
4726 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4728 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4732 if (LocaleCompare("draw",option+1) == 0)
4737 if (i == (ssize_t) argc)
4738 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 if (LocaleCompare("duration",option+1) == 0)
4746 if (i == (ssize_t) (argc-1))
4747 ThrowMogrifyException(OptionError,"MissingArgument",option);
4748 if (IsGeometry(argv[i]) == MagickFalse)
4749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4752 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4756 if (LocaleCompare("edge",option+1) == 0)
4761 if (i == (ssize_t) argc)
4762 ThrowMogrifyException(OptionError,"MissingArgument",option);
4763 if (IsGeometry(argv[i]) == MagickFalse)
4764 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4767 if (LocaleCompare("emboss",option+1) == 0)
4772 if (i == (ssize_t) argc)
4773 ThrowMogrifyException(OptionError,"MissingArgument",option);
4774 if (IsGeometry(argv[i]) == MagickFalse)
4775 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4778 if (LocaleCompare("encipher",option+1) == 0)
4783 if (i == (ssize_t) argc)
4784 ThrowMogrifyException(OptionError,"MissingArgument",option);
4787 if (LocaleCompare("encoding",option+1) == 0)
4792 if (i == (ssize_t) argc)
4793 ThrowMogrifyException(OptionError,"MissingArgument",option);
4796 if (LocaleCompare("endian",option+1) == 0)
4804 if (i == (ssize_t) argc)
4805 ThrowMogrifyException(OptionError,"MissingArgument",option);
4806 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4808 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4812 if (LocaleCompare("enhance",option+1) == 0)
4814 if (LocaleCompare("equalize",option+1) == 0)
4816 if (LocaleCompare("evaluate",option+1) == 0)
4824 if (i == (ssize_t) argc)
4825 ThrowMogrifyException(OptionError,"MissingArgument",option);
4826 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4828 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4831 if (i == (ssize_t) (argc-1))
4832 ThrowMogrifyException(OptionError,"MissingArgument",option);
4833 if (IsGeometry(argv[i]) == MagickFalse)
4834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4837 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4845 if (i == (ssize_t) argc)
4846 ThrowMogrifyException(OptionError,"MissingArgument",option);
4847 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4849 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4853 if (LocaleCompare("extent",option+1) == 0)
4858 if (i == (ssize_t) argc)
4859 ThrowMogrifyException(OptionError,"MissingArgument",option);
4860 if (IsGeometry(argv[i]) == MagickFalse)
4861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4864 if (LocaleCompare("extract",option+1) == 0)
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,"MissingArgument",option);
4871 if (IsGeometry(argv[i]) == MagickFalse)
4872 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4875 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4879 if (LocaleCompare("family",option+1) == 0)
4884 if (i == (ssize_t) (argc-1))
4885 ThrowMogrifyException(OptionError,"MissingArgument",option);
4888 if (LocaleCompare("fill",option+1) == 0)
4893 if (i == (ssize_t) argc)
4894 ThrowMogrifyException(OptionError,"MissingArgument",option);
4897 if (LocaleCompare("filter",option+1) == 0)
4905 if (i == (ssize_t) argc)
4906 ThrowMogrifyException(OptionError,"MissingArgument",option);
4907 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4909 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4913 if (LocaleCompare("flatten",option+1) == 0)
4915 if (LocaleCompare("flip",option+1) == 0)
4917 if (LocaleCompare("flop",option+1) == 0)
4919 if (LocaleCompare("floodfill",option+1) == 0)
4924 if (i == (ssize_t) argc)
4925 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 if (IsGeometry(argv[i]) == MagickFalse)
4927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4929 if (i == (ssize_t) argc)
4930 ThrowMogrifyException(OptionError,"MissingArgument",option);
4933 if (LocaleCompare("font",option+1) == 0)
4938 if (i == (ssize_t) argc)
4939 ThrowMogrifyException(OptionError,"MissingArgument",option);
4942 if (LocaleCompare("format",option+1) == 0)
4944 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4945 (void) CloneString(&format,(char *) NULL);
4949 if (i == (ssize_t) argc)
4950 ThrowMogrifyException(OptionError,"MissingArgument",option);
4951 (void) CloneString(&format,argv[i]);
4952 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4953 (void) ConcatenateMagickString(image_info->filename,":",
4955 (void) SetImageInfo(image_info,0,exception);
4956 if (*image_info->magick == '\0')
4957 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4961 if (LocaleCompare("frame",option+1) == 0)
4966 if (i == (ssize_t) argc)
4967 ThrowMogrifyException(OptionError,"MissingArgument",option);
4968 if (IsGeometry(argv[i]) == MagickFalse)
4969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4972 if (LocaleCompare("function",option+1) == 0)
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4982 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
4984 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4986 if (i == (ssize_t) (argc-1))
4987 ThrowMogrifyException(OptionError,"MissingArgument",option);
4990 if (LocaleCompare("fuzz",option+1) == 0)
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4997 if (IsGeometry(argv[i]) == MagickFalse)
4998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5001 if (LocaleCompare("fx",option+1) == 0)
5006 if (i == (ssize_t) (argc-1))
5007 ThrowMogrifyException(OptionError,"MissingArgument",option);
5010 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5014 if (LocaleCompare("gamma",option+1) == 0)
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,"MissingArgument",option);
5019 if (IsGeometry(argv[i]) == MagickFalse)
5020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5024 (LocaleCompare("gaussian",option+1) == 0))
5027 if (i == (ssize_t) argc)
5028 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 if (IsGeometry(argv[i]) == MagickFalse)
5030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5033 if (LocaleCompare("geometry",option+1) == 0)
5038 if (i == (ssize_t) argc)
5039 ThrowMogrifyException(OptionError,"MissingArgument",option);
5040 if (IsGeometry(argv[i]) == MagickFalse)
5041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5044 if (LocaleCompare("gravity",option+1) == 0)
5052 if (i == (ssize_t) argc)
5053 ThrowMogrifyException(OptionError,"MissingArgument",option);
5054 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5056 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5060 if (LocaleCompare("green-primary",option+1) == 0)
5065 if (i == (ssize_t) argc)
5066 ThrowMogrifyException(OptionError,"MissingArgument",option);
5067 if (IsGeometry(argv[i]) == MagickFalse)
5068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5071 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5075 if (LocaleCompare("hald-clut",option+1) == 0)
5077 if ((LocaleCompare("help",option+1) == 0) ||
5078 (LocaleCompare("-help",option+1) == 0))
5079 return(MogrifyUsage());
5080 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5084 if (LocaleCompare("identify",option+1) == 0)
5086 if (LocaleCompare("idft",option+1) == 0)
5088 if (LocaleCompare("implode",option+1) == 0)
5093 if (i == (ssize_t) argc)
5094 ThrowMogrifyException(OptionError,"MissingArgument",option);
5095 if (IsGeometry(argv[i]) == MagickFalse)
5096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5099 if (LocaleCompare("intent",option+1) == 0)
5107 if (i == (ssize_t) (argc-1))
5108 ThrowMogrifyException(OptionError,"MissingArgument",option);
5109 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5111 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5115 if (LocaleCompare("interlace",option+1) == 0)
5123 if (i == (ssize_t) argc)
5124 ThrowMogrifyException(OptionError,"MissingArgument",option);
5125 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5128 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5132 if (LocaleCompare("interline-spacing",option+1) == 0)
5137 if (i == (ssize_t) (argc-1))
5138 ThrowMogrifyException(OptionError,"MissingArgument",option);
5139 if (IsGeometry(argv[i]) == MagickFalse)
5140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5143 if (LocaleCompare("interpolate",option+1) == 0)
5151 if (i == (ssize_t) argc)
5152 ThrowMogrifyException(OptionError,"MissingArgument",option);
5153 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5155 if (interpolate < 0)
5156 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5160 if (LocaleCompare("interword-spacing",option+1) == 0)
5165 if (i == (ssize_t) (argc-1))
5166 ThrowMogrifyException(OptionError,"MissingArgument",option);
5167 if (IsGeometry(argv[i]) == MagickFalse)
5168 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5171 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5175 if (LocaleCompare("kerning",option+1) == 0)
5180 if (i == (ssize_t) (argc-1))
5181 ThrowMogrifyException(OptionError,"MissingArgument",option);
5182 if (IsGeometry(argv[i]) == MagickFalse)
5183 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5186 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5190 if (LocaleCompare("label",option+1) == 0)
5195 if (i == (ssize_t) argc)
5196 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 if (LocaleCompare("lat",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,"MissingArgument",option);
5206 if (IsGeometry(argv[i]) == MagickFalse)
5207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5209 if (LocaleCompare("layers",option+1) == 0)
5217 if (i == (ssize_t) (argc-1))
5218 ThrowMogrifyException(OptionError,"MissingArgument",option);
5219 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5221 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5225 if (LocaleCompare("level",option+1) == 0)
5228 if (i == (ssize_t) argc)
5229 ThrowMogrifyException(OptionError,"MissingArgument",option);
5230 if (IsGeometry(argv[i]) == MagickFalse)
5231 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5234 if (LocaleCompare("level-colors",option+1) == 0)
5237 if (i == (ssize_t) argc)
5238 ThrowMogrifyException(OptionError,"MissingArgument",option);
5241 if (LocaleCompare("linewidth",option+1) == 0)
5246 if (i == (ssize_t) argc)
5247 ThrowMogrifyException(OptionError,"MissingArgument",option);
5248 if (IsGeometry(argv[i]) == MagickFalse)
5249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5252 if (LocaleCompare("limit",option+1) == 0)
5266 if (i == (ssize_t) argc)
5267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5271 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5274 if (i == (ssize_t) argc)
5275 ThrowMogrifyException(OptionError,"MissingArgument",option);
5276 value=strtod(argv[i],&p);
5277 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5278 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5281 if (LocaleCompare("liquid-rescale",option+1) == 0)
5284 if (i == (ssize_t) argc)
5285 ThrowMogrifyException(OptionError,"MissingArgument",option);
5286 if (IsGeometry(argv[i]) == MagickFalse)
5287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5290 if (LocaleCompare("list",option+1) == 0)
5298 if (i == (ssize_t) argc)
5299 ThrowMogrifyException(OptionError,"MissingArgument",option);
5300 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5302 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5303 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5305 return(status != 0 ? MagickFalse : MagickTrue);
5307 if (LocaleCompare("log",option+1) == 0)
5312 if ((i == (ssize_t) argc) ||
5313 (strchr(argv[i],'%') == (char *) NULL))
5314 ThrowMogrifyException(OptionError,"MissingArgument",option);
5317 if (LocaleCompare("loop",option+1) == 0)
5322 if (i == (ssize_t) argc)
5323 ThrowMogrifyException(OptionError,"MissingArgument",option);
5324 if (IsGeometry(argv[i]) == MagickFalse)
5325 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5328 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5332 if (LocaleCompare("map",option+1) == 0)
5334 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5338 if (i == (ssize_t) argc)
5339 ThrowMogrifyException(OptionError,"MissingArgument",option);
5342 if (LocaleCompare("mask",option+1) == 0)
5347 if (i == (ssize_t) argc)
5348 ThrowMogrifyException(OptionError,"MissingArgument",option);
5351 if (LocaleCompare("matte",option+1) == 0)
5353 if (LocaleCompare("mattecolor",option+1) == 0)
5358 if (i == (ssize_t) argc)
5359 ThrowMogrifyException(OptionError,"MissingArgument",option);
5362 if (LocaleCompare("maximum",option+1) == 0)
5364 if (LocaleCompare("minimum",option+1) == 0)
5366 if (LocaleCompare("modulate",option+1) == 0)
5371 if (i == (ssize_t) argc)
5372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5377 if (LocaleCompare("median",option+1) == 0)
5382 if (i == (ssize_t) argc)
5383 ThrowMogrifyException(OptionError,"MissingArgument",option);
5384 if (IsGeometry(argv[i]) == MagickFalse)
5385 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5388 if (LocaleCompare("monitor",option+1) == 0)
5390 if (LocaleCompare("monochrome",option+1) == 0)
5392 if (LocaleCompare("morph",option+1) == 0)
5397 if (i == (ssize_t) (argc-1))
5398 ThrowMogrifyException(OptionError,"MissingArgument",option);
5399 if (IsGeometry(argv[i]) == MagickFalse)
5400 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5403 if (LocaleCompare("morphology",option+1) == 0)
5406 token[MaxTextExtent];
5415 if (i == (ssize_t) argc)
5416 ThrowMogrifyException(OptionError,"MissingArgument",option);
5417 GetMagickToken(argv[i],NULL,token);
5418 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5420 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5423 if (i == (ssize_t) (argc-1))
5424 ThrowMogrifyException(OptionError,"MissingArgument",option);
5425 kernel_info=AcquireKernelInfo(argv[i]);
5426 if (kernel_info == (KernelInfo *) NULL)
5427 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5428 kernel_info=DestroyKernelInfo(kernel_info);
5431 if (LocaleCompare("mosaic",option+1) == 0)
5433 if (LocaleCompare("motion-blur",option+1) == 0)
5438 if (i == (ssize_t) argc)
5439 ThrowMogrifyException(OptionError,"MissingArgument",option);
5440 if (IsGeometry(argv[i]) == MagickFalse)
5441 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5444 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5448 if (LocaleCompare("negate",option+1) == 0)
5450 if (LocaleCompare("noise",option+1) == 0)
5453 if (i == (ssize_t) argc)
5454 ThrowMogrifyException(OptionError,"MissingArgument",option);
5460 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5462 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5466 if (IsGeometry(argv[i]) == MagickFalse)
5467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5470 if (LocaleCompare("noop",option+1) == 0)
5472 if (LocaleCompare("normalize",option+1) == 0)
5474 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5478 if (LocaleCompare("opaque",option+1) == 0)
5481 if (i == (ssize_t) argc)
5482 ThrowMogrifyException(OptionError,"MissingArgument",option);
5485 if (LocaleCompare("ordered-dither",option+1) == 0)
5490 if (i == (ssize_t) argc)
5491 ThrowMogrifyException(OptionError,"MissingArgument",option);
5494 if (LocaleCompare("orient",option+1) == 0)
5499 orientation=UndefinedOrientation;
5503 if (i == (ssize_t) (argc-1))
5504 ThrowMogrifyException(OptionError,"MissingArgument",option);
5505 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5507 if (orientation < 0)
5508 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5512 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5516 if (LocaleCompare("page",option+1) == 0)
5521 if (i == (ssize_t) argc)
5522 ThrowMogrifyException(OptionError,"MissingArgument",option);
5525 if (LocaleCompare("paint",option+1) == 0)
5530 if (i == (ssize_t) argc)
5531 ThrowMogrifyException(OptionError,"MissingArgument",option);
5532 if (IsGeometry(argv[i]) == MagickFalse)
5533 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5536 if (LocaleCompare("path",option+1) == 0)
5538 (void) CloneString(&path,(char *) NULL);
5542 if (i == (ssize_t) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5544 (void) CloneString(&path,argv[i]);
5547 if (LocaleCompare("pointsize",option+1) == 0)
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,"MissingArgument",option);
5554 if (IsGeometry(argv[i]) == MagickFalse)
5555 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5558 if (LocaleCompare("polaroid",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("posterize",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("precision",option+1) == 0)
5585 if (i == (ssize_t) argc)
5586 ThrowMogrifyException(OptionError,"MissingArgument",option);
5587 if (IsGeometry(argv[i]) == MagickFalse)
5588 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5591 if (LocaleCompare("print",option+1) == 0)
5596 if (i == (ssize_t) argc)
5597 ThrowMogrifyException(OptionError,"MissingArgument",option);
5600 if (LocaleCompare("process",option+1) == 0)
5605 if (i == (ssize_t) (argc-1))
5606 ThrowMogrifyException(OptionError,"MissingArgument",option);
5609 if (LocaleCompare("profile",option+1) == 0)
5612 if (i == (ssize_t) argc)
5613 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5620 if (LocaleCompare("quality",option+1) == 0)
5625 if (i == (ssize_t) argc)
5626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 if (IsGeometry(argv[i]) == MagickFalse)
5628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 if (LocaleCompare("quantize",option+1) == 0)
5639 if (i == (ssize_t) (argc-1))
5640 ThrowMogrifyException(OptionError,"MissingArgument",option);
5641 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5644 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5648 if (LocaleCompare("quiet",option+1) == 0)
5650 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5654 if (LocaleCompare("radial-blur",option+1) == 0)
5657 if (i == (ssize_t) argc)
5658 ThrowMogrifyException(OptionError,"MissingArgument",option);
5659 if (IsGeometry(argv[i]) == MagickFalse)
5660 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5663 if (LocaleCompare("raise",option+1) == 0)
5666 if (i == (ssize_t) argc)
5667 ThrowMogrifyException(OptionError,"MissingArgument",option);
5668 if (IsGeometry(argv[i]) == MagickFalse)
5669 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5672 if (LocaleCompare("random-threshold",option+1) == 0)
5677 if (i == (ssize_t) argc)
5678 ThrowMogrifyException(OptionError,"MissingArgument",option);
5679 if (IsGeometry(argv[i]) == MagickFalse)
5680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5683 if (LocaleCompare("recolor",option+1) == 0)
5688 if (i == (ssize_t) (argc-1))
5689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5690 if (IsGeometry(argv[i]) == MagickFalse)
5691 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5694 if (LocaleCompare("red-primary",option+1) == 0)
5699 if (i == (ssize_t) argc)
5700 ThrowMogrifyException(OptionError,"MissingArgument",option);
5701 if (IsGeometry(argv[i]) == MagickFalse)
5702 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5704 if (LocaleCompare("regard-warnings",option+1) == 0)
5706 if (LocaleCompare("region",option+1) == 0)
5711 if (i == (ssize_t) argc)
5712 ThrowMogrifyException(OptionError,"MissingArgument",option);
5713 if (IsGeometry(argv[i]) == MagickFalse)
5714 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5717 if (LocaleCompare("remap",option+1) == 0)
5722 if (i == (ssize_t) (argc-1))
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5726 if (LocaleCompare("render",option+1) == 0)
5728 if (LocaleCompare("repage",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5735 if (IsGeometry(argv[i]) == MagickFalse)
5736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5739 if (LocaleCompare("resample",option+1) == 0)
5744 if (i == (ssize_t) argc)
5745 ThrowMogrifyException(OptionError,"MissingArgument",option);
5746 if (IsGeometry(argv[i]) == MagickFalse)
5747 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5750 if (LocaleCompare("resize",option+1) == 0)
5755 if (i == (ssize_t) argc)
5756 ThrowMogrifyException(OptionError,"MissingArgument",option);
5757 if (IsGeometry(argv[i]) == MagickFalse)
5758 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5761 if (LocaleCompare("reverse",option+1) == 0)
5763 if (LocaleCompare("roll",option+1) == 0)
5768 if (i == (ssize_t) argc)
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5770 if (IsGeometry(argv[i]) == MagickFalse)
5771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5774 if (LocaleCompare("rotate",option+1) == 0)
5777 if (i == (ssize_t) argc)
5778 ThrowMogrifyException(OptionError,"MissingArgument",option);
5779 if (IsGeometry(argv[i]) == MagickFalse)
5780 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5783 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5787 if (LocaleCompare("sample",option+1) == 0)
5792 if (i == (ssize_t) argc)
5793 ThrowMogrifyException(OptionError,"MissingArgument",option);
5794 if (IsGeometry(argv[i]) == MagickFalse)
5795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5798 if (LocaleCompare("sampling-factor",option+1) == 0)
5803 if (i == (ssize_t) argc)
5804 ThrowMogrifyException(OptionError,"MissingArgument",option);
5805 if (IsGeometry(argv[i]) == MagickFalse)
5806 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5809 if (LocaleCompare("scale",option+1) == 0)
5814 if (i == (ssize_t) argc)
5815 ThrowMogrifyException(OptionError,"MissingArgument",option);
5816 if (IsGeometry(argv[i]) == MagickFalse)
5817 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5820 if (LocaleCompare("scene",option+1) == 0)
5825 if (i == (ssize_t) argc)
5826 ThrowMogrifyException(OptionError,"MissingArgument",option);
5827 if (IsGeometry(argv[i]) == MagickFalse)
5828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 if (LocaleCompare("seed",option+1) == 0)
5836 if (i == (ssize_t) argc)
5837 ThrowMogrifyException(OptionError,"MissingArgument",option);
5838 if (IsGeometry(argv[i]) == MagickFalse)
5839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5842 if (LocaleCompare("segment",option+1) == 0)
5847 if (i == (ssize_t) argc)
5848 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 if (LocaleCompare("selective-blur",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("separate",option+1) == 0)
5864 if (LocaleCompare("sepia-tone",option+1) == 0)
5869 if (i == (ssize_t) argc)
5870 ThrowMogrifyException(OptionError,"MissingArgument",option);
5871 if (IsGeometry(argv[i]) == MagickFalse)
5872 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5875 if (LocaleCompare("set",option+1) == 0)
5878 if (i == (ssize_t) argc)
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5883 if (i == (ssize_t) argc)
5884 ThrowMogrifyException(OptionError,"MissingArgument",option);
5887 if (LocaleCompare("shade",option+1) == 0)
5890 if (i == (ssize_t) argc)
5891 ThrowMogrifyException(OptionError,"MissingArgument",option);
5892 if (IsGeometry(argv[i]) == MagickFalse)
5893 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5896 if (LocaleCompare("shadow",option+1) == 0)
5901 if (i == (ssize_t) argc)
5902 ThrowMogrifyException(OptionError,"MissingArgument",option);
5903 if (IsGeometry(argv[i]) == MagickFalse)
5904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5907 if (LocaleCompare("sharpen",option+1) == 0)
5910 if (i == (ssize_t) argc)
5911 ThrowMogrifyException(OptionError,"MissingArgument",option);
5912 if (IsGeometry(argv[i]) == MagickFalse)
5913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5916 if (LocaleCompare("shave",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 if (LocaleCompare("shear",option+1) == 0)
5930 if (i == (ssize_t) argc)
5931 ThrowMogrifyException(OptionError,"MissingArgument",option);
5932 if (IsGeometry(argv[i]) == MagickFalse)
5933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5936 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5939 if (i == (ssize_t) (argc-1))
5940 ThrowMogrifyException(OptionError,"MissingArgument",option);
5941 if (IsGeometry(argv[i]) == MagickFalse)
5942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5945 if (LocaleCompare("size",option+1) == 0)
5950 if (i == (ssize_t) argc)
5951 ThrowMogrifyException(OptionError,"MissingArgument",option);
5952 if (IsGeometry(argv[i]) == MagickFalse)
5953 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5956 if (LocaleCompare("sketch",option+1) == 0)
5961 if (i == (ssize_t) argc)
5962 ThrowMogrifyException(OptionError,"MissingArgument",option);
5963 if (IsGeometry(argv[i]) == MagickFalse)
5964 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5967 if (LocaleCompare("solarize",option+1) == 0)
5972 if (i == (ssize_t) argc)
5973 ThrowMogrifyException(OptionError,"MissingArgument",option);
5974 if (IsGeometry(argv[i]) == MagickFalse)
5975 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5978 if (LocaleCompare("sparse-color",option+1) == 0)
5984 if (i == (ssize_t) argc)
5985 ThrowMogrifyException(OptionError,"MissingArgument",option);
5986 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5988 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5991 if (i == (ssize_t) (argc-1))
5992 ThrowMogrifyException(OptionError,"MissingArgument",option);
5995 if (LocaleCompare("spread",option+1) == 0)
6000 if (i == (ssize_t) argc)
6001 ThrowMogrifyException(OptionError,"MissingArgument",option);
6002 if (IsGeometry(argv[i]) == MagickFalse)
6003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6006 if (LocaleCompare("stretch",option+1) == 0)
6014 if (i == (ssize_t) (argc-1))
6015 ThrowMogrifyException(OptionError,"MissingArgument",option);
6016 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6018 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6022 if (LocaleCompare("strip",option+1) == 0)
6024 if (LocaleCompare("stroke",option+1) == 0)
6029 if (i == (ssize_t) argc)
6030 ThrowMogrifyException(OptionError,"MissingArgument",option);
6033 if (LocaleCompare("strokewidth",option+1) == 0)
6038 if (i == (ssize_t) argc)
6039 ThrowMogrifyException(OptionError,"MissingArgument",option);
6040 if (IsGeometry(argv[i]) == MagickFalse)
6041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6044 if (LocaleCompare("style",option+1) == 0)
6052 if (i == (ssize_t) (argc-1))
6053 ThrowMogrifyException(OptionError,"MissingArgument",option);
6054 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6056 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6060 if (LocaleCompare("swirl",option+1) == 0)
6065 if (i == (ssize_t) argc)
6066 ThrowMogrifyException(OptionError,"MissingArgument",option);
6067 if (IsGeometry(argv[i]) == MagickFalse)
6068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6071 if (LocaleCompare("synchronize",option+1) == 0)
6073 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6077 if (LocaleCompare("taint",option+1) == 0)
6079 if (LocaleCompare("texture",option+1) == 0)
6084 if (i == (ssize_t) argc)
6085 ThrowMogrifyException(OptionError,"MissingArgument",option);
6088 if (LocaleCompare("tile",option+1) == 0)
6093 if (i == (ssize_t) (argc-1))
6094 ThrowMogrifyException(OptionError,"MissingArgument",option);
6097 if (LocaleCompare("tile-offset",option+1) == 0)
6102 if (i == (ssize_t) argc)
6103 ThrowMogrifyException(OptionError,"MissingArgument",option);
6104 if (IsGeometry(argv[i]) == MagickFalse)
6105 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6108 if (LocaleCompare("tint",option+1) == 0)
6113 if (i == (ssize_t) (argc-1))
6114 ThrowMogrifyException(OptionError,"MissingArgument",option);
6115 if (IsGeometry(argv[i]) == MagickFalse)
6116 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6119 if (LocaleCompare("transform",option+1) == 0)
6121 if (LocaleCompare("transpose",option+1) == 0)
6123 if (LocaleCompare("transverse",option+1) == 0)
6125 if (LocaleCompare("threshold",option+1) == 0)
6130 if (i == (ssize_t) argc)
6131 ThrowMogrifyException(OptionError,"MissingArgument",option);
6132 if (IsGeometry(argv[i]) == MagickFalse)
6133 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6136 if (LocaleCompare("thumbnail",option+1) == 0)
6141 if (i == (ssize_t) argc)
6142 ThrowMogrifyException(OptionError,"MissingArgument",option);
6143 if (IsGeometry(argv[i]) == MagickFalse)
6144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6147 if (LocaleCompare("transparent",option+1) == 0)
6150 if (i == (ssize_t) argc)
6151 ThrowMogrifyException(OptionError,"MissingArgument",option);
6154 if (LocaleCompare("transparent-color",option+1) == 0)
6159 if (i == (ssize_t) (argc-1))
6160 ThrowMogrifyException(OptionError,"MissingArgument",option);
6163 if (LocaleCompare("treedepth",option+1) == 0)
6168 if (i == (ssize_t) argc)
6169 ThrowMogrifyException(OptionError,"MissingArgument",option);
6170 if (IsGeometry(argv[i]) == MagickFalse)
6171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6174 if (LocaleCompare("trim",option+1) == 0)
6176 if (LocaleCompare("type",option+1) == 0)
6184 if (i == (ssize_t) argc)
6185 ThrowMogrifyException(OptionError,"MissingArgument",option);
6186 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6188 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6192 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6196 if (LocaleCompare("undercolor",option+1) == 0)
6201 if (i == (ssize_t) argc)
6202 ThrowMogrifyException(OptionError,"MissingArgument",option);
6205 if (LocaleCompare("unique-colors",option+1) == 0)
6207 if (LocaleCompare("units",option+1) == 0)
6215 if (i == (ssize_t) argc)
6216 ThrowMogrifyException(OptionError,"MissingArgument",option);
6217 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6220 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6224 if (LocaleCompare("unsharp",option+1) == 0)
6227 if (i == (ssize_t) argc)
6228 ThrowMogrifyException(OptionError,"MissingArgument",option);
6229 if (IsGeometry(argv[i]) == MagickFalse)
6230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6233 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6237 if (LocaleCompare("verbose",option+1) == 0)
6239 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6242 if ((LocaleCompare("version",option+1) == 0) ||
6243 (LocaleCompare("-version",option+1) == 0))
6245 (void) fprintf(stdout,"Version: %s\n",
6246 GetMagickVersion((size_t *) NULL));
6247 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6248 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
6251 if (LocaleCompare("view",option+1) == 0)
6256 if (i == (ssize_t) argc)
6257 ThrowMogrifyException(OptionError,"MissingArgument",option);
6260 if (LocaleCompare("vignette",option+1) == 0)
6265 if (i == (ssize_t) argc)
6266 ThrowMogrifyException(OptionError,"MissingArgument",option);
6267 if (IsGeometry(argv[i]) == MagickFalse)
6268 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6271 if (LocaleCompare("virtual-pixel",option+1) == 0)
6279 if (i == (ssize_t) argc)
6280 ThrowMogrifyException(OptionError,"MissingArgument",option);
6281 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6284 ThrowMogrifyException(OptionError,
6285 "UnrecognizedVirtualPixelMethod",argv[i]);
6288 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6292 if (LocaleCompare("wave",option+1) == 0)
6295 if (i == (ssize_t) argc)
6296 ThrowMogrifyException(OptionError,"MissingArgument",option);
6297 if (IsGeometry(argv[i]) == MagickFalse)
6298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6301 if (LocaleCompare("weight",option+1) == 0)
6306 if (i == (ssize_t) (argc-1))
6307 ThrowMogrifyException(OptionError,"MissingArgument",option);
6310 if (LocaleCompare("white-point",option+1) == 0)
6315 if (i == (ssize_t) argc)
6316 ThrowMogrifyException(OptionError,"MissingArgument",option);
6317 if (IsGeometry(argv[i]) == MagickFalse)
6318 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6321 if (LocaleCompare("white-threshold",option+1) == 0)
6326 if (i == (ssize_t) argc)
6327 ThrowMogrifyException(OptionError,"MissingArgument",option);
6328 if (IsGeometry(argv[i]) == MagickFalse)
6329 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6332 if (LocaleCompare("write",option+1) == 0)
6335 if (i == (ssize_t) (argc-1))
6336 ThrowMogrifyException(OptionError,"MissingArgument",option);
6339 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6344 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6346 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6347 MagickFalse : MagickTrue;
6348 if (fire != MagickFalse)
6349 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6352 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6353 if (i != (ssize_t) argc)
6354 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6356 return(status != 0 ? MagickTrue : MagickFalse);
6360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6364 + M o g r i f y I m a g e I n f o %
6368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6370 % MogrifyImageInfo() applies image processing settings to the image as
6371 % prescribed by command line options.
6373 % The format of the MogrifyImageInfo method is:
6375 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6376 % const char **argv,ExceptionInfo *exception)
6378 % A description of each parameter follows:
6380 % o image_info: the image info..
6382 % o argc: Specifies a pointer to an integer describing the number of
6383 % elements in the argument vector.
6385 % o argv: Specifies a pointer to a text array containing the command line
6388 % o exception: return any errors or warnings in this structure.
6391 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6392 const int argc,const char **argv,ExceptionInfo *exception)
6407 Initialize method variables.
6409 assert(image_info != (ImageInfo *) NULL);
6410 assert(image_info->signature == MagickSignature);
6411 if (image_info->debug != MagickFalse)
6412 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6413 image_info->filename);
6417 Set the image settings.
6419 for (i=0; i < (ssize_t) argc; i++)
6422 if (IsMagickOption(option) == MagickFalse)
6424 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6426 if ((i+count) >= (ssize_t) argc)
6428 switch (*(option+1))
6432 if (LocaleCompare("adjoin",option+1) == 0)
6434 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6437 if (LocaleCompare("antialias",option+1) == 0)
6439 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6442 if (LocaleCompare("attenuate",option+1) == 0)
6446 (void) DeleteImageOption(image_info,option+1);
6449 (void) SetImageOption(image_info,option+1,argv[i+1]);
6452 if (LocaleCompare("authenticate",option+1) == 0)
6455 (void) CloneString(&image_info->authenticate,(char *) NULL);
6457 (void) CloneString(&image_info->authenticate,argv[i+1]);
6464 if (LocaleCompare("background",option+1) == 0)
6468 (void) DeleteImageOption(image_info,option+1);
6469 (void) QueryColorDatabase(BackgroundColor,
6470 &image_info->background_color,exception);
6473 (void) SetImageOption(image_info,option+1,argv[i+1]);
6474 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6478 if (LocaleCompare("bias",option+1) == 0)
6482 (void) SetImageOption(image_info,option+1,"0.0");
6485 (void) SetImageOption(image_info,option+1,argv[i+1]);
6488 if (LocaleCompare("black-point-compensation",option+1) == 0)
6492 (void) SetImageOption(image_info,option+1,"false");
6495 (void) SetImageOption(image_info,option+1,"true");
6498 if (LocaleCompare("blue-primary",option+1) == 0)
6502 (void) SetImageOption(image_info,option+1,"0.0");
6505 (void) SetImageOption(image_info,option+1,argv[i+1]);
6508 if (LocaleCompare("bordercolor",option+1) == 0)
6512 (void) DeleteImageOption(image_info,option+1);
6513 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6517 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6519 (void) SetImageOption(image_info,option+1,argv[i+1]);
6522 if (LocaleCompare("box",option+1) == 0)
6526 (void) SetImageOption(image_info,"undercolor","none");
6529 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6536 if (LocaleCompare("cache",option+1) == 0)
6541 limit=MagickResourceInfinity;
6542 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6543 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6544 (void) SetMagickResourceLimit(MemoryResource,limit);
6545 (void) SetMagickResourceLimit(MapResource,2*limit);
6548 if (LocaleCompare("caption",option+1) == 0)
6552 (void) DeleteImageOption(image_info,option+1);
6555 (void) SetImageOption(image_info,option+1,argv[i+1]);
6558 if (LocaleCompare("channel",option+1) == 0)
6562 image_info->channel=DefaultChannels;
6565 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6568 if (LocaleCompare("colors",option+1) == 0)
6570 image_info->colors=StringToUnsignedLong(argv[i+1]);
6573 if (LocaleCompare("colorspace",option+1) == 0)
6577 image_info->colorspace=UndefinedColorspace;
6578 (void) SetImageOption(image_info,option+1,"undefined");
6581 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6582 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6583 (void) SetImageOption(image_info,option+1,argv[i+1]);
6586 if (LocaleCompare("compress",option+1) == 0)
6590 image_info->compression=UndefinedCompression;
6591 (void) SetImageOption(image_info,option+1,"undefined");
6594 image_info->compression=(CompressionType) ParseMagickOption(
6595 MagickCompressOptions,MagickFalse,argv[i+1]);
6596 (void) SetImageOption(image_info,option+1,argv[i+1]);
6599 if (LocaleCompare("comment",option+1) == 0)
6603 (void) DeleteImageOption(image_info,option+1);
6606 (void) SetImageOption(image_info,option+1,argv[i+1]);
6609 if (LocaleCompare("compose",option+1) == 0)
6613 (void) SetImageOption(image_info,option+1,"undefined");
6616 (void) SetImageOption(image_info,option+1,argv[i+1]);
6619 if (LocaleCompare("compress",option+1) == 0)
6623 image_info->compression=UndefinedCompression;
6624 (void) SetImageOption(image_info,option+1,"undefined");
6627 image_info->compression=(CompressionType) ParseMagickOption(
6628 MagickCompressOptions,MagickFalse,argv[i+1]);
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6636 if (LocaleCompare("debug",option+1) == 0)
6639 (void) SetLogEventMask("none");
6641 (void) SetLogEventMask(argv[i+1]);
6642 image_info->debug=IsEventLogging();
6645 if (LocaleCompare("define",option+1) == 0)
6649 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6650 (void) DeleteImageRegistry(argv[i+1]+9);
6652 (void) DeleteImageOption(image_info,argv[i+1]);
6655 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6657 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6661 (void) DefineImageOption(image_info,argv[i+1]);
6664 if (LocaleCompare("delay",option+1) == 0)
6668 (void) SetImageOption(image_info,option+1,"0");
6671 (void) SetImageOption(image_info,option+1,argv[i+1]);
6674 if (LocaleCompare("density",option+1) == 0)
6681 if (image_info->density != (char *) NULL)
6682 image_info->density=DestroyString(image_info->density);
6683 (void) SetImageOption(image_info,option+1,"72");
6686 (void) CloneString(&image_info->density,argv[i+1]);
6687 (void) SetImageOption(image_info,option+1,argv[i+1]);
6690 if (LocaleCompare("depth",option+1) == 0)
6694 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6697 image_info->depth=StringToUnsignedLong(argv[i+1]);
6700 if (LocaleCompare("direction",option+1) == 0)
6704 (void) SetImageOption(image_info,option+1,"undefined");
6707 (void) SetImageOption(image_info,option+1,argv[i+1]);
6710 if (LocaleCompare("display",option+1) == 0)
6714 if (image_info->server_name != (char *) NULL)
6715 image_info->server_name=DestroyString(
6716 image_info->server_name);
6719 (void) CloneString(&image_info->server_name,argv[i+1]);
6722 if (LocaleCompare("dispose",option+1) == 0)
6726 (void) SetImageOption(image_info,option+1,"undefined");
6729 (void) SetImageOption(image_info,option+1,argv[i+1]);
6732 if (LocaleCompare("dither",option+1) == 0)
6736 image_info->dither=MagickFalse;
6737 (void) SetImageOption(image_info,option+1,"none");
6740 (void) SetImageOption(image_info,option+1,argv[i+1]);
6741 image_info->dither=MagickTrue;
6748 if (LocaleCompare("encoding",option+1) == 0)
6752 (void) SetImageOption(image_info,option+1,"undefined");
6755 (void) SetImageOption(image_info,option+1,argv[i+1]);
6758 if (LocaleCompare("endian",option+1) == 0)
6762 image_info->endian=UndefinedEndian;
6763 (void) SetImageOption(image_info,option+1,"undefined");
6766 image_info->endian=(EndianType) ParseMagickOption(
6767 MagickEndianOptions,MagickFalse,argv[i+1]);
6768 (void) SetImageOption(image_info,option+1,argv[i+1]);
6771 if (LocaleCompare("extract",option+1) == 0)
6774 Set image extract geometry.
6778 if (image_info->extract != (char *) NULL)
6779 image_info->extract=DestroyString(image_info->extract);
6782 (void) CloneString(&image_info->extract,argv[i+1]);
6789 if (LocaleCompare("fill",option+1) == 0)
6793 (void) SetImageOption(image_info,option+1,"none");
6796 (void) SetImageOption(image_info,option+1,argv[i+1]);
6799 if (LocaleCompare("filter",option+1) == 0)
6803 (void) SetImageOption(image_info,option+1,"undefined");
6806 (void) SetImageOption(image_info,option+1,argv[i+1]);
6809 if (LocaleCompare("font",option+1) == 0)
6813 if (image_info->font != (char *) NULL)
6814 image_info->font=DestroyString(image_info->font);
6817 (void) CloneString(&image_info->font,argv[i+1]);
6820 if (LocaleCompare("format",option+1) == 0)
6825 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6826 if (strchr("gkrz@[#",*(q+1)) != (char *) NULL)
6827 image_info->ping=MagickFalse;
6828 (void) SetImageOption(image_info,option+1,argv[i+1]);
6831 if (LocaleCompare("fuzz",option+1) == 0)
6835 image_info->fuzz=0.0;
6836 (void) SetImageOption(image_info,option+1,"0");
6839 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6841 (void) SetImageOption(image_info,option+1,argv[i+1]);
6848 if (LocaleCompare("gravity",option+1) == 0)
6852 (void) SetImageOption(image_info,option+1,"undefined");
6855 (void) SetImageOption(image_info,option+1,argv[i+1]);
6858 if (LocaleCompare("green-primary",option+1) == 0)
6862 (void) SetImageOption(image_info,option+1,"0.0");
6865 (void) SetImageOption(image_info,option+1,argv[i+1]);
6872 if (LocaleCompare("intent",option+1) == 0)
6876 (void) SetImageOption(image_info,option+1,"undefined");
6879 (void) SetImageOption(image_info,option+1,argv[i+1]);
6882 if (LocaleCompare("interlace",option+1) == 0)
6886 image_info->interlace=UndefinedInterlace;
6887 (void) SetImageOption(image_info,option+1,"undefined");
6890 image_info->interlace=(InterlaceType) ParseMagickOption(
6891 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6892 (void) SetImageOption(image_info,option+1,argv[i+1]);
6895 if (LocaleCompare("interline-spacing",option+1) == 0)
6899 (void) SetImageOption(image_info,option+1,"undefined");
6902 (void) SetImageOption(image_info,option+1,argv[i+1]);
6905 if (LocaleCompare("interpolate",option+1) == 0)
6909 (void) SetImageOption(image_info,option+1,"undefined");
6912 (void) SetImageOption(image_info,option+1,argv[i+1]);
6915 if (LocaleCompare("interword-spacing",option+1) == 0)
6919 (void) SetImageOption(image_info,option+1,"undefined");
6922 (void) SetImageOption(image_info,option+1,argv[i+1]);
6929 if (LocaleCompare("kerning",option+1) == 0)
6933 (void) SetImageOption(image_info,option+1,"undefined");
6936 (void) SetImageOption(image_info,option+1,argv[i+1]);
6943 if (LocaleCompare("label",option+1) == 0)
6947 (void) DeleteImageOption(image_info,option+1);
6950 (void) SetImageOption(image_info,option+1,argv[i+1]);
6953 if (LocaleCompare("limit",option+1) == 0)
6963 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
6964 MagickFalse,argv[i+1]);
6965 limit=MagickResourceInfinity;
6966 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6967 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6968 (void) SetMagickResourceLimit(type,limit);
6971 if (LocaleCompare("list",option+1) == 0)
6977 Display configuration list.
6979 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
6982 case MagickCoderOptions:
6984 (void) ListCoderInfo((FILE *) NULL,exception);
6987 case MagickColorOptions:
6989 (void) ListColorInfo((FILE *) NULL,exception);
6992 case MagickConfigureOptions:
6994 (void) ListConfigureInfo((FILE *) NULL,exception);
6997 case MagickDelegateOptions:
6999 (void) ListDelegateInfo((FILE *) NULL,exception);
7002 case MagickFontOptions:
7004 (void) ListTypeInfo((FILE *) NULL,exception);
7007 case MagickFormatOptions:
7009 (void) ListMagickInfo((FILE *) NULL,exception);
7012 case MagickLocaleOptions:
7014 (void) ListLocaleInfo((FILE *) NULL,exception);
7017 case MagickLogOptions:
7019 (void) ListLogInfo((FILE *) NULL,exception);
7022 case MagickMagicOptions:
7024 (void) ListMagicInfo((FILE *) NULL,exception);
7027 case MagickMimeOptions:
7029 (void) ListMimeInfo((FILE *) NULL,exception);
7032 case MagickModuleOptions:
7034 (void) ListModuleInfo((FILE *) NULL,exception);
7037 case MagickPolicyOptions:
7039 (void) ListPolicyInfo((FILE *) NULL,exception);
7042 case MagickResourceOptions:
7044 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7047 case MagickThresholdOptions:
7049 (void) ListThresholdMaps((FILE *) NULL,exception);
7054 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7061 if (LocaleCompare("log",option+1) == 0)
7065 (void) SetLogFormat(argv[i+1]);
7068 if (LocaleCompare("loop",option+1) == 0)
7072 (void) SetImageOption(image_info,option+1,"0");
7075 (void) SetImageOption(image_info,option+1,argv[i+1]);
7082 if (LocaleCompare("matte",option+1) == 0)
7086 (void) SetImageOption(image_info,option+1,"false");
7089 (void) SetImageOption(image_info,option+1,"true");
7092 if (LocaleCompare("mattecolor",option+1) == 0)
7096 (void) SetImageOption(image_info,option+1,argv[i+1]);
7097 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7102 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7106 if (LocaleCompare("monitor",option+1) == 0)
7108 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7112 if (LocaleCompare("monochrome",option+1) == 0)
7114 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7121 if (LocaleCompare("orient",option+1) == 0)
7125 image_info->orientation=UndefinedOrientation;
7126 (void) SetImageOption(image_info,option+1,"undefined");
7129 image_info->orientation=(OrientationType) ParseMagickOption(
7130 MagickOrientationOptions,MagickFalse,argv[i+1]);
7131 (void) SetImageOption(image_info,option+1,argv[i+1]);
7137 if (LocaleCompare("page",option+1) == 0)
7141 page[MaxTextExtent];
7154 (void) DeleteImageOption(image_info,option+1);
7155 (void) CloneString(&image_info->page,(char *) NULL);
7158 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7159 image_option=GetImageOption(image_info,"page");
7160 if (image_option != (const char *) NULL)
7161 flags=ParseAbsoluteGeometry(image_option,&geometry);
7162 canonical_page=GetPageGeometry(argv[i+1]);
7163 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7164 canonical_page=DestroyString(canonical_page);
7165 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
7166 (unsigned long) geometry.width,(unsigned long) geometry.height);
7167 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7168 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7169 (unsigned long) geometry.width,(unsigned long) geometry.height,
7170 (long) geometry.x,(long) geometry.y);
7171 (void) SetImageOption(image_info,option+1,page);
7172 (void) CloneString(&image_info->page,page);
7175 if (LocaleCompare("pen",option+1) == 0)
7179 (void) SetImageOption(image_info,option+1,"none");
7182 (void) SetImageOption(image_info,option+1,argv[i+1]);
7185 if (LocaleCompare("ping",option+1) == 0)
7187 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7190 if (LocaleCompare("pointsize",option+1) == 0)
7193 geometry_info.rho=0.0;
7195 (void) ParseGeometry(argv[i+1],&geometry_info);
7196 image_info->pointsize=geometry_info.rho;
7199 if (LocaleCompare("precision",option+1) == 0)
7201 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7204 if (LocaleCompare("preview",option+1) == 0)
7211 image_info->preview_type=UndefinedPreview;
7214 image_info->preview_type=(PreviewType) ParseMagickOption(
7215 MagickPreviewOptions,MagickFalse,argv[i+1]);
7222 if (LocaleCompare("quality",option+1) == 0)
7225 Set image compression quality.
7229 image_info->quality=UndefinedCompressionQuality;
7230 (void) SetImageOption(image_info,option+1,"0");
7233 image_info->quality=StringToUnsignedLong(argv[i+1]);
7234 (void) SetImageOption(image_info,option+1,argv[i+1]);
7237 if (LocaleCompare("quiet",option+1) == 0)
7239 static WarningHandler
7240 warning_handler = (WarningHandler) NULL;
7245 Restore error or warning messages.
7247 warning_handler=SetWarningHandler(warning_handler);
7251 Suppress error or warning messages.
7253 warning_handler=SetWarningHandler((WarningHandler) NULL);
7260 if (LocaleCompare("red-primary",option+1) == 0)
7264 (void) SetImageOption(image_info,option+1,"0.0");
7267 (void) SetImageOption(image_info,option+1,argv[i+1]);
7274 if (LocaleCompare("sampling-factor",option+1) == 0)
7277 Set image sampling factor.
7281 if (image_info->sampling_factor != (char *) NULL)
7282 image_info->sampling_factor=DestroyString(
7283 image_info->sampling_factor);
7286 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7289 if (LocaleCompare("scene",option+1) == 0)
7296 image_info->scene=0;
7297 (void) SetImageOption(image_info,option+1,"0");
7300 image_info->scene=StringToUnsignedLong(argv[i+1]);
7301 (void) SetImageOption(image_info,option+1,argv[i+1]);
7304 if (LocaleCompare("seed",option+1) == 0)
7311 seed=(size_t) time((time_t *) NULL);
7312 SeedPseudoRandomGenerator(seed);
7315 seed=StringToUnsignedLong(argv[i+1]);
7316 SeedPseudoRandomGenerator(seed);
7319 if (LocaleCompare("size",option+1) == 0)
7323 if (image_info->size != (char *) NULL)
7324 image_info->size=DestroyString(image_info->size);
7327 (void) CloneString(&image_info->size,argv[i+1]);
7330 if (LocaleCompare("stroke",option+1) == 0)
7334 (void) SetImageOption(image_info,option+1,"none");
7337 (void) SetImageOption(image_info,option+1,argv[i+1]);
7340 if (LocaleCompare("strokewidth",option+1) == 0)
7344 (void) SetImageOption(image_info,option+1,"0");
7347 (void) SetImageOption(image_info,option+1,argv[i+1]);
7350 if (LocaleCompare("synchronize",option+1) == 0)
7354 image_info->synchronize=MagickFalse;
7357 image_info->synchronize=MagickTrue;
7364 if (LocaleCompare("taint",option+1) == 0)
7368 (void) SetImageOption(image_info,option+1,"false");
7371 (void) SetImageOption(image_info,option+1,"true");
7374 if (LocaleCompare("texture",option+1) == 0)
7378 if (image_info->texture != (char *) NULL)
7379 image_info->texture=DestroyString(image_info->texture);
7382 (void) CloneString(&image_info->texture,argv[i+1]);
7385 if (LocaleCompare("tile-offset",option+1) == 0)
7389 (void) SetImageOption(image_info,option+1,"0");
7392 (void) SetImageOption(image_info,option+1,argv[i+1]);
7395 if (LocaleCompare("transparent-color",option+1) == 0)
7399 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7400 (void) SetImageOption(image_info,option+1,"none");
7403 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7405 (void) SetImageOption(image_info,option+1,argv[i+1]);
7408 if (LocaleCompare("type",option+1) == 0)
7412 image_info->type=UndefinedType;
7413 (void) SetImageOption(image_info,option+1,"undefined");
7416 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7417 MagickFalse,argv[i+1]);
7418 (void) SetImageOption(image_info,option+1,argv[i+1]);
7425 if (LocaleCompare("undercolor",option+1) == 0)
7429 (void) DeleteImageOption(image_info,option+1);
7432 (void) SetImageOption(image_info,option+1,argv[i+1]);
7435 if (LocaleCompare("units",option+1) == 0)
7439 image_info->units=UndefinedResolution;
7440 (void) SetImageOption(image_info,option+1,"undefined");
7443 image_info->units=(ResolutionType) ParseMagickOption(
7444 MagickResolutionOptions,MagickFalse,argv[i+1]);
7445 (void) SetImageOption(image_info,option+1,argv[i+1]);
7452 if (LocaleCompare("verbose",option+1) == 0)
7456 image_info->verbose=MagickFalse;
7459 image_info->verbose=MagickTrue;
7460 image_info->ping=MagickFalse;
7463 if (LocaleCompare("view",option+1) == 0)
7467 if (image_info->view != (char *) NULL)
7468 image_info->view=DestroyString(image_info->view);
7471 (void) CloneString(&image_info->view,argv[i+1]);
7474 if (LocaleCompare("virtual-pixel",option+1) == 0)
7478 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7479 (void) SetImageOption(image_info,option+1,"undefined");
7482 image_info->virtual_pixel_method=(VirtualPixelMethod)
7483 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7485 (void) SetImageOption(image_info,option+1,argv[i+1]);
7492 if (LocaleCompare("white-point",option+1) == 0)
7496 (void) SetImageOption(image_info,option+1,"0.0");
7499 (void) SetImageOption(image_info,option+1,argv[i+1]);
7513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7517 + M o g r i f y I m a g e L i s t %
7521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7523 % MogrifyImageList() applies any command line options that might affect the
7524 % entire image list (e.g. -append, -coalesce, etc.).
7526 % The format of the MogrifyImage method is:
7528 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7529 % const char **argv,Image **images,ExceptionInfo *exception)
7531 % A description of each parameter follows:
7533 % o image_info: the image info..
7535 % o argc: Specifies a pointer to an integer describing the number of
7536 % elements in the argument vector.
7538 % o argv: Specifies a pointer to a text array containing the command line
7541 % o images: the images.
7543 % o exception: return any errors or warnings in this structure.
7546 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7547 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7572 Apply options to the image list.
7574 assert(image_info != (ImageInfo *) NULL);
7575 assert(image_info->signature == MagickSignature);
7576 assert(images != (Image **) NULL);
7577 assert((*images)->signature == MagickSignature);
7578 if ((*images)->debug != MagickFalse)
7579 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7580 (*images)->filename);
7581 if ((argc <= 0) || (*argv == (char *) NULL))
7583 mogrify_info=CloneImageInfo(image_info);
7584 quantize_info=AcquireQuantizeInfo(mogrify_info);
7585 channel=mogrify_info->channel;
7587 for (i=0; i < (ssize_t) argc; i++)
7589 if (*images == (Image *) NULL)
7592 if (IsMagickOption(option) == MagickFalse)
7594 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7596 if ((i+count) >= (ssize_t) argc)
7598 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7599 switch (*(option+1))
7603 if (LocaleCompare("affinity",option+1) == 0)
7605 (void) SyncImagesSettings(mogrify_info,*images);
7608 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7609 InheritException(exception,&(*images)->exception);
7615 if (LocaleCompare("append",option+1) == 0)
7620 (void) SyncImagesSettings(mogrify_info,*images);
7621 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7622 MagickFalse,exception);
7623 if (append_image == (Image *) NULL)
7628 *images=DestroyImageList(*images);
7629 *images=append_image;
7632 if (LocaleCompare("average",option+1) == 0)
7638 Average an image sequence (deprecated).
7640 (void) SyncImagesSettings(mogrify_info,*images);
7641 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7643 if (average_image == (Image *) NULL)
7648 *images=DestroyImageList(*images);
7649 *images=average_image;
7656 if (LocaleCompare("channel",option+1) == 0)
7660 channel=DefaultChannels;
7663 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7666 if (LocaleCompare("clut",option+1) == 0)
7672 (void) SyncImagesSettings(mogrify_info,*images);
7673 image=RemoveFirstImageFromList(images);
7674 clut_image=RemoveFirstImageFromList(images);
7675 if (clut_image == (Image *) NULL)
7680 (void) ClutImageChannel(image,channel,clut_image);
7681 clut_image=DestroyImage(clut_image);
7682 InheritException(exception,&image->exception);
7683 *images=DestroyImageList(*images);
7687 if (LocaleCompare("coalesce",option+1) == 0)
7692 (void) SyncImagesSettings(mogrify_info,*images);
7693 coalesce_image=CoalesceImages(*images,exception);
7694 if (coalesce_image == (Image *) NULL)
7699 *images=DestroyImageList(*images);
7700 *images=coalesce_image;
7703 if (LocaleCompare("combine",option+1) == 0)
7708 (void) SyncImagesSettings(mogrify_info,*images);
7709 combine_image=CombineImages(*images,channel,exception);
7710 if (combine_image == (Image *) NULL)
7715 *images=DestroyImageList(*images);
7716 *images=combine_image;
7719 if (LocaleCompare("composite",option+1) == 0)
7729 (void) SyncImagesSettings(mogrify_info,*images);
7730 image=RemoveFirstImageFromList(images);
7731 composite_image=RemoveFirstImageFromList(images);
7732 if (composite_image == (Image *) NULL)
7737 (void) TransformImage(&composite_image,(char *) NULL,
7738 composite_image->geometry);
7739 SetGeometry(composite_image,&geometry);
7740 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7741 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7743 mask_image=RemoveFirstImageFromList(images);
7744 if (mask_image != (Image *) NULL)
7746 if ((image->compose == DisplaceCompositeOp) ||
7747 (image->compose == DistortCompositeOp))
7750 Merge Y displacement into X displacement image.
7752 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7754 mask_image=DestroyImage(mask_image);
7759 Set a blending mask for the composition.
7761 image->mask=mask_image;
7762 (void) NegateImage(image->mask,MagickFalse);
7765 (void) CompositeImageChannel(image,channel,image->compose,
7766 composite_image,geometry.x,geometry.y);
7767 if (image->mask != (Image *) NULL)
7768 image->mask=DestroyImage(image->mask);
7769 composite_image=DestroyImage(composite_image);
7770 InheritException(exception,&image->exception);
7771 *images=DestroyImageList(*images);
7775 if (LocaleCompare("crop",option+1) == 0)
7783 (void) SyncImagesSettings(mogrify_info,*images);
7784 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7785 if (((geometry.width == 0) && (geometry.height == 0)) ||
7786 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7788 (void) TransformImages(images,argv[i+1],(char *) NULL);
7789 InheritException(exception,&(*images)->exception);
7796 if (LocaleCompare("deconstruct",option+1) == 0)
7801 (void) SyncImagesSettings(mogrify_info,*images);
7802 deconstruct_image=DeconstructImages(*images,exception);
7803 if (deconstruct_image == (Image *) NULL)
7808 *images=DestroyImageList(*images);
7809 *images=deconstruct_image;
7812 if (LocaleCompare("delete",option+1) == 0)
7815 DeleteImages(images,"-1",exception);
7817 DeleteImages(images,argv[i+1],exception);
7820 if (LocaleCompare("dither",option+1) == 0)
7824 quantize_info->dither=MagickFalse;
7827 quantize_info->dither=MagickTrue;
7828 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7829 MagickDitherOptions,MagickFalse,argv[i+1]);
7836 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7841 MagickEvaluateOperator
7844 (void) SyncImageSettings(mogrify_info,*images);
7845 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7846 MagickFalse,argv[i+1]);
7847 evaluate_image=EvaluateImages(*images,op,exception);
7848 if (evaluate_image == (Image *) NULL)
7853 *images=DestroyImageList(*images);
7854 *images=evaluate_image;
7861 if (LocaleCompare("fft",option+1) == 0)
7867 Implements the discrete Fourier transform (DFT).
7869 (void) SyncImageSettings(mogrify_info,*images);
7870 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7871 MagickTrue : MagickFalse,exception);
7872 if (fourier_image == (Image *) NULL)
7874 *images=DestroyImage(*images);
7875 *images=fourier_image;
7878 if (LocaleCompare("flatten",option+1) == 0)
7883 (void) SyncImagesSettings(mogrify_info,*images);
7884 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7885 if (flatten_image == (Image *) NULL)
7887 *images=DestroyImageList(*images);
7888 *images=flatten_image;
7891 if (LocaleCompare("fx",option+1) == 0)
7896 (void) SyncImagesSettings(mogrify_info,*images);
7897 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
7898 if (fx_image == (Image *) NULL)
7903 *images=DestroyImageList(*images);
7911 if (LocaleCompare("hald-clut",option+1) == 0)
7917 (void) SyncImagesSettings(mogrify_info,*images);
7918 image=RemoveFirstImageFromList(images);
7919 hald_image=RemoveFirstImageFromList(images);
7920 if (hald_image == (Image *) NULL)
7925 (void) HaldClutImageChannel(image,channel,hald_image);
7926 hald_image=DestroyImage(hald_image);
7927 InheritException(exception,&image->exception);
7928 if (*images != (Image *) NULL)
7929 *images=DestroyImageList(*images);
7937 if (LocaleCompare("ift",option+1) == 0)
7945 Implements the inverse fourier discrete Fourier transform (DFT).
7947 (void) SyncImagesSettings(mogrify_info,*images);
7948 magnitude_image=RemoveFirstImageFromList(images);
7949 phase_image=RemoveFirstImageFromList(images);
7950 if (phase_image == (Image *) NULL)
7955 fourier_image=InverseFourierTransformImage(magnitude_image,
7956 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7957 if (fourier_image == (Image *) NULL)
7959 if (*images != (Image *) NULL)
7960 *images=DestroyImage(*images);
7961 *images=fourier_image;
7964 if (LocaleCompare("insert",option+1) == 0)
7972 index=StringToLong(argv[i+1]);
7973 p=RemoveLastImageFromList(images);
7974 if (p == (Image *) NULL)
7976 (void) ThrowMagickException(exception,GetMagickModule(),
7977 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7983 PrependImageToList(images,q);
7985 if (index == (ssize_t) GetImageListLength(*images))
7986 AppendImageToList(images,q);
7989 q=GetImageFromList(*images,index-1);
7990 if (q == (Image *) NULL)
7992 (void) ThrowMagickException(exception,GetMagickModule(),
7993 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7997 InsertImageInList(&q,p);
7999 *images=GetFirstImageInList(q);
8006 if (LocaleCompare("layers",option+1) == 0)
8014 (void) SyncImagesSettings(mogrify_info,*images);
8015 layers=(Image *) NULL;
8016 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
8017 MagickFalse,argv[i+1]);
8022 layers=CoalesceImages(*images,exception);
8025 case CompareAnyLayer:
8026 case CompareClearLayer:
8027 case CompareOverlayLayer:
8030 layers=CompareImageLayers(*images,method,exception);
8036 case TrimBoundsLayer:
8038 layers=MergeImageLayers(*images,method,exception);
8043 layers=DisposeImages(*images,exception);
8046 case OptimizeImageLayer:
8048 layers=OptimizeImageLayers(*images,exception);
8051 case OptimizePlusLayer:
8053 layers=OptimizePlusImageLayers(*images,exception);
8056 case OptimizeTransLayer:
8058 OptimizeImageTransparency(*images,exception);
8061 case RemoveDupsLayer:
8063 RemoveDuplicateLayers(images,exception);
8066 case RemoveZeroLayer:
8068 RemoveZeroDelayLayers(images,exception);
8074 General Purpose, GIF Animation Optimizer.
8076 layers=CoalesceImages(*images,exception);
8077 if (layers == (Image *) NULL)
8082 InheritException(exception,&layers->exception);
8083 *images=DestroyImageList(*images);
8085 layers=OptimizeImageLayers(*images,exception);
8086 if (layers == (Image *) NULL)
8091 InheritException(exception,&layers->exception);
8092 *images=DestroyImageList(*images);
8094 layers=(Image *) NULL;
8095 OptimizeImageTransparency(*images,exception);
8096 InheritException(exception,&(*images)->exception);
8097 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8100 case CompositeLayer:
8112 Split image sequence at the first 'NULL:' image.
8115 while (source != (Image *) NULL)
8117 source=GetNextImageInList(source);
8118 if ((source != (Image *) NULL) &&
8119 (LocaleCompare(source->magick,"NULL") == 0))
8122 if (source != (Image *) NULL)
8124 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8125 (GetNextImageInList(source) == (Image *) NULL))
8126 source=(Image *) NULL;
8130 Separate the two lists, junk the null: image.
8132 source=SplitImageList(source->previous);
8133 DeleteImageFromList(&source);
8136 if (source == (Image *) NULL)
8138 (void) ThrowMagickException(exception,GetMagickModule(),
8139 OptionError,"MissingNullSeparator","layers Composite");
8144 Adjust offset with gravity and virtual canvas.
8146 SetGeometry(*images,&geometry);
8147 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8148 geometry.width=source->page.width != 0 ?
8149 source->page.width : source->columns;
8150 geometry.height=source->page.height != 0 ?
8151 source->page.height : source->rows;
8152 GravityAdjustGeometry((*images)->page.width != 0 ?
8153 (*images)->page.width : (*images)->columns,
8154 (*images)->page.height != 0 ? (*images)->page.height :
8155 (*images)->rows,(*images)->gravity,&geometry);
8156 compose=OverCompositeOp;
8157 option=GetImageOption(mogrify_info,"compose");
8158 if (option != (const char *) NULL)
8159 compose=(CompositeOperator) ParseMagickOption(
8160 MagickComposeOptions,MagickFalse,option);
8161 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8163 source=DestroyImageList(source);
8167 if (layers == (Image *) NULL)
8169 InheritException(exception,&layers->exception);
8170 *images=DestroyImageList(*images);
8178 if (LocaleCompare("map",option+1) == 0)
8180 (void) SyncImagesSettings(mogrify_info,*images);
8183 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8184 InheritException(exception,&(*images)->exception);
8190 if (LocaleCompare("maximum",option+1) == 0)
8196 Maximum image sequence (deprecated).
8198 (void) SyncImagesSettings(mogrify_info,*images);
8199 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8200 if (maximum_image == (Image *) NULL)
8205 *images=DestroyImageList(*images);
8206 *images=maximum_image;
8209 if (LocaleCompare("minimum",option+1) == 0)
8215 Minimum image sequence (deprecated).
8217 (void) SyncImagesSettings(mogrify_info,*images);
8218 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8219 if (minimum_image == (Image *) NULL)
8224 *images=DestroyImageList(*images);
8225 *images=minimum_image;
8228 if (LocaleCompare("morph",option+1) == 0)
8233 (void) SyncImagesSettings(mogrify_info,*images);
8234 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8236 if (morph_image == (Image *) NULL)
8241 *images=DestroyImageList(*images);
8242 *images=morph_image;
8245 if (LocaleCompare("mosaic",option+1) == 0)
8250 (void) SyncImagesSettings(mogrify_info,*images);
8251 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8252 if (mosaic_image == (Image *) NULL)
8257 *images=DestroyImageList(*images);
8258 *images=mosaic_image;
8265 if (LocaleCompare("print",option+1) == 0)
8270 (void) SyncImagesSettings(mogrify_info,*images);
8271 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
8272 if (string == (char *) NULL)
8274 InheritException(exception,&(*images)->exception);
8275 (void) fprintf(stdout,"%s",string);
8276 string=DestroyString(string);
8278 if (LocaleCompare("process",option+1) == 0)
8287 (void) SyncImagesSettings(mogrify_info,*images);
8288 arguments=StringToArgv(argv[i+1],&number_arguments);
8289 if (arguments == (char **) NULL)
8291 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8312 Support old style syntax, filter="-option arg".
8314 length=strlen(argv[i+1]);
8315 token=(char *) NULL;
8316 if (~length >= MaxTextExtent)
8317 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8319 if (token == (char *) NULL)
8322 arguments=argv[i+1];
8323 token_info=AcquireTokenInfo();
8324 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8325 "\"",'\0',&breaker,&next,"e);
8326 token_info=DestroyTokenInfo(token_info);
8332 argv=(&(arguments[next]));
8333 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8336 token=DestroyString(token);
8339 (void) SubstituteString(&arguments[1],"-","");
8340 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8341 number_arguments-2,(const char **) arguments+2,exception);
8342 for (j=0; j < number_arguments; j++)
8343 arguments[j]=DestroyString(arguments[j]);
8344 arguments=(char **) RelinquishMagickMemory(arguments);
8351 if (LocaleCompare("reverse",option+1) == 0)
8353 ReverseImageList(images);
8354 InheritException(exception,&(*images)->exception);
8361 if (LocaleCompare("swap",option+1) == 0)
8382 flags=ParseGeometry(argv[i+1],&geometry_info);
8383 index=(ssize_t) geometry_info.rho;
8384 if ((flags & SigmaValue) != 0)
8385 swap_index=(ssize_t) geometry_info.sigma;
8387 p=GetImageFromList(*images,index);
8388 q=GetImageFromList(*images,swap_index);
8389 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8391 (void) ThrowMagickException(exception,GetMagickModule(),
8392 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8398 swap=CloneImage(p,0,0,MagickTrue,exception);
8399 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8400 ReplaceImageInList(&q,swap);
8401 *images=GetFirstImageInList(q);
8408 if (LocaleCompare("write",option+1) == 0)
8419 (void) SyncImagesSettings(mogrify_info,*images);
8420 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8421 (void) DeleteImageRegistry(key);
8422 write_images=(*images);
8424 write_images=CloneImageList(*images,exception);
8425 write_info=CloneImageInfo(mogrify_info);
8426 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8427 write_info=DestroyImageInfo(write_info);
8429 write_images=DestroyImageList(write_images);
8439 quantize_info=DestroyQuantizeInfo(quantize_info);
8440 mogrify_info=DestroyImageInfo(mogrify_info);
8441 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8442 return(status != 0 ? MagickTrue : MagickFalse);
8446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8450 + M o g r i f y I m a g e s %
8454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8456 % MogrifyImages() applies image processing options to a sequence of images as
8457 % prescribed by command line options.
8459 % The format of the MogrifyImage method is:
8461 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8462 % const MagickBooleanType post,const int argc,const char **argv,
8463 % Image **images,Exceptioninfo *exception)
8465 % A description of each parameter follows:
8467 % o image_info: the image info..
8469 % o post: If true, post process image list operators otherwise pre-process.
8471 % o argc: Specifies a pointer to an integer describing the number of
8472 % elements in the argument vector.
8474 % o argv: Specifies a pointer to a text array containing the command line
8477 % o images: the images.
8479 % o exception: return any errors or warnings in this structure.
8482 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8483 const MagickBooleanType post,const int argc,const char **argv,
8484 Image **images,ExceptionInfo *exception)
8486 #define MogrifyImageTag "Mogrify/Image"
8505 Apply options to individual images in the list.
8507 assert(image_info != (ImageInfo *) NULL);
8508 assert(image_info->signature == MagickSignature);
8509 if (images == (Image **) NULL)
8510 return(MogrifyImage(image_info,argc,argv,images,exception));
8511 assert((*images)->signature == MagickSignature);
8512 if ((*images)->debug != MagickFalse)
8513 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8514 (*images)->filename);
8515 if ((argc <= 0) || (*argv == (char *) NULL))
8517 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8519 mogrify_images=NewImageList();
8520 number_images=GetImageListLength(*images);
8522 if (post == MagickFalse)
8523 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8524 for (i=0; i < (ssize_t) number_images; i++)
8526 image=RemoveFirstImageFromList(images);
8527 if (image == (Image *) NULL)
8529 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8530 AppendImageToList(&mogrify_images,image);
8531 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8533 if (proceed == MagickFalse)
8536 if (post != MagickFalse)
8537 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8538 *images=mogrify_images;
8539 return(status != 0 ? MagickTrue : MagickFalse);