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-2013 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 % It wiil look for special options like "-debug", "-bench", and
86 % "-distribute-cache" that needs to be applied even before the main
87 % processing begins, and may completely overrule normal command processing.
88 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
89 % and are typically ignored (as they have been handled) if seen later.
91 % The format of the MagickCommandGenesis method is:
93 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
94 % MagickCommand command,int argc,char **argv,char **metadata,
95 % ExceptionInfo *exception)
97 % A description of each parameter follows:
99 % o image_info: the image info.
101 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
102 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
103 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
104 % DisplayImageCommand, or AnimateImageCommand.
106 % o argc: Specifies a pointer to an integer describing the number of
107 % elements in the argument vector.
109 % o argv: Specifies a pointer to a text array containing the command line
112 % o metadata: any metadata is returned here.
114 % o exception: return any errors or warnings in this structure.
117 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
118 MagickCommand command,int argc,char **argv,char **metadata,
119 ExceptionInfo *exception)
143 (void) setlocale(LC_ALL,"");
144 (void) setlocale(LC_NUMERIC,"C");
145 concurrent=MagickFalse;
149 regard_warnings=MagickFalse;
150 for (i=1; i < (ssize_t) (argc-1); i++)
153 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
155 if (LocaleCompare("-bench",option) == 0)
156 iterations=StringToUnsignedLong(argv[++i]);
157 if (LocaleCompare("-concurrent",option) == 0)
158 concurrent=MagickTrue;
159 if (LocaleCompare("-debug",option) == 0)
160 (void) SetLogEventMask(argv[++i]);
161 if (LocaleCompare("-distribute-cache",option) == 0)
163 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
166 if (LocaleCompare("-duration",option) == 0)
167 duration=StringToDouble(argv[++i],(char **) NULL);
168 if (LocaleCompare("-regard-warnings",option) == 0)
169 regard_warnings=MagickTrue;
173 status=command(image_info,argc,argv,metadata,exception);
174 if (exception->severity != UndefinedException)
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
179 CatchException(exception);
181 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
183 (void) fputs(*metadata,stdout);
184 *metadata=DestroyString(*metadata);
186 return(status == MagickFalse ? 0 : 1);
188 number_threads=GetOpenMPMaximumThreads();
190 for (n=1; n <= (ssize_t) number_threads; n++)
200 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
201 timer=AcquireTimerInfo();
202 if (concurrent == MagickFalse)
204 for (i=0; i < (ssize_t) iterations; i++)
206 if (status != MagickFalse)
210 if (GetElapsedTime(timer) > duration)
212 (void) ContinueTimer(timer);
214 status=command(image_info,argc,argv,metadata,exception);
215 if (exception->severity != UndefinedException)
217 if ((exception->severity > ErrorException) ||
218 (regard_warnings != MagickFalse))
220 CatchException(exception);
222 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
224 (void) fputs(*metadata,stdout);
225 *metadata=DestroyString(*metadata);
232 #if defined(MAGICKCORE_OPENMP_SUPPORT)
233 # pragma omp parallel for shared(status)
235 for (i=0; i < (ssize_t) iterations; i++)
237 if (status != MagickFalse)
241 if (GetElapsedTime(timer) > duration)
243 (void) ContinueTimer(timer);
245 status=command(image_info,argc,argv,metadata,exception);
246 #if defined(MAGICKCORE_OPENMP_SUPPORT)
247 # pragma omp critical (MagickCore_CommandGenesis)
250 if (exception->severity != UndefinedException)
252 if ((exception->severity > ErrorException) ||
253 (regard_warnings != MagickFalse))
255 CatchException(exception);
257 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
259 (void) fputs(*metadata,stdout);
260 *metadata=DestroyString(*metadata);
265 user_time=GetUserTime(timer);
266 parallel=GetElapsedTime(timer);
271 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
272 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
273 (void) FormatLocaleFile(stderr,
274 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
275 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
276 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
277 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
278 timer=DestroyTimerInfo(timer);
280 return(status == MagickFalse ? 0 : 1);
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 + M o g r i f y I m a g e %
292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294 % MogrifyImage() applies simple single image processing options to a single
295 % image that may be part of a large list, but also handles any 'region'
298 % The image in the list may be modified in three different ways...
300 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
301 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
302 % * replace by a list of images (only the -separate option!)
304 % In each case the result is returned into the list, and a pointer to the
305 % modified image (last image added if replaced by a list of images) is
308 % ASIDE: The -crop is present but restricted to non-tile single image crops
310 % This means if all the images are being processed (such as by
311 % MogrifyImages(), next image to be processed will be as per the pointer
312 % (*image)->next. Also the image list may grow as a result of some specific
313 % operations but as images are never merged or deleted, it will never shrink
314 % in length. Typically the list will remain the same length.
316 % WARNING: As the image pointed to may be replaced, the first image in the
317 % list may also change. GetFirstImageInList() should be used by caller if
318 % they wish return the Image pointer to the first image in list.
321 % The format of the MogrifyImage method is:
323 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
324 % const char **argv,Image **image)
326 % A description of each parameter follows:
328 % o image_info: the image info..
330 % o argc: Specifies a pointer to an integer describing the number of
331 % elements in the argument vector.
333 % o argv: Specifies a pointer to a text array containing the command line
336 % o image: the image.
338 % o exception: return any errors or warnings in this structure.
342 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
343 ExceptionInfo *exception)
358 Read an image into a image cache (for repeated usage) if not already in
359 cache. Then return the image that is in the cache.
361 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
362 sans_exception=AcquireExceptionInfo();
363 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
364 sans_exception=DestroyExceptionInfo(sans_exception);
365 if (image != (Image *) NULL)
367 read_info=CloneImageInfo(image_info);
368 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
369 image=ReadImage(read_info,exception);
370 read_info=DestroyImageInfo(read_info);
371 if (image != (Image *) NULL)
372 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
376 static inline MagickBooleanType IsPathWritable(const char *path)
378 if (IsPathAccessible(path) == MagickFalse)
380 if (access_utf8(path,W_OK) != 0)
385 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
392 static MagickBooleanType MonitorProgress(const char *text,
393 const MagickOffsetType offset,const MagickSizeType extent,
394 void *wand_unused(client_data))
397 message[MaxTextExtent],
408 (void) CopyMagickMemory(tag,text,MaxTextExtent);
410 if (p != (char *) NULL)
412 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
413 locale_message=GetLocaleMessage(message);
414 if (locale_message == message)
416 if (p == (char *) NULL)
417 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
418 locale_message,(long) offset,(unsigned long) extent,(long)
419 (100L*offset/(extent-1)));
421 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
422 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
423 (100L*offset/(extent-1)));
424 if (offset == (MagickOffsetType) (extent-1))
425 (void) FormatLocaleFile(stderr,"\n");
426 (void) fflush(stderr);
430 static Image *SparseColorOption(const Image *image,
431 const SparseColorMethod method,const char *arguments,
432 const MagickBooleanType color_from_image,ExceptionInfo *exception)
435 token[MaxTextExtent];
460 SparseColorOption() parses the complex -sparse-color argument into an an
461 array of floating point values then calls SparseColorImage(). Argument is
462 a complex mix of floating-point pixel coodinates, and color specifications
463 (or direct floating point numbers). The number of floats needed to
464 represent a color varies depending on the current channel setting.
466 assert(image != (Image *) NULL);
467 assert(image->signature == MagickSignature);
468 if (image->debug != MagickFalse)
469 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
470 assert(exception != (ExceptionInfo *) NULL);
471 assert(exception->signature == MagickSignature);
473 Limit channels according to image - and add up number of color channel.
476 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
478 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
480 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
482 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
483 (image->colorspace == CMYKColorspace))
485 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
486 (image->alpha_trait == BlendPixelTrait))
490 Read string, to determine number of arguments needed,
496 GetMagickToken(p,&p,token);
497 if ( token[0] == ',' ) continue;
498 if ( isalpha((int) token[0]) || token[0] == '#' ) {
499 if ( color_from_image ) {
500 (void) ThrowMagickException(exception,GetMagickModule(),
501 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
502 "Color arg given, when colors are coming from image");
503 return( (Image *)NULL);
505 x += number_colors; /* color argument */
508 x++; /* floating point argument */
512 if ( color_from_image ) {
513 /* just the control points are being given */
514 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
515 number_arguments=(x/2)*(2+number_colors);
518 /* control points and color values */
519 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
523 (void) ThrowMagickException(exception,GetMagickModule(),
524 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
525 "Invalid number of Arguments");
526 return( (Image *)NULL);
529 /* Allocate and fill in the floating point arguments */
530 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
531 sizeof(*sparse_arguments));
532 if (sparse_arguments == (double *) NULL) {
533 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
534 "MemoryAllocationFailed","%s","SparseColorOption");
535 return( (Image *)NULL);
537 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
538 sizeof(*sparse_arguments));
541 while( *p != '\0' && x < number_arguments ) {
543 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
544 if ( token[0] == '\0' ) break;
545 if ( isalpha((int) token[0]) || token[0] == '#' ) {
546 (void) ThrowMagickException(exception,GetMagickModule(),
547 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
548 "Color found, instead of X-coord");
552 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
554 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
555 if ( token[0] == '\0' ) break;
556 if ( isalpha((int) token[0]) || token[0] == '#' ) {
557 (void) ThrowMagickException(exception,GetMagickModule(),
558 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
559 "Color found, instead of Y-coord");
563 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
564 /* color values for this control point */
566 if ( (color_from_image ) {
567 /* get color from image */
573 /* color name or function given in string argument */
574 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
575 if ( token[0] == '\0' ) break;
576 if ( isalpha((int) token[0]) || token[0] == '#' ) {
577 /* Color string given */
578 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
579 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
580 sparse_arguments[x++] = QuantumScale*color.red;
581 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
582 sparse_arguments[x++] = QuantumScale*color.green;
583 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
584 sparse_arguments[x++] = QuantumScale*color.blue;
585 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
586 (image->colorspace == CMYKColorspace))
587 sparse_arguments[x++] = QuantumScale*color.black;
588 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
589 (image->alpha_trait == BlendPixelTrait))
590 sparse_arguments[x++] = QuantumScale*color.alpha;
593 /* Colors given as a set of floating point values - experimental */
594 /* NB: token contains the first floating point value to use! */
595 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
597 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
598 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
600 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
601 token[0] = ','; /* used this token - get another */
603 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
605 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
606 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
608 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
609 token[0] = ','; /* used this token - get another */
611 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
613 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
614 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
616 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
617 token[0] = ','; /* used this token - get another */
619 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
620 (image->colorspace == CMYKColorspace))
622 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
623 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
625 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
626 token[0] = ','; /* used this token - get another */
628 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
629 (image->alpha_trait == BlendPixelTrait))
631 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
632 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
634 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
635 token[0] = ','; /* used this token - get another */
640 if ( number_arguments != x && !error ) {
641 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
642 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
643 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
644 return( (Image *)NULL);
647 return( (Image *)NULL);
649 /* Call the Interpolation function with the parsed arguments */
650 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
652 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
653 return( sparse_image );
656 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
657 const char **argv,Image **image,ExceptionInfo *exception)
690 PixelInterpolateMethod
704 Initialize method variables.
706 assert(image_info != (const ImageInfo *) NULL);
707 assert(image_info->signature == MagickSignature);
708 assert(image != (Image **) NULL);
709 assert((*image)->signature == MagickSignature);
710 if ((*image)->debug != MagickFalse)
711 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
714 mogrify_info=CloneImageInfo(image_info);
715 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
716 quantize_info=AcquireQuantizeInfo(mogrify_info);
717 SetGeometryInfo(&geometry_info);
718 GetPixelInfo(*image,&fill);
719 fill=(*image)->background_color;
721 compose=(*image)->compose;
722 interpolate_method=UndefinedInterpolatePixel;
723 format=GetImageOption(mogrify_info,"format");
724 SetGeometry(*image,®ion_geometry);
725 region_image=NewImageList();
727 Transmogrify the image.
729 for (i=0; i < (ssize_t) argc; i++)
738 if (IsCommandOption(option) == MagickFalse)
740 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
742 if ((i+count) >= (ssize_t) argc)
744 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
745 mogrify_image=(Image *)NULL;
750 if (LocaleCompare("adaptive-blur",option+1) == 0)
755 (void) SyncImageSettings(mogrify_info,*image,exception);
756 flags=ParseGeometry(argv[i+1],&geometry_info);
757 if ((flags & SigmaValue) == 0)
758 geometry_info.sigma=1.0;
759 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
760 geometry_info.sigma,exception);
763 if (LocaleCompare("adaptive-resize",option+1) == 0)
766 Adaptive resize image.
768 (void) SyncImageSettings(mogrify_info,*image,exception);
769 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
770 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
771 geometry.height,exception);
774 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
777 Adaptive sharpen image.
779 (void) SyncImageSettings(mogrify_info,*image,exception);
780 flags=ParseGeometry(argv[i+1],&geometry_info);
781 if ((flags & SigmaValue) == 0)
782 geometry_info.sigma=1.0;
783 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
784 geometry_info.sigma,exception);
787 if (LocaleCompare("affine",option+1) == 0)
794 GetAffineMatrix(&draw_info->affine);
797 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
800 if (LocaleCompare("alpha",option+1) == 0)
805 (void) SyncImageSettings(mogrify_info,*image,exception);
806 alpha_type=(AlphaChannelOption) ParseCommandOption(
807 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
808 (void) SetImageAlphaChannel(*image,alpha_type,exception);
811 if (LocaleCompare("annotate",option+1) == 0)
815 geometry[MaxTextExtent];
820 (void) SyncImageSettings(mogrify_info,*image,exception);
821 SetGeometryInfo(&geometry_info);
822 flags=ParseGeometry(argv[i+1],&geometry_info);
823 if ((flags & SigmaValue) == 0)
824 geometry_info.sigma=geometry_info.rho;
825 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
827 if (text == (char *) NULL)
829 (void) CloneString(&draw_info->text,text);
830 text=DestroyString(text);
831 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
832 geometry_info.xi,geometry_info.psi);
833 (void) CloneString(&draw_info->geometry,geometry);
834 draw_info->affine.sx=cos(DegreesToRadians(
835 fmod(geometry_info.rho,360.0)));
836 draw_info->affine.rx=sin(DegreesToRadians(
837 fmod(geometry_info.rho,360.0)));
838 draw_info->affine.ry=(-sin(DegreesToRadians(
839 fmod(geometry_info.sigma,360.0))));
840 draw_info->affine.sy=cos(DegreesToRadians(
841 fmod(geometry_info.sigma,360.0)));
842 (void) AnnotateImage(*image,draw_info,exception);
845 if (LocaleCompare("antialias",option+1) == 0)
847 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
849 draw_info->text_antialias=(*option == '-') ? MagickTrue :
853 if (LocaleCompare("attenuate",option+1) == 0)
860 attenuate=StringToDouble(argv[i+1],(char **) NULL);
863 if (LocaleCompare("auto-gamma",option+1) == 0)
866 Auto Adjust Gamma of image based on its mean
868 (void) SyncImageSettings(mogrify_info,*image,exception);
869 (void) AutoGammaImage(*image,exception);
872 if (LocaleCompare("auto-level",option+1) == 0)
875 Perfectly Normalize (max/min stretch) the image
877 (void) SyncImageSettings(mogrify_info,*image,exception);
878 (void) AutoLevelImage(*image,exception);
881 if (LocaleCompare("auto-orient",option+1) == 0)
883 (void) SyncImageSettings(mogrify_info,*image,exception);
884 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
892 if (LocaleCompare("black-threshold",option+1) == 0)
895 Black threshold image.
897 (void) SyncImageSettings(mogrify_info,*image,exception);
898 (void) BlackThresholdImage(*image,argv[i+1],exception);
901 if (LocaleCompare("blue-shift",option+1) == 0)
906 (void) SyncImageSettings(mogrify_info,*image,exception);
907 geometry_info.rho=1.5;
909 flags=ParseGeometry(argv[i+1],&geometry_info);
910 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
913 if (LocaleCompare("blur",option+1) == 0)
918 (void) SyncImageSettings(mogrify_info,*image,exception);
919 flags=ParseGeometry(argv[i+1],&geometry_info);
920 if ((flags & SigmaValue) == 0)
921 geometry_info.sigma=1.0;
922 if ((flags & XiValue) == 0)
923 geometry_info.xi=0.0;
924 mogrify_image=BlurImage(*image,geometry_info.rho,
925 geometry_info.sigma,exception);
928 if (LocaleCompare("border",option+1) == 0)
931 Surround image with a border of solid color.
933 (void) SyncImageSettings(mogrify_info,*image,exception);
934 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
935 mogrify_image=BorderImage(*image,&geometry,compose,exception);
938 if (LocaleCompare("bordercolor",option+1) == 0)
942 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
943 &draw_info->border_color,exception);
946 (void) QueryColorCompliance(argv[i+1],AllCompliance,
947 &draw_info->border_color,exception);
950 if (LocaleCompare("box",option+1) == 0)
952 (void) QueryColorCompliance(argv[i+1],AllCompliance,
953 &draw_info->undercolor,exception);
956 if (LocaleCompare("brightness-contrast",option+1) == 0)
969 Brightness / contrast image.
971 (void) SyncImageSettings(mogrify_info,*image,exception);
972 flags=ParseGeometry(argv[i+1],&geometry_info);
973 brightness=geometry_info.rho;
975 if ((flags & SigmaValue) != 0)
976 contrast=geometry_info.sigma;
977 (void) BrightnessContrastImage(*image,brightness,contrast,
985 if (LocaleCompare("cdl",option+1) == 0)
988 *color_correction_collection;
991 Color correct with a color decision list.
993 (void) SyncImageSettings(mogrify_info,*image,exception);
994 color_correction_collection=FileToString(argv[i+1],~0,exception);
995 if (color_correction_collection == (char *) NULL)
997 (void) ColorDecisionListImage(*image,color_correction_collection,
1001 if (LocaleCompare("charcoal",option+1) == 0)
1006 (void) SyncImageSettings(mogrify_info,*image,exception);
1007 flags=ParseGeometry(argv[i+1],&geometry_info);
1008 if ((flags & SigmaValue) == 0)
1009 geometry_info.sigma=1.0;
1010 if ((flags & XiValue) == 0)
1011 geometry_info.xi=1.0;
1012 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1013 geometry_info.sigma,exception);
1016 if (LocaleCompare("chop",option+1) == 0)
1021 (void) SyncImageSettings(mogrify_info,*image,exception);
1022 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1023 mogrify_image=ChopImage(*image,&geometry,exception);
1026 if (LocaleCompare("perceptible",option+1) == 0)
1031 (void) SyncImageSettings(mogrify_info,*image,exception);
1032 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
1033 (char **) NULL),exception);
1036 if (LocaleCompare("clip",option+1) == 0)
1038 (void) SyncImageSettings(mogrify_info,*image,exception);
1041 (void) SetImageMask(*image,(Image *) NULL,exception);
1044 (void) ClipImage(*image,exception);
1047 if (LocaleCompare("clip-mask",option+1) == 0)
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1070 (void) SetImageMask(*image,(Image *) NULL,exception);
1075 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1077 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1078 if (mask_image == (Image *) NULL)
1080 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1081 return(MagickFalse);
1082 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1083 for (y=0; y < (ssize_t) mask_image->rows; y++)
1085 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1087 if (q == (Quantum *) NULL)
1089 for (x=0; x < (ssize_t) mask_image->columns; x++)
1091 if (mask_image->alpha_trait != BlendPixelTrait)
1092 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1093 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1094 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1095 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1096 q+=GetPixelChannels(mask_image);
1098 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1101 mask_view=DestroyCacheView(mask_view);
1102 mask_image->alpha_trait=BlendPixelTrait;
1103 (void) SetImageMask(*image,mask_image,exception);
1106 if (LocaleCompare("clip-path",option+1) == 0)
1108 (void) SyncImageSettings(mogrify_info,*image,exception);
1109 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1110 MagickFalse,exception);
1113 if (LocaleCompare("colorize",option+1) == 0)
1118 (void) SyncImageSettings(mogrify_info,*image,exception);
1119 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1122 if (LocaleCompare("color-matrix",option+1) == 0)
1127 (void) SyncImageSettings(mogrify_info,*image,exception);
1128 kernel=AcquireKernelInfo(argv[i+1]);
1129 if (kernel == (KernelInfo *) NULL)
1131 /* FUTURE: check on size of the matrix */
1132 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1133 kernel=DestroyKernelInfo(kernel);
1136 if (LocaleCompare("colors",option+1) == 0)
1139 Reduce the number of colors in the image.
1141 (void) SyncImageSettings(mogrify_info,*image,exception);
1142 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1143 if (quantize_info->number_colors == 0)
1145 if (((*image)->storage_class == DirectClass) ||
1146 (*image)->colors > quantize_info->number_colors)
1147 (void) QuantizeImage(quantize_info,*image,exception);
1149 (void) CompressImageColormap(*image,exception);
1152 if (LocaleCompare("colorspace",option+1) == 0)
1157 (void) SyncImageSettings(mogrify_info,*image,exception);
1160 (void) TransformImageColorspace(*image,sRGBColorspace,
1164 colorspace=(ColorspaceType) ParseCommandOption(
1165 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1166 (void) TransformImageColorspace(*image,colorspace,exception);
1169 if (LocaleCompare("compose",option+1) == 0)
1171 (void) SyncImageSettings(mogrify_info,*image,exception);
1172 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1173 MagickFalse,argv[i+1]);
1176 if (LocaleCompare("contrast",option+1) == 0)
1178 (void) SyncImageSettings(mogrify_info,*image,exception);
1179 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1180 MagickFalse,exception);
1183 if (LocaleCompare("contrast-stretch",option+1) == 0)
1193 Contrast stretch image.
1195 (void) SyncImageSettings(mogrify_info,*image,exception);
1196 flags=ParseGeometry(argv[i+1],&geometry_info);
1197 black_point=geometry_info.rho;
1198 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1200 if ((flags & PercentValue) != 0)
1202 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1203 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1205 white_point=(double) (*image)->columns*(*image)->rows-
1207 (void) ContrastStretchImage(*image,black_point,white_point,
1211 if (LocaleCompare("convolve",option+1) == 0)
1216 (void) SyncImageSettings(mogrify_info,*image,exception);
1217 kernel_info=AcquireKernelInfo(argv[i+1]);
1218 if (kernel_info == (KernelInfo *) NULL)
1220 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1221 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1222 kernel_info,exception);
1223 kernel_info=DestroyKernelInfo(kernel_info);
1226 if (LocaleCompare("crop",option+1) == 0)
1229 Crop a image to a smaller size
1231 (void) SyncImageSettings(mogrify_info,*image,exception);
1232 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1235 if (LocaleCompare("cycle",option+1) == 0)
1238 Cycle an image colormap.
1240 (void) SyncImageSettings(mogrify_info,*image,exception);
1241 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1249 if (LocaleCompare("decipher",option+1) == 0)
1257 (void) SyncImageSettings(mogrify_info,*image,exception);
1258 passkey=FileToStringInfo(argv[i+1],~0,exception);
1259 if (passkey != (StringInfo *) NULL)
1261 (void) PasskeyDecipherImage(*image,passkey,exception);
1262 passkey=DestroyStringInfo(passkey);
1266 if (LocaleCompare("density",option+1) == 0)
1271 (void) CloneString(&draw_info->density,argv[i+1]);
1274 if (LocaleCompare("depth",option+1) == 0)
1276 (void) SyncImageSettings(mogrify_info,*image,exception);
1279 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1282 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1286 if (LocaleCompare("deskew",option+1) == 0)
1292 Straighten the image.
1294 (void) SyncImageSettings(mogrify_info,*image,exception);
1296 threshold=40.0*QuantumRange/100.0;
1298 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1300 mogrify_image=DeskewImage(*image,threshold,exception);
1303 if (LocaleCompare("despeckle",option+1) == 0)
1306 Reduce the speckles within an image.
1308 (void) SyncImageSettings(mogrify_info,*image,exception);
1309 mogrify_image=DespeckleImage(*image,exception);
1312 if (LocaleCompare("display",option+1) == 0)
1314 (void) CloneString(&draw_info->server_name,argv[i+1]);
1317 if (LocaleCompare("distort",option+1) == 0)
1321 token[MaxTextExtent];
1341 (void) SyncImageSettings(mogrify_info,*image,exception);
1342 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1343 MagickFalse,argv[i+1]);
1344 if (method == ResizeDistortion)
1350 Special Case - Argument is actually a resize geometry!
1351 Convert that to an appropriate distortion argument array.
1353 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1355 resize_args[0]=(double) geometry.width;
1356 resize_args[1]=(double) geometry.height;
1357 mogrify_image=DistortImage(*image,method,(size_t)2,
1358 resize_args,MagickTrue,exception);
1361 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1363 if (args == (char *) NULL)
1366 for (x=0; *p != '\0'; x++)
1368 GetMagickToken(p,&p,token);
1370 GetMagickToken(p,&p,token);
1372 number_arguments=(size_t) x;
1373 arguments=(double *) AcquireQuantumMemory(number_arguments,
1374 sizeof(*arguments));
1375 if (arguments == (double *) NULL)
1376 ThrowWandFatalException(ResourceLimitFatalError,
1377 "MemoryAllocationFailed",(*image)->filename);
1378 (void) ResetMagickMemory(arguments,0,number_arguments*
1379 sizeof(*arguments));
1381 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1383 GetMagickToken(p,&p,token);
1385 GetMagickToken(p,&p,token);
1386 arguments[x]=StringToDouble(token,(char **) NULL);
1388 args=DestroyString(args);
1389 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1390 (*option == '+') ? MagickTrue : MagickFalse,exception);
1391 arguments=(double *) RelinquishMagickMemory(arguments);
1394 if (LocaleCompare("dither",option+1) == 0)
1398 quantize_info->dither_method=NoDitherMethod;
1401 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1402 MagickDitherOptions,MagickFalse,argv[i+1]);
1405 if (LocaleCompare("draw",option+1) == 0)
1410 (void) SyncImageSettings(mogrify_info,*image,exception);
1411 (void) CloneString(&draw_info->primitive,argv[i+1]);
1412 (void) DrawImage(*image,draw_info,exception);
1419 if (LocaleCompare("edge",option+1) == 0)
1422 Enhance edges in the image.
1424 (void) SyncImageSettings(mogrify_info,*image,exception);
1425 flags=ParseGeometry(argv[i+1],&geometry_info);
1426 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1429 if (LocaleCompare("emboss",option+1) == 0)
1434 (void) SyncImageSettings(mogrify_info,*image,exception);
1435 flags=ParseGeometry(argv[i+1],&geometry_info);
1436 if ((flags & SigmaValue) == 0)
1437 geometry_info.sigma=1.0;
1438 mogrify_image=EmbossImage(*image,geometry_info.rho,
1439 geometry_info.sigma,exception);
1442 if (LocaleCompare("encipher",option+1) == 0)
1450 (void) SyncImageSettings(mogrify_info,*image,exception);
1451 passkey=FileToStringInfo(argv[i+1],~0,exception);
1452 if (passkey != (StringInfo *) NULL)
1454 (void) PasskeyEncipherImage(*image,passkey,exception);
1455 passkey=DestroyStringInfo(passkey);
1459 if (LocaleCompare("encoding",option+1) == 0)
1461 (void) CloneString(&draw_info->encoding,argv[i+1]);
1464 if (LocaleCompare("enhance",option+1) == 0)
1469 (void) SyncImageSettings(mogrify_info,*image,exception);
1470 mogrify_image=EnhanceImage(*image,exception);
1473 if (LocaleCompare("equalize",option+1) == 0)
1478 (void) SyncImageSettings(mogrify_info,*image,exception);
1479 (void) EqualizeImage(*image,exception);
1482 if (LocaleCompare("evaluate",option+1) == 0)
1487 MagickEvaluateOperator
1490 (void) SyncImageSettings(mogrify_info,*image,exception);
1491 op=(MagickEvaluateOperator) ParseCommandOption(
1492 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1493 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1495 (void) EvaluateImage(*image,op,constant,exception);
1498 if (LocaleCompare("extent",option+1) == 0)
1501 Set the image extent.
1503 (void) SyncImageSettings(mogrify_info,*image,exception);
1504 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1505 if (geometry.width == 0)
1506 geometry.width=(*image)->columns;
1507 if (geometry.height == 0)
1508 geometry.height=(*image)->rows;
1509 mogrify_image=ExtentImage(*image,&geometry,exception);
1516 if (LocaleCompare("family",option+1) == 0)
1520 if (draw_info->family != (char *) NULL)
1521 draw_info->family=DestroyString(draw_info->family);
1524 (void) CloneString(&draw_info->family,argv[i+1]);
1527 if (LocaleCompare("features",option+1) == 0)
1531 (void) DeleteImageArtifact(*image,"identify:features");
1534 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1537 if (LocaleCompare("fill",option+1) == 0)
1545 GetPixelInfo(*image,&fill);
1548 (void) QueryColorCompliance("none",AllCompliance,&fill,
1550 draw_info->fill=fill;
1551 if (draw_info->fill_pattern != (Image *) NULL)
1552 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1555 sans=AcquireExceptionInfo();
1556 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1557 sans=DestroyExceptionInfo(sans);
1558 if (status == MagickFalse)
1559 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1562 draw_info->fill=fill=color;
1565 if (LocaleCompare("flip",option+1) == 0)
1568 Flip image scanlines.
1570 (void) SyncImageSettings(mogrify_info,*image,exception);
1571 mogrify_image=FlipImage(*image,exception);
1574 if (LocaleCompare("floodfill",option+1) == 0)
1582 (void) SyncImageSettings(mogrify_info,*image,exception);
1583 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1584 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1586 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1587 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1590 if (LocaleCompare("flop",option+1) == 0)
1593 Flop image scanlines.
1595 (void) SyncImageSettings(mogrify_info,*image,exception);
1596 mogrify_image=FlopImage(*image,exception);
1599 if (LocaleCompare("font",option+1) == 0)
1603 if (draw_info->font != (char *) NULL)
1604 draw_info->font=DestroyString(draw_info->font);
1607 (void) CloneString(&draw_info->font,argv[i+1]);
1610 if (LocaleCompare("format",option+1) == 0)
1615 if (LocaleCompare("frame",option+1) == 0)
1621 Surround image with an ornamental border.
1623 (void) SyncImageSettings(mogrify_info,*image,exception);
1624 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1625 frame_info.width=geometry.width;
1626 frame_info.height=geometry.height;
1627 frame_info.outer_bevel=geometry.x;
1628 frame_info.inner_bevel=geometry.y;
1629 frame_info.x=(ssize_t) frame_info.width;
1630 frame_info.y=(ssize_t) frame_info.height;
1631 frame_info.width=(*image)->columns+2*frame_info.width;
1632 frame_info.height=(*image)->rows+2*frame_info.height;
1633 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1636 if (LocaleCompare("function",option+1) == 0)
1640 token[MaxTextExtent];
1658 Function Modify Image Values
1660 (void) SyncImageSettings(mogrify_info,*image,exception);
1661 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1662 MagickFalse,argv[i+1]);
1663 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1665 if (arguments == (char *) NULL)
1667 p=(char *) arguments;
1668 for (x=0; *p != '\0'; x++)
1670 GetMagickToken(p,&p,token);
1672 GetMagickToken(p,&p,token);
1674 number_parameters=(size_t) x;
1675 parameters=(double *) AcquireQuantumMemory(number_parameters,
1676 sizeof(*parameters));
1677 if (parameters == (double *) NULL)
1678 ThrowWandFatalException(ResourceLimitFatalError,
1679 "MemoryAllocationFailed",(*image)->filename);
1680 (void) ResetMagickMemory(parameters,0,number_parameters*
1681 sizeof(*parameters));
1682 p=(char *) arguments;
1683 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1685 GetMagickToken(p,&p,token);
1687 GetMagickToken(p,&p,token);
1688 parameters[x]=StringToDouble(token,(char **) NULL);
1690 arguments=DestroyString(arguments);
1691 (void) FunctionImage(*image,function,number_parameters,parameters,
1693 parameters=(double *) RelinquishMagickMemory(parameters);
1700 if (LocaleCompare("gamma",option+1) == 0)
1705 (void) SyncImageSettings(mogrify_info,*image,exception);
1707 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1709 (void) GammaImage(*image,StringToDouble(argv[i+1],
1710 (char **) NULL),exception);
1713 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1714 (LocaleCompare("gaussian",option+1) == 0))
1717 Gaussian blur image.
1719 (void) SyncImageSettings(mogrify_info,*image,exception);
1720 flags=ParseGeometry(argv[i+1],&geometry_info);
1721 if ((flags & SigmaValue) == 0)
1722 geometry_info.sigma=1.0;
1723 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1724 geometry_info.sigma,exception);
1727 if (LocaleCompare("geometry",option+1) == 0)
1730 Record Image offset, Resize last image.
1732 (void) SyncImageSettings(mogrify_info,*image,exception);
1735 if ((*image)->geometry != (char *) NULL)
1736 (*image)->geometry=DestroyString((*image)->geometry);
1739 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1740 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1741 (void) CloneString(&(*image)->geometry,argv[i+1]);
1743 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1744 (*image)->filter,exception);
1747 if (LocaleCompare("gravity",option+1) == 0)
1751 draw_info->gravity=UndefinedGravity;
1754 draw_info->gravity=(GravityType) ParseCommandOption(
1755 MagickGravityOptions,MagickFalse,argv[i+1]);
1758 if (LocaleCompare("grayscale",option+1) == 0)
1760 PixelIntensityMethod
1763 (void) SyncImageSettings(mogrify_info,*image,exception);
1764 method=(PixelIntensityMethod) ParseCommandOption(
1765 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1766 (void) GrayscaleImage(*image,method,exception);
1773 if (LocaleCompare("highlight-color",option+1) == 0)
1775 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1782 if (LocaleCompare("identify",option+1) == 0)
1787 (void) SyncImageSettings(mogrify_info,*image,exception);
1788 if (format == (char *) NULL)
1790 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1794 text=InterpretImageProperties(mogrify_info,*image,format,
1796 if (text == (char *) NULL)
1798 (void) fputs(text,stdout);
1799 text=DestroyString(text);
1802 if (LocaleCompare("implode",option+1) == 0)
1807 (void) SyncImageSettings(mogrify_info,*image,exception);
1808 (void) ParseGeometry(argv[i+1],&geometry_info);
1809 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1810 interpolate_method,exception);
1813 if (LocaleCompare("interline-spacing",option+1) == 0)
1816 (void) ParseGeometry("0",&geometry_info);
1818 (void) ParseGeometry(argv[i+1],&geometry_info);
1819 draw_info->interline_spacing=geometry_info.rho;
1822 if (LocaleCompare("interpolate",option+1) == 0)
1824 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1825 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1828 if (LocaleCompare("interword-spacing",option+1) == 0)
1831 (void) ParseGeometry("0",&geometry_info);
1833 (void) ParseGeometry(argv[i+1],&geometry_info);
1834 draw_info->interword_spacing=geometry_info.rho;
1837 if (LocaleCompare("interpolative-resize",option+1) == 0)
1840 Interpolative resize image.
1842 (void) SyncImageSettings(mogrify_info,*image,exception);
1843 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1844 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1845 geometry.height,interpolate_method,exception);
1852 if (LocaleCompare("kerning",option+1) == 0)
1855 (void) ParseGeometry("0",&geometry_info);
1857 (void) ParseGeometry(argv[i+1],&geometry_info);
1858 draw_info->kerning=geometry_info.rho;
1865 if (LocaleCompare("lat",option+1) == 0)
1868 Local adaptive threshold image.
1870 (void) SyncImageSettings(mogrify_info,*image,exception);
1871 flags=ParseGeometry(argv[i+1],&geometry_info);
1872 if ((flags & PercentValue) != 0)
1873 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1874 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1875 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1876 geometry_info.xi,exception);
1879 if (LocaleCompare("level",option+1) == 0)
1892 (void) SyncImageSettings(mogrify_info,*image,exception);
1893 flags=ParseGeometry(argv[i+1],&geometry_info);
1894 black_point=geometry_info.rho;
1895 white_point=(double) QuantumRange;
1896 if ((flags & SigmaValue) != 0)
1897 white_point=geometry_info.sigma;
1899 if ((flags & XiValue) != 0)
1900 gamma=geometry_info.xi;
1901 if ((flags & PercentValue) != 0)
1903 black_point*=(double) (QuantumRange/100.0);
1904 white_point*=(double) (QuantumRange/100.0);
1906 if ((flags & SigmaValue) == 0)
1907 white_point=(double) QuantumRange-black_point;
1908 if ((*option == '+') || ((flags & AspectValue) != 0))
1909 (void) LevelizeImage(*image,black_point,white_point,gamma,
1912 (void) LevelImage(*image,black_point,white_point,gamma,
1916 if (LocaleCompare("level-colors",option+1) == 0)
1919 token[MaxTextExtent];
1928 p=(const char *) argv[i+1];
1929 GetMagickToken(p,&p,token); /* get black point color */
1930 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1931 (void) QueryColorCompliance(token,AllCompliance,
1932 &black_point,exception);
1934 (void) QueryColorCompliance("#000000",AllCompliance,
1935 &black_point,exception);
1936 if (isalpha((int) token[0]) || (token[0] == '#'))
1937 GetMagickToken(p,&p,token);
1939 white_point=black_point; /* set everything to that color */
1942 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1943 GetMagickToken(p,&p,token); /* Get white point color. */
1944 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1945 (void) QueryColorCompliance(token,AllCompliance,
1946 &white_point,exception);
1948 (void) QueryColorCompliance("#ffffff",AllCompliance,
1949 &white_point,exception);
1951 (void) LevelImageColors(*image,&black_point,&white_point,
1952 *option == '+' ? MagickTrue : MagickFalse,exception);
1955 if (LocaleCompare("linear-stretch",option+1) == 0)
1964 (void) SyncImageSettings(mogrify_info,*image,exception);
1965 flags=ParseGeometry(argv[i+1],&geometry_info);
1966 black_point=geometry_info.rho;
1967 white_point=(double) (*image)->columns*(*image)->rows;
1968 if ((flags & SigmaValue) != 0)
1969 white_point=geometry_info.sigma;
1970 if ((flags & PercentValue) != 0)
1972 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1973 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1975 if ((flags & SigmaValue) == 0)
1976 white_point=(double) (*image)->columns*(*image)->rows-
1978 (void) LinearStretchImage(*image,black_point,white_point,exception);
1981 if (LocaleCompare("liquid-rescale",option+1) == 0)
1984 Liquid rescale image.
1986 (void) SyncImageSettings(mogrify_info,*image,exception);
1987 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1988 if ((flags & XValue) == 0)
1990 if ((flags & YValue) == 0)
1992 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1993 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1996 if (LocaleCompare("lowlight-color",option+1) == 0)
1998 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2005 if (LocaleCompare("magnify",option+1) == 0)
2010 (void) SyncImageSettings(mogrify_info,*image,exception);
2011 mogrify_image=MagnifyImage(*image,exception);
2014 if (LocaleCompare("map",option+1) == 0)
2020 Transform image colors to match this set of colors.
2022 (void) SyncImageSettings(mogrify_info,*image,exception);
2025 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2026 if (remap_image == (Image *) NULL)
2028 (void) RemapImage(quantize_info,*image,remap_image,exception);
2029 remap_image=DestroyImage(remap_image);
2032 if (LocaleCompare("mask",option+1) == 0)
2037 (void) SyncImageSettings(mogrify_info,*image,exception);
2043 (void) SetImageMask(*image,(Image *) NULL,exception);
2049 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2050 if (mask == (Image *) NULL)
2052 (void) SetImageMask(*image,mask,exception);
2053 mask=DestroyImage(mask);
2056 if (LocaleCompare("matte",option+1) == 0)
2058 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2059 SetAlphaChannel : DeactivateAlphaChannel,exception);
2062 if (LocaleCompare("median",option+1) == 0)
2065 Median filter image.
2067 (void) SyncImageSettings(mogrify_info,*image,exception);
2068 flags=ParseGeometry(argv[i+1],&geometry_info);
2069 if ((flags & SigmaValue) == 0)
2070 geometry_info.sigma=geometry_info.rho;
2071 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2072 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2075 if (LocaleCompare("mode",option+1) == 0)
2080 (void) SyncImageSettings(mogrify_info,*image,exception);
2081 flags=ParseGeometry(argv[i+1],&geometry_info);
2082 if ((flags & SigmaValue) == 0)
2083 geometry_info.sigma=geometry_info.rho;
2084 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2085 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2088 if (LocaleCompare("modulate",option+1) == 0)
2090 (void) SyncImageSettings(mogrify_info,*image,exception);
2091 (void) ModulateImage(*image,argv[i+1],exception);
2094 if (LocaleCompare("monitor",option+1) == 0)
2098 (void) SetImageProgressMonitor(*image,
2099 (MagickProgressMonitor) NULL,(void *) NULL);
2102 (void) SetImageProgressMonitor(*image,MonitorProgress,
2106 if (LocaleCompare("monochrome",option+1) == 0)
2108 (void) SyncImageSettings(mogrify_info,*image,exception);
2109 (void) SetImageType(*image,BilevelType,exception);
2112 if (LocaleCompare("morphology",option+1) == 0)
2115 token[MaxTextExtent];
2130 Morphological Image Operation
2132 (void) SyncImageSettings(mogrify_info,*image,exception);
2134 GetMagickToken(p,&p,token);
2135 method=(MorphologyMethod) ParseCommandOption(
2136 MagickMorphologyOptions,MagickFalse,token);
2138 GetMagickToken(p,&p,token);
2139 if ((*p == ':') || (*p == ','))
2140 GetMagickToken(p,&p,token);
2142 iterations=(ssize_t) StringToLong(p);
2143 kernel=AcquireKernelInfo(argv[i+2]);
2144 if (kernel == (KernelInfo *) NULL)
2146 (void) ThrowMagickException(exception,GetMagickModule(),
2147 OptionError,"UnabletoParseKernel","morphology");
2151 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2153 kernel=DestroyKernelInfo(kernel);
2156 if (LocaleCompare("motion-blur",option+1) == 0)
2161 (void) SyncImageSettings(mogrify_info,*image,exception);
2162 flags=ParseGeometry(argv[i+1],&geometry_info);
2163 if ((flags & SigmaValue) == 0)
2164 geometry_info.sigma=1.0;
2165 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2166 geometry_info.sigma,geometry_info.xi,exception);
2173 if (LocaleCompare("negate",option+1) == 0)
2175 (void) SyncImageSettings(mogrify_info,*image,exception);
2176 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2177 MagickFalse,exception);
2180 if (LocaleCompare("noise",option+1) == 0)
2182 (void) SyncImageSettings(mogrify_info,*image,exception);
2185 flags=ParseGeometry(argv[i+1],&geometry_info);
2186 if ((flags & SigmaValue) == 0)
2187 geometry_info.sigma=geometry_info.rho;
2188 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2189 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2196 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2197 MagickFalse,argv[i+1]);
2198 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2202 if (LocaleCompare("normalize",option+1) == 0)
2204 (void) SyncImageSettings(mogrify_info,*image,exception);
2205 (void) NormalizeImage(*image,exception);
2212 if (LocaleCompare("opaque",option+1) == 0)
2217 (void) SyncImageSettings(mogrify_info,*image,exception);
2218 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2220 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2221 MagickFalse : MagickTrue,exception);
2224 if (LocaleCompare("ordered-dither",option+1) == 0)
2226 (void) SyncImageSettings(mogrify_info,*image,exception);
2227 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2234 if (LocaleCompare("paint",option+1) == 0)
2236 (void) SyncImageSettings(mogrify_info,*image,exception);
2237 (void) ParseGeometry(argv[i+1],&geometry_info);
2238 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2239 geometry_info.sigma,exception);
2242 if (LocaleCompare("pointsize",option+1) == 0)
2245 (void) ParseGeometry("12",&geometry_info);
2247 (void) ParseGeometry(argv[i+1],&geometry_info);
2248 draw_info->pointsize=geometry_info.rho;
2251 if (LocaleCompare("polaroid",option+1) == 0)
2263 Simulate a Polaroid picture.
2265 (void) SyncImageSettings(mogrify_info,*image,exception);
2266 random_info=AcquireRandomInfo();
2267 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2268 random_info=DestroyRandomInfo(random_info);
2271 SetGeometryInfo(&geometry_info);
2272 flags=ParseGeometry(argv[i+1],&geometry_info);
2273 angle=geometry_info.rho;
2275 caption=GetImageProperty(*image,"caption",exception);
2276 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2277 interpolate_method,exception);
2280 if (LocaleCompare("posterize",option+1) == 0)
2285 (void) SyncImageSettings(mogrify_info,*image,exception);
2286 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2287 quantize_info->dither_method,exception);
2290 if (LocaleCompare("preview",option+1) == 0)
2298 (void) SyncImageSettings(mogrify_info,*image,exception);
2300 preview_type=UndefinedPreview;
2302 preview_type=(PreviewType) ParseCommandOption(
2303 MagickPreviewOptions,MagickFalse,argv[i+1]);
2304 mogrify_image=PreviewImage(*image,preview_type,exception);
2307 if (LocaleCompare("profile",option+1) == 0)
2321 (void) SyncImageSettings(mogrify_info,*image,exception);
2325 Remove a profile from the image.
2327 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2332 Associate a profile with the image.
2334 profile_info=CloneImageInfo(mogrify_info);
2335 profile=GetImageProfile(*image,"iptc");
2336 if (profile != (StringInfo *) NULL)
2337 profile_info->profile=(void *) CloneStringInfo(profile);
2338 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2339 profile_info=DestroyImageInfo(profile_info);
2340 if (profile_image == (Image *) NULL)
2345 profile_info=CloneImageInfo(mogrify_info);
2346 (void) CopyMagickString(profile_info->filename,argv[i+1],
2348 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2349 if (profile != (StringInfo *) NULL)
2351 (void) ProfileImage(*image,profile_info->magick,
2352 GetStringInfoDatum(profile),(size_t)
2353 GetStringInfoLength(profile),exception);
2354 profile=DestroyStringInfo(profile);
2356 profile_info=DestroyImageInfo(profile_info);
2359 ResetImageProfileIterator(profile_image);
2360 name=GetNextImageProfile(profile_image);
2361 while (name != (const char *) NULL)
2363 profile=GetImageProfile(profile_image,name);
2364 if (profile != (StringInfo *) NULL)
2365 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2366 (size_t) GetStringInfoLength(profile),exception);
2367 name=GetNextImageProfile(profile_image);
2369 profile_image=DestroyImage(profile_image);
2376 if (LocaleCompare("quantize",option+1) == 0)
2380 quantize_info->colorspace=UndefinedColorspace;
2383 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2384 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2391 if (LocaleCompare("radial-blur",option+1) == 0)
2396 (void) SyncImageSettings(mogrify_info,*image,exception);
2397 flags=ParseGeometry(argv[i+1],&geometry_info);
2398 mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception);
2401 if (LocaleCompare("raise",option+1) == 0)
2404 Surround image with a raise of solid color.
2406 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2407 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2408 MagickFalse,exception);
2411 if (LocaleCompare("random-threshold",option+1) == 0)
2416 (void) SyncImageSettings(mogrify_info,*image,exception);
2417 (void) RandomThresholdImage(*image,argv[i+1],exception);
2420 if (LocaleCompare("region",option+1) == 0)
2422 (void) SyncImageSettings(mogrify_info,*image,exception);
2423 if (region_image != (Image *) NULL)
2428 (void) CompositeImage(region_image,*image,
2429 region_image->alpha_trait == BlendPixelTrait ?
2430 CopyCompositeOp : OverCompositeOp,MagickTrue,
2431 region_geometry.x,region_geometry.y,exception);
2432 *image=DestroyImage(*image);
2433 *image=region_image;
2434 region_image = (Image *) NULL;
2439 Apply transformations to a selected region of the image.
2441 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2443 mogrify_image=CropImage(*image,®ion_geometry,exception);
2444 if (mogrify_image == (Image *) NULL)
2446 region_image=(*image);
2447 *image=mogrify_image;
2448 mogrify_image=(Image *) NULL;
2451 if (LocaleCompare("render",option+1) == 0)
2453 (void) SyncImageSettings(mogrify_info,*image,exception);
2454 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2457 if (LocaleCompare("remap",option+1) == 0)
2463 Transform image colors to match this set of colors.
2465 (void) SyncImageSettings(mogrify_info,*image,exception);
2468 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2469 if (remap_image == (Image *) NULL)
2471 (void) RemapImage(quantize_info,*image,remap_image,exception);
2472 remap_image=DestroyImage(remap_image);
2475 if (LocaleCompare("repage",option+1) == 0)
2479 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2482 (void) ResetImagePage(*image,argv[i+1]);
2485 if (LocaleCompare("resample",option+1) == 0)
2490 (void) SyncImageSettings(mogrify_info,*image,exception);
2491 flags=ParseGeometry(argv[i+1],&geometry_info);
2492 if ((flags & SigmaValue) == 0)
2493 geometry_info.sigma=geometry_info.rho;
2494 mogrify_image=ResampleImage(*image,geometry_info.rho,
2495 geometry_info.sigma,(*image)->filter,exception);
2498 if (LocaleCompare("resize",option+1) == 0)
2503 (void) SyncImageSettings(mogrify_info,*image,exception);
2504 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2505 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2506 (*image)->filter,exception);
2509 if (LocaleCompare("roll",option+1) == 0)
2514 (void) SyncImageSettings(mogrify_info,*image,exception);
2515 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2516 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2519 if (LocaleCompare("rotate",option+1) == 0)
2525 Check for conditional image rotation.
2527 (void) SyncImageSettings(mogrify_info,*image,exception);
2528 if (strchr(argv[i+1],'>') != (char *) NULL)
2529 if ((*image)->columns <= (*image)->rows)
2531 if (strchr(argv[i+1],'<') != (char *) NULL)
2532 if ((*image)->columns >= (*image)->rows)
2537 geometry=ConstantString(argv[i+1]);
2538 (void) SubstituteString(&geometry,">","");
2539 (void) SubstituteString(&geometry,"<","");
2540 (void) ParseGeometry(geometry,&geometry_info);
2541 geometry=DestroyString(geometry);
2542 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2549 if (LocaleCompare("sample",option+1) == 0)
2552 Sample image with pixel replication.
2554 (void) SyncImageSettings(mogrify_info,*image,exception);
2555 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2556 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2560 if (LocaleCompare("scale",option+1) == 0)
2565 (void) SyncImageSettings(mogrify_info,*image,exception);
2566 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2567 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2571 if (LocaleCompare("selective-blur",option+1) == 0)
2574 Selectively blur pixels within a contrast threshold.
2576 (void) SyncImageSettings(mogrify_info,*image,exception);
2577 flags=ParseGeometry(argv[i+1],&geometry_info);
2578 if ((flags & PercentValue) != 0)
2579 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2580 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2581 geometry_info.sigma,geometry_info.xi,exception);
2584 if (LocaleCompare("separate",option+1) == 0)
2587 Break channels into separate images.
2589 (void) SyncImageSettings(mogrify_info,*image,exception);
2590 mogrify_image=SeparateImages(*image,exception);
2593 if (LocaleCompare("sepia-tone",option+1) == 0)
2601 (void) SyncImageSettings(mogrify_info,*image,exception);
2602 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2604 mogrify_image=SepiaToneImage(*image,threshold,exception);
2607 if (LocaleCompare("segment",option+1) == 0)
2612 (void) SyncImageSettings(mogrify_info,*image,exception);
2613 flags=ParseGeometry(argv[i+1],&geometry_info);
2614 if ((flags & SigmaValue) == 0)
2615 geometry_info.sigma=1.0;
2616 (void) SegmentImage(*image,(*image)->colorspace,
2617 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2621 if (LocaleCompare("set",option+1) == 0)
2631 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2632 (void) DeleteImageRegistry(argv[i+1]+9);
2634 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2636 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2637 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2640 (void) DeleteImageProperty(*image,argv[i+1]);
2643 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2645 if (value == (char *) NULL)
2647 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2648 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2651 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2653 (void) SetImageOption(image_info,argv[i+1]+7,value);
2654 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2655 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2658 (void) SetImageProperty(*image,argv[i+1],value,exception);
2659 value=DestroyString(value);
2662 if (LocaleCompare("shade",option+1) == 0)
2667 (void) SyncImageSettings(mogrify_info,*image,exception);
2668 flags=ParseGeometry(argv[i+1],&geometry_info);
2669 if ((flags & SigmaValue) == 0)
2670 geometry_info.sigma=1.0;
2671 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2672 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2675 if (LocaleCompare("shadow",option+1) == 0)
2680 (void) SyncImageSettings(mogrify_info,*image,exception);
2681 flags=ParseGeometry(argv[i+1],&geometry_info);
2682 if ((flags & SigmaValue) == 0)
2683 geometry_info.sigma=1.0;
2684 if ((flags & XiValue) == 0)
2685 geometry_info.xi=4.0;
2686 if ((flags & PsiValue) == 0)
2687 geometry_info.psi=4.0;
2688 mogrify_image=ShadowImage(*image,geometry_info.rho,
2689 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2690 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2693 if (LocaleCompare("sharpen",option+1) == 0)
2698 (void) SyncImageSettings(mogrify_info,*image,exception);
2699 flags=ParseGeometry(argv[i+1],&geometry_info);
2700 if ((flags & SigmaValue) == 0)
2701 geometry_info.sigma=1.0;
2702 if ((flags & XiValue) == 0)
2703 geometry_info.xi=0.0;
2704 mogrify_image=SharpenImage(*image,geometry_info.rho,
2705 geometry_info.sigma,exception);
2708 if (LocaleCompare("shave",option+1) == 0)
2711 Shave the image edges.
2713 (void) SyncImageSettings(mogrify_info,*image,exception);
2714 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2715 mogrify_image=ShaveImage(*image,&geometry,exception);
2718 if (LocaleCompare("shear",option+1) == 0)
2723 (void) SyncImageSettings(mogrify_info,*image,exception);
2724 flags=ParseGeometry(argv[i+1],&geometry_info);
2725 if ((flags & SigmaValue) == 0)
2726 geometry_info.sigma=geometry_info.rho;
2727 mogrify_image=ShearImage(*image,geometry_info.rho,
2728 geometry_info.sigma,exception);
2731 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2734 Sigmoidal non-linearity contrast control.
2736 (void) SyncImageSettings(mogrify_info,*image,exception);
2737 flags=ParseGeometry(argv[i+1],&geometry_info);
2738 if ((flags & SigmaValue) == 0)
2739 geometry_info.sigma=(double) QuantumRange/2.0;
2740 if ((flags & PercentValue) != 0)
2741 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2743 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2744 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2748 if (LocaleCompare("sketch",option+1) == 0)
2753 (void) SyncImageSettings(mogrify_info,*image,exception);
2754 flags=ParseGeometry(argv[i+1],&geometry_info);
2755 if ((flags & SigmaValue) == 0)
2756 geometry_info.sigma=1.0;
2757 mogrify_image=SketchImage(*image,geometry_info.rho,
2758 geometry_info.sigma,geometry_info.xi,exception);
2761 if (LocaleCompare("solarize",option+1) == 0)
2766 (void) SyncImageSettings(mogrify_info,*image,exception);
2767 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2769 (void) SolarizeImage(*image,threshold,exception);
2772 if (LocaleCompare("sparse-color",option+1) == 0)
2781 Sparse Color Interpolated Gradient
2783 (void) SyncImageSettings(mogrify_info,*image,exception);
2784 method=(SparseColorMethod) ParseCommandOption(
2785 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2786 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2788 if (arguments == (char *) NULL)
2790 mogrify_image=SparseColorOption(*image,method,arguments,
2791 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2792 arguments=DestroyString(arguments);
2795 if (LocaleCompare("splice",option+1) == 0)
2798 Splice a solid color into the image.
2800 (void) SyncImageSettings(mogrify_info,*image,exception);
2801 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2802 mogrify_image=SpliceImage(*image,&geometry,exception);
2805 if (LocaleCompare("spread",option+1) == 0)
2810 (void) SyncImageSettings(mogrify_info,*image,exception);
2811 (void) ParseGeometry(argv[i+1],&geometry_info);
2812 mogrify_image=SpreadImage(*image,geometry_info.rho,
2813 interpolate_method,exception);
2816 if (LocaleCompare("statistic",option+1) == 0)
2821 (void) SyncImageSettings(mogrify_info,*image,exception);
2822 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2823 MagickFalse,argv[i+1]);
2824 (void) ParseGeometry(argv[i+2],&geometry_info);
2825 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2826 (size_t) geometry_info.sigma,exception);
2829 if (LocaleCompare("stretch",option+1) == 0)
2833 draw_info->stretch=UndefinedStretch;
2836 draw_info->stretch=(StretchType) ParseCommandOption(
2837 MagickStretchOptions,MagickFalse,argv[i+1]);
2840 if (LocaleCompare("strip",option+1) == 0)
2843 Strip image of profiles and comments.
2845 (void) SyncImageSettings(mogrify_info,*image,exception);
2846 (void) StripImage(*image,exception);
2849 if (LocaleCompare("stroke",option+1) == 0)
2859 (void) QueryColorCompliance("none",AllCompliance,
2860 &draw_info->stroke,exception);
2861 if (draw_info->stroke_pattern != (Image *) NULL)
2862 draw_info->stroke_pattern=DestroyImage(
2863 draw_info->stroke_pattern);
2866 sans=AcquireExceptionInfo();
2867 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2868 sans=DestroyExceptionInfo(sans);
2869 if (status == MagickFalse)
2870 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2873 draw_info->stroke=color;
2876 if (LocaleCompare("strokewidth",option+1) == 0)
2878 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2881 if (LocaleCompare("style",option+1) == 0)
2885 draw_info->style=UndefinedStyle;
2888 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2889 MagickFalse,argv[i+1]);
2892 if (LocaleCompare("swirl",option+1) == 0)
2897 (void) SyncImageSettings(mogrify_info,*image,exception);
2898 (void) ParseGeometry(argv[i+1],&geometry_info);
2899 mogrify_image=SwirlImage(*image,geometry_info.rho,
2900 interpolate_method,exception);
2907 if (LocaleCompare("threshold",option+1) == 0)
2915 (void) SyncImageSettings(mogrify_info,*image,exception);
2917 threshold=(double) QuantumRange/2;
2919 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2921 (void) BilevelImage(*image,threshold,exception);
2924 if (LocaleCompare("thumbnail",option+1) == 0)
2929 (void) SyncImageSettings(mogrify_info,*image,exception);
2930 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2931 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2935 if (LocaleCompare("tile",option+1) == 0)
2939 if (draw_info->fill_pattern != (Image *) NULL)
2940 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2943 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2947 if (LocaleCompare("tint",option+1) == 0)
2952 (void) SyncImageSettings(mogrify_info,*image,exception);
2953 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2956 if (LocaleCompare("transform",option+1) == 0)
2959 Affine transform image.
2961 (void) SyncImageSettings(mogrify_info,*image,exception);
2962 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2966 if (LocaleCompare("transparent",option+1) == 0)
2971 (void) SyncImageSettings(mogrify_info,*image,exception);
2972 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2974 (void) TransparentPaintImage(*image,&target,(Quantum)
2975 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2979 if (LocaleCompare("transpose",option+1) == 0)
2982 Transpose image scanlines.
2984 (void) SyncImageSettings(mogrify_info,*image,exception);
2985 mogrify_image=TransposeImage(*image,exception);
2988 if (LocaleCompare("transverse",option+1) == 0)
2991 Transverse image scanlines.
2993 (void) SyncImageSettings(mogrify_info,*image,exception);
2994 mogrify_image=TransverseImage(*image,exception);
2997 if (LocaleCompare("treedepth",option+1) == 0)
2999 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3002 if (LocaleCompare("trim",option+1) == 0)
3007 (void) SyncImageSettings(mogrify_info,*image,exception);
3008 mogrify_image=TrimImage(*image,exception);
3011 if (LocaleCompare("type",option+1) == 0)
3016 (void) SyncImageSettings(mogrify_info,*image,exception);
3020 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3022 (*image)->type=UndefinedType;
3023 (void) SetImageType(*image,type,exception);
3030 if (LocaleCompare("undercolor",option+1) == 0)
3032 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3033 &draw_info->undercolor,exception);
3036 if (LocaleCompare("unique",option+1) == 0)
3040 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3043 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3044 (void) SetImageArtifact(*image,"verbose","true");
3047 if (LocaleCompare("unique-colors",option+1) == 0)
3050 Unique image colors.
3052 (void) SyncImageSettings(mogrify_info,*image,exception);
3053 mogrify_image=UniqueImageColors(*image,exception);
3056 if (LocaleCompare("unsharp",option+1) == 0)
3061 (void) SyncImageSettings(mogrify_info,*image,exception);
3062 flags=ParseGeometry(argv[i+1],&geometry_info);
3063 if ((flags & SigmaValue) == 0)
3064 geometry_info.sigma=1.0;
3065 if ((flags & XiValue) == 0)
3066 geometry_info.xi=1.0;
3067 if ((flags & PsiValue) == 0)
3068 geometry_info.psi=0.05;
3069 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3070 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3078 if (LocaleCompare("verbose",option+1) == 0)
3080 (void) SetImageArtifact(*image,option+1,
3081 *option == '+' ? "false" : "true");
3084 if (LocaleCompare("vignette",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=0.1*(*image)->columns;
3095 if ((flags & PsiValue) == 0)
3096 geometry_info.psi=0.1*(*image)->rows;
3097 mogrify_image=VignetteImage(*image,geometry_info.rho,
3098 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3099 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3102 if (LocaleCompare("virtual-pixel",option+1) == 0)
3106 (void) SetImageVirtualPixelMethod(*image,
3107 UndefinedVirtualPixelMethod,exception);
3110 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3111 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3112 argv[i+1]),exception);
3119 if (LocaleCompare("wave",option+1) == 0)
3124 (void) SyncImageSettings(mogrify_info,*image,exception);
3125 flags=ParseGeometry(argv[i+1],&geometry_info);
3126 if ((flags & SigmaValue) == 0)
3127 geometry_info.sigma=1.0;
3128 mogrify_image=WaveImage(*image,geometry_info.rho,
3129 geometry_info.sigma,interpolate_method,exception);
3132 if (LocaleCompare("weight",option+1) == 0)
3134 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3135 if (LocaleCompare(argv[i+1],"all") == 0)
3136 draw_info->weight=0;
3137 if (LocaleCompare(argv[i+1],"bold") == 0)
3138 draw_info->weight=700;
3139 if (LocaleCompare(argv[i+1],"bolder") == 0)
3140 if (draw_info->weight <= 800)
3141 draw_info->weight+=100;
3142 if (LocaleCompare(argv[i+1],"lighter") == 0)
3143 if (draw_info->weight >= 100)
3144 draw_info->weight-=100;
3145 if (LocaleCompare(argv[i+1],"normal") == 0)
3146 draw_info->weight=400;
3149 if (LocaleCompare("white-threshold",option+1) == 0)
3152 White threshold image.
3154 (void) SyncImageSettings(mogrify_info,*image,exception);
3155 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3164 Replace current image with any image that was generated
3166 if (mogrify_image != (Image *) NULL)
3167 ReplaceImageInListReturnLast(image,mogrify_image);
3170 if (region_image != (Image *) NULL)
3173 Composite transformed region onto image.
3175 (void) SyncImageSettings(mogrify_info,*image,exception);
3176 (void) CompositeImage(region_image,*image,
3177 region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp :
3178 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3180 *image=DestroyImage(*image);
3181 *image=region_image;
3182 region_image = (Image *) NULL;
3187 quantize_info=DestroyQuantizeInfo(quantize_info);
3188 draw_info=DestroyDrawInfo(draw_info);
3189 mogrify_info=DestroyImageInfo(mogrify_info);
3190 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3191 return(status == 0 ? MagickFalse : MagickTrue);
3195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3199 + M o g r i f y I m a g e C o m m a n d %
3203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3205 % MogrifyImageCommand() transforms an image or a sequence of images. These
3206 % transforms include image scaling, image rotation, color reduction, and
3207 % others. The transmogrified image overwrites the original image.
3209 % The format of the MogrifyImageCommand method is:
3211 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3212 % const char **argv,char **metadata,ExceptionInfo *exception)
3214 % A description of each parameter follows:
3216 % o image_info: the image info.
3218 % o argc: the number of elements in the argument vector.
3220 % o argv: A text array containing the command line arguments.
3222 % o metadata: any metadata is returned here.
3224 % o exception: return any errors or warnings in this structure.
3228 static MagickBooleanType MogrifyUsage(void)
3231 *channel_operators[]=
3233 "-channel-fx expression",
3234 " exchange, extract, or transfer one or more image channels",
3235 "-separate separate an image channel into a grayscale image",
3240 "-debug events display copious debugging information",
3241 "-distribute-cache port",
3242 " distributed pixel cache spanning one or more servers",
3243 "-help print program options",
3244 "-list type print a list of supported option arguments",
3245 "-log format format of debugging information",
3246 "-version print version information",
3251 "-adaptive-blur geometry",
3252 " adaptively blur pixels; decrease effect near edges",
3253 "-adaptive-resize geometry",
3254 " adaptively resize image using 'mesh' interpolation",
3255 "-adaptive-sharpen geometry",
3256 " adaptively sharpen pixels; increase effect near edges",
3257 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3258 " transparent, extract, background, or shape",
3259 "-annotate geometry text",
3260 " annotate the image with text",
3261 "-auto-gamma automagically adjust gamma level of image",
3262 "-auto-level automagically adjust color levels of image",
3263 "-auto-orient automagically orient (rotate) image",
3264 "-bench iterations measure performance",
3265 "-black-threshold value",
3266 " force all pixels below the threshold into black",
3267 "-blue-shift simulate a scene at nighttime in the moonlight",
3268 "-blur geometry reduce image noise and reduce detail levels",
3269 "-border geometry surround image with a border of color",
3270 "-bordercolor color border color",
3271 "-brightness-contrast geometry",
3272 " improve brightness / contrast of the image",
3273 "-cdl filename color correct with a color decision list",
3274 "-charcoal geometry simulate a charcoal drawing",
3275 "-chop geometry remove pixels from the image interior",
3276 "-clamp keep pixel values in range (0-QuantumRange)",
3277 "-clip clip along the first path from the 8BIM profile",
3278 "-clip-mask filename associate a clip mask with the image",
3279 "-clip-path id clip along a named path from the 8BIM profile",
3280 "-colorize value colorize the image with the fill color",
3281 "-color-matrix matrix apply color correction to the image",
3282 "-contrast enhance or reduce the image contrast",
3283 "-contrast-stretch geometry",
3284 " improve contrast by 'stretching' the intensity range",
3285 "-convolve coefficients",
3286 " apply a convolution kernel to the image",
3287 "-cycle amount cycle the image colormap",
3288 "-decipher filename convert cipher pixels to plain pixels",
3289 "-deskew threshold straighten an image",
3290 "-despeckle reduce the speckles within an image",
3291 "-distort method args",
3292 " distort images according to given method ad args",
3293 "-draw string annotate the image with a graphic primitive",
3294 "-edge radius apply a filter to detect edges in the image",
3295 "-encipher filename convert plain pixels to cipher pixels",
3296 "-emboss radius emboss an image",
3297 "-enhance apply a digital filter to enhance a noisy image",
3298 "-equalize perform histogram equalization to an image",
3299 "-evaluate operator value",
3300 " evaluate an arithmetic, relational, or logical expression",
3301 "-extent geometry set the image size",
3302 "-extract geometry extract area from image",
3303 "-fft implements the discrete Fourier transform (DFT)",
3304 "-flip flip image vertically",
3305 "-floodfill geometry color",
3306 " floodfill the image with color",
3307 "-flop flop image horizontally",
3308 "-frame geometry surround image with an ornamental border",
3309 "-function name parameters",
3310 " apply function over image values",
3311 "-gamma value level of gamma correction",
3312 "-gaussian-blur geometry",
3313 " reduce image noise and reduce detail levels",
3314 "-geometry geometry preferred size or location of the image",
3315 "-grayscale method convert image to grayscale",
3316 "-identify identify the format and characteristics of the image",
3317 "-ift implements the inverse discrete Fourier transform (DFT)",
3318 "-implode amount implode image pixels about the center",
3319 "-interpolative-resize geometry",
3320 " resize image using interpolation",
3321 "-lat geometry local adaptive thresholding",
3322 "-level value adjust the level of image contrast",
3323 "-level-colors color,color",
3324 " level image with the given colors",
3325 "-linear-stretch geometry",
3326 " improve contrast by 'stretching with saturation'",
3327 "-liquid-rescale geometry",
3328 " rescale image with seam-carving",
3329 "-magnify double the size of the image with pixel art scaling",
3330 "-median geometry apply a median filter to the image",
3331 "-mode geometry make each pixel the 'predominant color' of the",
3333 "-modulate value vary the brightness, saturation, and hue",
3334 "-monochrome transform image to black and white",
3335 "-morphology method kernel",
3336 " apply a morphology method to the image",
3337 "-motion-blur geometry",
3338 " simulate motion blur",
3339 "-negate replace every pixel with its complementary color ",
3340 "-noise geometry add or reduce noise in an image",
3341 "-normalize transform image to span the full range of colors",
3342 "-opaque color change this color to the fill color",
3343 "-ordered-dither NxN",
3344 " add a noise pattern to the image with specific",
3346 "-paint radius simulate an oil painting",
3347 "-perceptible epsilon",
3348 " pixel value less than |epsilon| become epsilon or",
3350 "-polaroid angle simulate a Polaroid picture",
3351 "-posterize levels reduce the image to a limited number of color levels",
3352 "-profile filename add, delete, or apply an image profile",
3353 "-quantize colorspace reduce colors in this colorspace",
3354 "-radial-blur angle radial blur the image",
3355 "-raise value lighten/darken image edges to create a 3-D effect",
3356 "-random-threshold low,high",
3357 " random threshold the image",
3358 "-region geometry apply options to a portion of the image",
3359 "-render render vector graphics",
3360 "-repage geometry size and location of an image canvas",
3361 "-resample geometry change the resolution of an image",
3362 "-resize geometry resize the image",
3363 "-roll geometry roll an image vertically or horizontally",
3364 "-rotate degrees apply Paeth rotation to the image",
3365 "-sample geometry scale image with pixel sampling",
3366 "-scale geometry scale the image",
3367 "-segment values segment an image",
3368 "-selective-blur geometry",
3369 " selectively blur pixels within a contrast threshold",
3370 "-sepia-tone threshold",
3371 " simulate a sepia-toned photo",
3372 "-set property value set an image property",
3373 "-shade degrees shade the image using a distant light source",
3374 "-shadow geometry simulate an image shadow",
3375 "-sharpen geometry sharpen the image",
3376 "-shave geometry shave pixels from the image edges",
3377 "-shear geometry slide one edge of the image along the X or Y axis",
3378 "-sigmoidal-contrast geometry",
3379 " increase the contrast without saturating highlights or",
3381 "-sketch geometry simulate a pencil sketch",
3382 "-solarize threshold negate all pixels above the threshold level",
3383 "-sparse-color method args",
3384 " fill in a image based on a few color points",
3385 "-splice geometry splice the background color into the image",
3386 "-spread radius displace image pixels by a random amount",
3387 "-statistic type radius",
3388 " replace each pixel with corresponding statistic from the neighborhood",
3389 "-strip strip image of all profiles and comments",
3390 "-swirl degrees swirl image pixels about the center",
3391 "-threshold value threshold the image",
3392 "-thumbnail geometry create a thumbnail of the image",
3393 "-tile filename tile image when filling a graphic primitive",
3394 "-tint value tint the image with the fill color",
3395 "-transform affine transform image",
3396 "-transparent color make this color transparent within the image",
3397 "-transpose flip image vertically and rotate 90 degrees",
3398 "-transverse flop image horizontally and rotate 270 degrees",
3399 "-trim trim image edges",
3400 "-type type image type",
3401 "-unique-colors discard all but one of any pixel color",
3402 "-unsharp geometry sharpen the image",
3403 "-vignette geometry soften the edges of the image in vignette style",
3404 "-wave geometry alter an image along a sine wave",
3405 "-white-threshold value",
3406 " force all pixels above the threshold into white",
3409 *sequence_operators[]=
3411 "-affinity filename transform image colors to match this set of colors",
3412 "-append append an image sequence",
3413 "-clut apply a color lookup table to the image",
3414 "-coalesce merge a sequence of images",
3415 "-combine combine a sequence of images",
3416 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3417 "-complex operator perform complex mathematics on an image sequence",
3418 "-composite composite image",
3419 "-crop geometry cut out a rectangular region of the image",
3420 "-deconstruct break down an image sequence into constituent parts",
3421 "-evaluate-sequence operator",
3422 " evaluate an arithmetic, relational, or logical expression",
3423 "-flatten flatten a sequence of images",
3424 "-fx expression apply mathematical expression to an image channel(s)",
3425 "-hald-clut apply a Hald color lookup table to the image",
3426 "-layers method optimize, merge, or compare image layers",
3427 "-morph value morph an image sequence",
3428 "-mosaic create a mosaic from an image sequence",
3429 "-poly terms build a polynomial from the image sequence and the corresponding",
3430 " terms (coefficients and degree pairs).",
3431 "-print string interpret string and print to console",
3432 "-process arguments process the image with a custom image filter",
3433 "-smush geometry smush an image sequence together",
3434 "-write filename write images to this file",
3439 "-adjoin join images into a single multi-image file",
3440 "-affine matrix affine transform matrix",
3441 "-alpha option activate, deactivate, reset, or set the alpha channel",
3442 "-antialias remove pixel-aliasing",
3443 "-authenticate password",
3444 " decipher image with this password",
3445 "-attenuate value lessen (or intensify) when adding noise to an image",
3446 "-background color background color",
3447 "-bias value add bias when convolving an image",
3448 "-black-point-compensation",
3449 " use black point compensation",
3450 "-blue-primary point chromaticity blue primary point",
3451 "-bordercolor color border color",
3452 "-caption string assign a caption to an image",
3453 "-channel type apply option to select image channels",
3454 "-colors value preferred number of colors in the image",
3455 "-colorspace type alternate image colorspace",
3456 "-comment string annotate image with comment",
3457 "-compose operator set image composite operator",
3458 "-compress type type of pixel compression when writing the image",
3459 "-define format:option=value",
3460 " define one or more image format options",
3461 "-delay value display the next image after pausing",
3462 "-density geometry horizontal and vertical density of the image",
3463 "-depth value image depth",
3464 "-direction type render text right-to-left or left-to-right",
3465 "-display server get image or font from this X server",
3466 "-dispose method layer disposal method",
3467 "-dither method apply error diffusion to image",
3468 "-encoding type text encoding type",
3469 "-endian type endianness (MSB or LSB) of the image",
3470 "-family name render text with this font family",
3471 "-features distance analyze image features (e.g. contrast, correlation)",
3472 "-fill color color to use when filling a graphic primitive",
3473 "-filter type use this filter when resizing an image",
3474 "-font name render text with this font",
3475 "-format \"string\" output formatted image characteristics",
3476 "-fuzz distance colors within this distance are considered equal",
3477 "-gravity type horizontal and vertical text placement",
3478 "-green-primary point chromaticity green primary point",
3479 "-intensity method method to generate an intensity value from a pixel",
3480 "-intent type type of rendering intent when managing the image color",
3481 "-interlace type type of image interlacing scheme",
3482 "-interline-spacing value",
3483 " set the space between two text lines",
3484 "-interpolate method pixel color interpolation method",
3485 "-interword-spacing value",
3486 " set the space between two words",
3487 "-kerning value set the space between two letters",
3488 "-label string assign a label to an image",
3489 "-limit type value pixel cache resource limit",
3490 "-loop iterations add Netscape loop extension to your GIF animation",
3491 "-mask filename associate a mask with the image",
3492 "-matte store matte channel if the image has one",
3493 "-mattecolor color frame color",
3494 "-monitor monitor progress",
3495 "-orient type image orientation",
3496 "-page geometry size and location of an image canvas (setting)",
3497 "-path path write images to this path on disk",
3498 "-ping efficiently determine image attributes",
3499 "-pointsize value font point size",
3500 "-precision value maximum number of significant digits to print",
3501 "-preview type image preview type",
3502 "-quality value JPEG/MIFF/PNG compression level",
3503 "-quiet suppress all warning messages",
3504 "-red-primary point chromaticity red primary point",
3505 "-regard-warnings pay attention to warning messages",
3506 "-remap filename transform image colors to match this set of colors",
3507 "-respect-parentheses settings remain in effect until parenthesis boundary",
3508 "-sampling-factor geometry",
3509 " horizontal and vertical sampling factor",
3510 "-scene value image scene number",
3511 "-seed value seed a new sequence of pseudo-random numbers",
3512 "-size geometry width and height of image",
3513 "-stretch type render text with this font stretch",
3514 "-stroke color graphic primitive stroke color",
3515 "-strokewidth value graphic primitive stroke width",
3516 "-style type render text with this font style",
3517 "-synchronize synchronize image to storage device",
3518 "-taint declare the image as modified",
3519 "-texture filename name of texture to tile onto the image background",
3520 "-tile-offset geometry",
3522 "-treedepth value color tree depth",
3523 "-transparent-color color",
3524 " transparent color",
3525 "-undercolor color annotation bounding box color",
3526 "-units type the units of image resolution",
3527 "-verbose print detailed information about the image",
3528 "-view FlashPix viewing transforms",
3529 "-virtual-pixel method",
3530 " virtual pixel access method",
3531 "-weight type render text with this font weight",
3532 "-white-point point chromaticity white point",
3537 "-delete indexes delete the image from the image sequence",
3538 "-duplicate count,indexes",
3539 " duplicate an image one or more times",
3540 "-insert index insert last image into the image sequence",
3541 "-reverse reverse image sequence",
3542 "-swap indexes swap two images in the image sequence",
3549 ListMagickVersion(stdout);
3550 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3552 (void) printf("\nImage Settings:\n");
3553 for (p=settings; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nImage Operators:\n");
3556 for (p=operators; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3558 (void) printf("\nImage Channel Operators:\n");
3559 for (p=channel_operators; *p != (char *) NULL; p++)
3560 (void) printf(" %s\n",*p);
3561 (void) printf("\nImage Sequence Operators:\n");
3562 for (p=sequence_operators; *p != (char *) NULL; p++)
3563 (void) printf(" %s\n",*p);
3564 (void) printf("\nImage Stack Operators:\n");
3565 for (p=stack_operators; *p != (char *) NULL; p++)
3566 (void) printf(" %s\n",*p);
3567 (void) printf("\nMiscellaneous Options:\n");
3568 for (p=miscellaneous; *p != (char *) NULL; p++)
3569 (void) printf(" %s\n",*p);
3571 "\nBy default, the image format of 'file' is determined by its magic\n");
3573 "number. To specify a particular image format, precede the filename\n");
3575 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3577 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3578 (void) printf("'-' for standard input or output.\n");
3579 return(MagickFalse);
3582 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3583 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3585 #define DestroyMogrify() \
3587 if (format != (char *) NULL) \
3588 format=DestroyString(format); \
3589 if (path != (char *) NULL) \
3590 path=DestroyString(path); \
3591 DestroyImageStack(); \
3592 for (i=0; i < (ssize_t) argc; i++) \
3593 argv[i]=DestroyString(argv[i]); \
3594 argv=(char **) RelinquishMagickMemory(argv); \
3596 #define ThrowMogrifyException(asperity,tag,option) \
3598 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3601 return(MagickFalse); \
3603 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3605 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3606 "InvalidArgument","'%s': %s",argument,option); \
3608 return(MagickFalse); \
3620 image_stack[MaxImageStackDepth+1];
3628 respect_parenthesis;
3643 assert(image_info != (ImageInfo *) NULL);
3644 assert(image_info->signature == MagickSignature);
3645 if (image_info->debug != MagickFalse)
3646 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3647 assert(exception != (ExceptionInfo *) NULL);
3651 if ((LocaleCompare("version",option+1) == 0) ||
3652 (LocaleCompare("-version",option+1) == 0))
3654 ListMagickVersion(stdout);
3655 return(MagickFalse);
3659 return(MogrifyUsage());
3660 format=(char *) NULL;
3662 global_colormap=MagickFalse;
3666 option=(char *) NULL;
3668 respect_parenthesis=MagickFalse;
3673 ReadCommandlLine(argc,&argv);
3674 status=ExpandFilenames(&argc,&argv);
3675 if (status == MagickFalse)
3676 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3677 GetExceptionMessage(errno));
3678 for (i=1; i < (ssize_t) argc; i++)
3681 if (LocaleCompare(option,"(") == 0)
3683 FireImageStack(MagickFalse,MagickTrue,pend);
3684 if (k == MaxImageStackDepth)
3685 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3690 if (LocaleCompare(option,")") == 0)
3692 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3694 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3698 if (IsCommandOption(option) == MagickFalse)
3701 backup_filename[MaxTextExtent],
3708 Option is a file name: begin by reading image from specified file.
3710 FireImageStack(MagickFalse,MagickFalse,pend);
3712 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3714 images=ReadImages(image_info,filename,exception);
3715 status&=(images != (Image *) NULL) &&
3716 (exception->severity < ErrorException);
3717 if (images == (Image *) NULL)
3719 if (format != (char *) NULL)
3720 (void) CopyMagickString(images->filename,images->magick_filename,
3722 if (path != (char *) NULL)
3724 GetPathComponent(option,TailPath,filename);
3725 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3726 path,*DirectorySeparator,filename);
3728 if (format != (char *) NULL)
3729 AppendImageFormat(format,images->filename);
3730 AppendImageStack(images);
3731 FinalizeImageSettings(image_info,image,MagickFalse);
3732 if (global_colormap != MagickFalse)
3737 quantize_info=AcquireQuantizeInfo(image_info);
3738 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3739 quantize_info=DestroyQuantizeInfo(quantize_info);
3741 *backup_filename='\0';
3742 if ((LocaleCompare(image->filename,"-") != 0) &&
3743 (IsPathWritable(image->filename) != MagickFalse))
3749 Rename image file as backup.
3751 (void) CopyMagickString(backup_filename,image->filename,
3753 for (i=0; i < 6; i++)
3755 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3756 if (IsPathAccessible(backup_filename) == MagickFalse)
3759 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3760 (rename_utf8(image->filename,backup_filename) != 0))
3761 *backup_filename='\0';
3764 Write transmogrified image to disk.
3766 image_info->synchronize=MagickTrue;
3767 status&=WriteImages(image_info,image,image->filename,exception);
3768 if ((status == MagickFalse) && (*backup_filename != '\0'))
3769 (void) remove_utf8(backup_filename);
3770 RemoveAllImageStack();
3773 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3774 switch (*(option+1))
3778 if (LocaleCompare("adaptive-blur",option+1) == 0)
3781 if (i == (ssize_t) argc)
3782 ThrowMogrifyException(OptionError,"MissingArgument",option);
3783 if (IsGeometry(argv[i]) == MagickFalse)
3784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3787 if (LocaleCompare("adaptive-resize",option+1) == 0)
3790 if (i == (ssize_t) argc)
3791 ThrowMogrifyException(OptionError,"MissingArgument",option);
3792 if (IsGeometry(argv[i]) == MagickFalse)
3793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3796 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3799 if (i == (ssize_t) argc)
3800 ThrowMogrifyException(OptionError,"MissingArgument",option);
3801 if (IsGeometry(argv[i]) == MagickFalse)
3802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3805 if (LocaleCompare("affine",option+1) == 0)
3810 if (i == (ssize_t) argc)
3811 ThrowMogrifyException(OptionError,"MissingArgument",option);
3814 if (LocaleCompare("alpha",option+1) == 0)
3822 if (i == (ssize_t) argc)
3823 ThrowMogrifyException(OptionError,"MissingArgument",option);
3824 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
3826 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
3830 if (LocaleCompare("annotate",option+1) == 0)
3835 if (i == (ssize_t) argc)
3836 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (IsGeometry(argv[i]) == MagickFalse)
3838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3839 if (i == (ssize_t) argc)
3840 ThrowMogrifyException(OptionError,"MissingArgument",option);
3844 if (LocaleCompare("antialias",option+1) == 0)
3846 if (LocaleCompare("append",option+1) == 0)
3848 if (LocaleCompare("attenuate",option+1) == 0)
3853 if (i == (ssize_t) (argc-1))
3854 ThrowMogrifyException(OptionError,"MissingArgument",option);
3855 if (IsGeometry(argv[i]) == MagickFalse)
3856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3859 if (LocaleCompare("authenticate",option+1) == 0)
3864 if (i == (ssize_t) argc)
3865 ThrowMogrifyException(OptionError,"MissingArgument",option);
3868 if (LocaleCompare("auto-gamma",option+1) == 0)
3870 if (LocaleCompare("auto-level",option+1) == 0)
3872 if (LocaleCompare("auto-orient",option+1) == 0)
3874 if (LocaleCompare("average",option+1) == 0)
3876 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3880 if (LocaleCompare("background",option+1) == 0)
3885 if (i == (ssize_t) argc)
3886 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 if (LocaleCompare("bias",option+1) == 0)
3894 if (i == (ssize_t) (argc-1))
3895 ThrowMogrifyException(OptionError,"MissingArgument",option);
3896 if (IsGeometry(argv[i]) == MagickFalse)
3897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3900 if (LocaleCompare("black-point-compensation",option+1) == 0)
3902 if (LocaleCompare("black-threshold",option+1) == 0)
3907 if (i == (ssize_t) argc)
3908 ThrowMogrifyException(OptionError,"MissingArgument",option);
3909 if (IsGeometry(argv[i]) == MagickFalse)
3910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3913 if (LocaleCompare("blue-primary",option+1) == 0)
3918 if (i == (ssize_t) argc)
3919 ThrowMogrifyException(OptionError,"MissingArgument",option);
3920 if (IsGeometry(argv[i]) == MagickFalse)
3921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3924 if (LocaleCompare("blue-shift",option+1) == 0)
3927 if (i == (ssize_t) argc)
3928 ThrowMogrifyException(OptionError,"MissingArgument",option);
3929 if (IsGeometry(argv[i]) == MagickFalse)
3930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3933 if (LocaleCompare("blur",option+1) == 0)
3936 if (i == (ssize_t) argc)
3937 ThrowMogrifyException(OptionError,"MissingArgument",option);
3938 if (IsGeometry(argv[i]) == MagickFalse)
3939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3942 if (LocaleCompare("border",option+1) == 0)
3947 if (i == (ssize_t) argc)
3948 ThrowMogrifyException(OptionError,"MissingArgument",option);
3949 if (IsGeometry(argv[i]) == MagickFalse)
3950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 if (LocaleCompare("bordercolor",option+1) == 0)
3958 if (i == (ssize_t) argc)
3959 ThrowMogrifyException(OptionError,"MissingArgument",option);
3962 if (LocaleCompare("box",option+1) == 0)
3967 if (i == (ssize_t) argc)
3968 ThrowMogrifyException(OptionError,"MissingArgument",option);
3971 if (LocaleCompare("brightness-contrast",option+1) == 0)
3974 if (i == (ssize_t) argc)
3975 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (IsGeometry(argv[i]) == MagickFalse)
3977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3980 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3984 if (LocaleCompare("cache",option+1) == 0)
3989 if (i == (ssize_t) argc)
3990 ThrowMogrifyException(OptionError,"MissingArgument",option);
3991 if (IsGeometry(argv[i]) == MagickFalse)
3992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3995 if (LocaleCompare("caption",option+1) == 0)
4000 if (i == (ssize_t) argc)
4001 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 if (LocaleCompare("channel",option+1) == 0)
4012 if (i == (ssize_t) (argc-1))
4013 ThrowMogrifyException(OptionError,"MissingArgument",option);
4014 channel=ParseChannelOption(argv[i]);
4016 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4020 if (LocaleCompare("channel-fx",option+1) == 0)
4028 if (i == (ssize_t) (argc-1))
4029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 channel=ParsePixelChannelOption(argv[i]);
4032 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4036 if (LocaleCompare("cdl",option+1) == 0)
4041 if (i == (ssize_t) (argc-1))
4042 ThrowMogrifyException(OptionError,"MissingArgument",option);
4045 if (LocaleCompare("charcoal",option+1) == 0)
4050 if (i == (ssize_t) argc)
4051 ThrowMogrifyException(OptionError,"MissingArgument",option);
4052 if (IsGeometry(argv[i]) == MagickFalse)
4053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4056 if (LocaleCompare("chop",option+1) == 0)
4061 if (i == (ssize_t) argc)
4062 ThrowMogrifyException(OptionError,"MissingArgument",option);
4063 if (IsGeometry(argv[i]) == MagickFalse)
4064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4067 if (LocaleCompare("clamp",option+1) == 0)
4069 if (LocaleCompare("clip",option+1) == 0)
4071 if (LocaleCompare("clip-mask",option+1) == 0)
4076 if (i == (ssize_t) argc)
4077 ThrowMogrifyException(OptionError,"MissingArgument",option);
4080 if (LocaleCompare("clut",option+1) == 0)
4082 if (LocaleCompare("coalesce",option+1) == 0)
4084 if (LocaleCompare("colorize",option+1) == 0)
4089 if (i == (ssize_t) argc)
4090 ThrowMogrifyException(OptionError,"MissingArgument",option);
4091 if (IsGeometry(argv[i]) == MagickFalse)
4092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4095 if (LocaleCompare("color-matrix",option+1) == 0)
4103 if (i == (ssize_t) (argc-1))
4104 ThrowMogrifyException(OptionError,"MissingArgument",option);
4105 kernel_info=AcquireKernelInfo(argv[i]);
4106 if (kernel_info == (KernelInfo *) NULL)
4107 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4108 kernel_info=DestroyKernelInfo(kernel_info);
4111 if (LocaleCompare("colors",option+1) == 0)
4116 if (i == (ssize_t) argc)
4117 ThrowMogrifyException(OptionError,"MissingArgument",option);
4118 if (IsGeometry(argv[i]) == MagickFalse)
4119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4122 if (LocaleCompare("colorspace",option+1) == 0)
4130 if (i == (ssize_t) argc)
4131 ThrowMogrifyException(OptionError,"MissingArgument",option);
4132 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4135 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4139 if (LocaleCompare("combine",option+1) == 0)
4147 if (i == (ssize_t) argc)
4148 ThrowMogrifyException(OptionError,"MissingArgument",option);
4149 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4152 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4156 if (LocaleCompare("compare",option+1) == 0)
4158 if (LocaleCompare("comment",option+1) == 0)
4163 if (i == (ssize_t) argc)
4164 ThrowMogrifyException(OptionError,"MissingArgument",option);
4167 if (LocaleCompare("composite",option+1) == 0)
4169 if (LocaleCompare("compress",option+1) == 0)
4177 if (i == (ssize_t) argc)
4178 ThrowMogrifyException(OptionError,"MissingArgument",option);
4179 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4182 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4186 if (LocaleCompare("concurrent",option+1) == 0)
4188 if (LocaleCompare("contrast",option+1) == 0)
4190 if (LocaleCompare("contrast-stretch",option+1) == 0)
4193 if (i == (ssize_t) argc)
4194 ThrowMogrifyException(OptionError,"MissingArgument",option);
4195 if (IsGeometry(argv[i]) == MagickFalse)
4196 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4199 if (LocaleCompare("convolve",option+1) == 0)
4207 if (i == (ssize_t) argc)
4208 ThrowMogrifyException(OptionError,"MissingArgument",option);
4209 kernel_info=AcquireKernelInfo(argv[i]);
4210 if (kernel_info == (KernelInfo *) NULL)
4211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4212 kernel_info=DestroyKernelInfo(kernel_info);
4215 if (LocaleCompare("crop",option+1) == 0)
4220 if (i == (ssize_t) argc)
4221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4222 if (IsGeometry(argv[i]) == MagickFalse)
4223 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4226 if (LocaleCompare("cycle",option+1) == 0)
4231 if (i == (ssize_t) argc)
4232 ThrowMogrifyException(OptionError,"MissingArgument",option);
4233 if (IsGeometry(argv[i]) == MagickFalse)
4234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4237 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4241 if (LocaleCompare("decipher",option+1) == 0)
4246 if (i == (ssize_t) (argc-1))
4247 ThrowMogrifyException(OptionError,"MissingArgument",option);
4250 if (LocaleCompare("deconstruct",option+1) == 0)
4252 if (LocaleCompare("debug",option+1) == 0)
4260 if (i == (ssize_t) argc)
4261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4262 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4264 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4266 (void) SetLogEventMask(argv[i]);
4269 if (LocaleCompare("define",option+1) == 0)
4272 if (i == (ssize_t) argc)
4273 ThrowMogrifyException(OptionError,"MissingArgument",option);
4279 define=GetImageOption(image_info,argv[i]);
4280 if (define == (const char *) NULL)
4281 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4286 if (LocaleCompare("delay",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,"MissingArgument",option);
4293 if (IsGeometry(argv[i]) == MagickFalse)
4294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297 if (LocaleCompare("delete",option+1) == 0)
4302 if (i == (ssize_t) (argc-1))
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 if (IsGeometry(argv[i]) == MagickFalse)
4305 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308 if (LocaleCompare("density",option+1) == 0)
4313 if (i == (ssize_t) argc)
4314 ThrowMogrifyException(OptionError,"MissingArgument",option);
4315 if (IsGeometry(argv[i]) == MagickFalse)
4316 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4319 if (LocaleCompare("depth",option+1) == 0)
4324 if (i == (ssize_t) argc)
4325 ThrowMogrifyException(OptionError,"MissingArgument",option);
4326 if (IsGeometry(argv[i]) == MagickFalse)
4327 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4330 if (LocaleCompare("deskew",option+1) == 0)
4335 if (i == (ssize_t) argc)
4336 ThrowMogrifyException(OptionError,"MissingArgument",option);
4337 if (IsGeometry(argv[i]) == MagickFalse)
4338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4341 if (LocaleCompare("despeckle",option+1) == 0)
4343 if (LocaleCompare("dft",option+1) == 0)
4345 if (LocaleCompare("direction",option+1) == 0)
4353 if (i == (ssize_t) argc)
4354 ThrowMogrifyException(OptionError,"MissingArgument",option);
4355 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4358 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4362 if (LocaleCompare("display",option+1) == 0)
4367 if (i == (ssize_t) argc)
4368 ThrowMogrifyException(OptionError,"MissingArgument",option);
4371 if (LocaleCompare("dispose",option+1) == 0)
4379 if (i == (ssize_t) argc)
4380 ThrowMogrifyException(OptionError,"MissingArgument",option);
4381 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4383 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4387 if (LocaleCompare("distort",option+1) == 0)
4393 if (i == (ssize_t) argc)
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4395 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4397 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4400 if (i == (ssize_t) (argc-1))
4401 ThrowMogrifyException(OptionError,"MissingArgument",option);
4404 if (LocaleCompare("dither",option+1) == 0)
4412 if (i == (ssize_t) argc)
4413 ThrowMogrifyException(OptionError,"MissingArgument",option);
4414 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4416 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4420 if (LocaleCompare("draw",option+1) == 0)
4425 if (i == (ssize_t) argc)
4426 ThrowMogrifyException(OptionError,"MissingArgument",option);
4429 if (LocaleCompare("duplicate",option+1) == 0)
4434 if (i == (ssize_t) (argc-1))
4435 ThrowMogrifyException(OptionError,"MissingArgument",option);
4436 if (IsGeometry(argv[i]) == MagickFalse)
4437 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4440 if (LocaleCompare("duration",option+1) == 0)
4445 if (i == (ssize_t) (argc-1))
4446 ThrowMogrifyException(OptionError,"MissingArgument",option);
4447 if (IsGeometry(argv[i]) == MagickFalse)
4448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4451 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4455 if (LocaleCompare("edge",option+1) == 0)
4460 if (i == (ssize_t) argc)
4461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 if (IsGeometry(argv[i]) == MagickFalse)
4463 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4466 if (LocaleCompare("emboss",option+1) == 0)
4471 if (i == (ssize_t) argc)
4472 ThrowMogrifyException(OptionError,"MissingArgument",option);
4473 if (IsGeometry(argv[i]) == MagickFalse)
4474 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4477 if (LocaleCompare("encipher",option+1) == 0)
4482 if (i == (ssize_t) argc)
4483 ThrowMogrifyException(OptionError,"MissingArgument",option);
4486 if (LocaleCompare("encoding",option+1) == 0)
4491 if (i == (ssize_t) argc)
4492 ThrowMogrifyException(OptionError,"MissingArgument",option);
4495 if (LocaleCompare("endian",option+1) == 0)
4503 if (i == (ssize_t) argc)
4504 ThrowMogrifyException(OptionError,"MissingArgument",option);
4505 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4507 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4511 if (LocaleCompare("enhance",option+1) == 0)
4513 if (LocaleCompare("equalize",option+1) == 0)
4515 if (LocaleCompare("evaluate",option+1) == 0)
4523 if (i == (ssize_t) argc)
4524 ThrowMogrifyException(OptionError,"MissingArgument",option);
4525 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4527 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4530 if (i == (ssize_t) (argc-1))
4531 ThrowMogrifyException(OptionError,"MissingArgument",option);
4532 if (IsGeometry(argv[i]) == MagickFalse)
4533 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4536 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4544 if (i == (ssize_t) argc)
4545 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4548 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4552 if (LocaleCompare("extent",option+1) == 0)
4557 if (i == (ssize_t) argc)
4558 ThrowMogrifyException(OptionError,"MissingArgument",option);
4559 if (IsGeometry(argv[i]) == MagickFalse)
4560 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4563 if (LocaleCompare("extract",option+1) == 0)
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4570 if (IsGeometry(argv[i]) == MagickFalse)
4571 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4574 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4578 if (LocaleCompare("family",option+1) == 0)
4583 if (i == (ssize_t) (argc-1))
4584 ThrowMogrifyException(OptionError,"MissingArgument",option);
4587 if (LocaleCompare("features",option+1) == 0)
4592 if (i == (ssize_t) (argc-1))
4593 ThrowMogrifyException(OptionError,"MissingArgument",option);
4594 if (IsGeometry(argv[i]) == MagickFalse)
4595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4598 if (LocaleCompare("fill",option+1) == 0)
4603 if (i == (ssize_t) argc)
4604 ThrowMogrifyException(OptionError,"MissingArgument",option);
4607 if (LocaleCompare("filter",option+1) == 0)
4615 if (i == (ssize_t) argc)
4616 ThrowMogrifyException(OptionError,"MissingArgument",option);
4617 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4619 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4623 if (LocaleCompare("flatten",option+1) == 0)
4625 if (LocaleCompare("flip",option+1) == 0)
4627 if (LocaleCompare("flop",option+1) == 0)
4629 if (LocaleCompare("floodfill",option+1) == 0)
4634 if (i == (ssize_t) argc)
4635 ThrowMogrifyException(OptionError,"MissingArgument",option);
4636 if (IsGeometry(argv[i]) == MagickFalse)
4637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4639 if (i == (ssize_t) argc)
4640 ThrowMogrifyException(OptionError,"MissingArgument",option);
4643 if (LocaleCompare("font",option+1) == 0)
4648 if (i == (ssize_t) argc)
4649 ThrowMogrifyException(OptionError,"MissingArgument",option);
4652 if (LocaleCompare("format",option+1) == 0)
4654 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4655 (void) CloneString(&format,(char *) NULL);
4659 if (i == (ssize_t) argc)
4660 ThrowMogrifyException(OptionError,"MissingArgument",option);
4661 (void) CloneString(&format,argv[i]);
4662 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4663 (void) ConcatenateMagickString(image_info->filename,":",
4665 (void) SetImageInfo(image_info,0,exception);
4666 if (*image_info->magick == '\0')
4667 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4671 if (LocaleCompare("frame",option+1) == 0)
4676 if (i == (ssize_t) argc)
4677 ThrowMogrifyException(OptionError,"MissingArgument",option);
4678 if (IsGeometry(argv[i]) == MagickFalse)
4679 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4682 if (LocaleCompare("function",option+1) == 0)
4690 if (i == (ssize_t) argc)
4691 ThrowMogrifyException(OptionError,"MissingArgument",option);
4692 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4694 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4696 if (i == (ssize_t) (argc-1))
4697 ThrowMogrifyException(OptionError,"MissingArgument",option);
4700 if (LocaleCompare("fuzz",option+1) == 0)
4705 if (i == (ssize_t) argc)
4706 ThrowMogrifyException(OptionError,"MissingArgument",option);
4707 if (IsGeometry(argv[i]) == MagickFalse)
4708 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4711 if (LocaleCompare("fx",option+1) == 0)
4716 if (i == (ssize_t) (argc-1))
4717 ThrowMogrifyException(OptionError,"MissingArgument",option);
4720 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4724 if (LocaleCompare("gamma",option+1) == 0)
4727 if (i == (ssize_t) argc)
4728 ThrowMogrifyException(OptionError,"MissingArgument",option);
4729 if (IsGeometry(argv[i]) == MagickFalse)
4730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4733 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4734 (LocaleCompare("gaussian",option+1) == 0))
4737 if (i == (ssize_t) argc)
4738 ThrowMogrifyException(OptionError,"MissingArgument",option);
4739 if (IsGeometry(argv[i]) == MagickFalse)
4740 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4743 if (LocaleCompare("geometry",option+1) == 0)
4748 if (i == (ssize_t) argc)
4749 ThrowMogrifyException(OptionError,"MissingArgument",option);
4750 if (IsGeometry(argv[i]) == MagickFalse)
4751 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4754 if (LocaleCompare("gravity",option+1) == 0)
4762 if (i == (ssize_t) argc)
4763 ThrowMogrifyException(OptionError,"MissingArgument",option);
4764 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
4767 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4771 if (LocaleCompare("grayscale",option+1) == 0)
4779 if (i == (ssize_t) (argc-1))
4780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4781 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4784 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
4788 if (LocaleCompare("green-primary",option+1) == 0)
4793 if (i == (ssize_t) argc)
4794 ThrowMogrifyException(OptionError,"MissingArgument",option);
4795 if (IsGeometry(argv[i]) == MagickFalse)
4796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4799 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4803 if (LocaleCompare("hald-clut",option+1) == 0)
4805 if ((LocaleCompare("help",option+1) == 0) ||
4806 (LocaleCompare("-help",option+1) == 0))
4807 return(MogrifyUsage());
4808 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4812 if (LocaleCompare("identify",option+1) == 0)
4814 if (LocaleCompare("idft",option+1) == 0)
4816 if (LocaleCompare("implode",option+1) == 0)
4821 if (i == (ssize_t) argc)
4822 ThrowMogrifyException(OptionError,"MissingArgument",option);
4823 if (IsGeometry(argv[i]) == MagickFalse)
4824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4827 if (LocaleCompare("intensity",option+1) == 0)
4835 if (i == (ssize_t) (argc-1))
4836 ThrowMogrifyException(OptionError,"MissingArgument",option);
4837 intensity=ParseCommandOption(MagickPixelIntensityOptions,
4838 MagickFalse,argv[i]);
4840 ThrowMogrifyException(OptionError,
4841 "UnrecognizedPixelIntensityMethod",argv[i]);
4844 if (LocaleCompare("intent",option+1) == 0)
4852 if (i == (ssize_t) (argc-1))
4853 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4856 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4860 if (LocaleCompare("interlace",option+1) == 0)
4868 if (i == (ssize_t) argc)
4869 ThrowMogrifyException(OptionError,"MissingArgument",option);
4870 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4873 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4877 if (LocaleCompare("interline-spacing",option+1) == 0)
4882 if (i == (ssize_t) (argc-1))
4883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 if (IsGeometry(argv[i]) == MagickFalse)
4885 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4888 if (LocaleCompare("interpolate",option+1) == 0)
4896 if (i == (ssize_t) argc)
4897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4898 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4900 if (interpolate < 0)
4901 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4905 if (LocaleCompare("interword-spacing",option+1) == 0)
4910 if (i == (ssize_t) (argc-1))
4911 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 if (IsGeometry(argv[i]) == MagickFalse)
4913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4916 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4920 if (LocaleCompare("kerning",option+1) == 0)
4925 if (i == (ssize_t) (argc-1))
4926 ThrowMogrifyException(OptionError,"MissingArgument",option);
4927 if (IsGeometry(argv[i]) == MagickFalse)
4928 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4931 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4935 if (LocaleCompare("label",option+1) == 0)
4940 if (i == (ssize_t) argc)
4941 ThrowMogrifyException(OptionError,"MissingArgument",option);
4944 if (LocaleCompare("lat",option+1) == 0)
4949 if (i == (ssize_t) argc)
4950 ThrowMogrifyException(OptionError,"MissingArgument",option);
4951 if (IsGeometry(argv[i]) == MagickFalse)
4952 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4954 if (LocaleCompare("layers",option+1) == 0)
4962 if (i == (ssize_t) (argc-1))
4963 ThrowMogrifyException(OptionError,"MissingArgument",option);
4964 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4966 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4970 if (LocaleCompare("level",option+1) == 0)
4973 if (i == (ssize_t) argc)
4974 ThrowMogrifyException(OptionError,"MissingArgument",option);
4975 if (IsGeometry(argv[i]) == MagickFalse)
4976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4979 if (LocaleCompare("level-colors",option+1) == 0)
4982 if (i == (ssize_t) argc)
4983 ThrowMogrifyException(OptionError,"MissingArgument",option);
4986 if (LocaleCompare("limit",option+1) == 0)
5000 if (i == (ssize_t) argc)
5001 ThrowMogrifyException(OptionError,"MissingArgument",option);
5002 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5005 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5008 if (i == (ssize_t) argc)
5009 ThrowMogrifyException(OptionError,"MissingArgument",option);
5010 value=StringToDouble(argv[i],&p);
5012 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5016 if (LocaleCompare("liquid-rescale",option+1) == 0)
5019 if (i == (ssize_t) argc)
5020 ThrowMogrifyException(OptionError,"MissingArgument",option);
5021 if (IsGeometry(argv[i]) == MagickFalse)
5022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5025 if (LocaleCompare("list",option+1) == 0)
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,"MissingArgument",option);
5035 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5037 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5038 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5040 return(status != 0 ? MagickFalse : MagickTrue);
5042 if (LocaleCompare("log",option+1) == 0)
5047 if ((i == (ssize_t) argc) ||
5048 (strchr(argv[i],'%') == (char *) NULL))
5049 ThrowMogrifyException(OptionError,"MissingArgument",option);
5052 if (LocaleCompare("loop",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5067 if (LocaleCompare("map",option+1) == 0)
5069 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5073 if (i == (ssize_t) argc)
5074 ThrowMogrifyException(OptionError,"MissingArgument",option);
5077 if (LocaleCompare("mask",option+1) == 0)
5082 if (i == (ssize_t) argc)
5083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5086 if (LocaleCompare("matte",option+1) == 0)
5088 if (LocaleCompare("mattecolor",option+1) == 0)
5093 if (i == (ssize_t) argc)
5094 ThrowMogrifyException(OptionError,"MissingArgument",option);
5097 if (LocaleCompare("maximum",option+1) == 0)
5099 if (LocaleCompare("metric",option+1) == 0)
5107 if (i == (ssize_t) argc)
5108 ThrowMogrifyException(OptionError,"MissingArgument",option);
5109 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5111 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5115 if (LocaleCompare("minimum",option+1) == 0)
5117 if (LocaleCompare("modulate",option+1) == 0)
5122 if (i == (ssize_t) argc)
5123 ThrowMogrifyException(OptionError,"MissingArgument",option);
5124 if (IsGeometry(argv[i]) == MagickFalse)
5125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5128 if (LocaleCompare("median",option+1) == 0)
5133 if (i == (ssize_t) argc)
5134 ThrowMogrifyException(OptionError,"MissingArgument",option);
5135 if (IsGeometry(argv[i]) == MagickFalse)
5136 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5139 if (LocaleCompare("mode",option+1) == 0)
5144 if (i == (ssize_t) argc)
5145 ThrowMogrifyException(OptionError,"MissingArgument",option);
5146 if (IsGeometry(argv[i]) == MagickFalse)
5147 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5150 if (LocaleCompare("monitor",option+1) == 0)
5152 if (LocaleCompare("monochrome",option+1) == 0)
5154 if (LocaleCompare("morph",option+1) == 0)
5159 if (i == (ssize_t) (argc-1))
5160 ThrowMogrifyException(OptionError,"MissingArgument",option);
5161 if (IsGeometry(argv[i]) == MagickFalse)
5162 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5165 if (LocaleCompare("morphology",option+1) == 0)
5168 token[MaxTextExtent];
5177 if (i == (ssize_t) argc)
5178 ThrowMogrifyException(OptionError,"MissingArgument",option);
5179 GetMagickToken(argv[i],NULL,token);
5180 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5182 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5185 if (i == (ssize_t) (argc-1))
5186 ThrowMogrifyException(OptionError,"MissingArgument",option);
5187 kernel_info=AcquireKernelInfo(argv[i]);
5188 if (kernel_info == (KernelInfo *) NULL)
5189 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5190 kernel_info=DestroyKernelInfo(kernel_info);
5193 if (LocaleCompare("mosaic",option+1) == 0)
5195 if (LocaleCompare("motion-blur",option+1) == 0)
5200 if (i == (ssize_t) argc)
5201 ThrowMogrifyException(OptionError,"MissingArgument",option);
5202 if (IsGeometry(argv[i]) == MagickFalse)
5203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5206 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5210 if (LocaleCompare("negate",option+1) == 0)
5212 if (LocaleCompare("noise",option+1) == 0)
5215 if (i == (ssize_t) argc)
5216 ThrowMogrifyException(OptionError,"MissingArgument",option);
5222 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5224 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5228 if (IsGeometry(argv[i]) == MagickFalse)
5229 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5232 if (LocaleCompare("noop",option+1) == 0)
5234 if (LocaleCompare("normalize",option+1) == 0)
5236 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5240 if (LocaleCompare("opaque",option+1) == 0)
5243 if (i == (ssize_t) argc)
5244 ThrowMogrifyException(OptionError,"MissingArgument",option);
5247 if (LocaleCompare("ordered-dither",option+1) == 0)
5252 if (i == (ssize_t) argc)
5253 ThrowMogrifyException(OptionError,"MissingArgument",option);
5256 if (LocaleCompare("orient",option+1) == 0)
5261 orientation=UndefinedOrientation;
5265 if (i == (ssize_t) (argc-1))
5266 ThrowMogrifyException(OptionError,"MissingArgument",option);
5267 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5269 if (orientation < 0)
5270 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5274 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5278 if (LocaleCompare("page",option+1) == 0)
5283 if (i == (ssize_t) argc)
5284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 if (LocaleCompare("paint",option+1) == 0)
5292 if (i == (ssize_t) argc)
5293 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 if (IsGeometry(argv[i]) == MagickFalse)
5295 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5298 if (LocaleCompare("path",option+1) == 0)
5300 (void) CloneString(&path,(char *) NULL);
5304 if (i == (ssize_t) argc)
5305 ThrowMogrifyException(OptionError,"MissingArgument",option);
5306 (void) CloneString(&path,argv[i]);
5309 if (LocaleCompare("perceptible",option+1) == 0)
5314 if (i == (ssize_t) argc)
5315 ThrowMogrifyException(OptionError,"MissingArgument",option);
5316 if (IsGeometry(argv[i]) == MagickFalse)
5317 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5320 if (LocaleCompare("pointsize",option+1) == 0)
5325 if (i == (ssize_t) argc)
5326 ThrowMogrifyException(OptionError,"MissingArgument",option);
5327 if (IsGeometry(argv[i]) == MagickFalse)
5328 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5331 if (LocaleCompare("polaroid",option+1) == 0)
5336 if (i == (ssize_t) argc)
5337 ThrowMogrifyException(OptionError,"MissingArgument",option);
5338 if (IsGeometry(argv[i]) == MagickFalse)
5339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5342 if (LocaleCompare("poly",option+1) == 0)
5347 if (i == (ssize_t) argc)
5348 ThrowMogrifyException(OptionError,"MissingArgument",option);
5349 if (IsGeometry(argv[i]) == MagickFalse)
5350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5353 if (LocaleCompare("posterize",option+1) == 0)
5358 if (i == (ssize_t) argc)
5359 ThrowMogrifyException(OptionError,"MissingArgument",option);
5360 if (IsGeometry(argv[i]) == MagickFalse)
5361 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5364 if (LocaleCompare("precision",option+1) == 0)
5369 if (i == (ssize_t) argc)
5370 ThrowMogrifyException(OptionError,"MissingArgument",option);
5371 if (IsGeometry(argv[i]) == MagickFalse)
5372 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5375 if (LocaleCompare("print",option+1) == 0)
5380 if (i == (ssize_t) argc)
5381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5384 if (LocaleCompare("process",option+1) == 0)
5389 if (i == (ssize_t) (argc-1))
5390 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (LocaleCompare("profile",option+1) == 0)
5396 if (i == (ssize_t) argc)
5397 ThrowMogrifyException(OptionError,"MissingArgument",option);
5400 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5404 if (LocaleCompare("quality",option+1) == 0)
5409 if (i == (ssize_t) argc)
5410 ThrowMogrifyException(OptionError,"MissingArgument",option);
5411 if (IsGeometry(argv[i]) == MagickFalse)
5412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5415 if (LocaleCompare("quantize",option+1) == 0)
5423 if (i == (ssize_t) (argc-1))
5424 ThrowMogrifyException(OptionError,"MissingArgument",option);
5425 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5428 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5432 if (LocaleCompare("quiet",option+1) == 0)
5434 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5438 if (LocaleCompare("radial-blur",option+1) == 0)
5441 if (i == (ssize_t) argc)
5442 ThrowMogrifyException(OptionError,"MissingArgument",option);
5443 if (IsGeometry(argv[i]) == MagickFalse)
5444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5447 if (LocaleCompare("raise",option+1) == 0)
5450 if (i == (ssize_t) argc)
5451 ThrowMogrifyException(OptionError,"MissingArgument",option);
5452 if (IsGeometry(argv[i]) == MagickFalse)
5453 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5456 if (LocaleCompare("random-threshold",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("red-primary",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]);
5477 if (LocaleCompare("regard-warnings",option+1) == 0)
5479 if (LocaleCompare("region",option+1) == 0)
5484 if (i == (ssize_t) argc)
5485 ThrowMogrifyException(OptionError,"MissingArgument",option);
5486 if (IsGeometry(argv[i]) == MagickFalse)
5487 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5490 if (LocaleCompare("remap",option+1) == 0)
5495 if (i == (ssize_t) (argc-1))
5496 ThrowMogrifyException(OptionError,"MissingArgument",option);
5499 if (LocaleCompare("render",option+1) == 0)
5501 if (LocaleCompare("repage",option+1) == 0)
5506 if (i == (ssize_t) argc)
5507 ThrowMogrifyException(OptionError,"MissingArgument",option);
5508 if (IsGeometry(argv[i]) == MagickFalse)
5509 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5512 if (LocaleCompare("resample",option+1) == 0)
5517 if (i == (ssize_t) argc)
5518 ThrowMogrifyException(OptionError,"MissingArgument",option);
5519 if (IsGeometry(argv[i]) == MagickFalse)
5520 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5523 if (LocaleCompare("resize",option+1) == 0)
5528 if (i == (ssize_t) argc)
5529 ThrowMogrifyException(OptionError,"MissingArgument",option);
5530 if (IsGeometry(argv[i]) == MagickFalse)
5531 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5534 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5536 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5539 if (LocaleCompare("reverse",option+1) == 0)
5541 if (LocaleCompare("roll",option+1) == 0)
5546 if (i == (ssize_t) argc)
5547 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 if (IsGeometry(argv[i]) == MagickFalse)
5549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5552 if (LocaleCompare("rotate",option+1) == 0)
5555 if (i == (ssize_t) argc)
5556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 if (IsGeometry(argv[i]) == MagickFalse)
5558 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5561 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5565 if (LocaleCompare("sample",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("sampling-factor",option+1) == 0)
5581 if (i == (ssize_t) argc)
5582 ThrowMogrifyException(OptionError,"MissingArgument",option);
5583 if (IsGeometry(argv[i]) == MagickFalse)
5584 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5587 if (LocaleCompare("scale",option+1) == 0)
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (IsGeometry(argv[i]) == MagickFalse)
5595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5598 if (LocaleCompare("scene",option+1) == 0)
5603 if (i == (ssize_t) argc)
5604 ThrowMogrifyException(OptionError,"MissingArgument",option);
5605 if (IsGeometry(argv[i]) == MagickFalse)
5606 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5609 if (LocaleCompare("seed",option+1) == 0)
5614 if (i == (ssize_t) argc)
5615 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 if (IsGeometry(argv[i]) == MagickFalse)
5617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620 if (LocaleCompare("segment",option+1) == 0)
5625 if (i == (ssize_t) argc)
5626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 if (IsGeometry(argv[i]) == MagickFalse)
5628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 if (LocaleCompare("selective-blur",option+1) == 0)
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,"MissingArgument",option);
5636 if (IsGeometry(argv[i]) == MagickFalse)
5637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5640 if (LocaleCompare("separate",option+1) == 0)
5642 if (LocaleCompare("sepia-tone",option+1) == 0)
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 if (LocaleCompare("set",option+1) == 0)
5656 if (i == (ssize_t) argc)
5657 ThrowMogrifyException(OptionError,"MissingArgument",option);
5661 if (i == (ssize_t) argc)
5662 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 if (LocaleCompare("shade",option+1) == 0)
5668 if (i == (ssize_t) argc)
5669 ThrowMogrifyException(OptionError,"MissingArgument",option);
5670 if (IsGeometry(argv[i]) == MagickFalse)
5671 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5674 if (LocaleCompare("shadow",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("sharpen",option+1) == 0)
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5690 if (IsGeometry(argv[i]) == MagickFalse)
5691 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5694 if (LocaleCompare("shave",option+1) == 0)
5699 if (i == (ssize_t) argc)
5700 ThrowMogrifyException(OptionError,"MissingArgument",option);
5701 if (IsGeometry(argv[i]) == MagickFalse)
5702 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5705 if (LocaleCompare("shear",option+1) == 0)
5708 if (i == (ssize_t) argc)
5709 ThrowMogrifyException(OptionError,"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5714 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5717 if (i == (ssize_t) (argc-1))
5718 ThrowMogrifyException(OptionError,"MissingArgument",option);
5719 if (IsGeometry(argv[i]) == MagickFalse)
5720 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5723 if (LocaleCompare("size",option+1) == 0)
5728 if (i == (ssize_t) argc)
5729 ThrowMogrifyException(OptionError,"MissingArgument",option);
5730 if (IsGeometry(argv[i]) == MagickFalse)
5731 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5734 if (LocaleCompare("sketch",option+1) == 0)
5739 if (i == (ssize_t) argc)
5740 ThrowMogrifyException(OptionError,"MissingArgument",option);
5741 if (IsGeometry(argv[i]) == MagickFalse)
5742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5745 if (LocaleCompare("smush",option+1) == 0)
5748 if (i == (ssize_t) argc)
5749 ThrowMogrifyException(OptionError,"MissingArgument",option);
5750 if (IsGeometry(argv[i]) == MagickFalse)
5751 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5755 if (LocaleCompare("solarize",option+1) == 0)
5760 if (i == (ssize_t) argc)
5761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5766 if (LocaleCompare("sparse-color",option+1) == 0)
5772 if (i == (ssize_t) argc)
5773 ThrowMogrifyException(OptionError,"MissingArgument",option);
5774 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5776 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5779 if (i == (ssize_t) (argc-1))
5780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5783 if (LocaleCompare("splice",option+1) == 0)
5788 if (i == (ssize_t) argc)
5789 ThrowMogrifyException(OptionError,"MissingArgument",option);
5790 if (IsGeometry(argv[i]) == MagickFalse)
5791 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5794 if (LocaleCompare("spread",option+1) == 0)
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5801 if (IsGeometry(argv[i]) == MagickFalse)
5802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5805 if (LocaleCompare("statistic",option+1) == 0)
5813 if (i == (ssize_t) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5815 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5817 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5820 if (i == (ssize_t) (argc-1))
5821 ThrowMogrifyException(OptionError,"MissingArgument",option);
5822 if (IsGeometry(argv[i]) == MagickFalse)
5823 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 if (LocaleCompare("stretch",option+1) == 0)
5834 if (i == (ssize_t) (argc-1))
5835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5836 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5838 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5842 if (LocaleCompare("strip",option+1) == 0)
5844 if (LocaleCompare("stroke",option+1) == 0)
5849 if (i == (ssize_t) argc)
5850 ThrowMogrifyException(OptionError,"MissingArgument",option);
5853 if (LocaleCompare("strokewidth",option+1) == 0)
5858 if (i == (ssize_t) argc)
5859 ThrowMogrifyException(OptionError,"MissingArgument",option);
5860 if (IsGeometry(argv[i]) == MagickFalse)
5861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5864 if (LocaleCompare("style",option+1) == 0)
5872 if (i == (ssize_t) (argc-1))
5873 ThrowMogrifyException(OptionError,"MissingArgument",option);
5874 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5876 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5880 if (LocaleCompare("swap",option+1) == 0)
5885 if (i == (ssize_t) (argc-1))
5886 ThrowMogrifyException(OptionError,"MissingArgument",option);
5887 if (IsGeometry(argv[i]) == MagickFalse)
5888 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5891 if (LocaleCompare("swirl",option+1) == 0)
5896 if (i == (ssize_t) argc)
5897 ThrowMogrifyException(OptionError,"MissingArgument",option);
5898 if (IsGeometry(argv[i]) == MagickFalse)
5899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5902 if (LocaleCompare("synchronize",option+1) == 0)
5904 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5908 if (LocaleCompare("taint",option+1) == 0)
5910 if (LocaleCompare("texture",option+1) == 0)
5915 if (i == (ssize_t) argc)
5916 ThrowMogrifyException(OptionError,"MissingArgument",option);
5919 if (LocaleCompare("tile",option+1) == 0)
5924 if (i == (ssize_t) (argc-1))
5925 ThrowMogrifyException(OptionError,"MissingArgument",option);
5928 if (LocaleCompare("tile-offset",option+1) == 0)
5933 if (i == (ssize_t) argc)
5934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 if (IsGeometry(argv[i]) == MagickFalse)
5936 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939 if (LocaleCompare("tint",option+1) == 0)
5944 if (i == (ssize_t) (argc-1))
5945 ThrowMogrifyException(OptionError,"MissingArgument",option);
5946 if (IsGeometry(argv[i]) == MagickFalse)
5947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5950 if (LocaleCompare("transform",option+1) == 0)
5952 if (LocaleCompare("transpose",option+1) == 0)
5954 if (LocaleCompare("transverse",option+1) == 0)
5956 if (LocaleCompare("threshold",option+1) == 0)
5961 if (i == (ssize_t) argc)
5962 ThrowMogrifyException(OptionError,"MissingArgument",option);
5963 if (IsGeometry(argv[i]) == MagickFalse)
5964 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5967 if (LocaleCompare("thumbnail",option+1) == 0)
5972 if (i == (ssize_t) argc)
5973 ThrowMogrifyException(OptionError,"MissingArgument",option);
5974 if (IsGeometry(argv[i]) == MagickFalse)
5975 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5978 if (LocaleCompare("transparent",option+1) == 0)
5981 if (i == (ssize_t) argc)
5982 ThrowMogrifyException(OptionError,"MissingArgument",option);
5985 if (LocaleCompare("transparent-color",option+1) == 0)
5990 if (i == (ssize_t) (argc-1))
5991 ThrowMogrifyException(OptionError,"MissingArgument",option);
5994 if (LocaleCompare("treedepth",option+1) == 0)
5999 if (i == (ssize_t) argc)
6000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6001 if (IsGeometry(argv[i]) == MagickFalse)
6002 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6005 if (LocaleCompare("trim",option+1) == 0)
6007 if (LocaleCompare("type",option+1) == 0)
6015 if (i == (ssize_t) argc)
6016 ThrowMogrifyException(OptionError,"MissingArgument",option);
6017 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6019 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6023 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6027 if (LocaleCompare("undercolor",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6036 if (LocaleCompare("unique-colors",option+1) == 0)
6038 if (LocaleCompare("units",option+1) == 0)
6046 if (i == (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6051 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6055 if (LocaleCompare("unsharp",option+1) == 0)
6058 if (i == (ssize_t) argc)
6059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 if (IsGeometry(argv[i]) == MagickFalse)
6061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6068 if (LocaleCompare("verbose",option+1) == 0)
6070 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6073 if ((LocaleCompare("version",option+1) == 0) ||
6074 (LocaleCompare("-version",option+1) == 0))
6076 ListMagickVersion(stdout);
6079 if (LocaleCompare("view",option+1) == 0)
6084 if (i == (ssize_t) argc)
6085 ThrowMogrifyException(OptionError,"MissingArgument",option);
6088 if (LocaleCompare("vignette",option+1) == 0)
6093 if (i == (ssize_t) argc)
6094 ThrowMogrifyException(OptionError,"MissingArgument",option);
6095 if (IsGeometry(argv[i]) == MagickFalse)
6096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6099 if (LocaleCompare("virtual-pixel",option+1) == 0)
6107 if (i == (ssize_t) argc)
6108 ThrowMogrifyException(OptionError,"MissingArgument",option);
6109 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6112 ThrowMogrifyException(OptionError,
6113 "UnrecognizedVirtualPixelMethod",argv[i]);
6116 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6120 if (LocaleCompare("wave",option+1) == 0)
6123 if (i == (ssize_t) argc)
6124 ThrowMogrifyException(OptionError,"MissingArgument",option);
6125 if (IsGeometry(argv[i]) == MagickFalse)
6126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6129 if (LocaleCompare("weight",option+1) == 0)
6134 if (i == (ssize_t) (argc-1))
6135 ThrowMogrifyException(OptionError,"MissingArgument",option);
6138 if (LocaleCompare("white-point",option+1) == 0)
6143 if (i == (ssize_t) argc)
6144 ThrowMogrifyException(OptionError,"MissingArgument",option);
6145 if (IsGeometry(argv[i]) == MagickFalse)
6146 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6149 if (LocaleCompare("white-threshold",option+1) == 0)
6154 if (i == (ssize_t) argc)
6155 ThrowMogrifyException(OptionError,"MissingArgument",option);
6156 if (IsGeometry(argv[i]) == MagickFalse)
6157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6160 if (LocaleCompare("write",option+1) == 0)
6163 if (i == (ssize_t) (argc-1))
6164 ThrowMogrifyException(OptionError,"MissingArgument",option);
6167 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6172 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6174 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6175 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6176 if (fire != MagickFalse)
6177 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6180 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6181 if (i != (ssize_t) argc)
6182 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6184 return(status != 0 ? MagickTrue : MagickFalse);
6188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6192 + M o g r i f y I m a g e I n f o %
6196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6198 % MogrifyImageInfo() applies image processing settings to the image as
6199 % prescribed by command line options.
6201 % The format of the MogrifyImageInfo method is:
6203 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6204 % const char **argv,ExceptionInfo *exception)
6206 % A description of each parameter follows:
6208 % o image_info: the image info..
6210 % o argc: Specifies a pointer to an integer describing the number of
6211 % elements in the argument vector.
6213 % o argv: Specifies a pointer to a text array containing the command line
6216 % o exception: return any errors or warnings in this structure.
6219 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6220 const int argc,const char **argv,ExceptionInfo *exception)
6235 Initialize method variables.
6237 assert(image_info != (ImageInfo *) NULL);
6238 assert(image_info->signature == MagickSignature);
6239 if (image_info->debug != MagickFalse)
6240 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6241 image_info->filename);
6245 Set the image settings.
6247 for (i=0; i < (ssize_t) argc; i++)
6250 if (IsCommandOption(option) == MagickFalse)
6252 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6253 count=MagickMax(count,0L);
6254 if ((i+count) >= (ssize_t) argc)
6256 switch (*(option+1))
6260 if (LocaleCompare("adjoin",option+1) == 0)
6262 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6265 if (LocaleCompare("antialias",option+1) == 0)
6267 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6270 if (LocaleCompare("authenticate",option+1) == 0)
6273 (void) DeleteImageOption(image_info,option+1);
6275 (void) SetImageOption(image_info,option+1,argv[i+1]);
6282 if (LocaleCompare("background",option+1) == 0)
6286 (void) DeleteImageOption(image_info,option+1);
6287 (void) QueryColorCompliance(MogrifyBackgroundColor,
6288 AllCompliance,&image_info->background_color,exception);
6291 (void) SetImageOption(image_info,option+1,argv[i+1]);
6292 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6293 &image_info->background_color,exception);
6296 if (LocaleCompare("bias",option+1) == 0)
6300 (void) SetImageOption(image_info,option+1,"0.0");
6303 (void) SetImageOption(image_info,option+1,argv[i+1]);
6306 if (LocaleCompare("black-point-compensation",option+1) == 0)
6310 (void) SetImageOption(image_info,option+1,"false");
6313 (void) SetImageOption(image_info,option+1,"true");
6316 if (LocaleCompare("blue-primary",option+1) == 0)
6320 (void) SetImageOption(image_info,option+1,"0.0");
6323 (void) SetImageOption(image_info,option+1,argv[i+1]);
6326 if (LocaleCompare("bordercolor",option+1) == 0)
6330 (void) DeleteImageOption(image_info,option+1);
6331 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6332 &image_info->border_color,exception);
6335 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6336 &image_info->border_color,exception);
6337 (void) SetImageOption(image_info,option+1,argv[i+1]);
6340 if (LocaleCompare("box",option+1) == 0)
6344 (void) SetImageOption(image_info,"undercolor","none");
6347 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6354 if (LocaleCompare("cache",option+1) == 0)
6359 limit=MagickResourceInfinity;
6360 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6361 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6363 (void) SetMagickResourceLimit(MemoryResource,limit);
6364 (void) SetMagickResourceLimit(MapResource,2*limit);
6367 if (LocaleCompare("caption",option+1) == 0)
6371 (void) DeleteImageOption(image_info,option+1);
6374 (void) SetImageOption(image_info,option+1,argv[i+1]);
6377 if (LocaleCompare("channel",option+1) == 0)
6381 image_info->channel=DefaultChannels;
6382 (void) SetImageOption(image_info,option+1,"default");
6385 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6386 (void) SetImageOption(image_info,option+1,argv[i+1]);
6389 if (LocaleCompare("colorspace",option+1) == 0)
6393 image_info->colorspace=UndefinedColorspace;
6394 (void) SetImageOption(image_info,option+1,"undefined");
6397 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6398 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6399 (void) SetImageOption(image_info,option+1,argv[i+1]);
6402 if (LocaleCompare("comment",option+1) == 0)
6406 (void) DeleteImageOption(image_info,option+1);
6409 (void) SetImageOption(image_info,option+1,argv[i+1]);
6412 if (LocaleCompare("compose",option+1) == 0)
6416 (void) SetImageOption(image_info,option+1,"undefined");
6419 (void) SetImageOption(image_info,option+1,argv[i+1]);
6422 if (LocaleCompare("compress",option+1) == 0)
6426 image_info->compression=UndefinedCompression;
6427 (void) SetImageOption(image_info,option+1,"undefined");
6430 image_info->compression=(CompressionType) ParseCommandOption(
6431 MagickCompressOptions,MagickFalse,argv[i+1]);
6432 (void) SetImageOption(image_info,option+1,argv[i+1]);
6439 if (LocaleCompare("debug",option+1) == 0)
6442 (void) SetLogEventMask("none");
6444 (void) SetLogEventMask(argv[i+1]);
6445 image_info->debug=IsEventLogging();
6448 if (LocaleCompare("define",option+1) == 0)
6452 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6453 (void) DeleteImageRegistry(argv[i+1]+9);
6455 (void) DeleteImageOption(image_info,argv[i+1]);
6458 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6460 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6464 (void) DefineImageOption(image_info,argv[i+1]);
6467 if (LocaleCompare("delay",option+1) == 0)
6471 (void) SetImageOption(image_info,option+1,"0");
6474 (void) SetImageOption(image_info,option+1,argv[i+1]);
6477 if (LocaleCompare("density",option+1) == 0)
6484 if (image_info->density != (char *) NULL)
6485 image_info->density=DestroyString(image_info->density);
6486 (void) SetImageOption(image_info,option+1,"72");
6489 (void) CloneString(&image_info->density,argv[i+1]);
6490 (void) SetImageOption(image_info,option+1,argv[i+1]);
6493 if (LocaleCompare("depth",option+1) == 0)
6497 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6500 image_info->depth=StringToUnsignedLong(argv[i+1]);
6503 if (LocaleCompare("direction",option+1) == 0)
6507 (void) SetImageOption(image_info,option+1,"undefined");
6510 (void) SetImageOption(image_info,option+1,argv[i+1]);
6513 if (LocaleCompare("display",option+1) == 0)
6517 if (image_info->server_name != (char *) NULL)
6518 image_info->server_name=DestroyString(
6519 image_info->server_name);
6522 (void) CloneString(&image_info->server_name,argv[i+1]);
6525 if (LocaleCompare("dispose",option+1) == 0)
6529 (void) SetImageOption(image_info,option+1,"undefined");
6532 (void) SetImageOption(image_info,option+1,argv[i+1]);
6535 if (LocaleCompare("dither",option+1) == 0)
6539 image_info->dither=MagickFalse;
6540 (void) SetImageOption(image_info,option+1,"none");
6543 (void) SetImageOption(image_info,option+1,argv[i+1]);
6544 image_info->dither=MagickTrue;
6551 if (LocaleCompare("encoding",option+1) == 0)
6555 (void) SetImageOption(image_info,option+1,"undefined");
6558 (void) SetImageOption(image_info,option+1,argv[i+1]);
6561 if (LocaleCompare("endian",option+1) == 0)
6565 image_info->endian=UndefinedEndian;
6566 (void) SetImageOption(image_info,option+1,"undefined");
6569 image_info->endian=(EndianType) ParseCommandOption(
6570 MagickEndianOptions,MagickFalse,argv[i+1]);
6571 (void) SetImageOption(image_info,option+1,argv[i+1]);
6574 if (LocaleCompare("extract",option+1) == 0)
6577 Set image extract geometry.
6581 if (image_info->extract != (char *) NULL)
6582 image_info->extract=DestroyString(image_info->extract);
6585 (void) CloneString(&image_info->extract,argv[i+1]);
6592 if (LocaleCompare("fill",option+1) == 0)
6596 (void) SetImageOption(image_info,option+1,"none");
6599 (void) SetImageOption(image_info,option+1,argv[i+1]);
6602 if (LocaleCompare("filter",option+1) == 0)
6606 (void) SetImageOption(image_info,option+1,"undefined");
6609 (void) SetImageOption(image_info,option+1,argv[i+1]);
6612 if (LocaleCompare("font",option+1) == 0)
6616 if (image_info->font != (char *) NULL)
6617 image_info->font=DestroyString(image_info->font);
6620 (void) CloneString(&image_info->font,argv[i+1]);
6623 if (LocaleCompare("format",option+1) == 0)
6628 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6629 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6630 image_info->ping=MagickFalse;
6631 (void) SetImageOption(image_info,option+1,argv[i+1]);
6634 if (LocaleCompare("fuzz",option+1) == 0)
6638 image_info->fuzz=0.0;
6639 (void) SetImageOption(image_info,option+1,"0");
6642 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6644 (void) SetImageOption(image_info,option+1,argv[i+1]);
6651 if (LocaleCompare("gravity",option+1) == 0)
6655 (void) SetImageOption(image_info,option+1,"undefined");
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6661 if (LocaleCompare("green-primary",option+1) == 0)
6665 (void) SetImageOption(image_info,option+1,"0.0");
6668 (void) SetImageOption(image_info,option+1,argv[i+1]);
6675 if (LocaleCompare("intensity",option+1) == 0)
6679 (void) SetImageOption(image_info,option+1,"undefined");
6682 (void) SetImageOption(image_info,option+1,argv[i+1]);
6685 if (LocaleCompare("intent",option+1) == 0)
6689 (void) SetImageOption(image_info,option+1,"undefined");
6692 (void) SetImageOption(image_info,option+1,argv[i+1]);
6695 if (LocaleCompare("interlace",option+1) == 0)
6699 image_info->interlace=UndefinedInterlace;
6700 (void) SetImageOption(image_info,option+1,"undefined");
6703 image_info->interlace=(InterlaceType) ParseCommandOption(
6704 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6705 (void) SetImageOption(image_info,option+1,argv[i+1]);
6708 if (LocaleCompare("interline-spacing",option+1) == 0)
6712 (void) SetImageOption(image_info,option+1,"undefined");
6715 (void) SetImageOption(image_info,option+1,argv[i+1]);
6718 if (LocaleCompare("interpolate",option+1) == 0)
6722 (void) SetImageOption(image_info,option+1,"undefined");
6725 (void) SetImageOption(image_info,option+1,argv[i+1]);
6728 if (LocaleCompare("interword-spacing",option+1) == 0)
6732 (void) SetImageOption(image_info,option+1,"undefined");
6735 (void) SetImageOption(image_info,option+1,argv[i+1]);
6742 if (LocaleCompare("kerning",option+1) == 0)
6746 (void) SetImageOption(image_info,option+1,"undefined");
6749 (void) SetImageOption(image_info,option+1,argv[i+1]);
6756 if (LocaleCompare("label",option+1) == 0)
6760 (void) DeleteImageOption(image_info,option+1);
6763 (void) SetImageOption(image_info,option+1,argv[i+1]);
6766 if (LocaleCompare("limit",option+1) == 0)
6776 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6777 MagickFalse,argv[i+1]);
6778 limit=MagickResourceInfinity;
6779 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6780 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6781 (void) SetMagickResourceLimit(type,limit);
6784 if (LocaleCompare("list",option+1) == 0)
6790 Display configuration list.
6792 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6795 case MagickCoderOptions:
6797 (void) ListCoderInfo((FILE *) NULL,exception);
6800 case MagickColorOptions:
6802 (void) ListColorInfo((FILE *) NULL,exception);
6805 case MagickConfigureOptions:
6807 (void) ListConfigureInfo((FILE *) NULL,exception);
6810 case MagickDelegateOptions:
6812 (void) ListDelegateInfo((FILE *) NULL,exception);
6815 case MagickFontOptions:
6817 (void) ListTypeInfo((FILE *) NULL,exception);
6820 case MagickFormatOptions:
6822 (void) ListMagickInfo((FILE *) NULL,exception);
6825 case MagickLocaleOptions:
6827 (void) ListLocaleInfo((FILE *) NULL,exception);
6830 case MagickLogOptions:
6832 (void) ListLogInfo((FILE *) NULL,exception);
6835 case MagickMagicOptions:
6837 (void) ListMagicInfo((FILE *) NULL,exception);
6840 case MagickMimeOptions:
6842 (void) ListMimeInfo((FILE *) NULL,exception);
6845 case MagickModuleOptions:
6847 (void) ListModuleInfo((FILE *) NULL,exception);
6850 case MagickPolicyOptions:
6852 (void) ListPolicyInfo((FILE *) NULL,exception);
6855 case MagickResourceOptions:
6857 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6860 case MagickThresholdOptions:
6862 (void) ListThresholdMaps((FILE *) NULL,exception);
6867 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6874 if (LocaleCompare("log",option+1) == 0)
6878 (void) SetLogFormat(argv[i+1]);
6881 if (LocaleCompare("loop",option+1) == 0)
6885 (void) SetImageOption(image_info,option+1,"0");
6888 (void) SetImageOption(image_info,option+1,argv[i+1]);
6895 if (LocaleCompare("matte",option+1) == 0)
6899 (void) SetImageOption(image_info,option+1,"false");
6902 (void) SetImageOption(image_info,option+1,"true");
6905 if (LocaleCompare("mattecolor",option+1) == 0)
6909 (void) SetImageOption(image_info,option+1,argv[i+1]);
6910 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6911 &image_info->matte_color,exception);
6914 (void) SetImageOption(image_info,option+1,argv[i+1]);
6915 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6916 &image_info->matte_color,exception);
6919 if (LocaleCompare("metric",option+1) == 0)
6922 (void) DeleteImageOption(image_info,option+1);
6924 (void) SetImageOption(image_info,option+1,argv[i+1]);
6927 if (LocaleCompare("monitor",option+1) == 0)
6929 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6933 if (LocaleCompare("monochrome",option+1) == 0)
6935 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6942 if (LocaleCompare("orient",option+1) == 0)
6946 image_info->orientation=UndefinedOrientation;
6947 (void) SetImageOption(image_info,option+1,"undefined");
6950 image_info->orientation=(OrientationType) ParseCommandOption(
6951 MagickOrientationOptions,MagickFalse,argv[i+1]);
6952 (void) SetImageOption(image_info,option+1,argv[i+1]);
6958 if (LocaleCompare("page",option+1) == 0)
6962 page[MaxTextExtent];
6975 (void) DeleteImageOption(image_info,option+1);
6976 (void) CloneString(&image_info->page,(char *) NULL);
6979 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6980 image_option=GetImageOption(image_info,"page");
6981 if (image_option != (const char *) NULL)
6982 flags=ParseAbsoluteGeometry(image_option,&geometry);
6983 canonical_page=GetPageGeometry(argv[i+1]);
6984 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6985 canonical_page=DestroyString(canonical_page);
6986 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6987 (unsigned long) geometry.width,(unsigned long) geometry.height);
6988 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6989 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6990 (unsigned long) geometry.width,(unsigned long) geometry.height,
6991 (long) geometry.x,(long) geometry.y);
6992 (void) SetImageOption(image_info,option+1,page);
6993 (void) CloneString(&image_info->page,page);
6996 if (LocaleCompare("ping",option+1) == 0)
6998 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7001 if (LocaleCompare("pointsize",option+1) == 0)
7004 geometry_info.rho=0.0;
7006 (void) ParseGeometry(argv[i+1],&geometry_info);
7007 image_info->pointsize=geometry_info.rho;
7010 if (LocaleCompare("precision",option+1) == 0)
7012 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7015 if (LocaleCompare("preview",option+1) == 0)
7022 image_info->preview_type=UndefinedPreview;
7025 image_info->preview_type=(PreviewType) ParseCommandOption(
7026 MagickPreviewOptions,MagickFalse,argv[i+1]);
7033 if (LocaleCompare("quality",option+1) == 0)
7036 Set image compression quality.
7040 image_info->quality=UndefinedCompressionQuality;
7041 (void) SetImageOption(image_info,option+1,"0");
7044 image_info->quality=StringToUnsignedLong(argv[i+1]);
7045 (void) SetImageOption(image_info,option+1,argv[i+1]);
7048 if (LocaleCompare("quiet",option+1) == 0)
7050 static WarningHandler
7051 warning_handler = (WarningHandler) NULL;
7056 Restore error or warning messages.
7058 warning_handler=SetWarningHandler(warning_handler);
7062 Suppress error or warning messages.
7064 warning_handler=SetWarningHandler((WarningHandler) NULL);
7071 if (LocaleCompare("red-primary",option+1) == 0)
7075 (void) SetImageOption(image_info,option+1,"0.0");
7078 (void) SetImageOption(image_info,option+1,argv[i+1]);
7085 if (LocaleCompare("sampling-factor",option+1) == 0)
7088 Set image sampling factor.
7092 if (image_info->sampling_factor != (char *) NULL)
7093 image_info->sampling_factor=DestroyString(
7094 image_info->sampling_factor);
7097 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7100 if (LocaleCompare("scene",option+1) == 0)
7107 image_info->scene=0;
7108 (void) SetImageOption(image_info,option+1,"0");
7111 image_info->scene=StringToUnsignedLong(argv[i+1]);
7112 (void) SetImageOption(image_info,option+1,argv[i+1]);
7115 if (LocaleCompare("seed",option+1) == 0)
7122 seed=(size_t) time((time_t *) NULL);
7123 SetRandomSecretKey(seed);
7126 seed=StringToUnsignedLong(argv[i+1]);
7127 SetRandomSecretKey(seed);
7130 if (LocaleCompare("size",option+1) == 0)
7134 if (image_info->size != (char *) NULL)
7135 image_info->size=DestroyString(image_info->size);
7138 (void) CloneString(&image_info->size,argv[i+1]);
7141 if (LocaleCompare("stroke",option+1) == 0)
7145 (void) SetImageOption(image_info,option+1,"none");
7148 (void) SetImageOption(image_info,option+1,argv[i+1]);
7151 if (LocaleCompare("strokewidth",option+1) == 0)
7155 (void) SetImageOption(image_info,option+1,"0");
7158 (void) SetImageOption(image_info,option+1,argv[i+1]);
7161 if (LocaleCompare("synchronize",option+1) == 0)
7165 image_info->synchronize=MagickFalse;
7168 image_info->synchronize=MagickTrue;
7175 if (LocaleCompare("taint",option+1) == 0)
7179 (void) SetImageOption(image_info,option+1,"false");
7182 (void) SetImageOption(image_info,option+1,"true");
7185 if (LocaleCompare("texture",option+1) == 0)
7189 if (image_info->texture != (char *) NULL)
7190 image_info->texture=DestroyString(image_info->texture);
7193 (void) CloneString(&image_info->texture,argv[i+1]);
7196 if (LocaleCompare("tile-offset",option+1) == 0)
7199 (void) SetImageOption(image_info,option+1,"0");
7201 (void) SetImageOption(image_info,option+1,argv[i+1]);
7204 if (LocaleCompare("transparent-color",option+1) == 0)
7208 (void) QueryColorCompliance("none",AllCompliance,
7209 &image_info->transparent_color,exception);
7210 (void) SetImageOption(image_info,option+1,"none");
7213 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7214 &image_info->transparent_color,exception);
7215 (void) SetImageOption(image_info,option+1,argv[i+1]);
7218 if (LocaleCompare("type",option+1) == 0)
7222 image_info->type=UndefinedType;
7223 (void) SetImageOption(image_info,option+1,"undefined");
7226 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7227 MagickFalse,argv[i+1]);
7228 (void) SetImageOption(image_info,option+1,argv[i+1]);
7235 if (LocaleCompare("undercolor",option+1) == 0)
7238 (void) DeleteImageOption(image_info,option+1);
7240 (void) SetImageOption(image_info,option+1,argv[i+1]);
7243 if (LocaleCompare("units",option+1) == 0)
7247 image_info->units=UndefinedResolution;
7248 (void) SetImageOption(image_info,option+1,"undefined");
7251 image_info->units=(ResolutionType) ParseCommandOption(
7252 MagickResolutionOptions,MagickFalse,argv[i+1]);
7253 (void) SetImageOption(image_info,option+1,argv[i+1]);
7260 if (LocaleCompare("verbose",option+1) == 0)
7264 image_info->verbose=MagickFalse;
7267 image_info->verbose=MagickTrue;
7268 image_info->ping=MagickFalse;
7271 if (LocaleCompare("view",option+1) == 0)
7275 if (image_info->view != (char *) NULL)
7276 image_info->view=DestroyString(image_info->view);
7279 (void) CloneString(&image_info->view,argv[i+1]);
7282 if (LocaleCompare("virtual-pixel",option+1) == 0)
7285 (void) SetImageOption(image_info,option+1,"undefined");
7287 (void) SetImageOption(image_info,option+1,argv[i+1]);
7294 if (LocaleCompare("white-point",option+1) == 0)
7297 (void) SetImageOption(image_info,option+1,"0.0");
7299 (void) SetImageOption(image_info,option+1,argv[i+1]);
7313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7317 + M o g r i f y I m a g e L i s t %
7321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7323 % MogrifyImageList() applies any command line options that might affect the
7324 % entire image list (e.g. -append, -coalesce, etc.).
7326 % The format of the MogrifyImage method is:
7328 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7329 % const char **argv,Image **images,ExceptionInfo *exception)
7331 % A description of each parameter follows:
7333 % o image_info: the image info..
7335 % o argc: Specifies a pointer to an integer describing the number of
7336 % elements in the argument vector.
7338 % o argv: Specifies a pointer to a text array containing the command line
7341 % o images: pointer to pointer of the first image in image list.
7343 % o exception: return any errors or warnings in this structure.
7346 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7347 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7358 PixelInterpolateMethod
7372 Apply options to the image list.
7374 assert(image_info != (ImageInfo *) NULL);
7375 assert(image_info->signature == MagickSignature);
7376 assert(images != (Image **) NULL);
7377 assert((*images)->previous == (Image *) NULL);
7378 assert((*images)->signature == MagickSignature);
7379 if ((*images)->debug != MagickFalse)
7380 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7381 (*images)->filename);
7382 if ((argc <= 0) || (*argv == (char *) NULL))
7384 interpolate_method=UndefinedInterpolatePixel;
7385 mogrify_info=CloneImageInfo(image_info);
7386 quantize_info=AcquireQuantizeInfo(mogrify_info);
7388 for (i=0; i < (ssize_t) argc; i++)
7390 if (*images == (Image *) NULL)
7393 if (IsCommandOption(option) == MagickFalse)
7395 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7396 count=MagickMax(count,0L);
7397 if ((i+count) >= (ssize_t) argc)
7399 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7400 switch (*(option+1))
7404 if (LocaleCompare("affinity",option+1) == 0)
7406 (void) SyncImagesSettings(mogrify_info,*images,exception);
7409 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7416 if (LocaleCompare("append",option+1) == 0)
7421 (void) SyncImagesSettings(mogrify_info,*images,exception);
7422 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7423 MagickFalse,exception);
7424 if (append_image == (Image *) NULL)
7429 *images=DestroyImageList(*images);
7430 *images=append_image;
7433 if (LocaleCompare("average",option+1) == 0)
7439 Average an image sequence (deprecated).
7441 (void) SyncImagesSettings(mogrify_info,*images,exception);
7442 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7444 if (average_image == (Image *) NULL)
7449 *images=DestroyImageList(*images);
7450 *images=average_image;
7457 if (LocaleCompare("channel-fx",option+1) == 0)
7462 (void) SyncImagesSettings(mogrify_info,*images,exception);
7463 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7464 if (channel_image == (Image *) NULL)
7469 *images=DestroyImageList(*images);
7470 *images=channel_image;
7473 if (LocaleCompare("clut",option+1) == 0)
7479 (void) SyncImagesSettings(mogrify_info,*images,exception);
7480 image=RemoveFirstImageFromList(images);
7481 clut_image=RemoveFirstImageFromList(images);
7482 if (clut_image == (Image *) NULL)
7487 (void) ClutImage(image,clut_image,interpolate_method,exception);
7488 clut_image=DestroyImage(clut_image);
7489 *images=DestroyImageList(*images);
7493 if (LocaleCompare("coalesce",option+1) == 0)
7498 (void) SyncImagesSettings(mogrify_info,*images,exception);
7499 coalesce_image=CoalesceImages(*images,exception);
7500 if (coalesce_image == (Image *) NULL)
7505 *images=DestroyImageList(*images);
7506 *images=coalesce_image;
7509 if (LocaleCompare("combine",option+1) == 0)
7517 (void) SyncImagesSettings(mogrify_info,*images,exception);
7518 colorspace=(ColorspaceType) ParseCommandOption(
7519 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7520 combine_image=CombineImages(*images,colorspace,exception);
7521 if (combine_image == (Image *) NULL)
7526 *images=DestroyImageList(*images);
7527 *images=combine_image;
7530 if (LocaleCompare("compare",option+1) == 0)
7547 Mathematically and visually annotate the difference between an
7548 image and its reconstruction.
7550 (void) SyncImagesSettings(mogrify_info,*images,exception);
7551 image=RemoveFirstImageFromList(images);
7552 reconstruct_image=RemoveFirstImageFromList(images);
7553 if (reconstruct_image == (Image *) NULL)
7558 metric=UndefinedErrorMetric;
7559 option=GetImageOption(image_info,"metric");
7560 if (option != (const char *) NULL)
7561 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7562 MagickFalse,option);
7563 difference_image=CompareImages(image,reconstruct_image,metric,
7564 &distortion,exception);
7565 if (difference_image == (Image *) NULL)
7567 if (*images != (Image *) NULL)
7568 *images=DestroyImage(*images);
7569 *images=difference_image;
7572 if (LocaleCompare("complex",option+1) == 0)
7580 (void) SyncImageSettings(mogrify_info,*images,exception);
7581 operator=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7582 MagickFalse,argv[i+1]);
7583 complex_image=ComplexImages(*images,operator,exception);
7584 if (complex_image == (Image *) NULL)
7589 *images=DestroyImageList(*images);
7590 *images=complex_image;
7593 if (LocaleCompare("composite",option+1) == 0)
7609 (void) SyncImagesSettings(mogrify_info,*images,exception);
7610 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7611 if (value == (const char *) NULL)
7612 clip_to_self=MagickTrue;
7614 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7615 "compose:clip-to-self")); /* if this is true */
7616 if (IsMagickFalse(clip_to_self)) /* or */
7617 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7618 mogrify_info,"compose:outside-overlay"))) ? MagickTrue :
7619 MagickFalse; /* this false */
7620 image=RemoveFirstImageFromList(images);
7621 composite_image=RemoveFirstImageFromList(images);
7622 if (composite_image == (Image *) NULL)
7627 (void) TransformImage(&composite_image,(char *) NULL,
7628 composite_image->geometry,exception);
7629 SetGeometry(composite_image,&geometry);
7630 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7631 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7633 mask_image=RemoveFirstImageFromList(images);
7634 if (mask_image != (Image *) NULL)
7636 if ((image->compose == DisplaceCompositeOp) ||
7637 (image->compose == DistortCompositeOp))
7638 status&=CompositeImage(composite_image,mask_image,
7639 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7648 composite_geometry.width=mask_image->columns;
7649 composite_geometry.height=mask_image->rows;
7650 composite_geometry.x=(-geometry.x);
7651 composite_geometry.y=(-geometry.y);
7654 image=ExtentImage(composite_image,&composite_geometry,
7656 if (image != (Image *) NULL)
7658 composite_image=DestroyImage(composite_image);
7659 composite_image=image;
7661 status&=CompositeImage(composite_image,mask_image,
7662 IntensityCompositeOp,MagickTrue,0,0,exception);
7664 mask_image=DestroyImage(mask_image);
7666 (void) CompositeImage(image,composite_image,image->compose,
7667 clip_to_self,geometry.x,geometry.y,exception);
7668 composite_image=DestroyImage(composite_image);
7669 *images=DestroyImageList(*images);
7677 if (LocaleCompare("deconstruct",option+1) == 0)
7682 (void) SyncImagesSettings(mogrify_info,*images,exception);
7683 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7685 if (deconstruct_image == (Image *) NULL)
7690 *images=DestroyImageList(*images);
7691 *images=deconstruct_image;
7694 if (LocaleCompare("delete",option+1) == 0)
7697 DeleteImages(images,"-1",exception);
7699 DeleteImages(images,argv[i+1],exception);
7702 if (LocaleCompare("dither",option+1) == 0)
7706 quantize_info->dither_method=NoDitherMethod;
7709 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7710 MagickDitherOptions,MagickFalse,argv[i+1]);
7713 if (LocaleCompare("duplicate",option+1) == 0)
7719 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7728 number_duplicates=(size_t) StringToLong(argv[i+1]);
7729 p=strchr(argv[i+1],',');
7730 if (p == (const char *) NULL)
7731 duplicate_images=DuplicateImages(*images,number_duplicates,
7734 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7737 AppendImageToList(images, duplicate_images);
7738 (void) SyncImagesSettings(mogrify_info,*images,exception);
7745 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7750 MagickEvaluateOperator
7753 (void) SyncImageSettings(mogrify_info,*images,exception);
7754 op=(MagickEvaluateOperator) ParseCommandOption(
7755 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7756 evaluate_image=EvaluateImages(*images,op,exception);
7757 if (evaluate_image == (Image *) NULL)
7762 *images=DestroyImageList(*images);
7763 *images=evaluate_image;
7770 if (LocaleCompare("fft",option+1) == 0)
7776 Implements the discrete Fourier transform (DFT).
7778 (void) SyncImageSettings(mogrify_info,*images,exception);
7779 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7780 MagickTrue : MagickFalse,exception);
7781 if (fourier_image == (Image *) NULL)
7783 *images=DestroyImage(*images);
7784 *images=fourier_image;
7787 if (LocaleCompare("flatten",option+1) == 0)
7792 (void) SyncImagesSettings(mogrify_info,*images,exception);
7793 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7794 if (flatten_image == (Image *) NULL)
7796 *images=DestroyImageList(*images);
7797 *images=flatten_image;
7800 if (LocaleCompare("fx",option+1) == 0)
7805 (void) SyncImagesSettings(mogrify_info,*images,exception);
7806 fx_image=FxImage(*images,argv[i+1],exception);
7807 if (fx_image == (Image *) NULL)
7812 *images=DestroyImageList(*images);
7820 if (LocaleCompare("hald-clut",option+1) == 0)
7826 (void) SyncImagesSettings(mogrify_info,*images,exception);
7827 image=RemoveFirstImageFromList(images);
7828 hald_image=RemoveFirstImageFromList(images);
7829 if (hald_image == (Image *) NULL)
7834 (void) HaldClutImage(image,hald_image,exception);
7835 hald_image=DestroyImage(hald_image);
7836 if (*images != (Image *) NULL)
7837 *images=DestroyImageList(*images);
7845 if (LocaleCompare("ift",option+1) == 0)
7853 Implements the inverse fourier discrete Fourier transform (DFT).
7855 (void) SyncImagesSettings(mogrify_info,*images,exception);
7856 magnitude_image=RemoveFirstImageFromList(images);
7857 phase_image=RemoveFirstImageFromList(images);
7858 if (phase_image == (Image *) NULL)
7863 fourier_image=InverseFourierTransformImage(magnitude_image,
7864 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7865 if (fourier_image == (Image *) NULL)
7867 if (*images != (Image *) NULL)
7868 *images=DestroyImage(*images);
7869 *images=fourier_image;
7872 if (LocaleCompare("insert",option+1) == 0)
7880 index=(ssize_t) StringToLong(argv[i+1]);
7881 p=RemoveLastImageFromList(images);
7882 if (p == (Image *) NULL)
7884 (void) ThrowMagickException(exception,GetMagickModule(),
7885 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7891 PrependImageToList(images,q);
7893 if (index == (ssize_t) GetImageListLength(*images))
7894 AppendImageToList(images,q);
7897 q=GetImageFromList(*images,index-1);
7898 if (q == (Image *) NULL)
7900 (void) ThrowMagickException(exception,GetMagickModule(),
7901 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7905 InsertImageInList(&q,p);
7907 *images=GetFirstImageInList(q);
7910 if (LocaleCompare("interpolate",option+1) == 0)
7912 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7913 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7920 if (LocaleCompare("layers",option+1) == 0)
7928 (void) SyncImagesSettings(mogrify_info,*images,exception);
7929 layers=(Image *) NULL;
7930 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
7931 MagickFalse,argv[i+1]);
7936 layers=CoalesceImages(*images,exception);
7939 case CompareAnyLayer:
7940 case CompareClearLayer:
7941 case CompareOverlayLayer:
7944 layers=CompareImagesLayers(*images,method,exception);
7950 case TrimBoundsLayer:
7952 layers=MergeImageLayers(*images,method,exception);
7957 layers=DisposeImages(*images,exception);
7960 case OptimizeImageLayer:
7962 layers=OptimizeImageLayers(*images,exception);
7965 case OptimizePlusLayer:
7967 layers=OptimizePlusImageLayers(*images,exception);
7970 case OptimizeTransLayer:
7972 OptimizeImageTransparency(*images,exception);
7975 case RemoveDupsLayer:
7977 RemoveDuplicateLayers(images,exception);
7980 case RemoveZeroLayer:
7982 RemoveZeroDelayLayers(images,exception);
7988 General Purpose, GIF Animation Optimizer.
7990 layers=CoalesceImages(*images,exception);
7991 if (layers == (Image *) NULL)
7996 *images=DestroyImageList(*images);
7998 layers=OptimizeImageLayers(*images,exception);
7999 if (layers == (Image *) NULL)
8004 *images=DestroyImageList(*images);
8006 layers=(Image *) NULL;
8007 OptimizeImageTransparency(*images,exception);
8008 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8012 case CompositeLayer:
8024 Split image sequence at the first 'NULL:' image.
8027 while (source != (Image *) NULL)
8029 source=GetNextImageInList(source);
8030 if ((source != (Image *) NULL) &&
8031 (LocaleCompare(source->magick,"NULL") == 0))
8034 if (source != (Image *) NULL)
8036 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8037 (GetNextImageInList(source) == (Image *) NULL))
8038 source=(Image *) NULL;
8042 Separate the two lists, junk the null: image.
8044 source=SplitImageList(source->previous);
8045 DeleteImageFromList(&source);
8048 if (source == (Image *) NULL)
8050 (void) ThrowMagickException(exception,GetMagickModule(),
8051 OptionError,"MissingNullSeparator","layers Composite");
8056 Adjust offset with gravity and virtual canvas.
8058 SetGeometry(*images,&geometry);
8059 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8060 geometry.width=source->page.width != 0 ?
8061 source->page.width : source->columns;
8062 geometry.height=source->page.height != 0 ?
8063 source->page.height : source->rows;
8064 GravityAdjustGeometry((*images)->page.width != 0 ?
8065 (*images)->page.width : (*images)->columns,
8066 (*images)->page.height != 0 ? (*images)->page.height :
8067 (*images)->rows,(*images)->gravity,&geometry);
8068 compose=OverCompositeOp;
8069 option=GetImageOption(mogrify_info,"compose");
8070 if (option != (const char *) NULL)
8071 compose=(CompositeOperator) ParseCommandOption(
8072 MagickComposeOptions,MagickFalse,option);
8073 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8075 source=DestroyImageList(source);
8079 if (layers == (Image *) NULL)
8081 *images=DestroyImageList(*images);
8089 if (LocaleCompare("map",option+1) == 0)
8091 (void) SyncImagesSettings(mogrify_info,*images,exception);
8094 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8101 if (LocaleCompare("maximum",option+1) == 0)
8107 Maximum image sequence (deprecated).
8109 (void) SyncImagesSettings(mogrify_info,*images,exception);
8110 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8111 if (maximum_image == (Image *) NULL)
8116 *images=DestroyImageList(*images);
8117 *images=maximum_image;
8120 if (LocaleCompare("minimum",option+1) == 0)
8126 Minimum image sequence (deprecated).
8128 (void) SyncImagesSettings(mogrify_info,*images,exception);
8129 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8130 if (minimum_image == (Image *) NULL)
8135 *images=DestroyImageList(*images);
8136 *images=minimum_image;
8139 if (LocaleCompare("morph",option+1) == 0)
8144 (void) SyncImagesSettings(mogrify_info,*images,exception);
8145 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8147 if (morph_image == (Image *) NULL)
8152 *images=DestroyImageList(*images);
8153 *images=morph_image;
8156 if (LocaleCompare("mosaic",option+1) == 0)
8161 (void) SyncImagesSettings(mogrify_info,*images,exception);
8162 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8163 if (mosaic_image == (Image *) NULL)
8168 *images=DestroyImageList(*images);
8169 *images=mosaic_image;
8176 if (LocaleCompare("poly",option+1) == 0)
8180 token[MaxTextExtent];
8200 (void) SyncImageSettings(mogrify_info,*images,exception);
8201 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8203 if (args == (char *) NULL)
8206 for (x=0; *p != '\0'; x++)
8208 GetMagickToken(p,&p,token);
8210 GetMagickToken(p,&p,token);
8212 number_arguments=(size_t) x;
8213 arguments=(double *) AcquireQuantumMemory(number_arguments,
8214 sizeof(*arguments));
8215 if (arguments == (double *) NULL)
8216 ThrowWandFatalException(ResourceLimitFatalError,
8217 "MemoryAllocationFailed",(*images)->filename);
8218 (void) ResetMagickMemory(arguments,0,number_arguments*
8219 sizeof(*arguments));
8221 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8223 GetMagickToken(p,&p,token);
8225 GetMagickToken(p,&p,token);
8226 arguments[x]=StringToDouble(token,(char **) NULL);
8228 args=DestroyString(args);
8229 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8230 arguments,exception);
8231 arguments=(double *) RelinquishMagickMemory(arguments);
8232 if (polynomial_image == (Image *) NULL)
8237 *images=DestroyImageList(*images);
8238 *images=polynomial_image;
8240 if (LocaleCompare("print",option+1) == 0)
8245 (void) SyncImagesSettings(mogrify_info,*images,exception);
8246 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8248 if (string == (char *) NULL)
8250 (void) FormatLocaleFile(stdout,"%s",string);
8251 string=DestroyString(string);
8253 if (LocaleCompare("process",option+1) == 0)
8262 (void) SyncImagesSettings(mogrify_info,*images,exception);
8263 arguments=StringToArgv(argv[i+1],&number_arguments);
8264 if (arguments == (char **) NULL)
8266 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8287 Support old style syntax, filter="-option arg".
8289 length=strlen(argv[i+1]);
8290 token=(char *) NULL;
8291 if (~length >= (MaxTextExtent-1))
8292 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8294 if (token == (char *) NULL)
8297 arguments=argv[i+1];
8298 token_info=AcquireTokenInfo();
8299 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8300 "\"",'\0',&breaker,&next,"e);
8301 token_info=DestroyTokenInfo(token_info);
8307 argv=(&(arguments[next]));
8308 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8311 token=DestroyString(token);
8314 (void) SubstituteString(&arguments[1],"-","");
8315 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8316 number_arguments-2,(const char **) arguments+2,exception);
8317 for (j=0; j < number_arguments; j++)
8318 arguments[j]=DestroyString(arguments[j]);
8319 arguments=(char **) RelinquishMagickMemory(arguments);
8326 if (LocaleCompare("reverse",option+1) == 0)
8328 ReverseImageList(images);
8335 if (LocaleCompare("smush",option+1) == 0)
8343 (void) SyncImagesSettings(mogrify_info,*images,exception);
8344 offset=(ssize_t) StringToLong(argv[i+1]);
8345 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8346 MagickFalse,offset,exception);
8347 if (smush_image == (Image *) NULL)
8352 *images=DestroyImageList(*images);
8353 *images=smush_image;
8356 if (LocaleCompare("swap",option+1) == 0)
8377 flags=ParseGeometry(argv[i+1],&geometry_info);
8378 index=(ssize_t) geometry_info.rho;
8379 if ((flags & SigmaValue) != 0)
8380 swap_index=(ssize_t) geometry_info.sigma;
8382 p=GetImageFromList(*images,index);
8383 q=GetImageFromList(*images,swap_index);
8384 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8386 (void) ThrowMagickException(exception,GetMagickModule(),
8387 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8393 swap=CloneImage(p,0,0,MagickTrue,exception);
8394 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8395 ReplaceImageInList(&q,swap);
8396 *images=GetFirstImageInList(q);
8403 if (LocaleCompare("write",option+1) == 0)
8414 (void) SyncImagesSettings(mogrify_info,*images,exception);
8415 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8416 (void) DeleteImageRegistry(key);
8417 write_images=(*images);
8419 write_images=CloneImageList(*images,exception);
8420 write_info=CloneImageInfo(mogrify_info);
8421 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8422 write_info=DestroyImageInfo(write_info);
8424 write_images=DestroyImageList(write_images);
8434 quantize_info=DestroyQuantizeInfo(quantize_info);
8435 mogrify_info=DestroyImageInfo(mogrify_info);
8436 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8437 return(status != 0 ? MagickTrue : MagickFalse);
8441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8445 + M o g r i f y I m a g e s %
8449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8451 % MogrifyImages() applies image processing options to a sequence of images as
8452 % prescribed by command line options.
8454 % The format of the MogrifyImage method is:
8456 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8457 % const MagickBooleanType post,const int argc,const char **argv,
8458 % Image **images,Exceptioninfo *exception)
8460 % A description of each parameter follows:
8462 % o image_info: the image info..
8464 % o post: If true, post process image list operators otherwise pre-process.
8466 % o argc: Specifies a pointer to an integer describing the number of
8467 % elements in the argument vector.
8469 % o argv: Specifies a pointer to a text array containing the command line
8472 % o images: pointer to a pointer of the first image in image list.
8474 % o exception: return any errors or warnings in this structure.
8477 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8478 const MagickBooleanType post,const int argc,const char **argv,
8479 Image **images,ExceptionInfo *exception)
8481 #define MogrifyImageTag "Mogrify/Image"
8495 assert(image_info != (ImageInfo *) NULL);
8496 assert(image_info->signature == MagickSignature);
8497 if (images == (Image **) NULL)
8498 return(MogrifyImage(image_info,argc,argv,images,exception));
8499 assert((*images)->previous == (Image *) NULL);
8500 assert((*images)->signature == MagickSignature);
8501 if ((*images)->debug != MagickFalse)
8502 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8503 (*images)->filename);
8504 if ((argc <= 0) || (*argv == (char *) NULL))
8506 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8511 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8516 Pre-process multi-image sequence operators
8518 if (post == MagickFalse)
8519 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8521 For each image, process simple single image operators
8524 n=GetImageListLength(*images);
8528 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8529 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8531 status&=MogrifyImage(image_info,argc,argv,images,exception);
8532 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8533 if (proceed == MagickFalse)
8535 if ( (*images)->next == (Image *) NULL )
8537 *images=(*images)->next;
8540 assert( *images != (Image *) NULL );
8542 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8543 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8547 Post-process, multi-image sequence operators
8549 *images=GetFirstImageInList(*images);
8550 if (post != MagickFalse)
8551 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8552 return(status != 0 ? MagickTrue : MagickFalse);