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-2012 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/string-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/utility-private.h"
62 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
69 #define UndefinedCompressionQuality 0UL
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % M a g i c k C o m m a n d G e n e s i s %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % MagickCommandGenesis() applies image processing options to an image as
83 % prescribed by command line options.
85 % The format of the MagickCommandGenesis method is:
87 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
88 % MagickCommand command,int argc,char **argv,char **metadata,
89 % ExceptionInfo *exception)
91 % A description of each parameter follows:
93 % o image_info: the image info.
95 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
96 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
97 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98 % DisplayImageCommand, or AnimateImageCommand.
100 % o argc: Specifies a pointer to an integer describing the number of
101 % elements in the argument vector.
103 % o argv: Specifies a pointer to a text array containing the command line
106 % o metadata: any metadata is returned here.
108 % o exception: return any errors or warnings in this structure.
111 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
139 concurrent=MagickFalse;
143 regard_warnings=MagickFalse;
144 for (i=1; i < (ssize_t) (argc-1); i++)
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
149 if (LocaleCompare("-bench",option) == 0)
150 iterations=StringToUnsignedLong(argv[++i]);
151 if (LocaleCompare("-concurrent",option) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("-debug",option) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("-duration",option) == 0)
156 duration=StringToDouble(argv[++i],(char **) NULL);
157 if (LocaleCompare("-regard-warnings",option) == 0)
158 regard_warnings=MagickTrue;
162 status=command(image_info,argc,argv,metadata,exception);
163 if (exception->severity != UndefinedException)
165 if ((exception->severity > ErrorException) ||
166 (regard_warnings != MagickFalse))
168 CatchException(exception);
170 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
172 (void) fputs(*metadata,stdout);
173 (void) fputc('\n',stdout);
174 *metadata=DestroyString(*metadata);
178 number_threads=GetOpenMPMaximumThreads();
180 for (n=1; n <= (ssize_t) number_threads; n++)
190 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
191 timer=AcquireTimerInfo();
192 if (concurrent == MagickFalse)
194 for (i=0; i < (ssize_t) iterations; i++)
196 if (status != MagickFalse)
200 if (GetElapsedTime(timer) > duration)
202 (void) ContinueTimer(timer);
204 status=command(image_info,argc,argv,metadata,exception);
205 if (exception->severity != UndefinedException)
207 if ((exception->severity > ErrorException) ||
208 (regard_warnings != MagickFalse))
210 CatchException(exception);
212 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
214 (void) fputs(*metadata,stdout);
215 (void) fputc('\n',stdout);
216 *metadata=DestroyString(*metadata);
223 #if defined(MAGICKCORE_OPENMP_SUPPORT)
224 # pragma omp parallel for shared(status)
226 for (i=0; i < (ssize_t) iterations; i++)
228 if (status != MagickFalse)
232 if (GetElapsedTime(timer) > duration)
234 (void) ContinueTimer(timer);
236 status=command(image_info,argc,argv,metadata,exception);
237 #if defined(MAGICKCORE_OPENMP_SUPPORT)
238 # pragma omp critical (MagickCore_CommandGenesis)
241 if (exception->severity != UndefinedException)
243 if ((exception->severity > ErrorException) ||
244 (regard_warnings != MagickFalse))
246 CatchException(exception);
248 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
250 (void) fputs(*metadata,stdout);
251 (void) fputc('\n',stdout);
252 *metadata=DestroyString(*metadata);
257 user_time=GetUserTime(timer);
258 parallel=GetElapsedTime(timer);
263 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
264 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
265 (void) FormatLocaleFile(stderr,
266 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
267 (double) n,(double) iterations,(double) iterations/parallel,e,
268 user_time,(unsigned long) (parallel/60.0),(unsigned long)
269 floor(fmod(parallel,60.0)),(unsigned long)
270 (1000.0*(parallel-floor(parallel))+0.5));
271 timer=DestroyTimerInfo(timer);
277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281 + M o g r i f y I m a g e %
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 % MogrifyImage() applies simple single image processing options to a single
288 % image that may be part of a large list, but also handles any 'region'
291 % The image in the list may be modified in three different ways...
293 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
294 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
295 % * replace by a list of images (only the -separate option!)
297 % In each case the result is returned into the list, and a pointer to the
298 % modified image (last image added if replaced by a list of images) is
301 % ASIDE: The -crop is present but restricted to non-tile single image crops
303 % This means if all the images are being processed (such as by
304 % MogrifyImages(), next image to be processed will be as per the pointer
305 % (*image)->next. Also the image list may grow as a result of some specific
306 % operations but as images are never merged or deleted, it will never shrink
307 % in length. Typically the list will remain the same length.
309 % WARNING: As the image pointed to may be replaced, the first image in the
310 % list may also change. GetFirstImageInList() should be used by caller if
311 % they wish return the Image pointer to the first image in list.
314 % The format of the MogrifyImage method is:
316 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
317 % const char **argv,Image **image)
319 % A description of each parameter follows:
321 % o image_info: the image info..
323 % o argc: Specifies a pointer to an integer describing the number of
324 % elements in the argument vector.
326 % o argv: Specifies a pointer to a text array containing the command line
329 % o image: the image.
331 % o exception: return any errors or warnings in this structure.
335 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
336 ExceptionInfo *exception)
351 Read an image into a image cache (for repeated usage) if not already in
352 cache. Then return the image that is in the cache.
354 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
355 sans_exception=AcquireExceptionInfo();
356 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
357 sans_exception=DestroyExceptionInfo(sans_exception);
358 if (image != (Image *) NULL)
360 read_info=CloneImageInfo(image_info);
361 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
362 image=ReadImage(read_info,exception);
363 read_info=DestroyImageInfo(read_info);
364 if (image != (Image *) NULL)
365 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
369 static inline MagickBooleanType IsPathWritable(const char *path)
371 if (IsPathAccessible(path) == MagickFalse)
373 if (access_utf8(path,W_OK) != 0)
378 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
385 static MagickBooleanType MonitorProgress(const char *text,
386 const MagickOffsetType offset,const MagickSizeType extent,
387 void *wand_unused(client_data))
390 message[MaxTextExtent],
401 (void) CopyMagickMemory(tag,text,MaxTextExtent);
403 if (p != (char *) NULL)
405 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
406 locale_message=GetLocaleMessage(message);
407 if (locale_message == message)
409 if (p == (char *) NULL)
410 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
411 locale_message,(long) offset,(unsigned long) extent,(long)
412 (100L*offset/(extent-1)));
414 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
415 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
416 (100L*offset/(extent-1)));
417 if (offset == (MagickOffsetType) (extent-1))
418 (void) FormatLocaleFile(stderr,"\n");
419 (void) fflush(stderr);
423 static Image *SparseColorOption(const Image *image,
424 const SparseColorMethod method,const char *arguments,
425 const MagickBooleanType color_from_image,ExceptionInfo *exception)
428 token[MaxTextExtent];
453 SparseColorOption() parses the complex -sparse-color argument into an an
454 array of floating point values then calls SparseColorImage(). Argument is
455 a complex mix of floating-point pixel coodinates, and color specifications
456 (or direct floating point numbers). The number of floats needed to
457 represent a color varies depending on the current channel setting.
459 assert(image != (Image *) NULL);
460 assert(image->signature == MagickSignature);
461 if (image->debug != MagickFalse)
462 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
463 assert(exception != (ExceptionInfo *) NULL);
464 assert(exception->signature == MagickSignature);
466 Limit channels according to image - and add up number of color channel.
469 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
471 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
473 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
475 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
476 (image->colorspace == CMYKColorspace))
478 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
479 (image->alpha_trait == BlendPixelTrait))
483 Read string, to determine number of arguments needed,
489 GetMagickToken(p,&p,token);
490 if ( token[0] == ',' ) continue;
491 if ( isalpha((int) token[0]) || token[0] == '#' ) {
492 if ( color_from_image ) {
493 (void) ThrowMagickException(exception,GetMagickModule(),
494 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
495 "Color arg given, when colors are coming from image");
496 return( (Image *)NULL);
498 x += number_colors; /* color argument */
501 x++; /* floating point argument */
505 if ( color_from_image ) {
506 /* just the control points are being given */
507 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
508 number_arguments=(x/2)*(2+number_colors);
511 /* control points and color values */
512 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
516 (void) ThrowMagickException(exception,GetMagickModule(),
517 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
518 "Invalid number of Arguments");
519 return( (Image *)NULL);
522 /* Allocate and fill in the floating point arguments */
523 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
524 sizeof(*sparse_arguments));
525 if (sparse_arguments == (double *) NULL) {
526 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
527 "MemoryAllocationFailed","%s","SparseColorOption");
528 return( (Image *)NULL);
530 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
531 sizeof(*sparse_arguments));
534 while( *p != '\0' && x < number_arguments ) {
536 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
537 if ( token[0] == '\0' ) break;
538 if ( isalpha((int) token[0]) || token[0] == '#' ) {
539 (void) ThrowMagickException(exception,GetMagickModule(),
540 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
541 "Color found, instead of X-coord");
545 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
547 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
548 if ( token[0] == '\0' ) break;
549 if ( isalpha((int) token[0]) || token[0] == '#' ) {
550 (void) ThrowMagickException(exception,GetMagickModule(),
551 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
552 "Color found, instead of Y-coord");
556 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
557 /* color values for this control point */
559 if ( (color_from_image ) {
560 /* get color from image */
566 /* color name or function given in string argument */
567 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
568 if ( token[0] == '\0' ) break;
569 if ( isalpha((int) token[0]) || token[0] == '#' ) {
570 /* Color string given */
571 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
572 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
573 sparse_arguments[x++] = QuantumScale*color.red;
574 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
575 sparse_arguments[x++] = QuantumScale*color.green;
576 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
577 sparse_arguments[x++] = QuantumScale*color.blue;
578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
579 (image->colorspace == CMYKColorspace))
580 sparse_arguments[x++] = QuantumScale*color.black;
581 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
582 (image->alpha_trait == BlendPixelTrait))
583 sparse_arguments[x++] = QuantumScale*color.alpha;
586 /* Colors given as a set of floating point values - experimental */
587 /* NB: token contains the first floating point value to use! */
588 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
593 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
594 token[0] = ','; /* used this token - get another */
596 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
598 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
599 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
601 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
602 token[0] = ','; /* used this token - get another */
604 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
606 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
607 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
609 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
610 token[0] = ','; /* used this token - get another */
612 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
613 (image->colorspace == CMYKColorspace))
615 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
616 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
618 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
619 token[0] = ','; /* used this token - get another */
621 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
622 (image->alpha_trait == BlendPixelTrait))
624 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
625 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
627 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
628 token[0] = ','; /* used this token - get another */
633 if ( number_arguments != x && !error ) {
634 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
635 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
636 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
637 return( (Image *)NULL);
640 return( (Image *)NULL);
642 /* Call the Interpolation function with the parsed arguments */
643 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
645 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
646 return( sparse_image );
649 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
650 const char **argv,Image **image,ExceptionInfo *exception)
683 PixelInterpolateMethod
697 Initialize method variables.
699 assert(image_info != (const ImageInfo *) NULL);
700 assert(image_info->signature == MagickSignature);
701 assert(image != (Image **) NULL);
702 assert((*image)->signature == MagickSignature);
703 if ((*image)->debug != MagickFalse)
704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
707 mogrify_info=CloneImageInfo(image_info);
708 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
709 quantize_info=AcquireQuantizeInfo(mogrify_info);
710 SetGeometryInfo(&geometry_info);
711 GetPixelInfo(*image,&fill);
712 fill=(*image)->background_color;
714 compose=(*image)->compose;
715 interpolate_method=UndefinedInterpolatePixel;
716 format=GetImageOption(mogrify_info,"format");
717 SetGeometry(*image,®ion_geometry);
718 region_image=NewImageList();
720 Transmogrify the image.
722 for (i=0; i < (ssize_t) argc; i++)
731 if (IsCommandOption(option) == MagickFalse)
733 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
735 if ((i+count) >= (ssize_t) argc)
737 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
738 mogrify_image=(Image *)NULL;
743 if (LocaleCompare("adaptive-blur",option+1) == 0)
748 (void) SyncImageSettings(mogrify_info,*image,exception);
749 flags=ParseGeometry(argv[i+1],&geometry_info);
750 if ((flags & SigmaValue) == 0)
751 geometry_info.sigma=1.0;
752 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
753 geometry_info.sigma,exception);
756 if (LocaleCompare("adaptive-resize",option+1) == 0)
759 Adaptive resize image.
761 (void) SyncImageSettings(mogrify_info,*image,exception);
762 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
763 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
764 geometry.height,exception);
767 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
770 Adaptive sharpen image.
772 (void) SyncImageSettings(mogrify_info,*image,exception);
773 flags=ParseGeometry(argv[i+1],&geometry_info);
774 if ((flags & SigmaValue) == 0)
775 geometry_info.sigma=1.0;
776 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
777 geometry_info.sigma,exception);
780 if (LocaleCompare("affine",option+1) == 0)
787 GetAffineMatrix(&draw_info->affine);
790 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
793 if (LocaleCompare("alpha",option+1) == 0)
798 (void) SyncImageSettings(mogrify_info,*image,exception);
799 alpha_type=(AlphaChannelOption) ParseCommandOption(MagickAlphaChannelOptions,
800 MagickFalse,argv[i+1]);
801 (void) SetImageAlphaChannel(*image,alpha_type,exception);
804 if (LocaleCompare("annotate",option+1) == 0)
808 geometry[MaxTextExtent];
813 (void) SyncImageSettings(mogrify_info,*image,exception);
814 SetGeometryInfo(&geometry_info);
815 flags=ParseGeometry(argv[i+1],&geometry_info);
816 if ((flags & SigmaValue) == 0)
817 geometry_info.sigma=geometry_info.rho;
818 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
820 if (text == (char *) NULL)
822 (void) CloneString(&draw_info->text,text);
823 text=DestroyString(text);
824 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
825 geometry_info.xi,geometry_info.psi);
826 (void) CloneString(&draw_info->geometry,geometry);
827 draw_info->affine.sx=cos(DegreesToRadians(
828 fmod(geometry_info.rho,360.0)));
829 draw_info->affine.rx=sin(DegreesToRadians(
830 fmod(geometry_info.rho,360.0)));
831 draw_info->affine.ry=(-sin(DegreesToRadians(
832 fmod(geometry_info.sigma,360.0))));
833 draw_info->affine.sy=cos(DegreesToRadians(
834 fmod(geometry_info.sigma,360.0)));
835 (void) AnnotateImage(*image,draw_info,exception);
838 if (LocaleCompare("antialias",option+1) == 0)
840 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
842 draw_info->text_antialias=(*option == '-') ? MagickTrue :
846 if (LocaleCompare("attenuate",option+1) == 0)
853 attenuate=StringToDouble(argv[i+1],(char **) NULL);
856 if (LocaleCompare("auto-gamma",option+1) == 0)
859 Auto Adjust Gamma of image based on its mean
861 (void) SyncImageSettings(mogrify_info,*image,exception);
862 (void) AutoGammaImage(*image,exception);
865 if (LocaleCompare("auto-level",option+1) == 0)
868 Perfectly Normalize (max/min stretch) the image
870 (void) SyncImageSettings(mogrify_info,*image,exception);
871 (void) AutoLevelImage(*image,exception);
874 if (LocaleCompare("auto-orient",option+1) == 0)
876 (void) SyncImageSettings(mogrify_info,*image,exception);
877 switch ((*image)->orientation)
879 case TopRightOrientation:
881 mogrify_image=FlopImage(*image,exception);
884 case BottomRightOrientation:
886 mogrify_image=RotateImage(*image,180.0,exception);
889 case BottomLeftOrientation:
891 mogrify_image=FlipImage(*image,exception);
894 case LeftTopOrientation:
896 mogrify_image=TransposeImage(*image,exception);
899 case RightTopOrientation:
901 mogrify_image=RotateImage(*image,90.0,exception);
904 case RightBottomOrientation:
906 mogrify_image=TransverseImage(*image,exception);
909 case LeftBottomOrientation:
911 mogrify_image=RotateImage(*image,270.0,exception);
917 if (mogrify_image != (Image *) NULL)
918 mogrify_image->orientation=TopLeftOrientation;
925 if (LocaleCompare("black-threshold",option+1) == 0)
928 Black threshold image.
930 (void) SyncImageSettings(mogrify_info,*image,exception);
931 (void) BlackThresholdImage(*image,argv[i+1],exception);
934 if (LocaleCompare("blue-shift",option+1) == 0)
939 (void) SyncImageSettings(mogrify_info,*image,exception);
940 geometry_info.rho=1.5;
942 flags=ParseGeometry(argv[i+1],&geometry_info);
943 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
946 if (LocaleCompare("blur",option+1) == 0)
951 (void) SyncImageSettings(mogrify_info,*image,exception);
952 flags=ParseGeometry(argv[i+1],&geometry_info);
953 if ((flags & SigmaValue) == 0)
954 geometry_info.sigma=1.0;
955 if ((flags & XiValue) == 0)
956 geometry_info.xi=0.0;
957 mogrify_image=BlurImage(*image,geometry_info.rho,
958 geometry_info.sigma,exception);
961 if (LocaleCompare("border",option+1) == 0)
964 Surround image with a border of solid color.
966 (void) SyncImageSettings(mogrify_info,*image,exception);
967 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
968 mogrify_image=BorderImage(*image,&geometry,compose,exception);
971 if (LocaleCompare("bordercolor",option+1) == 0)
975 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
976 &draw_info->border_color,exception);
979 (void) QueryColorCompliance(argv[i+1],AllCompliance,
980 &draw_info->border_color,exception);
983 if (LocaleCompare("box",option+1) == 0)
985 (void) QueryColorCompliance(argv[i+1],AllCompliance,
986 &draw_info->undercolor,exception);
989 if (LocaleCompare("brightness-contrast",option+1) == 0)
1002 Brightness / contrast image.
1004 (void) SyncImageSettings(mogrify_info,*image,exception);
1005 flags=ParseGeometry(argv[i+1],&geometry_info);
1006 brightness=geometry_info.rho;
1008 if ((flags & SigmaValue) != 0)
1009 contrast=geometry_info.sigma;
1010 (void) BrightnessContrastImage(*image,brightness,contrast,
1018 if (LocaleCompare("cdl",option+1) == 0)
1021 *color_correction_collection;
1024 Color correct with a color decision list.
1026 (void) SyncImageSettings(mogrify_info,*image,exception);
1027 color_correction_collection=FileToString(argv[i+1],~0,exception);
1028 if (color_correction_collection == (char *) NULL)
1030 (void) ColorDecisionListImage(*image,color_correction_collection,
1034 if (LocaleCompare("charcoal",option+1) == 0)
1039 (void) SyncImageSettings(mogrify_info,*image,exception);
1040 flags=ParseGeometry(argv[i+1],&geometry_info);
1041 if ((flags & SigmaValue) == 0)
1042 geometry_info.sigma=1.0;
1043 if ((flags & XiValue) == 0)
1044 geometry_info.xi=1.0;
1045 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1046 geometry_info.sigma,exception);
1049 if (LocaleCompare("chop",option+1) == 0)
1054 (void) SyncImageSettings(mogrify_info,*image,exception);
1055 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1056 mogrify_image=ChopImage(*image,&geometry,exception);
1059 if (LocaleCompare("clamp",option+1) == 0)
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1065 (void) ClampImage(*image,exception);
1068 if (LocaleCompare("clip",option+1) == 0)
1070 (void) SyncImageSettings(mogrify_info,*image,exception);
1073 (void) SetImageMask(*image,(Image *) NULL,exception);
1076 (void) ClipImage(*image,exception);
1079 if (LocaleCompare("clip-mask",option+1) == 0)
1096 (void) SyncImageSettings(mogrify_info,*image,exception);
1102 (void) SetImageMask(*image,(Image *) NULL,exception);
1107 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1109 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1110 if (mask_image == (Image *) NULL)
1112 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1113 return(MagickFalse);
1114 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1115 for (y=0; y < (ssize_t) mask_image->rows; y++)
1117 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1119 if (q == (Quantum *) NULL)
1121 for (x=0; x < (ssize_t) mask_image->columns; x++)
1123 if (mask_image->alpha_trait != BlendPixelTrait)
1124 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1125 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1126 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1127 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1128 q+=GetPixelChannels(mask_image);
1130 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1133 mask_view=DestroyCacheView(mask_view);
1134 mask_image->alpha_trait=BlendPixelTrait;
1135 (void) SetImageMask(*image,mask_image,exception);
1138 if (LocaleCompare("clip-path",option+1) == 0)
1140 (void) SyncImageSettings(mogrify_info,*image,exception);
1141 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1142 MagickFalse,exception);
1145 if (LocaleCompare("colorize",option+1) == 0)
1150 (void) SyncImageSettings(mogrify_info,*image,exception);
1151 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1154 if (LocaleCompare("color-matrix",option+1) == 0)
1159 (void) SyncImageSettings(mogrify_info,*image,exception);
1160 kernel=AcquireKernelInfo(argv[i+1]);
1161 if (kernel == (KernelInfo *) NULL)
1163 /* FUTURE: check on size of the matrix */
1164 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1165 kernel=DestroyKernelInfo(kernel);
1168 if (LocaleCompare("colors",option+1) == 0)
1171 Reduce the number of colors in the image.
1173 (void) SyncImageSettings(mogrify_info,*image,exception);
1174 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1175 if (quantize_info->number_colors == 0)
1177 if (((*image)->storage_class == DirectClass) ||
1178 (*image)->colors > quantize_info->number_colors)
1179 (void) QuantizeImage(quantize_info,*image,exception);
1181 (void) CompressImageColormap(*image,exception);
1184 if (LocaleCompare("colorspace",option+1) == 0)
1189 (void) SyncImageSettings(mogrify_info,*image,exception);
1192 (void) TransformImageColorspace(*image,sRGBColorspace,
1196 colorspace=(ColorspaceType) ParseCommandOption(
1197 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1198 (void) TransformImageColorspace(*image,colorspace,exception);
1201 if (LocaleCompare("compose",option+1) == 0)
1203 (void) SyncImageSettings(mogrify_info,*image,exception);
1204 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1205 MagickFalse,argv[i+1]);
1208 if (LocaleCompare("contrast",option+1) == 0)
1210 (void) SyncImageSettings(mogrify_info,*image,exception);
1211 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1212 MagickFalse,exception);
1215 if (LocaleCompare("contrast-stretch",option+1) == 0)
1225 Contrast stretch image.
1227 (void) SyncImageSettings(mogrify_info,*image,exception);
1228 flags=ParseGeometry(argv[i+1],&geometry_info);
1229 black_point=geometry_info.rho;
1230 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1232 if ((flags & PercentValue) != 0)
1234 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1235 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1237 white_point=(double) (*image)->columns*(*image)->rows-
1239 (void) ContrastStretchImage(*image,black_point,white_point,
1243 if (LocaleCompare("convolve",option+1) == 0)
1248 (void) SyncImageSettings(mogrify_info,*image,exception);
1249 kernel_info=AcquireKernelInfo(argv[i+1]);
1250 if (kernel_info == (KernelInfo *) NULL)
1252 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1253 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1254 kernel_info,exception);
1255 kernel_info=DestroyKernelInfo(kernel_info);
1258 if (LocaleCompare("crop",option+1) == 0)
1261 Crop a image to a smaller size
1263 (void) SyncImageSettings(mogrify_info,*image,exception);
1264 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1267 if (LocaleCompare("cycle",option+1) == 0)
1270 Cycle an image colormap.
1272 (void) SyncImageSettings(mogrify_info,*image,exception);
1273 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1281 if (LocaleCompare("decipher",option+1) == 0)
1289 (void) SyncImageSettings(mogrify_info,*image,exception);
1290 passkey=FileToStringInfo(argv[i+1],~0,exception);
1291 if (passkey != (StringInfo *) NULL)
1293 (void) PasskeyDecipherImage(*image,passkey,exception);
1294 passkey=DestroyStringInfo(passkey);
1298 if (LocaleCompare("density",option+1) == 0)
1303 (void) CloneString(&draw_info->density,argv[i+1]);
1306 if (LocaleCompare("depth",option+1) == 0)
1308 (void) SyncImageSettings(mogrify_info,*image,exception);
1311 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1314 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1318 if (LocaleCompare("deskew",option+1) == 0)
1324 Straighten the image.
1326 (void) SyncImageSettings(mogrify_info,*image,exception);
1328 threshold=40.0*QuantumRange/100.0;
1330 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1332 mogrify_image=DeskewImage(*image,threshold,exception);
1335 if (LocaleCompare("despeckle",option+1) == 0)
1338 Reduce the speckles within an image.
1340 (void) SyncImageSettings(mogrify_info,*image,exception);
1341 mogrify_image=DespeckleImage(*image,exception);
1344 if (LocaleCompare("display",option+1) == 0)
1346 (void) CloneString(&draw_info->server_name,argv[i+1]);
1349 if (LocaleCompare("distort",option+1) == 0)
1353 token[MaxTextExtent];
1373 (void) SyncImageSettings(mogrify_info,*image,exception);
1374 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1375 MagickFalse,argv[i+1]);
1376 if (method == ResizeDistortion)
1382 Special Case - Argument is actually a resize geometry!
1383 Convert that to an appropriate distortion argument array.
1385 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1387 resize_args[0]=(double) geometry.width;
1388 resize_args[1]=(double) geometry.height;
1389 mogrify_image=DistortImage(*image,method,(size_t)2,
1390 resize_args,MagickTrue,exception);
1393 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1395 if (args == (char *) NULL)
1398 for (x=0; *p != '\0'; x++)
1400 GetMagickToken(p,&p,token);
1402 GetMagickToken(p,&p,token);
1404 number_arguments=(size_t) x;
1405 arguments=(double *) AcquireQuantumMemory(number_arguments,
1406 sizeof(*arguments));
1407 if (arguments == (double *) NULL)
1408 ThrowWandFatalException(ResourceLimitFatalError,
1409 "MemoryAllocationFailed",(*image)->filename);
1410 (void) ResetMagickMemory(arguments,0,number_arguments*
1411 sizeof(*arguments));
1413 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1415 GetMagickToken(p,&p,token);
1417 GetMagickToken(p,&p,token);
1418 arguments[x]=StringToDouble(token,(char **) NULL);
1420 args=DestroyString(args);
1421 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1422 (*option == '+') ? MagickTrue : MagickFalse,exception);
1423 arguments=(double *) RelinquishMagickMemory(arguments);
1426 if (LocaleCompare("dither",option+1) == 0)
1430 quantize_info->dither_method=NoDitherMethod;
1433 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1434 MagickDitherOptions,MagickFalse,argv[i+1]);
1437 if (LocaleCompare("draw",option+1) == 0)
1442 (void) SyncImageSettings(mogrify_info,*image,exception);
1443 (void) CloneString(&draw_info->primitive,argv[i+1]);
1444 (void) DrawImage(*image,draw_info,exception);
1451 if (LocaleCompare("edge",option+1) == 0)
1454 Enhance edges in the image.
1456 (void) SyncImageSettings(mogrify_info,*image,exception);
1457 flags=ParseGeometry(argv[i+1],&geometry_info);
1458 if ((flags & SigmaValue) == 0)
1459 geometry_info.sigma=1.0;
1460 mogrify_image=EdgeImage(*image,geometry_info.rho,
1461 geometry_info.sigma,exception);
1464 if (LocaleCompare("emboss",option+1) == 0)
1469 (void) SyncImageSettings(mogrify_info,*image,exception);
1470 flags=ParseGeometry(argv[i+1],&geometry_info);
1471 if ((flags & SigmaValue) == 0)
1472 geometry_info.sigma=1.0;
1473 mogrify_image=EmbossImage(*image,geometry_info.rho,
1474 geometry_info.sigma,exception);
1477 if (LocaleCompare("encipher",option+1) == 0)
1485 (void) SyncImageSettings(mogrify_info,*image,exception);
1486 passkey=FileToStringInfo(argv[i+1],~0,exception);
1487 if (passkey != (StringInfo *) NULL)
1489 (void) PasskeyEncipherImage(*image,passkey,exception);
1490 passkey=DestroyStringInfo(passkey);
1494 if (LocaleCompare("encoding",option+1) == 0)
1496 (void) CloneString(&draw_info->encoding,argv[i+1]);
1499 if (LocaleCompare("enhance",option+1) == 0)
1504 (void) SyncImageSettings(mogrify_info,*image,exception);
1505 mogrify_image=EnhanceImage(*image,exception);
1508 if (LocaleCompare("equalize",option+1) == 0)
1513 (void) SyncImageSettings(mogrify_info,*image,exception);
1514 (void) EqualizeImage(*image,exception);
1517 if (LocaleCompare("evaluate",option+1) == 0)
1522 MagickEvaluateOperator
1525 (void) SyncImageSettings(mogrify_info,*image,exception);
1526 op=(MagickEvaluateOperator) ParseCommandOption(
1527 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1528 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1530 (void) EvaluateImage(*image,op,constant,exception);
1533 if (LocaleCompare("extent",option+1) == 0)
1536 Set the image extent.
1538 (void) SyncImageSettings(mogrify_info,*image,exception);
1539 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1540 if (geometry.width == 0)
1541 geometry.width=(*image)->columns;
1542 if (geometry.height == 0)
1543 geometry.height=(*image)->rows;
1544 mogrify_image=ExtentImage(*image,&geometry,exception);
1551 if (LocaleCompare("family",option+1) == 0)
1555 if (draw_info->family != (char *) NULL)
1556 draw_info->family=DestroyString(draw_info->family);
1559 (void) CloneString(&draw_info->family,argv[i+1]);
1562 if (LocaleCompare("features",option+1) == 0)
1566 (void) DeleteImageArtifact(*image,"identify:features");
1569 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1572 if (LocaleCompare("fill",option+1) == 0)
1580 GetPixelInfo(*image,&fill);
1583 (void) QueryColorCompliance("none",AllCompliance,&fill,
1585 draw_info->fill=fill;
1586 if (draw_info->fill_pattern != (Image *) NULL)
1587 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1590 sans=AcquireExceptionInfo();
1591 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1592 sans=DestroyExceptionInfo(sans);
1593 if (status == MagickFalse)
1594 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1597 draw_info->fill=fill=color;
1600 if (LocaleCompare("flip",option+1) == 0)
1603 Flip image scanlines.
1605 (void) SyncImageSettings(mogrify_info,*image,exception);
1606 mogrify_image=FlipImage(*image,exception);
1609 if (LocaleCompare("floodfill",option+1) == 0)
1617 (void) SyncImageSettings(mogrify_info,*image,exception);
1618 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1619 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1621 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1622 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1625 if (LocaleCompare("flop",option+1) == 0)
1628 Flop image scanlines.
1630 (void) SyncImageSettings(mogrify_info,*image,exception);
1631 mogrify_image=FlopImage(*image,exception);
1634 if (LocaleCompare("font",option+1) == 0)
1638 if (draw_info->font != (char *) NULL)
1639 draw_info->font=DestroyString(draw_info->font);
1642 (void) CloneString(&draw_info->font,argv[i+1]);
1645 if (LocaleCompare("format",option+1) == 0)
1650 if (LocaleCompare("frame",option+1) == 0)
1656 Surround image with an ornamental border.
1658 (void) SyncImageSettings(mogrify_info,*image,exception);
1659 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1660 frame_info.width=geometry.width;
1661 frame_info.height=geometry.height;
1662 frame_info.outer_bevel=geometry.x;
1663 frame_info.inner_bevel=geometry.y;
1664 frame_info.x=(ssize_t) frame_info.width;
1665 frame_info.y=(ssize_t) frame_info.height;
1666 frame_info.width=(*image)->columns+2*frame_info.width;
1667 frame_info.height=(*image)->rows+2*frame_info.height;
1668 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1671 if (LocaleCompare("function",option+1) == 0)
1675 token[MaxTextExtent];
1693 Function Modify Image Values
1695 (void) SyncImageSettings(mogrify_info,*image,exception);
1696 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1697 MagickFalse,argv[i+1]);
1698 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1700 if (arguments == (char *) NULL)
1702 p=(char *) arguments;
1703 for (x=0; *p != '\0'; x++)
1705 GetMagickToken(p,&p,token);
1707 GetMagickToken(p,&p,token);
1709 number_parameters=(size_t) x;
1710 parameters=(double *) AcquireQuantumMemory(number_parameters,
1711 sizeof(*parameters));
1712 if (parameters == (double *) NULL)
1713 ThrowWandFatalException(ResourceLimitFatalError,
1714 "MemoryAllocationFailed",(*image)->filename);
1715 (void) ResetMagickMemory(parameters,0,number_parameters*
1716 sizeof(*parameters));
1717 p=(char *) arguments;
1718 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1720 GetMagickToken(p,&p,token);
1722 GetMagickToken(p,&p,token);
1723 parameters[x]=StringToDouble(token,(char **) NULL);
1725 arguments=DestroyString(arguments);
1726 (void) FunctionImage(*image,function,number_parameters,parameters,
1728 parameters=(double *) RelinquishMagickMemory(parameters);
1735 if (LocaleCompare("gamma",option+1) == 0)
1740 (void) SyncImageSettings(mogrify_info,*image,exception);
1742 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1744 (void) GammaImage(*image,StringToDouble(argv[i+1],
1745 (char **) NULL),exception);
1748 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1749 (LocaleCompare("gaussian",option+1) == 0))
1752 Gaussian blur image.
1754 (void) SyncImageSettings(mogrify_info,*image,exception);
1755 flags=ParseGeometry(argv[i+1],&geometry_info);
1756 if ((flags & SigmaValue) == 0)
1757 geometry_info.sigma=1.0;
1758 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1759 geometry_info.sigma,exception);
1762 if (LocaleCompare("geometry",option+1) == 0)
1765 Record Image offset, Resize last image.
1767 (void) SyncImageSettings(mogrify_info,*image,exception);
1770 if ((*image)->geometry != (char *) NULL)
1771 (*image)->geometry=DestroyString((*image)->geometry);
1774 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1775 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1776 (void) CloneString(&(*image)->geometry,argv[i+1]);
1778 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1779 (*image)->filter,exception);
1782 if (LocaleCompare("gravity",option+1) == 0)
1786 draw_info->gravity=UndefinedGravity;
1789 draw_info->gravity=(GravityType) ParseCommandOption(
1790 MagickGravityOptions,MagickFalse,argv[i+1]);
1797 if (LocaleCompare("highlight-color",option+1) == 0)
1799 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1806 if (LocaleCompare("identify",option+1) == 0)
1811 (void) SyncImageSettings(mogrify_info,*image,exception);
1812 if (format == (char *) NULL)
1814 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1818 text=InterpretImageProperties(mogrify_info,*image,format,
1820 if (text == (char *) NULL)
1822 (void) fputs(text,stdout);
1823 (void) fputc('\n',stdout);
1824 text=DestroyString(text);
1827 if (LocaleCompare("implode",option+1) == 0)
1832 (void) SyncImageSettings(mogrify_info,*image,exception);
1833 (void) ParseGeometry(argv[i+1],&geometry_info);
1834 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1835 interpolate_method,exception);
1838 if (LocaleCompare("interline-spacing",option+1) == 0)
1841 (void) ParseGeometry("0",&geometry_info);
1843 (void) ParseGeometry(argv[i+1],&geometry_info);
1844 draw_info->interline_spacing=geometry_info.rho;
1847 if (LocaleCompare("interpolate",option+1) == 0)
1849 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1850 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1853 if (LocaleCompare("interword-spacing",option+1) == 0)
1856 (void) ParseGeometry("0",&geometry_info);
1858 (void) ParseGeometry(argv[i+1],&geometry_info);
1859 draw_info->interword_spacing=geometry_info.rho;
1862 if (LocaleCompare("interpolative-resize",option+1) == 0)
1865 Interpolative resize image.
1867 (void) SyncImageSettings(mogrify_info,*image,exception);
1868 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1869 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1870 geometry.height,interpolate_method,exception);
1877 if (LocaleCompare("kerning",option+1) == 0)
1880 (void) ParseGeometry("0",&geometry_info);
1882 (void) ParseGeometry(argv[i+1],&geometry_info);
1883 draw_info->kerning=geometry_info.rho;
1890 if (LocaleCompare("lat",option+1) == 0)
1893 Local adaptive threshold image.
1895 (void) SyncImageSettings(mogrify_info,*image,exception);
1896 flags=ParseGeometry(argv[i+1],&geometry_info);
1897 if ((flags & PercentValue) != 0)
1898 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1899 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1900 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1901 geometry_info.xi,exception);
1904 if (LocaleCompare("level",option+1) == 0)
1917 (void) SyncImageSettings(mogrify_info,*image,exception);
1918 flags=ParseGeometry(argv[i+1],&geometry_info);
1919 black_point=geometry_info.rho;
1920 white_point=(double) QuantumRange;
1921 if ((flags & SigmaValue) != 0)
1922 white_point=geometry_info.sigma;
1924 if ((flags & XiValue) != 0)
1925 gamma=geometry_info.xi;
1926 if ((flags & PercentValue) != 0)
1928 black_point*=(double) (QuantumRange/100.0);
1929 white_point*=(double) (QuantumRange/100.0);
1931 if ((flags & SigmaValue) == 0)
1932 white_point=(double) QuantumRange-black_point;
1933 if ((*option == '+') || ((flags & AspectValue) != 0))
1934 (void) LevelizeImage(*image,black_point,white_point,gamma,
1937 (void) LevelImage(*image,black_point,white_point,gamma,
1941 if (LocaleCompare("level-colors",option+1) == 0)
1944 token[MaxTextExtent];
1953 p=(const char *) argv[i+1];
1954 GetMagickToken(p,&p,token); /* get black point color */
1955 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1956 (void) QueryColorCompliance(token,AllCompliance,
1957 &black_point,exception);
1959 (void) QueryColorCompliance("#000000",AllCompliance,
1960 &black_point,exception);
1961 if (isalpha((int) token[0]) || (token[0] == '#'))
1962 GetMagickToken(p,&p,token);
1964 white_point=black_point; /* set everything to that color */
1967 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1968 GetMagickToken(p,&p,token); /* Get white point color. */
1969 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1970 (void) QueryColorCompliance(token,AllCompliance,
1971 &white_point,exception);
1973 (void) QueryColorCompliance("#ffffff",AllCompliance,
1974 &white_point,exception);
1976 (void) LevelImageColors(*image,&black_point,&white_point,
1977 *option == '+' ? MagickTrue : MagickFalse,exception);
1980 if (LocaleCompare("linear-stretch",option+1) == 0)
1989 (void) SyncImageSettings(mogrify_info,*image,exception);
1990 flags=ParseGeometry(argv[i+1],&geometry_info);
1991 black_point=geometry_info.rho;
1992 white_point=(double) (*image)->columns*(*image)->rows;
1993 if ((flags & SigmaValue) != 0)
1994 white_point=geometry_info.sigma;
1995 if ((flags & PercentValue) != 0)
1997 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1998 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2000 if ((flags & SigmaValue) == 0)
2001 white_point=(double) (*image)->columns*(*image)->rows-
2003 (void) LinearStretchImage(*image,black_point,white_point,exception);
2006 if (LocaleCompare("liquid-rescale",option+1) == 0)
2009 Liquid rescale image.
2011 (void) SyncImageSettings(mogrify_info,*image,exception);
2012 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2013 if ((flags & XValue) == 0)
2015 if ((flags & YValue) == 0)
2017 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2018 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2021 if (LocaleCompare("lowlight-color",option+1) == 0)
2023 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2030 if (LocaleCompare("map",option+1) == 0)
2036 Transform image colors to match this set of colors.
2038 (void) SyncImageSettings(mogrify_info,*image,exception);
2041 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2042 if (remap_image == (Image *) NULL)
2044 (void) RemapImage(quantize_info,*image,remap_image,exception);
2045 remap_image=DestroyImage(remap_image);
2048 if (LocaleCompare("mask",option+1) == 0)
2053 (void) SyncImageSettings(mogrify_info,*image,exception);
2059 (void) SetImageMask(*image,(Image *) NULL,exception);
2065 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2066 if (mask == (Image *) NULL)
2068 (void) SetImageMask(*image,mask,exception);
2069 mask=DestroyImage(mask);
2072 if (LocaleCompare("matte",option+1) == 0)
2074 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2075 SetAlphaChannel : DeactivateAlphaChannel,exception);
2078 if (LocaleCompare("median",option+1) == 0)
2081 Median filter image.
2083 (void) SyncImageSettings(mogrify_info,*image,exception);
2084 flags=ParseGeometry(argv[i+1],&geometry_info);
2085 if ((flags & SigmaValue) == 0)
2086 geometry_info.sigma=geometry_info.rho;
2087 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2088 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2091 if (LocaleCompare("mode",option+1) == 0)
2096 (void) SyncImageSettings(mogrify_info,*image,exception);
2097 flags=ParseGeometry(argv[i+1],&geometry_info);
2098 if ((flags & SigmaValue) == 0)
2099 geometry_info.sigma=geometry_info.rho;
2100 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2101 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2104 if (LocaleCompare("modulate",option+1) == 0)
2106 (void) SyncImageSettings(mogrify_info,*image,exception);
2107 (void) ModulateImage(*image,argv[i+1],exception);
2110 if (LocaleCompare("monitor",option+1) == 0)
2114 (void) SetImageProgressMonitor(*image,
2115 (MagickProgressMonitor) NULL,(void *) NULL);
2118 (void) SetImageProgressMonitor(*image,MonitorProgress,
2122 if (LocaleCompare("monochrome",option+1) == 0)
2124 (void) SyncImageSettings(mogrify_info,*image,exception);
2125 (void) SetImageType(*image,BilevelType,exception);
2128 if (LocaleCompare("morphology",option+1) == 0)
2131 token[MaxTextExtent];
2146 Morphological Image Operation
2148 (void) SyncImageSettings(mogrify_info,*image,exception);
2150 GetMagickToken(p,&p,token);
2151 method=(MorphologyMethod) ParseCommandOption(
2152 MagickMorphologyOptions,MagickFalse,token);
2154 GetMagickToken(p,&p,token);
2155 if ((*p == ':') || (*p == ','))
2156 GetMagickToken(p,&p,token);
2158 iterations=(ssize_t) StringToLong(p);
2159 kernel=AcquireKernelInfo(argv[i+2]);
2160 if (kernel == (KernelInfo *) NULL)
2162 (void) ThrowMagickException(exception,GetMagickModule(),
2163 OptionError,"UnabletoParseKernel","morphology");
2167 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2169 kernel=DestroyKernelInfo(kernel);
2172 if (LocaleCompare("motion-blur",option+1) == 0)
2177 (void) SyncImageSettings(mogrify_info,*image,exception);
2178 flags=ParseGeometry(argv[i+1],&geometry_info);
2179 if ((flags & SigmaValue) == 0)
2180 geometry_info.sigma=1.0;
2181 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2182 geometry_info.sigma,geometry_info.xi,exception);
2189 if (LocaleCompare("negate",option+1) == 0)
2191 (void) SyncImageSettings(mogrify_info,*image,exception);
2192 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2193 MagickFalse,exception);
2196 if (LocaleCompare("noise",option+1) == 0)
2198 (void) SyncImageSettings(mogrify_info,*image,exception);
2201 flags=ParseGeometry(argv[i+1],&geometry_info);
2202 if ((flags & SigmaValue) == 0)
2203 geometry_info.sigma=geometry_info.rho;
2204 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2205 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2212 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2213 MagickFalse,argv[i+1]);
2214 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2218 if (LocaleCompare("normalize",option+1) == 0)
2220 (void) SyncImageSettings(mogrify_info,*image,exception);
2221 (void) NormalizeImage(*image,exception);
2228 if (LocaleCompare("opaque",option+1) == 0)
2233 (void) SyncImageSettings(mogrify_info,*image,exception);
2234 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2236 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2237 MagickFalse : MagickTrue,exception);
2240 if (LocaleCompare("ordered-dither",option+1) == 0)
2242 (void) SyncImageSettings(mogrify_info,*image,exception);
2243 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2250 if (LocaleCompare("paint",option+1) == 0)
2252 (void) SyncImageSettings(mogrify_info,*image,exception);
2253 (void) ParseGeometry(argv[i+1],&geometry_info);
2254 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2255 geometry_info.sigma,exception);
2258 if (LocaleCompare("pointsize",option+1) == 0)
2261 (void) ParseGeometry("12",&geometry_info);
2263 (void) ParseGeometry(argv[i+1],&geometry_info);
2264 draw_info->pointsize=geometry_info.rho;
2267 if (LocaleCompare("polaroid",option+1) == 0)
2279 Simulate a Polaroid picture.
2281 (void) SyncImageSettings(mogrify_info,*image,exception);
2282 random_info=AcquireRandomInfo();
2283 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2284 random_info=DestroyRandomInfo(random_info);
2287 SetGeometryInfo(&geometry_info);
2288 flags=ParseGeometry(argv[i+1],&geometry_info);
2289 angle=geometry_info.rho;
2291 caption=GetImageProperty(*image,"caption",exception);
2292 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2293 interpolate_method,exception);
2296 if (LocaleCompare("posterize",option+1) == 0)
2301 (void) SyncImageSettings(mogrify_info,*image,exception);
2302 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2303 quantize_info->dither_method,exception);
2306 if (LocaleCompare("preview",option+1) == 0)
2314 (void) SyncImageSettings(mogrify_info,*image,exception);
2316 preview_type=UndefinedPreview;
2318 preview_type=(PreviewType) ParseCommandOption(
2319 MagickPreviewOptions,MagickFalse,argv[i+1]);
2320 mogrify_image=PreviewImage(*image,preview_type,exception);
2323 if (LocaleCompare("profile",option+1) == 0)
2337 (void) SyncImageSettings(mogrify_info,*image,exception);
2341 Remove a profile from the image.
2343 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2348 Associate a profile with the image.
2350 profile_info=CloneImageInfo(mogrify_info);
2351 profile=GetImageProfile(*image,"iptc");
2352 if (profile != (StringInfo *) NULL)
2353 profile_info->profile=(void *) CloneStringInfo(profile);
2354 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2355 profile_info=DestroyImageInfo(profile_info);
2356 if (profile_image == (Image *) NULL)
2361 profile_info=CloneImageInfo(mogrify_info);
2362 (void) CopyMagickString(profile_info->filename,argv[i+1],
2364 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2365 if (profile != (StringInfo *) NULL)
2367 (void) ProfileImage(*image,profile_info->magick,
2368 GetStringInfoDatum(profile),(size_t)
2369 GetStringInfoLength(profile),exception);
2370 profile=DestroyStringInfo(profile);
2372 profile_info=DestroyImageInfo(profile_info);
2375 ResetImageProfileIterator(profile_image);
2376 name=GetNextImageProfile(profile_image);
2377 while (name != (const char *) NULL)
2379 profile=GetImageProfile(profile_image,name);
2380 if (profile != (StringInfo *) NULL)
2381 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2382 (size_t) GetStringInfoLength(profile),exception);
2383 name=GetNextImageProfile(profile_image);
2385 profile_image=DestroyImage(profile_image);
2392 if (LocaleCompare("quantize",option+1) == 0)
2396 quantize_info->colorspace=UndefinedColorspace;
2399 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2400 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2407 if (LocaleCompare("radial-blur",option+1) == 0)
2412 (void) SyncImageSettings(mogrify_info,*image,exception);
2413 flags=ParseGeometry(argv[i+1],&geometry_info);
2414 mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception);
2417 if (LocaleCompare("raise",option+1) == 0)
2420 Surround image with a raise of solid color.
2422 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2423 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2424 MagickFalse,exception);
2427 if (LocaleCompare("random-threshold",option+1) == 0)
2432 (void) SyncImageSettings(mogrify_info,*image,exception);
2433 (void) RandomThresholdImage(*image,argv[i+1],exception);
2436 if (LocaleCompare("region",option+1) == 0)
2438 (void) SyncImageSettings(mogrify_info,*image,exception);
2439 if (region_image != (Image *) NULL)
2444 (void) CompositeImage(region_image,*image,
2445 region_image->alpha_trait == BlendPixelTrait ?
2446 CopyCompositeOp : OverCompositeOp,MagickTrue,
2447 region_geometry.x,region_geometry.y,exception);
2448 *image=DestroyImage(*image);
2449 *image=region_image;
2450 region_image = (Image *) NULL;
2455 Apply transformations to a selected region of the image.
2457 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2459 mogrify_image=CropImage(*image,®ion_geometry,exception);
2460 if (mogrify_image == (Image *) NULL)
2462 region_image=(*image);
2463 *image=mogrify_image;
2464 mogrify_image=(Image *) NULL;
2467 if (LocaleCompare("render",option+1) == 0)
2469 (void) SyncImageSettings(mogrify_info,*image,exception);
2470 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2473 if (LocaleCompare("remap",option+1) == 0)
2479 Transform image colors to match this set of colors.
2481 (void) SyncImageSettings(mogrify_info,*image,exception);
2484 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2485 if (remap_image == (Image *) NULL)
2487 (void) RemapImage(quantize_info,*image,remap_image,exception);
2488 remap_image=DestroyImage(remap_image);
2491 if (LocaleCompare("repage",option+1) == 0)
2495 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2498 (void) ResetImagePage(*image,argv[i+1]);
2501 if (LocaleCompare("resample",option+1) == 0)
2506 (void) SyncImageSettings(mogrify_info,*image,exception);
2507 flags=ParseGeometry(argv[i+1],&geometry_info);
2508 if ((flags & SigmaValue) == 0)
2509 geometry_info.sigma=geometry_info.rho;
2510 mogrify_image=ResampleImage(*image,geometry_info.rho,
2511 geometry_info.sigma,(*image)->filter,exception);
2514 if (LocaleCompare("resize",option+1) == 0)
2519 (void) SyncImageSettings(mogrify_info,*image,exception);
2520 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2521 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2522 (*image)->filter,exception);
2525 if (LocaleCompare("roll",option+1) == 0)
2530 (void) SyncImageSettings(mogrify_info,*image,exception);
2531 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2532 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2535 if (LocaleCompare("rotate",option+1) == 0)
2541 Check for conditional image rotation.
2543 (void) SyncImageSettings(mogrify_info,*image,exception);
2544 if (strchr(argv[i+1],'>') != (char *) NULL)
2545 if ((*image)->columns <= (*image)->rows)
2547 if (strchr(argv[i+1],'<') != (char *) NULL)
2548 if ((*image)->columns >= (*image)->rows)
2553 geometry=ConstantString(argv[i+1]);
2554 (void) SubstituteString(&geometry,">","");
2555 (void) SubstituteString(&geometry,"<","");
2556 (void) ParseGeometry(geometry,&geometry_info);
2557 geometry=DestroyString(geometry);
2558 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2565 if (LocaleCompare("sample",option+1) == 0)
2568 Sample image with pixel replication.
2570 (void) SyncImageSettings(mogrify_info,*image,exception);
2571 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2572 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2576 if (LocaleCompare("scale",option+1) == 0)
2581 (void) SyncImageSettings(mogrify_info,*image,exception);
2582 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2583 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2587 if (LocaleCompare("selective-blur",option+1) == 0)
2590 Selectively blur pixels within a contrast threshold.
2592 (void) SyncImageSettings(mogrify_info,*image,exception);
2593 flags=ParseGeometry(argv[i+1],&geometry_info);
2594 if ((flags & PercentValue) != 0)
2595 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2596 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2597 geometry_info.sigma,geometry_info.xi,exception);
2600 if (LocaleCompare("separate",option+1) == 0)
2603 Break channels into separate images.
2605 (void) SyncImageSettings(mogrify_info,*image,exception);
2606 mogrify_image=SeparateImages(*image,exception);
2609 if (LocaleCompare("sepia-tone",option+1) == 0)
2617 (void) SyncImageSettings(mogrify_info,*image,exception);
2618 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2620 mogrify_image=SepiaToneImage(*image,threshold,exception);
2623 if (LocaleCompare("segment",option+1) == 0)
2628 (void) SyncImageSettings(mogrify_info,*image,exception);
2629 flags=ParseGeometry(argv[i+1],&geometry_info);
2630 if ((flags & SigmaValue) == 0)
2631 geometry_info.sigma=1.0;
2632 (void) SegmentImage(*image,(*image)->colorspace,
2633 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2637 if (LocaleCompare("set",option+1) == 0)
2647 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2648 (void) DeleteImageRegistry(argv[i+1]+9);
2650 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2652 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2653 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2656 (void) DeleteImageProperty(*image,argv[i+1]);
2659 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2661 if (value == (char *) NULL)
2663 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2664 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2667 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2669 (void) SetImageOption(image_info,argv[i+1]+7,value);
2670 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2671 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2674 (void) SetImageProperty(*image,argv[i+1],value,exception);
2675 value=DestroyString(value);
2678 if (LocaleCompare("shade",option+1) == 0)
2683 (void) SyncImageSettings(mogrify_info,*image,exception);
2684 flags=ParseGeometry(argv[i+1],&geometry_info);
2685 if ((flags & SigmaValue) == 0)
2686 geometry_info.sigma=1.0;
2687 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2688 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2691 if (LocaleCompare("shadow",option+1) == 0)
2696 (void) SyncImageSettings(mogrify_info,*image,exception);
2697 flags=ParseGeometry(argv[i+1],&geometry_info);
2698 if ((flags & SigmaValue) == 0)
2699 geometry_info.sigma=1.0;
2700 if ((flags & XiValue) == 0)
2701 geometry_info.xi=4.0;
2702 if ((flags & PsiValue) == 0)
2703 geometry_info.psi=4.0;
2704 mogrify_image=ShadowImage(*image,geometry_info.rho,
2705 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2706 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2709 if (LocaleCompare("sharpen",option+1) == 0)
2714 (void) SyncImageSettings(mogrify_info,*image,exception);
2715 flags=ParseGeometry(argv[i+1],&geometry_info);
2716 if ((flags & SigmaValue) == 0)
2717 geometry_info.sigma=1.0;
2718 if ((flags & XiValue) == 0)
2719 geometry_info.xi=0.0;
2720 mogrify_image=SharpenImage(*image,geometry_info.rho,
2721 geometry_info.sigma,exception);
2724 if (LocaleCompare("shave",option+1) == 0)
2727 Shave the image edges.
2729 (void) SyncImageSettings(mogrify_info,*image,exception);
2730 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2731 mogrify_image=ShaveImage(*image,&geometry,exception);
2734 if (LocaleCompare("shear",option+1) == 0)
2739 (void) SyncImageSettings(mogrify_info,*image,exception);
2740 flags=ParseGeometry(argv[i+1],&geometry_info);
2741 if ((flags & SigmaValue) == 0)
2742 geometry_info.sigma=geometry_info.rho;
2743 mogrify_image=ShearImage(*image,geometry_info.rho,
2744 geometry_info.sigma,exception);
2747 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2750 Sigmoidal non-linearity contrast control.
2752 (void) SyncImageSettings(mogrify_info,*image,exception);
2753 flags=ParseGeometry(argv[i+1],&geometry_info);
2754 if ((flags & SigmaValue) == 0)
2755 geometry_info.sigma=(double) QuantumRange/2.0;
2756 if ((flags & PercentValue) != 0)
2757 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2759 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2760 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2764 if (LocaleCompare("sketch",option+1) == 0)
2769 (void) SyncImageSettings(mogrify_info,*image,exception);
2770 flags=ParseGeometry(argv[i+1],&geometry_info);
2771 if ((flags & SigmaValue) == 0)
2772 geometry_info.sigma=1.0;
2773 mogrify_image=SketchImage(*image,geometry_info.rho,
2774 geometry_info.sigma,geometry_info.xi,exception);
2777 if (LocaleCompare("solarize",option+1) == 0)
2782 (void) SyncImageSettings(mogrify_info,*image,exception);
2783 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2785 (void) SolarizeImage(*image,threshold,exception);
2788 if (LocaleCompare("sparse-color",option+1) == 0)
2797 Sparse Color Interpolated Gradient
2799 (void) SyncImageSettings(mogrify_info,*image,exception);
2800 method=(SparseColorMethod) ParseCommandOption(
2801 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2802 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2804 if (arguments == (char *) NULL)
2806 mogrify_image=SparseColorOption(*image,method,arguments,
2807 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2808 arguments=DestroyString(arguments);
2811 if (LocaleCompare("splice",option+1) == 0)
2814 Splice a solid color into the image.
2816 (void) SyncImageSettings(mogrify_info,*image,exception);
2817 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2818 mogrify_image=SpliceImage(*image,&geometry,exception);
2821 if (LocaleCompare("spread",option+1) == 0)
2826 (void) SyncImageSettings(mogrify_info,*image,exception);
2827 (void) ParseGeometry(argv[i+1],&geometry_info);
2828 mogrify_image=SpreadImage(*image,geometry_info.rho,
2829 interpolate_method,exception);
2832 if (LocaleCompare("statistic",option+1) == 0)
2837 (void) SyncImageSettings(mogrify_info,*image,exception);
2838 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2839 MagickFalse,argv[i+1]);
2840 (void) ParseGeometry(argv[i+2],&geometry_info);
2841 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2842 (size_t) geometry_info.sigma,exception);
2845 if (LocaleCompare("stretch",option+1) == 0)
2849 draw_info->stretch=UndefinedStretch;
2852 draw_info->stretch=(StretchType) ParseCommandOption(
2853 MagickStretchOptions,MagickFalse,argv[i+1]);
2856 if (LocaleCompare("strip",option+1) == 0)
2859 Strip image of profiles and comments.
2861 (void) SyncImageSettings(mogrify_info,*image,exception);
2862 (void) StripImage(*image,exception);
2865 if (LocaleCompare("stroke",option+1) == 0)
2875 (void) QueryColorCompliance("none",AllCompliance,
2876 &draw_info->stroke,exception);
2877 if (draw_info->stroke_pattern != (Image *) NULL)
2878 draw_info->stroke_pattern=DestroyImage(
2879 draw_info->stroke_pattern);
2882 sans=AcquireExceptionInfo();
2883 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2884 sans=DestroyExceptionInfo(sans);
2885 if (status == MagickFalse)
2886 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2889 draw_info->stroke=color;
2892 if (LocaleCompare("strokewidth",option+1) == 0)
2894 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2897 if (LocaleCompare("style",option+1) == 0)
2901 draw_info->style=UndefinedStyle;
2904 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2905 MagickFalse,argv[i+1]);
2908 if (LocaleCompare("swirl",option+1) == 0)
2913 (void) SyncImageSettings(mogrify_info,*image,exception);
2914 (void) ParseGeometry(argv[i+1],&geometry_info);
2915 mogrify_image=SwirlImage(*image,geometry_info.rho,
2916 interpolate_method,exception);
2923 if (LocaleCompare("threshold",option+1) == 0)
2931 (void) SyncImageSettings(mogrify_info,*image,exception);
2933 threshold=(double) QuantumRange/2;
2935 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2937 (void) BilevelImage(*image,threshold,exception);
2940 if (LocaleCompare("thumbnail",option+1) == 0)
2945 (void) SyncImageSettings(mogrify_info,*image,exception);
2946 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2947 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2951 if (LocaleCompare("tile",option+1) == 0)
2955 if (draw_info->fill_pattern != (Image *) NULL)
2956 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2959 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2963 if (LocaleCompare("tint",option+1) == 0)
2968 (void) SyncImageSettings(mogrify_info,*image,exception);
2969 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2972 if (LocaleCompare("transform",option+1) == 0)
2975 Affine transform image.
2977 (void) SyncImageSettings(mogrify_info,*image,exception);
2978 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2982 if (LocaleCompare("transparent",option+1) == 0)
2987 (void) SyncImageSettings(mogrify_info,*image,exception);
2988 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2990 (void) TransparentPaintImage(*image,&target,(Quantum)
2991 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2995 if (LocaleCompare("transpose",option+1) == 0)
2998 Transpose image scanlines.
3000 (void) SyncImageSettings(mogrify_info,*image,exception);
3001 mogrify_image=TransposeImage(*image,exception);
3004 if (LocaleCompare("transverse",option+1) == 0)
3007 Transverse image scanlines.
3009 (void) SyncImageSettings(mogrify_info,*image,exception);
3010 mogrify_image=TransverseImage(*image,exception);
3013 if (LocaleCompare("treedepth",option+1) == 0)
3015 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3018 if (LocaleCompare("trim",option+1) == 0)
3023 (void) SyncImageSettings(mogrify_info,*image,exception);
3024 mogrify_image=TrimImage(*image,exception);
3027 if (LocaleCompare("type",option+1) == 0)
3032 (void) SyncImageSettings(mogrify_info,*image,exception);
3036 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3038 (*image)->type=UndefinedType;
3039 (void) SetImageType(*image,type,exception);
3046 if (LocaleCompare("undercolor",option+1) == 0)
3048 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3049 &draw_info->undercolor,exception);
3052 if (LocaleCompare("unique",option+1) == 0)
3056 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3059 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3060 (void) SetImageArtifact(*image,"verbose","true");
3063 if (LocaleCompare("unique-colors",option+1) == 0)
3066 Unique image colors.
3068 (void) SyncImageSettings(mogrify_info,*image,exception);
3069 mogrify_image=UniqueImageColors(*image,exception);
3072 if (LocaleCompare("unsharp",option+1) == 0)
3077 (void) SyncImageSettings(mogrify_info,*image,exception);
3078 flags=ParseGeometry(argv[i+1],&geometry_info);
3079 if ((flags & SigmaValue) == 0)
3080 geometry_info.sigma=1.0;
3081 if ((flags & XiValue) == 0)
3082 geometry_info.xi=1.0;
3083 if ((flags & PsiValue) == 0)
3084 geometry_info.psi=0.05;
3085 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3086 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3093 if (LocaleCompare("verbose",option+1) == 0)
3095 (void) SetImageArtifact(*image,option+1,
3096 *option == '+' ? "false" : "true");
3099 if (LocaleCompare("vignette",option+1) == 0)
3104 (void) SyncImageSettings(mogrify_info,*image,exception);
3105 flags=ParseGeometry(argv[i+1],&geometry_info);
3106 if ((flags & SigmaValue) == 0)
3107 geometry_info.sigma=1.0;
3108 if ((flags & XiValue) == 0)
3109 geometry_info.xi=0.1*(*image)->columns;
3110 if ((flags & PsiValue) == 0)
3111 geometry_info.psi=0.1*(*image)->rows;
3112 mogrify_image=VignetteImage(*image,geometry_info.rho,
3113 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3114 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3117 if (LocaleCompare("virtual-pixel",option+1) == 0)
3121 (void) SetImageVirtualPixelMethod(*image,
3122 UndefinedVirtualPixelMethod,exception);
3125 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3126 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3127 argv[i+1]),exception);
3134 if (LocaleCompare("wave",option+1) == 0)
3139 (void) SyncImageSettings(mogrify_info,*image,exception);
3140 flags=ParseGeometry(argv[i+1],&geometry_info);
3141 if ((flags & SigmaValue) == 0)
3142 geometry_info.sigma=1.0;
3143 mogrify_image=WaveImage(*image,geometry_info.rho,
3144 geometry_info.sigma,interpolate_method,exception);
3147 if (LocaleCompare("weight",option+1) == 0)
3149 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3150 if (LocaleCompare(argv[i+1],"all") == 0)
3151 draw_info->weight=0;
3152 if (LocaleCompare(argv[i+1],"bold") == 0)
3153 draw_info->weight=700;
3154 if (LocaleCompare(argv[i+1],"bolder") == 0)
3155 if (draw_info->weight <= 800)
3156 draw_info->weight+=100;
3157 if (LocaleCompare(argv[i+1],"lighter") == 0)
3158 if (draw_info->weight >= 100)
3159 draw_info->weight-=100;
3160 if (LocaleCompare(argv[i+1],"normal") == 0)
3161 draw_info->weight=400;
3164 if (LocaleCompare("white-threshold",option+1) == 0)
3167 White threshold image.
3169 (void) SyncImageSettings(mogrify_info,*image,exception);
3170 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3179 Replace current image with any image that was generated
3181 if (mogrify_image != (Image *) NULL)
3182 ReplaceImageInListReturnLast(image,mogrify_image);
3185 if (region_image != (Image *) NULL)
3188 Composite transformed region onto image.
3190 (void) SyncImageSettings(mogrify_info,*image,exception);
3191 (void) CompositeImage(region_image,*image,
3192 region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp :
3193 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3195 *image=DestroyImage(*image);
3196 *image=region_image;
3197 region_image = (Image *) NULL;
3202 quantize_info=DestroyQuantizeInfo(quantize_info);
3203 draw_info=DestroyDrawInfo(draw_info);
3204 mogrify_info=DestroyImageInfo(mogrify_info);
3205 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3206 return(status == 0 ? MagickFalse : MagickTrue);
3210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3214 + M o g r i f y I m a g e C o m m a n d %
3218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 % MogrifyImageCommand() transforms an image or a sequence of images. These
3221 % transforms include image scaling, image rotation, color reduction, and
3222 % others. The transmogrified image overwrites the original image.
3224 % The format of the MogrifyImageCommand method is:
3226 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3227 % const char **argv,char **metadata,ExceptionInfo *exception)
3229 % A description of each parameter follows:
3231 % o image_info: the image info.
3233 % o argc: the number of elements in the argument vector.
3235 % o argv: A text array containing the command line arguments.
3237 % o metadata: any metadata is returned here.
3239 % o exception: return any errors or warnings in this structure.
3243 static MagickBooleanType MogrifyUsage(void)
3246 *channel_operators[]=
3248 "-channel-fx expression",
3249 " exchange, extract, or transfer one or more image channels",
3250 "-separate separate an image channel into a grayscale image",
3255 "-debug events display copious debugging information",
3256 "-help print program options",
3257 "-list type print a list of supported option arguments",
3258 "-log format format of debugging information",
3259 "-version print version information",
3264 "-adaptive-blur geometry",
3265 " adaptively blur pixels; decrease effect near edges",
3266 "-adaptive-resize geometry",
3267 " adaptively resize image using 'mesh' interpolation",
3268 "-adaptive-sharpen geometry",
3269 " adaptively sharpen pixels; increase effect near edges",
3270 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3271 " transparent, extract, background, or shape",
3272 "-annotate geometry text",
3273 " annotate the image with text",
3274 "-auto-gamma automagically adjust gamma level of image",
3275 "-auto-level automagically adjust color levels of image",
3276 "-auto-orient automagically orient (rotate) image",
3277 "-bench iterations measure performance",
3278 "-black-threshold value",
3279 " force all pixels below the threshold into black",
3280 "-blue-shift simulate a scene at nighttime in the moonlight",
3281 "-blur geometry reduce image noise and reduce detail levels",
3282 "-border geometry surround image with a border of color",
3283 "-bordercolor color border color",
3284 "-brightness-contrast geometry",
3285 " improve brightness / contrast of the image",
3286 "-cdl filename color correct with a color decision list",
3287 "-charcoal geometry simulate a charcoal drawing",
3288 "-chop geometry remove pixels from the image interior",
3289 "-clamp restrict pixel range from 0 to the quantum depth",
3290 "-clip clip along the first path from the 8BIM profile",
3291 "-clip-mask filename associate a clip mask with the image",
3292 "-clip-path id clip along a named path from the 8BIM profile",
3293 "-colorize value colorize the image with the fill color",
3294 "-color-matrix matrix apply color correction to the image",
3295 "-contrast enhance or reduce the image contrast",
3296 "-contrast-stretch geometry",
3297 " improve contrast by 'stretching' the intensity range",
3298 "-convolve coefficients",
3299 " apply a convolution kernel to the image",
3300 "-cycle amount cycle the image colormap",
3301 "-decipher filename convert cipher pixels to plain pixels",
3302 "-deskew threshold straighten an image",
3303 "-despeckle reduce the speckles within an image",
3304 "-distort method args",
3305 " distort images according to given method ad args",
3306 "-draw string annotate the image with a graphic primitive",
3307 "-edge radius apply a filter to detect edges in the image",
3308 "-encipher filename convert plain pixels to cipher pixels",
3309 "-emboss radius emboss an image",
3310 "-enhance apply a digital filter to enhance a noisy image",
3311 "-equalize perform histogram equalization to an image",
3312 "-evaluate operator value",
3313 " evaluate an arithmetic, relational, or logical expression",
3314 "-extent geometry set the image size",
3315 "-extract geometry extract area from image",
3316 "-fft implements the discrete Fourier transform (DFT)",
3317 "-flip flip image vertically",
3318 "-floodfill geometry color",
3319 " floodfill the image with color",
3320 "-flop flop image horizontally",
3321 "-frame geometry surround image with an ornamental border",
3322 "-function name parameters",
3323 " apply function over image values",
3324 "-gamma value level of gamma correction",
3325 "-gaussian-blur geometry",
3326 " reduce image noise and reduce detail levels",
3327 "-geometry geometry preferred size or location of the image",
3328 "-identify identify the format and characteristics of the image",
3329 "-ift implements the inverse discrete Fourier transform (DFT)",
3330 "-implode amount implode image pixels about the center",
3331 "-interpolative-resize geometry",
3332 " resize image using interpolation",
3333 "-lat geometry local adaptive thresholding",
3334 "-layers method optimize, merge, or compare image layers",
3335 "-level value adjust the level of image contrast",
3336 "-level-colors color,color",
3337 " level image with the given colors",
3338 "-linear-stretch geometry",
3339 " improve contrast by 'stretching with saturation'",
3340 "-liquid-rescale geometry",
3341 " rescale image with seam-carving",
3342 "-median geometry apply a median filter to the image",
3343 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3344 "-modulate value vary the brightness, saturation, and hue",
3345 "-monochrome transform image to black and white",
3346 "-morphology method kernel",
3347 " apply a morphology method to the image",
3348 "-motion-blur geometry",
3349 " simulate motion blur",
3350 "-negate replace every pixel with its complementary color ",
3351 "-noise geometry add or reduce noise in an image",
3352 "-normalize transform image to span the full range of colors",
3353 "-opaque color change this color to the fill color",
3354 "-ordered-dither NxN",
3355 " add a noise pattern to the image with specific",
3357 "-paint radius simulate an oil painting",
3358 "-polaroid angle simulate a Polaroid picture",
3359 "-posterize levels reduce the image to a limited number of color levels",
3360 "-profile filename add, delete, or apply an image profile",
3361 "-quantize colorspace reduce colors in this colorspace",
3362 "-radial-blur angle radial blur the image",
3363 "-raise value lighten/darken image edges to create a 3-D effect",
3364 "-random-threshold low,high",
3365 " random threshold the image",
3366 "-region geometry apply options to a portion of the image",
3367 "-render render vector graphics",
3368 "-repage geometry size and location of an image canvas",
3369 "-resample geometry change the resolution of an image",
3370 "-resize geometry resize the image",
3371 "-roll geometry roll an image vertically or horizontally",
3372 "-rotate degrees apply Paeth rotation to the image",
3373 "-sample geometry scale image with pixel sampling",
3374 "-scale geometry scale the image",
3375 "-segment values segment an image",
3376 "-selective-blur geometry",
3377 " selectively blur pixels within a contrast threshold",
3378 "-sepia-tone threshold",
3379 " simulate a sepia-toned photo",
3380 "-set property value set an image property",
3381 "-shade degrees shade the image using a distant light source",
3382 "-shadow geometry simulate an image shadow",
3383 "-sharpen geometry sharpen the image",
3384 "-shave geometry shave pixels from the image edges",
3385 "-shear geometry slide one edge of the image along the X or Y axis",
3386 "-sigmoidal-contrast geometry",
3387 " increase the contrast without saturating highlights or shadows",
3388 "-sketch geometry simulate a pencil sketch",
3389 "-solarize threshold negate all pixels above the threshold level",
3390 "-sparse-color method args",
3391 " fill in a image based on a few color points",
3392 "-splice geometry splice the background color into the image",
3393 "-spread radius displace image pixels by a random amount",
3394 "-statistic type radius",
3395 " replace each pixel with corresponding statistic from the neighborhood",
3396 "-strip strip image of all profiles and comments",
3397 "-swirl degrees swirl image pixels about the center",
3398 "-threshold value threshold the image",
3399 "-thumbnail geometry create a thumbnail of the image",
3400 "-tile filename tile image when filling a graphic primitive",
3401 "-tint value tint the image with the fill color",
3402 "-transform affine transform image",
3403 "-transparent color make this color transparent within the image",
3404 "-transpose flip image vertically and rotate 90 degrees",
3405 "-transverse flop image horizontally and rotate 270 degrees",
3406 "-trim trim image edges",
3407 "-type type image type",
3408 "-unique-colors discard all but one of any pixel color",
3409 "-unsharp geometry sharpen the image",
3410 "-vignette geometry soften the edges of the image in vignette style",
3411 "-wave geometry alter an image along a sine wave",
3412 "-white-threshold value",
3413 " force all pixels above the threshold into white",
3416 *sequence_operators[]=
3418 "-append append an image sequence",
3419 "-clut apply a color lookup table to the image",
3420 "-coalesce merge a sequence of images",
3421 "-combine combine a sequence of images",
3422 "-composite composite image",
3423 "-crop geometry cut out a rectangular region of the image",
3424 "-deconstruct break down an image sequence into constituent parts",
3425 "-evaluate-sequence operator",
3426 " evaluate an arithmetic, relational, or logical expression",
3427 "-flatten flatten a sequence of images",
3428 "-fx expression apply mathematical expression to an image channel(s)",
3429 "-hald-clut apply a Hald color lookup table to the image",
3430 "-morph value morph an image sequence",
3431 "-mosaic create a mosaic from an image sequence",
3432 "-print string interpret string and print to console",
3433 "-process arguments process the image with a custom image filter",
3434 "-smush geometry smush an image sequence together",
3435 "-write filename write images to this file",
3440 "-adjoin join images into a single multi-image file",
3441 "-affine matrix affine transform matrix",
3442 "-alpha option activate, deactivate, reset, or set the alpha channel",
3443 "-antialias remove pixel-aliasing",
3444 "-authenticate password",
3445 " decipher image with this password",
3446 "-attenuate value lessen (or intensify) when adding noise to an image",
3447 "-background color background color",
3448 "-bias value add bias when convolving an image",
3449 "-black-point-compensation",
3450 " use black point compensation",
3451 "-blue-primary point chromaticity blue primary point",
3452 "-bordercolor color border color",
3453 "-caption string assign a caption to an image",
3454 "-channel type apply option to select image channels",
3455 "-colors value preferred number of colors in the image",
3456 "-colorspace type alternate image colorspace",
3457 "-comment string annotate image with comment",
3458 "-compose operator set image composite operator",
3459 "-compress type type of pixel compression when writing the image",
3460 "-define format:option=value",
3461 " define one or more image format options",
3462 "-delay value display the next image after pausing",
3463 "-density geometry horizontal and vertical density of the image",
3464 "-depth value image depth",
3465 "-direction type render text right-to-left or left-to-right",
3466 "-display server get image or font from this X server",
3467 "-dispose method layer disposal method",
3468 "-dither method apply error diffusion to image",
3469 "-encoding type text encoding type",
3470 "-endian type endianness (MSB or LSB) of the image",
3471 "-family name render text with this font family",
3472 "-features distance analyze image features (e.g. contrast, correlation)",
3473 "-fill color color to use when filling a graphic primitive",
3474 "-filter type use this filter when resizing an image",
3475 "-font name render text with this font",
3476 "-format \"string\" output formatted image characteristics",
3477 "-fuzz distance colors within this distance are considered equal",
3478 "-gravity type horizontal and vertical text placement",
3479 "-green-primary point chromaticity green primary point",
3480 "-intent type type of rendering intent when managing the image color",
3481 "-interlace type type of image interlacing scheme",
3482 "-interline-spacing value",
3483 " set the space between two text lines",
3484 "-interpolate method pixel color interpolation method",
3485 "-interword-spacing value",
3486 " set the space between two words",
3487 "-kerning value set the space between two letters",
3488 "-label string assign a label to an image",
3489 "-limit type value pixel cache resource limit",
3490 "-loop iterations add Netscape loop extension to your GIF animation",
3491 "-mask filename associate a mask with the image",
3492 "-mattecolor color frame color",
3493 "-monitor monitor progress",
3494 "-orient type image orientation",
3495 "-page geometry size and location of an image canvas (setting)",
3496 "-ping efficiently determine image attributes",
3497 "-pointsize value font point size",
3498 "-precision value maximum number of significant digits to print",
3499 "-preview type image preview type",
3500 "-quality value JPEG/MIFF/PNG compression level",
3501 "-quiet suppress all warning messages",
3502 "-red-primary point chromaticity red primary point",
3503 "-regard-warnings pay attention to warning messages",
3504 "-remap filename transform image colors to match this set of colors",
3505 "-respect-parentheses settings remain in effect until parenthesis boundary",
3506 "-sampling-factor geometry",
3507 " horizontal and vertical sampling factor",
3508 "-scene value image scene number",
3509 "-seed value seed a new sequence of pseudo-random numbers",
3510 "-size geometry width and height of image",
3511 "-stretch type render text with this font stretch",
3512 "-stroke color graphic primitive stroke color",
3513 "-strokewidth value graphic primitive stroke width",
3514 "-style type render text with this font style",
3515 "-synchronize synchronize image to storage device",
3516 "-taint declare the image as modified",
3517 "-texture filename name of texture to tile onto the image background",
3518 "-tile-offset geometry",
3520 "-treedepth value color tree depth",
3521 "-transparent-color color",
3522 " transparent color",
3523 "-undercolor color annotation bounding box color",
3524 "-units type the units of image resolution",
3525 "-verbose print detailed information about the image",
3526 "-view FlashPix viewing transforms",
3527 "-virtual-pixel method",
3528 " virtual pixel access method",
3529 "-weight type render text with this font weight",
3530 "-white-point point chromaticity white point",
3535 "-delete indexes delete the image from the image sequence",
3536 "-duplicate count,indexes",
3537 " duplicate an image one or more times",
3538 "-insert index insert last image into the image sequence",
3539 "-reverse reverse image sequence",
3540 "-swap indexes swap two images in the image sequence",
3547 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3548 (void) printf("Copyright: %s\n",GetMagickCopyright());
3549 (void) printf("Features: %s\n\n",GetMagickFeatures());
3550 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3552 (void) printf("\nImage Settings:\n");
3553 for (p=settings; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nImage Operators:\n");
3556 for (p=operators; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3558 (void) printf("\nImage Channel Operators:\n");
3559 for (p=channel_operators; *p != (char *) NULL; p++)
3560 (void) printf(" %s\n",*p);
3561 (void) printf("\nImage Sequence Operators:\n");
3562 for (p=sequence_operators; *p != (char *) NULL; p++)
3563 (void) printf(" %s\n",*p);
3564 (void) printf("\nImage Stack Operators:\n");
3565 for (p=stack_operators; *p != (char *) NULL; p++)
3566 (void) printf(" %s\n",*p);
3567 (void) printf("\nMiscellaneous Options:\n");
3568 for (p=miscellaneous; *p != (char *) NULL; p++)
3569 (void) printf(" %s\n",*p);
3571 "\nBy default, the image format of 'file' is determined by its magic\n");
3573 "number. To specify a particular image format, precede the filename\n");
3575 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3577 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3578 (void) printf("'-' for standard input or output.\n");
3579 return(MagickFalse);
3582 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3583 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3585 #define DestroyMogrify() \
3587 if (format != (char *) NULL) \
3588 format=DestroyString(format); \
3589 if (path != (char *) NULL) \
3590 path=DestroyString(path); \
3591 DestroyImageStack(); \
3592 for (i=0; i < (ssize_t) argc; i++) \
3593 argv[i]=DestroyString(argv[i]); \
3594 argv=(char **) RelinquishMagickMemory(argv); \
3596 #define ThrowMogrifyException(asperity,tag,option) \
3598 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
3601 return(MagickFalse); \
3603 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3605 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3606 "InvalidArgument","'%s': %s",argument,option); \
3608 return(MagickFalse); \
3620 image_stack[MaxImageStackDepth+1];
3628 respect_parenthesis;
3643 assert(image_info != (ImageInfo *) NULL);
3644 assert(image_info->signature == MagickSignature);
3645 if (image_info->debug != MagickFalse)
3646 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3647 assert(exception != (ExceptionInfo *) NULL);
3651 if ((LocaleCompare("version",option+1) == 0) ||
3652 (LocaleCompare("-version",option+1) == 0))
3654 (void) FormatLocaleFile(stdout,"Version: %s\n",
3655 GetMagickVersion((size_t *) NULL));
3656 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3657 GetMagickCopyright());
3658 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3659 GetMagickFeatures());
3660 return(MagickFalse);
3664 return(MogrifyUsage());
3665 format=(char *) NULL;
3667 global_colormap=MagickFalse;
3671 option=(char *) NULL;
3673 respect_parenthesis=MagickFalse;
3678 ReadCommandlLine(argc,&argv);
3679 status=ExpandFilenames(&argc,&argv);
3680 if (status == MagickFalse)
3681 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3682 GetExceptionMessage(errno));
3683 for (i=1; i < (ssize_t) argc; i++)
3686 if (LocaleCompare(option,"(") == 0)
3688 FireImageStack(MagickFalse,MagickTrue,pend);
3689 if (k == MaxImageStackDepth)
3690 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3695 if (LocaleCompare(option,")") == 0)
3697 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3699 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3703 if (IsCommandOption(option) == MagickFalse)
3706 backup_filename[MaxTextExtent],
3713 Option is a file name: begin by reading image from specified file.
3715 FireImageStack(MagickFalse,MagickFalse,pend);
3717 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3719 images=ReadImages(image_info,filename,exception);
3720 status&=(images != (Image *) NULL) &&
3721 (exception->severity < ErrorException);
3722 if (images == (Image *) NULL)
3724 if (format != (char *) NULL)
3725 (void) CopyMagickString(images->filename,images->magick_filename,
3727 if (path != (char *) NULL)
3729 GetPathComponent(option,TailPath,filename);
3730 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3731 path,*DirectorySeparator,filename);
3733 if (format != (char *) NULL)
3734 AppendImageFormat(format,images->filename);
3735 AppendImageStack(images);
3736 FinalizeImageSettings(image_info,image,MagickFalse);
3737 if (global_colormap != MagickFalse)
3742 quantize_info=AcquireQuantizeInfo(image_info);
3743 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3744 quantize_info=DestroyQuantizeInfo(quantize_info);
3746 *backup_filename='\0';
3747 if ((LocaleCompare(image->filename,"-") != 0) &&
3748 (IsPathWritable(image->filename) != MagickFalse))
3754 Rename image file as backup.
3756 (void) CopyMagickString(backup_filename,image->filename,
3758 for (i=0; i < 6; i++)
3760 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3761 if (IsPathAccessible(backup_filename) == MagickFalse)
3764 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3765 (rename_utf8(image->filename,backup_filename) != 0))
3766 *backup_filename='\0';
3769 Write transmogrified image to disk.
3771 image_info->synchronize=MagickTrue;
3772 status&=WriteImages(image_info,image,image->filename,exception);
3773 if ((status == MagickFalse) && (*backup_filename != '\0'))
3774 (void) remove_utf8(backup_filename);
3775 RemoveAllImageStack();
3778 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3779 switch (*(option+1))
3783 if (LocaleCompare("adaptive-blur",option+1) == 0)
3786 if (i == (ssize_t) argc)
3787 ThrowMogrifyException(OptionError,"MissingArgument",option);
3788 if (IsGeometry(argv[i]) == MagickFalse)
3789 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3792 if (LocaleCompare("adaptive-resize",option+1) == 0)
3795 if (i == (ssize_t) argc)
3796 ThrowMogrifyException(OptionError,"MissingArgument",option);
3797 if (IsGeometry(argv[i]) == MagickFalse)
3798 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3801 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3804 if (i == (ssize_t) argc)
3805 ThrowMogrifyException(OptionError,"MissingArgument",option);
3806 if (IsGeometry(argv[i]) == MagickFalse)
3807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3810 if (LocaleCompare("affine",option+1) == 0)
3815 if (i == (ssize_t) argc)
3816 ThrowMogrifyException(OptionError,"MissingArgument",option);
3819 if (LocaleCompare("alpha",option+1) == 0)
3827 if (i == (ssize_t) argc)
3828 ThrowMogrifyException(OptionError,"MissingArgument",option);
3829 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
3831 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
3835 if (LocaleCompare("annotate",option+1) == 0)
3840 if (i == (ssize_t) argc)
3841 ThrowMogrifyException(OptionError,"MissingArgument",option);
3842 if (IsGeometry(argv[i]) == MagickFalse)
3843 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3844 if (i == (ssize_t) argc)
3845 ThrowMogrifyException(OptionError,"MissingArgument",option);
3849 if (LocaleCompare("antialias",option+1) == 0)
3851 if (LocaleCompare("append",option+1) == 0)
3853 if (LocaleCompare("attenuate",option+1) == 0)
3858 if (i == (ssize_t) (argc-1))
3859 ThrowMogrifyException(OptionError,"MissingArgument",option);
3860 if (IsGeometry(argv[i]) == MagickFalse)
3861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3864 if (LocaleCompare("authenticate",option+1) == 0)
3869 if (i == (ssize_t) argc)
3870 ThrowMogrifyException(OptionError,"MissingArgument",option);
3873 if (LocaleCompare("auto-gamma",option+1) == 0)
3875 if (LocaleCompare("auto-level",option+1) == 0)
3877 if (LocaleCompare("auto-orient",option+1) == 0)
3879 if (LocaleCompare("average",option+1) == 0)
3881 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3885 if (LocaleCompare("background",option+1) == 0)
3890 if (i == (ssize_t) argc)
3891 ThrowMogrifyException(OptionError,"MissingArgument",option);
3894 if (LocaleCompare("bias",option+1) == 0)
3899 if (i == (ssize_t) (argc-1))
3900 ThrowMogrifyException(OptionError,"MissingArgument",option);
3901 if (IsGeometry(argv[i]) == MagickFalse)
3902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3905 if (LocaleCompare("black-point-compensation",option+1) == 0)
3907 if (LocaleCompare("black-threshold",option+1) == 0)
3912 if (i == (ssize_t) argc)
3913 ThrowMogrifyException(OptionError,"MissingArgument",option);
3914 if (IsGeometry(argv[i]) == MagickFalse)
3915 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3918 if (LocaleCompare("blue-primary",option+1) == 0)
3923 if (i == (ssize_t) argc)
3924 ThrowMogrifyException(OptionError,"MissingArgument",option);
3925 if (IsGeometry(argv[i]) == MagickFalse)
3926 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3929 if (LocaleCompare("blue-shift",option+1) == 0)
3932 if (i == (ssize_t) argc)
3933 ThrowMogrifyException(OptionError,"MissingArgument",option);
3934 if (IsGeometry(argv[i]) == MagickFalse)
3935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3938 if (LocaleCompare("blur",option+1) == 0)
3941 if (i == (ssize_t) argc)
3942 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (IsGeometry(argv[i]) == MagickFalse)
3944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3947 if (LocaleCompare("border",option+1) == 0)
3952 if (i == (ssize_t) argc)
3953 ThrowMogrifyException(OptionError,"MissingArgument",option);
3954 if (IsGeometry(argv[i]) == MagickFalse)
3955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3958 if (LocaleCompare("bordercolor",option+1) == 0)
3963 if (i == (ssize_t) argc)
3964 ThrowMogrifyException(OptionError,"MissingArgument",option);
3967 if (LocaleCompare("box",option+1) == 0)
3972 if (i == (ssize_t) argc)
3973 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (LocaleCompare("brightness-contrast",option+1) == 0)
3979 if (i == (ssize_t) argc)
3980 ThrowMogrifyException(OptionError,"MissingArgument",option);
3981 if (IsGeometry(argv[i]) == MagickFalse)
3982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3985 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3989 if (LocaleCompare("cache",option+1) == 0)
3994 if (i == (ssize_t) argc)
3995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3996 if (IsGeometry(argv[i]) == MagickFalse)
3997 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4000 if (LocaleCompare("caption",option+1) == 0)
4005 if (i == (ssize_t) argc)
4006 ThrowMogrifyException(OptionError,"MissingArgument",option);
4009 if (LocaleCompare("channel",option+1) == 0)
4017 if (i == (ssize_t) (argc-1))
4018 ThrowMogrifyException(OptionError,"MissingArgument",option);
4019 channel=ParseChannelOption(argv[i]);
4021 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4025 if (LocaleCompare("channel-fx",option+1) == 0)
4033 if (i == (ssize_t) (argc-1))
4034 ThrowMogrifyException(OptionError,"MissingArgument",option);
4035 channel=ParsePixelChannelOption(argv[i]);
4037 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4041 if (LocaleCompare("cdl",option+1) == 0)
4046 if (i == (ssize_t) (argc-1))
4047 ThrowMogrifyException(OptionError,"MissingArgument",option);
4050 if (LocaleCompare("charcoal",option+1) == 0)
4055 if (i == (ssize_t) argc)
4056 ThrowMogrifyException(OptionError,"MissingArgument",option);
4057 if (IsGeometry(argv[i]) == MagickFalse)
4058 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4061 if (LocaleCompare("chop",option+1) == 0)
4066 if (i == (ssize_t) argc)
4067 ThrowMogrifyException(OptionError,"MissingArgument",option);
4068 if (IsGeometry(argv[i]) == MagickFalse)
4069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4072 if (LocaleCompare("clamp",option+1) == 0)
4074 if (LocaleCompare("clip",option+1) == 0)
4076 if (LocaleCompare("clip-mask",option+1) == 0)
4081 if (i == (ssize_t) argc)
4082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4085 if (LocaleCompare("clut",option+1) == 0)
4087 if (LocaleCompare("coalesce",option+1) == 0)
4089 if (LocaleCompare("colorize",option+1) == 0)
4094 if (i == (ssize_t) argc)
4095 ThrowMogrifyException(OptionError,"MissingArgument",option);
4096 if (IsGeometry(argv[i]) == MagickFalse)
4097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4100 if (LocaleCompare("color-matrix",option+1) == 0)
4108 if (i == (ssize_t) (argc-1))
4109 ThrowMogrifyException(OptionError,"MissingArgument",option);
4110 kernel_info=AcquireKernelInfo(argv[i]);
4111 if (kernel_info == (KernelInfo *) NULL)
4112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4113 kernel_info=DestroyKernelInfo(kernel_info);
4116 if (LocaleCompare("colors",option+1) == 0)
4121 if (i == (ssize_t) argc)
4122 ThrowMogrifyException(OptionError,"MissingArgument",option);
4123 if (IsGeometry(argv[i]) == MagickFalse)
4124 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4127 if (LocaleCompare("colorspace",option+1) == 0)
4135 if (i == (ssize_t) argc)
4136 ThrowMogrifyException(OptionError,"MissingArgument",option);
4137 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4140 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4144 if (LocaleCompare("combine",option+1) == 0)
4152 if (i == (ssize_t) argc)
4153 ThrowMogrifyException(OptionError,"MissingArgument",option);
4154 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4157 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4161 if (LocaleCompare("comment",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (LocaleCompare("composite",option+1) == 0)
4172 if (LocaleCompare("compress",option+1) == 0)
4180 if (i == (ssize_t) argc)
4181 ThrowMogrifyException(OptionError,"MissingArgument",option);
4182 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4185 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4189 if (LocaleCompare("concurrent",option+1) == 0)
4191 if (LocaleCompare("contrast",option+1) == 0)
4193 if (LocaleCompare("contrast-stretch",option+1) == 0)
4196 if (i == (ssize_t) argc)
4197 ThrowMogrifyException(OptionError,"MissingArgument",option);
4198 if (IsGeometry(argv[i]) == MagickFalse)
4199 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4202 if (LocaleCompare("convolve",option+1) == 0)
4210 if (i == (ssize_t) argc)
4211 ThrowMogrifyException(OptionError,"MissingArgument",option);
4212 kernel_info=AcquireKernelInfo(argv[i]);
4213 if (kernel_info == (KernelInfo *) NULL)
4214 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4215 kernel_info=DestroyKernelInfo(kernel_info);
4218 if (LocaleCompare("crop",option+1) == 0)
4223 if (i == (ssize_t) argc)
4224 ThrowMogrifyException(OptionError,"MissingArgument",option);
4225 if (IsGeometry(argv[i]) == MagickFalse)
4226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4229 if (LocaleCompare("cycle",option+1) == 0)
4234 if (i == (ssize_t) argc)
4235 ThrowMogrifyException(OptionError,"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4240 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4244 if (LocaleCompare("decipher",option+1) == 0)
4249 if (i == (ssize_t) (argc-1))
4250 ThrowMogrifyException(OptionError,"MissingArgument",option);
4253 if (LocaleCompare("deconstruct",option+1) == 0)
4255 if (LocaleCompare("debug",option+1) == 0)
4263 if (i == (ssize_t) argc)
4264 ThrowMogrifyException(OptionError,"MissingArgument",option);
4265 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4267 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4269 (void) SetLogEventMask(argv[i]);
4272 if (LocaleCompare("define",option+1) == 0)
4275 if (i == (ssize_t) argc)
4276 ThrowMogrifyException(OptionError,"MissingArgument",option);
4282 define=GetImageOption(image_info,argv[i]);
4283 if (define == (const char *) NULL)
4284 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4289 if (LocaleCompare("delay",option+1) == 0)
4294 if (i == (ssize_t) argc)
4295 ThrowMogrifyException(OptionError,"MissingArgument",option);
4296 if (IsGeometry(argv[i]) == MagickFalse)
4297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4300 if (LocaleCompare("delete",option+1) == 0)
4305 if (i == (ssize_t) (argc-1))
4306 ThrowMogrifyException(OptionError,"MissingArgument",option);
4307 if (IsGeometry(argv[i]) == MagickFalse)
4308 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4311 if (LocaleCompare("density",option+1) == 0)
4316 if (i == (ssize_t) argc)
4317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 if (IsGeometry(argv[i]) == MagickFalse)
4319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4322 if (LocaleCompare("depth",option+1) == 0)
4327 if (i == (ssize_t) argc)
4328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4329 if (IsGeometry(argv[i]) == MagickFalse)
4330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4333 if (LocaleCompare("deskew",option+1) == 0)
4338 if (i == (ssize_t) argc)
4339 ThrowMogrifyException(OptionError,"MissingArgument",option);
4340 if (IsGeometry(argv[i]) == MagickFalse)
4341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4344 if (LocaleCompare("despeckle",option+1) == 0)
4346 if (LocaleCompare("dft",option+1) == 0)
4348 if (LocaleCompare("direction",option+1) == 0)
4356 if (i == (ssize_t) argc)
4357 ThrowMogrifyException(OptionError,"MissingArgument",option);
4358 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4361 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4365 if (LocaleCompare("display",option+1) == 0)
4370 if (i == (ssize_t) argc)
4371 ThrowMogrifyException(OptionError,"MissingArgument",option);
4374 if (LocaleCompare("dispose",option+1) == 0)
4382 if (i == (ssize_t) argc)
4383 ThrowMogrifyException(OptionError,"MissingArgument",option);
4384 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4386 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4390 if (LocaleCompare("distort",option+1) == 0)
4396 if (i == (ssize_t) argc)
4397 ThrowMogrifyException(OptionError,"MissingArgument",option);
4398 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4400 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4403 if (i == (ssize_t) (argc-1))
4404 ThrowMogrifyException(OptionError,"MissingArgument",option);
4407 if (LocaleCompare("dither",option+1) == 0)
4415 if (i == (ssize_t) argc)
4416 ThrowMogrifyException(OptionError,"MissingArgument",option);
4417 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4419 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4423 if (LocaleCompare("draw",option+1) == 0)
4428 if (i == (ssize_t) argc)
4429 ThrowMogrifyException(OptionError,"MissingArgument",option);
4432 if (LocaleCompare("duplicate",option+1) == 0)
4437 if (i == (ssize_t) (argc-1))
4438 ThrowMogrifyException(OptionError,"MissingArgument",option);
4439 if (IsGeometry(argv[i]) == MagickFalse)
4440 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4443 if (LocaleCompare("duration",option+1) == 0)
4448 if (i == (ssize_t) (argc-1))
4449 ThrowMogrifyException(OptionError,"MissingArgument",option);
4450 if (IsGeometry(argv[i]) == MagickFalse)
4451 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4454 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4458 if (LocaleCompare("edge",option+1) == 0)
4463 if (i == (ssize_t) argc)
4464 ThrowMogrifyException(OptionError,"MissingArgument",option);
4465 if (IsGeometry(argv[i]) == MagickFalse)
4466 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4469 if (LocaleCompare("emboss",option+1) == 0)
4474 if (i == (ssize_t) argc)
4475 ThrowMogrifyException(OptionError,"MissingArgument",option);
4476 if (IsGeometry(argv[i]) == MagickFalse)
4477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4480 if (LocaleCompare("encipher",option+1) == 0)
4485 if (i == (ssize_t) argc)
4486 ThrowMogrifyException(OptionError,"MissingArgument",option);
4489 if (LocaleCompare("encoding",option+1) == 0)
4494 if (i == (ssize_t) argc)
4495 ThrowMogrifyException(OptionError,"MissingArgument",option);
4498 if (LocaleCompare("endian",option+1) == 0)
4506 if (i == (ssize_t) argc)
4507 ThrowMogrifyException(OptionError,"MissingArgument",option);
4508 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4510 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4514 if (LocaleCompare("enhance",option+1) == 0)
4516 if (LocaleCompare("equalize",option+1) == 0)
4518 if (LocaleCompare("evaluate",option+1) == 0)
4526 if (i == (ssize_t) argc)
4527 ThrowMogrifyException(OptionError,"MissingArgument",option);
4528 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4530 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4533 if (i == (ssize_t) (argc-1))
4534 ThrowMogrifyException(OptionError,"MissingArgument",option);
4535 if (IsGeometry(argv[i]) == MagickFalse)
4536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4539 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4547 if (i == (ssize_t) argc)
4548 ThrowMogrifyException(OptionError,"MissingArgument",option);
4549 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4551 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4555 if (LocaleCompare("extent",option+1) == 0)
4560 if (i == (ssize_t) argc)
4561 ThrowMogrifyException(OptionError,"MissingArgument",option);
4562 if (IsGeometry(argv[i]) == MagickFalse)
4563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4566 if (LocaleCompare("extract",option+1) == 0)
4571 if (i == (ssize_t) argc)
4572 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 if (IsGeometry(argv[i]) == MagickFalse)
4574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4577 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4581 if (LocaleCompare("family",option+1) == 0)
4586 if (i == (ssize_t) (argc-1))
4587 ThrowMogrifyException(OptionError,"MissingArgument",option);
4590 if (LocaleCompare("features",option+1) == 0)
4595 if (i == (ssize_t) (argc-1))
4596 ThrowMogrifyException(OptionError,"MissingArgument",option);
4597 if (IsGeometry(argv[i]) == MagickFalse)
4598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4601 if (LocaleCompare("fill",option+1) == 0)
4606 if (i == (ssize_t) argc)
4607 ThrowMogrifyException(OptionError,"MissingArgument",option);
4610 if (LocaleCompare("filter",option+1) == 0)
4618 if (i == (ssize_t) argc)
4619 ThrowMogrifyException(OptionError,"MissingArgument",option);
4620 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4622 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4626 if (LocaleCompare("flatten",option+1) == 0)
4628 if (LocaleCompare("flip",option+1) == 0)
4630 if (LocaleCompare("flop",option+1) == 0)
4632 if (LocaleCompare("floodfill",option+1) == 0)
4637 if (i == (ssize_t) argc)
4638 ThrowMogrifyException(OptionError,"MissingArgument",option);
4639 if (IsGeometry(argv[i]) == MagickFalse)
4640 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4642 if (i == (ssize_t) argc)
4643 ThrowMogrifyException(OptionError,"MissingArgument",option);
4646 if (LocaleCompare("font",option+1) == 0)
4651 if (i == (ssize_t) argc)
4652 ThrowMogrifyException(OptionError,"MissingArgument",option);
4655 if (LocaleCompare("format",option+1) == 0)
4657 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4658 (void) CloneString(&format,(char *) NULL);
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4664 (void) CloneString(&format,argv[i]);
4665 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4666 (void) ConcatenateMagickString(image_info->filename,":",
4668 (void) SetImageInfo(image_info,0,exception);
4669 if (*image_info->magick == '\0')
4670 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4674 if (LocaleCompare("frame",option+1) == 0)
4679 if (i == (ssize_t) argc)
4680 ThrowMogrifyException(OptionError,"MissingArgument",option);
4681 if (IsGeometry(argv[i]) == MagickFalse)
4682 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4685 if (LocaleCompare("function",option+1) == 0)
4693 if (i == (ssize_t) argc)
4694 ThrowMogrifyException(OptionError,"MissingArgument",option);
4695 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4697 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4699 if (i == (ssize_t) (argc-1))
4700 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 if (LocaleCompare("fuzz",option+1) == 0)
4708 if (i == (ssize_t) argc)
4709 ThrowMogrifyException(OptionError,"MissingArgument",option);
4710 if (IsGeometry(argv[i]) == MagickFalse)
4711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4714 if (LocaleCompare("fx",option+1) == 0)
4719 if (i == (ssize_t) (argc-1))
4720 ThrowMogrifyException(OptionError,"MissingArgument",option);
4723 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4727 if (LocaleCompare("gamma",option+1) == 0)
4730 if (i == (ssize_t) argc)
4731 ThrowMogrifyException(OptionError,"MissingArgument",option);
4732 if (IsGeometry(argv[i]) == MagickFalse)
4733 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4736 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4737 (LocaleCompare("gaussian",option+1) == 0))
4740 if (i == (ssize_t) argc)
4741 ThrowMogrifyException(OptionError,"MissingArgument",option);
4742 if (IsGeometry(argv[i]) == MagickFalse)
4743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4746 if (LocaleCompare("geometry",option+1) == 0)
4751 if (i == (ssize_t) argc)
4752 ThrowMogrifyException(OptionError,"MissingArgument",option);
4753 if (IsGeometry(argv[i]) == MagickFalse)
4754 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757 if (LocaleCompare("gravity",option+1) == 0)
4765 if (i == (ssize_t) argc)
4766 ThrowMogrifyException(OptionError,"MissingArgument",option);
4767 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4769 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4773 if (LocaleCompare("green-primary",option+1) == 0)
4778 if (i == (ssize_t) argc)
4779 ThrowMogrifyException(OptionError,"MissingArgument",option);
4780 if (IsGeometry(argv[i]) == MagickFalse)
4781 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4784 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4788 if (LocaleCompare("hald-clut",option+1) == 0)
4790 if ((LocaleCompare("help",option+1) == 0) ||
4791 (LocaleCompare("-help",option+1) == 0))
4792 return(MogrifyUsage());
4793 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4797 if (LocaleCompare("identify",option+1) == 0)
4799 if (LocaleCompare("idft",option+1) == 0)
4801 if (LocaleCompare("implode",option+1) == 0)
4806 if (i == (ssize_t) argc)
4807 ThrowMogrifyException(OptionError,"MissingArgument",option);
4808 if (IsGeometry(argv[i]) == MagickFalse)
4809 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4812 if (LocaleCompare("intent",option+1) == 0)
4820 if (i == (ssize_t) (argc-1))
4821 ThrowMogrifyException(OptionError,"MissingArgument",option);
4822 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4824 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4828 if (LocaleCompare("interlace",option+1) == 0)
4836 if (i == (ssize_t) argc)
4837 ThrowMogrifyException(OptionError,"MissingArgument",option);
4838 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4841 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4845 if (LocaleCompare("interline-spacing",option+1) == 0)
4850 if (i == (ssize_t) (argc-1))
4851 ThrowMogrifyException(OptionError,"MissingArgument",option);
4852 if (IsGeometry(argv[i]) == MagickFalse)
4853 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4856 if (LocaleCompare("interpolate",option+1) == 0)
4864 if (i == (ssize_t) argc)
4865 ThrowMogrifyException(OptionError,"MissingArgument",option);
4866 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4868 if (interpolate < 0)
4869 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4873 if (LocaleCompare("interword-spacing",option+1) == 0)
4878 if (i == (ssize_t) (argc-1))
4879 ThrowMogrifyException(OptionError,"MissingArgument",option);
4880 if (IsGeometry(argv[i]) == MagickFalse)
4881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4884 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4888 if (LocaleCompare("kerning",option+1) == 0)
4893 if (i == (ssize_t) (argc-1))
4894 ThrowMogrifyException(OptionError,"MissingArgument",option);
4895 if (IsGeometry(argv[i]) == MagickFalse)
4896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4899 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4903 if (LocaleCompare("label",option+1) == 0)
4908 if (i == (ssize_t) argc)
4909 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 if (LocaleCompare("lat",option+1) == 0)
4917 if (i == (ssize_t) argc)
4918 ThrowMogrifyException(OptionError,"MissingArgument",option);
4919 if (IsGeometry(argv[i]) == MagickFalse)
4920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4922 if (LocaleCompare("layers",option+1) == 0)
4930 if (i == (ssize_t) (argc-1))
4931 ThrowMogrifyException(OptionError,"MissingArgument",option);
4932 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4934 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4938 if (LocaleCompare("level",option+1) == 0)
4941 if (i == (ssize_t) argc)
4942 ThrowMogrifyException(OptionError,"MissingArgument",option);
4943 if (IsGeometry(argv[i]) == MagickFalse)
4944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4947 if (LocaleCompare("level-colors",option+1) == 0)
4950 if (i == (ssize_t) argc)
4951 ThrowMogrifyException(OptionError,"MissingArgument",option);
4954 if (LocaleCompare("limit",option+1) == 0)
4968 if (i == (ssize_t) argc)
4969 ThrowMogrifyException(OptionError,"MissingArgument",option);
4970 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4973 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4976 if (i == (ssize_t) argc)
4977 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 value=StringToDouble(argv[i],&p);
4980 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4984 if (LocaleCompare("liquid-rescale",option+1) == 0)
4987 if (i == (ssize_t) argc)
4988 ThrowMogrifyException(OptionError,"MissingArgument",option);
4989 if (IsGeometry(argv[i]) == MagickFalse)
4990 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4993 if (LocaleCompare("list",option+1) == 0)
5001 if (i == (ssize_t) argc)
5002 ThrowMogrifyException(OptionError,"MissingArgument",option);
5003 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5005 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5006 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5008 return(status != 0 ? MagickFalse : MagickTrue);
5010 if (LocaleCompare("log",option+1) == 0)
5015 if ((i == (ssize_t) argc) ||
5016 (strchr(argv[i],'%') == (char *) NULL))
5017 ThrowMogrifyException(OptionError,"MissingArgument",option);
5020 if (LocaleCompare("loop",option+1) == 0)
5025 if (i == (ssize_t) argc)
5026 ThrowMogrifyException(OptionError,"MissingArgument",option);
5027 if (IsGeometry(argv[i]) == MagickFalse)
5028 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5031 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5035 if (LocaleCompare("map",option+1) == 0)
5037 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5041 if (i == (ssize_t) argc)
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5045 if (LocaleCompare("mask",option+1) == 0)
5050 if (i == (ssize_t) argc)
5051 ThrowMogrifyException(OptionError,"MissingArgument",option);
5054 if (LocaleCompare("matte",option+1) == 0)
5056 if (LocaleCompare("mattecolor",option+1) == 0)
5061 if (i == (ssize_t) argc)
5062 ThrowMogrifyException(OptionError,"MissingArgument",option);
5065 if (LocaleCompare("maximum",option+1) == 0)
5067 if (LocaleCompare("minimum",option+1) == 0)
5069 if (LocaleCompare("modulate",option+1) == 0)
5074 if (i == (ssize_t) argc)
5075 ThrowMogrifyException(OptionError,"MissingArgument",option);
5076 if (IsGeometry(argv[i]) == MagickFalse)
5077 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5080 if (LocaleCompare("median",option+1) == 0)
5085 if (i == (ssize_t) argc)
5086 ThrowMogrifyException(OptionError,"MissingArgument",option);
5087 if (IsGeometry(argv[i]) == MagickFalse)
5088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5091 if (LocaleCompare("mode",option+1) == 0)
5096 if (i == (ssize_t) argc)
5097 ThrowMogrifyException(OptionError,"MissingArgument",option);
5098 if (IsGeometry(argv[i]) == MagickFalse)
5099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5102 if (LocaleCompare("monitor",option+1) == 0)
5104 if (LocaleCompare("monochrome",option+1) == 0)
5106 if (LocaleCompare("morph",option+1) == 0)
5111 if (i == (ssize_t) (argc-1))
5112 ThrowMogrifyException(OptionError,"MissingArgument",option);
5113 if (IsGeometry(argv[i]) == MagickFalse)
5114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5117 if (LocaleCompare("morphology",option+1) == 0)
5120 token[MaxTextExtent];
5129 if (i == (ssize_t) argc)
5130 ThrowMogrifyException(OptionError,"MissingArgument",option);
5131 GetMagickToken(argv[i],NULL,token);
5132 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5134 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5137 if (i == (ssize_t) (argc-1))
5138 ThrowMogrifyException(OptionError,"MissingArgument",option);
5139 kernel_info=AcquireKernelInfo(argv[i]);
5140 if (kernel_info == (KernelInfo *) NULL)
5141 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5142 kernel_info=DestroyKernelInfo(kernel_info);
5145 if (LocaleCompare("mosaic",option+1) == 0)
5147 if (LocaleCompare("motion-blur",option+1) == 0)
5152 if (i == (ssize_t) argc)
5153 ThrowMogrifyException(OptionError,"MissingArgument",option);
5154 if (IsGeometry(argv[i]) == MagickFalse)
5155 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5158 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5162 if (LocaleCompare("negate",option+1) == 0)
5164 if (LocaleCompare("noise",option+1) == 0)
5167 if (i == (ssize_t) argc)
5168 ThrowMogrifyException(OptionError,"MissingArgument",option);
5174 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5176 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5180 if (IsGeometry(argv[i]) == MagickFalse)
5181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5184 if (LocaleCompare("noop",option+1) == 0)
5186 if (LocaleCompare("normalize",option+1) == 0)
5188 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5192 if (LocaleCompare("opaque",option+1) == 0)
5195 if (i == (ssize_t) argc)
5196 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 if (LocaleCompare("ordered-dither",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,"MissingArgument",option);
5208 if (LocaleCompare("orient",option+1) == 0)
5213 orientation=UndefinedOrientation;
5217 if (i == (ssize_t) (argc-1))
5218 ThrowMogrifyException(OptionError,"MissingArgument",option);
5219 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5221 if (orientation < 0)
5222 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5226 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5230 if (LocaleCompare("page",option+1) == 0)
5235 if (i == (ssize_t) argc)
5236 ThrowMogrifyException(OptionError,"MissingArgument",option);
5239 if (LocaleCompare("paint",option+1) == 0)
5244 if (i == (ssize_t) argc)
5245 ThrowMogrifyException(OptionError,"MissingArgument",option);
5246 if (IsGeometry(argv[i]) == MagickFalse)
5247 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5250 if (LocaleCompare("path",option+1) == 0)
5252 (void) CloneString(&path,(char *) NULL);
5256 if (i == (ssize_t) argc)
5257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5258 (void) CloneString(&path,argv[i]);
5261 if (LocaleCompare("pointsize",option+1) == 0)
5266 if (i == (ssize_t) argc)
5267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 if (IsGeometry(argv[i]) == MagickFalse)
5269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5272 if (LocaleCompare("polaroid",option+1) == 0)
5277 if (i == (ssize_t) argc)
5278 ThrowMogrifyException(OptionError,"MissingArgument",option);
5279 if (IsGeometry(argv[i]) == MagickFalse)
5280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5283 if (LocaleCompare("posterize",option+1) == 0)
5288 if (i == (ssize_t) argc)
5289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5290 if (IsGeometry(argv[i]) == MagickFalse)
5291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5294 if (LocaleCompare("precision",option+1) == 0)
5299 if (i == (ssize_t) argc)
5300 ThrowMogrifyException(OptionError,"MissingArgument",option);
5301 if (IsGeometry(argv[i]) == MagickFalse)
5302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5305 if (LocaleCompare("print",option+1) == 0)
5310 if (i == (ssize_t) argc)
5311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5314 if (LocaleCompare("process",option+1) == 0)
5319 if (i == (ssize_t) (argc-1))
5320 ThrowMogrifyException(OptionError,"MissingArgument",option);
5323 if (LocaleCompare("profile",option+1) == 0)
5326 if (i == (ssize_t) argc)
5327 ThrowMogrifyException(OptionError,"MissingArgument",option);
5330 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5334 if (LocaleCompare("quality",option+1) == 0)
5339 if (i == (ssize_t) argc)
5340 ThrowMogrifyException(OptionError,"MissingArgument",option);
5341 if (IsGeometry(argv[i]) == MagickFalse)
5342 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5345 if (LocaleCompare("quantize",option+1) == 0)
5353 if (i == (ssize_t) (argc-1))
5354 ThrowMogrifyException(OptionError,"MissingArgument",option);
5355 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5358 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5362 if (LocaleCompare("quiet",option+1) == 0)
5364 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5368 if (LocaleCompare("radial-blur",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("raise",option+1) == 0)
5380 if (i == (ssize_t) argc)
5381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5382 if (IsGeometry(argv[i]) == MagickFalse)
5383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5386 if (LocaleCompare("random-threshold",option+1) == 0)
5391 if (i == (ssize_t) argc)
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5397 if (LocaleCompare("red-primary",option+1) == 0)
5402 if (i == (ssize_t) argc)
5403 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 if (IsGeometry(argv[i]) == MagickFalse)
5405 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5407 if (LocaleCompare("regard-warnings",option+1) == 0)
5409 if (LocaleCompare("region",option+1) == 0)
5414 if (i == (ssize_t) argc)
5415 ThrowMogrifyException(OptionError,"MissingArgument",option);
5416 if (IsGeometry(argv[i]) == MagickFalse)
5417 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5420 if (LocaleCompare("remap",option+1) == 0)
5425 if (i == (ssize_t) (argc-1))
5426 ThrowMogrifyException(OptionError,"MissingArgument",option);
5429 if (LocaleCompare("render",option+1) == 0)
5431 if (LocaleCompare("repage",option+1) == 0)
5436 if (i == (ssize_t) argc)
5437 ThrowMogrifyException(OptionError,"MissingArgument",option);
5438 if (IsGeometry(argv[i]) == MagickFalse)
5439 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5442 if (LocaleCompare("resample",option+1) == 0)
5447 if (i == (ssize_t) argc)
5448 ThrowMogrifyException(OptionError,"MissingArgument",option);
5449 if (IsGeometry(argv[i]) == MagickFalse)
5450 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5453 if (LocaleCompare("resize",option+1) == 0)
5458 if (i == (ssize_t) argc)
5459 ThrowMogrifyException(OptionError,"MissingArgument",option);
5460 if (IsGeometry(argv[i]) == MagickFalse)
5461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5464 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5466 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5469 if (LocaleCompare("reverse",option+1) == 0)
5471 if (LocaleCompare("roll",option+1) == 0)
5476 if (i == (ssize_t) argc)
5477 ThrowMogrifyException(OptionError,"MissingArgument",option);
5478 if (IsGeometry(argv[i]) == MagickFalse)
5479 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5482 if (LocaleCompare("rotate",option+1) == 0)
5485 if (i == (ssize_t) argc)
5486 ThrowMogrifyException(OptionError,"MissingArgument",option);
5487 if (IsGeometry(argv[i]) == MagickFalse)
5488 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5491 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5495 if (LocaleCompare("sample",option+1) == 0)
5500 if (i == (ssize_t) argc)
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5502 if (IsGeometry(argv[i]) == MagickFalse)
5503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5506 if (LocaleCompare("sampling-factor",option+1) == 0)
5511 if (i == (ssize_t) argc)
5512 ThrowMogrifyException(OptionError,"MissingArgument",option);
5513 if (IsGeometry(argv[i]) == MagickFalse)
5514 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5517 if (LocaleCompare("scale",option+1) == 0)
5522 if (i == (ssize_t) argc)
5523 ThrowMogrifyException(OptionError,"MissingArgument",option);
5524 if (IsGeometry(argv[i]) == MagickFalse)
5525 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5528 if (LocaleCompare("scene",option+1) == 0)
5533 if (i == (ssize_t) argc)
5534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5539 if (LocaleCompare("seed",option+1) == 0)
5544 if (i == (ssize_t) argc)
5545 ThrowMogrifyException(OptionError,"MissingArgument",option);
5546 if (IsGeometry(argv[i]) == MagickFalse)
5547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5550 if (LocaleCompare("segment",option+1) == 0)
5555 if (i == (ssize_t) argc)
5556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 if (IsGeometry(argv[i]) == MagickFalse)
5558 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5561 if (LocaleCompare("selective-blur",option+1) == 0)
5564 if (i == (ssize_t) argc)
5565 ThrowMogrifyException(OptionError,"MissingArgument",option);
5566 if (IsGeometry(argv[i]) == MagickFalse)
5567 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5570 if (LocaleCompare("separate",option+1) == 0)
5572 if (LocaleCompare("sepia-tone",option+1) == 0)
5577 if (i == (ssize_t) argc)
5578 ThrowMogrifyException(OptionError,"MissingArgument",option);
5579 if (IsGeometry(argv[i]) == MagickFalse)
5580 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5583 if (LocaleCompare("set",option+1) == 0)
5586 if (i == (ssize_t) argc)
5587 ThrowMogrifyException(OptionError,"MissingArgument",option);
5591 if (i == (ssize_t) argc)
5592 ThrowMogrifyException(OptionError,"MissingArgument",option);
5595 if (LocaleCompare("shade",option+1) == 0)
5598 if (i == (ssize_t) argc)
5599 ThrowMogrifyException(OptionError,"MissingArgument",option);
5600 if (IsGeometry(argv[i]) == MagickFalse)
5601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5604 if (LocaleCompare("shadow",option+1) == 0)
5609 if (i == (ssize_t) argc)
5610 ThrowMogrifyException(OptionError,"MissingArgument",option);
5611 if (IsGeometry(argv[i]) == MagickFalse)
5612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5615 if (LocaleCompare("sharpen",option+1) == 0)
5618 if (i == (ssize_t) argc)
5619 ThrowMogrifyException(OptionError,"MissingArgument",option);
5620 if (IsGeometry(argv[i]) == MagickFalse)
5621 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5624 if (LocaleCompare("shave",option+1) == 0)
5629 if (i == (ssize_t) argc)
5630 ThrowMogrifyException(OptionError,"MissingArgument",option);
5631 if (IsGeometry(argv[i]) == MagickFalse)
5632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5635 if (LocaleCompare("shear",option+1) == 0)
5638 if (i == (ssize_t) argc)
5639 ThrowMogrifyException(OptionError,"MissingArgument",option);
5640 if (IsGeometry(argv[i]) == MagickFalse)
5641 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5647 if (i == (ssize_t) (argc-1))
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 if (LocaleCompare("size",option+1) == 0)
5658 if (i == (ssize_t) argc)
5659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 if (IsGeometry(argv[i]) == MagickFalse)
5661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5664 if (LocaleCompare("sketch",option+1) == 0)
5669 if (i == (ssize_t) argc)
5670 ThrowMogrifyException(OptionError,"MissingArgument",option);
5671 if (IsGeometry(argv[i]) == MagickFalse)
5672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5675 if (LocaleCompare("smush",option+1) == 0)
5678 if (i == (ssize_t) argc)
5679 ThrowMogrifyException(OptionError,"MissingArgument",option);
5680 if (IsGeometry(argv[i]) == MagickFalse)
5681 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5685 if (LocaleCompare("solarize",option+1) == 0)
5690 if (i == (ssize_t) argc)
5691 ThrowMogrifyException(OptionError,"MissingArgument",option);
5692 if (IsGeometry(argv[i]) == MagickFalse)
5693 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5696 if (LocaleCompare("sparse-color",option+1) == 0)
5702 if (i == (ssize_t) argc)
5703 ThrowMogrifyException(OptionError,"MissingArgument",option);
5704 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5706 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5709 if (i == (ssize_t) (argc-1))
5710 ThrowMogrifyException(OptionError,"MissingArgument",option);
5713 if (LocaleCompare("spread",option+1) == 0)
5718 if (i == (ssize_t) argc)
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 if (IsGeometry(argv[i]) == MagickFalse)
5721 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5724 if (LocaleCompare("statistic",option+1) == 0)
5732 if (i == (ssize_t) argc)
5733 ThrowMogrifyException(OptionError,"MissingArgument",option);
5734 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5736 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5739 if (i == (ssize_t) (argc-1))
5740 ThrowMogrifyException(OptionError,"MissingArgument",option);
5741 if (IsGeometry(argv[i]) == MagickFalse)
5742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5745 if (LocaleCompare("stretch",option+1) == 0)
5753 if (i == (ssize_t) (argc-1))
5754 ThrowMogrifyException(OptionError,"MissingArgument",option);
5755 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5757 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5761 if (LocaleCompare("strip",option+1) == 0)
5763 if (LocaleCompare("stroke",option+1) == 0)
5768 if (i == (ssize_t) argc)
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5772 if (LocaleCompare("strokewidth",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 if (LocaleCompare("style",option+1) == 0)
5791 if (i == (ssize_t) (argc-1))
5792 ThrowMogrifyException(OptionError,"MissingArgument",option);
5793 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5795 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5799 if (LocaleCompare("swap",option+1) == 0)
5804 if (i == (ssize_t) (argc-1))
5805 ThrowMogrifyException(OptionError,"MissingArgument",option);
5806 if (IsGeometry(argv[i]) == MagickFalse)
5807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5810 if (LocaleCompare("swirl",option+1) == 0)
5815 if (i == (ssize_t) argc)
5816 ThrowMogrifyException(OptionError,"MissingArgument",option);
5817 if (IsGeometry(argv[i]) == MagickFalse)
5818 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5821 if (LocaleCompare("synchronize",option+1) == 0)
5823 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5827 if (LocaleCompare("taint",option+1) == 0)
5829 if (LocaleCompare("texture",option+1) == 0)
5834 if (i == (ssize_t) argc)
5835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5838 if (LocaleCompare("tile",option+1) == 0)
5843 if (i == (ssize_t) (argc-1))
5844 ThrowMogrifyException(OptionError,"MissingArgument",option);
5847 if (LocaleCompare("tile-offset",option+1) == 0)
5852 if (i == (ssize_t) argc)
5853 ThrowMogrifyException(OptionError,"MissingArgument",option);
5854 if (IsGeometry(argv[i]) == MagickFalse)
5855 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5858 if (LocaleCompare("tint",option+1) == 0)
5863 if (i == (ssize_t) (argc-1))
5864 ThrowMogrifyException(OptionError,"MissingArgument",option);
5865 if (IsGeometry(argv[i]) == MagickFalse)
5866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5869 if (LocaleCompare("transform",option+1) == 0)
5871 if (LocaleCompare("transpose",option+1) == 0)
5873 if (LocaleCompare("transverse",option+1) == 0)
5875 if (LocaleCompare("threshold",option+1) == 0)
5880 if (i == (ssize_t) argc)
5881 ThrowMogrifyException(OptionError,"MissingArgument",option);
5882 if (IsGeometry(argv[i]) == MagickFalse)
5883 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5886 if (LocaleCompare("thumbnail",option+1) == 0)
5891 if (i == (ssize_t) argc)
5892 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 if (IsGeometry(argv[i]) == MagickFalse)
5894 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5897 if (LocaleCompare("transparent",option+1) == 0)
5900 if (i == (ssize_t) argc)
5901 ThrowMogrifyException(OptionError,"MissingArgument",option);
5904 if (LocaleCompare("transparent-color",option+1) == 0)
5909 if (i == (ssize_t) (argc-1))
5910 ThrowMogrifyException(OptionError,"MissingArgument",option);
5913 if (LocaleCompare("treedepth",option+1) == 0)
5918 if (i == (ssize_t) argc)
5919 ThrowMogrifyException(OptionError,"MissingArgument",option);
5920 if (IsGeometry(argv[i]) == MagickFalse)
5921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5924 if (LocaleCompare("trim",option+1) == 0)
5926 if (LocaleCompare("type",option+1) == 0)
5934 if (i == (ssize_t) argc)
5935 ThrowMogrifyException(OptionError,"MissingArgument",option);
5936 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5938 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5942 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5946 if (LocaleCompare("undercolor",option+1) == 0)
5951 if (i == (ssize_t) argc)
5952 ThrowMogrifyException(OptionError,"MissingArgument",option);
5955 if (LocaleCompare("unique-colors",option+1) == 0)
5957 if (LocaleCompare("units",option+1) == 0)
5965 if (i == (ssize_t) argc)
5966 ThrowMogrifyException(OptionError,"MissingArgument",option);
5967 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5970 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5974 if (LocaleCompare("unsharp",option+1) == 0)
5977 if (i == (ssize_t) argc)
5978 ThrowMogrifyException(OptionError,"MissingArgument",option);
5979 if (IsGeometry(argv[i]) == MagickFalse)
5980 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5983 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5987 if (LocaleCompare("verbose",option+1) == 0)
5989 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5992 if ((LocaleCompare("version",option+1) == 0) ||
5993 (LocaleCompare("-version",option+1) == 0))
5995 (void) FormatLocaleFile(stdout,"Version: %s\n",
5996 GetMagickVersion((size_t *) NULL));
5997 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5998 GetMagickCopyright());
5999 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
6000 GetMagickFeatures());
6003 if (LocaleCompare("view",option+1) == 0)
6008 if (i == (ssize_t) argc)
6009 ThrowMogrifyException(OptionError,"MissingArgument",option);
6012 if (LocaleCompare("vignette",option+1) == 0)
6017 if (i == (ssize_t) argc)
6018 ThrowMogrifyException(OptionError,"MissingArgument",option);
6019 if (IsGeometry(argv[i]) == MagickFalse)
6020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6023 if (LocaleCompare("virtual-pixel",option+1) == 0)
6031 if (i == (ssize_t) argc)
6032 ThrowMogrifyException(OptionError,"MissingArgument",option);
6033 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6036 ThrowMogrifyException(OptionError,
6037 "UnrecognizedVirtualPixelMethod",argv[i]);
6040 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6044 if (LocaleCompare("wave",option+1) == 0)
6047 if (i == (ssize_t) argc)
6048 ThrowMogrifyException(OptionError,"MissingArgument",option);
6049 if (IsGeometry(argv[i]) == MagickFalse)
6050 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 if (LocaleCompare("weight",option+1) == 0)
6058 if (i == (ssize_t) (argc-1))
6059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6062 if (LocaleCompare("white-point",option+1) == 0)
6067 if (i == (ssize_t) argc)
6068 ThrowMogrifyException(OptionError,"MissingArgument",option);
6069 if (IsGeometry(argv[i]) == MagickFalse)
6070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6073 if (LocaleCompare("white-threshold",option+1) == 0)
6078 if (i == (ssize_t) argc)
6079 ThrowMogrifyException(OptionError,"MissingArgument",option);
6080 if (IsGeometry(argv[i]) == MagickFalse)
6081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6084 if (LocaleCompare("write",option+1) == 0)
6087 if (i == (ssize_t) (argc-1))
6088 ThrowMogrifyException(OptionError,"MissingArgument",option);
6091 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6096 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6098 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6099 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6100 if (fire != MagickFalse)
6101 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6104 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6105 if (i != (ssize_t) argc)
6106 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6108 return(status != 0 ? MagickTrue : MagickFalse);
6112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6116 + M o g r i f y I m a g e I n f o %
6120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6122 % MogrifyImageInfo() applies image processing settings to the image as
6123 % prescribed by command line options.
6125 % The format of the MogrifyImageInfo method is:
6127 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6128 % const char **argv,ExceptionInfo *exception)
6130 % A description of each parameter follows:
6132 % o image_info: the image info..
6134 % o argc: Specifies a pointer to an integer describing the number of
6135 % elements in the argument vector.
6137 % o argv: Specifies a pointer to a text array containing the command line
6140 % o exception: return any errors or warnings in this structure.
6143 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6144 const int argc,const char **argv,ExceptionInfo *exception)
6159 Initialize method variables.
6161 assert(image_info != (ImageInfo *) NULL);
6162 assert(image_info->signature == MagickSignature);
6163 if (image_info->debug != MagickFalse)
6164 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6165 image_info->filename);
6169 Set the image settings.
6171 for (i=0; i < (ssize_t) argc; i++)
6174 if (IsCommandOption(option) == MagickFalse)
6176 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6177 count=MagickMax(count,0L);
6178 if ((i+count) >= (ssize_t) argc)
6180 switch (*(option+1))
6184 if (LocaleCompare("adjoin",option+1) == 0)
6186 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6189 if (LocaleCompare("antialias",option+1) == 0)
6191 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6194 if (LocaleCompare("authenticate",option+1) == 0)
6197 (void) DeleteImageOption(image_info,option+1);
6199 (void) SetImageOption(image_info,option+1,argv[i+1]);
6206 if (LocaleCompare("background",option+1) == 0)
6210 (void) DeleteImageOption(image_info,option+1);
6211 (void) QueryColorCompliance(MogrifyBackgroundColor,
6212 AllCompliance,&image_info->background_color,exception);
6215 (void) SetImageOption(image_info,option+1,argv[i+1]);
6216 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6217 &image_info->background_color,exception);
6220 if (LocaleCompare("bias",option+1) == 0)
6224 (void) SetImageOption(image_info,option+1,"0.0");
6227 (void) SetImageOption(image_info,option+1,argv[i+1]);
6230 if (LocaleCompare("black-point-compensation",option+1) == 0)
6234 (void) SetImageOption(image_info,option+1,"false");
6237 (void) SetImageOption(image_info,option+1,"true");
6240 if (LocaleCompare("blue-primary",option+1) == 0)
6244 (void) SetImageOption(image_info,option+1,"0.0");
6247 (void) SetImageOption(image_info,option+1,argv[i+1]);
6250 if (LocaleCompare("bordercolor",option+1) == 0)
6254 (void) DeleteImageOption(image_info,option+1);
6255 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6256 &image_info->border_color,exception);
6259 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6260 &image_info->border_color,exception);
6261 (void) SetImageOption(image_info,option+1,argv[i+1]);
6264 if (LocaleCompare("box",option+1) == 0)
6268 (void) SetImageOption(image_info,"undercolor","none");
6271 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6278 if (LocaleCompare("cache",option+1) == 0)
6283 limit=MagickResourceInfinity;
6284 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6285 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6287 (void) SetMagickResourceLimit(MemoryResource,limit);
6288 (void) SetMagickResourceLimit(MapResource,2*limit);
6291 if (LocaleCompare("caption",option+1) == 0)
6295 (void) DeleteImageOption(image_info,option+1);
6298 (void) SetImageOption(image_info,option+1,argv[i+1]);
6301 if (LocaleCompare("channel",option+1) == 0)
6305 image_info->channel=DefaultChannels;
6306 (void) SetImageOption(image_info,option+1,"default");
6309 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6310 (void) SetImageOption(image_info,option+1,argv[i+1]);
6313 if (LocaleCompare("colorspace",option+1) == 0)
6317 image_info->colorspace=UndefinedColorspace;
6318 (void) SetImageOption(image_info,option+1,"undefined");
6321 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6322 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6323 (void) SetImageOption(image_info,option+1,argv[i+1]);
6326 if (LocaleCompare("comment",option+1) == 0)
6330 (void) DeleteImageOption(image_info,option+1);
6333 (void) SetImageOption(image_info,option+1,argv[i+1]);
6336 if (LocaleCompare("compose",option+1) == 0)
6340 (void) SetImageOption(image_info,option+1,"undefined");
6343 (void) SetImageOption(image_info,option+1,argv[i+1]);
6346 if (LocaleCompare("compress",option+1) == 0)
6350 image_info->compression=UndefinedCompression;
6351 (void) SetImageOption(image_info,option+1,"undefined");
6354 image_info->compression=(CompressionType) ParseCommandOption(
6355 MagickCompressOptions,MagickFalse,argv[i+1]);
6356 (void) SetImageOption(image_info,option+1,argv[i+1]);
6363 if (LocaleCompare("debug",option+1) == 0)
6366 (void) SetLogEventMask("none");
6368 (void) SetLogEventMask(argv[i+1]);
6369 image_info->debug=IsEventLogging();
6372 if (LocaleCompare("define",option+1) == 0)
6376 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6377 (void) DeleteImageRegistry(argv[i+1]+9);
6379 (void) DeleteImageOption(image_info,argv[i+1]);
6382 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6384 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6388 (void) DefineImageOption(image_info,argv[i+1]);
6391 if (LocaleCompare("delay",option+1) == 0)
6395 (void) SetImageOption(image_info,option+1,"0");
6398 (void) SetImageOption(image_info,option+1,argv[i+1]);
6401 if (LocaleCompare("density",option+1) == 0)
6408 if (image_info->density != (char *) NULL)
6409 image_info->density=DestroyString(image_info->density);
6410 (void) SetImageOption(image_info,option+1,"72");
6413 (void) CloneString(&image_info->density,argv[i+1]);
6414 (void) SetImageOption(image_info,option+1,argv[i+1]);
6417 if (LocaleCompare("depth",option+1) == 0)
6421 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6424 image_info->depth=StringToUnsignedLong(argv[i+1]);
6427 if (LocaleCompare("direction",option+1) == 0)
6431 (void) SetImageOption(image_info,option+1,"undefined");
6434 (void) SetImageOption(image_info,option+1,argv[i+1]);
6437 if (LocaleCompare("display",option+1) == 0)
6441 if (image_info->server_name != (char *) NULL)
6442 image_info->server_name=DestroyString(
6443 image_info->server_name);
6446 (void) CloneString(&image_info->server_name,argv[i+1]);
6449 if (LocaleCompare("dispose",option+1) == 0)
6453 (void) SetImageOption(image_info,option+1,"undefined");
6456 (void) SetImageOption(image_info,option+1,argv[i+1]);
6459 if (LocaleCompare("dither",option+1) == 0)
6463 image_info->dither=MagickFalse;
6464 (void) SetImageOption(image_info,option+1,"none");
6467 (void) SetImageOption(image_info,option+1,argv[i+1]);
6468 image_info->dither=MagickTrue;
6475 if (LocaleCompare("encoding",option+1) == 0)
6479 (void) SetImageOption(image_info,option+1,"undefined");
6482 (void) SetImageOption(image_info,option+1,argv[i+1]);
6485 if (LocaleCompare("endian",option+1) == 0)
6489 image_info->endian=UndefinedEndian;
6490 (void) SetImageOption(image_info,option+1,"undefined");
6493 image_info->endian=(EndianType) ParseCommandOption(
6494 MagickEndianOptions,MagickFalse,argv[i+1]);
6495 (void) SetImageOption(image_info,option+1,argv[i+1]);
6498 if (LocaleCompare("extract",option+1) == 0)
6501 Set image extract geometry.
6505 if (image_info->extract != (char *) NULL)
6506 image_info->extract=DestroyString(image_info->extract);
6509 (void) CloneString(&image_info->extract,argv[i+1]);
6516 if (LocaleCompare("fill",option+1) == 0)
6520 (void) SetImageOption(image_info,option+1,"none");
6523 (void) SetImageOption(image_info,option+1,argv[i+1]);
6526 if (LocaleCompare("filter",option+1) == 0)
6530 (void) SetImageOption(image_info,option+1,"undefined");
6533 (void) SetImageOption(image_info,option+1,argv[i+1]);
6536 if (LocaleCompare("font",option+1) == 0)
6540 if (image_info->font != (char *) NULL)
6541 image_info->font=DestroyString(image_info->font);
6544 (void) CloneString(&image_info->font,argv[i+1]);
6547 if (LocaleCompare("format",option+1) == 0)
6552 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6553 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6554 image_info->ping=MagickFalse;
6555 (void) SetImageOption(image_info,option+1,argv[i+1]);
6558 if (LocaleCompare("fuzz",option+1) == 0)
6562 image_info->fuzz=0.0;
6563 (void) SetImageOption(image_info,option+1,"0");
6566 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6568 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("gravity",option+1) == 0)
6579 (void) SetImageOption(image_info,option+1,"undefined");
6582 (void) SetImageOption(image_info,option+1,argv[i+1]);
6585 if (LocaleCompare("green-primary",option+1) == 0)
6589 (void) SetImageOption(image_info,option+1,"0.0");
6592 (void) SetImageOption(image_info,option+1,argv[i+1]);
6599 if (LocaleCompare("intent",option+1) == 0)
6603 (void) SetImageOption(image_info,option+1,"undefined");
6606 (void) SetImageOption(image_info,option+1,argv[i+1]);
6609 if (LocaleCompare("interlace",option+1) == 0)
6613 image_info->interlace=UndefinedInterlace;
6614 (void) SetImageOption(image_info,option+1,"undefined");
6617 image_info->interlace=(InterlaceType) ParseCommandOption(
6618 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6622 if (LocaleCompare("interline-spacing",option+1) == 0)
6626 (void) SetImageOption(image_info,option+1,"undefined");
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6632 if (LocaleCompare("interpolate",option+1) == 0)
6636 (void) SetImageOption(image_info,option+1,"undefined");
6639 (void) SetImageOption(image_info,option+1,argv[i+1]);
6642 if (LocaleCompare("interword-spacing",option+1) == 0)
6646 (void) SetImageOption(image_info,option+1,"undefined");
6649 (void) SetImageOption(image_info,option+1,argv[i+1]);
6656 if (LocaleCompare("kerning",option+1) == 0)
6660 (void) SetImageOption(image_info,option+1,"undefined");
6663 (void) SetImageOption(image_info,option+1,argv[i+1]);
6670 if (LocaleCompare("label",option+1) == 0)
6674 (void) DeleteImageOption(image_info,option+1);
6677 (void) SetImageOption(image_info,option+1,argv[i+1]);
6680 if (LocaleCompare("limit",option+1) == 0)
6690 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6691 MagickFalse,argv[i+1]);
6692 limit=MagickResourceInfinity;
6693 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6694 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6695 (void) SetMagickResourceLimit(type,limit);
6698 if (LocaleCompare("list",option+1) == 0)
6704 Display configuration list.
6706 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6709 case MagickCoderOptions:
6711 (void) ListCoderInfo((FILE *) NULL,exception);
6714 case MagickColorOptions:
6716 (void) ListColorInfo((FILE *) NULL,exception);
6719 case MagickConfigureOptions:
6721 (void) ListConfigureInfo((FILE *) NULL,exception);
6724 case MagickDelegateOptions:
6726 (void) ListDelegateInfo((FILE *) NULL,exception);
6729 case MagickFontOptions:
6731 (void) ListTypeInfo((FILE *) NULL,exception);
6734 case MagickFormatOptions:
6736 (void) ListMagickInfo((FILE *) NULL,exception);
6739 case MagickLocaleOptions:
6741 (void) ListLocaleInfo((FILE *) NULL,exception);
6744 case MagickLogOptions:
6746 (void) ListLogInfo((FILE *) NULL,exception);
6749 case MagickMagicOptions:
6751 (void) ListMagicInfo((FILE *) NULL,exception);
6754 case MagickMimeOptions:
6756 (void) ListMimeInfo((FILE *) NULL,exception);
6759 case MagickModuleOptions:
6761 (void) ListModuleInfo((FILE *) NULL,exception);
6764 case MagickPolicyOptions:
6766 (void) ListPolicyInfo((FILE *) NULL,exception);
6769 case MagickResourceOptions:
6771 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6774 case MagickThresholdOptions:
6776 (void) ListThresholdMaps((FILE *) NULL,exception);
6781 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6788 if (LocaleCompare("log",option+1) == 0)
6792 (void) SetLogFormat(argv[i+1]);
6795 if (LocaleCompare("loop",option+1) == 0)
6799 (void) SetImageOption(image_info,option+1,"0");
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
6809 if (LocaleCompare("matte",option+1) == 0)
6813 (void) SetImageOption(image_info,option+1,"false");
6816 (void) SetImageOption(image_info,option+1,"true");
6819 if (LocaleCompare("mattecolor",option+1) == 0)
6823 (void) SetImageOption(image_info,option+1,argv[i+1]);
6824 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6825 &image_info->matte_color,exception);
6828 (void) SetImageOption(image_info,option+1,argv[i+1]);
6829 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6830 &image_info->matte_color,exception);
6833 if (LocaleCompare("monitor",option+1) == 0)
6835 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6839 if (LocaleCompare("monochrome",option+1) == 0)
6841 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6848 if (LocaleCompare("orient",option+1) == 0)
6852 image_info->orientation=UndefinedOrientation;
6853 (void) SetImageOption(image_info,option+1,"undefined");
6856 image_info->orientation=(OrientationType) ParseCommandOption(
6857 MagickOrientationOptions,MagickFalse,argv[i+1]);
6858 (void) SetImageOption(image_info,option+1,argv[i+1]);
6864 if (LocaleCompare("page",option+1) == 0)
6868 page[MaxTextExtent];
6881 (void) DeleteImageOption(image_info,option+1);
6882 (void) CloneString(&image_info->page,(char *) NULL);
6885 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6886 image_option=GetImageOption(image_info,"page");
6887 if (image_option != (const char *) NULL)
6888 flags=ParseAbsoluteGeometry(image_option,&geometry);
6889 canonical_page=GetPageGeometry(argv[i+1]);
6890 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6891 canonical_page=DestroyString(canonical_page);
6892 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6893 (unsigned long) geometry.width,(unsigned long) geometry.height);
6894 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6895 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6896 (unsigned long) geometry.width,(unsigned long) geometry.height,
6897 (long) geometry.x,(long) geometry.y);
6898 (void) SetImageOption(image_info,option+1,page);
6899 (void) CloneString(&image_info->page,page);
6902 if (LocaleCompare("ping",option+1) == 0)
6904 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6907 if (LocaleCompare("pointsize",option+1) == 0)
6910 geometry_info.rho=0.0;
6912 (void) ParseGeometry(argv[i+1],&geometry_info);
6913 image_info->pointsize=geometry_info.rho;
6916 if (LocaleCompare("precision",option+1) == 0)
6918 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6921 if (LocaleCompare("preview",option+1) == 0)
6928 image_info->preview_type=UndefinedPreview;
6931 image_info->preview_type=(PreviewType) ParseCommandOption(
6932 MagickPreviewOptions,MagickFalse,argv[i+1]);
6939 if (LocaleCompare("quality",option+1) == 0)
6942 Set image compression quality.
6946 image_info->quality=UndefinedCompressionQuality;
6947 (void) SetImageOption(image_info,option+1,"0");
6950 image_info->quality=StringToUnsignedLong(argv[i+1]);
6951 (void) SetImageOption(image_info,option+1,argv[i+1]);
6954 if (LocaleCompare("quiet",option+1) == 0)
6956 static WarningHandler
6957 warning_handler = (WarningHandler) NULL;
6962 Restore error or warning messages.
6964 warning_handler=SetWarningHandler(warning_handler);
6968 Suppress error or warning messages.
6970 warning_handler=SetWarningHandler((WarningHandler) NULL);
6977 if (LocaleCompare("red-primary",option+1) == 0)
6981 (void) SetImageOption(image_info,option+1,"0.0");
6984 (void) SetImageOption(image_info,option+1,argv[i+1]);
6991 if (LocaleCompare("sampling-factor",option+1) == 0)
6994 Set image sampling factor.
6998 if (image_info->sampling_factor != (char *) NULL)
6999 image_info->sampling_factor=DestroyString(
7000 image_info->sampling_factor);
7003 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7006 if (LocaleCompare("scene",option+1) == 0)
7013 image_info->scene=0;
7014 (void) SetImageOption(image_info,option+1,"0");
7017 image_info->scene=StringToUnsignedLong(argv[i+1]);
7018 (void) SetImageOption(image_info,option+1,argv[i+1]);
7021 if (LocaleCompare("seed",option+1) == 0)
7028 seed=(size_t) time((time_t *) NULL);
7029 SetRandomSecretKey(seed);
7032 seed=StringToUnsignedLong(argv[i+1]);
7033 SetRandomSecretKey(seed);
7036 if (LocaleCompare("size",option+1) == 0)
7040 if (image_info->size != (char *) NULL)
7041 image_info->size=DestroyString(image_info->size);
7044 (void) CloneString(&image_info->size,argv[i+1]);
7047 if (LocaleCompare("stroke",option+1) == 0)
7051 (void) SetImageOption(image_info,option+1,"none");
7054 (void) SetImageOption(image_info,option+1,argv[i+1]);
7057 if (LocaleCompare("strokewidth",option+1) == 0)
7061 (void) SetImageOption(image_info,option+1,"0");
7064 (void) SetImageOption(image_info,option+1,argv[i+1]);
7067 if (LocaleCompare("synchronize",option+1) == 0)
7071 image_info->synchronize=MagickFalse;
7074 image_info->synchronize=MagickTrue;
7081 if (LocaleCompare("taint",option+1) == 0)
7085 (void) SetImageOption(image_info,option+1,"false");
7088 (void) SetImageOption(image_info,option+1,"true");
7091 if (LocaleCompare("texture",option+1) == 0)
7095 if (image_info->texture != (char *) NULL)
7096 image_info->texture=DestroyString(image_info->texture);
7099 (void) CloneString(&image_info->texture,argv[i+1]);
7102 if (LocaleCompare("tile-offset",option+1) == 0)
7105 (void) SetImageOption(image_info,option+1,"0");
7107 (void) SetImageOption(image_info,option+1,argv[i+1]);
7110 if (LocaleCompare("transparent-color",option+1) == 0)
7114 (void) QueryColorCompliance("none",AllCompliance,
7115 &image_info->transparent_color,exception);
7116 (void) SetImageOption(image_info,option+1,"none");
7119 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7120 &image_info->transparent_color,exception);
7121 (void) SetImageOption(image_info,option+1,argv[i+1]);
7124 if (LocaleCompare("type",option+1) == 0)
7128 image_info->type=UndefinedType;
7129 (void) SetImageOption(image_info,option+1,"undefined");
7132 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7133 MagickFalse,argv[i+1]);
7134 (void) SetImageOption(image_info,option+1,argv[i+1]);
7141 if (LocaleCompare("undercolor",option+1) == 0)
7144 (void) DeleteImageOption(image_info,option+1);
7146 (void) SetImageOption(image_info,option+1,argv[i+1]);
7149 if (LocaleCompare("units",option+1) == 0)
7153 image_info->units=UndefinedResolution;
7154 (void) SetImageOption(image_info,option+1,"undefined");
7157 image_info->units=(ResolutionType) ParseCommandOption(
7158 MagickResolutionOptions,MagickFalse,argv[i+1]);
7159 (void) SetImageOption(image_info,option+1,argv[i+1]);
7166 if (LocaleCompare("verbose",option+1) == 0)
7170 image_info->verbose=MagickFalse;
7173 image_info->verbose=MagickTrue;
7174 image_info->ping=MagickFalse;
7177 if (LocaleCompare("view",option+1) == 0)
7181 if (image_info->view != (char *) NULL)
7182 image_info->view=DestroyString(image_info->view);
7185 (void) CloneString(&image_info->view,argv[i+1]);
7188 if (LocaleCompare("virtual-pixel",option+1) == 0)
7191 (void) SetImageOption(image_info,option+1,"undefined");
7193 (void) SetImageOption(image_info,option+1,argv[i+1]);
7200 if (LocaleCompare("white-point",option+1) == 0)
7203 (void) SetImageOption(image_info,option+1,"0.0");
7205 (void) SetImageOption(image_info,option+1,argv[i+1]);
7219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7223 + M o g r i f y I m a g e L i s t %
7227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7229 % MogrifyImageList() applies any command line options that might affect the
7230 % entire image list (e.g. -append, -coalesce, etc.).
7232 % The format of the MogrifyImage method is:
7234 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7235 % const char **argv,Image **images,ExceptionInfo *exception)
7237 % A description of each parameter follows:
7239 % o image_info: the image info..
7241 % o argc: Specifies a pointer to an integer describing the number of
7242 % elements in the argument vector.
7244 % o argv: Specifies a pointer to a text array containing the command line
7247 % o images: pointer to pointer of the first image in image list.
7249 % o exception: return any errors or warnings in this structure.
7252 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7253 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7264 PixelInterpolateMethod
7278 Apply options to the image list.
7280 assert(image_info != (ImageInfo *) NULL);
7281 assert(image_info->signature == MagickSignature);
7282 assert(images != (Image **) NULL);
7283 assert((*images)->previous == (Image *) NULL);
7284 assert((*images)->signature == MagickSignature);
7285 if ((*images)->debug != MagickFalse)
7286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7287 (*images)->filename);
7288 if ((argc <= 0) || (*argv == (char *) NULL))
7290 interpolate_method=UndefinedInterpolatePixel;
7291 mogrify_info=CloneImageInfo(image_info);
7292 quantize_info=AcquireQuantizeInfo(mogrify_info);
7294 for (i=0; i < (ssize_t) argc; i++)
7296 if (*images == (Image *) NULL)
7299 if (IsCommandOption(option) == MagickFalse)
7301 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7302 count=MagickMax(count,0L);
7303 if ((i+count) >= (ssize_t) argc)
7305 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7306 switch (*(option+1))
7310 if (LocaleCompare("affinity",option+1) == 0)
7312 (void) SyncImagesSettings(mogrify_info,*images,exception);
7315 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7322 if (LocaleCompare("append",option+1) == 0)
7327 (void) SyncImagesSettings(mogrify_info,*images,exception);
7328 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7329 MagickFalse,exception);
7330 if (append_image == (Image *) NULL)
7335 *images=DestroyImageList(*images);
7336 *images=append_image;
7339 if (LocaleCompare("average",option+1) == 0)
7345 Average an image sequence (deprecated).
7347 (void) SyncImagesSettings(mogrify_info,*images,exception);
7348 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7350 if (average_image == (Image *) NULL)
7355 *images=DestroyImageList(*images);
7356 *images=average_image;
7363 if (LocaleCompare("channel-fx",option+1) == 0)
7368 (void) SyncImagesSettings(mogrify_info,*images,exception);
7369 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7370 if (channel_image == (Image *) NULL)
7375 *images=DestroyImageList(*images);
7376 *images=channel_image;
7379 if (LocaleCompare("clut",option+1) == 0)
7385 (void) SyncImagesSettings(mogrify_info,*images,exception);
7386 image=RemoveFirstImageFromList(images);
7387 clut_image=RemoveFirstImageFromList(images);
7388 if (clut_image == (Image *) NULL)
7393 (void) ClutImage(image,clut_image,interpolate_method,exception);
7394 clut_image=DestroyImage(clut_image);
7395 *images=DestroyImageList(*images);
7399 if (LocaleCompare("coalesce",option+1) == 0)
7404 (void) SyncImagesSettings(mogrify_info,*images,exception);
7405 coalesce_image=CoalesceImages(*images,exception);
7406 if (coalesce_image == (Image *) NULL)
7411 *images=DestroyImageList(*images);
7412 *images=coalesce_image;
7415 if (LocaleCompare("combine",option+1) == 0)
7423 (void) SyncImagesSettings(mogrify_info,*images,exception);
7424 colorspace=(ColorspaceType) ParseCommandOption(
7425 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7426 combine_image=CombineImages(*images,colorspace,exception);
7427 if (combine_image == (Image *) NULL)
7432 *images=DestroyImageList(*images);
7433 *images=combine_image;
7436 if (LocaleCompare("composite",option+1) == 0)
7452 (void) SyncImagesSettings(mogrify_info,*images,exception);
7453 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7454 if (value == (const char *) NULL)
7455 clip_to_self=MagickTrue;
7457 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7458 "compose:clip-to-self")); /* if this is true */
7459 if (IsMagickFalse(clip_to_self)) /* or */
7460 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7461 mogrify_info,"compose:outside-overlay"))) ? MagickTrue : MagickFalse; /* this false */
7462 image=RemoveFirstImageFromList(images);
7463 composite_image=RemoveFirstImageFromList(images);
7464 if (composite_image == (Image *) NULL)
7469 (void) TransformImage(&composite_image,(char *) NULL,
7470 composite_image->geometry,exception);
7471 SetGeometry(composite_image,&geometry);
7472 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7473 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7475 mask_image=RemoveFirstImageFromList(images);
7476 if (mask_image != (Image *) NULL)
7478 if ((image->compose == DisplaceCompositeOp) ||
7479 (image->compose == DistortCompositeOp))
7482 Merge Y displacement into X displacement image.
7484 (void) CompositeImage(composite_image,mask_image,
7485 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7486 mask_image=DestroyImage(mask_image);
7491 Set a blending mask for the composition.
7493 (void) NegateImage(mask_image,MagickFalse,exception);
7494 (void) SetImageMask(composite_image,mask_image,exception);
7495 mask_image=DestroyImage(mask_image);
7498 (void) CompositeImage(image,composite_image,image->compose,
7499 clip_to_self,geometry.x,geometry.y,exception);
7500 (void) SetImageMask(image,(Image *) NULL,exception);
7501 composite_image=DestroyImage(composite_image);
7502 *images=DestroyImageList(*images);
7510 if (LocaleCompare("deconstruct",option+1) == 0)
7515 (void) SyncImagesSettings(mogrify_info,*images,exception);
7516 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7518 if (deconstruct_image == (Image *) NULL)
7523 *images=DestroyImageList(*images);
7524 *images=deconstruct_image;
7527 if (LocaleCompare("delete",option+1) == 0)
7530 DeleteImages(images,"-1",exception);
7532 DeleteImages(images,argv[i+1],exception);
7535 if (LocaleCompare("dither",option+1) == 0)
7539 quantize_info->dither_method=NoDitherMethod;
7542 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7543 MagickDitherOptions,MagickFalse,argv[i+1]);
7546 if (LocaleCompare("duplicate",option+1) == 0)
7552 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7561 number_duplicates=(size_t) StringToLong(argv[i+1]);
7562 p=strchr(argv[i+1],',');
7563 if (p == (const char *) NULL)
7564 duplicate_images=DuplicateImages(*images,number_duplicates,
7567 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7570 AppendImageToList(images, duplicate_images);
7571 (void) SyncImagesSettings(mogrify_info,*images,exception);
7578 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7583 MagickEvaluateOperator
7586 (void) SyncImageSettings(mogrify_info,*images,exception);
7587 op=(MagickEvaluateOperator) ParseCommandOption(
7588 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7589 evaluate_image=EvaluateImages(*images,op,exception);
7590 if (evaluate_image == (Image *) NULL)
7595 *images=DestroyImageList(*images);
7596 *images=evaluate_image;
7603 if (LocaleCompare("fft",option+1) == 0)
7609 Implements the discrete Fourier transform (DFT).
7611 (void) SyncImageSettings(mogrify_info,*images,exception);
7612 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7613 MagickTrue : MagickFalse,exception);
7614 if (fourier_image == (Image *) NULL)
7616 *images=DestroyImage(*images);
7617 *images=fourier_image;
7620 if (LocaleCompare("flatten",option+1) == 0)
7625 (void) SyncImagesSettings(mogrify_info,*images,exception);
7626 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7627 if (flatten_image == (Image *) NULL)
7629 *images=DestroyImageList(*images);
7630 *images=flatten_image;
7633 if (LocaleCompare("fx",option+1) == 0)
7638 (void) SyncImagesSettings(mogrify_info,*images,exception);
7639 fx_image=FxImage(*images,argv[i+1],exception);
7640 if (fx_image == (Image *) NULL)
7645 *images=DestroyImageList(*images);
7653 if (LocaleCompare("hald-clut",option+1) == 0)
7659 (void) SyncImagesSettings(mogrify_info,*images,exception);
7660 image=RemoveFirstImageFromList(images);
7661 hald_image=RemoveFirstImageFromList(images);
7662 if (hald_image == (Image *) NULL)
7667 (void) HaldClutImage(image,hald_image,exception);
7668 hald_image=DestroyImage(hald_image);
7669 if (*images != (Image *) NULL)
7670 *images=DestroyImageList(*images);
7678 if (LocaleCompare("ift",option+1) == 0)
7686 Implements the inverse fourier discrete Fourier transform (DFT).
7688 (void) SyncImagesSettings(mogrify_info,*images,exception);
7689 magnitude_image=RemoveFirstImageFromList(images);
7690 phase_image=RemoveFirstImageFromList(images);
7691 if (phase_image == (Image *) NULL)
7696 fourier_image=InverseFourierTransformImage(magnitude_image,
7697 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7698 if (fourier_image == (Image *) NULL)
7700 if (*images != (Image *) NULL)
7701 *images=DestroyImage(*images);
7702 *images=fourier_image;
7705 if (LocaleCompare("insert",option+1) == 0)
7713 index=(ssize_t) StringToLong(argv[i+1]);
7714 p=RemoveLastImageFromList(images);
7715 if (p == (Image *) NULL)
7717 (void) ThrowMagickException(exception,GetMagickModule(),
7718 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7724 PrependImageToList(images,q);
7726 if (index == (ssize_t) GetImageListLength(*images))
7727 AppendImageToList(images,q);
7730 q=GetImageFromList(*images,index-1);
7731 if (q == (Image *) NULL)
7733 (void) ThrowMagickException(exception,GetMagickModule(),
7734 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7738 InsertImageInList(&q,p);
7740 *images=GetFirstImageInList(q);
7743 if (LocaleCompare("interpolate",option+1) == 0)
7745 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7746 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7753 if (LocaleCompare("layers",option+1) == 0)
7761 (void) SyncImagesSettings(mogrify_info,*images,exception);
7762 layers=(Image *) NULL;
7763 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
7764 MagickFalse,argv[i+1]);
7769 layers=CoalesceImages(*images,exception);
7772 case CompareAnyLayer:
7773 case CompareClearLayer:
7774 case CompareOverlayLayer:
7777 layers=CompareImagesLayers(*images,method,exception);
7783 case TrimBoundsLayer:
7785 layers=MergeImageLayers(*images,method,exception);
7790 layers=DisposeImages(*images,exception);
7793 case OptimizeImageLayer:
7795 layers=OptimizeImageLayers(*images,exception);
7798 case OptimizePlusLayer:
7800 layers=OptimizePlusImageLayers(*images,exception);
7803 case OptimizeTransLayer:
7805 OptimizeImageTransparency(*images,exception);
7808 case RemoveDupsLayer:
7810 RemoveDuplicateLayers(images,exception);
7813 case RemoveZeroLayer:
7815 RemoveZeroDelayLayers(images,exception);
7821 General Purpose, GIF Animation Optimizer.
7823 layers=CoalesceImages(*images,exception);
7824 if (layers == (Image *) NULL)
7829 *images=DestroyImageList(*images);
7831 layers=OptimizeImageLayers(*images,exception);
7832 if (layers == (Image *) NULL)
7837 *images=DestroyImageList(*images);
7839 layers=(Image *) NULL;
7840 OptimizeImageTransparency(*images,exception);
7841 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7845 case CompositeLayer:
7857 Split image sequence at the first 'NULL:' image.
7860 while (source != (Image *) NULL)
7862 source=GetNextImageInList(source);
7863 if ((source != (Image *) NULL) &&
7864 (LocaleCompare(source->magick,"NULL") == 0))
7867 if (source != (Image *) NULL)
7869 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7870 (GetNextImageInList(source) == (Image *) NULL))
7871 source=(Image *) NULL;
7875 Separate the two lists, junk the null: image.
7877 source=SplitImageList(source->previous);
7878 DeleteImageFromList(&source);
7881 if (source == (Image *) NULL)
7883 (void) ThrowMagickException(exception,GetMagickModule(),
7884 OptionError,"MissingNullSeparator","layers Composite");
7889 Adjust offset with gravity and virtual canvas.
7891 SetGeometry(*images,&geometry);
7892 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7893 geometry.width=source->page.width != 0 ?
7894 source->page.width : source->columns;
7895 geometry.height=source->page.height != 0 ?
7896 source->page.height : source->rows;
7897 GravityAdjustGeometry((*images)->page.width != 0 ?
7898 (*images)->page.width : (*images)->columns,
7899 (*images)->page.height != 0 ? (*images)->page.height :
7900 (*images)->rows,(*images)->gravity,&geometry);
7901 compose=OverCompositeOp;
7902 option=GetImageOption(mogrify_info,"compose");
7903 if (option != (const char *) NULL)
7904 compose=(CompositeOperator) ParseCommandOption(
7905 MagickComposeOptions,MagickFalse,option);
7906 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7908 source=DestroyImageList(source);
7912 if (layers == (Image *) NULL)
7914 *images=DestroyImageList(*images);
7922 if (LocaleCompare("map",option+1) == 0)
7924 (void) SyncImagesSettings(mogrify_info,*images,exception);
7927 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7934 if (LocaleCompare("maximum",option+1) == 0)
7940 Maximum image sequence (deprecated).
7942 (void) SyncImagesSettings(mogrify_info,*images,exception);
7943 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7944 if (maximum_image == (Image *) NULL)
7949 *images=DestroyImageList(*images);
7950 *images=maximum_image;
7953 if (LocaleCompare("minimum",option+1) == 0)
7959 Minimum image sequence (deprecated).
7961 (void) SyncImagesSettings(mogrify_info,*images,exception);
7962 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7963 if (minimum_image == (Image *) NULL)
7968 *images=DestroyImageList(*images);
7969 *images=minimum_image;
7972 if (LocaleCompare("morph",option+1) == 0)
7977 (void) SyncImagesSettings(mogrify_info,*images,exception);
7978 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7980 if (morph_image == (Image *) NULL)
7985 *images=DestroyImageList(*images);
7986 *images=morph_image;
7989 if (LocaleCompare("mosaic",option+1) == 0)
7994 (void) SyncImagesSettings(mogrify_info,*images,exception);
7995 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7996 if (mosaic_image == (Image *) NULL)
8001 *images=DestroyImageList(*images);
8002 *images=mosaic_image;
8009 if (LocaleCompare("print",option+1) == 0)
8014 (void) SyncImagesSettings(mogrify_info,*images,exception);
8015 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8017 if (string == (char *) NULL)
8019 (void) FormatLocaleFile(stdout,"%s",string);
8020 string=DestroyString(string);
8022 if (LocaleCompare("process",option+1) == 0)
8031 (void) SyncImagesSettings(mogrify_info,*images,exception);
8032 arguments=StringToArgv(argv[i+1],&number_arguments);
8033 if (arguments == (char **) NULL)
8035 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8056 Support old style syntax, filter="-option arg".
8058 length=strlen(argv[i+1]);
8059 token=(char *) NULL;
8060 if (~length >= (MaxTextExtent-1))
8061 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8063 if (token == (char *) NULL)
8066 arguments=argv[i+1];
8067 token_info=AcquireTokenInfo();
8068 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8069 "\"",'\0',&breaker,&next,"e);
8070 token_info=DestroyTokenInfo(token_info);
8076 argv=(&(arguments[next]));
8077 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8080 token=DestroyString(token);
8083 (void) SubstituteString(&arguments[1],"-","");
8084 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8085 number_arguments-2,(const char **) arguments+2,exception);
8086 for (j=0; j < number_arguments; j++)
8087 arguments[j]=DestroyString(arguments[j]);
8088 arguments=(char **) RelinquishMagickMemory(arguments);
8095 if (LocaleCompare("reverse",option+1) == 0)
8097 ReverseImageList(images);
8104 if (LocaleCompare("smush",option+1) == 0)
8112 (void) SyncImagesSettings(mogrify_info,*images,exception);
8113 offset=(ssize_t) StringToLong(argv[i+1]);
8114 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8115 MagickFalse,offset,exception);
8116 if (smush_image == (Image *) NULL)
8121 *images=DestroyImageList(*images);
8122 *images=smush_image;
8125 if (LocaleCompare("swap",option+1) == 0)
8146 flags=ParseGeometry(argv[i+1],&geometry_info);
8147 index=(ssize_t) geometry_info.rho;
8148 if ((flags & SigmaValue) != 0)
8149 swap_index=(ssize_t) geometry_info.sigma;
8151 p=GetImageFromList(*images,index);
8152 q=GetImageFromList(*images,swap_index);
8153 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8155 (void) ThrowMagickException(exception,GetMagickModule(),
8156 OptionError,"NoSuchImage","'%s'",(*images)->filename);
8162 swap=CloneImage(p,0,0,MagickTrue,exception);
8163 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8164 ReplaceImageInList(&q,swap);
8165 *images=GetFirstImageInList(q);
8172 if (LocaleCompare("write",option+1) == 0)
8183 (void) SyncImagesSettings(mogrify_info,*images,exception);
8184 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8185 (void) DeleteImageRegistry(key);
8186 write_images=(*images);
8188 write_images=CloneImageList(*images,exception);
8189 write_info=CloneImageInfo(mogrify_info);
8190 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8191 write_info=DestroyImageInfo(write_info);
8193 write_images=DestroyImageList(write_images);
8203 quantize_info=DestroyQuantizeInfo(quantize_info);
8204 mogrify_info=DestroyImageInfo(mogrify_info);
8205 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8206 return(status != 0 ? MagickTrue : MagickFalse);
8210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8214 + M o g r i f y I m a g e s %
8218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8220 % MogrifyImages() applies image processing options to a sequence of images as
8221 % prescribed by command line options.
8223 % The format of the MogrifyImage method is:
8225 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8226 % const MagickBooleanType post,const int argc,const char **argv,
8227 % Image **images,Exceptioninfo *exception)
8229 % A description of each parameter follows:
8231 % o image_info: the image info..
8233 % o post: If true, post process image list operators otherwise pre-process.
8235 % o argc: Specifies a pointer to an integer describing the number of
8236 % elements in the argument vector.
8238 % o argv: Specifies a pointer to a text array containing the command line
8241 % o images: pointer to a pointer of the first image in image list.
8243 % o exception: return any errors or warnings in this structure.
8246 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8247 const MagickBooleanType post,const int argc,const char **argv,
8248 Image **images,ExceptionInfo *exception)
8250 #define MogrifyImageTag "Mogrify/Image"
8264 assert(image_info != (ImageInfo *) NULL);
8265 assert(image_info->signature == MagickSignature);
8266 if (images == (Image **) NULL)
8267 return(MogrifyImage(image_info,argc,argv,images,exception));
8268 assert((*images)->previous == (Image *) NULL);
8269 assert((*images)->signature == MagickSignature);
8270 if ((*images)->debug != MagickFalse)
8271 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8272 (*images)->filename);
8273 if ((argc <= 0) || (*argv == (char *) NULL))
8275 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8280 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8285 Pre-process multi-image sequence operators
8287 if (post == MagickFalse)
8288 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8290 For each image, process simple single image operators
8293 n=GetImageListLength(*images);
8297 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8298 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8300 status&=MogrifyImage(image_info,argc,argv,images,exception);
8301 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8302 if (proceed == MagickFalse)
8304 if ( (*images)->next == (Image *) NULL )
8306 *images=(*images)->next;
8309 assert( *images != (Image *) NULL );
8311 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8312 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8316 Post-process, multi-image sequence operators
8318 *images=GetFirstImageInList(*images);
8319 if (post != MagickFalse)
8320 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8321 return(status != 0 ? MagickTrue : MagickFalse);