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+1) == 0)
150 iterations=StringToUnsignedLong(argv[++i]);
151 if (LocaleCompare("concurrent",option+1) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("debug",option+1) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("duration",option+1) == 0)
156 duration=StringToDouble(argv[++i],(char **) NULL);
157 if (LocaleCompare("regard-warnings",option+1) == 0)
158 regard_warnings=MagickTrue;
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 if not already present. Return the image
352 that is in the cache under that filename.
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 if ((flags & XiValue) == 0)
753 geometry_info.xi=0.0;
754 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
755 geometry_info.sigma,geometry_info.xi,exception);
758 if (LocaleCompare("adaptive-resize",option+1) == 0)
761 Adaptive resize image.
763 (void) SyncImageSettings(mogrify_info,*image,exception);
764 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
765 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
766 geometry.height,exception);
769 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
772 Adaptive sharpen image.
774 (void) SyncImageSettings(mogrify_info,*image,exception);
775 flags=ParseGeometry(argv[i+1],&geometry_info);
776 if ((flags & SigmaValue) == 0)
777 geometry_info.sigma=1.0;
778 if ((flags & XiValue) == 0)
779 geometry_info.xi=0.0;
780 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
781 geometry_info.sigma,geometry_info.xi,exception);
784 if (LocaleCompare("affine",option+1) == 0)
791 GetAffineMatrix(&draw_info->affine);
794 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
797 if (LocaleCompare("alpha",option+1) == 0)
802 (void) SyncImageSettings(mogrify_info,*image,exception);
803 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
804 MagickFalse,argv[i+1]);
805 (void) SetImageAlphaChannel(*image,alpha_type,exception);
808 if (LocaleCompare("annotate",option+1) == 0)
812 geometry[MaxTextExtent];
817 (void) SyncImageSettings(mogrify_info,*image,exception);
818 SetGeometryInfo(&geometry_info);
819 flags=ParseGeometry(argv[i+1],&geometry_info);
820 if ((flags & SigmaValue) == 0)
821 geometry_info.sigma=geometry_info.rho;
822 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
824 if (text == (char *) NULL)
826 (void) CloneString(&draw_info->text,text);
827 text=DestroyString(text);
828 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
829 geometry_info.xi,geometry_info.psi);
830 (void) CloneString(&draw_info->geometry,geometry);
831 draw_info->affine.sx=cos(DegreesToRadians(
832 fmod(geometry_info.rho,360.0)));
833 draw_info->affine.rx=sin(DegreesToRadians(
834 fmod(geometry_info.rho,360.0)));
835 draw_info->affine.ry=(-sin(DegreesToRadians(
836 fmod(geometry_info.sigma,360.0))));
837 draw_info->affine.sy=cos(DegreesToRadians(
838 fmod(geometry_info.sigma,360.0)));
839 (void) AnnotateImage(*image,draw_info,exception);
842 if (LocaleCompare("antialias",option+1) == 0)
844 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
846 draw_info->text_antialias=(*option == '-') ? MagickTrue :
850 if (LocaleCompare("attenuate",option+1) == 0)
857 attenuate=StringToDouble(argv[i+1],(char **) NULL);
860 if (LocaleCompare("auto-gamma",option+1) == 0)
863 Auto Adjust Gamma of image based on its mean
865 (void) SyncImageSettings(mogrify_info,*image,exception);
866 (void) AutoGammaImage(*image,exception);
869 if (LocaleCompare("auto-level",option+1) == 0)
872 Perfectly Normalize (max/min stretch) the image
874 (void) SyncImageSettings(mogrify_info,*image,exception);
875 (void) AutoLevelImage(*image,exception);
878 if (LocaleCompare("auto-orient",option+1) == 0)
880 (void) SyncImageSettings(mogrify_info,*image,exception);
881 switch ((*image)->orientation)
883 case TopRightOrientation:
885 mogrify_image=FlopImage(*image,exception);
888 case BottomRightOrientation:
890 mogrify_image=RotateImage(*image,180.0,exception);
893 case BottomLeftOrientation:
895 mogrify_image=FlipImage(*image,exception);
898 case LeftTopOrientation:
900 mogrify_image=TransposeImage(*image,exception);
903 case RightTopOrientation:
905 mogrify_image=RotateImage(*image,90.0,exception);
908 case RightBottomOrientation:
910 mogrify_image=TransverseImage(*image,exception);
913 case LeftBottomOrientation:
915 mogrify_image=RotateImage(*image,270.0,exception);
921 if (mogrify_image != (Image *) NULL)
922 mogrify_image->orientation=TopLeftOrientation;
929 if (LocaleCompare("black-threshold",option+1) == 0)
932 Black threshold image.
934 (void) SyncImageSettings(mogrify_info,*image,exception);
935 (void) BlackThresholdImage(*image,argv[i+1],exception);
938 if (LocaleCompare("blue-shift",option+1) == 0)
943 (void) SyncImageSettings(mogrify_info,*image,exception);
944 geometry_info.rho=1.5;
946 flags=ParseGeometry(argv[i+1],&geometry_info);
947 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
950 if (LocaleCompare("blur",option+1) == 0)
955 (void) SyncImageSettings(mogrify_info,*image,exception);
956 flags=ParseGeometry(argv[i+1],&geometry_info);
957 if ((flags & SigmaValue) == 0)
958 geometry_info.sigma=1.0;
959 if ((flags & XiValue) == 0)
960 geometry_info.xi=0.0;
961 mogrify_image=BlurImage(*image,geometry_info.rho,
962 geometry_info.sigma,geometry_info.xi,exception);
965 if (LocaleCompare("border",option+1) == 0)
968 Surround image with a border of solid color.
970 (void) SyncImageSettings(mogrify_info,*image,exception);
971 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
972 if ((flags & SigmaValue) == 0)
973 geometry.height=geometry.width;
974 mogrify_image=BorderImage(*image,&geometry,compose,exception);
977 if (LocaleCompare("bordercolor",option+1) == 0)
981 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
982 &draw_info->border_color,exception);
985 (void) QueryColorCompliance(argv[i+1],AllCompliance,
986 &draw_info->border_color,exception);
989 if (LocaleCompare("box",option+1) == 0)
991 (void) QueryColorCompliance(argv[i+1],AllCompliance,
992 &draw_info->undercolor,exception);
995 if (LocaleCompare("brightness-contrast",option+1) == 0)
1008 Brightness / contrast image.
1010 (void) SyncImageSettings(mogrify_info,*image,exception);
1011 flags=ParseGeometry(argv[i+1],&geometry_info);
1012 brightness=geometry_info.rho;
1014 if ((flags & SigmaValue) != 0)
1015 contrast=geometry_info.sigma;
1016 (void) BrightnessContrastImage(*image,brightness,contrast,
1024 if (LocaleCompare("cdl",option+1) == 0)
1027 *color_correction_collection;
1030 Color correct with a color decision list.
1032 (void) SyncImageSettings(mogrify_info,*image,exception);
1033 color_correction_collection=FileToString(argv[i+1],~0,exception);
1034 if (color_correction_collection == (char *) NULL)
1036 (void) ColorDecisionListImage(*image,color_correction_collection,
1040 if (LocaleCompare("charcoal",option+1) == 0)
1045 (void) SyncImageSettings(mogrify_info,*image,exception);
1046 flags=ParseGeometry(argv[i+1],&geometry_info);
1047 if ((flags & SigmaValue) == 0)
1048 geometry_info.sigma=1.0;
1049 if ((flags & XiValue) == 0)
1050 geometry_info.xi=1.0;
1051 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1052 geometry_info.sigma,geometry_info.xi,exception);
1055 if (LocaleCompare("chop",option+1) == 0)
1060 (void) SyncImageSettings(mogrify_info,*image,exception);
1061 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1062 mogrify_image=ChopImage(*image,&geometry,exception);
1065 if (LocaleCompare("clamp",option+1) == 0)
1070 (void) SyncImageSettings(mogrify_info,*image,exception);
1071 (void) ClampImage(*image,exception);
1074 if (LocaleCompare("clip",option+1) == 0)
1076 (void) SyncImageSettings(mogrify_info,*image,exception);
1079 (void) SetImageMask(*image,(Image *) NULL,exception);
1082 (void) ClipImage(*image,exception);
1085 if (LocaleCompare("clip-mask",option+1) == 0)
1102 (void) SyncImageSettings(mogrify_info,*image,exception);
1108 (void) SetImageMask(*image,(Image *) NULL,exception);
1113 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1115 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1116 if (mask_image == (Image *) NULL)
1118 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1119 return(MagickFalse);
1120 mask_view=AcquireCacheView(mask_image);
1121 for (y=0; y < (ssize_t) mask_image->rows; y++)
1123 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1125 if (q == (Quantum *) NULL)
1127 for (x=0; x < (ssize_t) mask_image->columns; x++)
1129 if (mask_image->matte == MagickFalse)
1130 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1131 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1132 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1133 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1134 q+=GetPixelChannels(mask_image);
1136 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1139 mask_view=DestroyCacheView(mask_view);
1140 mask_image->matte=MagickTrue;
1141 (void) SetImageMask(*image,mask_image,exception);
1144 if (LocaleCompare("clip-path",option+1) == 0)
1146 (void) SyncImageSettings(mogrify_info,*image,exception);
1147 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1148 MagickFalse,exception);
1151 if (LocaleCompare("colorize",option+1) == 0)
1156 (void) SyncImageSettings(mogrify_info,*image,exception);
1157 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1160 if (LocaleCompare("color-matrix",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image,exception);
1166 kernel=AcquireKernelInfo(argv[i+1]);
1167 if (kernel == (KernelInfo *) NULL)
1169 /* FUTURE: check on size of the matrix */
1170 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1171 kernel=DestroyKernelInfo(kernel);
1174 if (LocaleCompare("colors",option+1) == 0)
1177 Reduce the number of colors in the image.
1179 (void) SyncImageSettings(mogrify_info,*image,exception);
1180 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1181 if (quantize_info->number_colors == 0)
1183 if (((*image)->storage_class == DirectClass) ||
1184 (*image)->colors > quantize_info->number_colors)
1185 (void) QuantizeImage(quantize_info,*image,exception);
1187 (void) CompressImageColormap(*image,exception);
1190 if (LocaleCompare("colorspace",option+1) == 0)
1195 (void) SyncImageSettings(mogrify_info,*image,exception);
1198 (void) TransformImageColorspace(*image,RGBColorspace,exception);
1201 colorspace=(ColorspaceType) ParseCommandOption(
1202 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1203 (void) TransformImageColorspace(*image,colorspace,exception);
1206 if (LocaleCompare("compose",option+1) == 0)
1208 (void) SyncImageSettings(mogrify_info,*image,exception);
1209 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1210 MagickFalse,argv[i+1]);
1213 if (LocaleCompare("contrast",option+1) == 0)
1215 (void) SyncImageSettings(mogrify_info,*image,exception);
1216 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1217 MagickFalse,exception);
1220 if (LocaleCompare("contrast-stretch",option+1) == 0)
1230 Contrast stretch image.
1232 (void) SyncImageSettings(mogrify_info,*image,exception);
1233 flags=ParseGeometry(argv[i+1],&geometry_info);
1234 black_point=geometry_info.rho;
1235 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1237 if ((flags & PercentValue) != 0)
1239 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1240 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1242 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1244 (void) ContrastStretchImage(*image,black_point,white_point,
1248 if (LocaleCompare("convolve",option+1) == 0)
1253 (void) SyncImageSettings(mogrify_info,*image,exception);
1254 kernel_info=AcquireKernelInfo(argv[i+1]);
1255 if (kernel_info == (KernelInfo *) NULL)
1257 kernel_info->bias=(*image)->bias;
1258 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1259 kernel_info=DestroyKernelInfo(kernel_info);
1262 if (LocaleCompare("crop",option+1) == 0)
1265 Crop a image to a smaller size
1267 (void) SyncImageSettings(mogrify_info,*image,exception);
1268 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1271 if (LocaleCompare("cycle",option+1) == 0)
1274 Cycle an image colormap.
1276 (void) SyncImageSettings(mogrify_info,*image,exception);
1277 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1285 if (LocaleCompare("decipher",option+1) == 0)
1293 (void) SyncImageSettings(mogrify_info,*image,exception);
1294 passkey=FileToStringInfo(argv[i+1],~0,exception);
1295 if (passkey != (StringInfo *) NULL)
1297 (void) PasskeyDecipherImage(*image,passkey,exception);
1298 passkey=DestroyStringInfo(passkey);
1302 if (LocaleCompare("density",option+1) == 0)
1307 (void) CloneString(&draw_info->density,argv[i+1]);
1310 if (LocaleCompare("depth",option+1) == 0)
1312 (void) SyncImageSettings(mogrify_info,*image,exception);
1315 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1318 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1322 if (LocaleCompare("deskew",option+1) == 0)
1328 Straighten the image.
1330 (void) SyncImageSettings(mogrify_info,*image,exception);
1332 threshold=40.0*QuantumRange/100.0;
1334 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1336 mogrify_image=DeskewImage(*image,threshold,exception);
1339 if (LocaleCompare("despeckle",option+1) == 0)
1342 Reduce the speckles within an image.
1344 (void) SyncImageSettings(mogrify_info,*image,exception);
1345 mogrify_image=DespeckleImage(*image,exception);
1348 if (LocaleCompare("display",option+1) == 0)
1350 (void) CloneString(&draw_info->server_name,argv[i+1]);
1353 if (LocaleCompare("distort",option+1) == 0)
1357 token[MaxTextExtent];
1377 (void) SyncImageSettings(mogrify_info,*image,exception);
1378 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1379 MagickFalse,argv[i+1]);
1380 if (method == ResizeDistortion)
1386 Special Case - Argument is actually a resize geometry!
1387 Convert that to an appropriate distortion argument array.
1389 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1391 resize_args[0]=(double) geometry.width;
1392 resize_args[1]=(double) geometry.height;
1393 mogrify_image=DistortImage(*image,method,(size_t)2,
1394 resize_args,MagickTrue,exception);
1397 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1399 if (args == (char *) NULL)
1402 for (x=0; *p != '\0'; x++)
1404 GetMagickToken(p,&p,token);
1406 GetMagickToken(p,&p,token);
1408 number_arguments=(size_t) x;
1409 arguments=(double *) AcquireQuantumMemory(number_arguments,
1410 sizeof(*arguments));
1411 if (arguments == (double *) NULL)
1412 ThrowWandFatalException(ResourceLimitFatalError,
1413 "MemoryAllocationFailed",(*image)->filename);
1414 (void) ResetMagickMemory(arguments,0,number_arguments*
1415 sizeof(*arguments));
1417 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1419 GetMagickToken(p,&p,token);
1421 GetMagickToken(p,&p,token);
1422 arguments[x]=StringToDouble(token,(char **) NULL);
1424 args=DestroyString(args);
1425 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1426 (*option == '+') ? MagickTrue : MagickFalse,exception);
1427 arguments=(double *) RelinquishMagickMemory(arguments);
1430 if (LocaleCompare("dither",option+1) == 0)
1434 quantize_info->dither=MagickFalse;
1437 quantize_info->dither=MagickTrue;
1438 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1439 MagickDitherOptions,MagickFalse,argv[i+1]);
1440 if (quantize_info->dither_method == NoDitherMethod)
1441 quantize_info->dither=MagickFalse;
1444 if (LocaleCompare("draw",option+1) == 0)
1449 (void) SyncImageSettings(mogrify_info,*image,exception);
1450 (void) CloneString(&draw_info->primitive,argv[i+1]);
1451 (void) DrawImage(*image,draw_info,exception);
1458 if (LocaleCompare("edge",option+1) == 0)
1461 Enhance edges in the image.
1463 (void) SyncImageSettings(mogrify_info,*image,exception);
1464 flags=ParseGeometry(argv[i+1],&geometry_info);
1465 if ((flags & SigmaValue) == 0)
1466 geometry_info.sigma=1.0;
1467 mogrify_image=EdgeImage(*image,geometry_info.rho,
1468 geometry_info.sigma,exception);
1471 if (LocaleCompare("emboss",option+1) == 0)
1476 (void) SyncImageSettings(mogrify_info,*image,exception);
1477 flags=ParseGeometry(argv[i+1],&geometry_info);
1478 if ((flags & SigmaValue) == 0)
1479 geometry_info.sigma=1.0;
1480 mogrify_image=EmbossImage(*image,geometry_info.rho,
1481 geometry_info.sigma,exception);
1484 if (LocaleCompare("encipher",option+1) == 0)
1492 (void) SyncImageSettings(mogrify_info,*image,exception);
1493 passkey=FileToStringInfo(argv[i+1],~0,exception);
1494 if (passkey != (StringInfo *) NULL)
1496 (void) PasskeyEncipherImage(*image,passkey,exception);
1497 passkey=DestroyStringInfo(passkey);
1501 if (LocaleCompare("encoding",option+1) == 0)
1503 (void) CloneString(&draw_info->encoding,argv[i+1]);
1506 if (LocaleCompare("enhance",option+1) == 0)
1511 (void) SyncImageSettings(mogrify_info,*image,exception);
1512 mogrify_image=EnhanceImage(*image,exception);
1515 if (LocaleCompare("equalize",option+1) == 0)
1520 (void) SyncImageSettings(mogrify_info,*image,exception);
1521 (void) EqualizeImage(*image,exception);
1524 if (LocaleCompare("evaluate",option+1) == 0)
1529 MagickEvaluateOperator
1532 (void) SyncImageSettings(mogrify_info,*image,exception);
1533 op=(MagickEvaluateOperator) ParseCommandOption(
1534 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1535 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1537 (void) EvaluateImage(*image,op,constant,exception);
1540 if (LocaleCompare("extent",option+1) == 0)
1543 Set the image extent.
1545 (void) SyncImageSettings(mogrify_info,*image,exception);
1546 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1547 if (geometry.width == 0)
1548 geometry.width=(*image)->columns;
1549 if (geometry.height == 0)
1550 geometry.height=(*image)->rows;
1551 mogrify_image=ExtentImage(*image,&geometry,exception);
1558 if (LocaleCompare("family",option+1) == 0)
1562 if (draw_info->family != (char *) NULL)
1563 draw_info->family=DestroyString(draw_info->family);
1566 (void) CloneString(&draw_info->family,argv[i+1]);
1569 if (LocaleCompare("features",option+1) == 0)
1573 (void) DeleteImageArtifact(*image,"identify:features");
1576 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1579 if (LocaleCompare("fill",option+1) == 0)
1587 GetPixelInfo(*image,&fill);
1590 (void) QueryColorCompliance("none",AllCompliance,&fill,
1592 draw_info->fill=fill;
1593 if (draw_info->fill_pattern != (Image *) NULL)
1594 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1597 sans=AcquireExceptionInfo();
1598 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1599 sans=DestroyExceptionInfo(sans);
1600 if (status == MagickFalse)
1601 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1604 draw_info->fill=fill=color;
1607 if (LocaleCompare("flip",option+1) == 0)
1610 Flip image scanlines.
1612 (void) SyncImageSettings(mogrify_info,*image,exception);
1613 mogrify_image=FlipImage(*image,exception);
1616 if (LocaleCompare("floodfill",option+1) == 0)
1624 (void) SyncImageSettings(mogrify_info,*image,exception);
1625 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1626 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1628 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1629 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1632 if (LocaleCompare("flop",option+1) == 0)
1635 Flop image scanlines.
1637 (void) SyncImageSettings(mogrify_info,*image,exception);
1638 mogrify_image=FlopImage(*image,exception);
1641 if (LocaleCompare("font",option+1) == 0)
1645 if (draw_info->font != (char *) NULL)
1646 draw_info->font=DestroyString(draw_info->font);
1649 (void) CloneString(&draw_info->font,argv[i+1]);
1652 if (LocaleCompare("format",option+1) == 0)
1657 if (LocaleCompare("frame",option+1) == 0)
1663 Surround image with an ornamental border.
1665 (void) SyncImageSettings(mogrify_info,*image,exception);
1666 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1667 frame_info.width=geometry.width;
1668 frame_info.height=geometry.height;
1669 if ((flags & HeightValue) == 0)
1670 frame_info.height=geometry.width;
1671 frame_info.outer_bevel=geometry.x;
1672 frame_info.inner_bevel=geometry.y;
1673 frame_info.x=(ssize_t) frame_info.width;
1674 frame_info.y=(ssize_t) frame_info.height;
1675 frame_info.width=(*image)->columns+2*frame_info.width;
1676 frame_info.height=(*image)->rows+2*frame_info.height;
1677 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1680 if (LocaleCompare("function",option+1) == 0)
1684 token[MaxTextExtent];
1702 Function Modify Image Values
1704 (void) SyncImageSettings(mogrify_info,*image,exception);
1705 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1706 MagickFalse,argv[i+1]);
1707 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1709 if (arguments == (char *) NULL)
1711 p=(char *) arguments;
1712 for (x=0; *p != '\0'; x++)
1714 GetMagickToken(p,&p,token);
1716 GetMagickToken(p,&p,token);
1718 number_parameters=(size_t) x;
1719 parameters=(double *) AcquireQuantumMemory(number_parameters,
1720 sizeof(*parameters));
1721 if (parameters == (double *) NULL)
1722 ThrowWandFatalException(ResourceLimitFatalError,
1723 "MemoryAllocationFailed",(*image)->filename);
1724 (void) ResetMagickMemory(parameters,0,number_parameters*
1725 sizeof(*parameters));
1726 p=(char *) arguments;
1727 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1729 GetMagickToken(p,&p,token);
1731 GetMagickToken(p,&p,token);
1732 parameters[x]=StringToDouble(token,(char **) NULL);
1734 arguments=DestroyString(arguments);
1735 (void) FunctionImage(*image,function,number_parameters,parameters,
1737 parameters=(double *) RelinquishMagickMemory(parameters);
1744 if (LocaleCompare("gamma",option+1) == 0)
1749 (void) SyncImageSettings(mogrify_info,*image,exception);
1751 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1753 (void) GammaImage(*image,StringToDouble(argv[i+1],
1754 (char **) NULL),exception);
1757 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1758 (LocaleCompare("gaussian",option+1) == 0))
1761 Gaussian blur image.
1763 (void) SyncImageSettings(mogrify_info,*image,exception);
1764 flags=ParseGeometry(argv[i+1],&geometry_info);
1765 if ((flags & SigmaValue) == 0)
1766 geometry_info.sigma=1.0;
1767 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1768 geometry_info.sigma,exception);
1771 if (LocaleCompare("geometry",option+1) == 0)
1774 Record Image offset, Resize last image.
1776 (void) SyncImageSettings(mogrify_info,*image,exception);
1779 if ((*image)->geometry != (char *) NULL)
1780 (*image)->geometry=DestroyString((*image)->geometry);
1783 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1784 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1785 (void) CloneString(&(*image)->geometry,argv[i+1]);
1787 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1788 (*image)->filter,(*image)->blur,exception);
1791 if (LocaleCompare("gravity",option+1) == 0)
1795 draw_info->gravity=UndefinedGravity;
1798 draw_info->gravity=(GravityType) ParseCommandOption(
1799 MagickGravityOptions,MagickFalse,argv[i+1]);
1806 if (LocaleCompare("highlight-color",option+1) == 0)
1808 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1815 if (LocaleCompare("identify",option+1) == 0)
1820 (void) SyncImageSettings(mogrify_info,*image,exception);
1821 if (format == (char *) NULL)
1823 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1827 text=InterpretImageProperties(mogrify_info,*image,format,
1829 if (text == (char *) NULL)
1831 (void) fputs(text,stdout);
1832 (void) fputc('\n',stdout);
1833 text=DestroyString(text);
1836 if (LocaleCompare("implode",option+1) == 0)
1841 (void) SyncImageSettings(mogrify_info,*image,exception);
1842 (void) ParseGeometry(argv[i+1],&geometry_info);
1843 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1844 interpolate_method,exception);
1847 if (LocaleCompare("interline-spacing",option+1) == 0)
1850 (void) ParseGeometry("0",&geometry_info);
1852 (void) ParseGeometry(argv[i+1],&geometry_info);
1853 draw_info->interline_spacing=geometry_info.rho;
1856 if (LocaleCompare("interpolate",option+1) == 0)
1858 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1859 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1862 if (LocaleCompare("interword-spacing",option+1) == 0)
1865 (void) ParseGeometry("0",&geometry_info);
1867 (void) ParseGeometry(argv[i+1],&geometry_info);
1868 draw_info->interword_spacing=geometry_info.rho;
1871 if (LocaleCompare("interpolative-resize",option+1) == 0)
1874 Interpolative resize image.
1876 (void) SyncImageSettings(mogrify_info,*image,exception);
1877 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1878 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1879 geometry.height,interpolate_method,exception);
1886 if (LocaleCompare("kerning",option+1) == 0)
1889 (void) ParseGeometry("0",&geometry_info);
1891 (void) ParseGeometry(argv[i+1],&geometry_info);
1892 draw_info->kerning=geometry_info.rho;
1899 if (LocaleCompare("lat",option+1) == 0)
1902 Local adaptive threshold image.
1904 (void) SyncImageSettings(mogrify_info,*image,exception);
1905 flags=ParseGeometry(argv[i+1],&geometry_info);
1906 if ((flags & PercentValue) != 0)
1907 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1908 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1909 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1910 geometry_info.xi,exception);
1913 if (LocaleCompare("level",option+1) == 0)
1926 (void) SyncImageSettings(mogrify_info,*image,exception);
1927 flags=ParseGeometry(argv[i+1],&geometry_info);
1928 black_point=geometry_info.rho;
1929 white_point=(MagickRealType) QuantumRange;
1930 if ((flags & SigmaValue) != 0)
1931 white_point=geometry_info.sigma;
1933 if ((flags & XiValue) != 0)
1934 gamma=geometry_info.xi;
1935 if ((flags & PercentValue) != 0)
1937 black_point*=(MagickRealType) (QuantumRange/100.0);
1938 white_point*=(MagickRealType) (QuantumRange/100.0);
1940 if ((flags & SigmaValue) == 0)
1941 white_point=(MagickRealType) QuantumRange-black_point;
1942 if ((*option == '+') || ((flags & AspectValue) != 0))
1943 (void) LevelizeImage(*image,black_point,white_point,gamma,
1946 (void) LevelImage(*image,black_point,white_point,gamma,
1950 if (LocaleCompare("level-colors",option+1) == 0)
1953 token[MaxTextExtent];
1962 p=(const char *) argv[i+1];
1963 GetMagickToken(p,&p,token); /* get black point color */
1964 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1965 (void) QueryColorCompliance(token,AllCompliance,
1966 &black_point,exception);
1968 (void) QueryColorCompliance("#000000",AllCompliance,
1969 &black_point,exception);
1970 if (isalpha((int) token[0]) || (token[0] == '#'))
1971 GetMagickToken(p,&p,token);
1973 white_point=black_point; /* set everything to that color */
1976 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1977 GetMagickToken(p,&p,token); /* Get white point color. */
1978 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1979 (void) QueryColorCompliance(token,AllCompliance,
1980 &white_point,exception);
1982 (void) QueryColorCompliance("#ffffff",AllCompliance,
1983 &white_point,exception);
1985 (void) LevelImageColors(*image,&black_point,&white_point,
1986 *option == '+' ? MagickTrue : MagickFalse,exception);
1989 if (LocaleCompare("linear-stretch",option+1) == 0)
1998 (void) SyncImageSettings(mogrify_info,*image,exception);
1999 flags=ParseGeometry(argv[i+1],&geometry_info);
2000 black_point=geometry_info.rho;
2001 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2002 if ((flags & SigmaValue) != 0)
2003 white_point=geometry_info.sigma;
2004 if ((flags & PercentValue) != 0)
2006 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2007 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2009 if ((flags & SigmaValue) == 0)
2010 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2012 (void) LinearStretchImage(*image,black_point,white_point,exception);
2015 if (LocaleCompare("liquid-rescale",option+1) == 0)
2018 Liquid rescale image.
2020 (void) SyncImageSettings(mogrify_info,*image,exception);
2021 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2022 if ((flags & XValue) == 0)
2024 if ((flags & YValue) == 0)
2026 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2027 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2030 if (LocaleCompare("lowlight-color",option+1) == 0)
2032 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2039 if (LocaleCompare("map",option+1) == 0)
2045 Transform image colors to match this set of colors.
2047 (void) SyncImageSettings(mogrify_info,*image,exception);
2050 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2051 if (remap_image == (Image *) NULL)
2053 (void) RemapImage(quantize_info,*image,remap_image,exception);
2054 remap_image=DestroyImage(remap_image);
2057 if (LocaleCompare("mask",option+1) == 0)
2062 (void) SyncImageSettings(mogrify_info,*image,exception);
2068 (void) SetImageMask(*image,(Image *) NULL,exception);
2074 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2075 if (mask == (Image *) NULL)
2077 (void) SetImageMask(*image,mask,exception);
2078 mask=DestroyImage(mask);
2081 if (LocaleCompare("matte",option+1) == 0)
2083 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2084 SetAlphaChannel : DeactivateAlphaChannel,exception);
2087 if (LocaleCompare("median",option+1) == 0)
2090 Median filter image.
2092 (void) SyncImageSettings(mogrify_info,*image,exception);
2093 flags=ParseGeometry(argv[i+1],&geometry_info);
2094 if ((flags & SigmaValue) == 0)
2095 geometry_info.sigma=geometry_info.rho;
2096 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2097 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2100 if (LocaleCompare("mode",option+1) == 0)
2105 (void) SyncImageSettings(mogrify_info,*image,exception);
2106 flags=ParseGeometry(argv[i+1],&geometry_info);
2107 if ((flags & SigmaValue) == 0)
2108 geometry_info.sigma=geometry_info.rho;
2109 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2110 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2113 if (LocaleCompare("modulate",option+1) == 0)
2115 (void) SyncImageSettings(mogrify_info,*image,exception);
2116 (void) ModulateImage(*image,argv[i+1],exception);
2119 if (LocaleCompare("monitor",option+1) == 0)
2123 (void) SetImageProgressMonitor(*image,
2124 (MagickProgressMonitor) NULL,(void *) NULL);
2127 (void) SetImageProgressMonitor(*image,MonitorProgress,
2131 if (LocaleCompare("monochrome",option+1) == 0)
2133 (void) SyncImageSettings(mogrify_info,*image,exception);
2134 (void) SetImageType(*image,BilevelType,exception);
2137 if (LocaleCompare("morphology",option+1) == 0)
2140 token[MaxTextExtent];
2155 Morphological Image Operation
2157 (void) SyncImageSettings(mogrify_info,*image,exception);
2159 GetMagickToken(p,&p,token);
2160 method=(MorphologyMethod) ParseCommandOption(
2161 MagickMorphologyOptions,MagickFalse,token);
2163 GetMagickToken(p,&p,token);
2164 if ((*p == ':') || (*p == ','))
2165 GetMagickToken(p,&p,token);
2167 iterations=(ssize_t) StringToLong(p);
2168 kernel=AcquireKernelInfo(argv[i+2]);
2169 if (kernel == (KernelInfo *) NULL)
2171 (void) ThrowMagickException(exception,GetMagickModule(),
2172 OptionError,"UnabletoParseKernel","morphology");
2176 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2178 kernel=DestroyKernelInfo(kernel);
2181 if (LocaleCompare("motion-blur",option+1) == 0)
2186 (void) SyncImageSettings(mogrify_info,*image,exception);
2187 flags=ParseGeometry(argv[i+1],&geometry_info);
2188 if ((flags & SigmaValue) == 0)
2189 geometry_info.sigma=1.0;
2190 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2191 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2198 if (LocaleCompare("negate",option+1) == 0)
2200 (void) SyncImageSettings(mogrify_info,*image,exception);
2201 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2202 MagickFalse,exception);
2205 if (LocaleCompare("noise",option+1) == 0)
2207 (void) SyncImageSettings(mogrify_info,*image,exception);
2210 flags=ParseGeometry(argv[i+1],&geometry_info);
2211 if ((flags & SigmaValue) == 0)
2212 geometry_info.sigma=geometry_info.rho;
2213 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2214 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2221 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2222 MagickFalse,argv[i+1]);
2223 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2227 if (LocaleCompare("normalize",option+1) == 0)
2229 (void) SyncImageSettings(mogrify_info,*image,exception);
2230 (void) NormalizeImage(*image,exception);
2237 if (LocaleCompare("opaque",option+1) == 0)
2242 (void) SyncImageSettings(mogrify_info,*image,exception);
2243 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2245 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2246 MagickFalse : MagickTrue,exception);
2249 if (LocaleCompare("ordered-dither",option+1) == 0)
2251 (void) SyncImageSettings(mogrify_info,*image,exception);
2252 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2259 if (LocaleCompare("paint",option+1) == 0)
2261 (void) SyncImageSettings(mogrify_info,*image,exception);
2262 (void) ParseGeometry(argv[i+1],&geometry_info);
2263 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2264 geometry_info.sigma,exception);
2267 if (LocaleCompare("pointsize",option+1) == 0)
2270 (void) ParseGeometry("12",&geometry_info);
2272 (void) ParseGeometry(argv[i+1],&geometry_info);
2273 draw_info->pointsize=geometry_info.rho;
2276 if (LocaleCompare("polaroid",option+1) == 0)
2288 Simulate a Polaroid picture.
2290 (void) SyncImageSettings(mogrify_info,*image,exception);
2291 random_info=AcquireRandomInfo();
2292 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2293 random_info=DestroyRandomInfo(random_info);
2296 SetGeometryInfo(&geometry_info);
2297 flags=ParseGeometry(argv[i+1],&geometry_info);
2298 angle=geometry_info.rho;
2300 caption=GetImageProperty(*image,"caption",exception);
2301 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2302 interpolate_method,exception);
2305 if (LocaleCompare("posterize",option+1) == 0)
2310 (void) SyncImageSettings(mogrify_info,*image,exception);
2311 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2312 quantize_info->dither,exception);
2315 if (LocaleCompare("preview",option+1) == 0)
2323 (void) SyncImageSettings(mogrify_info,*image,exception);
2325 preview_type=UndefinedPreview;
2327 preview_type=(PreviewType) ParseCommandOption(
2328 MagickPreviewOptions,MagickFalse,argv[i+1]);
2329 mogrify_image=PreviewImage(*image,preview_type,exception);
2332 if (LocaleCompare("profile",option+1) == 0)
2346 (void) SyncImageSettings(mogrify_info,*image,exception);
2350 Remove a profile from the image.
2352 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2357 Associate a profile with the image.
2359 profile_info=CloneImageInfo(mogrify_info);
2360 profile=GetImageProfile(*image,"iptc");
2361 if (profile != (StringInfo *) NULL)
2362 profile_info->profile=(void *) CloneStringInfo(profile);
2363 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2364 profile_info=DestroyImageInfo(profile_info);
2365 if (profile_image == (Image *) NULL)
2370 profile_info=CloneImageInfo(mogrify_info);
2371 (void) CopyMagickString(profile_info->filename,argv[i+1],
2373 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2374 if (profile != (StringInfo *) NULL)
2376 (void) ProfileImage(*image,profile_info->magick,
2377 GetStringInfoDatum(profile),(size_t)
2378 GetStringInfoLength(profile),exception);
2379 profile=DestroyStringInfo(profile);
2381 profile_info=DestroyImageInfo(profile_info);
2384 ResetImageProfileIterator(profile_image);
2385 name=GetNextImageProfile(profile_image);
2386 while (name != (const char *) NULL)
2388 profile=GetImageProfile(profile_image,name);
2389 if (profile != (StringInfo *) NULL)
2390 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2391 (size_t) GetStringInfoLength(profile),exception);
2392 name=GetNextImageProfile(profile_image);
2394 profile_image=DestroyImage(profile_image);
2401 if (LocaleCompare("quantize",option+1) == 0)
2405 quantize_info->colorspace=UndefinedColorspace;
2408 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2409 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2416 if (LocaleCompare("radial-blur",option+1) == 0)
2421 (void) SyncImageSettings(mogrify_info,*image,exception);
2422 flags=ParseGeometry(argv[i+1],&geometry_info);
2423 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2424 geometry_info.sigma,exception);
2427 if (LocaleCompare("raise",option+1) == 0)
2430 Surround image with a raise of solid color.
2432 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2433 if ((flags & SigmaValue) == 0)
2434 geometry.height=geometry.width;
2435 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2436 MagickFalse,exception);
2439 if (LocaleCompare("random-threshold",option+1) == 0)
2444 (void) SyncImageSettings(mogrify_info,*image,exception);
2445 (void) RandomThresholdImage(*image,argv[i+1],exception);
2448 if (LocaleCompare("region",option+1) == 0)
2450 (void) SyncImageSettings(mogrify_info,*image,exception);
2451 if (region_image != (Image *) NULL)
2456 (void) CompositeImage(region_image,region_image->matte !=
2457 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2458 region_geometry.x,region_geometry.y,exception);
2459 *image=DestroyImage(*image);
2460 *image=region_image;
2461 region_image = (Image *) NULL;
2466 Apply transformations to a selected region of the image.
2468 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2470 mogrify_image=CropImage(*image,®ion_geometry,exception);
2471 if (mogrify_image == (Image *) NULL)
2473 region_image=(*image);
2474 *image=mogrify_image;
2475 mogrify_image=(Image *) NULL;
2478 if (LocaleCompare("render",option+1) == 0)
2480 (void) SyncImageSettings(mogrify_info,*image,exception);
2481 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2484 if (LocaleCompare("remap",option+1) == 0)
2490 Transform image colors to match this set of colors.
2492 (void) SyncImageSettings(mogrify_info,*image,exception);
2495 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2496 if (remap_image == (Image *) NULL)
2498 (void) RemapImage(quantize_info,*image,remap_image,exception);
2499 remap_image=DestroyImage(remap_image);
2502 if (LocaleCompare("repage",option+1) == 0)
2506 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2509 (void) ResetImagePage(*image,argv[i+1]);
2512 if (LocaleCompare("resample",option+1) == 0)
2517 (void) SyncImageSettings(mogrify_info,*image,exception);
2518 flags=ParseGeometry(argv[i+1],&geometry_info);
2519 if ((flags & SigmaValue) == 0)
2520 geometry_info.sigma=geometry_info.rho;
2521 mogrify_image=ResampleImage(*image,geometry_info.rho,
2522 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2525 if (LocaleCompare("resize",option+1) == 0)
2530 (void) SyncImageSettings(mogrify_info,*image,exception);
2531 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2532 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2533 (*image)->filter,(*image)->blur,exception);
2536 if (LocaleCompare("roll",option+1) == 0)
2541 (void) SyncImageSettings(mogrify_info,*image,exception);
2542 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2543 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2546 if (LocaleCompare("rotate",option+1) == 0)
2552 Check for conditional image rotation.
2554 (void) SyncImageSettings(mogrify_info,*image,exception);
2555 if (strchr(argv[i+1],'>') != (char *) NULL)
2556 if ((*image)->columns <= (*image)->rows)
2558 if (strchr(argv[i+1],'<') != (char *) NULL)
2559 if ((*image)->columns >= (*image)->rows)
2564 geometry=ConstantString(argv[i+1]);
2565 (void) SubstituteString(&geometry,">","");
2566 (void) SubstituteString(&geometry,"<","");
2567 (void) ParseGeometry(geometry,&geometry_info);
2568 geometry=DestroyString(geometry);
2569 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2576 if (LocaleCompare("sample",option+1) == 0)
2579 Sample image with pixel replication.
2581 (void) SyncImageSettings(mogrify_info,*image,exception);
2582 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2583 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2587 if (LocaleCompare("scale",option+1) == 0)
2592 (void) SyncImageSettings(mogrify_info,*image,exception);
2593 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2594 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2598 if (LocaleCompare("selective-blur",option+1) == 0)
2601 Selectively blur pixels within a contrast threshold.
2603 (void) SyncImageSettings(mogrify_info,*image,exception);
2604 flags=ParseGeometry(argv[i+1],&geometry_info);
2605 if ((flags & PercentValue) != 0)
2606 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2607 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2608 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2611 if (LocaleCompare("separate",option+1) == 0)
2614 Break channels into separate images.
2616 (void) SyncImageSettings(mogrify_info,*image,exception);
2617 mogrify_image=SeparateImages(*image,exception);
2620 if (LocaleCompare("sepia-tone",option+1) == 0)
2628 (void) SyncImageSettings(mogrify_info,*image,exception);
2629 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2631 mogrify_image=SepiaToneImage(*image,threshold,exception);
2634 if (LocaleCompare("segment",option+1) == 0)
2639 (void) SyncImageSettings(mogrify_info,*image,exception);
2640 flags=ParseGeometry(argv[i+1],&geometry_info);
2641 if ((flags & SigmaValue) == 0)
2642 geometry_info.sigma=1.0;
2643 (void) SegmentImage(*image,(*image)->colorspace,
2644 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2648 if (LocaleCompare("set",option+1) == 0)
2658 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2659 (void) DeleteImageRegistry(argv[i+1]+9);
2661 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2663 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2664 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2667 (void) DeleteImageProperty(*image,argv[i+1]);
2670 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2672 if (value == (char *) NULL)
2674 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2675 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2678 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2680 (void) SetImageOption(image_info,argv[i+1]+7,value);
2681 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2682 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2685 (void) SetImageProperty(*image,argv[i+1],value,exception);
2686 value=DestroyString(value);
2689 if (LocaleCompare("shade",option+1) == 0)
2694 (void) SyncImageSettings(mogrify_info,*image,exception);
2695 flags=ParseGeometry(argv[i+1],&geometry_info);
2696 if ((flags & SigmaValue) == 0)
2697 geometry_info.sigma=1.0;
2698 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2699 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2702 if (LocaleCompare("shadow",option+1) == 0)
2707 (void) SyncImageSettings(mogrify_info,*image,exception);
2708 flags=ParseGeometry(argv[i+1],&geometry_info);
2709 if ((flags & SigmaValue) == 0)
2710 geometry_info.sigma=1.0;
2711 if ((flags & XiValue) == 0)
2712 geometry_info.xi=4.0;
2713 if ((flags & PsiValue) == 0)
2714 geometry_info.psi=4.0;
2715 mogrify_image=ShadowImage(*image,geometry_info.rho,
2716 geometry_info.sigma,(*image)->bias,(ssize_t)
2717 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
2721 if (LocaleCompare("sharpen",option+1) == 0)
2726 (void) SyncImageSettings(mogrify_info,*image,exception);
2727 flags=ParseGeometry(argv[i+1],&geometry_info);
2728 if ((flags & SigmaValue) == 0)
2729 geometry_info.sigma=1.0;
2730 if ((flags & XiValue) == 0)
2731 geometry_info.xi=0.0;
2732 mogrify_image=SharpenImage(*image,geometry_info.rho,
2733 geometry_info.sigma,geometry_info.xi,exception);
2736 if (LocaleCompare("shave",option+1) == 0)
2739 Shave the image edges.
2741 (void) SyncImageSettings(mogrify_info,*image,exception);
2742 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2743 mogrify_image=ShaveImage(*image,&geometry,exception);
2746 if (LocaleCompare("shear",option+1) == 0)
2751 (void) SyncImageSettings(mogrify_info,*image,exception);
2752 flags=ParseGeometry(argv[i+1],&geometry_info);
2753 if ((flags & SigmaValue) == 0)
2754 geometry_info.sigma=geometry_info.rho;
2755 mogrify_image=ShearImage(*image,geometry_info.rho,
2756 geometry_info.sigma,exception);
2759 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2762 Sigmoidal non-linearity contrast control.
2764 (void) SyncImageSettings(mogrify_info,*image,exception);
2765 flags=ParseGeometry(argv[i+1],&geometry_info);
2766 if ((flags & SigmaValue) == 0)
2767 geometry_info.sigma=(double) QuantumRange/2.0;
2768 if ((flags & PercentValue) != 0)
2769 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2771 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2772 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2776 if (LocaleCompare("sketch",option+1) == 0)
2781 (void) SyncImageSettings(mogrify_info,*image,exception);
2782 flags=ParseGeometry(argv[i+1],&geometry_info);
2783 if ((flags & SigmaValue) == 0)
2784 geometry_info.sigma=1.0;
2785 mogrify_image=SketchImage(*image,geometry_info.rho,
2786 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2789 if (LocaleCompare("solarize",option+1) == 0)
2794 (void) SyncImageSettings(mogrify_info,*image,exception);
2795 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2797 (void) SolarizeImage(*image,threshold,exception);
2800 if (LocaleCompare("sparse-color",option+1) == 0)
2809 Sparse Color Interpolated Gradient
2811 (void) SyncImageSettings(mogrify_info,*image,exception);
2812 method=(SparseColorMethod) ParseCommandOption(
2813 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2814 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2816 if (arguments == (char *) NULL)
2818 mogrify_image=SparseColorOption(*image,method,arguments,
2819 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2820 arguments=DestroyString(arguments);
2823 if (LocaleCompare("splice",option+1) == 0)
2826 Splice a solid color into the image.
2828 (void) SyncImageSettings(mogrify_info,*image,exception);
2829 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2830 mogrify_image=SpliceImage(*image,&geometry,exception);
2833 if (LocaleCompare("spread",option+1) == 0)
2838 (void) SyncImageSettings(mogrify_info,*image,exception);
2839 (void) ParseGeometry(argv[i+1],&geometry_info);
2840 mogrify_image=SpreadImage(*image,geometry_info.rho,
2841 interpolate_method,exception);
2844 if (LocaleCompare("statistic",option+1) == 0)
2849 (void) SyncImageSettings(mogrify_info,*image,exception);
2850 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2851 MagickFalse,argv[i+1]);
2852 (void) ParseGeometry(argv[i+2],&geometry_info);
2853 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2854 (size_t) geometry_info.sigma,exception);
2857 if (LocaleCompare("stretch",option+1) == 0)
2861 draw_info->stretch=UndefinedStretch;
2864 draw_info->stretch=(StretchType) ParseCommandOption(
2865 MagickStretchOptions,MagickFalse,argv[i+1]);
2868 if (LocaleCompare("strip",option+1) == 0)
2871 Strip image of profiles and comments.
2873 (void) SyncImageSettings(mogrify_info,*image,exception);
2874 (void) StripImage(*image,exception);
2877 if (LocaleCompare("stroke",option+1) == 0)
2887 (void) QueryColorCompliance("none",AllCompliance,
2888 &draw_info->stroke,exception);
2889 if (draw_info->stroke_pattern != (Image *) NULL)
2890 draw_info->stroke_pattern=DestroyImage(
2891 draw_info->stroke_pattern);
2894 sans=AcquireExceptionInfo();
2895 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2896 sans=DestroyExceptionInfo(sans);
2897 if (status == MagickFalse)
2898 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2901 draw_info->stroke=color;
2904 if (LocaleCompare("strokewidth",option+1) == 0)
2906 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2909 if (LocaleCompare("style",option+1) == 0)
2913 draw_info->style=UndefinedStyle;
2916 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2917 MagickFalse,argv[i+1]);
2920 if (LocaleCompare("swirl",option+1) == 0)
2925 (void) SyncImageSettings(mogrify_info,*image,exception);
2926 (void) ParseGeometry(argv[i+1],&geometry_info);
2927 mogrify_image=SwirlImage(*image,geometry_info.rho,
2928 interpolate_method,exception);
2935 if (LocaleCompare("threshold",option+1) == 0)
2943 (void) SyncImageSettings(mogrify_info,*image,exception);
2945 threshold=(double) QuantumRange/2;
2947 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2949 (void) BilevelImage(*image,threshold,exception);
2952 if (LocaleCompare("thumbnail",option+1) == 0)
2957 (void) SyncImageSettings(mogrify_info,*image,exception);
2958 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2959 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2963 if (LocaleCompare("tile",option+1) == 0)
2967 if (draw_info->fill_pattern != (Image *) NULL)
2968 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2971 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2975 if (LocaleCompare("tint",option+1) == 0)
2980 (void) SyncImageSettings(mogrify_info,*image,exception);
2981 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2984 if (LocaleCompare("transform",option+1) == 0)
2987 Affine transform image.
2989 (void) SyncImageSettings(mogrify_info,*image,exception);
2990 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2994 if (LocaleCompare("transparent",option+1) == 0)
2999 (void) SyncImageSettings(mogrify_info,*image,exception);
3000 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3002 (void) TransparentPaintImage(*image,&target,(Quantum)
3003 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3007 if (LocaleCompare("transpose",option+1) == 0)
3010 Transpose image scanlines.
3012 (void) SyncImageSettings(mogrify_info,*image,exception);
3013 mogrify_image=TransposeImage(*image,exception);
3016 if (LocaleCompare("transverse",option+1) == 0)
3019 Transverse image scanlines.
3021 (void) SyncImageSettings(mogrify_info,*image,exception);
3022 mogrify_image=TransverseImage(*image,exception);
3025 if (LocaleCompare("treedepth",option+1) == 0)
3027 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3030 if (LocaleCompare("trim",option+1) == 0)
3035 (void) SyncImageSettings(mogrify_info,*image,exception);
3036 mogrify_image=TrimImage(*image,exception);
3039 if (LocaleCompare("type",option+1) == 0)
3044 (void) SyncImageSettings(mogrify_info,*image,exception);
3048 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3050 (*image)->type=UndefinedType;
3051 (void) SetImageType(*image,type,exception);
3058 if (LocaleCompare("undercolor",option+1) == 0)
3060 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3061 &draw_info->undercolor,exception);
3064 if (LocaleCompare("unique",option+1) == 0)
3068 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3071 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3072 (void) SetImageArtifact(*image,"verbose","true");
3075 if (LocaleCompare("unique-colors",option+1) == 0)
3078 Unique image colors.
3080 (void) SyncImageSettings(mogrify_info,*image,exception);
3081 mogrify_image=UniqueImageColors(*image,exception);
3084 if (LocaleCompare("unsharp",option+1) == 0)
3089 (void) SyncImageSettings(mogrify_info,*image,exception);
3090 flags=ParseGeometry(argv[i+1],&geometry_info);
3091 if ((flags & SigmaValue) == 0)
3092 geometry_info.sigma=1.0;
3093 if ((flags & XiValue) == 0)
3094 geometry_info.xi=1.0;
3095 if ((flags & PsiValue) == 0)
3096 geometry_info.psi=0.05;
3097 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3098 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3105 if (LocaleCompare("verbose",option+1) == 0)
3107 (void) SetImageArtifact(*image,option+1,
3108 *option == '+' ? "false" : "true");
3111 if (LocaleCompare("vignette",option+1) == 0)
3116 (void) SyncImageSettings(mogrify_info,*image,exception);
3117 flags=ParseGeometry(argv[i+1],&geometry_info);
3118 if ((flags & SigmaValue) == 0)
3119 geometry_info.sigma=1.0;
3120 if ((flags & XiValue) == 0)
3121 geometry_info.xi=0.1*(*image)->columns;
3122 if ((flags & PsiValue) == 0)
3123 geometry_info.psi=0.1*(*image)->rows;
3124 mogrify_image=VignetteImage(*image,geometry_info.rho,
3125 geometry_info.sigma,(*image)->bias,(ssize_t)
3126 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3130 if (LocaleCompare("virtual-pixel",option+1) == 0)
3134 (void) SetImageVirtualPixelMethod(*image,
3135 UndefinedVirtualPixelMethod,exception);
3138 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3139 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3140 argv[i+1]),exception);
3147 if (LocaleCompare("wave",option+1) == 0)
3152 (void) SyncImageSettings(mogrify_info,*image,exception);
3153 flags=ParseGeometry(argv[i+1],&geometry_info);
3154 if ((flags & SigmaValue) == 0)
3155 geometry_info.sigma=1.0;
3156 mogrify_image=WaveImage(*image,geometry_info.rho,
3157 geometry_info.sigma,interpolate_method,exception);
3160 if (LocaleCompare("weight",option+1) == 0)
3162 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3163 if (LocaleCompare(argv[i+1],"all") == 0)
3164 draw_info->weight=0;
3165 if (LocaleCompare(argv[i+1],"bold") == 0)
3166 draw_info->weight=700;
3167 if (LocaleCompare(argv[i+1],"bolder") == 0)
3168 if (draw_info->weight <= 800)
3169 draw_info->weight+=100;
3170 if (LocaleCompare(argv[i+1],"lighter") == 0)
3171 if (draw_info->weight >= 100)
3172 draw_info->weight-=100;
3173 if (LocaleCompare(argv[i+1],"normal") == 0)
3174 draw_info->weight=400;
3177 if (LocaleCompare("white-threshold",option+1) == 0)
3180 White threshold image.
3182 (void) SyncImageSettings(mogrify_info,*image,exception);
3183 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3192 Replace current image with any image that was generated
3194 if (mogrify_image != (Image *) NULL)
3195 ReplaceImageInListReturnLast(image,mogrify_image);
3198 if (region_image != (Image *) NULL)
3201 Composite transformed region onto image.
3203 (void) SyncImageSettings(mogrify_info,*image,exception);
3204 (void) CompositeImage(region_image,region_image->matte !=
3205 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3206 region_geometry.x,region_geometry.y,exception);
3207 *image=DestroyImage(*image);
3208 *image=region_image;
3209 region_image = (Image *) NULL;
3214 quantize_info=DestroyQuantizeInfo(quantize_info);
3215 draw_info=DestroyDrawInfo(draw_info);
3216 mogrify_info=DestroyImageInfo(mogrify_info);
3217 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3218 return(status == 0 ? MagickFalse : MagickTrue);
3222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3226 + M o g r i f y I m a g e C o m m a n d %
3230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3232 % MogrifyImageCommand() transforms an image or a sequence of images. These
3233 % transforms include image scaling, image rotation, color reduction, and
3234 % others. The transmogrified image overwrites the original image.
3236 % The format of the MogrifyImageCommand method is:
3238 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3239 % const char **argv,char **metadata,ExceptionInfo *exception)
3241 % A description of each parameter follows:
3243 % o image_info: the image info.
3245 % o argc: the number of elements in the argument vector.
3247 % o argv: A text array containing the command line arguments.
3249 % o metadata: any metadata is returned here.
3251 % o exception: return any errors or warnings in this structure.
3255 static MagickBooleanType MogrifyUsage(void)
3260 "-debug events display copious debugging information",
3261 "-help print program options",
3262 "-list type print a list of supported option arguments",
3263 "-log format format of debugging information",
3264 "-version print version information",
3269 "-adaptive-blur geometry",
3270 " adaptively blur pixels; decrease effect near edges",
3271 "-adaptive-resize geometry",
3272 " adaptively resize image using 'mesh' interpolation",
3273 "-adaptive-sharpen geometry",
3274 " adaptively sharpen pixels; increase effect near edges",
3275 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3276 " transparent, extract, background, or shape",
3277 "-annotate geometry text",
3278 " annotate the image with text",
3279 "-auto-gamma automagically adjust gamma level of image",
3280 "-auto-level automagically adjust color levels of image",
3281 "-auto-orient automagically orient (rotate) image",
3282 "-bench iterations measure performance",
3283 "-black-threshold value",
3284 " force all pixels below the threshold into black",
3285 "-blue-shift simulate a scene at nighttime in the moonlight",
3286 "-blur geometry reduce image noise and reduce detail levels",
3287 "-border geometry surround image with a border of color",
3288 "-bordercolor color border color",
3289 "-brightness-contrast geometry",
3290 " improve brightness / contrast of the image",
3291 "-cdl filename color correct with a color decision list",
3292 "-charcoal geometry simulate a charcoal drawing",
3293 "-chop geometry remove pixels from the image interior",
3294 "-clamp restrict pixel range from 0 to the quantum depth",
3295 "-clip clip along the first path from the 8BIM profile",
3296 "-clip-mask filename associate a clip mask with the image",
3297 "-clip-path id clip along a named path from the 8BIM profile",
3298 "-colorize value colorize the image with the fill color",
3299 "-color-matrix matrix apply color correction to the image",
3300 "-contrast enhance or reduce the image contrast",
3301 "-contrast-stretch geometry",
3302 " improve contrast by `stretching' the intensity range",
3303 "-convolve coefficients",
3304 " apply a convolution kernel to the image",
3305 "-cycle amount cycle the image colormap",
3306 "-decipher filename convert cipher pixels to plain pixels",
3307 "-deskew threshold straighten an image",
3308 "-despeckle reduce the speckles within an image",
3309 "-distort method args",
3310 " distort images according to given method ad args",
3311 "-draw string annotate the image with a graphic primitive",
3312 "-edge radius apply a filter to detect edges in the image",
3313 "-encipher filename convert plain pixels to cipher pixels",
3314 "-emboss radius emboss an image",
3315 "-enhance apply a digital filter to enhance a noisy image",
3316 "-equalize perform histogram equalization to an image",
3317 "-evaluate operator value",
3318 " evaluate an arithmetic, relational, or logical expression",
3319 "-extent geometry set the image size",
3320 "-extract geometry extract area from image",
3321 "-fft implements the discrete Fourier transform (DFT)",
3322 "-flip flip image vertically",
3323 "-floodfill geometry color",
3324 " floodfill the image with color",
3325 "-flop flop image horizontally",
3326 "-frame geometry surround image with an ornamental border",
3327 "-function name parameters",
3328 " apply function over image values",
3329 "-gamma value level of gamma correction",
3330 "-gaussian-blur geometry",
3331 " reduce image noise and reduce detail levels",
3332 "-geometry geometry preferred size or location of the image",
3333 "-identify identify the format and characteristics of the image",
3334 "-ift implements the inverse discrete Fourier transform (DFT)",
3335 "-implode amount implode image pixels about the center",
3336 "-interpolative-resize geometry",
3337 " resize image using interpolation",
3338 "-lat geometry local adaptive thresholding",
3339 "-layers method optimize, merge, or compare image layers",
3340 "-level value adjust the level of image contrast",
3341 "-level-colors color,color",
3342 " level image with the given colors",
3343 "-linear-stretch geometry",
3344 " improve contrast by `stretching with saturation'",
3345 "-liquid-rescale geometry",
3346 " rescale image with seam-carving",
3347 "-median geometry apply a median filter to the image",
3348 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3349 "-modulate value vary the brightness, saturation, and hue",
3350 "-monochrome transform image to black and white",
3351 "-morphology method kernel",
3352 " apply a morphology method to the image",
3353 "-motion-blur geometry",
3354 " simulate motion blur",
3355 "-negate replace every pixel with its complementary color ",
3356 "-noise geometry add or reduce noise in an image",
3357 "-normalize transform image to span the full range of colors",
3358 "-opaque color change this color to the fill color",
3359 "-ordered-dither NxN",
3360 " add a noise pattern to the image with specific",
3362 "-paint radius simulate an oil painting",
3363 "-polaroid angle simulate a Polaroid picture",
3364 "-posterize levels reduce the image to a limited number of color levels",
3365 "-profile filename add, delete, or apply an image profile",
3366 "-quantize colorspace reduce colors in this colorspace",
3367 "-radial-blur angle radial blur the image",
3368 "-raise value lighten/darken image edges to create a 3-D effect",
3369 "-random-threshold low,high",
3370 " random threshold the image",
3371 "-region geometry apply options to a portion of the image",
3372 "-render render vector graphics",
3373 "-repage geometry size and location of an image canvas",
3374 "-resample geometry change the resolution of an image",
3375 "-resize geometry resize the image",
3376 "-roll geometry roll an image vertically or horizontally",
3377 "-rotate degrees apply Paeth rotation to the image",
3378 "-sample geometry scale image with pixel sampling",
3379 "-scale geometry scale the image",
3380 "-segment values segment an image",
3381 "-selective-blur geometry",
3382 " selectively blur pixels within a contrast threshold",
3383 "-sepia-tone threshold",
3384 " simulate a sepia-toned photo",
3385 "-set property value set an image property",
3386 "-shade degrees shade the image using a distant light source",
3387 "-shadow geometry simulate an image shadow",
3388 "-sharpen geometry sharpen the image",
3389 "-shave geometry shave pixels from the image edges",
3390 "-shear geometry slide one edge of the image along the X or Y axis",
3391 "-sigmoidal-contrast geometry",
3392 " increase the contrast without saturating highlights or shadows",
3393 "-sketch geometry simulate a pencil sketch",
3394 "-solarize threshold negate all pixels above the threshold level",
3395 "-sparse-color method args",
3396 " fill in a image based on a few color points",
3397 "-splice geometry splice the background color into the image",
3398 "-spread radius displace image pixels by a random amount",
3399 "-statistic type radius",
3400 " replace each pixel with corresponding statistic from the neighborhood",
3401 "-strip strip image of all profiles and comments",
3402 "-swirl degrees swirl image pixels about the center",
3403 "-threshold value threshold the image",
3404 "-thumbnail geometry create a thumbnail of the image",
3405 "-tile filename tile image when filling a graphic primitive",
3406 "-tint value tint the image with the fill color",
3407 "-transform affine transform image",
3408 "-transparent color make this color transparent within the image",
3409 "-transpose flip image vertically and rotate 90 degrees",
3410 "-transverse flop image horizontally and rotate 270 degrees",
3411 "-trim trim image edges",
3412 "-type type image type",
3413 "-unique-colors discard all but one of any pixel color",
3414 "-unsharp geometry sharpen the image",
3415 "-vignette geometry soften the edges of the image in vignette style",
3416 "-wave geometry alter an image along a sine wave",
3417 "-white-threshold value",
3418 " force all pixels above the threshold into white",
3421 *sequence_operators[]=
3423 "-append append an image sequence",
3424 "-clut apply a color lookup table to the image",
3425 "-coalesce merge a sequence of images",
3426 "-combine combine a sequence of images",
3427 "-composite composite image",
3428 "-crop geometry cut out a rectangular region of the image",
3429 "-deconstruct break down an image sequence into constituent parts",
3430 "-evaluate-sequence operator",
3431 " evaluate an arithmetic, relational, or logical expression",
3432 "-flatten flatten a sequence of images",
3433 "-fx expression apply mathematical expression to an image channel(s)",
3434 "-hald-clut apply a Hald color lookup table to the image",
3435 "-morph value morph an image sequence",
3436 "-mosaic create a mosaic from an image sequence",
3437 "-print string interpret string and print to console",
3438 "-process arguments process the image with a custom image filter",
3439 "-separate separate an image channel into a grayscale image",
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 Sequence Operators:\n");
3564 for (p=sequence_operators; *p != (char *) NULL; p++)
3565 (void) printf(" %s\n",*p);
3566 (void) printf("\nImage Stack Operators:\n");
3567 for (p=stack_operators; *p != (char *) NULL; p++)
3568 (void) printf(" %s\n",*p);
3569 (void) printf("\nMiscellaneous Options:\n");
3570 for (p=miscellaneous; *p != (char *) NULL; p++)
3571 (void) printf(" %s\n",*p);
3573 "\nBy default, the image format of 'file' is determined by its magic\n");
3575 "number. To specify a particular image format, precede the filename\n");
3577 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3579 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3580 (void) printf("'-' for standard input or output.\n");
3581 return(MagickFalse);
3584 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3585 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3587 #define DestroyMogrify() \
3589 if (format != (char *) NULL) \
3590 format=DestroyString(format); \
3591 if (path != (char *) NULL) \
3592 path=DestroyString(path); \
3593 DestroyImageStack(); \
3594 for (i=0; i < (ssize_t) argc; i++) \
3595 argv[i]=DestroyString(argv[i]); \
3596 argv=(char **) RelinquishMagickMemory(argv); \
3598 #define ThrowMogrifyException(asperity,tag,option) \
3600 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3603 return(MagickFalse); \
3605 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3607 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3608 "InvalidArgument","`%s': %s",argument,option); \
3610 return(MagickFalse); \
3622 image_stack[MaxImageStackDepth+1];
3630 respect_parenthesis;
3645 assert(image_info != (ImageInfo *) NULL);
3646 assert(image_info->signature == MagickSignature);
3647 if (image_info->debug != MagickFalse)
3648 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3649 assert(exception != (ExceptionInfo *) NULL);
3653 if ((LocaleCompare("version",option+1) == 0) ||
3654 (LocaleCompare("-version",option+1) == 0))
3656 (void) FormatLocaleFile(stdout,"Version: %s\n",
3657 GetMagickVersion((size_t *) NULL));
3658 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3659 GetMagickCopyright());
3660 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3661 GetMagickFeatures());
3662 return(MagickFalse);
3666 return(MogrifyUsage());
3667 format=(char *) NULL;
3669 global_colormap=MagickFalse;
3673 option=(char *) NULL;
3675 respect_parenthesis=MagickFalse;
3680 ReadCommandlLine(argc,&argv);
3681 status=ExpandFilenames(&argc,&argv);
3682 if (status == MagickFalse)
3683 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3684 GetExceptionMessage(errno));
3685 for (i=1; i < (ssize_t) argc; i++)
3688 if (LocaleCompare(option,"(") == 0)
3690 FireImageStack(MagickFalse,MagickTrue,pend);
3691 if (k == MaxImageStackDepth)
3692 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3697 if (LocaleCompare(option,")") == 0)
3699 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3701 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3705 if (IsCommandOption(option) == MagickFalse)
3708 backup_filename[MaxTextExtent],
3715 Option is a file name: begin by reading image from specified file.
3717 FireImageStack(MagickFalse,MagickFalse,pend);
3719 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3721 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3722 images=ReadImages(image_info,exception);
3723 status&=(images != (Image *) NULL) &&
3724 (exception->severity < ErrorException);
3725 if (images == (Image *) NULL)
3727 if (format != (char *) NULL)
3728 (void) CopyMagickString(images->filename,images->magick_filename,
3730 if (path != (char *) NULL)
3732 GetPathComponent(option,TailPath,filename);
3733 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3734 path,*DirectorySeparator,filename);
3736 if (format != (char *) NULL)
3737 AppendImageFormat(format,images->filename);
3738 AppendImageStack(images);
3739 FinalizeImageSettings(image_info,image,MagickFalse);
3740 if (global_colormap != MagickFalse)
3745 quantize_info=AcquireQuantizeInfo(image_info);
3746 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3747 quantize_info=DestroyQuantizeInfo(quantize_info);
3749 *backup_filename='\0';
3750 if ((LocaleCompare(image->filename,"-") != 0) &&
3751 (IsPathWritable(image->filename) != MagickFalse))
3757 Rename image file as backup.
3759 (void) CopyMagickString(backup_filename,image->filename,
3761 for (i=0; i < 6; i++)
3763 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3764 if (IsPathAccessible(backup_filename) == MagickFalse)
3767 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3768 (rename_utf8(image->filename,backup_filename) != 0))
3769 *backup_filename='\0';
3772 Write transmogrified image to disk.
3774 image_info->synchronize=MagickTrue;
3775 status&=WriteImages(image_info,image,image->filename,exception);
3776 if ((status == MagickFalse) && (*backup_filename != '\0'))
3777 (void) remove_utf8(backup_filename);
3778 RemoveAllImageStack();
3781 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3782 switch (*(option+1))
3786 if (LocaleCompare("adaptive-blur",option+1) == 0)
3789 if (i == (ssize_t) argc)
3790 ThrowMogrifyException(OptionError,"MissingArgument",option);
3791 if (IsGeometry(argv[i]) == MagickFalse)
3792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3795 if (LocaleCompare("adaptive-resize",option+1) == 0)
3798 if (i == (ssize_t) argc)
3799 ThrowMogrifyException(OptionError,"MissingArgument",option);
3800 if (IsGeometry(argv[i]) == MagickFalse)
3801 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3804 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3807 if (i == (ssize_t) argc)
3808 ThrowMogrifyException(OptionError,"MissingArgument",option);
3809 if (IsGeometry(argv[i]) == MagickFalse)
3810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3813 if (LocaleCompare("affine",option+1) == 0)
3818 if (i == (ssize_t) argc)
3819 ThrowMogrifyException(OptionError,"MissingArgument",option);
3822 if (LocaleCompare("alpha",option+1) == 0)
3830 if (i == (ssize_t) argc)
3831 ThrowMogrifyException(OptionError,"MissingArgument",option);
3832 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3834 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3838 if (LocaleCompare("annotate",option+1) == 0)
3843 if (i == (ssize_t) argc)
3844 ThrowMogrifyException(OptionError,"MissingArgument",option);
3845 if (IsGeometry(argv[i]) == MagickFalse)
3846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3847 if (i == (ssize_t) argc)
3848 ThrowMogrifyException(OptionError,"MissingArgument",option);
3852 if (LocaleCompare("antialias",option+1) == 0)
3854 if (LocaleCompare("append",option+1) == 0)
3856 if (LocaleCompare("attenuate",option+1) == 0)
3861 if (i == (ssize_t) (argc-1))
3862 ThrowMogrifyException(OptionError,"MissingArgument",option);
3863 if (IsGeometry(argv[i]) == MagickFalse)
3864 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3867 if (LocaleCompare("authenticate",option+1) == 0)
3872 if (i == (ssize_t) argc)
3873 ThrowMogrifyException(OptionError,"MissingArgument",option);
3876 if (LocaleCompare("auto-gamma",option+1) == 0)
3878 if (LocaleCompare("auto-level",option+1) == 0)
3880 if (LocaleCompare("auto-orient",option+1) == 0)
3882 if (LocaleCompare("average",option+1) == 0)
3884 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3888 if (LocaleCompare("background",option+1) == 0)
3893 if (i == (ssize_t) argc)
3894 ThrowMogrifyException(OptionError,"MissingArgument",option);
3897 if (LocaleCompare("bias",option+1) == 0)
3902 if (i == (ssize_t) (argc-1))
3903 ThrowMogrifyException(OptionError,"MissingArgument",option);
3904 if (IsGeometry(argv[i]) == MagickFalse)
3905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3908 if (LocaleCompare("black-point-compensation",option+1) == 0)
3910 if (LocaleCompare("black-threshold",option+1) == 0)
3915 if (i == (ssize_t) argc)
3916 ThrowMogrifyException(OptionError,"MissingArgument",option);
3917 if (IsGeometry(argv[i]) == MagickFalse)
3918 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3921 if (LocaleCompare("blue-primary",option+1) == 0)
3926 if (i == (ssize_t) argc)
3927 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (IsGeometry(argv[i]) == MagickFalse)
3929 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3932 if (LocaleCompare("blue-shift",option+1) == 0)
3935 if (i == (ssize_t) argc)
3936 ThrowMogrifyException(OptionError,"MissingArgument",option);
3937 if (IsGeometry(argv[i]) == MagickFalse)
3938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3941 if (LocaleCompare("blur",option+1) == 0)
3944 if (i == (ssize_t) argc)
3945 ThrowMogrifyException(OptionError,"MissingArgument",option);
3946 if (IsGeometry(argv[i]) == MagickFalse)
3947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3950 if (LocaleCompare("border",option+1) == 0)
3955 if (i == (ssize_t) argc)
3956 ThrowMogrifyException(OptionError,"MissingArgument",option);
3957 if (IsGeometry(argv[i]) == MagickFalse)
3958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3961 if (LocaleCompare("bordercolor",option+1) == 0)
3966 if (i == (ssize_t) argc)
3967 ThrowMogrifyException(OptionError,"MissingArgument",option);
3970 if (LocaleCompare("box",option+1) == 0)
3975 if (i == (ssize_t) argc)
3976 ThrowMogrifyException(OptionError,"MissingArgument",option);
3979 if (LocaleCompare("brightness-contrast",option+1) == 0)
3982 if (i == (ssize_t) argc)
3983 ThrowMogrifyException(OptionError,"MissingArgument",option);
3984 if (IsGeometry(argv[i]) == MagickFalse)
3985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3988 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3992 if (LocaleCompare("cache",option+1) == 0)
3997 if (i == (ssize_t) argc)
3998 ThrowMogrifyException(OptionError,"MissingArgument",option);
3999 if (IsGeometry(argv[i]) == MagickFalse)
4000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4003 if (LocaleCompare("caption",option+1) == 0)
4008 if (i == (ssize_t) argc)
4009 ThrowMogrifyException(OptionError,"MissingArgument",option);
4012 if (LocaleCompare("channel",option+1) == 0)
4020 if (i == (ssize_t) (argc-1))
4021 ThrowMogrifyException(OptionError,"MissingArgument",option);
4022 channel=ParseChannelOption(argv[i]);
4024 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4028 if (LocaleCompare("cdl",option+1) == 0)
4033 if (i == (ssize_t) (argc-1))
4034 ThrowMogrifyException(OptionError,"MissingArgument",option);
4037 if (LocaleCompare("charcoal",option+1) == 0)
4042 if (i == (ssize_t) argc)
4043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4044 if (IsGeometry(argv[i]) == MagickFalse)
4045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4048 if (LocaleCompare("chop",option+1) == 0)
4053 if (i == (ssize_t) argc)
4054 ThrowMogrifyException(OptionError,"MissingArgument",option);
4055 if (IsGeometry(argv[i]) == MagickFalse)
4056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4059 if (LocaleCompare("clamp",option+1) == 0)
4061 if (LocaleCompare("clip",option+1) == 0)
4063 if (LocaleCompare("clip-mask",option+1) == 0)
4068 if (i == (ssize_t) argc)
4069 ThrowMogrifyException(OptionError,"MissingArgument",option);
4072 if (LocaleCompare("clut",option+1) == 0)
4074 if (LocaleCompare("coalesce",option+1) == 0)
4076 if (LocaleCompare("colorize",option+1) == 0)
4081 if (i == (ssize_t) argc)
4082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4083 if (IsGeometry(argv[i]) == MagickFalse)
4084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4087 if (LocaleCompare("color-matrix",option+1) == 0)
4095 if (i == (ssize_t) (argc-1))
4096 ThrowMogrifyException(OptionError,"MissingArgument",option);
4097 kernel_info=AcquireKernelInfo(argv[i]);
4098 if (kernel_info == (KernelInfo *) NULL)
4099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4100 kernel_info=DestroyKernelInfo(kernel_info);
4103 if (LocaleCompare("colors",option+1) == 0)
4108 if (i == (ssize_t) argc)
4109 ThrowMogrifyException(OptionError,"MissingArgument",option);
4110 if (IsGeometry(argv[i]) == MagickFalse)
4111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4114 if (LocaleCompare("colorspace",option+1) == 0)
4122 if (i == (ssize_t) argc)
4123 ThrowMogrifyException(OptionError,"MissingArgument",option);
4124 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4127 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4131 if (LocaleCompare("combine",option+1) == 0)
4133 if (LocaleCompare("comment",option+1) == 0)
4138 if (i == (ssize_t) argc)
4139 ThrowMogrifyException(OptionError,"MissingArgument",option);
4142 if (LocaleCompare("composite",option+1) == 0)
4144 if (LocaleCompare("compress",option+1) == 0)
4152 if (i == (ssize_t) argc)
4153 ThrowMogrifyException(OptionError,"MissingArgument",option);
4154 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4157 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4161 if (LocaleCompare("concurrent",option+1) == 0)
4163 if (LocaleCompare("contrast",option+1) == 0)
4165 if (LocaleCompare("contrast-stretch",option+1) == 0)
4168 if (i == (ssize_t) argc)
4169 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (IsGeometry(argv[i]) == MagickFalse)
4171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4174 if (LocaleCompare("convolve",option+1) == 0)
4182 if (i == (ssize_t) argc)
4183 ThrowMogrifyException(OptionError,"MissingArgument",option);
4184 kernel_info=AcquireKernelInfo(argv[i]);
4185 if (kernel_info == (KernelInfo *) NULL)
4186 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4187 kernel_info=DestroyKernelInfo(kernel_info);
4190 if (LocaleCompare("crop",option+1) == 0)
4195 if (i == (ssize_t) argc)
4196 ThrowMogrifyException(OptionError,"MissingArgument",option);
4197 if (IsGeometry(argv[i]) == MagickFalse)
4198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4201 if (LocaleCompare("cycle",option+1) == 0)
4206 if (i == (ssize_t) argc)
4207 ThrowMogrifyException(OptionError,"MissingArgument",option);
4208 if (IsGeometry(argv[i]) == MagickFalse)
4209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4212 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4216 if (LocaleCompare("decipher",option+1) == 0)
4221 if (i == (ssize_t) (argc-1))
4222 ThrowMogrifyException(OptionError,"MissingArgument",option);
4225 if (LocaleCompare("deconstruct",option+1) == 0)
4227 if (LocaleCompare("debug",option+1) == 0)
4235 if (i == (ssize_t) argc)
4236 ThrowMogrifyException(OptionError,"MissingArgument",option);
4237 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4239 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4241 (void) SetLogEventMask(argv[i]);
4244 if (LocaleCompare("define",option+1) == 0)
4247 if (i == (ssize_t) argc)
4248 ThrowMogrifyException(OptionError,"MissingArgument",option);
4254 define=GetImageOption(image_info,argv[i]);
4255 if (define == (const char *) NULL)
4256 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4261 if (LocaleCompare("delay",option+1) == 0)
4266 if (i == (ssize_t) argc)
4267 ThrowMogrifyException(OptionError,"MissingArgument",option);
4268 if (IsGeometry(argv[i]) == MagickFalse)
4269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4272 if (LocaleCompare("delete",option+1) == 0)
4277 if (i == (ssize_t) (argc-1))
4278 ThrowMogrifyException(OptionError,"MissingArgument",option);
4279 if (IsGeometry(argv[i]) == MagickFalse)
4280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4283 if (LocaleCompare("density",option+1) == 0)
4288 if (i == (ssize_t) argc)
4289 ThrowMogrifyException(OptionError,"MissingArgument",option);
4290 if (IsGeometry(argv[i]) == MagickFalse)
4291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4294 if (LocaleCompare("depth",option+1) == 0)
4299 if (i == (ssize_t) argc)
4300 ThrowMogrifyException(OptionError,"MissingArgument",option);
4301 if (IsGeometry(argv[i]) == MagickFalse)
4302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4305 if (LocaleCompare("deskew",option+1) == 0)
4310 if (i == (ssize_t) argc)
4311 ThrowMogrifyException(OptionError,"MissingArgument",option);
4312 if (IsGeometry(argv[i]) == MagickFalse)
4313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4316 if (LocaleCompare("despeckle",option+1) == 0)
4318 if (LocaleCompare("dft",option+1) == 0)
4320 if (LocaleCompare("direction",option+1) == 0)
4328 if (i == (ssize_t) argc)
4329 ThrowMogrifyException(OptionError,"MissingArgument",option);
4330 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4333 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4337 if (LocaleCompare("display",option+1) == 0)
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4346 if (LocaleCompare("dispose",option+1) == 0)
4354 if (i == (ssize_t) argc)
4355 ThrowMogrifyException(OptionError,"MissingArgument",option);
4356 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4358 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4362 if (LocaleCompare("distort",option+1) == 0)
4368 if (i == (ssize_t) argc)
4369 ThrowMogrifyException(OptionError,"MissingArgument",option);
4370 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4372 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4375 if (i == (ssize_t) (argc-1))
4376 ThrowMogrifyException(OptionError,"MissingArgument",option);
4379 if (LocaleCompare("dither",option+1) == 0)
4387 if (i == (ssize_t) argc)
4388 ThrowMogrifyException(OptionError,"MissingArgument",option);
4389 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4391 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4395 if (LocaleCompare("draw",option+1) == 0)
4400 if (i == (ssize_t) argc)
4401 ThrowMogrifyException(OptionError,"MissingArgument",option);
4404 if (LocaleCompare("duplicate",option+1) == 0)
4409 if (i == (ssize_t) (argc-1))
4410 ThrowMogrifyException(OptionError,"MissingArgument",option);
4411 if (IsGeometry(argv[i]) == MagickFalse)
4412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4415 if (LocaleCompare("duration",option+1) == 0)
4420 if (i == (ssize_t) (argc-1))
4421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (IsGeometry(argv[i]) == MagickFalse)
4423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4426 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4430 if (LocaleCompare("edge",option+1) == 0)
4435 if (i == (ssize_t) argc)
4436 ThrowMogrifyException(OptionError,"MissingArgument",option);
4437 if (IsGeometry(argv[i]) == MagickFalse)
4438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4441 if (LocaleCompare("emboss",option+1) == 0)
4446 if (i == (ssize_t) argc)
4447 ThrowMogrifyException(OptionError,"MissingArgument",option);
4448 if (IsGeometry(argv[i]) == MagickFalse)
4449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4452 if (LocaleCompare("encipher",option+1) == 0)
4457 if (i == (ssize_t) argc)
4458 ThrowMogrifyException(OptionError,"MissingArgument",option);
4461 if (LocaleCompare("encoding",option+1) == 0)
4466 if (i == (ssize_t) argc)
4467 ThrowMogrifyException(OptionError,"MissingArgument",option);
4470 if (LocaleCompare("endian",option+1) == 0)
4478 if (i == (ssize_t) argc)
4479 ThrowMogrifyException(OptionError,"MissingArgument",option);
4480 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4482 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4486 if (LocaleCompare("enhance",option+1) == 0)
4488 if (LocaleCompare("equalize",option+1) == 0)
4490 if (LocaleCompare("evaluate",option+1) == 0)
4498 if (i == (ssize_t) argc)
4499 ThrowMogrifyException(OptionError,"MissingArgument",option);
4500 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4502 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4505 if (i == (ssize_t) (argc-1))
4506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4507 if (IsGeometry(argv[i]) == MagickFalse)
4508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4511 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4519 if (i == (ssize_t) argc)
4520 ThrowMogrifyException(OptionError,"MissingArgument",option);
4521 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4523 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4527 if (LocaleCompare("extent",option+1) == 0)
4532 if (i == (ssize_t) argc)
4533 ThrowMogrifyException(OptionError,"MissingArgument",option);
4534 if (IsGeometry(argv[i]) == MagickFalse)
4535 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4538 if (LocaleCompare("extract",option+1) == 0)
4543 if (i == (ssize_t) argc)
4544 ThrowMogrifyException(OptionError,"MissingArgument",option);
4545 if (IsGeometry(argv[i]) == MagickFalse)
4546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4549 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4553 if (LocaleCompare("family",option+1) == 0)
4558 if (i == (ssize_t) (argc-1))
4559 ThrowMogrifyException(OptionError,"MissingArgument",option);
4562 if (LocaleCompare("fill",option+1) == 0)
4567 if (i == (ssize_t) argc)
4568 ThrowMogrifyException(OptionError,"MissingArgument",option);
4571 if (LocaleCompare("filter",option+1) == 0)
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4583 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4587 if (LocaleCompare("flatten",option+1) == 0)
4589 if (LocaleCompare("flip",option+1) == 0)
4591 if (LocaleCompare("flop",option+1) == 0)
4593 if (LocaleCompare("floodfill",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4603 if (i == (ssize_t) argc)
4604 ThrowMogrifyException(OptionError,"MissingArgument",option);
4607 if (LocaleCompare("font",option+1) == 0)
4612 if (i == (ssize_t) argc)
4613 ThrowMogrifyException(OptionError,"MissingArgument",option);
4616 if (LocaleCompare("format",option+1) == 0)
4618 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4619 (void) CloneString(&format,(char *) NULL);
4623 if (i == (ssize_t) argc)
4624 ThrowMogrifyException(OptionError,"MissingArgument",option);
4625 (void) CloneString(&format,argv[i]);
4626 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4627 (void) ConcatenateMagickString(image_info->filename,":",
4629 (void) SetImageInfo(image_info,0,exception);
4630 if (*image_info->magick == '\0')
4631 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4635 if (LocaleCompare("frame",option+1) == 0)
4640 if (i == (ssize_t) argc)
4641 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4646 if (LocaleCompare("function",option+1) == 0)
4654 if (i == (ssize_t) argc)
4655 ThrowMogrifyException(OptionError,"MissingArgument",option);
4656 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4658 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4660 if (i == (ssize_t) (argc-1))
4661 ThrowMogrifyException(OptionError,"MissingArgument",option);
4664 if (LocaleCompare("fuzz",option+1) == 0)
4669 if (i == (ssize_t) argc)
4670 ThrowMogrifyException(OptionError,"MissingArgument",option);
4671 if (IsGeometry(argv[i]) == MagickFalse)
4672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4675 if (LocaleCompare("fx",option+1) == 0)
4680 if (i == (ssize_t) (argc-1))
4681 ThrowMogrifyException(OptionError,"MissingArgument",option);
4684 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4688 if (LocaleCompare("gamma",option+1) == 0)
4691 if (i == (ssize_t) argc)
4692 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 if (IsGeometry(argv[i]) == MagickFalse)
4694 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4697 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4698 (LocaleCompare("gaussian",option+1) == 0))
4701 if (i == (ssize_t) argc)
4702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 if (IsGeometry(argv[i]) == MagickFalse)
4704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4707 if (LocaleCompare("geometry",option+1) == 0)
4712 if (i == (ssize_t) argc)
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 if (IsGeometry(argv[i]) == MagickFalse)
4715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4718 if (LocaleCompare("gravity",option+1) == 0)
4726 if (i == (ssize_t) argc)
4727 ThrowMogrifyException(OptionError,"MissingArgument",option);
4728 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4730 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4734 if (LocaleCompare("green-primary",option+1) == 0)
4739 if (i == (ssize_t) argc)
4740 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 if (IsGeometry(argv[i]) == MagickFalse)
4742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4745 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4749 if (LocaleCompare("hald-clut",option+1) == 0)
4751 if ((LocaleCompare("help",option+1) == 0) ||
4752 (LocaleCompare("-help",option+1) == 0))
4753 return(MogrifyUsage());
4754 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4758 if (LocaleCompare("identify",option+1) == 0)
4760 if (LocaleCompare("idft",option+1) == 0)
4762 if (LocaleCompare("implode",option+1) == 0)
4767 if (i == (ssize_t) argc)
4768 ThrowMogrifyException(OptionError,"MissingArgument",option);
4769 if (IsGeometry(argv[i]) == MagickFalse)
4770 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4773 if (LocaleCompare("intent",option+1) == 0)
4781 if (i == (ssize_t) (argc-1))
4782 ThrowMogrifyException(OptionError,"MissingArgument",option);
4783 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4785 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4789 if (LocaleCompare("interlace",option+1) == 0)
4797 if (i == (ssize_t) argc)
4798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4802 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4806 if (LocaleCompare("interline-spacing",option+1) == 0)
4811 if (i == (ssize_t) (argc-1))
4812 ThrowMogrifyException(OptionError,"MissingArgument",option);
4813 if (IsGeometry(argv[i]) == MagickFalse)
4814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4817 if (LocaleCompare("interpolate",option+1) == 0)
4825 if (i == (ssize_t) argc)
4826 ThrowMogrifyException(OptionError,"MissingArgument",option);
4827 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4829 if (interpolate < 0)
4830 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4834 if (LocaleCompare("interword-spacing",option+1) == 0)
4839 if (i == (ssize_t) (argc-1))
4840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4845 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4849 if (LocaleCompare("kerning",option+1) == 0)
4854 if (i == (ssize_t) (argc-1))
4855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4856 if (IsGeometry(argv[i]) == MagickFalse)
4857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4860 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4864 if (LocaleCompare("label",option+1) == 0)
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,"MissingArgument",option);
4873 if (LocaleCompare("lat",option+1) == 0)
4878 if (i == (ssize_t) argc)
4879 ThrowMogrifyException(OptionError,"MissingArgument",option);
4880 if (IsGeometry(argv[i]) == MagickFalse)
4881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4883 if (LocaleCompare("layers",option+1) == 0)
4891 if (i == (ssize_t) (argc-1))
4892 ThrowMogrifyException(OptionError,"MissingArgument",option);
4893 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4895 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4899 if (LocaleCompare("level",option+1) == 0)
4902 if (i == (ssize_t) argc)
4903 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 if (IsGeometry(argv[i]) == MagickFalse)
4905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4908 if (LocaleCompare("level-colors",option+1) == 0)
4911 if (i == (ssize_t) argc)
4912 ThrowMogrifyException(OptionError,"MissingArgument",option);
4915 if (LocaleCompare("limit",option+1) == 0)
4929 if (i == (ssize_t) argc)
4930 ThrowMogrifyException(OptionError,"MissingArgument",option);
4931 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4934 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4937 if (i == (ssize_t) argc)
4938 ThrowMogrifyException(OptionError,"MissingArgument",option);
4939 value=StringToDouble(argv[i],&p);
4941 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4945 if (LocaleCompare("liquid-rescale",option+1) == 0)
4948 if (i == (ssize_t) argc)
4949 ThrowMogrifyException(OptionError,"MissingArgument",option);
4950 if (IsGeometry(argv[i]) == MagickFalse)
4951 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4954 if (LocaleCompare("list",option+1) == 0)
4962 if (i == (ssize_t) argc)
4963 ThrowMogrifyException(OptionError,"MissingArgument",option);
4964 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4966 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4967 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4969 return(status != 0 ? MagickFalse : MagickTrue);
4971 if (LocaleCompare("log",option+1) == 0)
4976 if ((i == (ssize_t) argc) ||
4977 (strchr(argv[i],'%') == (char *) NULL))
4978 ThrowMogrifyException(OptionError,"MissingArgument",option);
4981 if (LocaleCompare("loop",option+1) == 0)
4986 if (i == (ssize_t) argc)
4987 ThrowMogrifyException(OptionError,"MissingArgument",option);
4988 if (IsGeometry(argv[i]) == MagickFalse)
4989 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4992 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4996 if (LocaleCompare("map",option+1) == 0)
4998 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5002 if (i == (ssize_t) argc)
5003 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 if (LocaleCompare("mask",option+1) == 0)
5011 if (i == (ssize_t) argc)
5012 ThrowMogrifyException(OptionError,"MissingArgument",option);
5015 if (LocaleCompare("matte",option+1) == 0)
5017 if (LocaleCompare("mattecolor",option+1) == 0)
5022 if (i == (ssize_t) argc)
5023 ThrowMogrifyException(OptionError,"MissingArgument",option);
5026 if (LocaleCompare("maximum",option+1) == 0)
5028 if (LocaleCompare("minimum",option+1) == 0)
5030 if (LocaleCompare("modulate",option+1) == 0)
5035 if (i == (ssize_t) argc)
5036 ThrowMogrifyException(OptionError,"MissingArgument",option);
5037 if (IsGeometry(argv[i]) == MagickFalse)
5038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5041 if (LocaleCompare("median",option+1) == 0)
5046 if (i == (ssize_t) argc)
5047 ThrowMogrifyException(OptionError,"MissingArgument",option);
5048 if (IsGeometry(argv[i]) == MagickFalse)
5049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5052 if (LocaleCompare("mode",option+1) == 0)
5057 if (i == (ssize_t) argc)
5058 ThrowMogrifyException(OptionError,"MissingArgument",option);
5059 if (IsGeometry(argv[i]) == MagickFalse)
5060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5063 if (LocaleCompare("monitor",option+1) == 0)
5065 if (LocaleCompare("monochrome",option+1) == 0)
5067 if (LocaleCompare("morph",option+1) == 0)
5072 if (i == (ssize_t) (argc-1))
5073 ThrowMogrifyException(OptionError,"MissingArgument",option);
5074 if (IsGeometry(argv[i]) == MagickFalse)
5075 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5078 if (LocaleCompare("morphology",option+1) == 0)
5081 token[MaxTextExtent];
5090 if (i == (ssize_t) argc)
5091 ThrowMogrifyException(OptionError,"MissingArgument",option);
5092 GetMagickToken(argv[i],NULL,token);
5093 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5095 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5098 if (i == (ssize_t) (argc-1))
5099 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 kernel_info=AcquireKernelInfo(argv[i]);
5101 if (kernel_info == (KernelInfo *) NULL)
5102 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5103 kernel_info=DestroyKernelInfo(kernel_info);
5106 if (LocaleCompare("mosaic",option+1) == 0)
5108 if (LocaleCompare("motion-blur",option+1) == 0)
5113 if (i == (ssize_t) argc)
5114 ThrowMogrifyException(OptionError,"MissingArgument",option);
5115 if (IsGeometry(argv[i]) == MagickFalse)
5116 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5119 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5123 if (LocaleCompare("negate",option+1) == 0)
5125 if (LocaleCompare("noise",option+1) == 0)
5128 if (i == (ssize_t) argc)
5129 ThrowMogrifyException(OptionError,"MissingArgument",option);
5135 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5137 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5141 if (IsGeometry(argv[i]) == MagickFalse)
5142 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5145 if (LocaleCompare("noop",option+1) == 0)
5147 if (LocaleCompare("normalize",option+1) == 0)
5149 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5153 if (LocaleCompare("opaque",option+1) == 0)
5156 if (i == (ssize_t) argc)
5157 ThrowMogrifyException(OptionError,"MissingArgument",option);
5160 if (LocaleCompare("ordered-dither",option+1) == 0)
5165 if (i == (ssize_t) argc)
5166 ThrowMogrifyException(OptionError,"MissingArgument",option);
5169 if (LocaleCompare("orient",option+1) == 0)
5174 orientation=UndefinedOrientation;
5178 if (i == (ssize_t) (argc-1))
5179 ThrowMogrifyException(OptionError,"MissingArgument",option);
5180 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5182 if (orientation < 0)
5183 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5187 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5191 if (LocaleCompare("page",option+1) == 0)
5196 if (i == (ssize_t) argc)
5197 ThrowMogrifyException(OptionError,"MissingArgument",option);
5200 if (LocaleCompare("paint",option+1) == 0)
5205 if (i == (ssize_t) argc)
5206 ThrowMogrifyException(OptionError,"MissingArgument",option);
5207 if (IsGeometry(argv[i]) == MagickFalse)
5208 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5211 if (LocaleCompare("path",option+1) == 0)
5213 (void) CloneString(&path,(char *) NULL);
5217 if (i == (ssize_t) argc)
5218 ThrowMogrifyException(OptionError,"MissingArgument",option);
5219 (void) CloneString(&path,argv[i]);
5222 if (LocaleCompare("pointsize",option+1) == 0)
5227 if (i == (ssize_t) argc)
5228 ThrowMogrifyException(OptionError,"MissingArgument",option);
5229 if (IsGeometry(argv[i]) == MagickFalse)
5230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5233 if (LocaleCompare("polaroid",option+1) == 0)
5238 if (i == (ssize_t) argc)
5239 ThrowMogrifyException(OptionError,"MissingArgument",option);
5240 if (IsGeometry(argv[i]) == MagickFalse)
5241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5244 if (LocaleCompare("posterize",option+1) == 0)
5249 if (i == (ssize_t) argc)
5250 ThrowMogrifyException(OptionError,"MissingArgument",option);
5251 if (IsGeometry(argv[i]) == MagickFalse)
5252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5255 if (LocaleCompare("precision",option+1) == 0)
5260 if (i == (ssize_t) argc)
5261 ThrowMogrifyException(OptionError,"MissingArgument",option);
5262 if (IsGeometry(argv[i]) == MagickFalse)
5263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5266 if (LocaleCompare("print",option+1) == 0)
5271 if (i == (ssize_t) argc)
5272 ThrowMogrifyException(OptionError,"MissingArgument",option);
5275 if (LocaleCompare("process",option+1) == 0)
5280 if (i == (ssize_t) (argc-1))
5281 ThrowMogrifyException(OptionError,"MissingArgument",option);
5284 if (LocaleCompare("profile",option+1) == 0)
5287 if (i == (ssize_t) argc)
5288 ThrowMogrifyException(OptionError,"MissingArgument",option);
5291 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5295 if (LocaleCompare("quality",option+1) == 0)
5300 if (i == (ssize_t) argc)
5301 ThrowMogrifyException(OptionError,"MissingArgument",option);
5302 if (IsGeometry(argv[i]) == MagickFalse)
5303 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5306 if (LocaleCompare("quantize",option+1) == 0)
5314 if (i == (ssize_t) (argc-1))
5315 ThrowMogrifyException(OptionError,"MissingArgument",option);
5316 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5319 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5323 if (LocaleCompare("quiet",option+1) == 0)
5325 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5329 if (LocaleCompare("radial-blur",option+1) == 0)
5332 if (i == (ssize_t) argc)
5333 ThrowMogrifyException(OptionError,"MissingArgument",option);
5334 if (IsGeometry(argv[i]) == MagickFalse)
5335 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5338 if (LocaleCompare("raise",option+1) == 0)
5341 if (i == (ssize_t) argc)
5342 ThrowMogrifyException(OptionError,"MissingArgument",option);
5343 if (IsGeometry(argv[i]) == MagickFalse)
5344 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5347 if (LocaleCompare("random-threshold",option+1) == 0)
5352 if (i == (ssize_t) argc)
5353 ThrowMogrifyException(OptionError,"MissingArgument",option);
5354 if (IsGeometry(argv[i]) == MagickFalse)
5355 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5358 if (LocaleCompare("red-primary",option+1) == 0)
5363 if (i == (ssize_t) argc)
5364 ThrowMogrifyException(OptionError,"MissingArgument",option);
5365 if (IsGeometry(argv[i]) == MagickFalse)
5366 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5368 if (LocaleCompare("regard-warnings",option+1) == 0)
5370 if (LocaleCompare("region",option+1) == 0)
5375 if (i == (ssize_t) argc)
5376 ThrowMogrifyException(OptionError,"MissingArgument",option);
5377 if (IsGeometry(argv[i]) == MagickFalse)
5378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5381 if (LocaleCompare("remap",option+1) == 0)
5386 if (i == (ssize_t) (argc-1))
5387 ThrowMogrifyException(OptionError,"MissingArgument",option);
5390 if (LocaleCompare("render",option+1) == 0)
5392 if (LocaleCompare("repage",option+1) == 0)
5397 if (i == (ssize_t) argc)
5398 ThrowMogrifyException(OptionError,"MissingArgument",option);
5399 if (IsGeometry(argv[i]) == MagickFalse)
5400 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5403 if (LocaleCompare("resample",option+1) == 0)
5408 if (i == (ssize_t) argc)
5409 ThrowMogrifyException(OptionError,"MissingArgument",option);
5410 if (IsGeometry(argv[i]) == MagickFalse)
5411 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5414 if (LocaleCompare("resize",option+1) == 0)
5419 if (i == (ssize_t) argc)
5420 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 if (IsGeometry(argv[i]) == MagickFalse)
5422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5425 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5427 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5430 if (LocaleCompare("reverse",option+1) == 0)
5432 if (LocaleCompare("roll",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 (LocaleCompare("rotate",option+1) == 0)
5446 if (i == (ssize_t) argc)
5447 ThrowMogrifyException(OptionError,"MissingArgument",option);
5448 if (IsGeometry(argv[i]) == MagickFalse)
5449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5452 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5456 if (LocaleCompare("sample",option+1) == 0)
5461 if (i == (ssize_t) argc)
5462 ThrowMogrifyException(OptionError,"MissingArgument",option);
5463 if (IsGeometry(argv[i]) == MagickFalse)
5464 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5467 if (LocaleCompare("sampling-factor",option+1) == 0)
5472 if (i == (ssize_t) argc)
5473 ThrowMogrifyException(OptionError,"MissingArgument",option);
5474 if (IsGeometry(argv[i]) == MagickFalse)
5475 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5478 if (LocaleCompare("scale",option+1) == 0)
5483 if (i == (ssize_t) argc)
5484 ThrowMogrifyException(OptionError,"MissingArgument",option);
5485 if (IsGeometry(argv[i]) == MagickFalse)
5486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5489 if (LocaleCompare("scene",option+1) == 0)
5494 if (i == (ssize_t) argc)
5495 ThrowMogrifyException(OptionError,"MissingArgument",option);
5496 if (IsGeometry(argv[i]) == MagickFalse)
5497 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5500 if (LocaleCompare("seed",option+1) == 0)
5505 if (i == (ssize_t) argc)
5506 ThrowMogrifyException(OptionError,"MissingArgument",option);
5507 if (IsGeometry(argv[i]) == MagickFalse)
5508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5511 if (LocaleCompare("segment",option+1) == 0)
5516 if (i == (ssize_t) argc)
5517 ThrowMogrifyException(OptionError,"MissingArgument",option);
5518 if (IsGeometry(argv[i]) == MagickFalse)
5519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5522 if (LocaleCompare("selective-blur",option+1) == 0)
5525 if (i == (ssize_t) argc)
5526 ThrowMogrifyException(OptionError,"MissingArgument",option);
5527 if (IsGeometry(argv[i]) == MagickFalse)
5528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5531 if (LocaleCompare("separate",option+1) == 0)
5533 if (LocaleCompare("sepia-tone",option+1) == 0)
5538 if (i == (ssize_t) argc)
5539 ThrowMogrifyException(OptionError,"MissingArgument",option);
5540 if (IsGeometry(argv[i]) == MagickFalse)
5541 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5544 if (LocaleCompare("set",option+1) == 0)
5547 if (i == (ssize_t) argc)
5548 ThrowMogrifyException(OptionError,"MissingArgument",option);
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,"MissingArgument",option);
5556 if (LocaleCompare("shade",option+1) == 0)
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5561 if (IsGeometry(argv[i]) == MagickFalse)
5562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5565 if (LocaleCompare("shadow",option+1) == 0)
5570 if (i == (ssize_t) argc)
5571 ThrowMogrifyException(OptionError,"MissingArgument",option);
5572 if (IsGeometry(argv[i]) == MagickFalse)
5573 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5576 if (LocaleCompare("sharpen",option+1) == 0)
5579 if (i == (ssize_t) argc)
5580 ThrowMogrifyException(OptionError,"MissingArgument",option);
5581 if (IsGeometry(argv[i]) == MagickFalse)
5582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5585 if (LocaleCompare("shave",option+1) == 0)
5590 if (i == (ssize_t) argc)
5591 ThrowMogrifyException(OptionError,"MissingArgument",option);
5592 if (IsGeometry(argv[i]) == MagickFalse)
5593 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5596 if (LocaleCompare("shear",option+1) == 0)
5599 if (i == (ssize_t) argc)
5600 ThrowMogrifyException(OptionError,"MissingArgument",option);
5601 if (IsGeometry(argv[i]) == MagickFalse)
5602 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5605 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5608 if (i == (ssize_t) (argc-1))
5609 ThrowMogrifyException(OptionError,"MissingArgument",option);
5610 if (IsGeometry(argv[i]) == MagickFalse)
5611 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5614 if (LocaleCompare("size",option+1) == 0)
5619 if (i == (ssize_t) argc)
5620 ThrowMogrifyException(OptionError,"MissingArgument",option);
5621 if (IsGeometry(argv[i]) == MagickFalse)
5622 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5625 if (LocaleCompare("sketch",option+1) == 0)
5630 if (i == (ssize_t) argc)
5631 ThrowMogrifyException(OptionError,"MissingArgument",option);
5632 if (IsGeometry(argv[i]) == MagickFalse)
5633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5636 if (LocaleCompare("smush",option+1) == 0)
5639 if (i == (ssize_t) argc)
5640 ThrowMogrifyException(OptionError,"MissingArgument",option);
5641 if (IsGeometry(argv[i]) == MagickFalse)
5642 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5646 if (LocaleCompare("solarize",option+1) == 0)
5651 if (i == (ssize_t) argc)
5652 ThrowMogrifyException(OptionError,"MissingArgument",option);
5653 if (IsGeometry(argv[i]) == MagickFalse)
5654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5657 if (LocaleCompare("sparse-color",option+1) == 0)
5663 if (i == (ssize_t) argc)
5664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5667 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5670 if (i == (ssize_t) (argc-1))
5671 ThrowMogrifyException(OptionError,"MissingArgument",option);
5674 if (LocaleCompare("spread",option+1) == 0)
5679 if (i == (ssize_t) argc)
5680 ThrowMogrifyException(OptionError,"MissingArgument",option);
5681 if (IsGeometry(argv[i]) == MagickFalse)
5682 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5685 if (LocaleCompare("statistic",option+1) == 0)
5693 if (i == (ssize_t) argc)
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5697 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5700 if (i == (ssize_t) (argc-1))
5701 ThrowMogrifyException(OptionError,"MissingArgument",option);
5702 if (IsGeometry(argv[i]) == MagickFalse)
5703 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5706 if (LocaleCompare("stretch",option+1) == 0)
5714 if (i == (ssize_t) (argc-1))
5715 ThrowMogrifyException(OptionError,"MissingArgument",option);
5716 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5718 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5722 if (LocaleCompare("strip",option+1) == 0)
5724 if (LocaleCompare("stroke",option+1) == 0)
5729 if (i == (ssize_t) argc)
5730 ThrowMogrifyException(OptionError,"MissingArgument",option);
5733 if (LocaleCompare("strokewidth",option+1) == 0)
5738 if (i == (ssize_t) argc)
5739 ThrowMogrifyException(OptionError,"MissingArgument",option);
5740 if (IsGeometry(argv[i]) == MagickFalse)
5741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5744 if (LocaleCompare("style",option+1) == 0)
5752 if (i == (ssize_t) (argc-1))
5753 ThrowMogrifyException(OptionError,"MissingArgument",option);
5754 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5756 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5760 if (LocaleCompare("swap",option+1) == 0)
5765 if (i == (ssize_t) (argc-1))
5766 ThrowMogrifyException(OptionError,"MissingArgument",option);
5767 if (IsGeometry(argv[i]) == MagickFalse)
5768 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5771 if (LocaleCompare("swirl",option+1) == 0)
5776 if (i == (ssize_t) argc)
5777 ThrowMogrifyException(OptionError,"MissingArgument",option);
5778 if (IsGeometry(argv[i]) == MagickFalse)
5779 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5782 if (LocaleCompare("synchronize",option+1) == 0)
5784 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5788 if (LocaleCompare("taint",option+1) == 0)
5790 if (LocaleCompare("texture",option+1) == 0)
5795 if (i == (ssize_t) argc)
5796 ThrowMogrifyException(OptionError,"MissingArgument",option);
5799 if (LocaleCompare("tile",option+1) == 0)
5804 if (i == (ssize_t) (argc-1))
5805 ThrowMogrifyException(OptionError,"MissingArgument",option);
5808 if (LocaleCompare("tile-offset",option+1) == 0)
5813 if (i == (ssize_t) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5815 if (IsGeometry(argv[i]) == MagickFalse)
5816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5819 if (LocaleCompare("tint",option+1) == 0)
5824 if (i == (ssize_t) (argc-1))
5825 ThrowMogrifyException(OptionError,"MissingArgument",option);
5826 if (IsGeometry(argv[i]) == MagickFalse)
5827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5830 if (LocaleCompare("transform",option+1) == 0)
5832 if (LocaleCompare("transpose",option+1) == 0)
5834 if (LocaleCompare("transverse",option+1) == 0)
5836 if (LocaleCompare("threshold",option+1) == 0)
5841 if (i == (ssize_t) argc)
5842 ThrowMogrifyException(OptionError,"MissingArgument",option);
5843 if (IsGeometry(argv[i]) == MagickFalse)
5844 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5847 if (LocaleCompare("thumbnail",option+1) == 0)
5852 if (i == (ssize_t) argc)
5853 ThrowMogrifyException(OptionError,"MissingArgument",option);
5854 if (IsGeometry(argv[i]) == MagickFalse)
5855 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5858 if (LocaleCompare("transparent",option+1) == 0)
5861 if (i == (ssize_t) argc)
5862 ThrowMogrifyException(OptionError,"MissingArgument",option);
5865 if (LocaleCompare("transparent-color",option+1) == 0)
5870 if (i == (ssize_t) (argc-1))
5871 ThrowMogrifyException(OptionError,"MissingArgument",option);
5874 if (LocaleCompare("treedepth",option+1) == 0)
5879 if (i == (ssize_t) argc)
5880 ThrowMogrifyException(OptionError,"MissingArgument",option);
5881 if (IsGeometry(argv[i]) == MagickFalse)
5882 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5885 if (LocaleCompare("trim",option+1) == 0)
5887 if (LocaleCompare("type",option+1) == 0)
5895 if (i == (ssize_t) argc)
5896 ThrowMogrifyException(OptionError,"MissingArgument",option);
5897 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5899 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5903 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5907 if (LocaleCompare("undercolor",option+1) == 0)
5912 if (i == (ssize_t) argc)
5913 ThrowMogrifyException(OptionError,"MissingArgument",option);
5916 if (LocaleCompare("unique-colors",option+1) == 0)
5918 if (LocaleCompare("units",option+1) == 0)
5926 if (i == (ssize_t) argc)
5927 ThrowMogrifyException(OptionError,"MissingArgument",option);
5928 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5931 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5935 if (LocaleCompare("unsharp",option+1) == 0)
5938 if (i == (ssize_t) argc)
5939 ThrowMogrifyException(OptionError,"MissingArgument",option);
5940 if (IsGeometry(argv[i]) == MagickFalse)
5941 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5944 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5948 if (LocaleCompare("verbose",option+1) == 0)
5950 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5953 if ((LocaleCompare("version",option+1) == 0) ||
5954 (LocaleCompare("-version",option+1) == 0))
5956 (void) FormatLocaleFile(stdout,"Version: %s\n",
5957 GetMagickVersion((size_t *) NULL));
5958 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5959 GetMagickCopyright());
5960 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5961 GetMagickFeatures());
5964 if (LocaleCompare("view",option+1) == 0)
5969 if (i == (ssize_t) argc)
5970 ThrowMogrifyException(OptionError,"MissingArgument",option);
5973 if (LocaleCompare("vignette",option+1) == 0)
5978 if (i == (ssize_t) argc)
5979 ThrowMogrifyException(OptionError,"MissingArgument",option);
5980 if (IsGeometry(argv[i]) == MagickFalse)
5981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5984 if (LocaleCompare("virtual-pixel",option+1) == 0)
5992 if (i == (ssize_t) argc)
5993 ThrowMogrifyException(OptionError,"MissingArgument",option);
5994 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5997 ThrowMogrifyException(OptionError,
5998 "UnrecognizedVirtualPixelMethod",argv[i]);
6001 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6005 if (LocaleCompare("wave",option+1) == 0)
6008 if (i == (ssize_t) argc)
6009 ThrowMogrifyException(OptionError,"MissingArgument",option);
6010 if (IsGeometry(argv[i]) == MagickFalse)
6011 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6014 if (LocaleCompare("weight",option+1) == 0)
6019 if (i == (ssize_t) (argc-1))
6020 ThrowMogrifyException(OptionError,"MissingArgument",option);
6023 if (LocaleCompare("white-point",option+1) == 0)
6028 if (i == (ssize_t) argc)
6029 ThrowMogrifyException(OptionError,"MissingArgument",option);
6030 if (IsGeometry(argv[i]) == MagickFalse)
6031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6034 if (LocaleCompare("white-threshold",option+1) == 0)
6039 if (i == (ssize_t) argc)
6040 ThrowMogrifyException(OptionError,"MissingArgument",option);
6041 if (IsGeometry(argv[i]) == MagickFalse)
6042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6045 if (LocaleCompare("write",option+1) == 0)
6048 if (i == (ssize_t) (argc-1))
6049 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6057 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6059 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6060 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6061 if (fire != MagickFalse)
6062 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6065 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6066 if (i != (ssize_t) argc)
6067 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6069 return(status != 0 ? MagickTrue : MagickFalse);
6073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6077 + M o g r i f y I m a g e I n f o %
6081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6083 % MogrifyImageInfo() applies image processing settings to the image as
6084 % prescribed by command line options.
6086 % The format of the MogrifyImageInfo method is:
6088 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6089 % const char **argv,ExceptionInfo *exception)
6091 % A description of each parameter follows:
6093 % o image_info: the image info..
6095 % o argc: Specifies a pointer to an integer describing the number of
6096 % elements in the argument vector.
6098 % o argv: Specifies a pointer to a text array containing the command line
6101 % o exception: return any errors or warnings in this structure.
6104 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6105 const int argc,const char **argv,ExceptionInfo *exception)
6120 Initialize method variables.
6122 assert(image_info != (ImageInfo *) NULL);
6123 assert(image_info->signature == MagickSignature);
6124 if (image_info->debug != MagickFalse)
6125 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6126 image_info->filename);
6130 Set the image settings.
6132 for (i=0; i < (ssize_t) argc; i++)
6135 if (IsCommandOption(option) == MagickFalse)
6137 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6138 count=MagickMax(count,0L);
6139 if ((i+count) >= (ssize_t) argc)
6141 switch (*(option+1))
6145 if (LocaleCompare("adjoin",option+1) == 0)
6147 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6150 if (LocaleCompare("antialias",option+1) == 0)
6152 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6155 if (LocaleCompare("authenticate",option+1) == 0)
6158 (void) DeleteImageOption(image_info,option+1);
6160 (void) SetImageOption(image_info,option+1,argv[i+1]);
6167 if (LocaleCompare("background",option+1) == 0)
6171 (void) DeleteImageOption(image_info,option+1);
6172 (void) QueryColorCompliance(MogrifyBackgroundColor,
6173 AllCompliance,&image_info->background_color,exception);
6176 (void) SetImageOption(image_info,option+1,argv[i+1]);
6177 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6178 &image_info->background_color,exception);
6181 if (LocaleCompare("bias",option+1) == 0)
6185 (void) SetImageOption(image_info,option+1,"0.0");
6188 (void) SetImageOption(image_info,option+1,argv[i+1]);
6191 if (LocaleCompare("black-point-compensation",option+1) == 0)
6195 (void) SetImageOption(image_info,option+1,"false");
6198 (void) SetImageOption(image_info,option+1,"true");
6201 if (LocaleCompare("blue-primary",option+1) == 0)
6205 (void) SetImageOption(image_info,option+1,"0.0");
6208 (void) SetImageOption(image_info,option+1,argv[i+1]);
6211 if (LocaleCompare("bordercolor",option+1) == 0)
6215 (void) DeleteImageOption(image_info,option+1);
6216 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6217 &image_info->border_color,exception);
6220 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6221 &image_info->border_color,exception);
6222 (void) SetImageOption(image_info,option+1,argv[i+1]);
6225 if (LocaleCompare("box",option+1) == 0)
6229 (void) SetImageOption(image_info,"undercolor","none");
6232 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6239 if (LocaleCompare("cache",option+1) == 0)
6244 limit=MagickResourceInfinity;
6245 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6246 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6248 (void) SetMagickResourceLimit(MemoryResource,limit);
6249 (void) SetMagickResourceLimit(MapResource,2*limit);
6252 if (LocaleCompare("caption",option+1) == 0)
6256 (void) DeleteImageOption(image_info,option+1);
6259 (void) SetImageOption(image_info,option+1,argv[i+1]);
6262 if (LocaleCompare("channel",option+1) == 0)
6266 image_info->channel=DefaultChannels;
6269 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6272 if (LocaleCompare("colorspace",option+1) == 0)
6276 image_info->colorspace=UndefinedColorspace;
6277 (void) SetImageOption(image_info,option+1,"undefined");
6280 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6281 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6282 (void) SetImageOption(image_info,option+1,argv[i+1]);
6285 if (LocaleCompare("comment",option+1) == 0)
6289 (void) DeleteImageOption(image_info,option+1);
6292 (void) SetImageOption(image_info,option+1,argv[i+1]);
6295 if (LocaleCompare("compose",option+1) == 0)
6299 (void) SetImageOption(image_info,option+1,"undefined");
6302 (void) SetImageOption(image_info,option+1,argv[i+1]);
6305 if (LocaleCompare("compress",option+1) == 0)
6309 image_info->compression=UndefinedCompression;
6310 (void) SetImageOption(image_info,option+1,"undefined");
6313 image_info->compression=(CompressionType) ParseCommandOption(
6314 MagickCompressOptions,MagickFalse,argv[i+1]);
6315 (void) SetImageOption(image_info,option+1,argv[i+1]);
6322 if (LocaleCompare("debug",option+1) == 0)
6325 (void) SetLogEventMask("none");
6327 (void) SetLogEventMask(argv[i+1]);
6328 image_info->debug=IsEventLogging();
6331 if (LocaleCompare("define",option+1) == 0)
6335 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6336 (void) DeleteImageRegistry(argv[i+1]+9);
6338 (void) DeleteImageOption(image_info,argv[i+1]);
6341 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6343 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6347 (void) DefineImageOption(image_info,argv[i+1]);
6350 if (LocaleCompare("delay",option+1) == 0)
6354 (void) SetImageOption(image_info,option+1,"0");
6357 (void) SetImageOption(image_info,option+1,argv[i+1]);
6360 if (LocaleCompare("density",option+1) == 0)
6367 if (image_info->density != (char *) NULL)
6368 image_info->density=DestroyString(image_info->density);
6369 (void) SetImageOption(image_info,option+1,"72");
6372 (void) CloneString(&image_info->density,argv[i+1]);
6373 (void) SetImageOption(image_info,option+1,argv[i+1]);
6376 if (LocaleCompare("depth",option+1) == 0)
6380 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6383 image_info->depth=StringToUnsignedLong(argv[i+1]);
6386 if (LocaleCompare("direction",option+1) == 0)
6390 (void) SetImageOption(image_info,option+1,"undefined");
6393 (void) SetImageOption(image_info,option+1,argv[i+1]);
6396 if (LocaleCompare("display",option+1) == 0)
6400 if (image_info->server_name != (char *) NULL)
6401 image_info->server_name=DestroyString(
6402 image_info->server_name);
6405 (void) CloneString(&image_info->server_name,argv[i+1]);
6408 if (LocaleCompare("dispose",option+1) == 0)
6412 (void) SetImageOption(image_info,option+1,"undefined");
6415 (void) SetImageOption(image_info,option+1,argv[i+1]);
6418 if (LocaleCompare("dither",option+1) == 0)
6422 image_info->dither=MagickFalse;
6423 (void) SetImageOption(image_info,option+1,"none");
6426 (void) SetImageOption(image_info,option+1,argv[i+1]);
6427 image_info->dither=MagickTrue;
6434 if (LocaleCompare("encoding",option+1) == 0)
6438 (void) SetImageOption(image_info,option+1,"undefined");
6441 (void) SetImageOption(image_info,option+1,argv[i+1]);
6444 if (LocaleCompare("endian",option+1) == 0)
6448 image_info->endian=UndefinedEndian;
6449 (void) SetImageOption(image_info,option+1,"undefined");
6452 image_info->endian=(EndianType) ParseCommandOption(
6453 MagickEndianOptions,MagickFalse,argv[i+1]);
6454 (void) SetImageOption(image_info,option+1,argv[i+1]);
6457 if (LocaleCompare("extract",option+1) == 0)
6460 Set image extract geometry.
6464 if (image_info->extract != (char *) NULL)
6465 image_info->extract=DestroyString(image_info->extract);
6468 (void) CloneString(&image_info->extract,argv[i+1]);
6475 if (LocaleCompare("fill",option+1) == 0)
6479 (void) SetImageOption(image_info,option+1,"none");
6482 (void) SetImageOption(image_info,option+1,argv[i+1]);
6485 if (LocaleCompare("filter",option+1) == 0)
6489 (void) SetImageOption(image_info,option+1,"undefined");
6492 (void) SetImageOption(image_info,option+1,argv[i+1]);
6495 if (LocaleCompare("font",option+1) == 0)
6499 if (image_info->font != (char *) NULL)
6500 image_info->font=DestroyString(image_info->font);
6503 (void) CloneString(&image_info->font,argv[i+1]);
6506 if (LocaleCompare("format",option+1) == 0)
6511 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6512 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6513 image_info->ping=MagickFalse;
6514 (void) SetImageOption(image_info,option+1,argv[i+1]);
6517 if (LocaleCompare("fuzz",option+1) == 0)
6521 image_info->fuzz=0.0;
6522 (void) SetImageOption(image_info,option+1,"0");
6525 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6527 (void) SetImageOption(image_info,option+1,argv[i+1]);
6534 if (LocaleCompare("gravity",option+1) == 0)
6538 (void) SetImageOption(image_info,option+1,"undefined");
6541 (void) SetImageOption(image_info,option+1,argv[i+1]);
6544 if (LocaleCompare("green-primary",option+1) == 0)
6548 (void) SetImageOption(image_info,option+1,"0.0");
6551 (void) SetImageOption(image_info,option+1,argv[i+1]);
6558 if (LocaleCompare("intent",option+1) == 0)
6562 (void) SetImageOption(image_info,option+1,"undefined");
6565 (void) SetImageOption(image_info,option+1,argv[i+1]);
6568 if (LocaleCompare("interlace",option+1) == 0)
6572 image_info->interlace=UndefinedInterlace;
6573 (void) SetImageOption(image_info,option+1,"undefined");
6576 image_info->interlace=(InterlaceType) ParseCommandOption(
6577 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6578 (void) SetImageOption(image_info,option+1,argv[i+1]);
6581 if (LocaleCompare("interline-spacing",option+1) == 0)
6585 (void) SetImageOption(image_info,option+1,"undefined");
6588 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 if (LocaleCompare("interpolate",option+1) == 0)
6595 (void) SetImageOption(image_info,option+1,"undefined");
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("interword-spacing",option+1) == 0)
6605 (void) SetImageOption(image_info,option+1,"undefined");
6608 (void) SetImageOption(image_info,option+1,argv[i+1]);
6615 if (LocaleCompare("kerning",option+1) == 0)
6619 (void) SetImageOption(image_info,option+1,"undefined");
6622 (void) SetImageOption(image_info,option+1,argv[i+1]);
6629 if (LocaleCompare("label",option+1) == 0)
6633 (void) DeleteImageOption(image_info,option+1);
6636 (void) SetImageOption(image_info,option+1,argv[i+1]);
6639 if (LocaleCompare("limit",option+1) == 0)
6649 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6650 MagickFalse,argv[i+1]);
6651 limit=MagickResourceInfinity;
6652 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6653 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6654 (void) SetMagickResourceLimit(type,limit);
6657 if (LocaleCompare("list",option+1) == 0)
6663 Display configuration list.
6665 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6668 case MagickCoderOptions:
6670 (void) ListCoderInfo((FILE *) NULL,exception);
6673 case MagickColorOptions:
6675 (void) ListColorInfo((FILE *) NULL,exception);
6678 case MagickConfigureOptions:
6680 (void) ListConfigureInfo((FILE *) NULL,exception);
6683 case MagickDelegateOptions:
6685 (void) ListDelegateInfo((FILE *) NULL,exception);
6688 case MagickFontOptions:
6690 (void) ListTypeInfo((FILE *) NULL,exception);
6693 case MagickFormatOptions:
6695 (void) ListMagickInfo((FILE *) NULL,exception);
6698 case MagickLocaleOptions:
6700 (void) ListLocaleInfo((FILE *) NULL,exception);
6703 case MagickLogOptions:
6705 (void) ListLogInfo((FILE *) NULL,exception);
6708 case MagickMagicOptions:
6710 (void) ListMagicInfo((FILE *) NULL,exception);
6713 case MagickMimeOptions:
6715 (void) ListMimeInfo((FILE *) NULL,exception);
6718 case MagickModuleOptions:
6720 (void) ListModuleInfo((FILE *) NULL,exception);
6723 case MagickPolicyOptions:
6725 (void) ListPolicyInfo((FILE *) NULL,exception);
6728 case MagickResourceOptions:
6730 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6733 case MagickThresholdOptions:
6735 (void) ListThresholdMaps((FILE *) NULL,exception);
6740 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6747 if (LocaleCompare("log",option+1) == 0)
6751 (void) SetLogFormat(argv[i+1]);
6754 if (LocaleCompare("loop",option+1) == 0)
6758 (void) SetImageOption(image_info,option+1,"0");
6761 (void) SetImageOption(image_info,option+1,argv[i+1]);
6768 if (LocaleCompare("matte",option+1) == 0)
6772 (void) SetImageOption(image_info,option+1,"false");
6775 (void) SetImageOption(image_info,option+1,"true");
6778 if (LocaleCompare("mattecolor",option+1) == 0)
6782 (void) SetImageOption(image_info,option+1,argv[i+1]);
6783 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6784 &image_info->matte_color,exception);
6787 (void) SetImageOption(image_info,option+1,argv[i+1]);
6788 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6789 &image_info->matte_color,exception);
6792 if (LocaleCompare("monitor",option+1) == 0)
6794 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6798 if (LocaleCompare("monochrome",option+1) == 0)
6800 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6807 if (LocaleCompare("orient",option+1) == 0)
6811 image_info->orientation=UndefinedOrientation;
6812 (void) SetImageOption(image_info,option+1,"undefined");
6815 image_info->orientation=(OrientationType) ParseCommandOption(
6816 MagickOrientationOptions,MagickFalse,argv[i+1]);
6817 (void) SetImageOption(image_info,option+1,argv[i+1]);
6823 if (LocaleCompare("page",option+1) == 0)
6827 page[MaxTextExtent];
6840 (void) DeleteImageOption(image_info,option+1);
6841 (void) CloneString(&image_info->page,(char *) NULL);
6844 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6845 image_option=GetImageOption(image_info,"page");
6846 if (image_option != (const char *) NULL)
6847 flags=ParseAbsoluteGeometry(image_option,&geometry);
6848 canonical_page=GetPageGeometry(argv[i+1]);
6849 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6850 canonical_page=DestroyString(canonical_page);
6851 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6852 (unsigned long) geometry.width,(unsigned long) geometry.height);
6853 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6854 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6855 (unsigned long) geometry.width,(unsigned long) geometry.height,
6856 (long) geometry.x,(long) geometry.y);
6857 (void) SetImageOption(image_info,option+1,page);
6858 (void) CloneString(&image_info->page,page);
6861 if (LocaleCompare("ping",option+1) == 0)
6863 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6866 if (LocaleCompare("pointsize",option+1) == 0)
6869 geometry_info.rho=0.0;
6871 (void) ParseGeometry(argv[i+1],&geometry_info);
6872 image_info->pointsize=geometry_info.rho;
6875 if (LocaleCompare("precision",option+1) == 0)
6877 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6880 if (LocaleCompare("preview",option+1) == 0)
6887 image_info->preview_type=UndefinedPreview;
6890 image_info->preview_type=(PreviewType) ParseCommandOption(
6891 MagickPreviewOptions,MagickFalse,argv[i+1]);
6898 if (LocaleCompare("quality",option+1) == 0)
6901 Set image compression quality.
6905 image_info->quality=UndefinedCompressionQuality;
6906 (void) SetImageOption(image_info,option+1,"0");
6909 image_info->quality=StringToUnsignedLong(argv[i+1]);
6910 (void) SetImageOption(image_info,option+1,argv[i+1]);
6913 if (LocaleCompare("quiet",option+1) == 0)
6915 static WarningHandler
6916 warning_handler = (WarningHandler) NULL;
6921 Restore error or warning messages.
6923 warning_handler=SetWarningHandler(warning_handler);
6927 Suppress error or warning messages.
6929 warning_handler=SetWarningHandler((WarningHandler) NULL);
6936 if (LocaleCompare("red-primary",option+1) == 0)
6940 (void) SetImageOption(image_info,option+1,"0.0");
6943 (void) SetImageOption(image_info,option+1,argv[i+1]);
6950 if (LocaleCompare("sampling-factor",option+1) == 0)
6953 Set image sampling factor.
6957 if (image_info->sampling_factor != (char *) NULL)
6958 image_info->sampling_factor=DestroyString(
6959 image_info->sampling_factor);
6962 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6965 if (LocaleCompare("scene",option+1) == 0)
6972 image_info->scene=0;
6973 (void) SetImageOption(image_info,option+1,"0");
6976 image_info->scene=StringToUnsignedLong(argv[i+1]);
6977 (void) SetImageOption(image_info,option+1,argv[i+1]);
6980 if (LocaleCompare("seed",option+1) == 0)
6987 seed=(size_t) time((time_t *) NULL);
6988 SeedPseudoRandomGenerator(seed);
6991 seed=StringToUnsignedLong(argv[i+1]);
6992 SeedPseudoRandomGenerator(seed);
6995 if (LocaleCompare("size",option+1) == 0)
6999 if (image_info->size != (char *) NULL)
7000 image_info->size=DestroyString(image_info->size);
7003 (void) CloneString(&image_info->size,argv[i+1]);
7006 if (LocaleCompare("stroke",option+1) == 0)
7010 (void) SetImageOption(image_info,option+1,"none");
7013 (void) SetImageOption(image_info,option+1,argv[i+1]);
7016 if (LocaleCompare("strokewidth",option+1) == 0)
7020 (void) SetImageOption(image_info,option+1,"0");
7023 (void) SetImageOption(image_info,option+1,argv[i+1]);
7026 if (LocaleCompare("synchronize",option+1) == 0)
7030 image_info->synchronize=MagickFalse;
7033 image_info->synchronize=MagickTrue;
7040 if (LocaleCompare("taint",option+1) == 0)
7044 (void) SetImageOption(image_info,option+1,"false");
7047 (void) SetImageOption(image_info,option+1,"true");
7050 if (LocaleCompare("texture",option+1) == 0)
7054 if (image_info->texture != (char *) NULL)
7055 image_info->texture=DestroyString(image_info->texture);
7058 (void) CloneString(&image_info->texture,argv[i+1]);
7061 if (LocaleCompare("tile-offset",option+1) == 0)
7064 (void) SetImageOption(image_info,option+1,"0");
7066 (void) SetImageOption(image_info,option+1,argv[i+1]);
7069 if (LocaleCompare("transparent-color",option+1) == 0)
7073 (void) QueryColorCompliance("none",AllCompliance,
7074 &image_info->transparent_color,exception);
7075 (void) SetImageOption(image_info,option+1,"none");
7078 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7079 &image_info->transparent_color,exception);
7080 (void) SetImageOption(image_info,option+1,argv[i+1]);
7083 if (LocaleCompare("type",option+1) == 0)
7087 image_info->type=UndefinedType;
7088 (void) SetImageOption(image_info,option+1,"undefined");
7091 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7092 MagickFalse,argv[i+1]);
7093 (void) SetImageOption(image_info,option+1,argv[i+1]);
7100 if (LocaleCompare("undercolor",option+1) == 0)
7103 (void) DeleteImageOption(image_info,option+1);
7105 (void) SetImageOption(image_info,option+1,argv[i+1]);
7108 if (LocaleCompare("units",option+1) == 0)
7112 image_info->units=UndefinedResolution;
7113 (void) SetImageOption(image_info,option+1,"undefined");
7116 image_info->units=(ResolutionType) ParseCommandOption(
7117 MagickResolutionOptions,MagickFalse,argv[i+1]);
7118 (void) SetImageOption(image_info,option+1,argv[i+1]);
7125 if (LocaleCompare("verbose",option+1) == 0)
7129 image_info->verbose=MagickFalse;
7132 image_info->verbose=MagickTrue;
7133 image_info->ping=MagickFalse;
7136 if (LocaleCompare("view",option+1) == 0)
7140 if (image_info->view != (char *) NULL)
7141 image_info->view=DestroyString(image_info->view);
7144 (void) CloneString(&image_info->view,argv[i+1]);
7147 if (LocaleCompare("virtual-pixel",option+1) == 0)
7150 (void) SetImageOption(image_info,option+1,"undefined");
7152 (void) SetImageOption(image_info,option+1,argv[i+1]);
7159 if (LocaleCompare("white-point",option+1) == 0)
7162 (void) SetImageOption(image_info,option+1,"0.0");
7164 (void) SetImageOption(image_info,option+1,argv[i+1]);
7178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7182 + M o g r i f y I m a g e L i s t %
7186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7188 % MogrifyImageList() applies any command line options that might affect the
7189 % entire image list (e.g. -append, -coalesce, etc.).
7191 % The format of the MogrifyImage method is:
7193 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7194 % const char **argv,Image **images,ExceptionInfo *exception)
7196 % A description of each parameter follows:
7198 % o image_info: the image info..
7200 % o argc: Specifies a pointer to an integer describing the number of
7201 % elements in the argument vector.
7203 % o argv: Specifies a pointer to a text array containing the command line
7206 % o images: pointer to pointer of the first image in image list.
7208 % o exception: return any errors or warnings in this structure.
7211 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7212 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7223 PixelInterpolateMethod
7237 Apply options to the image list.
7239 assert(image_info != (ImageInfo *) NULL);
7240 assert(image_info->signature == MagickSignature);
7241 assert(images != (Image **) NULL);
7242 assert((*images)->previous == (Image *) NULL);
7243 assert((*images)->signature == MagickSignature);
7244 if ((*images)->debug != MagickFalse)
7245 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7246 (*images)->filename);
7247 if ((argc <= 0) || (*argv == (char *) NULL))
7249 interpolate_method=UndefinedInterpolatePixel;
7250 mogrify_info=CloneImageInfo(image_info);
7251 quantize_info=AcquireQuantizeInfo(mogrify_info);
7253 for (i=0; i < (ssize_t) argc; i++)
7255 if (*images == (Image *) NULL)
7258 if (IsCommandOption(option) == MagickFalse)
7260 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7261 count=MagickMax(count,0L);
7262 if ((i+count) >= (ssize_t) argc)
7264 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7265 switch (*(option+1))
7269 if (LocaleCompare("affinity",option+1) == 0)
7271 (void) SyncImagesSettings(mogrify_info,*images,exception);
7274 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7281 if (LocaleCompare("append",option+1) == 0)
7286 (void) SyncImagesSettings(mogrify_info,*images,exception);
7287 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7288 MagickFalse,exception);
7289 if (append_image == (Image *) NULL)
7294 *images=DestroyImageList(*images);
7295 *images=append_image;
7298 if (LocaleCompare("average",option+1) == 0)
7304 Average an image sequence (deprecated).
7306 (void) SyncImagesSettings(mogrify_info,*images,exception);
7307 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7309 if (average_image == (Image *) NULL)
7314 *images=DestroyImageList(*images);
7315 *images=average_image;
7322 if (LocaleCompare("clut",option+1) == 0)
7328 (void) SyncImagesSettings(mogrify_info,*images,exception);
7329 image=RemoveFirstImageFromList(images);
7330 clut_image=RemoveFirstImageFromList(images);
7331 if (clut_image == (Image *) NULL)
7336 (void) ClutImage(image,clut_image,interpolate_method,exception);
7337 clut_image=DestroyImage(clut_image);
7338 *images=DestroyImageList(*images);
7342 if (LocaleCompare("coalesce",option+1) == 0)
7347 (void) SyncImagesSettings(mogrify_info,*images,exception);
7348 coalesce_image=CoalesceImages(*images,exception);
7349 if (coalesce_image == (Image *) NULL)
7354 *images=DestroyImageList(*images);
7355 *images=coalesce_image;
7358 if (LocaleCompare("combine",option+1) == 0)
7363 (void) SyncImagesSettings(mogrify_info,*images,exception);
7364 combine_image=CombineImages(*images,exception);
7365 if (combine_image == (Image *) NULL)
7370 *images=DestroyImageList(*images);
7371 *images=combine_image;
7374 if (LocaleCompare("composite",option+1) == 0)
7384 (void) SyncImagesSettings(mogrify_info,*images,exception);
7385 image=RemoveFirstImageFromList(images);
7386 composite_image=RemoveFirstImageFromList(images);
7387 if (composite_image == (Image *) NULL)
7392 (void) TransformImage(&composite_image,(char *) NULL,
7393 composite_image->geometry,exception);
7394 SetGeometry(composite_image,&geometry);
7395 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7396 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7398 mask_image=RemoveFirstImageFromList(images);
7399 if (mask_image != (Image *) NULL)
7401 if ((image->compose == DisplaceCompositeOp) ||
7402 (image->compose == DistortCompositeOp))
7405 Merge Y displacement into X displacement image.
7407 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7408 mask_image,0,0,exception);
7409 mask_image=DestroyImage(mask_image);
7414 Set a blending mask for the composition.
7416 (void) NegateImage(mask_image,MagickFalse,exception);
7417 (void) SetImageMask(image,mask_image,exception);
7418 mask_image=DestroyImage(mask_image);
7421 (void) CompositeImage(image,image->compose,composite_image,
7422 geometry.x,geometry.y,exception);
7423 (void) SetImageMask(image,(Image *) NULL,exception);
7424 composite_image=DestroyImage(composite_image);
7425 *images=DestroyImageList(*images);
7433 if (LocaleCompare("deconstruct",option+1) == 0)
7438 (void) SyncImagesSettings(mogrify_info,*images,exception);
7439 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7441 if (deconstruct_image == (Image *) NULL)
7446 *images=DestroyImageList(*images);
7447 *images=deconstruct_image;
7450 if (LocaleCompare("delete",option+1) == 0)
7453 DeleteImages(images,"-1",exception);
7455 DeleteImages(images,argv[i+1],exception);
7458 if (LocaleCompare("dither",option+1) == 0)
7462 quantize_info->dither=MagickFalse;
7465 quantize_info->dither=MagickTrue;
7466 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7467 MagickDitherOptions,MagickFalse,argv[i+1]);
7470 if (LocaleCompare("duplicate",option+1) == 0)
7476 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7485 number_duplicates=(size_t) StringToLong(argv[i+1]);
7486 p=strchr(argv[i+1],',');
7487 if (p == (const char *) NULL)
7488 duplicate_images=DuplicateImages(*images,number_duplicates,
7491 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7494 AppendImageToList(images, duplicate_images);
7495 (void) SyncImagesSettings(mogrify_info,*images,exception);
7502 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7507 MagickEvaluateOperator
7510 (void) SyncImageSettings(mogrify_info,*images,exception);
7511 op=(MagickEvaluateOperator) ParseCommandOption(
7512 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7513 evaluate_image=EvaluateImages(*images,op,exception);
7514 if (evaluate_image == (Image *) NULL)
7519 *images=DestroyImageList(*images);
7520 *images=evaluate_image;
7527 if (LocaleCompare("fft",option+1) == 0)
7533 Implements the discrete Fourier transform (DFT).
7535 (void) SyncImageSettings(mogrify_info,*images,exception);
7536 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7537 MagickTrue : MagickFalse,exception);
7538 if (fourier_image == (Image *) NULL)
7540 *images=DestroyImage(*images);
7541 *images=fourier_image;
7544 if (LocaleCompare("flatten",option+1) == 0)
7549 (void) SyncImagesSettings(mogrify_info,*images,exception);
7550 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7551 if (flatten_image == (Image *) NULL)
7553 *images=DestroyImageList(*images);
7554 *images=flatten_image;
7557 if (LocaleCompare("fx",option+1) == 0)
7562 (void) SyncImagesSettings(mogrify_info,*images,exception);
7563 fx_image=FxImage(*images,argv[i+1],exception);
7564 if (fx_image == (Image *) NULL)
7569 *images=DestroyImageList(*images);
7577 if (LocaleCompare("hald-clut",option+1) == 0)
7583 (void) SyncImagesSettings(mogrify_info,*images,exception);
7584 image=RemoveFirstImageFromList(images);
7585 hald_image=RemoveFirstImageFromList(images);
7586 if (hald_image == (Image *) NULL)
7591 (void) HaldClutImage(image,hald_image,exception);
7592 hald_image=DestroyImage(hald_image);
7593 if (*images != (Image *) NULL)
7594 *images=DestroyImageList(*images);
7602 if (LocaleCompare("ift",option+1) == 0)
7610 Implements the inverse fourier discrete Fourier transform (DFT).
7612 (void) SyncImagesSettings(mogrify_info,*images,exception);
7613 magnitude_image=RemoveFirstImageFromList(images);
7614 phase_image=RemoveFirstImageFromList(images);
7615 if (phase_image == (Image *) NULL)
7620 fourier_image=InverseFourierTransformImage(magnitude_image,
7621 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7622 if (fourier_image == (Image *) NULL)
7624 if (*images != (Image *) NULL)
7625 *images=DestroyImage(*images);
7626 *images=fourier_image;
7629 if (LocaleCompare("insert",option+1) == 0)
7637 index=(ssize_t) StringToLong(argv[i+1]);
7638 p=RemoveLastImageFromList(images);
7639 if (p == (Image *) NULL)
7641 (void) ThrowMagickException(exception,GetMagickModule(),
7642 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7648 PrependImageToList(images,q);
7650 if (index == (ssize_t) GetImageListLength(*images))
7651 AppendImageToList(images,q);
7654 q=GetImageFromList(*images,index-1);
7655 if (q == (Image *) NULL)
7657 (void) ThrowMagickException(exception,GetMagickModule(),
7658 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7662 InsertImageInList(&q,p);
7664 *images=GetFirstImageInList(q);
7667 if (LocaleCompare("interpolate",option+1) == 0)
7669 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7670 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7677 if (LocaleCompare("layers",option+1) == 0)
7685 (void) SyncImagesSettings(mogrify_info,*images,exception);
7686 layers=(Image *) NULL;
7687 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7688 MagickFalse,argv[i+1]);
7693 layers=CoalesceImages(*images,exception);
7696 case CompareAnyLayer:
7697 case CompareClearLayer:
7698 case CompareOverlayLayer:
7701 layers=CompareImagesLayers(*images,method,exception);
7707 case TrimBoundsLayer:
7709 layers=MergeImageLayers(*images,method,exception);
7714 layers=DisposeImages(*images,exception);
7717 case OptimizeImageLayer:
7719 layers=OptimizeImageLayers(*images,exception);
7722 case OptimizePlusLayer:
7724 layers=OptimizePlusImageLayers(*images,exception);
7727 case OptimizeTransLayer:
7729 OptimizeImageTransparency(*images,exception);
7732 case RemoveDupsLayer:
7734 RemoveDuplicateLayers(images,exception);
7737 case RemoveZeroLayer:
7739 RemoveZeroDelayLayers(images,exception);
7745 General Purpose, GIF Animation Optimizer.
7747 layers=CoalesceImages(*images,exception);
7748 if (layers == (Image *) NULL)
7753 *images=DestroyImageList(*images);
7755 layers=OptimizeImageLayers(*images,exception);
7756 if (layers == (Image *) NULL)
7761 *images=DestroyImageList(*images);
7763 layers=(Image *) NULL;
7764 OptimizeImageTransparency(*images,exception);
7765 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7769 case CompositeLayer:
7781 Split image sequence at the first 'NULL:' image.
7784 while (source != (Image *) NULL)
7786 source=GetNextImageInList(source);
7787 if ((source != (Image *) NULL) &&
7788 (LocaleCompare(source->magick,"NULL") == 0))
7791 if (source != (Image *) NULL)
7793 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7794 (GetNextImageInList(source) == (Image *) NULL))
7795 source=(Image *) NULL;
7799 Separate the two lists, junk the null: image.
7801 source=SplitImageList(source->previous);
7802 DeleteImageFromList(&source);
7805 if (source == (Image *) NULL)
7807 (void) ThrowMagickException(exception,GetMagickModule(),
7808 OptionError,"MissingNullSeparator","layers Composite");
7813 Adjust offset with gravity and virtual canvas.
7815 SetGeometry(*images,&geometry);
7816 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7817 geometry.width=source->page.width != 0 ?
7818 source->page.width : source->columns;
7819 geometry.height=source->page.height != 0 ?
7820 source->page.height : source->rows;
7821 GravityAdjustGeometry((*images)->page.width != 0 ?
7822 (*images)->page.width : (*images)->columns,
7823 (*images)->page.height != 0 ? (*images)->page.height :
7824 (*images)->rows,(*images)->gravity,&geometry);
7825 compose=OverCompositeOp;
7826 option=GetImageOption(mogrify_info,"compose");
7827 if (option != (const char *) NULL)
7828 compose=(CompositeOperator) ParseCommandOption(
7829 MagickComposeOptions,MagickFalse,option);
7830 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7832 source=DestroyImageList(source);
7836 if (layers == (Image *) NULL)
7838 *images=DestroyImageList(*images);
7846 if (LocaleCompare("map",option+1) == 0)
7848 (void) SyncImagesSettings(mogrify_info,*images,exception);
7851 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7858 if (LocaleCompare("maximum",option+1) == 0)
7864 Maximum image sequence (deprecated).
7866 (void) SyncImagesSettings(mogrify_info,*images,exception);
7867 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7868 if (maximum_image == (Image *) NULL)
7873 *images=DestroyImageList(*images);
7874 *images=maximum_image;
7877 if (LocaleCompare("minimum",option+1) == 0)
7883 Minimum image sequence (deprecated).
7885 (void) SyncImagesSettings(mogrify_info,*images,exception);
7886 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7887 if (minimum_image == (Image *) NULL)
7892 *images=DestroyImageList(*images);
7893 *images=minimum_image;
7896 if (LocaleCompare("morph",option+1) == 0)
7901 (void) SyncImagesSettings(mogrify_info,*images,exception);
7902 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7904 if (morph_image == (Image *) NULL)
7909 *images=DestroyImageList(*images);
7910 *images=morph_image;
7913 if (LocaleCompare("mosaic",option+1) == 0)
7918 (void) SyncImagesSettings(mogrify_info,*images,exception);
7919 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7920 if (mosaic_image == (Image *) NULL)
7925 *images=DestroyImageList(*images);
7926 *images=mosaic_image;
7933 if (LocaleCompare("print",option+1) == 0)
7938 (void) SyncImagesSettings(mogrify_info,*images,exception);
7939 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7941 if (string == (char *) NULL)
7943 (void) FormatLocaleFile(stdout,"%s",string);
7944 string=DestroyString(string);
7946 if (LocaleCompare("process",option+1) == 0)
7955 (void) SyncImagesSettings(mogrify_info,*images,exception);
7956 arguments=StringToArgv(argv[i+1],&number_arguments);
7957 if (arguments == (char **) NULL)
7959 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
7980 Support old style syntax, filter="-option arg".
7982 length=strlen(argv[i+1]);
7983 token=(char *) NULL;
7984 if (~length >= (MaxTextExtent-1))
7985 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7987 if (token == (char *) NULL)
7990 arguments=argv[i+1];
7991 token_info=AcquireTokenInfo();
7992 status=Tokenizer(token_info,0,token,length,arguments,"","=",
7993 "\"",'\0',&breaker,&next,"e);
7994 token_info=DestroyTokenInfo(token_info);
8000 argv=(&(arguments[next]));
8001 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8004 token=DestroyString(token);
8007 (void) SubstituteString(&arguments[1],"-","");
8008 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8009 number_arguments-2,(const char **) arguments+2,exception);
8010 for (j=0; j < number_arguments; j++)
8011 arguments[j]=DestroyString(arguments[j]);
8012 arguments=(char **) RelinquishMagickMemory(arguments);
8019 if (LocaleCompare("reverse",option+1) == 0)
8021 ReverseImageList(images);
8028 if (LocaleCompare("smush",option+1) == 0)
8036 (void) SyncImagesSettings(mogrify_info,*images,exception);
8037 offset=(ssize_t) StringToLong(argv[i+1]);
8038 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8039 MagickFalse,offset,exception);
8040 if (smush_image == (Image *) NULL)
8045 *images=DestroyImageList(*images);
8046 *images=smush_image;
8049 if (LocaleCompare("swap",option+1) == 0)
8070 flags=ParseGeometry(argv[i+1],&geometry_info);
8071 index=(ssize_t) geometry_info.rho;
8072 if ((flags & SigmaValue) != 0)
8073 swap_index=(ssize_t) geometry_info.sigma;
8075 p=GetImageFromList(*images,index);
8076 q=GetImageFromList(*images,swap_index);
8077 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8079 (void) ThrowMagickException(exception,GetMagickModule(),
8080 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8086 swap=CloneImage(p,0,0,MagickTrue,exception);
8087 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8088 ReplaceImageInList(&q,swap);
8089 *images=GetFirstImageInList(q);
8096 if (LocaleCompare("write",option+1) == 0)
8107 (void) SyncImagesSettings(mogrify_info,*images,exception);
8108 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8109 (void) DeleteImageRegistry(key);
8110 write_images=(*images);
8112 write_images=CloneImageList(*images,exception);
8113 write_info=CloneImageInfo(mogrify_info);
8114 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8115 write_info=DestroyImageInfo(write_info);
8117 write_images=DestroyImageList(write_images);
8127 quantize_info=DestroyQuantizeInfo(quantize_info);
8128 mogrify_info=DestroyImageInfo(mogrify_info);
8129 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8130 return(status != 0 ? MagickTrue : MagickFalse);
8134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8138 + M o g r i f y I m a g e s %
8142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8144 % MogrifyImages() applies image processing options to a sequence of images as
8145 % prescribed by command line options.
8147 % The format of the MogrifyImage method is:
8149 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8150 % const MagickBooleanType post,const int argc,const char **argv,
8151 % Image **images,Exceptioninfo *exception)
8153 % A description of each parameter follows:
8155 % o image_info: the image info..
8157 % o post: If true, post process image list operators otherwise pre-process.
8159 % o argc: Specifies a pointer to an integer describing the number of
8160 % elements in the argument vector.
8162 % o argv: Specifies a pointer to a text array containing the command line
8165 % o images: pointer to a pointer of the first image in image list.
8167 % o exception: return any errors or warnings in this structure.
8170 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8171 const MagickBooleanType post,const int argc,const char **argv,
8172 Image **images,ExceptionInfo *exception)
8174 #define MogrifyImageTag "Mogrify/Image"
8188 assert(image_info != (ImageInfo *) NULL);
8189 assert(image_info->signature == MagickSignature);
8190 if (images == (Image **) NULL)
8191 return(MogrifyImage(image_info,argc,argv,images,exception));
8192 assert((*images)->previous == (Image *) NULL);
8193 assert((*images)->signature == MagickSignature);
8194 if ((*images)->debug != MagickFalse)
8195 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8196 (*images)->filename);
8197 if ((argc <= 0) || (*argv == (char *) NULL))
8199 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8204 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8209 Pre-process multi-image sequence operators
8211 if (post == MagickFalse)
8212 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8214 For each image, process simple single image operators
8217 n=GetImageListLength(*images);
8221 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8222 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8224 status&=MogrifyImage(image_info,argc,argv,images,exception);
8225 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8226 if (proceed == MagickFalse)
8228 if ( (*images)->next == (Image *) NULL )
8230 *images=(*images)->next;
8233 assert( *images != (Image *) NULL );
8235 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8236 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8240 Post-process, multi-image sequence operators
8242 *images=GetFirstImageInList(*images);
8243 if (post != MagickFalse)
8244 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8245 return(status != 0 ? MagickTrue : MagickFalse);