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-2014 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/magick-wand-private.h"
50 #include "MagickWand/mogrify-private.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/string-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/utility-private.h"
61 MogrifyBackgroundColor[] = "#ffffff", /* white */
62 MogrifyBorderColor[] = "#dfdfdf", /* gray */
63 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
68 #define UndefinedCompressionQuality 0UL
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % M a g i c k C o m m a n d G e n e s i s %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % MagickCommandGenesis() applies image processing options to an image as
82 % prescribed by command line options.
84 % It wiil look for special options like "-debug", "-bench", and
85 % "-distribute-cache" that needs to be applied even before the main
86 % processing begins, and may completely overrule normal command processing.
87 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
88 % and are typically ignored (as they have been handled) if seen later.
90 % The format of the MagickCommandGenesis method is:
92 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
93 % MagickCommand command,int argc,char **argv,char **metadata,
94 % ExceptionInfo *exception)
96 % A description of each parameter follows:
98 % o image_info: the image info.
100 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
101 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
102 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
103 % DisplayImageCommand, or AnimateImageCommand.
105 % o argc: Specifies a pointer to an integer describing the number of
106 % elements in the argument vector.
108 % o argv: Specifies a pointer to a text array containing the command line
111 % o metadata: any metadata is returned here.
113 % o exception: return any errors or warnings in this structure.
116 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
117 MagickCommand command,int argc,char **argv,char **metadata,
118 ExceptionInfo *exception)
142 (void) setlocale(LC_ALL,"");
143 (void) setlocale(LC_NUMERIC,"C");
144 concurrent=MagickFalse;
148 regard_warnings=MagickFalse;
149 for (i=1; i < (ssize_t) (argc-1); i++)
152 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
154 if (LocaleCompare("-bench",option) == 0)
155 iterations=StringToUnsignedLong(argv[++i]);
156 if (LocaleCompare("-concurrent",option) == 0)
157 concurrent=MagickTrue;
158 if (LocaleCompare("-debug",option) == 0)
159 (void) SetLogEventMask(argv[++i]);
160 if (LocaleCompare("-distribute-cache",option) == 0)
162 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
165 if (LocaleCompare("-duration",option) == 0)
166 duration=StringToDouble(argv[++i],(char **) NULL);
167 if (LocaleCompare("-regard-warnings",option) == 0)
168 regard_warnings=MagickTrue;
172 status=command(image_info,argc,argv,metadata,exception);
173 if (exception->severity != UndefinedException)
175 if ((exception->severity > ErrorException) ||
176 (regard_warnings != MagickFalse))
178 CatchException(exception);
180 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
182 (void) fputs(*metadata,stdout);
183 *metadata=DestroyString(*metadata);
187 number_threads=GetOpenMPMaximumThreads();
189 for (n=1; n <= (ssize_t) number_threads; n++)
199 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
200 timer=AcquireTimerInfo();
201 if (concurrent == MagickFalse)
203 for (i=0; i < (ssize_t) iterations; i++)
205 if (status != MagickFalse)
209 if (GetElapsedTime(timer) > duration)
211 (void) ContinueTimer(timer);
213 status=command(image_info,argc,argv,metadata,exception);
214 if (exception->severity != UndefinedException)
216 if ((exception->severity > ErrorException) ||
217 (regard_warnings != MagickFalse))
219 CatchException(exception);
221 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
223 (void) fputs(*metadata,stdout);
224 *metadata=DestroyString(*metadata);
231 #if defined(MAGICKCORE_OPENMP_SUPPORT)
232 # pragma omp parallel for shared(status)
234 for (i=0; i < (ssize_t) iterations; i++)
236 if (status != MagickFalse)
240 if (GetElapsedTime(timer) > duration)
242 (void) ContinueTimer(timer);
244 status=command(image_info,argc,argv,metadata,exception);
245 #if defined(MAGICKCORE_OPENMP_SUPPORT)
246 # pragma omp critical (MagickCore_CommandGenesis)
249 if (exception->severity != UndefinedException)
251 if ((exception->severity > ErrorException) ||
252 (regard_warnings != MagickFalse))
254 CatchException(exception);
256 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
258 (void) fputs(*metadata,stdout);
259 *metadata=DestroyString(*metadata);
264 user_time=GetUserTime(timer);
265 parallel=GetElapsedTime(timer);
270 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
271 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
272 (void) FormatLocaleFile(stderr,
273 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
274 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
275 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
276 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
277 timer=DestroyTimerInfo(timer);
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 + M o g r i f y I m a g e %
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 % MogrifyImage() applies simple single image processing options to a single
294 % image that may be part of a large list, but also handles any 'region'
297 % The image in the list may be modified in three different ways...
299 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
300 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
301 % * replace by a list of images (only the -separate option!)
303 % In each case the result is returned into the list, and a pointer to the
304 % modified image (last image added if replaced by a list of images) is
307 % ASIDE: The -crop is present but restricted to non-tile single image crops
309 % This means if all the images are being processed (such as by
310 % MogrifyImages(), next image to be processed will be as per the pointer
311 % (*image)->next. Also the image list may grow as a result of some specific
312 % operations but as images are never merged or deleted, it will never shrink
313 % in length. Typically the list will remain the same length.
315 % WARNING: As the image pointed to may be replaced, the first image in the
316 % list may also change. GetFirstImageInList() should be used by caller if
317 % they wish return the Image pointer to the first image in list.
320 % The format of the MogrifyImage method is:
322 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
323 % const char **argv,Image **image)
325 % A description of each parameter follows:
327 % o image_info: the image info..
329 % o argc: Specifies a pointer to an integer describing the number of
330 % elements in the argument vector.
332 % o argv: Specifies a pointer to a text array containing the command line
335 % o image: the image.
337 % o exception: return any errors or warnings in this structure.
341 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
342 ExceptionInfo *exception)
357 Read an image into a image cache (for repeated usage) if not already in
358 cache. Then return the image that is in the cache.
360 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
361 sans_exception=AcquireExceptionInfo();
362 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
363 sans_exception=DestroyExceptionInfo(sans_exception);
364 if (image != (Image *) NULL)
366 read_info=CloneImageInfo(image_info);
367 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
368 image=ReadImage(read_info,exception);
369 read_info=DestroyImageInfo(read_info);
370 if (image != (Image *) NULL)
371 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
375 static inline MagickBooleanType IsPathWritable(const char *path)
377 if (IsPathAccessible(path) == MagickFalse)
379 if (access_utf8(path,W_OK) != 0)
384 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
391 static MagickBooleanType MonitorProgress(const char *text,
392 const MagickOffsetType offset,const MagickSizeType extent,
393 void *wand_unused(client_data))
396 message[MaxTextExtent],
407 (void) CopyMagickMemory(tag,text,MaxTextExtent);
409 if (p != (char *) NULL)
411 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
412 locale_message=GetLocaleMessage(message);
413 if (locale_message == message)
415 if (p == (char *) NULL)
416 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
417 locale_message,(long) offset,(unsigned long) extent,(long)
418 (100L*offset/(extent-1)));
420 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
421 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
422 (100L*offset/(extent-1)));
423 if (offset == (MagickOffsetType) (extent-1))
424 (void) FormatLocaleFile(stderr,"\n");
425 (void) fflush(stderr);
429 static Image *SparseColorOption(const Image *image,
430 const SparseColorMethod method,const char *arguments,
431 const MagickBooleanType color_from_image,ExceptionInfo *exception)
434 token[MaxTextExtent];
459 SparseColorOption() parses the complex -sparse-color argument into an an
460 array of floating point values then calls SparseColorImage(). Argument is
461 a complex mix of floating-point pixel coodinates, and color specifications
462 (or direct floating point numbers). The number of floats needed to
463 represent a color varies depending on the current channel setting.
465 assert(image != (Image *) NULL);
466 assert(image->signature == MagickSignature);
467 if (image->debug != MagickFalse)
468 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
469 assert(exception != (ExceptionInfo *) NULL);
470 assert(exception->signature == MagickSignature);
472 Limit channels according to image - and add up number of color channel.
475 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
477 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
479 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
481 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
482 (image->colorspace == CMYKColorspace))
484 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
485 (image->alpha_trait == BlendPixelTrait))
489 Read string, to determine number of arguments needed,
495 GetMagickToken(p,&p,token);
496 if ( token[0] == ',' ) continue;
497 if ( isalpha((int) token[0]) || token[0] == '#' ) {
498 if ( color_from_image ) {
499 (void) ThrowMagickException(exception,GetMagickModule(),
500 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
501 "Color arg given, when colors are coming from image");
502 return( (Image *)NULL);
504 x += number_colors; /* color argument */
507 x++; /* floating point argument */
511 if ( color_from_image ) {
512 /* just the control points are being given */
513 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
514 number_arguments=(x/2)*(2+number_colors);
517 /* control points and color values */
518 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
522 (void) ThrowMagickException(exception,GetMagickModule(),
523 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
524 "Invalid number of Arguments");
525 return( (Image *)NULL);
528 /* Allocate and fill in the floating point arguments */
529 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
530 sizeof(*sparse_arguments));
531 if (sparse_arguments == (double *) NULL) {
532 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
533 "MemoryAllocationFailed","%s","SparseColorOption");
534 return( (Image *)NULL);
536 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
537 sizeof(*sparse_arguments));
540 while( *p != '\0' && x < number_arguments ) {
542 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
543 if ( token[0] == '\0' ) break;
544 if ( isalpha((int) token[0]) || token[0] == '#' ) {
545 (void) ThrowMagickException(exception,GetMagickModule(),
546 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
547 "Color found, instead of X-coord");
551 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
553 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
554 if ( token[0] == '\0' ) break;
555 if ( isalpha((int) token[0]) || token[0] == '#' ) {
556 (void) ThrowMagickException(exception,GetMagickModule(),
557 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
558 "Color found, instead of Y-coord");
562 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
563 /* color values for this control point */
565 if ( (color_from_image ) {
566 /* get color from image */
572 /* color name or function given in string argument */
573 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
574 if ( token[0] == '\0' ) break;
575 if ( isalpha((int) token[0]) || token[0] == '#' ) {
576 /* Color string given */
577 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
578 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
579 sparse_arguments[x++] = QuantumScale*color.red;
580 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
581 sparse_arguments[x++] = QuantumScale*color.green;
582 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
583 sparse_arguments[x++] = QuantumScale*color.blue;
584 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
585 (image->colorspace == CMYKColorspace))
586 sparse_arguments[x++] = QuantumScale*color.black;
587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
588 (image->alpha_trait == BlendPixelTrait))
589 sparse_arguments[x++] = QuantumScale*color.alpha;
592 /* Colors given as a set of floating point values - experimental */
593 /* NB: token contains the first floating point value to use! */
594 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
596 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
597 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
599 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
600 token[0] = ','; /* used this token - get another */
602 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
604 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
605 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
607 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
608 token[0] = ','; /* used this token - get another */
610 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
612 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
613 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
615 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
616 token[0] = ','; /* used this token - get another */
618 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
619 (image->colorspace == CMYKColorspace))
621 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
622 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
624 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
625 token[0] = ','; /* used this token - get another */
627 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
628 (image->alpha_trait == BlendPixelTrait))
630 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
631 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
633 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
634 token[0] = ','; /* used this token - get another */
639 if ( number_arguments != x && !error ) {
640 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
641 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
642 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
643 return( (Image *)NULL);
646 return( (Image *)NULL);
648 /* Call the Interpolation function with the parsed arguments */
649 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
651 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
652 return( sparse_image );
655 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
656 const char **argv,Image **image,ExceptionInfo *exception)
689 PixelInterpolateMethod
703 Initialize method variables.
705 assert(image_info != (const ImageInfo *) NULL);
706 assert(image_info->signature == MagickSignature);
707 assert(image != (Image **) NULL);
708 assert((*image)->signature == MagickSignature);
709 if ((*image)->debug != MagickFalse)
710 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
713 mogrify_info=CloneImageInfo(image_info);
714 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
715 quantize_info=AcquireQuantizeInfo(mogrify_info);
716 SetGeometryInfo(&geometry_info);
717 GetPixelInfo(*image,&fill);
718 fill=(*image)->background_color;
720 compose=(*image)->compose;
721 interpolate_method=UndefinedInterpolatePixel;
722 format=GetImageOption(mogrify_info,"format");
723 SetGeometry(*image,®ion_geometry);
724 region_image=NewImageList();
726 Transmogrify the image.
728 for (i=0; i < (ssize_t) argc; i++)
737 if (IsCommandOption(option) == MagickFalse)
739 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
741 if ((i+count) >= (ssize_t) argc)
743 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
744 mogrify_image=(Image *)NULL;
749 if (LocaleCompare("adaptive-blur",option+1) == 0)
754 (void) SyncImageSettings(mogrify_info,*image,exception);
755 flags=ParseGeometry(argv[i+1],&geometry_info);
756 if ((flags & SigmaValue) == 0)
757 geometry_info.sigma=1.0;
758 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
759 geometry_info.sigma,exception);
762 if (LocaleCompare("adaptive-resize",option+1) == 0)
765 Adaptive resize image.
767 (void) SyncImageSettings(mogrify_info,*image,exception);
768 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
769 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
770 geometry.height,exception);
773 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
776 Adaptive sharpen image.
778 (void) SyncImageSettings(mogrify_info,*image,exception);
779 flags=ParseGeometry(argv[i+1],&geometry_info);
780 if ((flags & SigmaValue) == 0)
781 geometry_info.sigma=1.0;
782 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
783 geometry_info.sigma,exception);
786 if (LocaleCompare("affine",option+1) == 0)
793 GetAffineMatrix(&draw_info->affine);
796 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
799 if (LocaleCompare("alpha",option+1) == 0)
804 (void) SyncImageSettings(mogrify_info,*image,exception);
805 alpha_type=(AlphaChannelOption) ParseCommandOption(
806 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
807 (void) SetImageAlphaChannel(*image,alpha_type,exception);
810 if (LocaleCompare("annotate",option+1) == 0)
814 geometry[MaxTextExtent];
819 (void) SyncImageSettings(mogrify_info,*image,exception);
820 SetGeometryInfo(&geometry_info);
821 flags=ParseGeometry(argv[i+1],&geometry_info);
822 if ((flags & SigmaValue) == 0)
823 geometry_info.sigma=geometry_info.rho;
824 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
826 if (text == (char *) NULL)
828 (void) CloneString(&draw_info->text,text);
829 text=DestroyString(text);
830 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
831 geometry_info.xi,geometry_info.psi);
832 (void) CloneString(&draw_info->geometry,geometry);
833 draw_info->affine.sx=cos(DegreesToRadians(
834 fmod(geometry_info.rho,360.0)));
835 draw_info->affine.rx=sin(DegreesToRadians(
836 fmod(geometry_info.rho,360.0)));
837 draw_info->affine.ry=(-sin(DegreesToRadians(
838 fmod(geometry_info.sigma,360.0))));
839 draw_info->affine.sy=cos(DegreesToRadians(
840 fmod(geometry_info.sigma,360.0)));
841 (void) AnnotateImage(*image,draw_info,exception);
844 if (LocaleCompare("antialias",option+1) == 0)
846 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
848 draw_info->text_antialias=(*option == '-') ? MagickTrue :
852 if (LocaleCompare("attenuate",option+1) == 0)
859 attenuate=StringToDouble(argv[i+1],(char **) NULL);
862 if (LocaleCompare("auto-gamma",option+1) == 0)
865 Auto Adjust Gamma of image based on its mean
867 (void) SyncImageSettings(mogrify_info,*image,exception);
868 (void) AutoGammaImage(*image,exception);
871 if (LocaleCompare("auto-level",option+1) == 0)
874 Perfectly Normalize (max/min stretch) the image
876 (void) SyncImageSettings(mogrify_info,*image,exception);
877 (void) AutoLevelImage(*image,exception);
880 if (LocaleCompare("auto-orient",option+1) == 0)
882 (void) SyncImageSettings(mogrify_info,*image,exception);
883 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
891 if (LocaleCompare("black-threshold",option+1) == 0)
894 Black threshold image.
896 (void) SyncImageSettings(mogrify_info,*image,exception);
897 (void) BlackThresholdImage(*image,argv[i+1],exception);
900 if (LocaleCompare("blue-shift",option+1) == 0)
905 (void) SyncImageSettings(mogrify_info,*image,exception);
906 geometry_info.rho=1.5;
908 flags=ParseGeometry(argv[i+1],&geometry_info);
909 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
912 if (LocaleCompare("blur",option+1) == 0)
917 (void) SyncImageSettings(mogrify_info,*image,exception);
918 flags=ParseGeometry(argv[i+1],&geometry_info);
919 if ((flags & SigmaValue) == 0)
920 geometry_info.sigma=1.0;
921 if ((flags & XiValue) == 0)
922 geometry_info.xi=0.0;
923 mogrify_image=BlurImage(*image,geometry_info.rho,
924 geometry_info.sigma,exception);
927 if (LocaleCompare("border",option+1) == 0)
930 Surround image with a border of solid color.
932 (void) SyncImageSettings(mogrify_info,*image,exception);
933 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
934 mogrify_image=BorderImage(*image,&geometry,compose,exception);
937 if (LocaleCompare("bordercolor",option+1) == 0)
941 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
942 &draw_info->border_color,exception);
945 (void) QueryColorCompliance(argv[i+1],AllCompliance,
946 &draw_info->border_color,exception);
949 if (LocaleCompare("box",option+1) == 0)
951 (void) QueryColorCompliance(argv[i+1],AllCompliance,
952 &draw_info->undercolor,exception);
955 if (LocaleCompare("brightness-contrast",option+1) == 0)
968 Brightness / contrast image.
970 (void) SyncImageSettings(mogrify_info,*image,exception);
971 flags=ParseGeometry(argv[i+1],&geometry_info);
972 brightness=geometry_info.rho;
974 if ((flags & SigmaValue) != 0)
975 contrast=geometry_info.sigma;
976 (void) BrightnessContrastImage(*image,brightness,contrast,
984 if (LocaleCompare("canny",option+1) == 0)
987 Detect edges in the image.
989 (void) SyncImageSettings(mogrify_info,*image,exception);
990 flags=ParseGeometry(argv[i+1],&geometry_info);
991 if ((flags & SigmaValue) == 0)
992 geometry_info.sigma=1.0;
993 if ((flags & XiValue) == 0)
994 geometry_info.xi=0.10;
995 if ((flags & PsiValue) == 0)
996 geometry_info.psi=0.30;
997 if ((flags & PercentValue) != 0)
999 geometry_info.xi/=100.0;
1000 geometry_info.psi/=100.0;
1002 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
1003 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
1006 if (LocaleCompare("cdl",option+1) == 0)
1009 *color_correction_collection;
1012 Color correct with a color decision list.
1014 (void) SyncImageSettings(mogrify_info,*image,exception);
1015 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1016 if (color_correction_collection == (char *) NULL)
1018 (void) ColorDecisionListImage(*image,color_correction_collection,
1022 if (LocaleCompare("charcoal",option+1) == 0)
1027 (void) SyncImageSettings(mogrify_info,*image,exception);
1028 flags=ParseGeometry(argv[i+1],&geometry_info);
1029 if ((flags & SigmaValue) == 0)
1030 geometry_info.sigma=1.0;
1031 if ((flags & XiValue) == 0)
1032 geometry_info.xi=1.0;
1033 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1034 geometry_info.sigma,exception);
1037 if (LocaleCompare("chop",option+1) == 0)
1042 (void) SyncImageSettings(mogrify_info,*image,exception);
1043 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1044 mogrify_image=ChopImage(*image,&geometry,exception);
1047 if (LocaleCompare("perceptible",option+1) == 0)
1052 (void) SyncImageSettings(mogrify_info,*image,exception);
1053 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
1054 (char **) NULL),exception);
1057 if (LocaleCompare("clip",option+1) == 0)
1059 (void) SyncImageSettings(mogrify_info,*image,exception);
1062 (void) SetImageMask(*image,(Image *) NULL,exception);
1065 (void) ClipImage(*image,exception);
1068 if (LocaleCompare("clip-mask",option+1) == 0)
1085 (void) SyncImageSettings(mogrify_info,*image,exception);
1091 (void) SetImageMask(*image,(Image *) NULL,exception);
1096 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1098 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1099 if (mask_image == (Image *) NULL)
1101 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1102 return(MagickFalse);
1103 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1104 for (y=0; y < (ssize_t) mask_image->rows; y++)
1106 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1108 if (q == (Quantum *) NULL)
1110 for (x=0; x < (ssize_t) mask_image->columns; x++)
1112 if (mask_image->alpha_trait != BlendPixelTrait)
1113 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1114 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1115 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1116 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1117 q+=GetPixelChannels(mask_image);
1119 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1122 mask_view=DestroyCacheView(mask_view);
1123 mask_image->alpha_trait=BlendPixelTrait;
1124 (void) SetImageMask(*image,mask_image,exception);
1127 if (LocaleCompare("clip-path",option+1) == 0)
1129 (void) SyncImageSettings(mogrify_info,*image,exception);
1130 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1131 MagickFalse,exception);
1134 if (LocaleCompare("colorize",option+1) == 0)
1139 (void) SyncImageSettings(mogrify_info,*image,exception);
1140 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1143 if (LocaleCompare("color-matrix",option+1) == 0)
1148 (void) SyncImageSettings(mogrify_info,*image,exception);
1149 kernel=AcquireKernelInfo(argv[i+1]);
1150 if (kernel == (KernelInfo *) NULL)
1152 /* FUTURE: check on size of the matrix */
1153 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1154 kernel=DestroyKernelInfo(kernel);
1157 if (LocaleCompare("colors",option+1) == 0)
1160 Reduce the number of colors in the image.
1162 (void) SyncImageSettings(mogrify_info,*image,exception);
1163 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1164 if (quantize_info->number_colors == 0)
1166 if (((*image)->storage_class == DirectClass) ||
1167 (*image)->colors > quantize_info->number_colors)
1168 (void) QuantizeImage(quantize_info,*image,exception);
1170 (void) CompressImageColormap(*image,exception);
1173 if (LocaleCompare("colorspace",option+1) == 0)
1178 (void) SyncImageSettings(mogrify_info,*image,exception);
1181 (void) TransformImageColorspace(*image,sRGBColorspace,
1185 colorspace=(ColorspaceType) ParseCommandOption(
1186 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1187 (void) TransformImageColorspace(*image,colorspace,exception);
1190 if (LocaleCompare("compose",option+1) == 0)
1192 (void) SyncImageSettings(mogrify_info,*image,exception);
1193 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1194 MagickFalse,argv[i+1]);
1197 if (LocaleCompare("contrast",option+1) == 0)
1199 (void) SyncImageSettings(mogrify_info,*image,exception);
1200 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1201 MagickFalse,exception);
1204 if (LocaleCompare("contrast-stretch",option+1) == 0)
1214 Contrast stretch image.
1216 (void) SyncImageSettings(mogrify_info,*image,exception);
1217 flags=ParseGeometry(argv[i+1],&geometry_info);
1218 black_point=geometry_info.rho;
1219 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1221 if ((flags & PercentValue) != 0)
1223 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1224 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1226 white_point=(double) (*image)->columns*(*image)->rows-
1228 (void) ContrastStretchImage(*image,black_point,white_point,
1232 if (LocaleCompare("convolve",option+1) == 0)
1237 (void) SyncImageSettings(mogrify_info,*image,exception);
1238 kernel_info=AcquireKernelInfo(argv[i+1]);
1239 if (kernel_info == (KernelInfo *) NULL)
1241 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1242 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1243 kernel_info,exception);
1244 kernel_info=DestroyKernelInfo(kernel_info);
1247 if (LocaleCompare("crop",option+1) == 0)
1250 Crop a image to a smaller size
1252 (void) SyncImageSettings(mogrify_info,*image,exception);
1253 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1256 if (LocaleCompare("cycle",option+1) == 0)
1259 Cycle an image colormap.
1261 (void) SyncImageSettings(mogrify_info,*image,exception);
1262 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1270 if (LocaleCompare("decipher",option+1) == 0)
1278 (void) SyncImageSettings(mogrify_info,*image,exception);
1279 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1280 if (passkey != (StringInfo *) NULL)
1282 (void) PasskeyDecipherImage(*image,passkey,exception);
1283 passkey=DestroyStringInfo(passkey);
1287 if (LocaleCompare("density",option+1) == 0)
1292 (void) CloneString(&draw_info->density,argv[i+1]);
1295 if (LocaleCompare("depth",option+1) == 0)
1297 (void) SyncImageSettings(mogrify_info,*image,exception);
1300 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1303 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1307 if (LocaleCompare("deskew",option+1) == 0)
1313 Straighten the image.
1315 (void) SyncImageSettings(mogrify_info,*image,exception);
1317 threshold=40.0*QuantumRange/100.0;
1319 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1321 mogrify_image=DeskewImage(*image,threshold,exception);
1324 if (LocaleCompare("despeckle",option+1) == 0)
1327 Reduce the speckles within an image.
1329 (void) SyncImageSettings(mogrify_info,*image,exception);
1330 mogrify_image=DespeckleImage(*image,exception);
1333 if (LocaleCompare("display",option+1) == 0)
1335 (void) CloneString(&draw_info->server_name,argv[i+1]);
1338 if (LocaleCompare("distort",option+1) == 0)
1342 token[MaxTextExtent];
1362 (void) SyncImageSettings(mogrify_info,*image,exception);
1363 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1364 MagickFalse,argv[i+1]);
1365 if (method == ResizeDistortion)
1371 Special Case - Argument is actually a resize geometry!
1372 Convert that to an appropriate distortion argument array.
1374 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1376 resize_args[0]=(double) geometry.width;
1377 resize_args[1]=(double) geometry.height;
1378 mogrify_image=DistortImage(*image,method,(size_t)2,
1379 resize_args,MagickTrue,exception);
1382 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1384 if (args == (char *) NULL)
1387 for (x=0; *p != '\0'; x++)
1389 GetMagickToken(p,&p,token);
1391 GetMagickToken(p,&p,token);
1393 number_arguments=(size_t) x;
1394 arguments=(double *) AcquireQuantumMemory(number_arguments,
1395 sizeof(*arguments));
1396 if (arguments == (double *) NULL)
1397 ThrowWandFatalException(ResourceLimitFatalError,
1398 "MemoryAllocationFailed",(*image)->filename);
1399 (void) ResetMagickMemory(arguments,0,number_arguments*
1400 sizeof(*arguments));
1402 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1404 GetMagickToken(p,&p,token);
1406 GetMagickToken(p,&p,token);
1407 arguments[x]=StringToDouble(token,(char **) NULL);
1409 args=DestroyString(args);
1410 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1411 (*option == '+') ? MagickTrue : MagickFalse,exception);
1412 arguments=(double *) RelinquishMagickMemory(arguments);
1415 if (LocaleCompare("dither",option+1) == 0)
1419 quantize_info->dither_method=NoDitherMethod;
1422 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1423 MagickDitherOptions,MagickFalse,argv[i+1]);
1426 if (LocaleCompare("draw",option+1) == 0)
1431 (void) SyncImageSettings(mogrify_info,*image,exception);
1432 (void) CloneString(&draw_info->primitive,argv[i+1]);
1433 (void) DrawImage(*image,draw_info,exception);
1440 if (LocaleCompare("edge",option+1) == 0)
1443 Enhance edges in the image.
1445 (void) SyncImageSettings(mogrify_info,*image,exception);
1446 flags=ParseGeometry(argv[i+1],&geometry_info);
1447 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1450 if (LocaleCompare("emboss",option+1) == 0)
1455 (void) SyncImageSettings(mogrify_info,*image,exception);
1456 flags=ParseGeometry(argv[i+1],&geometry_info);
1457 if ((flags & SigmaValue) == 0)
1458 geometry_info.sigma=1.0;
1459 mogrify_image=EmbossImage(*image,geometry_info.rho,
1460 geometry_info.sigma,exception);
1463 if (LocaleCompare("encipher",option+1) == 0)
1471 (void) SyncImageSettings(mogrify_info,*image,exception);
1472 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1473 if (passkey != (StringInfo *) NULL)
1475 (void) PasskeyEncipherImage(*image,passkey,exception);
1476 passkey=DestroyStringInfo(passkey);
1480 if (LocaleCompare("encoding",option+1) == 0)
1482 (void) CloneString(&draw_info->encoding,argv[i+1]);
1485 if (LocaleCompare("enhance",option+1) == 0)
1490 (void) SyncImageSettings(mogrify_info,*image,exception);
1491 mogrify_image=EnhanceImage(*image,exception);
1494 if (LocaleCompare("equalize",option+1) == 0)
1499 (void) SyncImageSettings(mogrify_info,*image,exception);
1500 (void) EqualizeImage(*image,exception);
1503 if (LocaleCompare("evaluate",option+1) == 0)
1508 MagickEvaluateOperator
1511 (void) SyncImageSettings(mogrify_info,*image,exception);
1512 op=(MagickEvaluateOperator) ParseCommandOption(
1513 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1514 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1516 (void) EvaluateImage(*image,op,constant,exception);
1519 if (LocaleCompare("extent",option+1) == 0)
1522 Set the image extent.
1524 (void) SyncImageSettings(mogrify_info,*image,exception);
1525 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1526 if (geometry.width == 0)
1527 geometry.width=(*image)->columns;
1528 if (geometry.height == 0)
1529 geometry.height=(*image)->rows;
1530 mogrify_image=ExtentImage(*image,&geometry,exception);
1537 if (LocaleCompare("family",option+1) == 0)
1541 if (draw_info->family != (char *) NULL)
1542 draw_info->family=DestroyString(draw_info->family);
1545 (void) CloneString(&draw_info->family,argv[i+1]);
1548 if (LocaleCompare("features",option+1) == 0)
1552 (void) DeleteImageArtifact(*image,"identify:features");
1555 (void) SetImageArtifact(*image,"vdentify:features",argv[i+1]);
1556 (void) SetImageArtifact(*image,"verbose","true");
1559 if (LocaleCompare("fill",option+1) == 0)
1567 GetPixelInfo(*image,&fill);
1570 (void) QueryColorCompliance("none",AllCompliance,&fill,
1572 draw_info->fill=fill;
1573 if (draw_info->fill_pattern != (Image *) NULL)
1574 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1577 sans=AcquireExceptionInfo();
1578 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1579 sans=DestroyExceptionInfo(sans);
1580 if (status == MagickFalse)
1581 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1584 draw_info->fill=fill=color;
1587 if (LocaleCompare("flip",option+1) == 0)
1590 Flip image scanlines.
1592 (void) SyncImageSettings(mogrify_info,*image,exception);
1593 mogrify_image=FlipImage(*image,exception);
1596 if (LocaleCompare("floodfill",option+1) == 0)
1604 (void) SyncImageSettings(mogrify_info,*image,exception);
1605 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1606 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1608 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1609 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1612 if (LocaleCompare("flop",option+1) == 0)
1615 Flop image scanlines.
1617 (void) SyncImageSettings(mogrify_info,*image,exception);
1618 mogrify_image=FlopImage(*image,exception);
1621 if (LocaleCompare("font",option+1) == 0)
1625 if (draw_info->font != (char *) NULL)
1626 draw_info->font=DestroyString(draw_info->font);
1629 (void) CloneString(&draw_info->font,argv[i+1]);
1632 if (LocaleCompare("format",option+1) == 0)
1637 if (LocaleCompare("frame",option+1) == 0)
1643 Surround image with an ornamental border.
1645 (void) SyncImageSettings(mogrify_info,*image,exception);
1646 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1647 frame_info.width=geometry.width;
1648 frame_info.height=geometry.height;
1649 frame_info.outer_bevel=geometry.x;
1650 frame_info.inner_bevel=geometry.y;
1651 frame_info.x=(ssize_t) frame_info.width;
1652 frame_info.y=(ssize_t) frame_info.height;
1653 frame_info.width=(*image)->columns+2*frame_info.width;
1654 frame_info.height=(*image)->rows+2*frame_info.height;
1655 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1658 if (LocaleCompare("function",option+1) == 0)
1662 token[MaxTextExtent];
1680 Function Modify Image Values
1682 (void) SyncImageSettings(mogrify_info,*image,exception);
1683 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1684 MagickFalse,argv[i+1]);
1685 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1687 if (arguments == (char *) NULL)
1689 p=(char *) arguments;
1690 for (x=0; *p != '\0'; x++)
1692 GetMagickToken(p,&p,token);
1694 GetMagickToken(p,&p,token);
1696 number_parameters=(size_t) x;
1697 parameters=(double *) AcquireQuantumMemory(number_parameters,
1698 sizeof(*parameters));
1699 if (parameters == (double *) NULL)
1700 ThrowWandFatalException(ResourceLimitFatalError,
1701 "MemoryAllocationFailed",(*image)->filename);
1702 (void) ResetMagickMemory(parameters,0,number_parameters*
1703 sizeof(*parameters));
1704 p=(char *) arguments;
1705 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1707 GetMagickToken(p,&p,token);
1709 GetMagickToken(p,&p,token);
1710 parameters[x]=StringToDouble(token,(char **) NULL);
1712 arguments=DestroyString(arguments);
1713 (void) FunctionImage(*image,function,number_parameters,parameters,
1715 parameters=(double *) RelinquishMagickMemory(parameters);
1722 if (LocaleCompare("gamma",option+1) == 0)
1727 (void) SyncImageSettings(mogrify_info,*image,exception);
1729 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1731 (void) GammaImage(*image,StringToDouble(argv[i+1],
1732 (char **) NULL),exception);
1735 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1736 (LocaleCompare("gaussian",option+1) == 0))
1739 Gaussian blur image.
1741 (void) SyncImageSettings(mogrify_info,*image,exception);
1742 flags=ParseGeometry(argv[i+1],&geometry_info);
1743 if ((flags & SigmaValue) == 0)
1744 geometry_info.sigma=1.0;
1745 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1746 geometry_info.sigma,exception);
1749 if (LocaleCompare("geometry",option+1) == 0)
1752 Record Image offset, Resize last image.
1754 (void) SyncImageSettings(mogrify_info,*image,exception);
1757 if ((*image)->geometry != (char *) NULL)
1758 (*image)->geometry=DestroyString((*image)->geometry);
1761 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1762 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1763 (void) CloneString(&(*image)->geometry,argv[i+1]);
1765 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1766 (*image)->filter,exception);
1769 if (LocaleCompare("gravity",option+1) == 0)
1773 draw_info->gravity=UndefinedGravity;
1776 draw_info->gravity=(GravityType) ParseCommandOption(
1777 MagickGravityOptions,MagickFalse,argv[i+1]);
1780 if (LocaleCompare("grayscale",option+1) == 0)
1782 PixelIntensityMethod
1785 (void) SyncImageSettings(mogrify_info,*image,exception);
1786 method=(PixelIntensityMethod) ParseCommandOption(
1787 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1788 (void) GrayscaleImage(*image,method,exception);
1795 if (LocaleCompare("highlight-color",option+1) == 0)
1797 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1800 if (LocaleCompare("hough-lines",option+1) == 0)
1803 Detect edges in the image.
1805 (void) SyncImageSettings(mogrify_info,*image,exception);
1806 flags=ParseGeometry(argv[i+1],&geometry_info);
1807 if ((flags & SigmaValue) == 0)
1808 geometry_info.sigma=geometry_info.rho;
1809 if ((flags & XiValue) == 0)
1810 geometry_info.xi=40;
1811 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1812 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1819 if (LocaleCompare("identify",option+1) == 0)
1824 (void) SyncImageSettings(mogrify_info,*image,exception);
1825 if (format == (char *) NULL)
1827 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1831 text=InterpretImageProperties(mogrify_info,*image,format,
1833 if (text == (char *) NULL)
1835 (void) fputs(text,stdout);
1836 text=DestroyString(text);
1839 if (LocaleCompare("implode",option+1) == 0)
1844 (void) SyncImageSettings(mogrify_info,*image,exception);
1845 (void) ParseGeometry(argv[i+1],&geometry_info);
1846 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1847 interpolate_method,exception);
1850 if (LocaleCompare("interline-spacing",option+1) == 0)
1853 (void) ParseGeometry("0",&geometry_info);
1855 (void) ParseGeometry(argv[i+1],&geometry_info);
1856 draw_info->interline_spacing=geometry_info.rho;
1859 if (LocaleCompare("interpolate",option+1) == 0)
1861 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1862 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1865 if (LocaleCompare("interword-spacing",option+1) == 0)
1868 (void) ParseGeometry("0",&geometry_info);
1870 (void) ParseGeometry(argv[i+1],&geometry_info);
1871 draw_info->interword_spacing=geometry_info.rho;
1874 if (LocaleCompare("interpolative-resize",option+1) == 0)
1877 Interpolative resize image.
1879 (void) SyncImageSettings(mogrify_info,*image,exception);
1880 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1881 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1882 geometry.height,interpolate_method,exception);
1889 if (LocaleCompare("kerning",option+1) == 0)
1892 (void) ParseGeometry("0",&geometry_info);
1894 (void) ParseGeometry(argv[i+1],&geometry_info);
1895 draw_info->kerning=geometry_info.rho;
1902 if (LocaleCompare("lat",option+1) == 0)
1905 Local adaptive threshold image.
1907 (void) SyncImageSettings(mogrify_info,*image,exception);
1908 flags=ParseGeometry(argv[i+1],&geometry_info);
1909 if ((flags & PercentValue) != 0)
1910 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1911 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1912 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1913 geometry_info.xi,exception);
1916 if (LocaleCompare("level",option+1) == 0)
1929 (void) SyncImageSettings(mogrify_info,*image,exception);
1930 flags=ParseGeometry(argv[i+1],&geometry_info);
1931 black_point=geometry_info.rho;
1932 white_point=(double) QuantumRange;
1933 if ((flags & SigmaValue) != 0)
1934 white_point=geometry_info.sigma;
1936 if ((flags & XiValue) != 0)
1937 gamma=geometry_info.xi;
1938 if ((flags & PercentValue) != 0)
1940 black_point*=(double) (QuantumRange/100.0);
1941 white_point*=(double) (QuantumRange/100.0);
1943 if ((flags & SigmaValue) == 0)
1944 white_point=(double) QuantumRange-black_point;
1945 if ((*option == '+') || ((flags & AspectValue) != 0))
1946 (void) LevelizeImage(*image,black_point,white_point,gamma,
1949 (void) LevelImage(*image,black_point,white_point,gamma,
1953 if (LocaleCompare("level-colors",option+1) == 0)
1956 token[MaxTextExtent];
1965 p=(const char *) argv[i+1];
1966 GetMagickToken(p,&p,token); /* get black point color */
1967 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1968 (void) QueryColorCompliance(token,AllCompliance,
1969 &black_point,exception);
1971 (void) QueryColorCompliance("#000000",AllCompliance,
1972 &black_point,exception);
1973 if (isalpha((int) token[0]) || (token[0] == '#'))
1974 GetMagickToken(p,&p,token);
1976 white_point=black_point; /* set everything to that color */
1979 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1980 GetMagickToken(p,&p,token); /* Get white point color. */
1981 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1982 (void) QueryColorCompliance(token,AllCompliance,
1983 &white_point,exception);
1985 (void) QueryColorCompliance("#ffffff",AllCompliance,
1986 &white_point,exception);
1988 (void) LevelImageColors(*image,&black_point,&white_point,
1989 *option == '+' ? MagickTrue : MagickFalse,exception);
1992 if (LocaleCompare("linear-stretch",option+1) == 0)
2001 (void) SyncImageSettings(mogrify_info,*image,exception);
2002 flags=ParseGeometry(argv[i+1],&geometry_info);
2003 black_point=geometry_info.rho;
2004 white_point=(double) (*image)->columns*(*image)->rows;
2005 if ((flags & SigmaValue) != 0)
2006 white_point=geometry_info.sigma;
2007 if ((flags & PercentValue) != 0)
2009 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2010 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2012 if ((flags & SigmaValue) == 0)
2013 white_point=(double) (*image)->columns*(*image)->rows-
2015 (void) LinearStretchImage(*image,black_point,white_point,exception);
2018 if (LocaleCompare("liquid-rescale",option+1) == 0)
2021 Liquid rescale image.
2023 (void) SyncImageSettings(mogrify_info,*image,exception);
2024 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2025 if ((flags & XValue) == 0)
2027 if ((flags & YValue) == 0)
2029 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2030 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2033 if (LocaleCompare("lowlight-color",option+1) == 0)
2035 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2042 if (LocaleCompare("magnify",option+1) == 0)
2047 (void) SyncImageSettings(mogrify_info,*image,exception);
2048 mogrify_image=MagnifyImage(*image,exception);
2051 if (LocaleCompare("map",option+1) == 0)
2057 Transform image colors to match this set of colors.
2059 (void) SyncImageSettings(mogrify_info,*image,exception);
2062 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2063 if (remap_image == (Image *) NULL)
2065 (void) RemapImage(quantize_info,*image,remap_image,exception);
2066 remap_image=DestroyImage(remap_image);
2069 if (LocaleCompare("mask",option+1) == 0)
2074 (void) SyncImageSettings(mogrify_info,*image,exception);
2080 (void) SetImageMask(*image,(Image *) NULL,exception);
2086 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2087 if (mask == (Image *) NULL)
2089 (void) SetImageMask(*image,mask,exception);
2090 mask=DestroyImage(mask);
2093 if (LocaleCompare("matte",option+1) == 0)
2095 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2096 SetAlphaChannel : DeactivateAlphaChannel,exception);
2099 if (LocaleCompare("mean-shift",option+1) == 0)
2102 Detect edges in the image.
2104 (void) SyncImageSettings(mogrify_info,*image,exception);
2105 flags=ParseGeometry(argv[i+1],&geometry_info);
2106 if ((flags & SigmaValue) == 0)
2107 geometry_info.sigma=geometry_info.rho;
2108 if ((flags & XiValue) == 0)
2109 geometry_info.xi=0.10*QuantumRange;
2110 if ((flags & PercentValue) != 0)
2111 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2112 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2113 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2116 if (LocaleCompare("median",option+1) == 0)
2119 Median filter image.
2121 (void) SyncImageSettings(mogrify_info,*image,exception);
2122 flags=ParseGeometry(argv[i+1],&geometry_info);
2123 if ((flags & SigmaValue) == 0)
2124 geometry_info.sigma=geometry_info.rho;
2125 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2126 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2129 if (LocaleCompare("mode",option+1) == 0)
2134 (void) SyncImageSettings(mogrify_info,*image,exception);
2135 flags=ParseGeometry(argv[i+1],&geometry_info);
2136 if ((flags & SigmaValue) == 0)
2137 geometry_info.sigma=geometry_info.rho;
2138 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2139 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2142 if (LocaleCompare("modulate",option+1) == 0)
2144 (void) SyncImageSettings(mogrify_info,*image,exception);
2145 (void) ModulateImage(*image,argv[i+1],exception);
2148 if (LocaleCompare("moments",option+1) == 0)
2152 (void) DeleteImageArtifact(*image,"identify:moments");
2155 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2156 (void) SetImageArtifact(*image,"verbose","true");
2159 if (LocaleCompare("monitor",option+1) == 0)
2163 (void) SetImageProgressMonitor(*image,
2164 (MagickProgressMonitor) NULL,(void *) NULL);
2167 (void) SetImageProgressMonitor(*image,MonitorProgress,
2171 if (LocaleCompare("monochrome",option+1) == 0)
2173 (void) SyncImageSettings(mogrify_info,*image,exception);
2174 (void) SetImageType(*image,BilevelType,exception);
2177 if (LocaleCompare("morphology",option+1) == 0)
2180 token[MaxTextExtent];
2195 Morphological Image Operation
2197 (void) SyncImageSettings(mogrify_info,*image,exception);
2199 GetMagickToken(p,&p,token);
2200 method=(MorphologyMethod) ParseCommandOption(
2201 MagickMorphologyOptions,MagickFalse,token);
2203 GetMagickToken(p,&p,token);
2204 if ((*p == ':') || (*p == ','))
2205 GetMagickToken(p,&p,token);
2207 iterations=(ssize_t) StringToLong(p);
2208 kernel=AcquireKernelInfo(argv[i+2]);
2209 if (kernel == (KernelInfo *) NULL)
2211 (void) ThrowMagickException(exception,GetMagickModule(),
2212 OptionError,"UnabletoParseKernel","morphology");
2216 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2218 kernel=DestroyKernelInfo(kernel);
2221 if (LocaleCompare("motion-blur",option+1) == 0)
2226 (void) SyncImageSettings(mogrify_info,*image,exception);
2227 flags=ParseGeometry(argv[i+1],&geometry_info);
2228 if ((flags & SigmaValue) == 0)
2229 geometry_info.sigma=1.0;
2230 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2231 geometry_info.sigma,geometry_info.xi,exception);
2238 if (LocaleCompare("negate",option+1) == 0)
2240 (void) SyncImageSettings(mogrify_info,*image,exception);
2241 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2242 MagickFalse,exception);
2245 if (LocaleCompare("noise",option+1) == 0)
2247 (void) SyncImageSettings(mogrify_info,*image,exception);
2250 flags=ParseGeometry(argv[i+1],&geometry_info);
2251 if ((flags & SigmaValue) == 0)
2252 geometry_info.sigma=geometry_info.rho;
2253 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2254 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2261 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2262 MagickFalse,argv[i+1]);
2263 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2267 if (LocaleCompare("normalize",option+1) == 0)
2269 (void) SyncImageSettings(mogrify_info,*image,exception);
2270 (void) NormalizeImage(*image,exception);
2277 if (LocaleCompare("opaque",option+1) == 0)
2282 (void) SyncImageSettings(mogrify_info,*image,exception);
2283 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2285 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2286 MagickFalse : MagickTrue,exception);
2289 if (LocaleCompare("ordered-dither",option+1) == 0)
2291 (void) SyncImageSettings(mogrify_info,*image,exception);
2292 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2299 if (LocaleCompare("paint",option+1) == 0)
2301 (void) SyncImageSettings(mogrify_info,*image,exception);
2302 (void) ParseGeometry(argv[i+1],&geometry_info);
2303 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2304 geometry_info.sigma,exception);
2307 if (LocaleCompare("pointsize",option+1) == 0)
2310 (void) ParseGeometry("12",&geometry_info);
2312 (void) ParseGeometry(argv[i+1],&geometry_info);
2313 draw_info->pointsize=geometry_info.rho;
2316 if (LocaleCompare("polaroid",option+1) == 0)
2328 Simulate a Polaroid picture.
2330 (void) SyncImageSettings(mogrify_info,*image,exception);
2331 random_info=AcquireRandomInfo();
2332 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2333 random_info=DestroyRandomInfo(random_info);
2336 SetGeometryInfo(&geometry_info);
2337 flags=ParseGeometry(argv[i+1],&geometry_info);
2338 angle=geometry_info.rho;
2340 caption=GetImageProperty(*image,"caption",exception);
2341 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2342 interpolate_method,exception);
2345 if (LocaleCompare("posterize",option+1) == 0)
2350 (void) SyncImageSettings(mogrify_info,*image,exception);
2351 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2352 quantize_info->dither_method,exception);
2355 if (LocaleCompare("preview",option+1) == 0)
2363 (void) SyncImageSettings(mogrify_info,*image,exception);
2365 preview_type=UndefinedPreview;
2367 preview_type=(PreviewType) ParseCommandOption(
2368 MagickPreviewOptions,MagickFalse,argv[i+1]);
2369 mogrify_image=PreviewImage(*image,preview_type,exception);
2372 if (LocaleCompare("profile",option+1) == 0)
2386 (void) SyncImageSettings(mogrify_info,*image,exception);
2390 Remove a profile from the image.
2392 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2397 Associate a profile with the image.
2399 profile_info=CloneImageInfo(mogrify_info);
2400 profile=GetImageProfile(*image,"iptc");
2401 if (profile != (StringInfo *) NULL)
2402 profile_info->profile=(void *) CloneStringInfo(profile);
2403 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2404 profile_info=DestroyImageInfo(profile_info);
2405 if (profile_image == (Image *) NULL)
2410 profile_info=CloneImageInfo(mogrify_info);
2411 (void) CopyMagickString(profile_info->filename,argv[i+1],
2413 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2414 if (profile != (StringInfo *) NULL)
2416 (void) ProfileImage(*image,profile_info->magick,
2417 GetStringInfoDatum(profile),(size_t)
2418 GetStringInfoLength(profile),exception);
2419 profile=DestroyStringInfo(profile);
2421 profile_info=DestroyImageInfo(profile_info);
2424 ResetImageProfileIterator(profile_image);
2425 name=GetNextImageProfile(profile_image);
2426 while (name != (const char *) NULL)
2428 profile=GetImageProfile(profile_image,name);
2429 if (profile != (StringInfo *) NULL)
2430 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2431 (size_t) GetStringInfoLength(profile),exception);
2432 name=GetNextImageProfile(profile_image);
2434 profile_image=DestroyImage(profile_image);
2441 if (LocaleCompare("quantize",option+1) == 0)
2445 quantize_info->colorspace=UndefinedColorspace;
2448 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2449 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2456 if (LocaleCompare("rotational-blur",option+1) == 0)
2459 Rotational blur image.
2461 (void) SyncImageSettings(mogrify_info,*image,exception);
2462 flags=ParseGeometry(argv[i+1],&geometry_info);
2463 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,exception);
2466 if (LocaleCompare("raise",option+1) == 0)
2469 Surround image with a raise of solid color.
2471 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2472 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2473 MagickFalse,exception);
2476 if (LocaleCompare("random-threshold",option+1) == 0)
2481 (void) SyncImageSettings(mogrify_info,*image,exception);
2482 (void) RandomThresholdImage(*image,argv[i+1],exception);
2485 if (LocaleCompare("region",option+1) == 0)
2487 (void) SyncImageSettings(mogrify_info,*image,exception);
2488 if (region_image != (Image *) NULL)
2493 (void) CompositeImage(region_image,*image,
2494 region_image->alpha_trait == BlendPixelTrait ?
2495 CopyCompositeOp : OverCompositeOp,MagickTrue,
2496 region_geometry.x,region_geometry.y,exception);
2497 *image=DestroyImage(*image);
2498 *image=region_image;
2499 region_image = (Image *) NULL;
2504 Apply transformations to a selected region of the image.
2506 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2508 mogrify_image=CropImage(*image,®ion_geometry,exception);
2509 if (mogrify_image == (Image *) NULL)
2511 region_image=(*image);
2512 *image=mogrify_image;
2513 mogrify_image=(Image *) NULL;
2516 if (LocaleCompare("render",option+1) == 0)
2518 (void) SyncImageSettings(mogrify_info,*image,exception);
2519 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2522 if (LocaleCompare("remap",option+1) == 0)
2528 Transform image colors to match this set of colors.
2530 (void) SyncImageSettings(mogrify_info,*image,exception);
2533 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2534 if (remap_image == (Image *) NULL)
2536 (void) RemapImage(quantize_info,*image,remap_image,exception);
2537 remap_image=DestroyImage(remap_image);
2540 if (LocaleCompare("repage",option+1) == 0)
2544 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2547 (void) ResetImagePage(*image,argv[i+1]);
2550 if (LocaleCompare("resample",option+1) == 0)
2555 (void) SyncImageSettings(mogrify_info,*image,exception);
2556 flags=ParseGeometry(argv[i+1],&geometry_info);
2557 if ((flags & SigmaValue) == 0)
2558 geometry_info.sigma=geometry_info.rho;
2559 mogrify_image=ResampleImage(*image,geometry_info.rho,
2560 geometry_info.sigma,(*image)->filter,exception);
2563 if (LocaleCompare("resize",option+1) == 0)
2568 (void) SyncImageSettings(mogrify_info,*image,exception);
2569 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2570 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2571 (*image)->filter,exception);
2574 if (LocaleCompare("roll",option+1) == 0)
2579 (void) SyncImageSettings(mogrify_info,*image,exception);
2580 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2581 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2584 if (LocaleCompare("rotate",option+1) == 0)
2590 Check for conditional image rotation.
2592 (void) SyncImageSettings(mogrify_info,*image,exception);
2593 if (strchr(argv[i+1],'>') != (char *) NULL)
2594 if ((*image)->columns <= (*image)->rows)
2596 if (strchr(argv[i+1],'<') != (char *) NULL)
2597 if ((*image)->columns >= (*image)->rows)
2602 geometry=ConstantString(argv[i+1]);
2603 (void) SubstituteString(&geometry,">","");
2604 (void) SubstituteString(&geometry,"<","");
2605 (void) ParseGeometry(geometry,&geometry_info);
2606 geometry=DestroyString(geometry);
2607 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2614 if (LocaleCompare("sample",option+1) == 0)
2617 Sample image with pixel replication.
2619 (void) SyncImageSettings(mogrify_info,*image,exception);
2620 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2621 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2625 if (LocaleCompare("scale",option+1) == 0)
2630 (void) SyncImageSettings(mogrify_info,*image,exception);
2631 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2632 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2636 if (LocaleCompare("selective-blur",option+1) == 0)
2639 Selectively blur pixels within a contrast threshold.
2641 (void) SyncImageSettings(mogrify_info,*image,exception);
2642 flags=ParseGeometry(argv[i+1],&geometry_info);
2643 if ((flags & PercentValue) != 0)
2644 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2645 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2646 geometry_info.sigma,geometry_info.xi,exception);
2649 if (LocaleCompare("separate",option+1) == 0)
2652 Break channels into separate images.
2654 (void) SyncImageSettings(mogrify_info,*image,exception);
2655 mogrify_image=SeparateImages(*image,exception);
2658 if (LocaleCompare("sepia-tone",option+1) == 0)
2666 (void) SyncImageSettings(mogrify_info,*image,exception);
2667 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2669 mogrify_image=SepiaToneImage(*image,threshold,exception);
2672 if (LocaleCompare("segment",option+1) == 0)
2677 (void) SyncImageSettings(mogrify_info,*image,exception);
2678 flags=ParseGeometry(argv[i+1],&geometry_info);
2679 if ((flags & SigmaValue) == 0)
2680 geometry_info.sigma=1.0;
2681 (void) SegmentImage(*image,(*image)->colorspace,
2682 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2686 if (LocaleCompare("set",option+1) == 0)
2696 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2697 (void) DeleteImageRegistry(argv[i+1]+9);
2699 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2701 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2702 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2705 (void) DeleteImageProperty(*image,argv[i+1]);
2708 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2710 if (value == (char *) NULL)
2712 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2713 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2716 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2718 (void) SetImageOption(image_info,argv[i+1]+7,value);
2719 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2720 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2723 (void) SetImageProperty(*image,argv[i+1],value,exception);
2724 value=DestroyString(value);
2727 if (LocaleCompare("shade",option+1) == 0)
2732 (void) SyncImageSettings(mogrify_info,*image,exception);
2733 flags=ParseGeometry(argv[i+1],&geometry_info);
2734 if ((flags & SigmaValue) == 0)
2735 geometry_info.sigma=1.0;
2736 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2737 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2740 if (LocaleCompare("shadow",option+1) == 0)
2745 (void) SyncImageSettings(mogrify_info,*image,exception);
2746 flags=ParseGeometry(argv[i+1],&geometry_info);
2747 if ((flags & SigmaValue) == 0)
2748 geometry_info.sigma=1.0;
2749 if ((flags & XiValue) == 0)
2750 geometry_info.xi=4.0;
2751 if ((flags & PsiValue) == 0)
2752 geometry_info.psi=4.0;
2753 mogrify_image=ShadowImage(*image,geometry_info.rho,
2754 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2755 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2758 if (LocaleCompare("sharpen",option+1) == 0)
2763 (void) SyncImageSettings(mogrify_info,*image,exception);
2764 flags=ParseGeometry(argv[i+1],&geometry_info);
2765 if ((flags & SigmaValue) == 0)
2766 geometry_info.sigma=1.0;
2767 if ((flags & XiValue) == 0)
2768 geometry_info.xi=0.0;
2769 mogrify_image=SharpenImage(*image,geometry_info.rho,
2770 geometry_info.sigma,exception);
2773 if (LocaleCompare("shave",option+1) == 0)
2776 Shave the image edges.
2778 (void) SyncImageSettings(mogrify_info,*image,exception);
2779 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2780 mogrify_image=ShaveImage(*image,&geometry,exception);
2783 if (LocaleCompare("shear",option+1) == 0)
2788 (void) SyncImageSettings(mogrify_info,*image,exception);
2789 flags=ParseGeometry(argv[i+1],&geometry_info);
2790 if ((flags & SigmaValue) == 0)
2791 geometry_info.sigma=geometry_info.rho;
2792 mogrify_image=ShearImage(*image,geometry_info.rho,
2793 geometry_info.sigma,exception);
2796 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2799 Sigmoidal non-linearity contrast control.
2801 (void) SyncImageSettings(mogrify_info,*image,exception);
2802 flags=ParseGeometry(argv[i+1],&geometry_info);
2803 if ((flags & SigmaValue) == 0)
2804 geometry_info.sigma=(double) QuantumRange/2.0;
2805 if ((flags & PercentValue) != 0)
2806 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2808 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2809 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2813 if (LocaleCompare("sketch",option+1) == 0)
2818 (void) SyncImageSettings(mogrify_info,*image,exception);
2819 flags=ParseGeometry(argv[i+1],&geometry_info);
2820 if ((flags & SigmaValue) == 0)
2821 geometry_info.sigma=1.0;
2822 mogrify_image=SketchImage(*image,geometry_info.rho,
2823 geometry_info.sigma,geometry_info.xi,exception);
2826 if (LocaleCompare("solarize",option+1) == 0)
2831 (void) SyncImageSettings(mogrify_info,*image,exception);
2832 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2834 (void) SolarizeImage(*image,threshold,exception);
2837 if (LocaleCompare("sparse-color",option+1) == 0)
2846 Sparse Color Interpolated Gradient
2848 (void) SyncImageSettings(mogrify_info,*image,exception);
2849 method=(SparseColorMethod) ParseCommandOption(
2850 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2851 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2853 if (arguments == (char *) NULL)
2855 mogrify_image=SparseColorOption(*image,method,arguments,
2856 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2857 arguments=DestroyString(arguments);
2860 if (LocaleCompare("splice",option+1) == 0)
2863 Splice a solid color into the image.
2865 (void) SyncImageSettings(mogrify_info,*image,exception);
2866 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2867 mogrify_image=SpliceImage(*image,&geometry,exception);
2870 if (LocaleCompare("spread",option+1) == 0)
2875 (void) SyncImageSettings(mogrify_info,*image,exception);
2876 (void) ParseGeometry(argv[i+1],&geometry_info);
2877 mogrify_image=SpreadImage(*image,geometry_info.rho,
2878 interpolate_method,exception);
2881 if (LocaleCompare("statistic",option+1) == 0)
2886 (void) SyncImageSettings(mogrify_info,*image,exception);
2887 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2888 MagickFalse,argv[i+1]);
2889 (void) ParseGeometry(argv[i+2],&geometry_info);
2890 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2891 (size_t) geometry_info.sigma,exception);
2894 if (LocaleCompare("stretch",option+1) == 0)
2898 draw_info->stretch=UndefinedStretch;
2901 draw_info->stretch=(StretchType) ParseCommandOption(
2902 MagickStretchOptions,MagickFalse,argv[i+1]);
2905 if (LocaleCompare("strip",option+1) == 0)
2908 Strip image of profiles and comments.
2910 (void) SyncImageSettings(mogrify_info,*image,exception);
2911 (void) StripImage(*image,exception);
2914 if (LocaleCompare("stroke",option+1) == 0)
2924 (void) QueryColorCompliance("none",AllCompliance,
2925 &draw_info->stroke,exception);
2926 if (draw_info->stroke_pattern != (Image *) NULL)
2927 draw_info->stroke_pattern=DestroyImage(
2928 draw_info->stroke_pattern);
2931 sans=AcquireExceptionInfo();
2932 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2933 sans=DestroyExceptionInfo(sans);
2934 if (status == MagickFalse)
2935 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2938 draw_info->stroke=color;
2941 if (LocaleCompare("strokewidth",option+1) == 0)
2943 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2946 if (LocaleCompare("style",option+1) == 0)
2950 draw_info->style=UndefinedStyle;
2953 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2954 MagickFalse,argv[i+1]);
2957 if (LocaleCompare("swirl",option+1) == 0)
2962 (void) SyncImageSettings(mogrify_info,*image,exception);
2963 (void) ParseGeometry(argv[i+1],&geometry_info);
2964 mogrify_image=SwirlImage(*image,geometry_info.rho,
2965 interpolate_method,exception);
2972 if (LocaleCompare("threshold",option+1) == 0)
2980 (void) SyncImageSettings(mogrify_info,*image,exception);
2982 threshold=(double) QuantumRange/2;
2984 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2986 (void) BilevelImage(*image,threshold,exception);
2989 if (LocaleCompare("thumbnail",option+1) == 0)
2994 (void) SyncImageSettings(mogrify_info,*image,exception);
2995 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2996 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3000 if (LocaleCompare("tile",option+1) == 0)
3004 if (draw_info->fill_pattern != (Image *) NULL)
3005 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3008 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3012 if (LocaleCompare("tint",option+1) == 0)
3017 (void) SyncImageSettings(mogrify_info,*image,exception);
3018 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3021 if (LocaleCompare("transform",option+1) == 0)
3024 Affine transform image.
3026 (void) SyncImageSettings(mogrify_info,*image,exception);
3027 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3031 if (LocaleCompare("transparent",option+1) == 0)
3036 (void) SyncImageSettings(mogrify_info,*image,exception);
3037 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3039 (void) TransparentPaintImage(*image,&target,(Quantum)
3040 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3044 if (LocaleCompare("transpose",option+1) == 0)
3047 Transpose image scanlines.
3049 (void) SyncImageSettings(mogrify_info,*image,exception);
3050 mogrify_image=TransposeImage(*image,exception);
3053 if (LocaleCompare("transverse",option+1) == 0)
3056 Transverse image scanlines.
3058 (void) SyncImageSettings(mogrify_info,*image,exception);
3059 mogrify_image=TransverseImage(*image,exception);
3062 if (LocaleCompare("treedepth",option+1) == 0)
3064 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3067 if (LocaleCompare("trim",option+1) == 0)
3072 (void) SyncImageSettings(mogrify_info,*image,exception);
3073 mogrify_image=TrimImage(*image,exception);
3076 if (LocaleCompare("type",option+1) == 0)
3081 (void) SyncImageSettings(mogrify_info,*image,exception);
3085 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3087 (*image)->type=UndefinedType;
3088 (void) SetImageType(*image,type,exception);
3095 if (LocaleCompare("undercolor",option+1) == 0)
3097 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3098 &draw_info->undercolor,exception);
3101 if (LocaleCompare("unique",option+1) == 0)
3105 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3108 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3109 (void) SetImageArtifact(*image,"verbose","true");
3112 if (LocaleCompare("unique-colors",option+1) == 0)
3115 Unique image colors.
3117 (void) SyncImageSettings(mogrify_info,*image,exception);
3118 mogrify_image=UniqueImageColors(*image,exception);
3121 if (LocaleCompare("unsharp",option+1) == 0)
3126 (void) SyncImageSettings(mogrify_info,*image,exception);
3127 flags=ParseGeometry(argv[i+1],&geometry_info);
3128 if ((flags & SigmaValue) == 0)
3129 geometry_info.sigma=1.0;
3130 if ((flags & XiValue) == 0)
3131 geometry_info.xi=1.0;
3132 if ((flags & PsiValue) == 0)
3133 geometry_info.psi=0.05;
3134 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3135 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3143 if (LocaleCompare("verbose",option+1) == 0)
3145 (void) SetImageArtifact(*image,option+1,
3146 *option == '+' ? "false" : "true");
3149 if (LocaleCompare("vignette",option+1) == 0)
3154 (void) SyncImageSettings(mogrify_info,*image,exception);
3155 flags=ParseGeometry(argv[i+1],&geometry_info);
3156 if ((flags & SigmaValue) == 0)
3157 geometry_info.sigma=1.0;
3158 if ((flags & XiValue) == 0)
3159 geometry_info.xi=0.1*(*image)->columns;
3160 if ((flags & PsiValue) == 0)
3161 geometry_info.psi=0.1*(*image)->rows;
3162 if ((flags & PercentValue) != 0)
3164 geometry_info.xi*=(double) (*image)->columns/100.0;
3165 geometry_info.psi*=(double) (*image)->rows/100.0;
3167 mogrify_image=VignetteImage(*image,geometry_info.rho,
3168 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3169 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3172 if (LocaleCompare("virtual-pixel",option+1) == 0)
3176 (void) SetImageVirtualPixelMethod(*image,
3177 UndefinedVirtualPixelMethod,exception);
3180 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3181 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3182 argv[i+1]),exception);
3189 if (LocaleCompare("wave",option+1) == 0)
3194 (void) SyncImageSettings(mogrify_info,*image,exception);
3195 flags=ParseGeometry(argv[i+1],&geometry_info);
3196 if ((flags & SigmaValue) == 0)
3197 geometry_info.sigma=1.0;
3198 mogrify_image=WaveImage(*image,geometry_info.rho,
3199 geometry_info.sigma,interpolate_method,exception);
3202 if (LocaleCompare("weight",option+1) == 0)
3204 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3205 if (LocaleCompare(argv[i+1],"all") == 0)
3206 draw_info->weight=0;
3207 if (LocaleCompare(argv[i+1],"bold") == 0)
3208 draw_info->weight=700;
3209 if (LocaleCompare(argv[i+1],"bolder") == 0)
3210 if (draw_info->weight <= 800)
3211 draw_info->weight+=100;
3212 if (LocaleCompare(argv[i+1],"lighter") == 0)
3213 if (draw_info->weight >= 100)
3214 draw_info->weight-=100;
3215 if (LocaleCompare(argv[i+1],"normal") == 0)
3216 draw_info->weight=400;
3219 if (LocaleCompare("white-threshold",option+1) == 0)
3222 White threshold image.
3224 (void) SyncImageSettings(mogrify_info,*image,exception);
3225 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3234 Replace current image with any image that was generated
3236 if (mogrify_image != (Image *) NULL)
3237 ReplaceImageInListReturnLast(image,mogrify_image);
3240 if (region_image != (Image *) NULL)
3243 Composite transformed region onto image.
3245 (void) SyncImageSettings(mogrify_info,*image,exception);
3246 (void) CompositeImage(region_image,*image,
3247 region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp :
3248 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3250 *image=DestroyImage(*image);
3251 *image=region_image;
3252 region_image = (Image *) NULL;
3257 quantize_info=DestroyQuantizeInfo(quantize_info);
3258 draw_info=DestroyDrawInfo(draw_info);
3259 mogrify_info=DestroyImageInfo(mogrify_info);
3260 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3261 return(status == 0 ? MagickFalse : MagickTrue);
3265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3269 + M o g r i f y I m a g e C o m m a n d %
3273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3275 % MogrifyImageCommand() transforms an image or a sequence of images. These
3276 % transforms include image scaling, image rotation, color reduction, and
3277 % others. The transmogrified image overwrites the original image.
3279 % The format of the MogrifyImageCommand method is:
3281 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3282 % const char **argv,char **metadata,ExceptionInfo *exception)
3284 % A description of each parameter follows:
3286 % o image_info: the image info.
3288 % o argc: the number of elements in the argument vector.
3290 % o argv: A text array containing the command line arguments.
3292 % o metadata: any metadata is returned here.
3294 % o exception: return any errors or warnings in this structure.
3298 static MagickBooleanType MogrifyUsage(void)
3301 *channel_operators[]=
3303 "-channel-fx expression",
3304 " exchange, extract, or transfer one or more image channels",
3305 "-separate separate an image channel into a grayscale image",
3310 "-debug events display copious debugging information",
3311 "-distribute-cache port",
3312 " distributed pixel cache spanning one or more servers",
3313 "-help print program options",
3314 "-list type print a list of supported option arguments",
3315 "-log format format of debugging information",
3316 "-version print version information",
3321 "-adaptive-blur geometry",
3322 " adaptively blur pixels; decrease effect near edges",
3323 "-adaptive-resize geometry",
3324 " adaptively resize image using 'mesh' interpolation",
3325 "-adaptive-sharpen geometry",
3326 " adaptively sharpen pixels; increase effect near edges",
3327 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3328 " transparent, extract, background, or shape",
3329 "-annotate geometry text",
3330 " annotate the image with text",
3331 "-auto-gamma automagically adjust gamma level of image",
3332 "-auto-level automagically adjust color levels of image",
3333 "-auto-orient automagically orient (rotate) image",
3334 "-bench iterations measure performance",
3335 "-black-threshold value",
3336 " force all pixels below the threshold into black",
3337 "-blue-shift simulate a scene at nighttime in the moonlight",
3338 "-blur geometry reduce image noise and reduce detail levels",
3339 "-border geometry surround image with a border of color",
3340 "-bordercolor color border color",
3341 "-brightness-contrast geometry",
3342 " improve brightness / contrast of the image",
3343 "-canny geometry detect edges in the image",
3344 "-cdl filename color correct with a color decision list",
3345 "-charcoal geometry simulate a charcoal drawing",
3346 "-chop geometry remove pixels from the image interior",
3347 "-clamp keep pixel values in range (0-QuantumRange)",
3348 "-clip clip along the first path from the 8BIM profile",
3349 "-clip-mask filename associate a clip mask with the image",
3350 "-clip-path id clip along a named path from the 8BIM profile",
3351 "-colorize value colorize the image with the fill color",
3352 "-color-matrix matrix apply color correction to the image",
3353 "-contrast enhance or reduce the image contrast",
3354 "-contrast-stretch geometry",
3355 " improve contrast by 'stretching' the intensity range",
3356 "-convolve coefficients",
3357 " apply a convolution kernel to the image",
3358 "-cycle amount cycle the image colormap",
3359 "-decipher filename convert cipher pixels to plain pixels",
3360 "-deskew threshold straighten an image",
3361 "-despeckle reduce the speckles within an image",
3362 "-distort method args",
3363 " distort images according to given method ad args",
3364 "-draw string annotate the image with a graphic primitive",
3365 "-edge radius apply a filter to detect edges in the image",
3366 "-encipher filename convert plain pixels to cipher pixels",
3367 "-emboss radius emboss an image",
3368 "-enhance apply a digital filter to enhance a noisy image",
3369 "-equalize perform histogram equalization to an image",
3370 "-evaluate operator value",
3371 " evaluate an arithmetic, relational, or logical expression",
3372 "-extent geometry set the image size",
3373 "-extract geometry extract area from image",
3374 "-fft implements the discrete Fourier transform (DFT)",
3375 "-flip flip image vertically",
3376 "-floodfill geometry color",
3377 " floodfill the image with color",
3378 "-flop flop image horizontally",
3379 "-frame geometry surround image with an ornamental border",
3380 "-function name parameters",
3381 " apply function over image values",
3382 "-gamma value level of gamma correction",
3383 "-gaussian-blur geometry",
3384 " reduce image noise and reduce detail levels",
3385 "-geometry geometry preferred size or location of the image",
3386 "-grayscale method convert image to grayscale",
3387 "-hough-lines geometry",
3388 " identify lines in the image",
3389 "-identify identify the format and characteristics of the image",
3390 "-ift implements the inverse discrete Fourier transform (DFT)",
3391 "-implode amount implode image pixels about the center",
3392 "-interpolative-resize geometry",
3393 " resize image using interpolation",
3394 "-lat geometry local adaptive thresholding",
3395 "-level value adjust the level of image contrast",
3396 "-level-colors color,color",
3397 " level image with the given colors",
3398 "-linear-stretch geometry",
3399 " improve contrast by 'stretching with saturation'",
3400 "-liquid-rescale geometry",
3401 " rescale image with seam-carving",
3402 "-magnify double the size of the image with pixel art scaling",
3403 "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3404 "-median geometry apply a median filter to the image",
3405 "-mode geometry make each pixel the 'predominant color' of the",
3407 "-modulate value vary the brightness, saturation, and hue",
3408 "-monochrome transform image to black and white",
3409 "-morphology method kernel",
3410 " apply a morphology method to the image",
3411 "-motion-blur geometry",
3412 " simulate motion blur",
3413 "-negate replace every pixel with its complementary color ",
3414 "-noise geometry add or reduce noise in an image",
3415 "-normalize transform image to span the full range of colors",
3416 "-opaque color change this color to the fill color",
3417 "-ordered-dither NxN",
3418 " add a noise pattern to the image with specific",
3420 "-paint radius simulate an oil painting",
3421 "-perceptible epsilon",
3422 " pixel value less than |epsilon| become epsilon or",
3424 "-polaroid angle simulate a Polaroid picture",
3425 "-posterize levels reduce the image to a limited number of color levels",
3426 "-profile filename add, delete, or apply an image profile",
3427 "-quantize colorspace reduce colors in this colorspace",
3428 "-raise value lighten/darken image edges to create a 3-D effect",
3429 "-random-threshold low,high",
3430 " random threshold the image",
3431 "-region geometry apply options to a portion of the image",
3432 "-render render vector graphics",
3433 "-repage geometry size and location of an image canvas",
3434 "-resample geometry change the resolution of an image",
3435 "-resize geometry resize the image",
3436 "-roll geometry roll an image vertically or horizontally",
3437 "-rotate degrees apply Paeth rotation to the image",
3438 "-rotational-blur angle",
3439 " rotational blur the image",
3440 "-sample geometry scale image with pixel sampling",
3441 "-scale geometry scale the image",
3442 "-segment values segment an image",
3443 "-selective-blur geometry",
3444 " selectively blur pixels within a contrast threshold",
3445 "-sepia-tone threshold",
3446 " simulate a sepia-toned photo",
3447 "-set property value set an image property",
3448 "-shade degrees shade the image using a distant light source",
3449 "-shadow geometry simulate an image shadow",
3450 "-sharpen geometry sharpen the image",
3451 "-shave geometry shave pixels from the image edges",
3452 "-shear geometry slide one edge of the image along the X or Y axis",
3453 "-sigmoidal-contrast geometry",
3454 " increase the contrast without saturating highlights or",
3456 "-sketch geometry simulate a pencil sketch",
3457 "-solarize threshold negate all pixels above the threshold level",
3458 "-sparse-color method args",
3459 " fill in a image based on a few color points",
3460 "-splice geometry splice the background color into the image",
3461 "-spread radius displace image pixels by a random amount",
3462 "-statistic type radius",
3463 " replace each pixel with corresponding statistic from the neighborhood",
3464 "-strip strip image of all profiles and comments",
3465 "-swirl degrees swirl image pixels about the center",
3466 "-threshold value threshold the image",
3467 "-thumbnail geometry create a thumbnail of the image",
3468 "-tile filename tile image when filling a graphic primitive",
3469 "-tint value tint the image with the fill color",
3470 "-transform affine transform image",
3471 "-transparent color make this color transparent within the image",
3472 "-transpose flip image vertically and rotate 90 degrees",
3473 "-transverse flop image horizontally and rotate 270 degrees",
3474 "-trim trim image edges",
3475 "-type type image type",
3476 "-unique-colors discard all but one of any pixel color",
3477 "-unsharp geometry sharpen the image",
3478 "-vignette geometry soften the edges of the image in vignette style",
3479 "-wave geometry alter an image along a sine wave",
3480 "-white-threshold value",
3481 " force all pixels above the threshold into white",
3484 *sequence_operators[]=
3486 "-affinity filename transform image colors to match this set of colors",
3487 "-append append an image sequence",
3488 "-clut apply a color lookup table to the image",
3489 "-coalesce merge a sequence of images",
3490 "-combine combine a sequence of images",
3491 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3492 "-complex operator perform complex mathematics on an image sequence",
3493 "-composite composite image",
3494 "-crop geometry cut out a rectangular region of the image",
3495 "-deconstruct break down an image sequence into constituent parts",
3496 "-evaluate-sequence operator",
3497 " evaluate an arithmetic, relational, or logical expression",
3498 "-flatten flatten a sequence of images",
3499 "-fx expression apply mathematical expression to an image channel(s)",
3500 "-hald-clut apply a Hald color lookup table to the image",
3501 "-layers method optimize, merge, or compare image layers",
3502 "-morph value morph an image sequence",
3503 "-mosaic create a mosaic from an image sequence",
3504 "-poly terms build a polynomial from the image sequence and the corresponding",
3505 " terms (coefficients and degree pairs).",
3506 "-print string interpret string and print to console",
3507 "-process arguments process the image with a custom image filter",
3508 "-smush geometry smush an image sequence together",
3509 "-write filename write images to this file",
3514 "-adjoin join images into a single multi-image file",
3515 "-affine matrix affine transform matrix",
3516 "-alpha option activate, deactivate, reset, or set the alpha channel",
3517 "-antialias remove pixel-aliasing",
3518 "-authenticate password",
3519 " decipher image with this password",
3520 "-attenuate value lessen (or intensify) when adding noise to an image",
3521 "-background color background color",
3522 "-bias value add bias when convolving an image",
3523 "-black-point-compensation",
3524 " use black point compensation",
3525 "-blue-primary point chromaticity blue primary point",
3526 "-bordercolor color border color",
3527 "-caption string assign a caption to an image",
3528 "-channel type apply option to select image channels",
3529 "-colors value preferred number of colors in the image",
3530 "-colorspace type alternate image colorspace",
3531 "-comment string annotate image with comment",
3532 "-compose operator set image composite operator",
3533 "-compress type type of pixel compression when writing the image",
3534 "-define format:option=value",
3535 " define one or more image format options",
3536 "-delay value display the next image after pausing",
3537 "-density geometry horizontal and vertical density of the image",
3538 "-depth value image depth",
3539 "-direction type render text right-to-left or left-to-right",
3540 "-display server get image or font from this X server",
3541 "-dispose method layer disposal method",
3542 "-dither method apply error diffusion to image",
3543 "-encoding type text encoding type",
3544 "-endian type endianness (MSB or LSB) of the image",
3545 "-family name render text with this font family",
3546 "-features distance analyze image features (e.g. contrast, correlation)",
3547 "-fill color color to use when filling a graphic primitive",
3548 "-filter type use this filter when resizing an image",
3549 "-font name render text with this font",
3550 "-format \"string\" output formatted image characteristics",
3551 "-fuzz distance colors within this distance are considered equal",
3552 "-gravity type horizontal and vertical text placement",
3553 "-green-primary point chromaticity green primary point",
3554 "-intensity method method to generate an intensity value from a pixel",
3555 "-intent type type of rendering intent when managing the image color",
3556 "-interlace type type of image interlacing scheme",
3557 "-interline-spacing value",
3558 " set the space between two text lines",
3559 "-interpolate method pixel color interpolation method",
3560 "-interword-spacing value",
3561 " set the space between two words",
3562 "-kerning value set the space between two letters",
3563 "-label string assign a label to an image",
3564 "-limit type value pixel cache resource limit",
3565 "-loop iterations add Netscape loop extension to your GIF animation",
3566 "-mask filename associate a mask with the image",
3567 "-matte store matte channel if the image has one",
3568 "-mattecolor color frame color",
3569 "-monitor monitor progress",
3570 "-orient type image orientation",
3571 "-page geometry size and location of an image canvas (setting)",
3572 "-path path write images to this path on disk",
3573 "-ping efficiently determine image attributes",
3574 "-pointsize value font point size",
3575 "-precision value maximum number of significant digits to print",
3576 "-preview type image preview type",
3577 "-quality value JPEG/MIFF/PNG compression level",
3578 "-quiet suppress all warning messages",
3579 "-red-primary point chromaticity red primary point",
3580 "-regard-warnings pay attention to warning messages",
3581 "-remap filename transform image colors to match this set of colors",
3582 "-respect-parentheses settings remain in effect until parenthesis boundary",
3583 "-sampling-factor geometry",
3584 " horizontal and vertical sampling factor",
3585 "-scene value image scene number",
3586 "-seed value seed a new sequence of pseudo-random numbers",
3587 "-size geometry width and height of image",
3588 "-stretch type render text with this font stretch",
3589 "-stroke color graphic primitive stroke color",
3590 "-strokewidth value graphic primitive stroke width",
3591 "-style type render text with this font style",
3592 "-synchronize synchronize image to storage device",
3593 "-taint declare the image as modified",
3594 "-texture filename name of texture to tile onto the image background",
3595 "-tile-offset geometry",
3597 "-treedepth value color tree depth",
3598 "-transparent-color color",
3599 " transparent color",
3600 "-undercolor color annotation bounding box color",
3601 "-units type the units of image resolution",
3602 "-verbose print detailed information about the image",
3603 "-view FlashPix viewing transforms",
3604 "-virtual-pixel method",
3605 " virtual pixel access method",
3606 "-weight type render text with this font weight",
3607 "-white-point point chromaticity white point",
3612 "-delete indexes delete the image from the image sequence",
3613 "-duplicate count,indexes",
3614 " duplicate an image one or more times",
3615 "-insert index insert last image into the image sequence",
3616 "-reverse reverse image sequence",
3617 "-swap indexes swap two images in the image sequence",
3624 ListMagickVersion(stdout);
3625 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3627 (void) printf("\nImage Settings:\n");
3628 for (p=settings; *p != (char *) NULL; p++)
3629 (void) printf(" %s\n",*p);
3630 (void) printf("\nImage Operators:\n");
3631 for (p=operators; *p != (char *) NULL; p++)
3632 (void) printf(" %s\n",*p);
3633 (void) printf("\nImage Channel Operators:\n");
3634 for (p=channel_operators; *p != (char *) NULL; p++)
3635 (void) printf(" %s\n",*p);
3636 (void) printf("\nImage Sequence Operators:\n");
3637 for (p=sequence_operators; *p != (char *) NULL; p++)
3638 (void) printf(" %s\n",*p);
3639 (void) printf("\nImage Stack Operators:\n");
3640 for (p=stack_operators; *p != (char *) NULL; p++)
3641 (void) printf(" %s\n",*p);
3642 (void) printf("\nMiscellaneous Options:\n");
3643 for (p=miscellaneous; *p != (char *) NULL; p++)
3644 (void) printf(" %s\n",*p);
3646 "\nBy default, the image format of 'file' is determined by its magic\n");
3648 "number. To specify a particular image format, precede the filename\n");
3650 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3652 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3653 (void) printf("'-' for standard input or output.\n");
3654 return(MagickFalse);
3657 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3658 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3660 #define DestroyMogrify() \
3662 if (format != (char *) NULL) \
3663 format=DestroyString(format); \
3664 if (path != (char *) NULL) \
3665 path=DestroyString(path); \
3666 DestroyImageStack(); \
3667 for (i=0; i < (ssize_t) argc; i++) \
3668 argv[i]=DestroyString(argv[i]); \
3669 argv=(char **) RelinquishMagickMemory(argv); \
3671 #define ThrowMogrifyException(asperity,tag,option) \
3673 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3676 return(MagickFalse); \
3678 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3680 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3681 "InvalidArgument","'%s': %s",argument,option); \
3683 return(MagickFalse); \
3695 image_stack[MaxImageStackDepth+1];
3703 respect_parenthesis;
3718 assert(image_info != (ImageInfo *) NULL);
3719 assert(image_info->signature == MagickSignature);
3720 if (image_info->debug != MagickFalse)
3721 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3722 assert(exception != (ExceptionInfo *) NULL);
3726 if ((LocaleCompare("version",option+1) == 0) ||
3727 (LocaleCompare("-version",option+1) == 0))
3729 ListMagickVersion(stdout);
3730 return(MagickFalse);
3734 return(MogrifyUsage());
3735 format=(char *) NULL;
3737 global_colormap=MagickFalse;
3741 option=(char *) NULL;
3743 respect_parenthesis=MagickFalse;
3748 ReadCommandlLine(argc,&argv);
3749 status=ExpandFilenames(&argc,&argv);
3750 if (status == MagickFalse)
3751 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3752 GetExceptionMessage(errno));
3753 for (i=1; i < (ssize_t) argc; i++)
3756 if (LocaleCompare(option,"(") == 0)
3758 FireImageStack(MagickFalse,MagickTrue,pend);
3759 if (k == MaxImageStackDepth)
3760 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3765 if (LocaleCompare(option,")") == 0)
3767 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3769 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3773 if (IsCommandOption(option) == MagickFalse)
3776 backup_filename[MaxTextExtent],
3783 Option is a file name: begin by reading image from specified file.
3785 FireImageStack(MagickFalse,MagickFalse,pend);
3787 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3789 images=ReadImages(image_info,filename,exception);
3790 status&=(images != (Image *) NULL) &&
3791 (exception->severity < ErrorException);
3792 if (images == (Image *) NULL)
3794 if (format != (char *) NULL)
3795 (void) CopyMagickString(images->filename,images->magick_filename,
3797 if (path != (char *) NULL)
3799 GetPathComponent(option,TailPath,filename);
3800 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3801 path,*DirectorySeparator,filename);
3803 if (format != (char *) NULL)
3804 AppendImageFormat(format,images->filename);
3805 AppendImageStack(images);
3806 FinalizeImageSettings(image_info,image,MagickFalse);
3807 if (global_colormap != MagickFalse)
3812 quantize_info=AcquireQuantizeInfo(image_info);
3813 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3814 quantize_info=DestroyQuantizeInfo(quantize_info);
3816 *backup_filename='\0';
3817 if ((LocaleCompare(image->filename,"-") != 0) &&
3818 (IsPathWritable(image->filename) != MagickFalse))
3824 Rename image file as backup.
3826 (void) CopyMagickString(backup_filename,image->filename,
3828 for (i=0; i < 6; i++)
3830 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3831 if (IsPathAccessible(backup_filename) == MagickFalse)
3834 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3835 (rename_utf8(image->filename,backup_filename) != 0))
3836 *backup_filename='\0';
3839 Write transmogrified image to disk.
3841 image_info->synchronize=MagickTrue;
3842 status&=WriteImages(image_info,image,image->filename,exception);
3843 if ((status == MagickFalse) && (*backup_filename != '\0'))
3844 (void) remove_utf8(backup_filename);
3845 RemoveAllImageStack();
3848 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3849 switch (*(option+1))
3853 if (LocaleCompare("adaptive-blur",option+1) == 0)
3856 if (i == (ssize_t) argc)
3857 ThrowMogrifyException(OptionError,"MissingArgument",option);
3858 if (IsGeometry(argv[i]) == MagickFalse)
3859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3862 if (LocaleCompare("adaptive-resize",option+1) == 0)
3865 if (i == (ssize_t) argc)
3866 ThrowMogrifyException(OptionError,"MissingArgument",option);
3867 if (IsGeometry(argv[i]) == MagickFalse)
3868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3871 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3874 if (i == (ssize_t) argc)
3875 ThrowMogrifyException(OptionError,"MissingArgument",option);
3876 if (IsGeometry(argv[i]) == MagickFalse)
3877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3880 if (LocaleCompare("affine",option+1) == 0)
3885 if (i == (ssize_t) argc)
3886 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 if (LocaleCompare("alpha",option+1) == 0)
3897 if (i == (ssize_t) argc)
3898 ThrowMogrifyException(OptionError,"MissingArgument",option);
3899 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
3901 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
3905 if (LocaleCompare("annotate",option+1) == 0)
3910 if (i == (ssize_t) argc)
3911 ThrowMogrifyException(OptionError,"MissingArgument",option);
3912 if (IsGeometry(argv[i]) == MagickFalse)
3913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3914 if (i == (ssize_t) argc)
3915 ThrowMogrifyException(OptionError,"MissingArgument",option);
3919 if (LocaleCompare("antialias",option+1) == 0)
3921 if (LocaleCompare("append",option+1) == 0)
3923 if (LocaleCompare("attenuate",option+1) == 0)
3928 if (i == (ssize_t) argc)
3929 ThrowMogrifyException(OptionError,"MissingArgument",option);
3930 if (IsGeometry(argv[i]) == MagickFalse)
3931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 if (LocaleCompare("authenticate",option+1) == 0)
3939 if (i == (ssize_t) argc)
3940 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (LocaleCompare("auto-gamma",option+1) == 0)
3945 if (LocaleCompare("auto-level",option+1) == 0)
3947 if (LocaleCompare("auto-orient",option+1) == 0)
3949 if (LocaleCompare("average",option+1) == 0)
3951 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3955 if (LocaleCompare("background",option+1) == 0)
3960 if (i == (ssize_t) argc)
3961 ThrowMogrifyException(OptionError,"MissingArgument",option);
3964 if (LocaleCompare("bias",option+1) == 0)
3969 if (i == (ssize_t) argc)
3970 ThrowMogrifyException(OptionError,"MissingArgument",option);
3971 if (IsGeometry(argv[i]) == MagickFalse)
3972 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3975 if (LocaleCompare("black-point-compensation",option+1) == 0)
3977 if (LocaleCompare("black-threshold",option+1) == 0)
3982 if (i == (ssize_t) argc)
3983 ThrowMogrifyException(OptionError,"MissingArgument",option);
3984 if (IsGeometry(argv[i]) == MagickFalse)
3985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3988 if (LocaleCompare("blue-primary",option+1) == 0)
3993 if (i == (ssize_t) argc)
3994 ThrowMogrifyException(OptionError,"MissingArgument",option);
3995 if (IsGeometry(argv[i]) == MagickFalse)
3996 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3999 if (LocaleCompare("blue-shift",option+1) == 0)
4002 if (i == (ssize_t) argc)
4003 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 if (IsGeometry(argv[i]) == MagickFalse)
4005 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4008 if (LocaleCompare("blur",option+1) == 0)
4011 if (i == (ssize_t) argc)
4012 ThrowMogrifyException(OptionError,"MissingArgument",option);
4013 if (IsGeometry(argv[i]) == MagickFalse)
4014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4017 if (LocaleCompare("border",option+1) == 0)
4022 if (i == (ssize_t) argc)
4023 ThrowMogrifyException(OptionError,"MissingArgument",option);
4024 if (IsGeometry(argv[i]) == MagickFalse)
4025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4028 if (LocaleCompare("bordercolor",option+1) == 0)
4033 if (i == (ssize_t) argc)
4034 ThrowMogrifyException(OptionError,"MissingArgument",option);
4037 if (LocaleCompare("box",option+1) == 0)
4042 if (i == (ssize_t) argc)
4043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4046 if (LocaleCompare("brightness-contrast",option+1) == 0)
4049 if (i == (ssize_t) argc)
4050 ThrowMogrifyException(OptionError,"MissingArgument",option);
4051 if (IsGeometry(argv[i]) == MagickFalse)
4052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4055 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4059 if (LocaleCompare("cache",option+1) == 0)
4064 if (i == (ssize_t) argc)
4065 ThrowMogrifyException(OptionError,"MissingArgument",option);
4066 if (IsGeometry(argv[i]) == MagickFalse)
4067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4070 if (LocaleCompare("canny",option+1) == 0)
4075 if (i == (ssize_t) argc)
4076 ThrowMogrifyException(OptionError,"MissingArgument",option);
4077 if (IsGeometry(argv[i]) == MagickFalse)
4078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4081 if (LocaleCompare("caption",option+1) == 0)
4086 if (i == (ssize_t) argc)
4087 ThrowMogrifyException(OptionError,"MissingArgument",option);
4090 if (LocaleCompare("channel",option+1) == 0)
4098 if (i == (ssize_t) argc)
4099 ThrowMogrifyException(OptionError,"MissingArgument",option);
4100 channel=ParseChannelOption(argv[i]);
4102 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4106 if (LocaleCompare("channel-fx",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 channel=ParsePixelChannelOption(argv[i]);
4118 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4122 if (LocaleCompare("cdl",option+1) == 0)
4127 if (i == (ssize_t) argc)
4128 ThrowMogrifyException(OptionError,"MissingArgument",option);
4131 if (LocaleCompare("charcoal",option+1) == 0)
4136 if (i == (ssize_t) argc)
4137 ThrowMogrifyException(OptionError,"MissingArgument",option);
4138 if (IsGeometry(argv[i]) == MagickFalse)
4139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4142 if (LocaleCompare("chop",option+1) == 0)
4147 if (i == (ssize_t) argc)
4148 ThrowMogrifyException(OptionError,"MissingArgument",option);
4149 if (IsGeometry(argv[i]) == MagickFalse)
4150 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4153 if (LocaleCompare("clamp",option+1) == 0)
4155 if (LocaleCompare("clip",option+1) == 0)
4157 if (LocaleCompare("clip-mask",option+1) == 0)
4162 if (i == (ssize_t) argc)
4163 ThrowMogrifyException(OptionError,"MissingArgument",option);
4166 if (LocaleCompare("clut",option+1) == 0)
4168 if (LocaleCompare("coalesce",option+1) == 0)
4170 if (LocaleCompare("colorize",option+1) == 0)
4175 if (i == (ssize_t) argc)
4176 ThrowMogrifyException(OptionError,"MissingArgument",option);
4177 if (IsGeometry(argv[i]) == MagickFalse)
4178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4181 if (LocaleCompare("color-matrix",option+1) == 0)
4189 if (i == (ssize_t) argc)
4190 ThrowMogrifyException(OptionError,"MissingArgument",option);
4191 kernel_info=AcquireKernelInfo(argv[i]);
4192 if (kernel_info == (KernelInfo *) NULL)
4193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 kernel_info=DestroyKernelInfo(kernel_info);
4197 if (LocaleCompare("colors",option+1) == 0)
4202 if (i == (ssize_t) argc)
4203 ThrowMogrifyException(OptionError,"MissingArgument",option);
4204 if (IsGeometry(argv[i]) == MagickFalse)
4205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4208 if (LocaleCompare("colorspace",option+1) == 0)
4216 if (i == (ssize_t) argc)
4217 ThrowMogrifyException(OptionError,"MissingArgument",option);
4218 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4221 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4225 if (LocaleCompare("combine",option+1) == 0)
4233 if (i == (ssize_t) argc)
4234 ThrowMogrifyException(OptionError,"MissingArgument",option);
4235 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4238 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4242 if (LocaleCompare("compare",option+1) == 0)
4244 if (LocaleCompare("comment",option+1) == 0)
4249 if (i == (ssize_t) argc)
4250 ThrowMogrifyException(OptionError,"MissingArgument",option);
4253 if (LocaleCompare("composite",option+1) == 0)
4255 if (LocaleCompare("compress",option+1) == 0)
4263 if (i == (ssize_t) argc)
4264 ThrowMogrifyException(OptionError,"MissingArgument",option);
4265 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4268 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4272 if (LocaleCompare("concurrent",option+1) == 0)
4274 if (LocaleCompare("contrast",option+1) == 0)
4276 if (LocaleCompare("contrast-stretch",option+1) == 0)
4279 if (i == (ssize_t) argc)
4280 ThrowMogrifyException(OptionError,"MissingArgument",option);
4281 if (IsGeometry(argv[i]) == MagickFalse)
4282 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4285 if (LocaleCompare("convolve",option+1) == 0)
4293 if (i == (ssize_t) argc)
4294 ThrowMogrifyException(OptionError,"MissingArgument",option);
4295 kernel_info=AcquireKernelInfo(argv[i]);
4296 if (kernel_info == (KernelInfo *) NULL)
4297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4298 kernel_info=DestroyKernelInfo(kernel_info);
4301 if (LocaleCompare("crop",option+1) == 0)
4306 if (i == (ssize_t) argc)
4307 ThrowMogrifyException(OptionError,"MissingArgument",option);
4308 if (IsGeometry(argv[i]) == MagickFalse)
4309 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4312 if (LocaleCompare("cycle",option+1) == 0)
4317 if (i == (ssize_t) argc)
4318 ThrowMogrifyException(OptionError,"MissingArgument",option);
4319 if (IsGeometry(argv[i]) == MagickFalse)
4320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4323 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4327 if (LocaleCompare("decipher",option+1) == 0)
4332 if (i == (ssize_t) argc)
4333 ThrowMogrifyException(OptionError,"MissingArgument",option);
4336 if (LocaleCompare("deconstruct",option+1) == 0)
4338 if (LocaleCompare("debug",option+1) == 0)
4346 if (i == (ssize_t) argc)
4347 ThrowMogrifyException(OptionError,"MissingArgument",option);
4348 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4350 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4352 (void) SetLogEventMask(argv[i]);
4355 if (LocaleCompare("define",option+1) == 0)
4358 if (i == (ssize_t) argc)
4359 ThrowMogrifyException(OptionError,"MissingArgument",option);
4365 define=GetImageOption(image_info,argv[i]);
4366 if (define == (const char *) NULL)
4367 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4372 if (LocaleCompare("delay",option+1) == 0)
4377 if (i == (ssize_t) argc)
4378 ThrowMogrifyException(OptionError,"MissingArgument",option);
4379 if (IsGeometry(argv[i]) == MagickFalse)
4380 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4383 if (LocaleCompare("delete",option+1) == 0)
4388 if (i == (ssize_t) argc)
4389 ThrowMogrifyException(OptionError,"MissingArgument",option);
4390 if (IsGeometry(argv[i]) == MagickFalse)
4391 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4394 if (LocaleCompare("density",option+1) == 0)
4399 if (i == (ssize_t) argc)
4400 ThrowMogrifyException(OptionError,"MissingArgument",option);
4401 if (IsGeometry(argv[i]) == MagickFalse)
4402 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4405 if (LocaleCompare("depth",option+1) == 0)
4410 if (i == (ssize_t) argc)
4411 ThrowMogrifyException(OptionError,"MissingArgument",option);
4412 if (IsGeometry(argv[i]) == MagickFalse)
4413 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4416 if (LocaleCompare("deskew",option+1) == 0)
4421 if (i == (ssize_t) argc)
4422 ThrowMogrifyException(OptionError,"MissingArgument",option);
4423 if (IsGeometry(argv[i]) == MagickFalse)
4424 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4427 if (LocaleCompare("despeckle",option+1) == 0)
4429 if (LocaleCompare("dft",option+1) == 0)
4431 if (LocaleCompare("direction",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4441 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4444 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4448 if (LocaleCompare("display",option+1) == 0)
4453 if (i == (ssize_t) argc)
4454 ThrowMogrifyException(OptionError,"MissingArgument",option);
4457 if (LocaleCompare("dispose",option+1) == 0)
4465 if (i == (ssize_t) argc)
4466 ThrowMogrifyException(OptionError,"MissingArgument",option);
4467 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4469 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4473 if (LocaleCompare("distort",option+1) == 0)
4479 if (i == (ssize_t) argc)
4480 ThrowMogrifyException(OptionError,"MissingArgument",option);
4481 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4483 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4486 if (i == (ssize_t) argc)
4487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4490 if (LocaleCompare("dither",option+1) == 0)
4498 if (i == (ssize_t) argc)
4499 ThrowMogrifyException(OptionError,"MissingArgument",option);
4500 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4502 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4506 if (LocaleCompare("draw",option+1) == 0)
4511 if (i == (ssize_t) argc)
4512 ThrowMogrifyException(OptionError,"MissingArgument",option);
4515 if (LocaleCompare("duplicate",option+1) == 0)
4520 if (i == (ssize_t) argc)
4521 ThrowMogrifyException(OptionError,"MissingArgument",option);
4522 if (IsGeometry(argv[i]) == MagickFalse)
4523 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4526 if (LocaleCompare("duration",option+1) == 0)
4531 if (i == (ssize_t) argc)
4532 ThrowMogrifyException(OptionError,"MissingArgument",option);
4533 if (IsGeometry(argv[i]) == MagickFalse)
4534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4537 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4541 if (LocaleCompare("edge",option+1) == 0)
4546 if (i == (ssize_t) argc)
4547 ThrowMogrifyException(OptionError,"MissingArgument",option);
4548 if (IsGeometry(argv[i]) == MagickFalse)
4549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4552 if (LocaleCompare("emboss",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("encipher",option+1) == 0)
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4572 if (LocaleCompare("encoding",option+1) == 0)
4577 if (i == (ssize_t) argc)
4578 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (LocaleCompare("endian",option+1) == 0)
4589 if (i == (ssize_t) argc)
4590 ThrowMogrifyException(OptionError,"MissingArgument",option);
4591 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4593 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4597 if (LocaleCompare("enhance",option+1) == 0)
4599 if (LocaleCompare("equalize",option+1) == 0)
4601 if (LocaleCompare("evaluate",option+1) == 0)
4609 if (i == (ssize_t) argc)
4610 ThrowMogrifyException(OptionError,"MissingArgument",option);
4611 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4613 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4616 if (i == (ssize_t) argc)
4617 ThrowMogrifyException(OptionError,"MissingArgument",option);
4618 if (IsGeometry(argv[i]) == MagickFalse)
4619 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4622 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4630 if (i == (ssize_t) argc)
4631 ThrowMogrifyException(OptionError,"MissingArgument",option);
4632 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4634 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4638 if (LocaleCompare("extent",option+1) == 0)
4643 if (i == (ssize_t) argc)
4644 ThrowMogrifyException(OptionError,"MissingArgument",option);
4645 if (IsGeometry(argv[i]) == MagickFalse)
4646 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4649 if (LocaleCompare("extract",option+1) == 0)
4654 if (i == (ssize_t) argc)
4655 ThrowMogrifyException(OptionError,"MissingArgument",option);
4656 if (IsGeometry(argv[i]) == MagickFalse)
4657 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4660 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4664 if (LocaleCompare("family",option+1) == 0)
4669 if (i == (ssize_t) argc)
4670 ThrowMogrifyException(OptionError,"MissingArgument",option);
4673 if (LocaleCompare("features",option+1) == 0)
4678 if (i == (ssize_t) argc)
4679 ThrowMogrifyException(OptionError,"MissingArgument",option);
4680 if (IsGeometry(argv[i]) == MagickFalse)
4681 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4684 if (LocaleCompare("fill",option+1) == 0)
4689 if (i == (ssize_t) argc)
4690 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 if (LocaleCompare("filter",option+1) == 0)
4701 if (i == (ssize_t) argc)
4702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4705 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4709 if (LocaleCompare("flatten",option+1) == 0)
4711 if (LocaleCompare("flip",option+1) == 0)
4713 if (LocaleCompare("flop",option+1) == 0)
4715 if (LocaleCompare("floodfill",option+1) == 0)
4720 if (i == (ssize_t) argc)
4721 ThrowMogrifyException(OptionError,"MissingArgument",option);
4722 if (IsGeometry(argv[i]) == MagickFalse)
4723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4725 if (i == (ssize_t) argc)
4726 ThrowMogrifyException(OptionError,"MissingArgument",option);
4729 if (LocaleCompare("font",option+1) == 0)
4734 if (i == (ssize_t) argc)
4735 ThrowMogrifyException(OptionError,"MissingArgument",option);
4738 if (LocaleCompare("format",option+1) == 0)
4740 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4741 (void) CloneString(&format,(char *) NULL);
4745 if (i == (ssize_t) argc)
4746 ThrowMogrifyException(OptionError,"MissingArgument",option);
4747 (void) CloneString(&format,argv[i]);
4748 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4749 (void) ConcatenateMagickString(image_info->filename,":",
4751 (void) SetImageInfo(image_info,0,exception);
4752 if (*image_info->magick == '\0')
4753 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4757 if (LocaleCompare("frame",option+1) == 0)
4762 if (i == (ssize_t) argc)
4763 ThrowMogrifyException(OptionError,"MissingArgument",option);
4764 if (IsGeometry(argv[i]) == MagickFalse)
4765 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4768 if (LocaleCompare("function",option+1) == 0)
4776 if (i == (ssize_t) argc)
4777 ThrowMogrifyException(OptionError,"MissingArgument",option);
4778 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4780 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4782 if (i == (ssize_t) argc)
4783 ThrowMogrifyException(OptionError,"MissingArgument",option);
4786 if (LocaleCompare("fuzz",option+1) == 0)
4791 if (i == (ssize_t) argc)
4792 ThrowMogrifyException(OptionError,"MissingArgument",option);
4793 if (IsGeometry(argv[i]) == MagickFalse)
4794 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4797 if (LocaleCompare("fx",option+1) == 0)
4802 if (i == (ssize_t) argc)
4803 ThrowMogrifyException(OptionError,"MissingArgument",option);
4806 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4810 if (LocaleCompare("gamma",option+1) == 0)
4813 if (i == (ssize_t) argc)
4814 ThrowMogrifyException(OptionError,"MissingArgument",option);
4815 if (IsGeometry(argv[i]) == MagickFalse)
4816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4819 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4820 (LocaleCompare("gaussian",option+1) == 0))
4823 if (i == (ssize_t) argc)
4824 ThrowMogrifyException(OptionError,"MissingArgument",option);
4825 if (IsGeometry(argv[i]) == MagickFalse)
4826 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4829 if (LocaleCompare("geometry",option+1) == 0)
4834 if (i == (ssize_t) argc)
4835 ThrowMogrifyException(OptionError,"MissingArgument",option);
4836 if (IsGeometry(argv[i]) == MagickFalse)
4837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4840 if (LocaleCompare("gravity",option+1) == 0)
4848 if (i == (ssize_t) argc)
4849 ThrowMogrifyException(OptionError,"MissingArgument",option);
4850 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
4853 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4857 if (LocaleCompare("grayscale",option+1) == 0)
4865 if (i == (ssize_t) argc)
4866 ThrowMogrifyException(OptionError,"MissingArgument",option);
4867 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4870 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
4874 if (LocaleCompare("green-primary",option+1) == 0)
4879 if (i == (ssize_t) argc)
4880 ThrowMogrifyException(OptionError,"MissingArgument",option);
4881 if (IsGeometry(argv[i]) == MagickFalse)
4882 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4885 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4889 if (LocaleCompare("hald-clut",option+1) == 0)
4891 if ((LocaleCompare("help",option+1) == 0) ||
4892 (LocaleCompare("-help",option+1) == 0))
4893 return(MogrifyUsage());
4894 if (LocaleCompare("hough-lines",option+1) == 0)
4899 if (i == (ssize_t) argc)
4900 ThrowMogrifyException(OptionError,"MissingArgument",option);
4901 if (IsGeometry(argv[i]) == MagickFalse)
4902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4905 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4909 if (LocaleCompare("identify",option+1) == 0)
4911 if (LocaleCompare("idft",option+1) == 0)
4913 if (LocaleCompare("implode",option+1) == 0)
4918 if (i == (ssize_t) argc)
4919 ThrowMogrifyException(OptionError,"MissingArgument",option);
4920 if (IsGeometry(argv[i]) == MagickFalse)
4921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4924 if (LocaleCompare("intensity",option+1) == 0)
4932 if (i == (ssize_t) argc)
4933 ThrowMogrifyException(OptionError,"MissingArgument",option);
4934 intensity=ParseCommandOption(MagickPixelIntensityOptions,
4935 MagickFalse,argv[i]);
4937 ThrowMogrifyException(OptionError,
4938 "UnrecognizedPixelIntensityMethod",argv[i]);
4941 if (LocaleCompare("intent",option+1) == 0)
4949 if (i == (ssize_t) argc)
4950 ThrowMogrifyException(OptionError,"MissingArgument",option);
4951 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4953 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4957 if (LocaleCompare("interlace",option+1) == 0)
4965 if (i == (ssize_t) argc)
4966 ThrowMogrifyException(OptionError,"MissingArgument",option);
4967 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4970 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4974 if (LocaleCompare("interline-spacing",option+1) == 0)
4979 if (i == (ssize_t) argc)
4980 ThrowMogrifyException(OptionError,"MissingArgument",option);
4981 if (IsGeometry(argv[i]) == MagickFalse)
4982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4985 if (LocaleCompare("interpolate",option+1) == 0)
4993 if (i == (ssize_t) argc)
4994 ThrowMogrifyException(OptionError,"MissingArgument",option);
4995 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4997 if (interpolate < 0)
4998 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5002 if (LocaleCompare("interword-spacing",option+1) == 0)
5007 if (i == (ssize_t) argc)
5008 ThrowMogrifyException(OptionError,"MissingArgument",option);
5009 if (IsGeometry(argv[i]) == MagickFalse)
5010 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5013 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5017 if (LocaleCompare("kerning",option+1) == 0)
5022 if (i == (ssize_t) argc)
5023 ThrowMogrifyException(OptionError,"MissingArgument",option);
5024 if (IsGeometry(argv[i]) == MagickFalse)
5025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5028 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5032 if (LocaleCompare("label",option+1) == 0)
5037 if (i == (ssize_t) argc)
5038 ThrowMogrifyException(OptionError,"MissingArgument",option);
5041 if (LocaleCompare("lat",option+1) == 0)
5046 if (i == (ssize_t) argc)
5047 ThrowMogrifyException(OptionError,"MissingArgument",option);
5048 if (IsGeometry(argv[i]) == MagickFalse)
5049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5051 if (LocaleCompare("layers",option+1) == 0)
5059 if (i == (ssize_t) argc)
5060 ThrowMogrifyException(OptionError,"MissingArgument",option);
5061 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5063 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5067 if (LocaleCompare("level",option+1) == 0)
5070 if (i == (ssize_t) argc)
5071 ThrowMogrifyException(OptionError,"MissingArgument",option);
5072 if (IsGeometry(argv[i]) == MagickFalse)
5073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5076 if (LocaleCompare("level-colors",option+1) == 0)
5079 if (i == (ssize_t) argc)
5080 ThrowMogrifyException(OptionError,"MissingArgument",option);
5083 if (LocaleCompare("limit",option+1) == 0)
5097 if (i == (ssize_t) argc)
5098 ThrowMogrifyException(OptionError,"MissingArgument",option);
5099 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5102 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5105 if (i == (ssize_t) argc)
5106 ThrowMogrifyException(OptionError,"MissingArgument",option);
5107 value=StringToDouble(argv[i],&p);
5109 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5110 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5113 if (LocaleCompare("liquid-rescale",option+1) == 0)
5116 if (i == (ssize_t) argc)
5117 ThrowMogrifyException(OptionError,"MissingArgument",option);
5118 if (IsGeometry(argv[i]) == MagickFalse)
5119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5122 if (LocaleCompare("list",option+1) == 0)
5130 if (i == (ssize_t) argc)
5131 ThrowMogrifyException(OptionError,"MissingArgument",option);
5132 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5134 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5135 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5137 return(status != 0 ? MagickFalse : MagickTrue);
5139 if (LocaleCompare("log",option+1) == 0)
5144 if ((i == (ssize_t) argc) ||
5145 (strchr(argv[i],'%') == (char *) NULL))
5146 ThrowMogrifyException(OptionError,"MissingArgument",option);
5149 if (LocaleCompare("loop",option+1) == 0)
5154 if (i == (ssize_t) argc)
5155 ThrowMogrifyException(OptionError,"MissingArgument",option);
5156 if (IsGeometry(argv[i]) == MagickFalse)
5157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5160 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5164 if (LocaleCompare("map",option+1) == 0)
5166 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5170 if (i == (ssize_t) argc)
5171 ThrowMogrifyException(OptionError,"MissingArgument",option);
5174 if (LocaleCompare("mask",option+1) == 0)
5179 if (i == (ssize_t) argc)
5180 ThrowMogrifyException(OptionError,"MissingArgument",option);
5183 if (LocaleCompare("matte",option+1) == 0)
5185 if (LocaleCompare("mattecolor",option+1) == 0)
5190 if (i == (ssize_t) argc)
5191 ThrowMogrifyException(OptionError,"MissingArgument",option);
5194 if (LocaleCompare("maximum",option+1) == 0)
5196 if (LocaleCompare("mean-shift",option+1) == 0)
5201 if (i == (ssize_t) argc)
5202 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 if (IsGeometry(argv[i]) == MagickFalse)
5204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5207 if (LocaleCompare("median",option+1) == 0)
5212 if (i == (ssize_t) argc)
5213 ThrowMogrifyException(OptionError,"MissingArgument",option);
5214 if (IsGeometry(argv[i]) == MagickFalse)
5215 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5218 if (LocaleCompare("metric",option+1) == 0)
5226 if (i == (ssize_t) argc)
5227 ThrowMogrifyException(OptionError,"MissingArgument",option);
5228 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5230 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5234 if (LocaleCompare("minimum",option+1) == 0)
5236 if (LocaleCompare("modulate",option+1) == 0)
5241 if (i == (ssize_t) argc)
5242 ThrowMogrifyException(OptionError,"MissingArgument",option);
5243 if (IsGeometry(argv[i]) == MagickFalse)
5244 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5247 if (LocaleCompare("mode",option+1) == 0)
5252 if (i == (ssize_t) argc)
5253 ThrowMogrifyException(OptionError,"MissingArgument",option);
5254 if (IsGeometry(argv[i]) == MagickFalse)
5255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5258 if (LocaleCompare("monitor",option+1) == 0)
5260 if (LocaleCompare("monochrome",option+1) == 0)
5262 if (LocaleCompare("morph",option+1) == 0)
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,"MissingArgument",option);
5269 if (IsGeometry(argv[i]) == MagickFalse)
5270 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5273 if (LocaleCompare("morphology",option+1) == 0)
5276 token[MaxTextExtent];
5285 if (i == (ssize_t) argc)
5286 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 GetMagickToken(argv[i],NULL,token);
5288 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5290 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5293 if (i == (ssize_t) argc)
5294 ThrowMogrifyException(OptionError,"MissingArgument",option);
5295 kernel_info=AcquireKernelInfo(argv[i]);
5296 if (kernel_info == (KernelInfo *) NULL)
5297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5298 kernel_info=DestroyKernelInfo(kernel_info);
5301 if (LocaleCompare("mosaic",option+1) == 0)
5303 if (LocaleCompare("motion-blur",option+1) == 0)
5308 if (i == (ssize_t) argc)
5309 ThrowMogrifyException(OptionError,"MissingArgument",option);
5310 if (IsGeometry(argv[i]) == MagickFalse)
5311 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5314 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5318 if (LocaleCompare("negate",option+1) == 0)
5320 if (LocaleCompare("noise",option+1) == 0)
5323 if (i == (ssize_t) argc)
5324 ThrowMogrifyException(OptionError,"MissingArgument",option);
5330 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5332 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5336 if (IsGeometry(argv[i]) == MagickFalse)
5337 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5340 if (LocaleCompare("noop",option+1) == 0)
5342 if (LocaleCompare("normalize",option+1) == 0)
5344 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5348 if (LocaleCompare("opaque",option+1) == 0)
5351 if (i == (ssize_t) argc)
5352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5355 if (LocaleCompare("ordered-dither",option+1) == 0)
5360 if (i == (ssize_t) argc)
5361 ThrowMogrifyException(OptionError,"MissingArgument",option);
5364 if (LocaleCompare("orient",option+1) == 0)
5369 orientation=UndefinedOrientation;
5373 if (i == (ssize_t) argc)
5374 ThrowMogrifyException(OptionError,"MissingArgument",option);
5375 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5377 if (orientation < 0)
5378 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5382 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5386 if (LocaleCompare("page",option+1) == 0)
5391 if (i == (ssize_t) argc)
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5395 if (LocaleCompare("paint",option+1) == 0)
5400 if (i == (ssize_t) argc)
5401 ThrowMogrifyException(OptionError,"MissingArgument",option);
5402 if (IsGeometry(argv[i]) == MagickFalse)
5403 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5406 if (LocaleCompare("path",option+1) == 0)
5408 (void) CloneString(&path,(char *) NULL);
5412 if (i == (ssize_t) argc)
5413 ThrowMogrifyException(OptionError,"MissingArgument",option);
5414 (void) CloneString(&path,argv[i]);
5417 if (LocaleCompare("perceptible",option+1) == 0)
5422 if (i == (ssize_t) argc)
5423 ThrowMogrifyException(OptionError,"MissingArgument",option);
5424 if (IsGeometry(argv[i]) == MagickFalse)
5425 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5428 if (LocaleCompare("pointsize",option+1) == 0)
5433 if (i == (ssize_t) argc)
5434 ThrowMogrifyException(OptionError,"MissingArgument",option);
5435 if (IsGeometry(argv[i]) == MagickFalse)
5436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5439 if (LocaleCompare("polaroid",option+1) == 0)
5444 if (i == (ssize_t) argc)
5445 ThrowMogrifyException(OptionError,"MissingArgument",option);
5446 if (IsGeometry(argv[i]) == MagickFalse)
5447 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5450 if (LocaleCompare("poly",option+1) == 0)
5455 if (i == (ssize_t) argc)
5456 ThrowMogrifyException(OptionError,"MissingArgument",option);
5457 if (IsGeometry(argv[i]) == MagickFalse)
5458 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5461 if (LocaleCompare("posterize",option+1) == 0)
5466 if (i == (ssize_t) argc)
5467 ThrowMogrifyException(OptionError,"MissingArgument",option);
5468 if (IsGeometry(argv[i]) == MagickFalse)
5469 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5472 if (LocaleCompare("precision",option+1) == 0)
5477 if (i == (ssize_t) argc)
5478 ThrowMogrifyException(OptionError,"MissingArgument",option);
5479 if (IsGeometry(argv[i]) == MagickFalse)
5480 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5483 if (LocaleCompare("print",option+1) == 0)
5488 if (i == (ssize_t) argc)
5489 ThrowMogrifyException(OptionError,"MissingArgument",option);
5492 if (LocaleCompare("process",option+1) == 0)
5497 if (i == (ssize_t) argc)
5498 ThrowMogrifyException(OptionError,"MissingArgument",option);
5501 if (LocaleCompare("profile",option+1) == 0)
5504 if (i == (ssize_t) argc)
5505 ThrowMogrifyException(OptionError,"MissingArgument",option);
5508 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5512 if (LocaleCompare("quality",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("quantize",option+1) == 0)
5531 if (i == (ssize_t) argc)
5532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5536 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5540 if (LocaleCompare("quiet",option+1) == 0)
5542 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5546 if (LocaleCompare("rotational-blur",option+1) == 0)
5549 if (i == (ssize_t) argc)
5550 ThrowMogrifyException(OptionError,"MissingArgument",option);
5551 if (IsGeometry(argv[i]) == MagickFalse)
5552 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5555 if (LocaleCompare("raise",option+1) == 0)
5558 if (i == (ssize_t) argc)
5559 ThrowMogrifyException(OptionError,"MissingArgument",option);
5560 if (IsGeometry(argv[i]) == MagickFalse)
5561 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5564 if (LocaleCompare("random-threshold",option+1) == 0)
5569 if (i == (ssize_t) argc)
5570 ThrowMogrifyException(OptionError,"MissingArgument",option);
5571 if (IsGeometry(argv[i]) == MagickFalse)
5572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5575 if (LocaleCompare("red-primary",option+1) == 0)
5580 if (i == (ssize_t) argc)
5581 ThrowMogrifyException(OptionError,"MissingArgument",option);
5582 if (IsGeometry(argv[i]) == MagickFalse)
5583 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5585 if (LocaleCompare("regard-warnings",option+1) == 0)
5587 if (LocaleCompare("region",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("remap",option+1) == 0)
5603 if (i == (ssize_t) argc)
5604 ThrowMogrifyException(OptionError,"MissingArgument",option);
5607 if (LocaleCompare("render",option+1) == 0)
5609 if (LocaleCompare("repage",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("resample",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("resize",option+1) == 0)
5636 if (i == (ssize_t) argc)
5637 ThrowMogrifyException(OptionError,"MissingArgument",option);
5638 if (IsGeometry(argv[i]) == MagickFalse)
5639 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5644 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5647 if (LocaleCompare("reverse",option+1) == 0)
5649 if (LocaleCompare("roll",option+1) == 0)
5654 if (i == (ssize_t) argc)
5655 ThrowMogrifyException(OptionError,"MissingArgument",option);
5656 if (IsGeometry(argv[i]) == MagickFalse)
5657 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5660 if (LocaleCompare("rotate",option+1) == 0)
5663 if (i == (ssize_t) argc)
5664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 if (IsGeometry(argv[i]) == MagickFalse)
5666 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5669 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5673 if (LocaleCompare("sample",option+1) == 0)
5678 if (i == (ssize_t) argc)
5679 ThrowMogrifyException(OptionError,"MissingArgument",option);
5680 if (IsGeometry(argv[i]) == MagickFalse)
5681 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5684 if (LocaleCompare("sampling-factor",option+1) == 0)
5689 if (i == (ssize_t) argc)
5690 ThrowMogrifyException(OptionError,"MissingArgument",option);
5691 if (IsGeometry(argv[i]) == MagickFalse)
5692 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5695 if (LocaleCompare("scale",option+1) == 0)
5700 if (i == (ssize_t) argc)
5701 ThrowMogrifyException(OptionError,"MissingArgument",option);
5702 if (IsGeometry(argv[i]) == MagickFalse)
5703 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5706 if (LocaleCompare("scene",option+1) == 0)
5711 if (i == (ssize_t) argc)
5712 ThrowMogrifyException(OptionError,"MissingArgument",option);
5713 if (IsGeometry(argv[i]) == MagickFalse)
5714 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5717 if (LocaleCompare("seed",option+1) == 0)
5722 if (i == (ssize_t) argc)
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5724 if (IsGeometry(argv[i]) == MagickFalse)
5725 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5728 if (LocaleCompare("segment",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5735 if (IsGeometry(argv[i]) == MagickFalse)
5736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5739 if (LocaleCompare("selective-blur",option+1) == 0)
5742 if (i == (ssize_t) argc)
5743 ThrowMogrifyException(OptionError,"MissingArgument",option);
5744 if (IsGeometry(argv[i]) == MagickFalse)
5745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 if (LocaleCompare("separate",option+1) == 0)
5750 if (LocaleCompare("sepia-tone",option+1) == 0)
5755 if (i == (ssize_t) argc)
5756 ThrowMogrifyException(OptionError,"MissingArgument",option);
5757 if (IsGeometry(argv[i]) == MagickFalse)
5758 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5761 if (LocaleCompare("set",option+1) == 0)
5764 if (i == (ssize_t) argc)
5765 ThrowMogrifyException(OptionError,"MissingArgument",option);
5769 if (i == (ssize_t) argc)
5770 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (LocaleCompare("shade",option+1) == 0)
5776 if (i == (ssize_t) argc)
5777 ThrowMogrifyException(OptionError,"MissingArgument",option);
5778 if (IsGeometry(argv[i]) == MagickFalse)
5779 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5782 if (LocaleCompare("shadow",option+1) == 0)
5787 if (i == (ssize_t) argc)
5788 ThrowMogrifyException(OptionError,"MissingArgument",option);
5789 if (IsGeometry(argv[i]) == MagickFalse)
5790 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5793 if (LocaleCompare("sharpen",option+1) == 0)
5796 if (i == (ssize_t) argc)
5797 ThrowMogrifyException(OptionError,"MissingArgument",option);
5798 if (IsGeometry(argv[i]) == MagickFalse)
5799 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5802 if (LocaleCompare("shave",option+1) == 0)
5807 if (i == (ssize_t) argc)
5808 ThrowMogrifyException(OptionError,"MissingArgument",option);
5809 if (IsGeometry(argv[i]) == MagickFalse)
5810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5813 if (LocaleCompare("shear",option+1) == 0)
5816 if (i == (ssize_t) argc)
5817 ThrowMogrifyException(OptionError,"MissingArgument",option);
5818 if (IsGeometry(argv[i]) == MagickFalse)
5819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5822 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5825 if (i == (ssize_t) argc)
5826 ThrowMogrifyException(OptionError,"MissingArgument",option);
5827 if (IsGeometry(argv[i]) == MagickFalse)
5828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 if (LocaleCompare("size",option+1) == 0)
5836 if (i == (ssize_t) argc)
5837 ThrowMogrifyException(OptionError,"MissingArgument",option);
5838 if (IsGeometry(argv[i]) == MagickFalse)
5839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5842 if (LocaleCompare("sketch",option+1) == 0)
5847 if (i == (ssize_t) argc)
5848 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (IsGeometry(argv[i]) == MagickFalse)
5850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 if (LocaleCompare("smush",option+1) == 0)
5856 if (i == (ssize_t) argc)
5857 ThrowMogrifyException(OptionError,"MissingArgument",option);
5858 if (IsGeometry(argv[i]) == MagickFalse)
5859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5863 if (LocaleCompare("solarize",option+1) == 0)
5868 if (i == (ssize_t) argc)
5869 ThrowMogrifyException(OptionError,"MissingArgument",option);
5870 if (IsGeometry(argv[i]) == MagickFalse)
5871 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5874 if (LocaleCompare("sparse-color",option+1) == 0)
5880 if (i == (ssize_t) argc)
5881 ThrowMogrifyException(OptionError,"MissingArgument",option);
5882 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5884 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5887 if (i == (ssize_t) argc)
5888 ThrowMogrifyException(OptionError,"MissingArgument",option);
5891 if (LocaleCompare("splice",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("spread",option+1) == 0)
5907 if (i == (ssize_t) argc)
5908 ThrowMogrifyException(OptionError,"MissingArgument",option);
5909 if (IsGeometry(argv[i]) == MagickFalse)
5910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5913 if (LocaleCompare("statistic",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5925 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5928 if (i == (ssize_t) argc)
5929 ThrowMogrifyException(OptionError,"MissingArgument",option);
5930 if (IsGeometry(argv[i]) == MagickFalse)
5931 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5934 if (LocaleCompare("stretch",option+1) == 0)
5942 if (i == (ssize_t) argc)
5943 ThrowMogrifyException(OptionError,"MissingArgument",option);
5944 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5946 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5950 if (LocaleCompare("strip",option+1) == 0)
5952 if (LocaleCompare("stroke",option+1) == 0)
5957 if (i == (ssize_t) argc)
5958 ThrowMogrifyException(OptionError,"MissingArgument",option);
5961 if (LocaleCompare("strokewidth",option+1) == 0)
5966 if (i == (ssize_t) argc)
5967 ThrowMogrifyException(OptionError,"MissingArgument",option);
5968 if (IsGeometry(argv[i]) == MagickFalse)
5969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5972 if (LocaleCompare("style",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,"MissingArgument",option);
5982 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5984 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5988 if (LocaleCompare("swap",option+1) == 0)
5993 if (i == (ssize_t) argc)
5994 ThrowMogrifyException(OptionError,"MissingArgument",option);
5995 if (IsGeometry(argv[i]) == MagickFalse)
5996 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5999 if (LocaleCompare("swirl",option+1) == 0)
6004 if (i == (ssize_t) argc)
6005 ThrowMogrifyException(OptionError,"MissingArgument",option);
6006 if (IsGeometry(argv[i]) == MagickFalse)
6007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6010 if (LocaleCompare("synchronize",option+1) == 0)
6012 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6016 if (LocaleCompare("taint",option+1) == 0)
6018 if (LocaleCompare("texture",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6027 if (LocaleCompare("tile",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6036 if (LocaleCompare("tile-offset",option+1) == 0)
6041 if (i == (ssize_t) argc)
6042 ThrowMogrifyException(OptionError,"MissingArgument",option);
6043 if (IsGeometry(argv[i]) == MagickFalse)
6044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6047 if (LocaleCompare("tint",option+1) == 0)
6052 if (i == (ssize_t) argc)
6053 ThrowMogrifyException(OptionError,"MissingArgument",option);
6054 if (IsGeometry(argv[i]) == MagickFalse)
6055 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6058 if (LocaleCompare("transform",option+1) == 0)
6060 if (LocaleCompare("transpose",option+1) == 0)
6062 if (LocaleCompare("transverse",option+1) == 0)
6064 if (LocaleCompare("threshold",option+1) == 0)
6069 if (i == (ssize_t) argc)
6070 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 if (IsGeometry(argv[i]) == MagickFalse)
6072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6075 if (LocaleCompare("thumbnail",option+1) == 0)
6080 if (i == (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,"MissingArgument",option);
6082 if (IsGeometry(argv[i]) == MagickFalse)
6083 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6086 if (LocaleCompare("transparent",option+1) == 0)
6089 if (i == (ssize_t) argc)
6090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6093 if (LocaleCompare("transparent-color",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6102 if (LocaleCompare("treedepth",option+1) == 0)
6107 if (i == (ssize_t) argc)
6108 ThrowMogrifyException(OptionError,"MissingArgument",option);
6109 if (IsGeometry(argv[i]) == MagickFalse)
6110 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6113 if (LocaleCompare("trim",option+1) == 0)
6115 if (LocaleCompare("type",option+1) == 0)
6123 if (i == (ssize_t) argc)
6124 ThrowMogrifyException(OptionError,"MissingArgument",option);
6125 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6127 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6131 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6135 if (LocaleCompare("undercolor",option+1) == 0)
6140 if (i == (ssize_t) argc)
6141 ThrowMogrifyException(OptionError,"MissingArgument",option);
6144 if (LocaleCompare("unique-colors",option+1) == 0)
6146 if (LocaleCompare("units",option+1) == 0)
6154 if (i == (ssize_t) argc)
6155 ThrowMogrifyException(OptionError,"MissingArgument",option);
6156 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6159 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6163 if (LocaleCompare("unsharp",option+1) == 0)
6166 if (i == (ssize_t) argc)
6167 ThrowMogrifyException(OptionError,"MissingArgument",option);
6168 if (IsGeometry(argv[i]) == MagickFalse)
6169 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6172 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6176 if (LocaleCompare("verbose",option+1) == 0)
6178 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6181 if ((LocaleCompare("version",option+1) == 0) ||
6182 (LocaleCompare("-version",option+1) == 0))
6184 ListMagickVersion(stdout);
6187 if (LocaleCompare("view",option+1) == 0)
6192 if (i == (ssize_t) argc)
6193 ThrowMogrifyException(OptionError,"MissingArgument",option);
6196 if (LocaleCompare("vignette",option+1) == 0)
6201 if (i == (ssize_t) argc)
6202 ThrowMogrifyException(OptionError,"MissingArgument",option);
6203 if (IsGeometry(argv[i]) == MagickFalse)
6204 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6207 if (LocaleCompare("virtual-pixel",option+1) == 0)
6215 if (i == (ssize_t) argc)
6216 ThrowMogrifyException(OptionError,"MissingArgument",option);
6217 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6220 ThrowMogrifyException(OptionError,
6221 "UnrecognizedVirtualPixelMethod",argv[i]);
6224 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6228 if (LocaleCompare("wave",option+1) == 0)
6231 if (i == (ssize_t) argc)
6232 ThrowMogrifyException(OptionError,"MissingArgument",option);
6233 if (IsGeometry(argv[i]) == MagickFalse)
6234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6237 if (LocaleCompare("weight",option+1) == 0)
6242 if (i == (ssize_t) argc)
6243 ThrowMogrifyException(OptionError,"MissingArgument",option);
6246 if (LocaleCompare("white-point",option+1) == 0)
6251 if (i == (ssize_t) argc)
6252 ThrowMogrifyException(OptionError,"MissingArgument",option);
6253 if (IsGeometry(argv[i]) == MagickFalse)
6254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6257 if (LocaleCompare("white-threshold",option+1) == 0)
6262 if (i == (ssize_t) argc)
6263 ThrowMogrifyException(OptionError,"MissingArgument",option);
6264 if (IsGeometry(argv[i]) == MagickFalse)
6265 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6268 if (LocaleCompare("write",option+1) == 0)
6271 if (i == (ssize_t) argc)
6272 ThrowMogrifyException(OptionError,"MissingArgument",option);
6275 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6280 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6282 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6283 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6284 if (fire != MagickFalse)
6285 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6288 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6289 if (i != (ssize_t) argc)
6290 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6292 return(status != 0 ? MagickTrue : MagickFalse);
6296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6300 + M o g r i f y I m a g e I n f o %
6304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6306 % MogrifyImageInfo() applies image processing settings to the image as
6307 % prescribed by command line options.
6309 % The format of the MogrifyImageInfo method is:
6311 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6312 % const char **argv,ExceptionInfo *exception)
6314 % A description of each parameter follows:
6316 % o image_info: the image info..
6318 % o argc: Specifies a pointer to an integer describing the number of
6319 % elements in the argument vector.
6321 % o argv: Specifies a pointer to a text array containing the command line
6324 % o exception: return any errors or warnings in this structure.
6327 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6328 const int argc,const char **argv,ExceptionInfo *exception)
6343 Initialize method variables.
6345 assert(image_info != (ImageInfo *) NULL);
6346 assert(image_info->signature == MagickSignature);
6347 if (image_info->debug != MagickFalse)
6348 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6349 image_info->filename);
6353 Set the image settings.
6355 for (i=0; i < (ssize_t) argc; i++)
6358 if (IsCommandOption(option) == MagickFalse)
6360 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6361 count=MagickMax(count,0L);
6362 if ((i+count) >= (ssize_t) argc)
6364 switch (*(option+1))
6368 if (LocaleCompare("adjoin",option+1) == 0)
6370 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6373 if (LocaleCompare("antialias",option+1) == 0)
6375 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6378 if (LocaleCompare("authenticate",option+1) == 0)
6381 (void) DeleteImageOption(image_info,option+1);
6383 (void) SetImageOption(image_info,option+1,argv[i+1]);
6390 if (LocaleCompare("background",option+1) == 0)
6394 (void) DeleteImageOption(image_info,option+1);
6395 (void) QueryColorCompliance(MogrifyBackgroundColor,
6396 AllCompliance,&image_info->background_color,exception);
6399 (void) SetImageOption(image_info,option+1,argv[i+1]);
6400 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6401 &image_info->background_color,exception);
6404 if (LocaleCompare("bias",option+1) == 0)
6408 (void) SetImageOption(image_info,option+1,"0.0");
6411 (void) SetImageOption(image_info,option+1,argv[i+1]);
6414 if (LocaleCompare("black-point-compensation",option+1) == 0)
6418 (void) SetImageOption(image_info,option+1,"false");
6421 (void) SetImageOption(image_info,option+1,"true");
6424 if (LocaleCompare("blue-primary",option+1) == 0)
6428 (void) SetImageOption(image_info,option+1,"0.0");
6431 (void) SetImageOption(image_info,option+1,argv[i+1]);
6434 if (LocaleCompare("bordercolor",option+1) == 0)
6438 (void) DeleteImageOption(image_info,option+1);
6439 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6440 &image_info->border_color,exception);
6443 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6444 &image_info->border_color,exception);
6445 (void) SetImageOption(image_info,option+1,argv[i+1]);
6448 if (LocaleCompare("box",option+1) == 0)
6452 (void) SetImageOption(image_info,"undercolor","none");
6455 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6462 if (LocaleCompare("cache",option+1) == 0)
6467 limit=MagickResourceInfinity;
6468 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6469 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6471 (void) SetMagickResourceLimit(MemoryResource,limit);
6472 (void) SetMagickResourceLimit(MapResource,2*limit);
6475 if (LocaleCompare("caption",option+1) == 0)
6479 (void) DeleteImageOption(image_info,option+1);
6482 (void) SetImageOption(image_info,option+1,argv[i+1]);
6485 if (LocaleCompare("channel",option+1) == 0)
6489 image_info->channel=DefaultChannels;
6490 (void) SetImageOption(image_info,option+1,"default");
6493 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6494 (void) SetImageOption(image_info,option+1,argv[i+1]);
6497 if (LocaleCompare("colorspace",option+1) == 0)
6501 image_info->colorspace=UndefinedColorspace;
6502 (void) SetImageOption(image_info,option+1,"undefined");
6505 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6506 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6507 (void) SetImageOption(image_info,option+1,argv[i+1]);
6510 if (LocaleCompare("comment",option+1) == 0)
6514 (void) DeleteImageOption(image_info,option+1);
6517 (void) SetImageOption(image_info,option+1,argv[i+1]);
6520 if (LocaleCompare("compose",option+1) == 0)
6524 (void) SetImageOption(image_info,option+1,"undefined");
6527 (void) SetImageOption(image_info,option+1,argv[i+1]);
6530 if (LocaleCompare("compress",option+1) == 0)
6534 image_info->compression=UndefinedCompression;
6535 (void) SetImageOption(image_info,option+1,"undefined");
6538 image_info->compression=(CompressionType) ParseCommandOption(
6539 MagickCompressOptions,MagickFalse,argv[i+1]);
6540 (void) SetImageOption(image_info,option+1,argv[i+1]);
6547 if (LocaleCompare("debug",option+1) == 0)
6550 (void) SetLogEventMask("none");
6552 (void) SetLogEventMask(argv[i+1]);
6553 image_info->debug=IsEventLogging();
6556 if (LocaleCompare("define",option+1) == 0)
6560 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6561 (void) DeleteImageRegistry(argv[i+1]+9);
6563 (void) DeleteImageOption(image_info,argv[i+1]);
6566 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6568 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6572 (void) DefineImageOption(image_info,argv[i+1]);
6575 if (LocaleCompare("delay",option+1) == 0)
6579 (void) SetImageOption(image_info,option+1,"0");
6582 (void) SetImageOption(image_info,option+1,argv[i+1]);
6585 if (LocaleCompare("density",option+1) == 0)
6592 if (image_info->density != (char *) NULL)
6593 image_info->density=DestroyString(image_info->density);
6594 (void) SetImageOption(image_info,option+1,"72");
6597 (void) CloneString(&image_info->density,argv[i+1]);
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("depth",option+1) == 0)
6605 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6608 image_info->depth=StringToUnsignedLong(argv[i+1]);
6611 if (LocaleCompare("direction",option+1) == 0)
6615 (void) SetImageOption(image_info,option+1,"undefined");
6618 (void) SetImageOption(image_info,option+1,argv[i+1]);
6621 if (LocaleCompare("display",option+1) == 0)
6625 if (image_info->server_name != (char *) NULL)
6626 image_info->server_name=DestroyString(
6627 image_info->server_name);
6630 (void) CloneString(&image_info->server_name,argv[i+1]);
6633 if (LocaleCompare("dispose",option+1) == 0)
6637 (void) SetImageOption(image_info,option+1,"undefined");
6640 (void) SetImageOption(image_info,option+1,argv[i+1]);
6643 if (LocaleCompare("dither",option+1) == 0)
6647 image_info->dither=MagickFalse;
6648 (void) SetImageOption(image_info,option+1,"none");
6651 (void) SetImageOption(image_info,option+1,argv[i+1]);
6652 image_info->dither=MagickTrue;
6659 if (LocaleCompare("encoding",option+1) == 0)
6663 (void) SetImageOption(image_info,option+1,"undefined");
6666 (void) SetImageOption(image_info,option+1,argv[i+1]);
6669 if (LocaleCompare("endian",option+1) == 0)
6673 image_info->endian=UndefinedEndian;
6674 (void) SetImageOption(image_info,option+1,"undefined");
6677 image_info->endian=(EndianType) ParseCommandOption(
6678 MagickEndianOptions,MagickFalse,argv[i+1]);
6679 (void) SetImageOption(image_info,option+1,argv[i+1]);
6682 if (LocaleCompare("extract",option+1) == 0)
6685 Set image extract geometry.
6689 if (image_info->extract != (char *) NULL)
6690 image_info->extract=DestroyString(image_info->extract);
6693 (void) CloneString(&image_info->extract,argv[i+1]);
6700 if (LocaleCompare("fill",option+1) == 0)
6704 (void) SetImageOption(image_info,option+1,"none");
6707 (void) SetImageOption(image_info,option+1,argv[i+1]);
6710 if (LocaleCompare("filter",option+1) == 0)
6714 (void) SetImageOption(image_info,option+1,"undefined");
6717 (void) SetImageOption(image_info,option+1,argv[i+1]);
6720 if (LocaleCompare("font",option+1) == 0)
6724 if (image_info->font != (char *) NULL)
6725 image_info->font=DestroyString(image_info->font);
6728 (void) CloneString(&image_info->font,argv[i+1]);
6731 if (LocaleCompare("format",option+1) == 0)
6736 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6737 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6738 image_info->ping=MagickFalse;
6739 (void) SetImageOption(image_info,option+1,argv[i+1]);
6742 if (LocaleCompare("fuzz",option+1) == 0)
6746 image_info->fuzz=0.0;
6747 (void) SetImageOption(image_info,option+1,"0");
6750 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6752 (void) SetImageOption(image_info,option+1,argv[i+1]);
6759 if (LocaleCompare("gravity",option+1) == 0)
6763 (void) SetImageOption(image_info,option+1,"undefined");
6766 (void) SetImageOption(image_info,option+1,argv[i+1]);
6769 if (LocaleCompare("green-primary",option+1) == 0)
6773 (void) SetImageOption(image_info,option+1,"0.0");
6776 (void) SetImageOption(image_info,option+1,argv[i+1]);
6783 if (LocaleCompare("intensity",option+1) == 0)
6787 (void) SetImageOption(image_info,option+1,"undefined");
6790 (void) SetImageOption(image_info,option+1,argv[i+1]);
6793 if (LocaleCompare("intent",option+1) == 0)
6797 (void) SetImageOption(image_info,option+1,"undefined");
6800 (void) SetImageOption(image_info,option+1,argv[i+1]);
6803 if (LocaleCompare("interlace",option+1) == 0)
6807 image_info->interlace=UndefinedInterlace;
6808 (void) SetImageOption(image_info,option+1,"undefined");
6811 image_info->interlace=(InterlaceType) ParseCommandOption(
6812 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6813 (void) SetImageOption(image_info,option+1,argv[i+1]);
6816 if (LocaleCompare("interline-spacing",option+1) == 0)
6820 (void) SetImageOption(image_info,option+1,"undefined");
6823 (void) SetImageOption(image_info,option+1,argv[i+1]);
6826 if (LocaleCompare("interpolate",option+1) == 0)
6830 (void) SetImageOption(image_info,option+1,"undefined");
6833 (void) SetImageOption(image_info,option+1,argv[i+1]);
6836 if (LocaleCompare("interword-spacing",option+1) == 0)
6840 (void) SetImageOption(image_info,option+1,"undefined");
6843 (void) SetImageOption(image_info,option+1,argv[i+1]);
6850 if (LocaleCompare("kerning",option+1) == 0)
6854 (void) SetImageOption(image_info,option+1,"undefined");
6857 (void) SetImageOption(image_info,option+1,argv[i+1]);
6864 if (LocaleCompare("label",option+1) == 0)
6868 (void) DeleteImageOption(image_info,option+1);
6871 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 if (LocaleCompare("limit",option+1) == 0)
6884 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6885 MagickFalse,argv[i+1]);
6886 limit=MagickResourceInfinity;
6887 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6888 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6889 (void) SetMagickResourceLimit(type,limit);
6892 if (LocaleCompare("list",option+1) == 0)
6898 Display configuration list.
6900 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6903 case MagickCoderOptions:
6905 (void) ListCoderInfo((FILE *) NULL,exception);
6908 case MagickColorOptions:
6910 (void) ListColorInfo((FILE *) NULL,exception);
6913 case MagickConfigureOptions:
6915 (void) ListConfigureInfo((FILE *) NULL,exception);
6918 case MagickDelegateOptions:
6920 (void) ListDelegateInfo((FILE *) NULL,exception);
6923 case MagickFontOptions:
6925 (void) ListTypeInfo((FILE *) NULL,exception);
6928 case MagickFormatOptions:
6930 (void) ListMagickInfo((FILE *) NULL,exception);
6933 case MagickLocaleOptions:
6935 (void) ListLocaleInfo((FILE *) NULL,exception);
6938 case MagickLogOptions:
6940 (void) ListLogInfo((FILE *) NULL,exception);
6943 case MagickMagicOptions:
6945 (void) ListMagicInfo((FILE *) NULL,exception);
6948 case MagickMimeOptions:
6950 (void) ListMimeInfo((FILE *) NULL,exception);
6953 case MagickModuleOptions:
6955 (void) ListModuleInfo((FILE *) NULL,exception);
6958 case MagickPolicyOptions:
6960 (void) ListPolicyInfo((FILE *) NULL,exception);
6963 case MagickResourceOptions:
6965 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6968 case MagickThresholdOptions:
6970 (void) ListThresholdMaps((FILE *) NULL,exception);
6975 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6982 if (LocaleCompare("log",option+1) == 0)
6986 (void) SetLogFormat(argv[i+1]);
6989 if (LocaleCompare("loop",option+1) == 0)
6993 (void) SetImageOption(image_info,option+1,"0");
6996 (void) SetImageOption(image_info,option+1,argv[i+1]);
7003 if (LocaleCompare("matte",option+1) == 0)
7007 (void) SetImageOption(image_info,option+1,"false");
7010 (void) SetImageOption(image_info,option+1,"true");
7013 if (LocaleCompare("mattecolor",option+1) == 0)
7017 (void) SetImageOption(image_info,option+1,argv[i+1]);
7018 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
7019 &image_info->matte_color,exception);
7022 (void) SetImageOption(image_info,option+1,argv[i+1]);
7023 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7024 &image_info->matte_color,exception);
7027 if (LocaleCompare("metric",option+1) == 0)
7030 (void) DeleteImageOption(image_info,option+1);
7032 (void) SetImageOption(image_info,option+1,argv[i+1]);
7035 if (LocaleCompare("monitor",option+1) == 0)
7037 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7041 if (LocaleCompare("monochrome",option+1) == 0)
7043 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7050 if (LocaleCompare("orient",option+1) == 0)
7054 image_info->orientation=UndefinedOrientation;
7055 (void) SetImageOption(image_info,option+1,"undefined");
7058 image_info->orientation=(OrientationType) ParseCommandOption(
7059 MagickOrientationOptions,MagickFalse,argv[i+1]);
7060 (void) SetImageOption(image_info,option+1,argv[i+1]);
7066 if (LocaleCompare("page",option+1) == 0)
7070 page[MaxTextExtent];
7083 (void) DeleteImageOption(image_info,option+1);
7084 (void) CloneString(&image_info->page,(char *) NULL);
7087 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7088 image_option=GetImageOption(image_info,"page");
7089 if (image_option != (const char *) NULL)
7090 flags=ParseAbsoluteGeometry(image_option,&geometry);
7091 canonical_page=GetPageGeometry(argv[i+1]);
7092 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7093 canonical_page=DestroyString(canonical_page);
7094 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
7095 (unsigned long) geometry.width,(unsigned long) geometry.height);
7096 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7097 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7098 (unsigned long) geometry.width,(unsigned long) geometry.height,
7099 (long) geometry.x,(long) geometry.y);
7100 (void) SetImageOption(image_info,option+1,page);
7101 (void) CloneString(&image_info->page,page);
7104 if (LocaleCompare("ping",option+1) == 0)
7106 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7109 if (LocaleCompare("pointsize",option+1) == 0)
7112 geometry_info.rho=0.0;
7114 (void) ParseGeometry(argv[i+1],&geometry_info);
7115 image_info->pointsize=geometry_info.rho;
7118 if (LocaleCompare("precision",option+1) == 0)
7120 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7123 if (LocaleCompare("preview",option+1) == 0)
7130 image_info->preview_type=UndefinedPreview;
7133 image_info->preview_type=(PreviewType) ParseCommandOption(
7134 MagickPreviewOptions,MagickFalse,argv[i+1]);
7141 if (LocaleCompare("quality",option+1) == 0)
7144 Set image compression quality.
7148 image_info->quality=UndefinedCompressionQuality;
7149 (void) SetImageOption(image_info,option+1,"0");
7152 image_info->quality=StringToUnsignedLong(argv[i+1]);
7153 (void) SetImageOption(image_info,option+1,argv[i+1]);
7156 if (LocaleCompare("quiet",option+1) == 0)
7158 static WarningHandler
7159 warning_handler = (WarningHandler) NULL;
7164 Restore error or warning messages.
7166 warning_handler=SetWarningHandler(warning_handler);
7170 Suppress error or warning messages.
7172 warning_handler=SetWarningHandler((WarningHandler) NULL);
7179 if (LocaleCompare("red-primary",option+1) == 0)
7183 (void) SetImageOption(image_info,option+1,"0.0");
7186 (void) SetImageOption(image_info,option+1,argv[i+1]);
7193 if (LocaleCompare("sampling-factor",option+1) == 0)
7196 Set image sampling factor.
7200 if (image_info->sampling_factor != (char *) NULL)
7201 image_info->sampling_factor=DestroyString(
7202 image_info->sampling_factor);
7205 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7208 if (LocaleCompare("scene",option+1) == 0)
7215 image_info->scene=0;
7216 (void) SetImageOption(image_info,option+1,"0");
7219 image_info->scene=StringToUnsignedLong(argv[i+1]);
7220 (void) SetImageOption(image_info,option+1,argv[i+1]);
7223 if (LocaleCompare("seed",option+1) == 0)
7230 seed=(unsigned long) time((time_t *) NULL);
7231 SetRandomSecretKey(seed);
7234 seed=StringToUnsignedLong(argv[i+1]);
7235 SetRandomSecretKey(seed);
7238 if (LocaleCompare("size",option+1) == 0)
7242 if (image_info->size != (char *) NULL)
7243 image_info->size=DestroyString(image_info->size);
7246 (void) CloneString(&image_info->size,argv[i+1]);
7249 if (LocaleCompare("stroke",option+1) == 0)
7253 (void) SetImageOption(image_info,option+1,"none");
7256 (void) SetImageOption(image_info,option+1,argv[i+1]);
7259 if (LocaleCompare("strokewidth",option+1) == 0)
7263 (void) SetImageOption(image_info,option+1,"0");
7266 (void) SetImageOption(image_info,option+1,argv[i+1]);
7269 if (LocaleCompare("synchronize",option+1) == 0)
7273 image_info->synchronize=MagickFalse;
7276 image_info->synchronize=MagickTrue;
7283 if (LocaleCompare("taint",option+1) == 0)
7287 (void) SetImageOption(image_info,option+1,"false");
7290 (void) SetImageOption(image_info,option+1,"true");
7293 if (LocaleCompare("texture",option+1) == 0)
7297 if (image_info->texture != (char *) NULL)
7298 image_info->texture=DestroyString(image_info->texture);
7301 (void) CloneString(&image_info->texture,argv[i+1]);
7304 if (LocaleCompare("tile-offset",option+1) == 0)
7307 (void) SetImageOption(image_info,option+1,"0");
7309 (void) SetImageOption(image_info,option+1,argv[i+1]);
7312 if (LocaleCompare("transparent-color",option+1) == 0)
7316 (void) QueryColorCompliance("none",AllCompliance,
7317 &image_info->transparent_color,exception);
7318 (void) SetImageOption(image_info,option+1,"none");
7321 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7322 &image_info->transparent_color,exception);
7323 (void) SetImageOption(image_info,option+1,argv[i+1]);
7326 if (LocaleCompare("type",option+1) == 0)
7330 image_info->type=UndefinedType;
7331 (void) SetImageOption(image_info,option+1,"undefined");
7334 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7335 MagickFalse,argv[i+1]);
7336 (void) SetImageOption(image_info,option+1,argv[i+1]);
7343 if (LocaleCompare("undercolor",option+1) == 0)
7346 (void) DeleteImageOption(image_info,option+1);
7348 (void) SetImageOption(image_info,option+1,argv[i+1]);
7351 if (LocaleCompare("units",option+1) == 0)
7355 image_info->units=UndefinedResolution;
7356 (void) SetImageOption(image_info,option+1,"undefined");
7359 image_info->units=(ResolutionType) ParseCommandOption(
7360 MagickResolutionOptions,MagickFalse,argv[i+1]);
7361 (void) SetImageOption(image_info,option+1,argv[i+1]);
7368 if (LocaleCompare("verbose",option+1) == 0)
7372 image_info->verbose=MagickFalse;
7375 image_info->verbose=MagickTrue;
7376 image_info->ping=MagickFalse;
7379 if (LocaleCompare("view",option+1) == 0)
7383 if (image_info->view != (char *) NULL)
7384 image_info->view=DestroyString(image_info->view);
7387 (void) CloneString(&image_info->view,argv[i+1]);
7390 if (LocaleCompare("virtual-pixel",option+1) == 0)
7393 (void) SetImageOption(image_info,option+1,"undefined");
7395 (void) SetImageOption(image_info,option+1,argv[i+1]);
7402 if (LocaleCompare("white-point",option+1) == 0)
7405 (void) SetImageOption(image_info,option+1,"0.0");
7407 (void) SetImageOption(image_info,option+1,argv[i+1]);
7421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7425 + M o g r i f y I m a g e L i s t %
7429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7431 % MogrifyImageList() applies any command line options that might affect the
7432 % entire image list (e.g. -append, -coalesce, etc.).
7434 % The format of the MogrifyImage method is:
7436 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7437 % const char **argv,Image **images,ExceptionInfo *exception)
7439 % A description of each parameter follows:
7441 % o image_info: the image info..
7443 % o argc: Specifies a pointer to an integer describing the number of
7444 % elements in the argument vector.
7446 % o argv: Specifies a pointer to a text array containing the command line
7449 % o images: pointer to pointer of the first image in image list.
7451 % o exception: return any errors or warnings in this structure.
7454 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7455 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7466 PixelInterpolateMethod
7480 Apply options to the image list.
7482 assert(image_info != (ImageInfo *) NULL);
7483 assert(image_info->signature == MagickSignature);
7484 assert(images != (Image **) NULL);
7485 assert((*images)->previous == (Image *) NULL);
7486 assert((*images)->signature == MagickSignature);
7487 if ((*images)->debug != MagickFalse)
7488 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7489 (*images)->filename);
7490 if ((argc <= 0) || (*argv == (char *) NULL))
7492 interpolate_method=UndefinedInterpolatePixel;
7493 mogrify_info=CloneImageInfo(image_info);
7494 quantize_info=AcquireQuantizeInfo(mogrify_info);
7496 for (i=0; i < (ssize_t) argc; i++)
7498 if (*images == (Image *) NULL)
7501 if (IsCommandOption(option) == MagickFalse)
7503 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7504 count=MagickMax(count,0L);
7505 if ((i+count) >= (ssize_t) argc)
7507 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7508 switch (*(option+1))
7512 if (LocaleCompare("affinity",option+1) == 0)
7514 (void) SyncImagesSettings(mogrify_info,*images,exception);
7517 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7524 if (LocaleCompare("append",option+1) == 0)
7529 (void) SyncImagesSettings(mogrify_info,*images,exception);
7530 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7531 MagickFalse,exception);
7532 if (append_image == (Image *) NULL)
7537 *images=DestroyImageList(*images);
7538 *images=append_image;
7541 if (LocaleCompare("average",option+1) == 0)
7547 Average an image sequence (deprecated).
7549 (void) SyncImagesSettings(mogrify_info,*images,exception);
7550 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7552 if (average_image == (Image *) NULL)
7557 *images=DestroyImageList(*images);
7558 *images=average_image;
7565 if (LocaleCompare("channel-fx",option+1) == 0)
7570 (void) SyncImagesSettings(mogrify_info,*images,exception);
7571 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7572 if (channel_image == (Image *) NULL)
7577 *images=DestroyImageList(*images);
7578 *images=channel_image;
7581 if (LocaleCompare("clut",option+1) == 0)
7587 (void) SyncImagesSettings(mogrify_info,*images,exception);
7588 image=RemoveFirstImageFromList(images);
7589 clut_image=RemoveFirstImageFromList(images);
7590 if (clut_image == (Image *) NULL)
7595 (void) ClutImage(image,clut_image,interpolate_method,exception);
7596 clut_image=DestroyImage(clut_image);
7597 *images=DestroyImageList(*images);
7601 if (LocaleCompare("coalesce",option+1) == 0)
7606 (void) SyncImagesSettings(mogrify_info,*images,exception);
7607 coalesce_image=CoalesceImages(*images,exception);
7608 if (coalesce_image == (Image *) NULL)
7613 *images=DestroyImageList(*images);
7614 *images=coalesce_image;
7617 if (LocaleCompare("combine",option+1) == 0)
7625 (void) SyncImagesSettings(mogrify_info,*images,exception);
7626 colorspace=(ColorspaceType) ParseCommandOption(
7627 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7628 combine_image=CombineImages(*images,colorspace,exception);
7629 if (combine_image == (Image *) NULL)
7634 *images=DestroyImageList(*images);
7635 *images=combine_image;
7638 if (LocaleCompare("compare",option+1) == 0)
7655 Mathematically and visually annotate the difference between an
7656 image and its reconstruction.
7658 (void) SyncImagesSettings(mogrify_info,*images,exception);
7659 image=RemoveFirstImageFromList(images);
7660 reconstruct_image=RemoveFirstImageFromList(images);
7661 if (reconstruct_image == (Image *) NULL)
7666 metric=UndefinedErrorMetric;
7667 option=GetImageOption(image_info,"metric");
7668 if (option != (const char *) NULL)
7669 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7670 MagickFalse,option);
7671 difference_image=CompareImages(image,reconstruct_image,metric,
7672 &distortion,exception);
7673 if (difference_image == (Image *) NULL)
7675 if (*images != (Image *) NULL)
7676 *images=DestroyImage(*images);
7677 *images=difference_image;
7680 if (LocaleCompare("complex",option+1) == 0)
7688 (void) SyncImageSettings(mogrify_info,*images,exception);
7689 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7690 MagickFalse,argv[i+1]);
7691 complex_images=ComplexImages(*images,op,exception);
7692 if (complex_images == (Image *) NULL)
7697 *images=DestroyImageList(*images);
7698 *images=complex_images;
7701 if (LocaleCompare("composite",option+1) == 0)
7717 (void) SyncImagesSettings(mogrify_info,*images,exception);
7718 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7719 if (value == (const char *) NULL)
7720 clip_to_self=MagickTrue;
7722 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7723 "compose:clip-to-self")); /* if this is true */
7724 if (IsMagickFalse(clip_to_self)) /* or */
7725 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7726 mogrify_info,"compose:outside-overlay"))) ? MagickTrue :
7727 MagickFalse; /* this false */
7728 image=RemoveFirstImageFromList(images);
7729 composite_image=RemoveFirstImageFromList(images);
7730 if (composite_image == (Image *) NULL)
7735 (void) TransformImage(&composite_image,(char *) NULL,
7736 composite_image->geometry,exception);
7737 SetGeometry(composite_image,&geometry);
7738 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7739 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7741 mask_image=RemoveFirstImageFromList(images);
7742 if (mask_image != (Image *) NULL)
7744 if ((image->compose == DisplaceCompositeOp) ||
7745 (image->compose == DistortCompositeOp))
7746 status&=CompositeImage(composite_image,mask_image,
7747 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7756 composite_geometry.width=mask_image->columns;
7757 composite_geometry.height=mask_image->rows;
7758 composite_geometry.x=(-geometry.x);
7759 composite_geometry.y=(-geometry.y);
7762 image=ExtentImage(composite_image,&composite_geometry,
7764 if (image != (Image *) NULL)
7766 composite_image=DestroyImage(composite_image);
7767 composite_image=image;
7769 status&=CompositeImage(composite_image,mask_image,
7770 IntensityCompositeOp,MagickTrue,0,0,exception);
7772 mask_image=DestroyImage(mask_image);
7774 (void) CompositeImage(image,composite_image,image->compose,
7775 clip_to_self,geometry.x,geometry.y,exception);
7776 composite_image=DestroyImage(composite_image);
7777 *images=DestroyImageList(*images);
7785 if (LocaleCompare("deconstruct",option+1) == 0)
7790 (void) SyncImagesSettings(mogrify_info,*images,exception);
7791 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7793 if (deconstruct_image == (Image *) NULL)
7798 *images=DestroyImageList(*images);
7799 *images=deconstruct_image;
7802 if (LocaleCompare("delete",option+1) == 0)
7805 DeleteImages(images,"-1",exception);
7807 DeleteImages(images,argv[i+1],exception);
7810 if (LocaleCompare("dither",option+1) == 0)
7814 quantize_info->dither_method=NoDitherMethod;
7817 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7818 MagickDitherOptions,MagickFalse,argv[i+1]);
7821 if (LocaleCompare("duplicate",option+1) == 0)
7827 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7836 number_duplicates=(size_t) StringToLong(argv[i+1]);
7837 p=strchr(argv[i+1],',');
7838 if (p == (const char *) NULL)
7839 duplicate_images=DuplicateImages(*images,number_duplicates,
7842 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7845 AppendImageToList(images, duplicate_images);
7846 (void) SyncImagesSettings(mogrify_info,*images,exception);
7853 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7858 MagickEvaluateOperator
7861 (void) SyncImageSettings(mogrify_info,*images,exception);
7862 op=(MagickEvaluateOperator) ParseCommandOption(
7863 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7864 evaluate_image=EvaluateImages(*images,op,exception);
7865 if (evaluate_image == (Image *) NULL)
7870 *images=DestroyImageList(*images);
7871 *images=evaluate_image;
7878 if (LocaleCompare("fft",option+1) == 0)
7884 Implements the discrete Fourier transform (DFT).
7886 (void) SyncImageSettings(mogrify_info,*images,exception);
7887 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7888 MagickTrue : MagickFalse,exception);
7889 if (fourier_image == (Image *) NULL)
7891 *images=DestroyImage(*images);
7892 *images=fourier_image;
7895 if (LocaleCompare("flatten",option+1) == 0)
7900 (void) SyncImagesSettings(mogrify_info,*images,exception);
7901 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7902 if (flatten_image == (Image *) NULL)
7904 *images=DestroyImageList(*images);
7905 *images=flatten_image;
7908 if (LocaleCompare("fx",option+1) == 0)
7913 (void) SyncImagesSettings(mogrify_info,*images,exception);
7914 fx_image=FxImage(*images,argv[i+1],exception);
7915 if (fx_image == (Image *) NULL)
7920 *images=DestroyImageList(*images);
7928 if (LocaleCompare("hald-clut",option+1) == 0)
7934 (void) SyncImagesSettings(mogrify_info,*images,exception);
7935 image=RemoveFirstImageFromList(images);
7936 hald_image=RemoveFirstImageFromList(images);
7937 if (hald_image == (Image *) NULL)
7942 (void) HaldClutImage(image,hald_image,exception);
7943 hald_image=DestroyImage(hald_image);
7944 if (*images != (Image *) NULL)
7945 *images=DestroyImageList(*images);
7953 if (LocaleCompare("ift",option+1) == 0)
7961 Implements the inverse fourier discrete Fourier transform (DFT).
7963 (void) SyncImagesSettings(mogrify_info,*images,exception);
7964 magnitude_image=RemoveFirstImageFromList(images);
7965 phase_image=RemoveFirstImageFromList(images);
7966 if (phase_image == (Image *) NULL)
7971 fourier_image=InverseFourierTransformImage(magnitude_image,
7972 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7973 if (fourier_image == (Image *) NULL)
7975 if (*images != (Image *) NULL)
7976 *images=DestroyImage(*images);
7977 *images=fourier_image;
7980 if (LocaleCompare("insert",option+1) == 0)
7988 index=(ssize_t) StringToLong(argv[i+1]);
7989 p=RemoveLastImageFromList(images);
7990 if (p == (Image *) NULL)
7992 (void) ThrowMagickException(exception,GetMagickModule(),
7993 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7999 PrependImageToList(images,q);
8001 if (index == (ssize_t) GetImageListLength(*images))
8002 AppendImageToList(images,q);
8005 q=GetImageFromList(*images,index-1);
8006 if (q == (Image *) NULL)
8008 (void) ThrowMagickException(exception,GetMagickModule(),
8009 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8013 InsertImageInList(&q,p);
8015 *images=GetFirstImageInList(q);
8018 if (LocaleCompare("interpolate",option+1) == 0)
8020 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8021 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8028 if (LocaleCompare("layers",option+1) == 0)
8036 (void) SyncImagesSettings(mogrify_info,*images,exception);
8037 layers=(Image *) NULL;
8038 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8039 MagickFalse,argv[i+1]);
8044 layers=CoalesceImages(*images,exception);
8047 case CompareAnyLayer:
8048 case CompareClearLayer:
8049 case CompareOverlayLayer:
8052 layers=CompareImagesLayers(*images,method,exception);
8058 case TrimBoundsLayer:
8060 layers=MergeImageLayers(*images,method,exception);
8065 layers=DisposeImages(*images,exception);
8068 case OptimizeImageLayer:
8070 layers=OptimizeImageLayers(*images,exception);
8073 case OptimizePlusLayer:
8075 layers=OptimizePlusImageLayers(*images,exception);
8078 case OptimizeTransLayer:
8080 OptimizeImageTransparency(*images,exception);
8083 case RemoveDupsLayer:
8085 RemoveDuplicateLayers(images,exception);
8088 case RemoveZeroLayer:
8090 RemoveZeroDelayLayers(images,exception);
8096 General Purpose, GIF Animation Optimizer.
8098 layers=CoalesceImages(*images,exception);
8099 if (layers == (Image *) NULL)
8104 *images=DestroyImageList(*images);
8106 layers=OptimizeImageLayers(*images,exception);
8107 if (layers == (Image *) NULL)
8112 *images=DestroyImageList(*images);
8114 layers=(Image *) NULL;
8115 OptimizeImageTransparency(*images,exception);
8116 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8120 case CompositeLayer:
8132 Split image sequence at the first 'NULL:' image.
8135 while (source != (Image *) NULL)
8137 source=GetNextImageInList(source);
8138 if ((source != (Image *) NULL) &&
8139 (LocaleCompare(source->magick,"NULL") == 0))
8142 if (source != (Image *) NULL)
8144 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8145 (GetNextImageInList(source) == (Image *) NULL))
8146 source=(Image *) NULL;
8150 Separate the two lists, junk the null: image.
8152 source=SplitImageList(source->previous);
8153 DeleteImageFromList(&source);
8156 if (source == (Image *) NULL)
8158 (void) ThrowMagickException(exception,GetMagickModule(),
8159 OptionError,"MissingNullSeparator","layers Composite");
8164 Adjust offset with gravity and virtual canvas.
8166 SetGeometry(*images,&geometry);
8167 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8168 geometry.width=source->page.width != 0 ?
8169 source->page.width : source->columns;
8170 geometry.height=source->page.height != 0 ?
8171 source->page.height : source->rows;
8172 GravityAdjustGeometry((*images)->page.width != 0 ?
8173 (*images)->page.width : (*images)->columns,
8174 (*images)->page.height != 0 ? (*images)->page.height :
8175 (*images)->rows,(*images)->gravity,&geometry);
8176 compose=OverCompositeOp;
8177 option=GetImageOption(mogrify_info,"compose");
8178 if (option != (const char *) NULL)
8179 compose=(CompositeOperator) ParseCommandOption(
8180 MagickComposeOptions,MagickFalse,option);
8181 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8183 source=DestroyImageList(source);
8187 if (layers == (Image *) NULL)
8189 *images=DestroyImageList(*images);
8197 if (LocaleCompare("map",option+1) == 0)
8199 (void) SyncImagesSettings(mogrify_info,*images,exception);
8202 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8209 if (LocaleCompare("maximum",option+1) == 0)
8215 Maximum image sequence (deprecated).
8217 (void) SyncImagesSettings(mogrify_info,*images,exception);
8218 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8219 if (maximum_image == (Image *) NULL)
8224 *images=DestroyImageList(*images);
8225 *images=maximum_image;
8228 if (LocaleCompare("minimum",option+1) == 0)
8234 Minimum image sequence (deprecated).
8236 (void) SyncImagesSettings(mogrify_info,*images,exception);
8237 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8238 if (minimum_image == (Image *) NULL)
8243 *images=DestroyImageList(*images);
8244 *images=minimum_image;
8247 if (LocaleCompare("morph",option+1) == 0)
8252 (void) SyncImagesSettings(mogrify_info,*images,exception);
8253 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8255 if (morph_image == (Image *) NULL)
8260 *images=DestroyImageList(*images);
8261 *images=morph_image;
8264 if (LocaleCompare("mosaic",option+1) == 0)
8269 (void) SyncImagesSettings(mogrify_info,*images,exception);
8270 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8271 if (mosaic_image == (Image *) NULL)
8276 *images=DestroyImageList(*images);
8277 *images=mosaic_image;
8284 if (LocaleCompare("poly",option+1) == 0)
8288 token[MaxTextExtent];
8308 (void) SyncImageSettings(mogrify_info,*images,exception);
8309 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8311 if (args == (char *) NULL)
8314 for (x=0; *p != '\0'; x++)
8316 GetMagickToken(p,&p,token);
8318 GetMagickToken(p,&p,token);
8320 number_arguments=(size_t) x;
8321 arguments=(double *) AcquireQuantumMemory(number_arguments,
8322 sizeof(*arguments));
8323 if (arguments == (double *) NULL)
8324 ThrowWandFatalException(ResourceLimitFatalError,
8325 "MemoryAllocationFailed",(*images)->filename);
8326 (void) ResetMagickMemory(arguments,0,number_arguments*
8327 sizeof(*arguments));
8329 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8331 GetMagickToken(p,&p,token);
8333 GetMagickToken(p,&p,token);
8334 arguments[x]=StringToDouble(token,(char **) NULL);
8336 args=DestroyString(args);
8337 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8338 arguments,exception);
8339 arguments=(double *) RelinquishMagickMemory(arguments);
8340 if (polynomial_image == (Image *) NULL)
8345 *images=DestroyImageList(*images);
8346 *images=polynomial_image;
8348 if (LocaleCompare("print",option+1) == 0)
8353 (void) SyncImagesSettings(mogrify_info,*images,exception);
8354 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8356 if (string == (char *) NULL)
8358 (void) FormatLocaleFile(stdout,"%s",string);
8359 string=DestroyString(string);
8361 if (LocaleCompare("process",option+1) == 0)
8370 (void) SyncImagesSettings(mogrify_info,*images,exception);
8371 arguments=StringToArgv(argv[i+1],&number_arguments);
8372 if (arguments == (char **) NULL)
8374 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8395 Support old style syntax, filter="-option arg".
8397 length=strlen(argv[i+1]);
8398 token=(char *) NULL;
8399 if (~length >= (MaxTextExtent-1))
8400 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8402 if (token == (char *) NULL)
8405 arguments=argv[i+1];
8406 token_info=AcquireTokenInfo();
8407 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8408 "\"",'\0',&breaker,&next,"e);
8409 token_info=DestroyTokenInfo(token_info);
8415 argv=(&(arguments[next]));
8416 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8419 token=DestroyString(token);
8422 (void) SubstituteString(&arguments[1],"-","");
8423 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8424 number_arguments-2,(const char **) arguments+2,exception);
8425 for (j=0; j < number_arguments; j++)
8426 arguments[j]=DestroyString(arguments[j]);
8427 arguments=(char **) RelinquishMagickMemory(arguments);
8434 if (LocaleCompare("reverse",option+1) == 0)
8436 ReverseImageList(images);
8443 if (LocaleCompare("smush",option+1) == 0)
8451 (void) SyncImagesSettings(mogrify_info,*images,exception);
8452 offset=(ssize_t) StringToLong(argv[i+1]);
8453 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8454 MagickFalse,offset,exception);
8455 if (smush_image == (Image *) NULL)
8460 *images=DestroyImageList(*images);
8461 *images=smush_image;
8464 if (LocaleCompare("swap",option+1) == 0)
8485 flags=ParseGeometry(argv[i+1],&geometry_info);
8486 index=(ssize_t) geometry_info.rho;
8487 if ((flags & SigmaValue) != 0)
8488 swap_index=(ssize_t) geometry_info.sigma;
8490 p=GetImageFromList(*images,index);
8491 q=GetImageFromList(*images,swap_index);
8492 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8494 (void) ThrowMagickException(exception,GetMagickModule(),
8495 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8501 swap=CloneImage(p,0,0,MagickTrue,exception);
8502 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8503 ReplaceImageInList(&q,swap);
8504 *images=GetFirstImageInList(q);
8511 if (LocaleCompare("write",option+1) == 0)
8522 (void) SyncImagesSettings(mogrify_info,*images,exception);
8523 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8524 (void) DeleteImageRegistry(key);
8525 write_images=(*images);
8527 write_images=CloneImageList(*images,exception);
8528 write_info=CloneImageInfo(mogrify_info);
8529 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8530 write_info=DestroyImageInfo(write_info);
8532 write_images=DestroyImageList(write_images);
8542 quantize_info=DestroyQuantizeInfo(quantize_info);
8543 mogrify_info=DestroyImageInfo(mogrify_info);
8544 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8545 return(status != 0 ? MagickTrue : MagickFalse);
8549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8553 + M o g r i f y I m a g e s %
8557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8559 % MogrifyImages() applies image processing options to a sequence of images as
8560 % prescribed by command line options.
8562 % The format of the MogrifyImage method is:
8564 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8565 % const MagickBooleanType post,const int argc,const char **argv,
8566 % Image **images,Exceptioninfo *exception)
8568 % A description of each parameter follows:
8570 % o image_info: the image info..
8572 % o post: If true, post process image list operators otherwise pre-process.
8574 % o argc: Specifies a pointer to an integer describing the number of
8575 % elements in the argument vector.
8577 % o argv: Specifies a pointer to a text array containing the command line
8580 % o images: pointer to a pointer of the first image in image list.
8582 % o exception: return any errors or warnings in this structure.
8585 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8586 const MagickBooleanType post,const int argc,const char **argv,
8587 Image **images,ExceptionInfo *exception)
8589 #define MogrifyImageTag "Mogrify/Image"
8603 assert(image_info != (ImageInfo *) NULL);
8604 assert(image_info->signature == MagickSignature);
8605 if (images == (Image **) NULL)
8606 return(MogrifyImage(image_info,argc,argv,images,exception));
8607 assert((*images)->previous == (Image *) NULL);
8608 assert((*images)->signature == MagickSignature);
8609 if ((*images)->debug != MagickFalse)
8610 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8611 (*images)->filename);
8612 if ((argc <= 0) || (*argv == (char *) NULL))
8614 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8619 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8624 Pre-process multi-image sequence operators
8626 if (post == MagickFalse)
8627 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8629 For each image, process simple single image operators
8632 n=GetImageListLength(*images);
8636 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8637 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8639 status&=MogrifyImage(image_info,argc,argv,images,exception);
8640 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8641 if (proceed == MagickFalse)
8643 if ( (*images)->next == (Image *) NULL )
8645 *images=(*images)->next;
8648 assert( *images != (Image *) NULL );
8650 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8651 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8655 Post-process, multi-image sequence operators
8657 *images=GetFirstImageInList(*images);
8658 if (post != MagickFalse)
8659 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8660 return(status != 0 ? MagickTrue : MagickFalse);