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 SetOpenMPMaximumThreads((int) 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 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->matte != MagickFalse))
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->matte != MagickFalse))
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->matte != MagickFalse))
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=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
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 if ((flags & SigmaValue) == 0)
969 geometry.height=geometry.width;
970 mogrify_image=BorderImage(*image,&geometry,compose,exception);
973 if (LocaleCompare("bordercolor",option+1) == 0)
977 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
978 &draw_info->border_color,exception);
981 (void) QueryColorCompliance(argv[i+1],AllCompliance,
982 &draw_info->border_color,exception);
985 if (LocaleCompare("box",option+1) == 0)
987 (void) QueryColorCompliance(argv[i+1],AllCompliance,
988 &draw_info->undercolor,exception);
991 if (LocaleCompare("brightness-contrast",option+1) == 0)
1004 Brightness / contrast image.
1006 (void) SyncImageSettings(mogrify_info,*image,exception);
1007 flags=ParseGeometry(argv[i+1],&geometry_info);
1008 brightness=geometry_info.rho;
1010 if ((flags & SigmaValue) != 0)
1011 contrast=geometry_info.sigma;
1012 (void) BrightnessContrastImage(*image,brightness,contrast,
1020 if (LocaleCompare("cdl",option+1) == 0)
1023 *color_correction_collection;
1026 Color correct with a color decision list.
1028 (void) SyncImageSettings(mogrify_info,*image,exception);
1029 color_correction_collection=FileToString(argv[i+1],~0,exception);
1030 if (color_correction_collection == (char *) NULL)
1032 (void) ColorDecisionListImage(*image,color_correction_collection,
1036 if (LocaleCompare("charcoal",option+1) == 0)
1041 (void) SyncImageSettings(mogrify_info,*image,exception);
1042 flags=ParseGeometry(argv[i+1],&geometry_info);
1043 if ((flags & SigmaValue) == 0)
1044 geometry_info.sigma=1.0;
1045 if ((flags & XiValue) == 0)
1046 geometry_info.xi=1.0;
1047 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1048 geometry_info.sigma,exception);
1051 if (LocaleCompare("chop",option+1) == 0)
1056 (void) SyncImageSettings(mogrify_info,*image,exception);
1057 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1058 mogrify_image=ChopImage(*image,&geometry,exception);
1061 if (LocaleCompare("clamp",option+1) == 0)
1066 (void) SyncImageSettings(mogrify_info,*image,exception);
1067 (void) ClampImage(*image,exception);
1070 if (LocaleCompare("clip",option+1) == 0)
1072 (void) SyncImageSettings(mogrify_info,*image,exception);
1075 (void) SetImageMask(*image,(Image *) NULL,exception);
1078 (void) ClipImage(*image,exception);
1081 if (LocaleCompare("clip-mask",option+1) == 0)
1098 (void) SyncImageSettings(mogrify_info,*image,exception);
1104 (void) SetImageMask(*image,(Image *) NULL,exception);
1109 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1111 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1112 if (mask_image == (Image *) NULL)
1114 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1115 return(MagickFalse);
1116 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1117 for (y=0; y < (ssize_t) mask_image->rows; y++)
1119 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1121 if (q == (Quantum *) NULL)
1123 for (x=0; x < (ssize_t) mask_image->columns; x++)
1125 if (mask_image->matte == MagickFalse)
1126 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1127 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1128 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1129 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1130 q+=GetPixelChannels(mask_image);
1132 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1135 mask_view=DestroyCacheView(mask_view);
1136 mask_image->matte=MagickTrue;
1137 (void) SetImageMask(*image,mask_image,exception);
1140 if (LocaleCompare("clip-path",option+1) == 0)
1142 (void) SyncImageSettings(mogrify_info,*image,exception);
1143 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1144 MagickFalse,exception);
1147 if (LocaleCompare("colorize",option+1) == 0)
1152 (void) SyncImageSettings(mogrify_info,*image,exception);
1153 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1156 if (LocaleCompare("color-matrix",option+1) == 0)
1161 (void) SyncImageSettings(mogrify_info,*image,exception);
1162 kernel=AcquireKernelInfo(argv[i+1]);
1163 if (kernel == (KernelInfo *) NULL)
1165 /* FUTURE: check on size of the matrix */
1166 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1167 kernel=DestroyKernelInfo(kernel);
1170 if (LocaleCompare("colors",option+1) == 0)
1173 Reduce the number of colors in the image.
1175 (void) SyncImageSettings(mogrify_info,*image,exception);
1176 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1177 if (quantize_info->number_colors == 0)
1179 if (((*image)->storage_class == DirectClass) ||
1180 (*image)->colors > quantize_info->number_colors)
1181 (void) QuantizeImage(quantize_info,*image,exception);
1183 (void) CompressImageColormap(*image,exception);
1186 if (LocaleCompare("colorspace",option+1) == 0)
1191 (void) SyncImageSettings(mogrify_info,*image,exception);
1194 (void) TransformImageColorspace(*image,sRGBColorspace,
1198 colorspace=(ColorspaceType) ParseCommandOption(
1199 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1200 (void) TransformImageColorspace(*image,colorspace,exception);
1203 if (LocaleCompare("compose",option+1) == 0)
1205 (void) SyncImageSettings(mogrify_info,*image,exception);
1206 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1207 MagickFalse,argv[i+1]);
1210 if (LocaleCompare("contrast",option+1) == 0)
1212 (void) SyncImageSettings(mogrify_info,*image,exception);
1213 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1214 MagickFalse,exception);
1217 if (LocaleCompare("contrast-stretch",option+1) == 0)
1227 Contrast stretch image.
1229 (void) SyncImageSettings(mogrify_info,*image,exception);
1230 flags=ParseGeometry(argv[i+1],&geometry_info);
1231 black_point=geometry_info.rho;
1232 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1234 if ((flags & PercentValue) != 0)
1236 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1237 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1239 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1241 (void) ContrastStretchImage(*image,black_point,white_point,
1245 if (LocaleCompare("convolve",option+1) == 0)
1250 (void) SyncImageSettings(mogrify_info,*image,exception);
1251 kernel_info=AcquireKernelInfo(argv[i+1]);
1252 if (kernel_info == (KernelInfo *) NULL)
1254 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1255 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1256 kernel_info=DestroyKernelInfo(kernel_info);
1259 if (LocaleCompare("crop",option+1) == 0)
1262 Crop a image to a smaller size
1264 (void) SyncImageSettings(mogrify_info,*image,exception);
1265 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1268 if (LocaleCompare("cycle",option+1) == 0)
1271 Cycle an image colormap.
1273 (void) SyncImageSettings(mogrify_info,*image,exception);
1274 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1282 if (LocaleCompare("decipher",option+1) == 0)
1290 (void) SyncImageSettings(mogrify_info,*image,exception);
1291 passkey=FileToStringInfo(argv[i+1],~0,exception);
1292 if (passkey != (StringInfo *) NULL)
1294 (void) PasskeyDecipherImage(*image,passkey,exception);
1295 passkey=DestroyStringInfo(passkey);
1299 if (LocaleCompare("density",option+1) == 0)
1304 (void) CloneString(&draw_info->density,argv[i+1]);
1307 if (LocaleCompare("depth",option+1) == 0)
1309 (void) SyncImageSettings(mogrify_info,*image,exception);
1312 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1315 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1319 if (LocaleCompare("deskew",option+1) == 0)
1325 Straighten the image.
1327 (void) SyncImageSettings(mogrify_info,*image,exception);
1329 threshold=40.0*QuantumRange/100.0;
1331 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1333 mogrify_image=DeskewImage(*image,threshold,exception);
1336 if (LocaleCompare("despeckle",option+1) == 0)
1339 Reduce the speckles within an image.
1341 (void) SyncImageSettings(mogrify_info,*image,exception);
1342 mogrify_image=DespeckleImage(*image,exception);
1345 if (LocaleCompare("display",option+1) == 0)
1347 (void) CloneString(&draw_info->server_name,argv[i+1]);
1350 if (LocaleCompare("distort",option+1) == 0)
1354 token[MaxTextExtent];
1374 (void) SyncImageSettings(mogrify_info,*image,exception);
1375 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1376 MagickFalse,argv[i+1]);
1377 if (method == ResizeDistortion)
1383 Special Case - Argument is actually a resize geometry!
1384 Convert that to an appropriate distortion argument array.
1386 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1388 resize_args[0]=(double) geometry.width;
1389 resize_args[1]=(double) geometry.height;
1390 mogrify_image=DistortImage(*image,method,(size_t)2,
1391 resize_args,MagickTrue,exception);
1394 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1396 if (args == (char *) NULL)
1399 for (x=0; *p != '\0'; x++)
1401 GetMagickToken(p,&p,token);
1403 GetMagickToken(p,&p,token);
1405 number_arguments=(size_t) x;
1406 arguments=(double *) AcquireQuantumMemory(number_arguments,
1407 sizeof(*arguments));
1408 if (arguments == (double *) NULL)
1409 ThrowWandFatalException(ResourceLimitFatalError,
1410 "MemoryAllocationFailed",(*image)->filename);
1411 (void) ResetMagickMemory(arguments,0,number_arguments*
1412 sizeof(*arguments));
1414 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1416 GetMagickToken(p,&p,token);
1418 GetMagickToken(p,&p,token);
1419 arguments[x]=StringToDouble(token,(char **) NULL);
1421 args=DestroyString(args);
1422 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1423 (*option == '+') ? MagickTrue : MagickFalse,exception);
1424 arguments=(double *) RelinquishMagickMemory(arguments);
1427 if (LocaleCompare("dither",option+1) == 0)
1431 quantize_info->dither=MagickFalse;
1434 quantize_info->dither=MagickTrue;
1435 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1436 MagickDitherOptions,MagickFalse,argv[i+1]);
1437 if (quantize_info->dither_method == NoDitherMethod)
1438 quantize_info->dither=MagickFalse;
1441 if (LocaleCompare("draw",option+1) == 0)
1446 (void) SyncImageSettings(mogrify_info,*image,exception);
1447 (void) CloneString(&draw_info->primitive,argv[i+1]);
1448 (void) DrawImage(*image,draw_info,exception);
1455 if (LocaleCompare("edge",option+1) == 0)
1458 Enhance edges in the image.
1460 (void) SyncImageSettings(mogrify_info,*image,exception);
1461 flags=ParseGeometry(argv[i+1],&geometry_info);
1462 if ((flags & SigmaValue) == 0)
1463 geometry_info.sigma=1.0;
1464 mogrify_image=EdgeImage(*image,geometry_info.rho,
1465 geometry_info.sigma,exception);
1468 if (LocaleCompare("emboss",option+1) == 0)
1473 (void) SyncImageSettings(mogrify_info,*image,exception);
1474 flags=ParseGeometry(argv[i+1],&geometry_info);
1475 if ((flags & SigmaValue) == 0)
1476 geometry_info.sigma=1.0;
1477 mogrify_image=EmbossImage(*image,geometry_info.rho,
1478 geometry_info.sigma,exception);
1481 if (LocaleCompare("encipher",option+1) == 0)
1489 (void) SyncImageSettings(mogrify_info,*image,exception);
1490 passkey=FileToStringInfo(argv[i+1],~0,exception);
1491 if (passkey != (StringInfo *) NULL)
1493 (void) PasskeyEncipherImage(*image,passkey,exception);
1494 passkey=DestroyStringInfo(passkey);
1498 if (LocaleCompare("encoding",option+1) == 0)
1500 (void) CloneString(&draw_info->encoding,argv[i+1]);
1503 if (LocaleCompare("enhance",option+1) == 0)
1508 (void) SyncImageSettings(mogrify_info,*image,exception);
1509 mogrify_image=EnhanceImage(*image,exception);
1512 if (LocaleCompare("equalize",option+1) == 0)
1517 (void) SyncImageSettings(mogrify_info,*image,exception);
1518 (void) EqualizeImage(*image,exception);
1521 if (LocaleCompare("evaluate",option+1) == 0)
1526 MagickEvaluateOperator
1529 (void) SyncImageSettings(mogrify_info,*image,exception);
1530 op=(MagickEvaluateOperator) ParseCommandOption(
1531 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1532 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1534 (void) EvaluateImage(*image,op,constant,exception);
1537 if (LocaleCompare("extent",option+1) == 0)
1540 Set the image extent.
1542 (void) SyncImageSettings(mogrify_info,*image,exception);
1543 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1544 if (geometry.width == 0)
1545 geometry.width=(*image)->columns;
1546 if (geometry.height == 0)
1547 geometry.height=(*image)->rows;
1548 mogrify_image=ExtentImage(*image,&geometry,exception);
1555 if (LocaleCompare("family",option+1) == 0)
1559 if (draw_info->family != (char *) NULL)
1560 draw_info->family=DestroyString(draw_info->family);
1563 (void) CloneString(&draw_info->family,argv[i+1]);
1566 if (LocaleCompare("features",option+1) == 0)
1570 (void) DeleteImageArtifact(*image,"identify:features");
1573 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1576 if (LocaleCompare("fill",option+1) == 0)
1584 GetPixelInfo(*image,&fill);
1587 (void) QueryColorCompliance("none",AllCompliance,&fill,
1589 draw_info->fill=fill;
1590 if (draw_info->fill_pattern != (Image *) NULL)
1591 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1594 sans=AcquireExceptionInfo();
1595 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1596 sans=DestroyExceptionInfo(sans);
1597 if (status == MagickFalse)
1598 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1601 draw_info->fill=fill=color;
1604 if (LocaleCompare("flip",option+1) == 0)
1607 Flip image scanlines.
1609 (void) SyncImageSettings(mogrify_info,*image,exception);
1610 mogrify_image=FlipImage(*image,exception);
1613 if (LocaleCompare("floodfill",option+1) == 0)
1621 (void) SyncImageSettings(mogrify_info,*image,exception);
1622 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1623 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1625 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1626 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1629 if (LocaleCompare("flop",option+1) == 0)
1632 Flop image scanlines.
1634 (void) SyncImageSettings(mogrify_info,*image,exception);
1635 mogrify_image=FlopImage(*image,exception);
1638 if (LocaleCompare("font",option+1) == 0)
1642 if (draw_info->font != (char *) NULL)
1643 draw_info->font=DestroyString(draw_info->font);
1646 (void) CloneString(&draw_info->font,argv[i+1]);
1649 if (LocaleCompare("format",option+1) == 0)
1654 if (LocaleCompare("frame",option+1) == 0)
1660 Surround image with an ornamental border.
1662 (void) SyncImageSettings(mogrify_info,*image,exception);
1663 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1664 frame_info.width=geometry.width;
1665 frame_info.height=geometry.height;
1666 if ((flags & HeightValue) == 0)
1667 frame_info.height=geometry.width;
1668 frame_info.outer_bevel=geometry.x;
1669 frame_info.inner_bevel=geometry.y;
1670 frame_info.x=(ssize_t) frame_info.width;
1671 frame_info.y=(ssize_t) frame_info.height;
1672 frame_info.width=(*image)->columns+2*frame_info.width;
1673 frame_info.height=(*image)->rows+2*frame_info.height;
1674 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1677 if (LocaleCompare("function",option+1) == 0)
1681 token[MaxTextExtent];
1699 Function Modify Image Values
1701 (void) SyncImageSettings(mogrify_info,*image,exception);
1702 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1703 MagickFalse,argv[i+1]);
1704 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1706 if (arguments == (char *) NULL)
1708 p=(char *) arguments;
1709 for (x=0; *p != '\0'; x++)
1711 GetMagickToken(p,&p,token);
1713 GetMagickToken(p,&p,token);
1715 number_parameters=(size_t) x;
1716 parameters=(double *) AcquireQuantumMemory(number_parameters,
1717 sizeof(*parameters));
1718 if (parameters == (double *) NULL)
1719 ThrowWandFatalException(ResourceLimitFatalError,
1720 "MemoryAllocationFailed",(*image)->filename);
1721 (void) ResetMagickMemory(parameters,0,number_parameters*
1722 sizeof(*parameters));
1723 p=(char *) arguments;
1724 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1726 GetMagickToken(p,&p,token);
1728 GetMagickToken(p,&p,token);
1729 parameters[x]=StringToDouble(token,(char **) NULL);
1731 arguments=DestroyString(arguments);
1732 (void) FunctionImage(*image,function,number_parameters,parameters,
1734 parameters=(double *) RelinquishMagickMemory(parameters);
1741 if (LocaleCompare("gamma",option+1) == 0)
1746 (void) SyncImageSettings(mogrify_info,*image,exception);
1748 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1750 (void) GammaImage(*image,StringToDouble(argv[i+1],
1751 (char **) NULL),exception);
1754 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1755 (LocaleCompare("gaussian",option+1) == 0))
1758 Gaussian blur image.
1760 (void) SyncImageSettings(mogrify_info,*image,exception);
1761 flags=ParseGeometry(argv[i+1],&geometry_info);
1762 if ((flags & SigmaValue) == 0)
1763 geometry_info.sigma=1.0;
1764 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1765 geometry_info.sigma,exception);
1768 if (LocaleCompare("geometry",option+1) == 0)
1771 Record Image offset, Resize last image.
1773 (void) SyncImageSettings(mogrify_info,*image,exception);
1776 if ((*image)->geometry != (char *) NULL)
1777 (*image)->geometry=DestroyString((*image)->geometry);
1780 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1781 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1782 (void) CloneString(&(*image)->geometry,argv[i+1]);
1784 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1785 (*image)->filter,exception);
1788 if (LocaleCompare("gravity",option+1) == 0)
1792 draw_info->gravity=UndefinedGravity;
1795 draw_info->gravity=(GravityType) ParseCommandOption(
1796 MagickGravityOptions,MagickFalse,argv[i+1]);
1803 if (LocaleCompare("highlight-color",option+1) == 0)
1805 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1812 if (LocaleCompare("identify",option+1) == 0)
1817 (void) SyncImageSettings(mogrify_info,*image,exception);
1818 if (format == (char *) NULL)
1820 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1824 text=InterpretImageProperties(mogrify_info,*image,format,
1826 if (text == (char *) NULL)
1828 (void) fputs(text,stdout);
1829 (void) fputc('\n',stdout);
1830 text=DestroyString(text);
1833 if (LocaleCompare("implode",option+1) == 0)
1838 (void) SyncImageSettings(mogrify_info,*image,exception);
1839 (void) ParseGeometry(argv[i+1],&geometry_info);
1840 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1841 interpolate_method,exception);
1844 if (LocaleCompare("interline-spacing",option+1) == 0)
1847 (void) ParseGeometry("0",&geometry_info);
1849 (void) ParseGeometry(argv[i+1],&geometry_info);
1850 draw_info->interline_spacing=geometry_info.rho;
1853 if (LocaleCompare("interpolate",option+1) == 0)
1855 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1856 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1859 if (LocaleCompare("interword-spacing",option+1) == 0)
1862 (void) ParseGeometry("0",&geometry_info);
1864 (void) ParseGeometry(argv[i+1],&geometry_info);
1865 draw_info->interword_spacing=geometry_info.rho;
1868 if (LocaleCompare("interpolative-resize",option+1) == 0)
1871 Interpolative resize image.
1873 (void) SyncImageSettings(mogrify_info,*image,exception);
1874 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1875 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1876 geometry.height,interpolate_method,exception);
1883 if (LocaleCompare("kerning",option+1) == 0)
1886 (void) ParseGeometry("0",&geometry_info);
1888 (void) ParseGeometry(argv[i+1],&geometry_info);
1889 draw_info->kerning=geometry_info.rho;
1896 if (LocaleCompare("lat",option+1) == 0)
1899 Local adaptive threshold image.
1901 (void) SyncImageSettings(mogrify_info,*image,exception);
1902 flags=ParseGeometry(argv[i+1],&geometry_info);
1903 if ((flags & PercentValue) != 0)
1904 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1905 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1906 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1907 geometry_info.xi,exception);
1910 if (LocaleCompare("level",option+1) == 0)
1923 (void) SyncImageSettings(mogrify_info,*image,exception);
1924 flags=ParseGeometry(argv[i+1],&geometry_info);
1925 black_point=geometry_info.rho;
1926 white_point=(MagickRealType) QuantumRange;
1927 if ((flags & SigmaValue) != 0)
1928 white_point=geometry_info.sigma;
1930 if ((flags & XiValue) != 0)
1931 gamma=geometry_info.xi;
1932 if ((flags & PercentValue) != 0)
1934 black_point*=(MagickRealType) (QuantumRange/100.0);
1935 white_point*=(MagickRealType) (QuantumRange/100.0);
1937 if ((flags & SigmaValue) == 0)
1938 white_point=(MagickRealType) QuantumRange-black_point;
1939 if ((*option == '+') || ((flags & AspectValue) != 0))
1940 (void) LevelizeImage(*image,black_point,white_point,gamma,
1943 (void) LevelImage(*image,black_point,white_point,gamma,
1947 if (LocaleCompare("level-colors",option+1) == 0)
1950 token[MaxTextExtent];
1959 p=(const char *) argv[i+1];
1960 GetMagickToken(p,&p,token); /* get black point color */
1961 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1962 (void) QueryColorCompliance(token,AllCompliance,
1963 &black_point,exception);
1965 (void) QueryColorCompliance("#000000",AllCompliance,
1966 &black_point,exception);
1967 if (isalpha((int) token[0]) || (token[0] == '#'))
1968 GetMagickToken(p,&p,token);
1970 white_point=black_point; /* set everything to that color */
1973 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1974 GetMagickToken(p,&p,token); /* Get white point color. */
1975 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1976 (void) QueryColorCompliance(token,AllCompliance,
1977 &white_point,exception);
1979 (void) QueryColorCompliance("#ffffff",AllCompliance,
1980 &white_point,exception);
1982 (void) LevelImageColors(*image,&black_point,&white_point,
1983 *option == '+' ? MagickTrue : MagickFalse,exception);
1986 if (LocaleCompare("linear-stretch",option+1) == 0)
1995 (void) SyncImageSettings(mogrify_info,*image,exception);
1996 flags=ParseGeometry(argv[i+1],&geometry_info);
1997 black_point=geometry_info.rho;
1998 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1999 if ((flags & SigmaValue) != 0)
2000 white_point=geometry_info.sigma;
2001 if ((flags & PercentValue) != 0)
2003 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2004 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2006 if ((flags & SigmaValue) == 0)
2007 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2009 (void) LinearStretchImage(*image,black_point,white_point,exception);
2012 if (LocaleCompare("liquid-rescale",option+1) == 0)
2015 Liquid rescale image.
2017 (void) SyncImageSettings(mogrify_info,*image,exception);
2018 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2019 if ((flags & XValue) == 0)
2021 if ((flags & YValue) == 0)
2023 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2024 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2027 if (LocaleCompare("lowlight-color",option+1) == 0)
2029 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2036 if (LocaleCompare("map",option+1) == 0)
2042 Transform image colors to match this set of colors.
2044 (void) SyncImageSettings(mogrify_info,*image,exception);
2047 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2048 if (remap_image == (Image *) NULL)
2050 (void) RemapImage(quantize_info,*image,remap_image,exception);
2051 remap_image=DestroyImage(remap_image);
2054 if (LocaleCompare("mask",option+1) == 0)
2059 (void) SyncImageSettings(mogrify_info,*image,exception);
2065 (void) SetImageMask(*image,(Image *) NULL,exception);
2071 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2072 if (mask == (Image *) NULL)
2074 (void) SetImageMask(*image,mask,exception);
2075 mask=DestroyImage(mask);
2078 if (LocaleCompare("matte",option+1) == 0)
2080 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2081 SetAlphaChannel : DeactivateAlphaChannel,exception);
2084 if (LocaleCompare("median",option+1) == 0)
2087 Median filter image.
2089 (void) SyncImageSettings(mogrify_info,*image,exception);
2090 flags=ParseGeometry(argv[i+1],&geometry_info);
2091 if ((flags & SigmaValue) == 0)
2092 geometry_info.sigma=geometry_info.rho;
2093 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2094 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2097 if (LocaleCompare("mode",option+1) == 0)
2102 (void) SyncImageSettings(mogrify_info,*image,exception);
2103 flags=ParseGeometry(argv[i+1],&geometry_info);
2104 if ((flags & SigmaValue) == 0)
2105 geometry_info.sigma=geometry_info.rho;
2106 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2107 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2110 if (LocaleCompare("modulate",option+1) == 0)
2112 (void) SyncImageSettings(mogrify_info,*image,exception);
2113 (void) ModulateImage(*image,argv[i+1],exception);
2116 if (LocaleCompare("monitor",option+1) == 0)
2120 (void) SetImageProgressMonitor(*image,
2121 (MagickProgressMonitor) NULL,(void *) NULL);
2124 (void) SetImageProgressMonitor(*image,MonitorProgress,
2128 if (LocaleCompare("monochrome",option+1) == 0)
2130 (void) SyncImageSettings(mogrify_info,*image,exception);
2131 (void) SetImageType(*image,BilevelType,exception);
2134 if (LocaleCompare("morphology",option+1) == 0)
2137 token[MaxTextExtent];
2152 Morphological Image Operation
2154 (void) SyncImageSettings(mogrify_info,*image,exception);
2156 GetMagickToken(p,&p,token);
2157 method=(MorphologyMethod) ParseCommandOption(
2158 MagickMorphologyOptions,MagickFalse,token);
2160 GetMagickToken(p,&p,token);
2161 if ((*p == ':') || (*p == ','))
2162 GetMagickToken(p,&p,token);
2164 iterations=(ssize_t) StringToLong(p);
2165 kernel=AcquireKernelInfo(argv[i+2]);
2166 if (kernel == (KernelInfo *) NULL)
2168 (void) ThrowMagickException(exception,GetMagickModule(),
2169 OptionError,"UnabletoParseKernel","morphology");
2173 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2175 kernel=DestroyKernelInfo(kernel);
2178 if (LocaleCompare("motion-blur",option+1) == 0)
2183 (void) SyncImageSettings(mogrify_info,*image,exception);
2184 flags=ParseGeometry(argv[i+1],&geometry_info);
2185 if ((flags & SigmaValue) == 0)
2186 geometry_info.sigma=1.0;
2187 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2188 geometry_info.sigma,geometry_info.xi,exception);
2195 if (LocaleCompare("negate",option+1) == 0)
2197 (void) SyncImageSettings(mogrify_info,*image,exception);
2198 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2199 MagickFalse,exception);
2202 if (LocaleCompare("noise",option+1) == 0)
2204 (void) SyncImageSettings(mogrify_info,*image,exception);
2207 flags=ParseGeometry(argv[i+1],&geometry_info);
2208 if ((flags & SigmaValue) == 0)
2209 geometry_info.sigma=geometry_info.rho;
2210 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2211 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2218 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2219 MagickFalse,argv[i+1]);
2220 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2224 if (LocaleCompare("normalize",option+1) == 0)
2226 (void) SyncImageSettings(mogrify_info,*image,exception);
2227 (void) NormalizeImage(*image,exception);
2234 if (LocaleCompare("opaque",option+1) == 0)
2239 (void) SyncImageSettings(mogrify_info,*image,exception);
2240 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2242 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2243 MagickFalse : MagickTrue,exception);
2246 if (LocaleCompare("ordered-dither",option+1) == 0)
2248 (void) SyncImageSettings(mogrify_info,*image,exception);
2249 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2256 if (LocaleCompare("paint",option+1) == 0)
2258 (void) SyncImageSettings(mogrify_info,*image,exception);
2259 (void) ParseGeometry(argv[i+1],&geometry_info);
2260 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2261 geometry_info.sigma,exception);
2264 if (LocaleCompare("pointsize",option+1) == 0)
2267 (void) ParseGeometry("12",&geometry_info);
2269 (void) ParseGeometry(argv[i+1],&geometry_info);
2270 draw_info->pointsize=geometry_info.rho;
2273 if (LocaleCompare("polaroid",option+1) == 0)
2285 Simulate a Polaroid picture.
2287 (void) SyncImageSettings(mogrify_info,*image,exception);
2288 random_info=AcquireRandomInfo();
2289 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2290 random_info=DestroyRandomInfo(random_info);
2293 SetGeometryInfo(&geometry_info);
2294 flags=ParseGeometry(argv[i+1],&geometry_info);
2295 angle=geometry_info.rho;
2297 caption=GetImageProperty(*image,"caption",exception);
2298 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2299 interpolate_method,exception);
2302 if (LocaleCompare("posterize",option+1) == 0)
2307 (void) SyncImageSettings(mogrify_info,*image,exception);
2308 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2309 quantize_info->dither,exception);
2312 if (LocaleCompare("preview",option+1) == 0)
2320 (void) SyncImageSettings(mogrify_info,*image,exception);
2322 preview_type=UndefinedPreview;
2324 preview_type=(PreviewType) ParseCommandOption(
2325 MagickPreviewOptions,MagickFalse,argv[i+1]);
2326 mogrify_image=PreviewImage(*image,preview_type,exception);
2329 if (LocaleCompare("profile",option+1) == 0)
2343 (void) SyncImageSettings(mogrify_info,*image,exception);
2347 Remove a profile from the image.
2349 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2354 Associate a profile with the image.
2356 profile_info=CloneImageInfo(mogrify_info);
2357 profile=GetImageProfile(*image,"iptc");
2358 if (profile != (StringInfo *) NULL)
2359 profile_info->profile=(void *) CloneStringInfo(profile);
2360 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2361 profile_info=DestroyImageInfo(profile_info);
2362 if (profile_image == (Image *) NULL)
2367 profile_info=CloneImageInfo(mogrify_info);
2368 (void) CopyMagickString(profile_info->filename,argv[i+1],
2370 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2371 if (profile != (StringInfo *) NULL)
2373 (void) ProfileImage(*image,profile_info->magick,
2374 GetStringInfoDatum(profile),(size_t)
2375 GetStringInfoLength(profile),exception);
2376 profile=DestroyStringInfo(profile);
2378 profile_info=DestroyImageInfo(profile_info);
2381 ResetImageProfileIterator(profile_image);
2382 name=GetNextImageProfile(profile_image);
2383 while (name != (const char *) NULL)
2385 profile=GetImageProfile(profile_image,name);
2386 if (profile != (StringInfo *) NULL)
2387 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2388 (size_t) GetStringInfoLength(profile),exception);
2389 name=GetNextImageProfile(profile_image);
2391 profile_image=DestroyImage(profile_image);
2398 if (LocaleCompare("quantize",option+1) == 0)
2402 quantize_info->colorspace=UndefinedColorspace;
2405 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2406 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2413 if (LocaleCompare("radial-blur",option+1) == 0)
2418 (void) SyncImageSettings(mogrify_info,*image,exception);
2419 flags=ParseGeometry(argv[i+1],&geometry_info);
2420 mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception);
2423 if (LocaleCompare("raise",option+1) == 0)
2426 Surround image with a raise of solid color.
2428 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2429 if ((flags & SigmaValue) == 0)
2430 geometry.height=geometry.width;
2431 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2432 MagickFalse,exception);
2435 if (LocaleCompare("random-threshold",option+1) == 0)
2440 (void) SyncImageSettings(mogrify_info,*image,exception);
2441 (void) RandomThresholdImage(*image,argv[i+1],exception);
2444 if (LocaleCompare("region",option+1) == 0)
2446 (void) SyncImageSettings(mogrify_info,*image,exception);
2447 if (region_image != (Image *) NULL)
2452 (void) CompositeImage(region_image,*image,region_image->matte !=
2453 MagickFalse ? CopyCompositeOp : OverCompositeOp,MagickTrue,
2454 region_geometry.x,region_geometry.y,exception);
2455 *image=DestroyImage(*image);
2456 *image=region_image;
2457 region_image = (Image *) NULL;
2462 Apply transformations to a selected region of the image.
2464 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2466 mogrify_image=CropImage(*image,®ion_geometry,exception);
2467 if (mogrify_image == (Image *) NULL)
2469 region_image=(*image);
2470 *image=mogrify_image;
2471 mogrify_image=(Image *) NULL;
2474 if (LocaleCompare("render",option+1) == 0)
2476 (void) SyncImageSettings(mogrify_info,*image,exception);
2477 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2480 if (LocaleCompare("remap",option+1) == 0)
2486 Transform image colors to match this set of colors.
2488 (void) SyncImageSettings(mogrify_info,*image,exception);
2491 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2492 if (remap_image == (Image *) NULL)
2494 (void) RemapImage(quantize_info,*image,remap_image,exception);
2495 remap_image=DestroyImage(remap_image);
2498 if (LocaleCompare("repage",option+1) == 0)
2502 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2505 (void) ResetImagePage(*image,argv[i+1]);
2508 if (LocaleCompare("resample",option+1) == 0)
2513 (void) SyncImageSettings(mogrify_info,*image,exception);
2514 flags=ParseGeometry(argv[i+1],&geometry_info);
2515 if ((flags & SigmaValue) == 0)
2516 geometry_info.sigma=geometry_info.rho;
2517 mogrify_image=ResampleImage(*image,geometry_info.rho,
2518 geometry_info.sigma,(*image)->filter,exception);
2521 if (LocaleCompare("resize",option+1) == 0)
2526 (void) SyncImageSettings(mogrify_info,*image,exception);
2527 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2528 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2529 (*image)->filter,exception);
2532 if (LocaleCompare("roll",option+1) == 0)
2537 (void) SyncImageSettings(mogrify_info,*image,exception);
2538 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2539 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2542 if (LocaleCompare("rotate",option+1) == 0)
2548 Check for conditional image rotation.
2550 (void) SyncImageSettings(mogrify_info,*image,exception);
2551 if (strchr(argv[i+1],'>') != (char *) NULL)
2552 if ((*image)->columns <= (*image)->rows)
2554 if (strchr(argv[i+1],'<') != (char *) NULL)
2555 if ((*image)->columns >= (*image)->rows)
2560 geometry=ConstantString(argv[i+1]);
2561 (void) SubstituteString(&geometry,">","");
2562 (void) SubstituteString(&geometry,"<","");
2563 (void) ParseGeometry(geometry,&geometry_info);
2564 geometry=DestroyString(geometry);
2565 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2572 if (LocaleCompare("sample",option+1) == 0)
2575 Sample image with pixel replication.
2577 (void) SyncImageSettings(mogrify_info,*image,exception);
2578 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2579 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2583 if (LocaleCompare("scale",option+1) == 0)
2588 (void) SyncImageSettings(mogrify_info,*image,exception);
2589 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2590 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2594 if (LocaleCompare("selective-blur",option+1) == 0)
2597 Selectively blur pixels within a contrast threshold.
2599 (void) SyncImageSettings(mogrify_info,*image,exception);
2600 flags=ParseGeometry(argv[i+1],&geometry_info);
2601 if ((flags & PercentValue) != 0)
2602 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2603 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2604 geometry_info.sigma,geometry_info.xi,exception);
2607 if (LocaleCompare("separate",option+1) == 0)
2610 Break channels into separate images.
2612 (void) SyncImageSettings(mogrify_info,*image,exception);
2613 mogrify_image=SeparateImages(*image,exception);
2616 if (LocaleCompare("sepia-tone",option+1) == 0)
2624 (void) SyncImageSettings(mogrify_info,*image,exception);
2625 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2627 mogrify_image=SepiaToneImage(*image,threshold,exception);
2630 if (LocaleCompare("segment",option+1) == 0)
2635 (void) SyncImageSettings(mogrify_info,*image,exception);
2636 flags=ParseGeometry(argv[i+1],&geometry_info);
2637 if ((flags & SigmaValue) == 0)
2638 geometry_info.sigma=1.0;
2639 (void) SegmentImage(*image,(*image)->colorspace,
2640 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2644 if (LocaleCompare("set",option+1) == 0)
2654 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2655 (void) DeleteImageRegistry(argv[i+1]+9);
2657 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2659 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2660 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2663 (void) DeleteImageProperty(*image,argv[i+1]);
2666 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2668 if (value == (char *) NULL)
2670 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2671 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2674 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2676 (void) SetImageOption(image_info,argv[i+1]+7,value);
2677 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2678 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2681 (void) SetImageProperty(*image,argv[i+1],value,exception);
2682 value=DestroyString(value);
2685 if (LocaleCompare("shade",option+1) == 0)
2690 (void) SyncImageSettings(mogrify_info,*image,exception);
2691 flags=ParseGeometry(argv[i+1],&geometry_info);
2692 if ((flags & SigmaValue) == 0)
2693 geometry_info.sigma=1.0;
2694 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2695 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2698 if (LocaleCompare("shadow",option+1) == 0)
2703 (void) SyncImageSettings(mogrify_info,*image,exception);
2704 flags=ParseGeometry(argv[i+1],&geometry_info);
2705 if ((flags & SigmaValue) == 0)
2706 geometry_info.sigma=1.0;
2707 if ((flags & XiValue) == 0)
2708 geometry_info.xi=4.0;
2709 if ((flags & PsiValue) == 0)
2710 geometry_info.psi=4.0;
2711 mogrify_image=ShadowImage(*image,geometry_info.rho,
2712 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2713 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2716 if (LocaleCompare("sharpen",option+1) == 0)
2721 (void) SyncImageSettings(mogrify_info,*image,exception);
2722 flags=ParseGeometry(argv[i+1],&geometry_info);
2723 if ((flags & SigmaValue) == 0)
2724 geometry_info.sigma=1.0;
2725 if ((flags & XiValue) == 0)
2726 geometry_info.xi=0.0;
2727 mogrify_image=SharpenImage(*image,geometry_info.rho,
2728 geometry_info.sigma,exception);
2731 if (LocaleCompare("shave",option+1) == 0)
2734 Shave the image edges.
2736 (void) SyncImageSettings(mogrify_info,*image,exception);
2737 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2738 mogrify_image=ShaveImage(*image,&geometry,exception);
2741 if (LocaleCompare("shear",option+1) == 0)
2746 (void) SyncImageSettings(mogrify_info,*image,exception);
2747 flags=ParseGeometry(argv[i+1],&geometry_info);
2748 if ((flags & SigmaValue) == 0)
2749 geometry_info.sigma=geometry_info.rho;
2750 mogrify_image=ShearImage(*image,geometry_info.rho,
2751 geometry_info.sigma,exception);
2754 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2757 Sigmoidal non-linearity contrast control.
2759 (void) SyncImageSettings(mogrify_info,*image,exception);
2760 flags=ParseGeometry(argv[i+1],&geometry_info);
2761 if ((flags & SigmaValue) == 0)
2762 geometry_info.sigma=(double) QuantumRange/2.0;
2763 if ((flags & PercentValue) != 0)
2764 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2766 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2767 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2771 if (LocaleCompare("sketch",option+1) == 0)
2776 (void) SyncImageSettings(mogrify_info,*image,exception);
2777 flags=ParseGeometry(argv[i+1],&geometry_info);
2778 if ((flags & SigmaValue) == 0)
2779 geometry_info.sigma=1.0;
2780 mogrify_image=SketchImage(*image,geometry_info.rho,
2781 geometry_info.sigma,geometry_info.xi,exception);
2784 if (LocaleCompare("solarize",option+1) == 0)
2789 (void) SyncImageSettings(mogrify_info,*image,exception);
2790 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2792 (void) SolarizeImage(*image,threshold,exception);
2795 if (LocaleCompare("sparse-color",option+1) == 0)
2804 Sparse Color Interpolated Gradient
2806 (void) SyncImageSettings(mogrify_info,*image,exception);
2807 method=(SparseColorMethod) ParseCommandOption(
2808 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2809 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2811 if (arguments == (char *) NULL)
2813 mogrify_image=SparseColorOption(*image,method,arguments,
2814 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2815 arguments=DestroyString(arguments);
2818 if (LocaleCompare("splice",option+1) == 0)
2821 Splice a solid color into the image.
2823 (void) SyncImageSettings(mogrify_info,*image,exception);
2824 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2825 mogrify_image=SpliceImage(*image,&geometry,exception);
2828 if (LocaleCompare("spread",option+1) == 0)
2833 (void) SyncImageSettings(mogrify_info,*image,exception);
2834 (void) ParseGeometry(argv[i+1],&geometry_info);
2835 mogrify_image=SpreadImage(*image,geometry_info.rho,
2836 interpolate_method,exception);
2839 if (LocaleCompare("statistic",option+1) == 0)
2844 (void) SyncImageSettings(mogrify_info,*image,exception);
2845 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2846 MagickFalse,argv[i+1]);
2847 (void) ParseGeometry(argv[i+2],&geometry_info);
2848 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2849 (size_t) geometry_info.sigma,exception);
2852 if (LocaleCompare("stretch",option+1) == 0)
2856 draw_info->stretch=UndefinedStretch;
2859 draw_info->stretch=(StretchType) ParseCommandOption(
2860 MagickStretchOptions,MagickFalse,argv[i+1]);
2863 if (LocaleCompare("strip",option+1) == 0)
2866 Strip image of profiles and comments.
2868 (void) SyncImageSettings(mogrify_info,*image,exception);
2869 (void) StripImage(*image,exception);
2872 if (LocaleCompare("stroke",option+1) == 0)
2882 (void) QueryColorCompliance("none",AllCompliance,
2883 &draw_info->stroke,exception);
2884 if (draw_info->stroke_pattern != (Image *) NULL)
2885 draw_info->stroke_pattern=DestroyImage(
2886 draw_info->stroke_pattern);
2889 sans=AcquireExceptionInfo();
2890 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2891 sans=DestroyExceptionInfo(sans);
2892 if (status == MagickFalse)
2893 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2896 draw_info->stroke=color;
2899 if (LocaleCompare("strokewidth",option+1) == 0)
2901 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2904 if (LocaleCompare("style",option+1) == 0)
2908 draw_info->style=UndefinedStyle;
2911 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2912 MagickFalse,argv[i+1]);
2915 if (LocaleCompare("swirl",option+1) == 0)
2920 (void) SyncImageSettings(mogrify_info,*image,exception);
2921 (void) ParseGeometry(argv[i+1],&geometry_info);
2922 mogrify_image=SwirlImage(*image,geometry_info.rho,
2923 interpolate_method,exception);
2930 if (LocaleCompare("threshold",option+1) == 0)
2938 (void) SyncImageSettings(mogrify_info,*image,exception);
2940 threshold=(double) QuantumRange/2;
2942 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2944 (void) BilevelImage(*image,threshold,exception);
2947 if (LocaleCompare("thumbnail",option+1) == 0)
2952 (void) SyncImageSettings(mogrify_info,*image,exception);
2953 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2954 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2958 if (LocaleCompare("tile",option+1) == 0)
2962 if (draw_info->fill_pattern != (Image *) NULL)
2963 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2966 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2970 if (LocaleCompare("tint",option+1) == 0)
2975 (void) SyncImageSettings(mogrify_info,*image,exception);
2976 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2979 if (LocaleCompare("transform",option+1) == 0)
2982 Affine transform image.
2984 (void) SyncImageSettings(mogrify_info,*image,exception);
2985 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2989 if (LocaleCompare("transparent",option+1) == 0)
2994 (void) SyncImageSettings(mogrify_info,*image,exception);
2995 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2997 (void) TransparentPaintImage(*image,&target,(Quantum)
2998 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3002 if (LocaleCompare("transpose",option+1) == 0)
3005 Transpose image scanlines.
3007 (void) SyncImageSettings(mogrify_info,*image,exception);
3008 mogrify_image=TransposeImage(*image,exception);
3011 if (LocaleCompare("transverse",option+1) == 0)
3014 Transverse image scanlines.
3016 (void) SyncImageSettings(mogrify_info,*image,exception);
3017 mogrify_image=TransverseImage(*image,exception);
3020 if (LocaleCompare("treedepth",option+1) == 0)
3022 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3025 if (LocaleCompare("trim",option+1) == 0)
3030 (void) SyncImageSettings(mogrify_info,*image,exception);
3031 mogrify_image=TrimImage(*image,exception);
3034 if (LocaleCompare("type",option+1) == 0)
3039 (void) SyncImageSettings(mogrify_info,*image,exception);
3043 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3045 (*image)->type=UndefinedType;
3046 (void) SetImageType(*image,type,exception);
3053 if (LocaleCompare("undercolor",option+1) == 0)
3055 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3056 &draw_info->undercolor,exception);
3059 if (LocaleCompare("unique",option+1) == 0)
3063 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3066 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3067 (void) SetImageArtifact(*image,"verbose","true");
3070 if (LocaleCompare("unique-colors",option+1) == 0)
3073 Unique image colors.
3075 (void) SyncImageSettings(mogrify_info,*image,exception);
3076 mogrify_image=UniqueImageColors(*image,exception);
3079 if (LocaleCompare("unsharp",option+1) == 0)
3084 (void) SyncImageSettings(mogrify_info,*image,exception);
3085 flags=ParseGeometry(argv[i+1],&geometry_info);
3086 if ((flags & SigmaValue) == 0)
3087 geometry_info.sigma=1.0;
3088 if ((flags & XiValue) == 0)
3089 geometry_info.xi=1.0;
3090 if ((flags & PsiValue) == 0)
3091 geometry_info.psi=0.05;
3092 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3093 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3100 if (LocaleCompare("verbose",option+1) == 0)
3102 (void) SetImageArtifact(*image,option+1,
3103 *option == '+' ? "false" : "true");
3106 if (LocaleCompare("vignette",option+1) == 0)
3111 (void) SyncImageSettings(mogrify_info,*image,exception);
3112 flags=ParseGeometry(argv[i+1],&geometry_info);
3113 if ((flags & SigmaValue) == 0)
3114 geometry_info.sigma=1.0;
3115 if ((flags & XiValue) == 0)
3116 geometry_info.xi=0.1*(*image)->columns;
3117 if ((flags & PsiValue) == 0)
3118 geometry_info.psi=0.1*(*image)->rows;
3119 mogrify_image=VignetteImage(*image,geometry_info.rho,
3120 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3121 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3124 if (LocaleCompare("virtual-pixel",option+1) == 0)
3128 (void) SetImageVirtualPixelMethod(*image,
3129 UndefinedVirtualPixelMethod,exception);
3132 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3133 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3134 argv[i+1]),exception);
3141 if (LocaleCompare("wave",option+1) == 0)
3146 (void) SyncImageSettings(mogrify_info,*image,exception);
3147 flags=ParseGeometry(argv[i+1],&geometry_info);
3148 if ((flags & SigmaValue) == 0)
3149 geometry_info.sigma=1.0;
3150 mogrify_image=WaveImage(*image,geometry_info.rho,
3151 geometry_info.sigma,interpolate_method,exception);
3154 if (LocaleCompare("weight",option+1) == 0)
3156 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3157 if (LocaleCompare(argv[i+1],"all") == 0)
3158 draw_info->weight=0;
3159 if (LocaleCompare(argv[i+1],"bold") == 0)
3160 draw_info->weight=700;
3161 if (LocaleCompare(argv[i+1],"bolder") == 0)
3162 if (draw_info->weight <= 800)
3163 draw_info->weight+=100;
3164 if (LocaleCompare(argv[i+1],"lighter") == 0)
3165 if (draw_info->weight >= 100)
3166 draw_info->weight-=100;
3167 if (LocaleCompare(argv[i+1],"normal") == 0)
3168 draw_info->weight=400;
3171 if (LocaleCompare("white-threshold",option+1) == 0)
3174 White threshold image.
3176 (void) SyncImageSettings(mogrify_info,*image,exception);
3177 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3186 Replace current image with any image that was generated
3188 if (mogrify_image != (Image *) NULL)
3189 ReplaceImageInListReturnLast(image,mogrify_image);
3192 if (region_image != (Image *) NULL)
3195 Composite transformed region onto image.
3197 (void) SyncImageSettings(mogrify_info,*image,exception);
3198 (void) CompositeImage(region_image,*image,region_image->matte !=
3199 MagickFalse ? CopyCompositeOp : OverCompositeOp,MagickTrue,
3200 region_geometry.x,region_geometry.y,exception);
3201 *image=DestroyImage(*image);
3202 *image=region_image;
3203 region_image = (Image *) NULL;
3208 quantize_info=DestroyQuantizeInfo(quantize_info);
3209 draw_info=DestroyDrawInfo(draw_info);
3210 mogrify_info=DestroyImageInfo(mogrify_info);
3211 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3212 return(status == 0 ? MagickFalse : MagickTrue);
3216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 + M o g r i f y I m a g e C o m m a n d %
3224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3226 % MogrifyImageCommand() transforms an image or a sequence of images. These
3227 % transforms include image scaling, image rotation, color reduction, and
3228 % others. The transmogrified image overwrites the original image.
3230 % The format of the MogrifyImageCommand method is:
3232 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3233 % const char **argv,char **metadata,ExceptionInfo *exception)
3235 % A description of each parameter follows:
3237 % o image_info: the image info.
3239 % o argc: the number of elements in the argument vector.
3241 % o argv: A text array containing the command line arguments.
3243 % o metadata: any metadata is returned here.
3245 % o exception: return any errors or warnings in this structure.
3249 static MagickBooleanType MogrifyUsage(void)
3252 *channel_operators[]=
3254 "-channel-fx expression",
3255 " exchange, extract, or transfer one or more image channels",
3256 "-separate separate an image channel into a grayscale image",
3261 "-debug events display copious debugging information",
3262 "-help print program options",
3263 "-list type print a list of supported option arguments",
3264 "-log format format of debugging information",
3265 "-version print version information",
3270 "-adaptive-blur geometry",
3271 " adaptively blur pixels; decrease effect near edges",
3272 "-adaptive-resize geometry",
3273 " adaptively resize image using 'mesh' interpolation",
3274 "-adaptive-sharpen geometry",
3275 " adaptively sharpen pixels; increase effect near edges",
3276 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3277 " transparent, extract, background, or shape",
3278 "-annotate geometry text",
3279 " annotate the image with text",
3280 "-auto-gamma automagically adjust gamma level of image",
3281 "-auto-level automagically adjust color levels of image",
3282 "-auto-orient automagically orient (rotate) image",
3283 "-bench iterations measure performance",
3284 "-black-threshold value",
3285 " force all pixels below the threshold into black",
3286 "-blue-shift simulate a scene at nighttime in the moonlight",
3287 "-blur geometry reduce image noise and reduce detail levels",
3288 "-border geometry surround image with a border of color",
3289 "-bordercolor color border color",
3290 "-brightness-contrast geometry",
3291 " improve brightness / contrast of the image",
3292 "-cdl filename color correct with a color decision list",
3293 "-charcoal geometry simulate a charcoal drawing",
3294 "-chop geometry remove pixels from the image interior",
3295 "-clamp restrict pixel range from 0 to the quantum depth",
3296 "-clip clip along the first path from the 8BIM profile",
3297 "-clip-mask filename associate a clip mask with the image",
3298 "-clip-path id clip along a named path from the 8BIM profile",
3299 "-colorize value colorize the image with the fill color",
3300 "-color-matrix matrix apply color correction to the image",
3301 "-contrast enhance or reduce the image contrast",
3302 "-contrast-stretch geometry",
3303 " improve contrast by 'stretching' the intensity range",
3304 "-convolve coefficients",
3305 " apply a convolution kernel to the image",
3306 "-cycle amount cycle the image colormap",
3307 "-decipher filename convert cipher pixels to plain pixels",
3308 "-deskew threshold straighten an image",
3309 "-despeckle reduce the speckles within an image",
3310 "-distort method args",
3311 " distort images according to given method ad args",
3312 "-draw string annotate the image with a graphic primitive",
3313 "-edge radius apply a filter to detect edges in the image",
3314 "-encipher filename convert plain pixels to cipher pixels",
3315 "-emboss radius emboss an image",
3316 "-enhance apply a digital filter to enhance a noisy image",
3317 "-equalize perform histogram equalization to an image",
3318 "-evaluate operator value",
3319 " evaluate an arithmetic, relational, or logical expression",
3320 "-extent geometry set the image size",
3321 "-extract geometry extract area from image",
3322 "-fft implements the discrete Fourier transform (DFT)",
3323 "-flip flip image vertically",
3324 "-floodfill geometry color",
3325 " floodfill the image with color",
3326 "-flop flop image horizontally",
3327 "-frame geometry surround image with an ornamental border",
3328 "-function name parameters",
3329 " apply function over image values",
3330 "-gamma value level of gamma correction",
3331 "-gaussian-blur geometry",
3332 " reduce image noise and reduce detail levels",
3333 "-geometry geometry preferred size or location of the image",
3334 "-identify identify the format and characteristics of the image",
3335 "-ift implements the inverse discrete Fourier transform (DFT)",
3336 "-implode amount implode image pixels about the center",
3337 "-interpolative-resize geometry",
3338 " resize image using interpolation",
3339 "-lat geometry local adaptive thresholding",
3340 "-layers method optimize, merge, or compare image layers",
3341 "-level value adjust the level of image contrast",
3342 "-level-colors color,color",
3343 " level image with the given colors",
3344 "-linear-stretch geometry",
3345 " improve contrast by 'stretching with saturation'",
3346 "-liquid-rescale geometry",
3347 " rescale image with seam-carving",
3348 "-median geometry apply a median filter to the image",
3349 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3350 "-modulate value vary the brightness, saturation, and hue",
3351 "-monochrome transform image to black and white",
3352 "-morphology method kernel",
3353 " apply a morphology method to the image",
3354 "-motion-blur geometry",
3355 " simulate motion blur",
3356 "-negate replace every pixel with its complementary color ",
3357 "-noise geometry add or reduce noise in an image",
3358 "-normalize transform image to span the full range of colors",
3359 "-opaque color change this color to the fill color",
3360 "-ordered-dither NxN",
3361 " add a noise pattern to the image with specific",
3363 "-paint radius simulate an oil painting",
3364 "-polaroid angle simulate a Polaroid picture",
3365 "-posterize levels reduce the image to a limited number of color levels",
3366 "-profile filename add, delete, or apply an image profile",
3367 "-quantize colorspace reduce colors in this colorspace",
3368 "-radial-blur angle radial blur the image",
3369 "-raise value lighten/darken image edges to create a 3-D effect",
3370 "-random-threshold low,high",
3371 " random threshold the image",
3372 "-region geometry apply options to a portion of the image",
3373 "-render render vector graphics",
3374 "-repage geometry size and location of an image canvas",
3375 "-resample geometry change the resolution of an image",
3376 "-resize geometry resize the image",
3377 "-roll geometry roll an image vertically or horizontally",
3378 "-rotate degrees apply Paeth rotation to the image",
3379 "-sample geometry scale image with pixel sampling",
3380 "-scale geometry scale the image",
3381 "-segment values segment an image",
3382 "-selective-blur geometry",
3383 " selectively blur pixels within a contrast threshold",
3384 "-sepia-tone threshold",
3385 " simulate a sepia-toned photo",
3386 "-set property value set an image property",
3387 "-shade degrees shade the image using a distant light source",
3388 "-shadow geometry simulate an image shadow",
3389 "-sharpen geometry sharpen the image",
3390 "-shave geometry shave pixels from the image edges",
3391 "-shear geometry slide one edge of the image along the X or Y axis",
3392 "-sigmoidal-contrast geometry",
3393 " increase the contrast without saturating highlights or shadows",
3394 "-sketch geometry simulate a pencil sketch",
3395 "-solarize threshold negate all pixels above the threshold level",
3396 "-sparse-color method args",
3397 " fill in a image based on a few color points",
3398 "-splice geometry splice the background color into the image",
3399 "-spread radius displace image pixels by a random amount",
3400 "-statistic type radius",
3401 " replace each pixel with corresponding statistic from the neighborhood",
3402 "-strip strip image of all profiles and comments",
3403 "-swirl degrees swirl image pixels about the center",
3404 "-threshold value threshold the image",
3405 "-thumbnail geometry create a thumbnail of the image",
3406 "-tile filename tile image when filling a graphic primitive",
3407 "-tint value tint the image with the fill color",
3408 "-transform affine transform image",
3409 "-transparent color make this color transparent within the image",
3410 "-transpose flip image vertically and rotate 90 degrees",
3411 "-transverse flop image horizontally and rotate 270 degrees",
3412 "-trim trim image edges",
3413 "-type type image type",
3414 "-unique-colors discard all but one of any pixel color",
3415 "-unsharp geometry sharpen the image",
3416 "-vignette geometry soften the edges of the image in vignette style",
3417 "-wave geometry alter an image along a sine wave",
3418 "-white-threshold value",
3419 " force all pixels above the threshold into white",
3422 *sequence_operators[]=
3424 "-append append an image sequence",
3425 "-clut apply a color lookup table to the image",
3426 "-coalesce merge a sequence of images",
3427 "-combine combine a sequence of images",
3428 "-composite composite image",
3429 "-crop geometry cut out a rectangular region of the image",
3430 "-deconstruct break down an image sequence into constituent parts",
3431 "-evaluate-sequence operator",
3432 " evaluate an arithmetic, relational, or logical expression",
3433 "-flatten flatten a sequence of images",
3434 "-fx expression apply mathematical expression to an image channel(s)",
3435 "-hald-clut apply a Hald color lookup table to the image",
3436 "-morph value morph an image sequence",
3437 "-mosaic create a mosaic from an image sequence",
3438 "-print string interpret string and print to console",
3439 "-process arguments process the image with a custom image filter",
3440 "-smush geometry smush an image sequence together",
3441 "-write filename write images to this file",
3446 "-adjoin join images into a single multi-image file",
3447 "-affine matrix affine transform matrix",
3448 "-alpha option activate, deactivate, reset, or set the alpha channel",
3449 "-antialias remove pixel-aliasing",
3450 "-authenticate password",
3451 " decipher image with this password",
3452 "-attenuate value lessen (or intensify) when adding noise to an image",
3453 "-background color background color",
3454 "-bias value add bias when convolving an image",
3455 "-black-point-compensation",
3456 " use black point compensation",
3457 "-blue-primary point chromaticity blue primary point",
3458 "-bordercolor color border color",
3459 "-caption string assign a caption to an image",
3460 "-channel type apply option to select image channels",
3461 "-colors value preferred number of colors in the image",
3462 "-colorspace type alternate image colorspace",
3463 "-comment string annotate image with comment",
3464 "-compose operator set image composite operator",
3465 "-compress type type of pixel compression when writing the image",
3466 "-define format:option=value",
3467 " define one or more image format options",
3468 "-delay value display the next image after pausing",
3469 "-density geometry horizontal and vertical density of the image",
3470 "-depth value image depth",
3471 "-direction type render text right-to-left or left-to-right",
3472 "-display server get image or font from this X server",
3473 "-dispose method layer disposal method",
3474 "-dither method apply error diffusion to image",
3475 "-encoding type text encoding type",
3476 "-endian type endianness (MSB or LSB) of the image",
3477 "-family name render text with this font family",
3478 "-fill color color to use when filling a graphic primitive",
3479 "-filter type use this filter when resizing an image",
3480 "-font name render text with this font",
3481 "-format \"string\" output formatted image characteristics",
3482 "-fuzz distance colors within this distance are considered equal",
3483 "-gravity type horizontal and vertical text placement",
3484 "-green-primary point chromaticity green primary point",
3485 "-intent type type of rendering intent when managing the image color",
3486 "-interlace type type of image interlacing scheme",
3487 "-interline-spacing value",
3488 " set the space between two text lines",
3489 "-interpolate method pixel color interpolation method",
3490 "-interword-spacing value",
3491 " set the space between two words",
3492 "-kerning value set the space between two letters",
3493 "-label string assign a label to an image",
3494 "-limit type value pixel cache resource limit",
3495 "-loop iterations add Netscape loop extension to your GIF animation",
3496 "-mask filename associate a mask with the image",
3497 "-mattecolor color frame color",
3498 "-monitor monitor progress",
3499 "-orient type image orientation",
3500 "-page geometry size and location of an image canvas (setting)",
3501 "-ping efficiently determine image attributes",
3502 "-pointsize value font point size",
3503 "-precision value maximum number of significant digits to print",
3504 "-preview type image preview type",
3505 "-quality value JPEG/MIFF/PNG compression level",
3506 "-quiet suppress all warning messages",
3507 "-red-primary point chromaticity red primary point",
3508 "-regard-warnings pay attention to warning messages",
3509 "-remap filename transform image colors to match this set of colors",
3510 "-respect-parentheses settings remain in effect until parenthesis boundary",
3511 "-sampling-factor geometry",
3512 " horizontal and vertical sampling factor",
3513 "-scene value image scene number",
3514 "-seed value seed a new sequence of pseudo-random numbers",
3515 "-size geometry width and height of image",
3516 "-stretch type render text with this font stretch",
3517 "-stroke color graphic primitive stroke color",
3518 "-strokewidth value graphic primitive stroke width",
3519 "-style type render text with this font style",
3520 "-synchronize synchronize image to storage device",
3521 "-taint declare the image as modified",
3522 "-texture filename name of texture to tile onto the image background",
3523 "-tile-offset geometry",
3525 "-treedepth value color tree depth",
3526 "-transparent-color color",
3527 " transparent color",
3528 "-undercolor color annotation bounding box color",
3529 "-units type the units of image resolution",
3530 "-verbose print detailed information about the image",
3531 "-view FlashPix viewing transforms",
3532 "-virtual-pixel method",
3533 " virtual pixel access method",
3534 "-weight type render text with this font weight",
3535 "-white-point point chromaticity white point",
3540 "-delete indexes delete the image from the image sequence",
3541 "-duplicate count,indexes",
3542 " duplicate an image one or more times",
3543 "-insert index insert last image into the image sequence",
3544 "-reverse reverse image sequence",
3545 "-swap indexes swap two images in the image sequence",
3552 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3553 (void) printf("Copyright: %s\n",GetMagickCopyright());
3554 (void) printf("Features: %s\n\n",GetMagickFeatures());
3555 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3557 (void) printf("\nImage Settings:\n");
3558 for (p=settings; *p != (char *) NULL; p++)
3559 (void) printf(" %s\n",*p);
3560 (void) printf("\nImage Operators:\n");
3561 for (p=operators; *p != (char *) NULL; p++)
3562 (void) printf(" %s\n",*p);
3563 (void) printf("\nImage Channel Operators:\n");
3564 for (p=channel_operators; *p != (char *) NULL; p++)
3565 (void) printf(" %s\n",*p);
3566 (void) printf("\nImage Sequence Operators:\n");
3567 for (p=sequence_operators; *p != (char *) NULL; p++)
3568 (void) printf(" %s\n",*p);
3569 (void) printf("\nImage Stack Operators:\n");
3570 for (p=stack_operators; *p != (char *) NULL; p++)
3571 (void) printf(" %s\n",*p);
3572 (void) printf("\nMiscellaneous Options:\n");
3573 for (p=miscellaneous; *p != (char *) NULL; p++)
3574 (void) printf(" %s\n",*p);
3576 "\nBy default, the image format of 'file' is determined by its magic\n");
3578 "number. To specify a particular image format, precede the filename\n");
3580 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3582 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3583 (void) printf("'-' for standard input or output.\n");
3584 return(MagickFalse);
3587 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3588 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3590 #define DestroyMogrify() \
3592 if (format != (char *) NULL) \
3593 format=DestroyString(format); \
3594 if (path != (char *) NULL) \
3595 path=DestroyString(path); \
3596 DestroyImageStack(); \
3597 for (i=0; i < (ssize_t) argc; i++) \
3598 argv[i]=DestroyString(argv[i]); \
3599 argv=(char **) RelinquishMagickMemory(argv); \
3601 #define ThrowMogrifyException(asperity,tag,option) \
3603 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
3606 return(MagickFalse); \
3608 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3610 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3611 "InvalidArgument","'%s': %s",argument,option); \
3613 return(MagickFalse); \
3625 image_stack[MaxImageStackDepth+1];
3633 respect_parenthesis;
3648 assert(image_info != (ImageInfo *) NULL);
3649 assert(image_info->signature == MagickSignature);
3650 if (image_info->debug != MagickFalse)
3651 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3652 assert(exception != (ExceptionInfo *) NULL);
3656 if ((LocaleCompare("version",option+1) == 0) ||
3657 (LocaleCompare("-version",option+1) == 0))
3659 (void) FormatLocaleFile(stdout,"Version: %s\n",
3660 GetMagickVersion((size_t *) NULL));
3661 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3662 GetMagickCopyright());
3663 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3664 GetMagickFeatures());
3665 return(MagickFalse);
3669 return(MogrifyUsage());
3670 format=(char *) NULL;
3672 global_colormap=MagickFalse;
3676 option=(char *) NULL;
3678 respect_parenthesis=MagickFalse;
3683 ReadCommandlLine(argc,&argv);
3684 status=ExpandFilenames(&argc,&argv);
3685 if (status == MagickFalse)
3686 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3687 GetExceptionMessage(errno));
3688 for (i=1; i < (ssize_t) argc; i++)
3691 if (LocaleCompare(option,"(") == 0)
3693 FireImageStack(MagickFalse,MagickTrue,pend);
3694 if (k == MaxImageStackDepth)
3695 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3700 if (LocaleCompare(option,")") == 0)
3702 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3704 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3708 if (IsCommandOption(option) == MagickFalse)
3711 backup_filename[MaxTextExtent],
3718 Option is a file name: begin by reading image from specified file.
3720 FireImageStack(MagickFalse,MagickFalse,pend);
3722 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3724 images=ReadImages(image_info,filename,exception);
3725 status&=(images != (Image *) NULL) &&
3726 (exception->severity < ErrorException);
3727 if (images == (Image *) NULL)
3729 if (format != (char *) NULL)
3730 (void) CopyMagickString(images->filename,images->magick_filename,
3732 if (path != (char *) NULL)
3734 GetPathComponent(option,TailPath,filename);
3735 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3736 path,*DirectorySeparator,filename);
3738 if (format != (char *) NULL)
3739 AppendImageFormat(format,images->filename);
3740 AppendImageStack(images);
3741 FinalizeImageSettings(image_info,image,MagickFalse);
3742 if (global_colormap != MagickFalse)
3747 quantize_info=AcquireQuantizeInfo(image_info);
3748 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3749 quantize_info=DestroyQuantizeInfo(quantize_info);
3751 *backup_filename='\0';
3752 if ((LocaleCompare(image->filename,"-") != 0) &&
3753 (IsPathWritable(image->filename) != MagickFalse))
3759 Rename image file as backup.
3761 (void) CopyMagickString(backup_filename,image->filename,
3763 for (i=0; i < 6; i++)
3765 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3766 if (IsPathAccessible(backup_filename) == MagickFalse)
3769 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3770 (rename_utf8(image->filename,backup_filename) != 0))
3771 *backup_filename='\0';
3774 Write transmogrified image to disk.
3776 image_info->synchronize=MagickTrue;
3777 status&=WriteImages(image_info,image,image->filename,exception);
3778 if ((status == MagickFalse) && (*backup_filename != '\0'))
3779 (void) remove_utf8(backup_filename);
3780 RemoveAllImageStack();
3783 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3784 switch (*(option+1))
3788 if (LocaleCompare("adaptive-blur",option+1) == 0)
3791 if (i == (ssize_t) argc)
3792 ThrowMogrifyException(OptionError,"MissingArgument",option);
3793 if (IsGeometry(argv[i]) == MagickFalse)
3794 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3797 if (LocaleCompare("adaptive-resize",option+1) == 0)
3800 if (i == (ssize_t) argc)
3801 ThrowMogrifyException(OptionError,"MissingArgument",option);
3802 if (IsGeometry(argv[i]) == MagickFalse)
3803 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3806 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3809 if (i == (ssize_t) argc)
3810 ThrowMogrifyException(OptionError,"MissingArgument",option);
3811 if (IsGeometry(argv[i]) == MagickFalse)
3812 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3815 if (LocaleCompare("affine",option+1) == 0)
3820 if (i == (ssize_t) argc)
3821 ThrowMogrifyException(OptionError,"MissingArgument",option);
3824 if (LocaleCompare("alpha",option+1) == 0)
3832 if (i == (ssize_t) argc)
3833 ThrowMogrifyException(OptionError,"MissingArgument",option);
3834 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3836 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3840 if (LocaleCompare("annotate",option+1) == 0)
3845 if (i == (ssize_t) argc)
3846 ThrowMogrifyException(OptionError,"MissingArgument",option);
3847 if (IsGeometry(argv[i]) == MagickFalse)
3848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3849 if (i == (ssize_t) argc)
3850 ThrowMogrifyException(OptionError,"MissingArgument",option);
3854 if (LocaleCompare("antialias",option+1) == 0)
3856 if (LocaleCompare("append",option+1) == 0)
3858 if (LocaleCompare("attenuate",option+1) == 0)
3863 if (i == (ssize_t) (argc-1))
3864 ThrowMogrifyException(OptionError,"MissingArgument",option);
3865 if (IsGeometry(argv[i]) == MagickFalse)
3866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3869 if (LocaleCompare("authenticate",option+1) == 0)
3874 if (i == (ssize_t) argc)
3875 ThrowMogrifyException(OptionError,"MissingArgument",option);
3878 if (LocaleCompare("auto-gamma",option+1) == 0)
3880 if (LocaleCompare("auto-level",option+1) == 0)
3882 if (LocaleCompare("auto-orient",option+1) == 0)
3884 if (LocaleCompare("average",option+1) == 0)
3886 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3890 if (LocaleCompare("background",option+1) == 0)
3895 if (i == (ssize_t) argc)
3896 ThrowMogrifyException(OptionError,"MissingArgument",option);
3899 if (LocaleCompare("bias",option+1) == 0)
3904 if (i == (ssize_t) (argc-1))
3905 ThrowMogrifyException(OptionError,"MissingArgument",option);
3906 if (IsGeometry(argv[i]) == MagickFalse)
3907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3910 if (LocaleCompare("black-point-compensation",option+1) == 0)
3912 if (LocaleCompare("black-threshold",option+1) == 0)
3917 if (i == (ssize_t) argc)
3918 ThrowMogrifyException(OptionError,"MissingArgument",option);
3919 if (IsGeometry(argv[i]) == MagickFalse)
3920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3923 if (LocaleCompare("blue-primary",option+1) == 0)
3928 if (i == (ssize_t) argc)
3929 ThrowMogrifyException(OptionError,"MissingArgument",option);
3930 if (IsGeometry(argv[i]) == MagickFalse)
3931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 if (LocaleCompare("blue-shift",option+1) == 0)
3937 if (i == (ssize_t) argc)
3938 ThrowMogrifyException(OptionError,"MissingArgument",option);
3939 if (IsGeometry(argv[i]) == MagickFalse)
3940 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3943 if (LocaleCompare("blur",option+1) == 0)
3946 if (i == (ssize_t) argc)
3947 ThrowMogrifyException(OptionError,"MissingArgument",option);
3948 if (IsGeometry(argv[i]) == MagickFalse)
3949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3952 if (LocaleCompare("border",option+1) == 0)
3957 if (i == (ssize_t) argc)
3958 ThrowMogrifyException(OptionError,"MissingArgument",option);
3959 if (IsGeometry(argv[i]) == MagickFalse)
3960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3963 if (LocaleCompare("bordercolor",option+1) == 0)
3968 if (i == (ssize_t) argc)
3969 ThrowMogrifyException(OptionError,"MissingArgument",option);
3972 if (LocaleCompare("box",option+1) == 0)
3977 if (i == (ssize_t) argc)
3978 ThrowMogrifyException(OptionError,"MissingArgument",option);
3981 if (LocaleCompare("brightness-contrast",option+1) == 0)
3984 if (i == (ssize_t) argc)
3985 ThrowMogrifyException(OptionError,"MissingArgument",option);
3986 if (IsGeometry(argv[i]) == MagickFalse)
3987 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3990 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3994 if (LocaleCompare("cache",option+1) == 0)
3999 if (i == (ssize_t) argc)
4000 ThrowMogrifyException(OptionError,"MissingArgument",option);
4001 if (IsGeometry(argv[i]) == MagickFalse)
4002 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4005 if (LocaleCompare("caption",option+1) == 0)
4010 if (i == (ssize_t) argc)
4011 ThrowMogrifyException(OptionError,"MissingArgument",option);
4014 if (LocaleCompare("channel",option+1) == 0)
4022 if (i == (ssize_t) (argc-1))
4023 ThrowMogrifyException(OptionError,"MissingArgument",option);
4024 channel=ParseChannelOption(argv[i]);
4026 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4030 if (LocaleCompare("channel-fx",option+1) == 0)
4038 if (i == (ssize_t) (argc-1))
4039 ThrowMogrifyException(OptionError,"MissingArgument",option);
4040 channel=ParsePixelChannelOption(argv[i]);
4042 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4046 if (LocaleCompare("cdl",option+1) == 0)
4051 if (i == (ssize_t) (argc-1))
4052 ThrowMogrifyException(OptionError,"MissingArgument",option);
4055 if (LocaleCompare("charcoal",option+1) == 0)
4060 if (i == (ssize_t) argc)
4061 ThrowMogrifyException(OptionError,"MissingArgument",option);
4062 if (IsGeometry(argv[i]) == MagickFalse)
4063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4066 if (LocaleCompare("chop",option+1) == 0)
4071 if (i == (ssize_t) argc)
4072 ThrowMogrifyException(OptionError,"MissingArgument",option);
4073 if (IsGeometry(argv[i]) == MagickFalse)
4074 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4077 if (LocaleCompare("clamp",option+1) == 0)
4079 if (LocaleCompare("clip",option+1) == 0)
4081 if (LocaleCompare("clip-mask",option+1) == 0)
4086 if (i == (ssize_t) argc)
4087 ThrowMogrifyException(OptionError,"MissingArgument",option);
4090 if (LocaleCompare("clut",option+1) == 0)
4092 if (LocaleCompare("coalesce",option+1) == 0)
4094 if (LocaleCompare("colorize",option+1) == 0)
4099 if (i == (ssize_t) argc)
4100 ThrowMogrifyException(OptionError,"MissingArgument",option);
4101 if (IsGeometry(argv[i]) == MagickFalse)
4102 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4105 if (LocaleCompare("color-matrix",option+1) == 0)
4113 if (i == (ssize_t) (argc-1))
4114 ThrowMogrifyException(OptionError,"MissingArgument",option);
4115 kernel_info=AcquireKernelInfo(argv[i]);
4116 if (kernel_info == (KernelInfo *) NULL)
4117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4118 kernel_info=DestroyKernelInfo(kernel_info);
4121 if (LocaleCompare("colors",option+1) == 0)
4126 if (i == (ssize_t) argc)
4127 ThrowMogrifyException(OptionError,"MissingArgument",option);
4128 if (IsGeometry(argv[i]) == MagickFalse)
4129 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4132 if (LocaleCompare("colorspace",option+1) == 0)
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,"MissingArgument",option);
4142 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4145 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4149 if (LocaleCompare("combine",option+1) == 0)
4151 if (LocaleCompare("comment",option+1) == 0)
4156 if (i == (ssize_t) argc)
4157 ThrowMogrifyException(OptionError,"MissingArgument",option);
4160 if (LocaleCompare("composite",option+1) == 0)
4162 if (LocaleCompare("compress",option+1) == 0)
4170 if (i == (ssize_t) argc)
4171 ThrowMogrifyException(OptionError,"MissingArgument",option);
4172 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4175 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4179 if (LocaleCompare("concurrent",option+1) == 0)
4181 if (LocaleCompare("contrast",option+1) == 0)
4183 if (LocaleCompare("contrast-stretch",option+1) == 0)
4186 if (i == (ssize_t) argc)
4187 ThrowMogrifyException(OptionError,"MissingArgument",option);
4188 if (IsGeometry(argv[i]) == MagickFalse)
4189 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4192 if (LocaleCompare("convolve",option+1) == 0)
4200 if (i == (ssize_t) argc)
4201 ThrowMogrifyException(OptionError,"MissingArgument",option);
4202 kernel_info=AcquireKernelInfo(argv[i]);
4203 if (kernel_info == (KernelInfo *) NULL)
4204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4205 kernel_info=DestroyKernelInfo(kernel_info);
4208 if (LocaleCompare("crop",option+1) == 0)
4213 if (i == (ssize_t) argc)
4214 ThrowMogrifyException(OptionError,"MissingArgument",option);
4215 if (IsGeometry(argv[i]) == MagickFalse)
4216 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4219 if (LocaleCompare("cycle",option+1) == 0)
4224 if (i == (ssize_t) argc)
4225 ThrowMogrifyException(OptionError,"MissingArgument",option);
4226 if (IsGeometry(argv[i]) == MagickFalse)
4227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4230 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4234 if (LocaleCompare("decipher",option+1) == 0)
4239 if (i == (ssize_t) (argc-1))
4240 ThrowMogrifyException(OptionError,"MissingArgument",option);
4243 if (LocaleCompare("deconstruct",option+1) == 0)
4245 if (LocaleCompare("debug",option+1) == 0)
4253 if (i == (ssize_t) argc)
4254 ThrowMogrifyException(OptionError,"MissingArgument",option);
4255 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4257 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4259 (void) SetLogEventMask(argv[i]);
4262 if (LocaleCompare("define",option+1) == 0)
4265 if (i == (ssize_t) argc)
4266 ThrowMogrifyException(OptionError,"MissingArgument",option);
4272 define=GetImageOption(image_info,argv[i]);
4273 if (define == (const char *) NULL)
4274 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4279 if (LocaleCompare("delay",option+1) == 0)
4284 if (i == (ssize_t) argc)
4285 ThrowMogrifyException(OptionError,"MissingArgument",option);
4286 if (IsGeometry(argv[i]) == MagickFalse)
4287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4290 if (LocaleCompare("delete",option+1) == 0)
4295 if (i == (ssize_t) (argc-1))
4296 ThrowMogrifyException(OptionError,"MissingArgument",option);
4297 if (IsGeometry(argv[i]) == MagickFalse)
4298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4301 if (LocaleCompare("density",option+1) == 0)
4306 if (i == (ssize_t) argc)
4307 ThrowMogrifyException(OptionError,"MissingArgument",option);
4308 if (IsGeometry(argv[i]) == MagickFalse)
4309 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4312 if (LocaleCompare("depth",option+1) == 0)
4317 if (i == (ssize_t) argc)
4318 ThrowMogrifyException(OptionError,"MissingArgument",option);
4319 if (IsGeometry(argv[i]) == MagickFalse)
4320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4323 if (LocaleCompare("deskew",option+1) == 0)
4328 if (i == (ssize_t) argc)
4329 ThrowMogrifyException(OptionError,"MissingArgument",option);
4330 if (IsGeometry(argv[i]) == MagickFalse)
4331 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4334 if (LocaleCompare("despeckle",option+1) == 0)
4336 if (LocaleCompare("dft",option+1) == 0)
4338 if (LocaleCompare("direction",option+1) == 0)
4346 if (i == (ssize_t) argc)
4347 ThrowMogrifyException(OptionError,"MissingArgument",option);
4348 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4351 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4355 if (LocaleCompare("display",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4364 if (LocaleCompare("dispose",option+1) == 0)
4372 if (i == (ssize_t) argc)
4373 ThrowMogrifyException(OptionError,"MissingArgument",option);
4374 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4376 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4380 if (LocaleCompare("distort",option+1) == 0)
4386 if (i == (ssize_t) argc)
4387 ThrowMogrifyException(OptionError,"MissingArgument",option);
4388 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4390 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4393 if (i == (ssize_t) (argc-1))
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4397 if (LocaleCompare("dither",option+1) == 0)
4405 if (i == (ssize_t) argc)
4406 ThrowMogrifyException(OptionError,"MissingArgument",option);
4407 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4409 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4413 if (LocaleCompare("draw",option+1) == 0)
4418 if (i == (ssize_t) argc)
4419 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (LocaleCompare("duplicate",option+1) == 0)
4427 if (i == (ssize_t) (argc-1))
4428 ThrowMogrifyException(OptionError,"MissingArgument",option);
4429 if (IsGeometry(argv[i]) == MagickFalse)
4430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4433 if (LocaleCompare("duration",option+1) == 0)
4438 if (i == (ssize_t) (argc-1))
4439 ThrowMogrifyException(OptionError,"MissingArgument",option);
4440 if (IsGeometry(argv[i]) == MagickFalse)
4441 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4444 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4448 if (LocaleCompare("edge",option+1) == 0)
4453 if (i == (ssize_t) argc)
4454 ThrowMogrifyException(OptionError,"MissingArgument",option);
4455 if (IsGeometry(argv[i]) == MagickFalse)
4456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4459 if (LocaleCompare("emboss",option+1) == 0)
4464 if (i == (ssize_t) argc)
4465 ThrowMogrifyException(OptionError,"MissingArgument",option);
4466 if (IsGeometry(argv[i]) == MagickFalse)
4467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4470 if (LocaleCompare("encipher",option+1) == 0)
4475 if (i == (ssize_t) argc)
4476 ThrowMogrifyException(OptionError,"MissingArgument",option);
4479 if (LocaleCompare("encoding",option+1) == 0)
4484 if (i == (ssize_t) argc)
4485 ThrowMogrifyException(OptionError,"MissingArgument",option);
4488 if (LocaleCompare("endian",option+1) == 0)
4496 if (i == (ssize_t) argc)
4497 ThrowMogrifyException(OptionError,"MissingArgument",option);
4498 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4500 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4504 if (LocaleCompare("enhance",option+1) == 0)
4506 if (LocaleCompare("equalize",option+1) == 0)
4508 if (LocaleCompare("evaluate",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4518 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4520 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4523 if (i == (ssize_t) (argc-1))
4524 ThrowMogrifyException(OptionError,"MissingArgument",option);
4525 if (IsGeometry(argv[i]) == MagickFalse)
4526 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4529 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4541 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4545 if (LocaleCompare("extent",option+1) == 0)
4550 if (i == (ssize_t) argc)
4551 ThrowMogrifyException(OptionError,"MissingArgument",option);
4552 if (IsGeometry(argv[i]) == MagickFalse)
4553 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4556 if (LocaleCompare("extract",option+1) == 0)
4561 if (i == (ssize_t) argc)
4562 ThrowMogrifyException(OptionError,"MissingArgument",option);
4563 if (IsGeometry(argv[i]) == MagickFalse)
4564 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4567 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4571 if (LocaleCompare("family",option+1) == 0)
4576 if (i == (ssize_t) (argc-1))
4577 ThrowMogrifyException(OptionError,"MissingArgument",option);
4580 if (LocaleCompare("fill",option+1) == 0)
4585 if (i == (ssize_t) argc)
4586 ThrowMogrifyException(OptionError,"MissingArgument",option);
4589 if (LocaleCompare("filter",option+1) == 0)
4597 if (i == (ssize_t) argc)
4598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4601 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4605 if (LocaleCompare("flatten",option+1) == 0)
4607 if (LocaleCompare("flip",option+1) == 0)
4609 if (LocaleCompare("flop",option+1) == 0)
4611 if (LocaleCompare("floodfill",option+1) == 0)
4616 if (i == (ssize_t) argc)
4617 ThrowMogrifyException(OptionError,"MissingArgument",option);
4618 if (IsGeometry(argv[i]) == MagickFalse)
4619 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4621 if (i == (ssize_t) argc)
4622 ThrowMogrifyException(OptionError,"MissingArgument",option);
4625 if (LocaleCompare("font",option+1) == 0)
4630 if (i == (ssize_t) argc)
4631 ThrowMogrifyException(OptionError,"MissingArgument",option);
4634 if (LocaleCompare("format",option+1) == 0)
4636 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4637 (void) CloneString(&format,(char *) NULL);
4641 if (i == (ssize_t) argc)
4642 ThrowMogrifyException(OptionError,"MissingArgument",option);
4643 (void) CloneString(&format,argv[i]);
4644 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4645 (void) ConcatenateMagickString(image_info->filename,":",
4647 (void) SetImageInfo(image_info,0,exception);
4648 if (*image_info->magick == '\0')
4649 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4653 if (LocaleCompare("frame",option+1) == 0)
4658 if (i == (ssize_t) argc)
4659 ThrowMogrifyException(OptionError,"MissingArgument",option);
4660 if (IsGeometry(argv[i]) == MagickFalse)
4661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4664 if (LocaleCompare("function",option+1) == 0)
4672 if (i == (ssize_t) argc)
4673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4674 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4676 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4678 if (i == (ssize_t) (argc-1))
4679 ThrowMogrifyException(OptionError,"MissingArgument",option);
4682 if (LocaleCompare("fuzz",option+1) == 0)
4687 if (i == (ssize_t) argc)
4688 ThrowMogrifyException(OptionError,"MissingArgument",option);
4689 if (IsGeometry(argv[i]) == MagickFalse)
4690 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4693 if (LocaleCompare("fx",option+1) == 0)
4698 if (i == (ssize_t) (argc-1))
4699 ThrowMogrifyException(OptionError,"MissingArgument",option);
4702 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4706 if (LocaleCompare("gamma",option+1) == 0)
4709 if (i == (ssize_t) argc)
4710 ThrowMogrifyException(OptionError,"MissingArgument",option);
4711 if (IsGeometry(argv[i]) == MagickFalse)
4712 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4715 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4716 (LocaleCompare("gaussian",option+1) == 0))
4719 if (i == (ssize_t) argc)
4720 ThrowMogrifyException(OptionError,"MissingArgument",option);
4721 if (IsGeometry(argv[i]) == MagickFalse)
4722 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4725 if (LocaleCompare("geometry",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("gravity",option+1) == 0)
4744 if (i == (ssize_t) argc)
4745 ThrowMogrifyException(OptionError,"MissingArgument",option);
4746 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4748 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4752 if (LocaleCompare("green-primary",option+1) == 0)
4757 if (i == (ssize_t) argc)
4758 ThrowMogrifyException(OptionError,"MissingArgument",option);
4759 if (IsGeometry(argv[i]) == MagickFalse)
4760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4763 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4767 if (LocaleCompare("hald-clut",option+1) == 0)
4769 if ((LocaleCompare("help",option+1) == 0) ||
4770 (LocaleCompare("-help",option+1) == 0))
4771 return(MogrifyUsage());
4772 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4776 if (LocaleCompare("identify",option+1) == 0)
4778 if (LocaleCompare("idft",option+1) == 0)
4780 if (LocaleCompare("implode",option+1) == 0)
4785 if (i == (ssize_t) argc)
4786 ThrowMogrifyException(OptionError,"MissingArgument",option);
4787 if (IsGeometry(argv[i]) == MagickFalse)
4788 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4791 if (LocaleCompare("intent",option+1) == 0)
4799 if (i == (ssize_t) (argc-1))
4800 ThrowMogrifyException(OptionError,"MissingArgument",option);
4801 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4803 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4807 if (LocaleCompare("interlace",option+1) == 0)
4815 if (i == (ssize_t) argc)
4816 ThrowMogrifyException(OptionError,"MissingArgument",option);
4817 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4820 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4824 if (LocaleCompare("interline-spacing",option+1) == 0)
4829 if (i == (ssize_t) (argc-1))
4830 ThrowMogrifyException(OptionError,"MissingArgument",option);
4831 if (IsGeometry(argv[i]) == MagickFalse)
4832 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4835 if (LocaleCompare("interpolate",option+1) == 0)
4843 if (i == (ssize_t) argc)
4844 ThrowMogrifyException(OptionError,"MissingArgument",option);
4845 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4847 if (interpolate < 0)
4848 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4852 if (LocaleCompare("interword-spacing",option+1) == 0)
4857 if (i == (ssize_t) (argc-1))
4858 ThrowMogrifyException(OptionError,"MissingArgument",option);
4859 if (IsGeometry(argv[i]) == MagickFalse)
4860 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4863 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4867 if (LocaleCompare("kerning",option+1) == 0)
4872 if (i == (ssize_t) (argc-1))
4873 ThrowMogrifyException(OptionError,"MissingArgument",option);
4874 if (IsGeometry(argv[i]) == MagickFalse)
4875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4878 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4882 if (LocaleCompare("label",option+1) == 0)
4887 if (i == (ssize_t) argc)
4888 ThrowMogrifyException(OptionError,"MissingArgument",option);
4891 if (LocaleCompare("lat",option+1) == 0)
4896 if (i == (ssize_t) argc)
4897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4898 if (IsGeometry(argv[i]) == MagickFalse)
4899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4901 if (LocaleCompare("layers",option+1) == 0)
4909 if (i == (ssize_t) (argc-1))
4910 ThrowMogrifyException(OptionError,"MissingArgument",option);
4911 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4913 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4917 if (LocaleCompare("level",option+1) == 0)
4920 if (i == (ssize_t) argc)
4921 ThrowMogrifyException(OptionError,"MissingArgument",option);
4922 if (IsGeometry(argv[i]) == MagickFalse)
4923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4926 if (LocaleCompare("level-colors",option+1) == 0)
4929 if (i == (ssize_t) argc)
4930 ThrowMogrifyException(OptionError,"MissingArgument",option);
4933 if (LocaleCompare("limit",option+1) == 0)
4947 if (i == (ssize_t) argc)
4948 ThrowMogrifyException(OptionError,"MissingArgument",option);
4949 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4952 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4955 if (i == (ssize_t) argc)
4956 ThrowMogrifyException(OptionError,"MissingArgument",option);
4957 value=StringToDouble(argv[i],&p);
4959 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4963 if (LocaleCompare("liquid-rescale",option+1) == 0)
4966 if (i == (ssize_t) argc)
4967 ThrowMogrifyException(OptionError,"MissingArgument",option);
4968 if (IsGeometry(argv[i]) == MagickFalse)
4969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4972 if (LocaleCompare("list",option+1) == 0)
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4982 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4984 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4985 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4987 return(status != 0 ? MagickFalse : MagickTrue);
4989 if (LocaleCompare("log",option+1) == 0)
4994 if ((i == (ssize_t) argc) ||
4995 (strchr(argv[i],'%') == (char *) NULL))
4996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4999 if (LocaleCompare("loop",option+1) == 0)
5004 if (i == (ssize_t) argc)
5005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 if (IsGeometry(argv[i]) == MagickFalse)
5007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5010 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5014 if (LocaleCompare("map",option+1) == 0)
5016 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5020 if (i == (ssize_t) argc)
5021 ThrowMogrifyException(OptionError,"MissingArgument",option);
5024 if (LocaleCompare("mask",option+1) == 0)
5029 if (i == (ssize_t) argc)
5030 ThrowMogrifyException(OptionError,"MissingArgument",option);
5033 if (LocaleCompare("matte",option+1) == 0)
5035 if (LocaleCompare("mattecolor",option+1) == 0)
5040 if (i == (ssize_t) argc)
5041 ThrowMogrifyException(OptionError,"MissingArgument",option);
5044 if (LocaleCompare("maximum",option+1) == 0)
5046 if (LocaleCompare("minimum",option+1) == 0)
5048 if (LocaleCompare("modulate",option+1) == 0)
5053 if (i == (ssize_t) argc)
5054 ThrowMogrifyException(OptionError,"MissingArgument",option);
5055 if (IsGeometry(argv[i]) == MagickFalse)
5056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5059 if (LocaleCompare("median",option+1) == 0)
5064 if (i == (ssize_t) argc)
5065 ThrowMogrifyException(OptionError,"MissingArgument",option);
5066 if (IsGeometry(argv[i]) == MagickFalse)
5067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5070 if (LocaleCompare("mode",option+1) == 0)
5075 if (i == (ssize_t) argc)
5076 ThrowMogrifyException(OptionError,"MissingArgument",option);
5077 if (IsGeometry(argv[i]) == MagickFalse)
5078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5081 if (LocaleCompare("monitor",option+1) == 0)
5083 if (LocaleCompare("monochrome",option+1) == 0)
5085 if (LocaleCompare("morph",option+1) == 0)
5090 if (i == (ssize_t) (argc-1))
5091 ThrowMogrifyException(OptionError,"MissingArgument",option);
5092 if (IsGeometry(argv[i]) == MagickFalse)
5093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5096 if (LocaleCompare("morphology",option+1) == 0)
5099 token[MaxTextExtent];
5108 if (i == (ssize_t) argc)
5109 ThrowMogrifyException(OptionError,"MissingArgument",option);
5110 GetMagickToken(argv[i],NULL,token);
5111 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5113 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5116 if (i == (ssize_t) (argc-1))
5117 ThrowMogrifyException(OptionError,"MissingArgument",option);
5118 kernel_info=AcquireKernelInfo(argv[i]);
5119 if (kernel_info == (KernelInfo *) NULL)
5120 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5121 kernel_info=DestroyKernelInfo(kernel_info);
5124 if (LocaleCompare("mosaic",option+1) == 0)
5126 if (LocaleCompare("motion-blur",option+1) == 0)
5131 if (i == (ssize_t) argc)
5132 ThrowMogrifyException(OptionError,"MissingArgument",option);
5133 if (IsGeometry(argv[i]) == MagickFalse)
5134 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5137 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5141 if (LocaleCompare("negate",option+1) == 0)
5143 if (LocaleCompare("noise",option+1) == 0)
5146 if (i == (ssize_t) argc)
5147 ThrowMogrifyException(OptionError,"MissingArgument",option);
5153 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5155 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5159 if (IsGeometry(argv[i]) == MagickFalse)
5160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5163 if (LocaleCompare("noop",option+1) == 0)
5165 if (LocaleCompare("normalize",option+1) == 0)
5167 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5171 if (LocaleCompare("opaque",option+1) == 0)
5174 if (i == (ssize_t) argc)
5175 ThrowMogrifyException(OptionError,"MissingArgument",option);
5178 if (LocaleCompare("ordered-dither",option+1) == 0)
5183 if (i == (ssize_t) argc)
5184 ThrowMogrifyException(OptionError,"MissingArgument",option);
5187 if (LocaleCompare("orient",option+1) == 0)
5192 orientation=UndefinedOrientation;
5196 if (i == (ssize_t) (argc-1))
5197 ThrowMogrifyException(OptionError,"MissingArgument",option);
5198 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5200 if (orientation < 0)
5201 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5205 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5209 if (LocaleCompare("page",option+1) == 0)
5214 if (i == (ssize_t) argc)
5215 ThrowMogrifyException(OptionError,"MissingArgument",option);
5218 if (LocaleCompare("paint",option+1) == 0)
5223 if (i == (ssize_t) argc)
5224 ThrowMogrifyException(OptionError,"MissingArgument",option);
5225 if (IsGeometry(argv[i]) == MagickFalse)
5226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5229 if (LocaleCompare("path",option+1) == 0)
5231 (void) CloneString(&path,(char *) NULL);
5235 if (i == (ssize_t) argc)
5236 ThrowMogrifyException(OptionError,"MissingArgument",option);
5237 (void) CloneString(&path,argv[i]);
5240 if (LocaleCompare("pointsize",option+1) == 0)
5245 if (i == (ssize_t) argc)
5246 ThrowMogrifyException(OptionError,"MissingArgument",option);
5247 if (IsGeometry(argv[i]) == MagickFalse)
5248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5251 if (LocaleCompare("polaroid",option+1) == 0)
5256 if (i == (ssize_t) argc)
5257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5258 if (IsGeometry(argv[i]) == MagickFalse)
5259 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5262 if (LocaleCompare("posterize",option+1) == 0)
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,"MissingArgument",option);
5269 if (IsGeometry(argv[i]) == MagickFalse)
5270 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5273 if (LocaleCompare("precision",option+1) == 0)
5278 if (i == (ssize_t) argc)
5279 ThrowMogrifyException(OptionError,"MissingArgument",option);
5280 if (IsGeometry(argv[i]) == MagickFalse)
5281 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5284 if (LocaleCompare("print",option+1) == 0)
5289 if (i == (ssize_t) argc)
5290 ThrowMogrifyException(OptionError,"MissingArgument",option);
5293 if (LocaleCompare("process",option+1) == 0)
5298 if (i == (ssize_t) (argc-1))
5299 ThrowMogrifyException(OptionError,"MissingArgument",option);
5302 if (LocaleCompare("profile",option+1) == 0)
5305 if (i == (ssize_t) argc)
5306 ThrowMogrifyException(OptionError,"MissingArgument",option);
5309 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5313 if (LocaleCompare("quality",option+1) == 0)
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,"MissingArgument",option);
5320 if (IsGeometry(argv[i]) == MagickFalse)
5321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5324 if (LocaleCompare("quantize",option+1) == 0)
5332 if (i == (ssize_t) (argc-1))
5333 ThrowMogrifyException(OptionError,"MissingArgument",option);
5334 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5337 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5341 if (LocaleCompare("quiet",option+1) == 0)
5343 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5347 if (LocaleCompare("radial-blur",option+1) == 0)
5350 if (i == (ssize_t) argc)
5351 ThrowMogrifyException(OptionError,"MissingArgument",option);
5352 if (IsGeometry(argv[i]) == MagickFalse)
5353 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5356 if (LocaleCompare("raise",option+1) == 0)
5359 if (i == (ssize_t) argc)
5360 ThrowMogrifyException(OptionError,"MissingArgument",option);
5361 if (IsGeometry(argv[i]) == MagickFalse)
5362 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5365 if (LocaleCompare("random-threshold",option+1) == 0)
5370 if (i == (ssize_t) argc)
5371 ThrowMogrifyException(OptionError,"MissingArgument",option);
5372 if (IsGeometry(argv[i]) == MagickFalse)
5373 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5376 if (LocaleCompare("red-primary",option+1) == 0)
5381 if (i == (ssize_t) argc)
5382 ThrowMogrifyException(OptionError,"MissingArgument",option);
5383 if (IsGeometry(argv[i]) == MagickFalse)
5384 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5386 if (LocaleCompare("regard-warnings",option+1) == 0)
5388 if (LocaleCompare("region",option+1) == 0)
5393 if (i == (ssize_t) argc)
5394 ThrowMogrifyException(OptionError,"MissingArgument",option);
5395 if (IsGeometry(argv[i]) == MagickFalse)
5396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5399 if (LocaleCompare("remap",option+1) == 0)
5404 if (i == (ssize_t) (argc-1))
5405 ThrowMogrifyException(OptionError,"MissingArgument",option);
5408 if (LocaleCompare("render",option+1) == 0)
5410 if (LocaleCompare("repage",option+1) == 0)
5415 if (i == (ssize_t) argc)
5416 ThrowMogrifyException(OptionError,"MissingArgument",option);
5417 if (IsGeometry(argv[i]) == MagickFalse)
5418 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5421 if (LocaleCompare("resample",option+1) == 0)
5426 if (i == (ssize_t) argc)
5427 ThrowMogrifyException(OptionError,"MissingArgument",option);
5428 if (IsGeometry(argv[i]) == MagickFalse)
5429 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5432 if (LocaleCompare("resize",option+1) == 0)
5437 if (i == (ssize_t) argc)
5438 ThrowMogrifyException(OptionError,"MissingArgument",option);
5439 if (IsGeometry(argv[i]) == MagickFalse)
5440 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5443 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5445 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5448 if (LocaleCompare("reverse",option+1) == 0)
5450 if (LocaleCompare("roll",option+1) == 0)
5455 if (i == (ssize_t) argc)
5456 ThrowMogrifyException(OptionError,"MissingArgument",option);
5457 if (IsGeometry(argv[i]) == MagickFalse)
5458 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5461 if (LocaleCompare("rotate",option+1) == 0)
5464 if (i == (ssize_t) argc)
5465 ThrowMogrifyException(OptionError,"MissingArgument",option);
5466 if (IsGeometry(argv[i]) == MagickFalse)
5467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5470 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5474 if (LocaleCompare("sample",option+1) == 0)
5479 if (i == (ssize_t) argc)
5480 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (IsGeometry(argv[i]) == MagickFalse)
5482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5485 if (LocaleCompare("sampling-factor",option+1) == 0)
5490 if (i == (ssize_t) argc)
5491 ThrowMogrifyException(OptionError,"MissingArgument",option);
5492 if (IsGeometry(argv[i]) == MagickFalse)
5493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5496 if (LocaleCompare("scale",option+1) == 0)
5501 if (i == (ssize_t) argc)
5502 ThrowMogrifyException(OptionError,"MissingArgument",option);
5503 if (IsGeometry(argv[i]) == MagickFalse)
5504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5507 if (LocaleCompare("scene",option+1) == 0)
5512 if (i == (ssize_t) argc)
5513 ThrowMogrifyException(OptionError,"MissingArgument",option);
5514 if (IsGeometry(argv[i]) == MagickFalse)
5515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5518 if (LocaleCompare("seed",option+1) == 0)
5523 if (i == (ssize_t) argc)
5524 ThrowMogrifyException(OptionError,"MissingArgument",option);
5525 if (IsGeometry(argv[i]) == MagickFalse)
5526 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5529 if (LocaleCompare("segment",option+1) == 0)
5534 if (i == (ssize_t) argc)
5535 ThrowMogrifyException(OptionError,"MissingArgument",option);
5536 if (IsGeometry(argv[i]) == MagickFalse)
5537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5540 if (LocaleCompare("selective-blur",option+1) == 0)
5543 if (i == (ssize_t) argc)
5544 ThrowMogrifyException(OptionError,"MissingArgument",option);
5545 if (IsGeometry(argv[i]) == MagickFalse)
5546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5549 if (LocaleCompare("separate",option+1) == 0)
5551 if (LocaleCompare("sepia-tone",option+1) == 0)
5556 if (i == (ssize_t) argc)
5557 ThrowMogrifyException(OptionError,"MissingArgument",option);
5558 if (IsGeometry(argv[i]) == MagickFalse)
5559 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5562 if (LocaleCompare("set",option+1) == 0)
5565 if (i == (ssize_t) argc)
5566 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 if (i == (ssize_t) argc)
5571 ThrowMogrifyException(OptionError,"MissingArgument",option);
5574 if (LocaleCompare("shade",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("shadow",option+1) == 0)
5588 if (i == (ssize_t) argc)
5589 ThrowMogrifyException(OptionError,"MissingArgument",option);
5590 if (IsGeometry(argv[i]) == MagickFalse)
5591 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5594 if (LocaleCompare("sharpen",option+1) == 0)
5597 if (i == (ssize_t) argc)
5598 ThrowMogrifyException(OptionError,"MissingArgument",option);
5599 if (IsGeometry(argv[i]) == MagickFalse)
5600 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5603 if (LocaleCompare("shave",option+1) == 0)
5608 if (i == (ssize_t) argc)
5609 ThrowMogrifyException(OptionError,"MissingArgument",option);
5610 if (IsGeometry(argv[i]) == MagickFalse)
5611 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5614 if (LocaleCompare("shear",option+1) == 0)
5617 if (i == (ssize_t) argc)
5618 ThrowMogrifyException(OptionError,"MissingArgument",option);
5619 if (IsGeometry(argv[i]) == MagickFalse)
5620 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5623 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5626 if (i == (ssize_t) (argc-1))
5627 ThrowMogrifyException(OptionError,"MissingArgument",option);
5628 if (IsGeometry(argv[i]) == MagickFalse)
5629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5632 if (LocaleCompare("size",option+1) == 0)
5637 if (i == (ssize_t) argc)
5638 ThrowMogrifyException(OptionError,"MissingArgument",option);
5639 if (IsGeometry(argv[i]) == MagickFalse)
5640 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5643 if (LocaleCompare("sketch",option+1) == 0)
5648 if (i == (ssize_t) argc)
5649 ThrowMogrifyException(OptionError,"MissingArgument",option);
5650 if (IsGeometry(argv[i]) == MagickFalse)
5651 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5654 if (LocaleCompare("smush",option+1) == 0)
5657 if (i == (ssize_t) argc)
5658 ThrowMogrifyException(OptionError,"MissingArgument",option);
5659 if (IsGeometry(argv[i]) == MagickFalse)
5660 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5664 if (LocaleCompare("solarize",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("sparse-color",option+1) == 0)
5681 if (i == (ssize_t) argc)
5682 ThrowMogrifyException(OptionError,"MissingArgument",option);
5683 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5685 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5688 if (i == (ssize_t) (argc-1))
5689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5692 if (LocaleCompare("spread",option+1) == 0)
5697 if (i == (ssize_t) argc)
5698 ThrowMogrifyException(OptionError,"MissingArgument",option);
5699 if (IsGeometry(argv[i]) == MagickFalse)
5700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5703 if (LocaleCompare("statistic",option+1) == 0)
5711 if (i == (ssize_t) argc)
5712 ThrowMogrifyException(OptionError,"MissingArgument",option);
5713 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5715 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5718 if (i == (ssize_t) (argc-1))
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 if (IsGeometry(argv[i]) == MagickFalse)
5721 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5724 if (LocaleCompare("stretch",option+1) == 0)
5732 if (i == (ssize_t) (argc-1))
5733 ThrowMogrifyException(OptionError,"MissingArgument",option);
5734 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5736 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5740 if (LocaleCompare("strip",option+1) == 0)
5742 if (LocaleCompare("stroke",option+1) == 0)
5747 if (i == (ssize_t) argc)
5748 ThrowMogrifyException(OptionError,"MissingArgument",option);
5751 if (LocaleCompare("strokewidth",option+1) == 0)
5756 if (i == (ssize_t) argc)
5757 ThrowMogrifyException(OptionError,"MissingArgument",option);
5758 if (IsGeometry(argv[i]) == MagickFalse)
5759 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5762 if (LocaleCompare("style",option+1) == 0)
5770 if (i == (ssize_t) (argc-1))
5771 ThrowMogrifyException(OptionError,"MissingArgument",option);
5772 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5774 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5778 if (LocaleCompare("swap",option+1) == 0)
5783 if (i == (ssize_t) (argc-1))
5784 ThrowMogrifyException(OptionError,"MissingArgument",option);
5785 if (IsGeometry(argv[i]) == MagickFalse)
5786 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5789 if (LocaleCompare("swirl",option+1) == 0)
5794 if (i == (ssize_t) argc)
5795 ThrowMogrifyException(OptionError,"MissingArgument",option);
5796 if (IsGeometry(argv[i]) == MagickFalse)
5797 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5800 if (LocaleCompare("synchronize",option+1) == 0)
5802 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5806 if (LocaleCompare("taint",option+1) == 0)
5808 if (LocaleCompare("texture",option+1) == 0)
5813 if (i == (ssize_t) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5817 if (LocaleCompare("tile",option+1) == 0)
5822 if (i == (ssize_t) (argc-1))
5823 ThrowMogrifyException(OptionError,"MissingArgument",option);
5826 if (LocaleCompare("tile-offset",option+1) == 0)
5831 if (i == (ssize_t) argc)
5832 ThrowMogrifyException(OptionError,"MissingArgument",option);
5833 if (IsGeometry(argv[i]) == MagickFalse)
5834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5837 if (LocaleCompare("tint",option+1) == 0)
5842 if (i == (ssize_t) (argc-1))
5843 ThrowMogrifyException(OptionError,"MissingArgument",option);
5844 if (IsGeometry(argv[i]) == MagickFalse)
5845 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5848 if (LocaleCompare("transform",option+1) == 0)
5850 if (LocaleCompare("transpose",option+1) == 0)
5852 if (LocaleCompare("transverse",option+1) == 0)
5854 if (LocaleCompare("threshold",option+1) == 0)
5859 if (i == (ssize_t) argc)
5860 ThrowMogrifyException(OptionError,"MissingArgument",option);
5861 if (IsGeometry(argv[i]) == MagickFalse)
5862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5865 if (LocaleCompare("thumbnail",option+1) == 0)
5870 if (i == (ssize_t) argc)
5871 ThrowMogrifyException(OptionError,"MissingArgument",option);
5872 if (IsGeometry(argv[i]) == MagickFalse)
5873 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5876 if (LocaleCompare("transparent",option+1) == 0)
5879 if (i == (ssize_t) argc)
5880 ThrowMogrifyException(OptionError,"MissingArgument",option);
5883 if (LocaleCompare("transparent-color",option+1) == 0)
5888 if (i == (ssize_t) (argc-1))
5889 ThrowMogrifyException(OptionError,"MissingArgument",option);
5892 if (LocaleCompare("treedepth",option+1) == 0)
5897 if (i == (ssize_t) argc)
5898 ThrowMogrifyException(OptionError,"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5903 if (LocaleCompare("trim",option+1) == 0)
5905 if (LocaleCompare("type",option+1) == 0)
5913 if (i == (ssize_t) argc)
5914 ThrowMogrifyException(OptionError,"MissingArgument",option);
5915 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5917 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5921 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5925 if (LocaleCompare("undercolor",option+1) == 0)
5930 if (i == (ssize_t) argc)
5931 ThrowMogrifyException(OptionError,"MissingArgument",option);
5934 if (LocaleCompare("unique-colors",option+1) == 0)
5936 if (LocaleCompare("units",option+1) == 0)
5944 if (i == (ssize_t) argc)
5945 ThrowMogrifyException(OptionError,"MissingArgument",option);
5946 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5949 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5953 if (LocaleCompare("unsharp",option+1) == 0)
5956 if (i == (ssize_t) argc)
5957 ThrowMogrifyException(OptionError,"MissingArgument",option);
5958 if (IsGeometry(argv[i]) == MagickFalse)
5959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5962 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5966 if (LocaleCompare("verbose",option+1) == 0)
5968 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5971 if ((LocaleCompare("version",option+1) == 0) ||
5972 (LocaleCompare("-version",option+1) == 0))
5974 (void) FormatLocaleFile(stdout,"Version: %s\n",
5975 GetMagickVersion((size_t *) NULL));
5976 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5977 GetMagickCopyright());
5978 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5979 GetMagickFeatures());
5982 if (LocaleCompare("view",option+1) == 0)
5987 if (i == (ssize_t) argc)
5988 ThrowMogrifyException(OptionError,"MissingArgument",option);
5991 if (LocaleCompare("vignette",option+1) == 0)
5996 if (i == (ssize_t) argc)
5997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5998 if (IsGeometry(argv[i]) == MagickFalse)
5999 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6002 if (LocaleCompare("virtual-pixel",option+1) == 0)
6010 if (i == (ssize_t) argc)
6011 ThrowMogrifyException(OptionError,"MissingArgument",option);
6012 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6015 ThrowMogrifyException(OptionError,
6016 "UnrecognizedVirtualPixelMethod",argv[i]);
6019 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6023 if (LocaleCompare("wave",option+1) == 0)
6026 if (i == (ssize_t) argc)
6027 ThrowMogrifyException(OptionError,"MissingArgument",option);
6028 if (IsGeometry(argv[i]) == MagickFalse)
6029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032 if (LocaleCompare("weight",option+1) == 0)
6037 if (i == (ssize_t) (argc-1))
6038 ThrowMogrifyException(OptionError,"MissingArgument",option);
6041 if (LocaleCompare("white-point",option+1) == 0)
6046 if (i == (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 if (IsGeometry(argv[i]) == MagickFalse)
6049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6052 if (LocaleCompare("white-threshold",option+1) == 0)
6057 if (i == (ssize_t) argc)
6058 ThrowMogrifyException(OptionError,"MissingArgument",option);
6059 if (IsGeometry(argv[i]) == MagickFalse)
6060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6063 if (LocaleCompare("write",option+1) == 0)
6066 if (i == (ssize_t) (argc-1))
6067 ThrowMogrifyException(OptionError,"MissingArgument",option);
6070 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6075 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6077 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6078 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6079 if (fire != MagickFalse)
6080 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6083 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6084 if (i != (ssize_t) argc)
6085 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6087 return(status != 0 ? MagickTrue : MagickFalse);
6091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6095 + M o g r i f y I m a g e I n f o %
6099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6101 % MogrifyImageInfo() applies image processing settings to the image as
6102 % prescribed by command line options.
6104 % The format of the MogrifyImageInfo method is:
6106 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6107 % const char **argv,ExceptionInfo *exception)
6109 % A description of each parameter follows:
6111 % o image_info: the image info..
6113 % o argc: Specifies a pointer to an integer describing the number of
6114 % elements in the argument vector.
6116 % o argv: Specifies a pointer to a text array containing the command line
6119 % o exception: return any errors or warnings in this structure.
6122 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6123 const int argc,const char **argv,ExceptionInfo *exception)
6138 Initialize method variables.
6140 assert(image_info != (ImageInfo *) NULL);
6141 assert(image_info->signature == MagickSignature);
6142 if (image_info->debug != MagickFalse)
6143 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6144 image_info->filename);
6148 Set the image settings.
6150 for (i=0; i < (ssize_t) argc; i++)
6153 if (IsCommandOption(option) == MagickFalse)
6155 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6156 count=MagickMax(count,0L);
6157 if ((i+count) >= (ssize_t) argc)
6159 switch (*(option+1))
6163 if (LocaleCompare("adjoin",option+1) == 0)
6165 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6168 if (LocaleCompare("antialias",option+1) == 0)
6170 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6173 if (LocaleCompare("authenticate",option+1) == 0)
6176 (void) DeleteImageOption(image_info,option+1);
6178 (void) SetImageOption(image_info,option+1,argv[i+1]);
6185 if (LocaleCompare("background",option+1) == 0)
6189 (void) DeleteImageOption(image_info,option+1);
6190 (void) QueryColorCompliance(MogrifyBackgroundColor,
6191 AllCompliance,&image_info->background_color,exception);
6194 (void) SetImageOption(image_info,option+1,argv[i+1]);
6195 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6196 &image_info->background_color,exception);
6199 if (LocaleCompare("bias",option+1) == 0)
6203 (void) SetImageOption(image_info,option+1,"0.0");
6206 (void) SetImageOption(image_info,option+1,argv[i+1]);
6209 if (LocaleCompare("black-point-compensation",option+1) == 0)
6213 (void) SetImageOption(image_info,option+1,"false");
6216 (void) SetImageOption(image_info,option+1,"true");
6219 if (LocaleCompare("blue-primary",option+1) == 0)
6223 (void) SetImageOption(image_info,option+1,"0.0");
6226 (void) SetImageOption(image_info,option+1,argv[i+1]);
6229 if (LocaleCompare("bordercolor",option+1) == 0)
6233 (void) DeleteImageOption(image_info,option+1);
6234 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6235 &image_info->border_color,exception);
6238 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6239 &image_info->border_color,exception);
6240 (void) SetImageOption(image_info,option+1,argv[i+1]);
6243 if (LocaleCompare("box",option+1) == 0)
6247 (void) SetImageOption(image_info,"undercolor","none");
6250 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6257 if (LocaleCompare("cache",option+1) == 0)
6262 limit=MagickResourceInfinity;
6263 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6264 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6266 (void) SetMagickResourceLimit(MemoryResource,limit);
6267 (void) SetMagickResourceLimit(MapResource,2*limit);
6270 if (LocaleCompare("caption",option+1) == 0)
6274 (void) DeleteImageOption(image_info,option+1);
6277 (void) SetImageOption(image_info,option+1,argv[i+1]);
6280 if (LocaleCompare("channel",option+1) == 0)
6284 image_info->channel=DefaultChannels;
6285 (void) SetImageOption(image_info,option+1,"default");
6288 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6289 (void) SetImageOption(image_info,option+1,argv[i+1]);
6292 if (LocaleCompare("colorspace",option+1) == 0)
6296 image_info->colorspace=UndefinedColorspace;
6297 (void) SetImageOption(image_info,option+1,"undefined");
6300 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6301 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6302 (void) SetImageOption(image_info,option+1,argv[i+1]);
6305 if (LocaleCompare("comment",option+1) == 0)
6309 (void) DeleteImageOption(image_info,option+1);
6312 (void) SetImageOption(image_info,option+1,argv[i+1]);
6315 if (LocaleCompare("compose",option+1) == 0)
6319 (void) SetImageOption(image_info,option+1,"undefined");
6322 (void) SetImageOption(image_info,option+1,argv[i+1]);
6325 if (LocaleCompare("compress",option+1) == 0)
6329 image_info->compression=UndefinedCompression;
6330 (void) SetImageOption(image_info,option+1,"undefined");
6333 image_info->compression=(CompressionType) ParseCommandOption(
6334 MagickCompressOptions,MagickFalse,argv[i+1]);
6335 (void) SetImageOption(image_info,option+1,argv[i+1]);
6342 if (LocaleCompare("debug",option+1) == 0)
6345 (void) SetLogEventMask("none");
6347 (void) SetLogEventMask(argv[i+1]);
6348 image_info->debug=IsEventLogging();
6351 if (LocaleCompare("define",option+1) == 0)
6355 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6356 (void) DeleteImageRegistry(argv[i+1]+9);
6358 (void) DeleteImageOption(image_info,argv[i+1]);
6361 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6363 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6367 (void) DefineImageOption(image_info,argv[i+1]);
6370 if (LocaleCompare("delay",option+1) == 0)
6374 (void) SetImageOption(image_info,option+1,"0");
6377 (void) SetImageOption(image_info,option+1,argv[i+1]);
6380 if (LocaleCompare("density",option+1) == 0)
6387 if (image_info->density != (char *) NULL)
6388 image_info->density=DestroyString(image_info->density);
6389 (void) SetImageOption(image_info,option+1,"72");
6392 (void) CloneString(&image_info->density,argv[i+1]);
6393 (void) SetImageOption(image_info,option+1,argv[i+1]);
6396 if (LocaleCompare("depth",option+1) == 0)
6400 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6403 image_info->depth=StringToUnsignedLong(argv[i+1]);
6406 if (LocaleCompare("direction",option+1) == 0)
6410 (void) SetImageOption(image_info,option+1,"undefined");
6413 (void) SetImageOption(image_info,option+1,argv[i+1]);
6416 if (LocaleCompare("display",option+1) == 0)
6420 if (image_info->server_name != (char *) NULL)
6421 image_info->server_name=DestroyString(
6422 image_info->server_name);
6425 (void) CloneString(&image_info->server_name,argv[i+1]);
6428 if (LocaleCompare("dispose",option+1) == 0)
6432 (void) SetImageOption(image_info,option+1,"undefined");
6435 (void) SetImageOption(image_info,option+1,argv[i+1]);
6438 if (LocaleCompare("dither",option+1) == 0)
6442 image_info->dither=MagickFalse;
6443 (void) SetImageOption(image_info,option+1,"none");
6446 (void) SetImageOption(image_info,option+1,argv[i+1]);
6447 image_info->dither=MagickTrue;
6454 if (LocaleCompare("encoding",option+1) == 0)
6458 (void) SetImageOption(image_info,option+1,"undefined");
6461 (void) SetImageOption(image_info,option+1,argv[i+1]);
6464 if (LocaleCompare("endian",option+1) == 0)
6468 image_info->endian=UndefinedEndian;
6469 (void) SetImageOption(image_info,option+1,"undefined");
6472 image_info->endian=(EndianType) ParseCommandOption(
6473 MagickEndianOptions,MagickFalse,argv[i+1]);
6474 (void) SetImageOption(image_info,option+1,argv[i+1]);
6477 if (LocaleCompare("extract",option+1) == 0)
6480 Set image extract geometry.
6484 if (image_info->extract != (char *) NULL)
6485 image_info->extract=DestroyString(image_info->extract);
6488 (void) CloneString(&image_info->extract,argv[i+1]);
6495 if (LocaleCompare("fill",option+1) == 0)
6499 (void) SetImageOption(image_info,option+1,"none");
6502 (void) SetImageOption(image_info,option+1,argv[i+1]);
6505 if (LocaleCompare("filter",option+1) == 0)
6509 (void) SetImageOption(image_info,option+1,"undefined");
6512 (void) SetImageOption(image_info,option+1,argv[i+1]);
6515 if (LocaleCompare("font",option+1) == 0)
6519 if (image_info->font != (char *) NULL)
6520 image_info->font=DestroyString(image_info->font);
6523 (void) CloneString(&image_info->font,argv[i+1]);
6526 if (LocaleCompare("format",option+1) == 0)
6531 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6532 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6533 image_info->ping=MagickFalse;
6534 (void) SetImageOption(image_info,option+1,argv[i+1]);
6537 if (LocaleCompare("fuzz",option+1) == 0)
6541 image_info->fuzz=0.0;
6542 (void) SetImageOption(image_info,option+1,"0");
6545 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6547 (void) SetImageOption(image_info,option+1,argv[i+1]);
6554 if (LocaleCompare("gravity",option+1) == 0)
6558 (void) SetImageOption(image_info,option+1,"undefined");
6561 (void) SetImageOption(image_info,option+1,argv[i+1]);
6564 if (LocaleCompare("green-primary",option+1) == 0)
6568 (void) SetImageOption(image_info,option+1,"0.0");
6571 (void) SetImageOption(image_info,option+1,argv[i+1]);
6578 if (LocaleCompare("intent",option+1) == 0)
6582 (void) SetImageOption(image_info,option+1,"undefined");
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 if (LocaleCompare("interlace",option+1) == 0)
6592 image_info->interlace=UndefinedInterlace;
6593 (void) SetImageOption(image_info,option+1,"undefined");
6596 image_info->interlace=(InterlaceType) ParseCommandOption(
6597 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("interline-spacing",option+1) == 0)
6605 (void) SetImageOption(image_info,option+1,"undefined");
6608 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 if (LocaleCompare("interpolate",option+1) == 0)
6615 (void) SetImageOption(image_info,option+1,"undefined");
6618 (void) SetImageOption(image_info,option+1,argv[i+1]);
6621 if (LocaleCompare("interword-spacing",option+1) == 0)
6625 (void) SetImageOption(image_info,option+1,"undefined");
6628 (void) SetImageOption(image_info,option+1,argv[i+1]);
6635 if (LocaleCompare("kerning",option+1) == 0)
6639 (void) SetImageOption(image_info,option+1,"undefined");
6642 (void) SetImageOption(image_info,option+1,argv[i+1]);
6649 if (LocaleCompare("label",option+1) == 0)
6653 (void) DeleteImageOption(image_info,option+1);
6656 (void) SetImageOption(image_info,option+1,argv[i+1]);
6659 if (LocaleCompare("limit",option+1) == 0)
6669 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6670 MagickFalse,argv[i+1]);
6671 limit=MagickResourceInfinity;
6672 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6673 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6674 (void) SetMagickResourceLimit(type,limit);
6677 if (LocaleCompare("list",option+1) == 0)
6683 Display configuration list.
6685 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6688 case MagickCoderOptions:
6690 (void) ListCoderInfo((FILE *) NULL,exception);
6693 case MagickColorOptions:
6695 (void) ListColorInfo((FILE *) NULL,exception);
6698 case MagickConfigureOptions:
6700 (void) ListConfigureInfo((FILE *) NULL,exception);
6703 case MagickDelegateOptions:
6705 (void) ListDelegateInfo((FILE *) NULL,exception);
6708 case MagickFontOptions:
6710 (void) ListTypeInfo((FILE *) NULL,exception);
6713 case MagickFormatOptions:
6715 (void) ListMagickInfo((FILE *) NULL,exception);
6718 case MagickLocaleOptions:
6720 (void) ListLocaleInfo((FILE *) NULL,exception);
6723 case MagickLogOptions:
6725 (void) ListLogInfo((FILE *) NULL,exception);
6728 case MagickMagicOptions:
6730 (void) ListMagicInfo((FILE *) NULL,exception);
6733 case MagickMimeOptions:
6735 (void) ListMimeInfo((FILE *) NULL,exception);
6738 case MagickModuleOptions:
6740 (void) ListModuleInfo((FILE *) NULL,exception);
6743 case MagickPolicyOptions:
6745 (void) ListPolicyInfo((FILE *) NULL,exception);
6748 case MagickResourceOptions:
6750 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6753 case MagickThresholdOptions:
6755 (void) ListThresholdMaps((FILE *) NULL,exception);
6760 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6767 if (LocaleCompare("log",option+1) == 0)
6771 (void) SetLogFormat(argv[i+1]);
6774 if (LocaleCompare("loop",option+1) == 0)
6778 (void) SetImageOption(image_info,option+1,"0");
6781 (void) SetImageOption(image_info,option+1,argv[i+1]);
6788 if (LocaleCompare("matte",option+1) == 0)
6792 (void) SetImageOption(image_info,option+1,"false");
6795 (void) SetImageOption(image_info,option+1,"true");
6798 if (LocaleCompare("mattecolor",option+1) == 0)
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
6803 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6804 &image_info->matte_color,exception);
6807 (void) SetImageOption(image_info,option+1,argv[i+1]);
6808 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6809 &image_info->matte_color,exception);
6812 if (LocaleCompare("monitor",option+1) == 0)
6814 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6818 if (LocaleCompare("monochrome",option+1) == 0)
6820 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6827 if (LocaleCompare("orient",option+1) == 0)
6831 image_info->orientation=UndefinedOrientation;
6832 (void) SetImageOption(image_info,option+1,"undefined");
6835 image_info->orientation=(OrientationType) ParseCommandOption(
6836 MagickOrientationOptions,MagickFalse,argv[i+1]);
6837 (void) SetImageOption(image_info,option+1,argv[i+1]);
6843 if (LocaleCompare("page",option+1) == 0)
6847 page[MaxTextExtent];
6860 (void) DeleteImageOption(image_info,option+1);
6861 (void) CloneString(&image_info->page,(char *) NULL);
6864 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6865 image_option=GetImageOption(image_info,"page");
6866 if (image_option != (const char *) NULL)
6867 flags=ParseAbsoluteGeometry(image_option,&geometry);
6868 canonical_page=GetPageGeometry(argv[i+1]);
6869 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6870 canonical_page=DestroyString(canonical_page);
6871 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6872 (unsigned long) geometry.width,(unsigned long) geometry.height);
6873 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6874 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6875 (unsigned long) geometry.width,(unsigned long) geometry.height,
6876 (long) geometry.x,(long) geometry.y);
6877 (void) SetImageOption(image_info,option+1,page);
6878 (void) CloneString(&image_info->page,page);
6881 if (LocaleCompare("ping",option+1) == 0)
6883 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6886 if (LocaleCompare("pointsize",option+1) == 0)
6889 geometry_info.rho=0.0;
6891 (void) ParseGeometry(argv[i+1],&geometry_info);
6892 image_info->pointsize=geometry_info.rho;
6895 if (LocaleCompare("precision",option+1) == 0)
6897 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6900 if (LocaleCompare("preview",option+1) == 0)
6907 image_info->preview_type=UndefinedPreview;
6910 image_info->preview_type=(PreviewType) ParseCommandOption(
6911 MagickPreviewOptions,MagickFalse,argv[i+1]);
6918 if (LocaleCompare("quality",option+1) == 0)
6921 Set image compression quality.
6925 image_info->quality=UndefinedCompressionQuality;
6926 (void) SetImageOption(image_info,option+1,"0");
6929 image_info->quality=StringToUnsignedLong(argv[i+1]);
6930 (void) SetImageOption(image_info,option+1,argv[i+1]);
6933 if (LocaleCompare("quiet",option+1) == 0)
6935 static WarningHandler
6936 warning_handler = (WarningHandler) NULL;
6941 Restore error or warning messages.
6943 warning_handler=SetWarningHandler(warning_handler);
6947 Suppress error or warning messages.
6949 warning_handler=SetWarningHandler((WarningHandler) NULL);
6956 if (LocaleCompare("red-primary",option+1) == 0)
6960 (void) SetImageOption(image_info,option+1,"0.0");
6963 (void) SetImageOption(image_info,option+1,argv[i+1]);
6970 if (LocaleCompare("sampling-factor",option+1) == 0)
6973 Set image sampling factor.
6977 if (image_info->sampling_factor != (char *) NULL)
6978 image_info->sampling_factor=DestroyString(
6979 image_info->sampling_factor);
6982 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6985 if (LocaleCompare("scene",option+1) == 0)
6992 image_info->scene=0;
6993 (void) SetImageOption(image_info,option+1,"0");
6996 image_info->scene=StringToUnsignedLong(argv[i+1]);
6997 (void) SetImageOption(image_info,option+1,argv[i+1]);
7000 if (LocaleCompare("seed",option+1) == 0)
7007 seed=(size_t) time((time_t *) NULL);
7008 SetRandomSecretKey(seed);
7011 seed=StringToUnsignedLong(argv[i+1]);
7012 SetRandomSecretKey(seed);
7015 if (LocaleCompare("size",option+1) == 0)
7019 if (image_info->size != (char *) NULL)
7020 image_info->size=DestroyString(image_info->size);
7023 (void) CloneString(&image_info->size,argv[i+1]);
7026 if (LocaleCompare("stroke",option+1) == 0)
7030 (void) SetImageOption(image_info,option+1,"none");
7033 (void) SetImageOption(image_info,option+1,argv[i+1]);
7036 if (LocaleCompare("strokewidth",option+1) == 0)
7040 (void) SetImageOption(image_info,option+1,"0");
7043 (void) SetImageOption(image_info,option+1,argv[i+1]);
7046 if (LocaleCompare("synchronize",option+1) == 0)
7050 image_info->synchronize=MagickFalse;
7053 image_info->synchronize=MagickTrue;
7060 if (LocaleCompare("taint",option+1) == 0)
7064 (void) SetImageOption(image_info,option+1,"false");
7067 (void) SetImageOption(image_info,option+1,"true");
7070 if (LocaleCompare("texture",option+1) == 0)
7074 if (image_info->texture != (char *) NULL)
7075 image_info->texture=DestroyString(image_info->texture);
7078 (void) CloneString(&image_info->texture,argv[i+1]);
7081 if (LocaleCompare("tile-offset",option+1) == 0)
7084 (void) SetImageOption(image_info,option+1,"0");
7086 (void) SetImageOption(image_info,option+1,argv[i+1]);
7089 if (LocaleCompare("transparent-color",option+1) == 0)
7093 (void) QueryColorCompliance("none",AllCompliance,
7094 &image_info->transparent_color,exception);
7095 (void) SetImageOption(image_info,option+1,"none");
7098 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7099 &image_info->transparent_color,exception);
7100 (void) SetImageOption(image_info,option+1,argv[i+1]);
7103 if (LocaleCompare("type",option+1) == 0)
7107 image_info->type=UndefinedType;
7108 (void) SetImageOption(image_info,option+1,"undefined");
7111 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7112 MagickFalse,argv[i+1]);
7113 (void) SetImageOption(image_info,option+1,argv[i+1]);
7120 if (LocaleCompare("undercolor",option+1) == 0)
7123 (void) DeleteImageOption(image_info,option+1);
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7128 if (LocaleCompare("units",option+1) == 0)
7132 image_info->units=UndefinedResolution;
7133 (void) SetImageOption(image_info,option+1,"undefined");
7136 image_info->units=(ResolutionType) ParseCommandOption(
7137 MagickResolutionOptions,MagickFalse,argv[i+1]);
7138 (void) SetImageOption(image_info,option+1,argv[i+1]);
7145 if (LocaleCompare("verbose",option+1) == 0)
7149 image_info->verbose=MagickFalse;
7152 image_info->verbose=MagickTrue;
7153 image_info->ping=MagickFalse;
7156 if (LocaleCompare("view",option+1) == 0)
7160 if (image_info->view != (char *) NULL)
7161 image_info->view=DestroyString(image_info->view);
7164 (void) CloneString(&image_info->view,argv[i+1]);
7167 if (LocaleCompare("virtual-pixel",option+1) == 0)
7170 (void) SetImageOption(image_info,option+1,"undefined");
7172 (void) SetImageOption(image_info,option+1,argv[i+1]);
7179 if (LocaleCompare("white-point",option+1) == 0)
7182 (void) SetImageOption(image_info,option+1,"0.0");
7184 (void) SetImageOption(image_info,option+1,argv[i+1]);
7198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7202 + M o g r i f y I m a g e L i s t %
7206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7208 % MogrifyImageList() applies any command line options that might affect the
7209 % entire image list (e.g. -append, -coalesce, etc.).
7211 % The format of the MogrifyImage method is:
7213 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7214 % const char **argv,Image **images,ExceptionInfo *exception)
7216 % A description of each parameter follows:
7218 % o image_info: the image info..
7220 % o argc: Specifies a pointer to an integer describing the number of
7221 % elements in the argument vector.
7223 % o argv: Specifies a pointer to a text array containing the command line
7226 % o images: pointer to pointer of the first image in image list.
7228 % o exception: return any errors or warnings in this structure.
7231 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7232 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7243 PixelInterpolateMethod
7257 Apply options to the image list.
7259 assert(image_info != (ImageInfo *) NULL);
7260 assert(image_info->signature == MagickSignature);
7261 assert(images != (Image **) NULL);
7262 assert((*images)->previous == (Image *) NULL);
7263 assert((*images)->signature == MagickSignature);
7264 if ((*images)->debug != MagickFalse)
7265 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7266 (*images)->filename);
7267 if ((argc <= 0) || (*argv == (char *) NULL))
7269 interpolate_method=UndefinedInterpolatePixel;
7270 mogrify_info=CloneImageInfo(image_info);
7271 quantize_info=AcquireQuantizeInfo(mogrify_info);
7273 for (i=0; i < (ssize_t) argc; i++)
7275 if (*images == (Image *) NULL)
7278 if (IsCommandOption(option) == MagickFalse)
7280 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7281 count=MagickMax(count,0L);
7282 if ((i+count) >= (ssize_t) argc)
7284 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7285 switch (*(option+1))
7289 if (LocaleCompare("affinity",option+1) == 0)
7291 (void) SyncImagesSettings(mogrify_info,*images,exception);
7294 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7301 if (LocaleCompare("append",option+1) == 0)
7306 (void) SyncImagesSettings(mogrify_info,*images,exception);
7307 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7308 MagickFalse,exception);
7309 if (append_image == (Image *) NULL)
7314 *images=DestroyImageList(*images);
7315 *images=append_image;
7318 if (LocaleCompare("average",option+1) == 0)
7324 Average an image sequence (deprecated).
7326 (void) SyncImagesSettings(mogrify_info,*images,exception);
7327 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7329 if (average_image == (Image *) NULL)
7334 *images=DestroyImageList(*images);
7335 *images=average_image;
7342 if (LocaleCompare("channel-fx",option+1) == 0)
7347 (void) SyncImagesSettings(mogrify_info,*images,exception);
7348 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7349 if (channel_image == (Image *) NULL)
7354 *images=DestroyImageList(*images);
7355 *images=channel_image;
7358 if (LocaleCompare("clut",option+1) == 0)
7364 (void) SyncImagesSettings(mogrify_info,*images,exception);
7365 image=RemoveFirstImageFromList(images);
7366 clut_image=RemoveFirstImageFromList(images);
7367 if (clut_image == (Image *) NULL)
7372 (void) ClutImage(image,clut_image,interpolate_method,exception);
7373 clut_image=DestroyImage(clut_image);
7374 *images=DestroyImageList(*images);
7378 if (LocaleCompare("coalesce",option+1) == 0)
7383 (void) SyncImagesSettings(mogrify_info,*images,exception);
7384 coalesce_image=CoalesceImages(*images,exception);
7385 if (coalesce_image == (Image *) NULL)
7390 *images=DestroyImageList(*images);
7391 *images=coalesce_image;
7394 if (LocaleCompare("combine",option+1) == 0)
7399 (void) SyncImagesSettings(mogrify_info,*images,exception);
7400 combine_image=CombineImages(*images,exception);
7401 if (combine_image == (Image *) NULL)
7406 *images=DestroyImageList(*images);
7407 *images=combine_image;
7410 if (LocaleCompare("composite",option+1) == 0)
7426 (void) SyncImagesSettings(mogrify_info,*images,exception);
7427 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7428 if (value == (const char *) NULL)
7429 clip_to_self=MagickTrue;
7431 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7432 "compose:clip-to-self")); /* if this is true */
7433 if (IsMagickFalse(clip_to_self)) /* or */
7434 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7435 mogrify_info,"compose:outside-overlay"))); /* this false */
7436 image=RemoveFirstImageFromList(images);
7437 composite_image=RemoveFirstImageFromList(images);
7438 if (composite_image == (Image *) NULL)
7443 (void) TransformImage(&composite_image,(char *) NULL,
7444 composite_image->geometry,exception);
7445 SetGeometry(composite_image,&geometry);
7446 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7447 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7449 mask_image=RemoveFirstImageFromList(images);
7450 if (mask_image != (Image *) NULL)
7452 if ((image->compose == DisplaceCompositeOp) ||
7453 (image->compose == DistortCompositeOp))
7456 Merge Y displacement into X displacement image.
7458 (void) CompositeImage(composite_image,mask_image,
7459 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7460 mask_image=DestroyImage(mask_image);
7465 Set a blending mask for the composition.
7467 (void) NegateImage(mask_image,MagickFalse,exception);
7468 (void) SetImageMask(image,mask_image,exception);
7469 mask_image=DestroyImage(mask_image);
7472 (void) CompositeImage(image,composite_image,image->compose,
7473 clip_to_self,geometry.x,geometry.y,exception);
7474 (void) SetImageMask(image,(Image *) NULL,exception);
7475 composite_image=DestroyImage(composite_image);
7476 *images=DestroyImageList(*images);
7484 if (LocaleCompare("deconstruct",option+1) == 0)
7489 (void) SyncImagesSettings(mogrify_info,*images,exception);
7490 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7492 if (deconstruct_image == (Image *) NULL)
7497 *images=DestroyImageList(*images);
7498 *images=deconstruct_image;
7501 if (LocaleCompare("delete",option+1) == 0)
7504 DeleteImages(images,"-1",exception);
7506 DeleteImages(images,argv[i+1],exception);
7509 if (LocaleCompare("dither",option+1) == 0)
7513 quantize_info->dither=MagickFalse;
7516 quantize_info->dither=MagickTrue;
7517 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7518 MagickDitherOptions,MagickFalse,argv[i+1]);
7521 if (LocaleCompare("duplicate",option+1) == 0)
7527 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7536 number_duplicates=(size_t) StringToLong(argv[i+1]);
7537 p=strchr(argv[i+1],',');
7538 if (p == (const char *) NULL)
7539 duplicate_images=DuplicateImages(*images,number_duplicates,
7542 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7545 AppendImageToList(images, duplicate_images);
7546 (void) SyncImagesSettings(mogrify_info,*images,exception);
7553 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7558 MagickEvaluateOperator
7561 (void) SyncImageSettings(mogrify_info,*images,exception);
7562 op=(MagickEvaluateOperator) ParseCommandOption(
7563 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7564 evaluate_image=EvaluateImages(*images,op,exception);
7565 if (evaluate_image == (Image *) NULL)
7570 *images=DestroyImageList(*images);
7571 *images=evaluate_image;
7578 if (LocaleCompare("fft",option+1) == 0)
7584 Implements the discrete Fourier transform (DFT).
7586 (void) SyncImageSettings(mogrify_info,*images,exception);
7587 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7588 MagickTrue : MagickFalse,exception);
7589 if (fourier_image == (Image *) NULL)
7591 *images=DestroyImage(*images);
7592 *images=fourier_image;
7595 if (LocaleCompare("flatten",option+1) == 0)
7600 (void) SyncImagesSettings(mogrify_info,*images,exception);
7601 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7602 if (flatten_image == (Image *) NULL)
7604 *images=DestroyImageList(*images);
7605 *images=flatten_image;
7608 if (LocaleCompare("fx",option+1) == 0)
7613 (void) SyncImagesSettings(mogrify_info,*images,exception);
7614 fx_image=FxImage(*images,argv[i+1],exception);
7615 if (fx_image == (Image *) NULL)
7620 *images=DestroyImageList(*images);
7628 if (LocaleCompare("hald-clut",option+1) == 0)
7634 (void) SyncImagesSettings(mogrify_info,*images,exception);
7635 image=RemoveFirstImageFromList(images);
7636 hald_image=RemoveFirstImageFromList(images);
7637 if (hald_image == (Image *) NULL)
7642 (void) HaldClutImage(image,hald_image,exception);
7643 hald_image=DestroyImage(hald_image);
7644 if (*images != (Image *) NULL)
7645 *images=DestroyImageList(*images);
7653 if (LocaleCompare("ift",option+1) == 0)
7661 Implements the inverse fourier discrete Fourier transform (DFT).
7663 (void) SyncImagesSettings(mogrify_info,*images,exception);
7664 magnitude_image=RemoveFirstImageFromList(images);
7665 phase_image=RemoveFirstImageFromList(images);
7666 if (phase_image == (Image *) NULL)
7671 fourier_image=InverseFourierTransformImage(magnitude_image,
7672 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7673 if (fourier_image == (Image *) NULL)
7675 if (*images != (Image *) NULL)
7676 *images=DestroyImage(*images);
7677 *images=fourier_image;
7680 if (LocaleCompare("insert",option+1) == 0)
7688 index=(ssize_t) StringToLong(argv[i+1]);
7689 p=RemoveLastImageFromList(images);
7690 if (p == (Image *) NULL)
7692 (void) ThrowMagickException(exception,GetMagickModule(),
7693 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7699 PrependImageToList(images,q);
7701 if (index == (ssize_t) GetImageListLength(*images))
7702 AppendImageToList(images,q);
7705 q=GetImageFromList(*images,index-1);
7706 if (q == (Image *) NULL)
7708 (void) ThrowMagickException(exception,GetMagickModule(),
7709 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7713 InsertImageInList(&q,p);
7715 *images=GetFirstImageInList(q);
7718 if (LocaleCompare("interpolate",option+1) == 0)
7720 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7721 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7728 if (LocaleCompare("layers",option+1) == 0)
7736 (void) SyncImagesSettings(mogrify_info,*images,exception);
7737 layers=(Image *) NULL;
7738 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7739 MagickFalse,argv[i+1]);
7744 layers=CoalesceImages(*images,exception);
7747 case CompareAnyLayer:
7748 case CompareClearLayer:
7749 case CompareOverlayLayer:
7752 layers=CompareImagesLayers(*images,method,exception);
7758 case TrimBoundsLayer:
7760 layers=MergeImageLayers(*images,method,exception);
7765 layers=DisposeImages(*images,exception);
7768 case OptimizeImageLayer:
7770 layers=OptimizeImageLayers(*images,exception);
7773 case OptimizePlusLayer:
7775 layers=OptimizePlusImageLayers(*images,exception);
7778 case OptimizeTransLayer:
7780 OptimizeImageTransparency(*images,exception);
7783 case RemoveDupsLayer:
7785 RemoveDuplicateLayers(images,exception);
7788 case RemoveZeroLayer:
7790 RemoveZeroDelayLayers(images,exception);
7796 General Purpose, GIF Animation Optimizer.
7798 layers=CoalesceImages(*images,exception);
7799 if (layers == (Image *) NULL)
7804 *images=DestroyImageList(*images);
7806 layers=OptimizeImageLayers(*images,exception);
7807 if (layers == (Image *) NULL)
7812 *images=DestroyImageList(*images);
7814 layers=(Image *) NULL;
7815 OptimizeImageTransparency(*images,exception);
7816 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7820 case CompositeLayer:
7832 Split image sequence at the first 'NULL:' image.
7835 while (source != (Image *) NULL)
7837 source=GetNextImageInList(source);
7838 if ((source != (Image *) NULL) &&
7839 (LocaleCompare(source->magick,"NULL") == 0))
7842 if (source != (Image *) NULL)
7844 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7845 (GetNextImageInList(source) == (Image *) NULL))
7846 source=(Image *) NULL;
7850 Separate the two lists, junk the null: image.
7852 source=SplitImageList(source->previous);
7853 DeleteImageFromList(&source);
7856 if (source == (Image *) NULL)
7858 (void) ThrowMagickException(exception,GetMagickModule(),
7859 OptionError,"MissingNullSeparator","layers Composite");
7864 Adjust offset with gravity and virtual canvas.
7866 SetGeometry(*images,&geometry);
7867 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7868 geometry.width=source->page.width != 0 ?
7869 source->page.width : source->columns;
7870 geometry.height=source->page.height != 0 ?
7871 source->page.height : source->rows;
7872 GravityAdjustGeometry((*images)->page.width != 0 ?
7873 (*images)->page.width : (*images)->columns,
7874 (*images)->page.height != 0 ? (*images)->page.height :
7875 (*images)->rows,(*images)->gravity,&geometry);
7876 compose=OverCompositeOp;
7877 option=GetImageOption(mogrify_info,"compose");
7878 if (option != (const char *) NULL)
7879 compose=(CompositeOperator) ParseCommandOption(
7880 MagickComposeOptions,MagickFalse,option);
7881 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7883 source=DestroyImageList(source);
7887 if (layers == (Image *) NULL)
7889 *images=DestroyImageList(*images);
7897 if (LocaleCompare("map",option+1) == 0)
7899 (void) SyncImagesSettings(mogrify_info,*images,exception);
7902 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7909 if (LocaleCompare("maximum",option+1) == 0)
7915 Maximum image sequence (deprecated).
7917 (void) SyncImagesSettings(mogrify_info,*images,exception);
7918 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7919 if (maximum_image == (Image *) NULL)
7924 *images=DestroyImageList(*images);
7925 *images=maximum_image;
7928 if (LocaleCompare("minimum",option+1) == 0)
7934 Minimum image sequence (deprecated).
7936 (void) SyncImagesSettings(mogrify_info,*images,exception);
7937 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7938 if (minimum_image == (Image *) NULL)
7943 *images=DestroyImageList(*images);
7944 *images=minimum_image;
7947 if (LocaleCompare("morph",option+1) == 0)
7952 (void) SyncImagesSettings(mogrify_info,*images,exception);
7953 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7955 if (morph_image == (Image *) NULL)
7960 *images=DestroyImageList(*images);
7961 *images=morph_image;
7964 if (LocaleCompare("mosaic",option+1) == 0)
7969 (void) SyncImagesSettings(mogrify_info,*images,exception);
7970 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7971 if (mosaic_image == (Image *) NULL)
7976 *images=DestroyImageList(*images);
7977 *images=mosaic_image;
7984 if (LocaleCompare("print",option+1) == 0)
7989 (void) SyncImagesSettings(mogrify_info,*images,exception);
7990 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7992 if (string == (char *) NULL)
7994 (void) FormatLocaleFile(stdout,"%s",string);
7995 string=DestroyString(string);
7997 if (LocaleCompare("process",option+1) == 0)
8006 (void) SyncImagesSettings(mogrify_info,*images,exception);
8007 arguments=StringToArgv(argv[i+1],&number_arguments);
8008 if (arguments == (char **) NULL)
8010 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8031 Support old style syntax, filter="-option arg".
8033 length=strlen(argv[i+1]);
8034 token=(char *) NULL;
8035 if (~length >= (MaxTextExtent-1))
8036 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8038 if (token == (char *) NULL)
8041 arguments=argv[i+1];
8042 token_info=AcquireTokenInfo();
8043 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8044 "\"",'\0',&breaker,&next,"e);
8045 token_info=DestroyTokenInfo(token_info);
8051 argv=(&(arguments[next]));
8052 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8055 token=DestroyString(token);
8058 (void) SubstituteString(&arguments[1],"-","");
8059 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8060 number_arguments-2,(const char **) arguments+2,exception);
8061 for (j=0; j < number_arguments; j++)
8062 arguments[j]=DestroyString(arguments[j]);
8063 arguments=(char **) RelinquishMagickMemory(arguments);
8070 if (LocaleCompare("reverse",option+1) == 0)
8072 ReverseImageList(images);
8079 if (LocaleCompare("smush",option+1) == 0)
8087 (void) SyncImagesSettings(mogrify_info,*images,exception);
8088 offset=(ssize_t) StringToLong(argv[i+1]);
8089 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8090 MagickFalse,offset,exception);
8091 if (smush_image == (Image *) NULL)
8096 *images=DestroyImageList(*images);
8097 *images=smush_image;
8100 if (LocaleCompare("swap",option+1) == 0)
8121 flags=ParseGeometry(argv[i+1],&geometry_info);
8122 index=(ssize_t) geometry_info.rho;
8123 if ((flags & SigmaValue) != 0)
8124 swap_index=(ssize_t) geometry_info.sigma;
8126 p=GetImageFromList(*images,index);
8127 q=GetImageFromList(*images,swap_index);
8128 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8130 (void) ThrowMagickException(exception,GetMagickModule(),
8131 OptionError,"NoSuchImage","'%s'",(*images)->filename);
8137 swap=CloneImage(p,0,0,MagickTrue,exception);
8138 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8139 ReplaceImageInList(&q,swap);
8140 *images=GetFirstImageInList(q);
8147 if (LocaleCompare("write",option+1) == 0)
8158 (void) SyncImagesSettings(mogrify_info,*images,exception);
8159 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8160 (void) DeleteImageRegistry(key);
8161 write_images=(*images);
8163 write_images=CloneImageList(*images,exception);
8164 write_info=CloneImageInfo(mogrify_info);
8165 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8166 write_info=DestroyImageInfo(write_info);
8168 write_images=DestroyImageList(write_images);
8178 quantize_info=DestroyQuantizeInfo(quantize_info);
8179 mogrify_info=DestroyImageInfo(mogrify_info);
8180 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8181 return(status != 0 ? MagickTrue : MagickFalse);
8185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8189 + M o g r i f y I m a g e s %
8193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8195 % MogrifyImages() applies image processing options to a sequence of images as
8196 % prescribed by command line options.
8198 % The format of the MogrifyImage method is:
8200 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8201 % const MagickBooleanType post,const int argc,const char **argv,
8202 % Image **images,Exceptioninfo *exception)
8204 % A description of each parameter follows:
8206 % o image_info: the image info..
8208 % o post: If true, post process image list operators otherwise pre-process.
8210 % o argc: Specifies a pointer to an integer describing the number of
8211 % elements in the argument vector.
8213 % o argv: Specifies a pointer to a text array containing the command line
8216 % o images: pointer to a pointer of the first image in image list.
8218 % o exception: return any errors or warnings in this structure.
8221 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8222 const MagickBooleanType post,const int argc,const char **argv,
8223 Image **images,ExceptionInfo *exception)
8225 #define MogrifyImageTag "Mogrify/Image"
8239 assert(image_info != (ImageInfo *) NULL);
8240 assert(image_info->signature == MagickSignature);
8241 if (images == (Image **) NULL)
8242 return(MogrifyImage(image_info,argc,argv,images,exception));
8243 assert((*images)->previous == (Image *) NULL);
8244 assert((*images)->signature == MagickSignature);
8245 if ((*images)->debug != MagickFalse)
8246 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8247 (*images)->filename);
8248 if ((argc <= 0) || (*argv == (char *) NULL))
8250 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8255 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8260 Pre-process multi-image sequence operators
8262 if (post == MagickFalse)
8263 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8265 For each image, process simple single image operators
8268 n=GetImageListLength(*images);
8272 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8273 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8275 status&=MogrifyImage(image_info,argc,argv,images,exception);
8276 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8277 if (proceed == MagickFalse)
8279 if ( (*images)->next == (Image *) NULL )
8281 *images=(*images)->next;
8284 assert( *images != (Image *) NULL );
8286 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8287 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8291 Post-process, multi-image sequence operators
8293 *images=GetFirstImageInList(*images);
8294 if (post != MagickFalse)
8295 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8296 return(status != 0 ? MagickTrue : MagickFalse);