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-2015 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_MagickCommandGenesis)
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 != UndefinedPixelTrait))
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 != UndefinedPixelTrait))
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 != UndefinedPixelTrait))
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("channel",option+1) == 0)
1027 (void) SyncImageSettings(mogrify_info,*image,exception);
1030 SetPixelChannelMask(*image,DefaultChannels);
1033 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1034 SetPixelChannelMask(*image,channel);
1037 if (LocaleCompare("charcoal",option+1) == 0)
1042 (void) SyncImageSettings(mogrify_info,*image,exception);
1043 flags=ParseGeometry(argv[i+1],&geometry_info);
1044 if ((flags & SigmaValue) == 0)
1045 geometry_info.sigma=1.0;
1046 if ((flags & XiValue) == 0)
1047 geometry_info.xi=1.0;
1048 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1049 geometry_info.sigma,exception);
1052 if (LocaleCompare("chop",option+1) == 0)
1057 (void) SyncImageSettings(mogrify_info,*image,exception);
1058 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1059 mogrify_image=ChopImage(*image,&geometry,exception);
1062 if (LocaleCompare("clip",option+1) == 0)
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1067 (void) SetImageMask(*image,(Image *) NULL,exception);
1070 (void) ClipImage(*image,exception);
1073 if (LocaleCompare("clip-mask",option+1) == 0)
1090 (void) SyncImageSettings(mogrify_info,*image,exception);
1096 (void) SetImageMask(*image,(Image *) NULL,exception);
1101 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1103 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1104 if (mask_image == (Image *) NULL)
1106 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1107 return(MagickFalse);
1108 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1109 for (y=0; y < (ssize_t) mask_image->rows; y++)
1111 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1113 if (q == (Quantum *) NULL)
1115 for (x=0; x < (ssize_t) mask_image->columns; x++)
1117 if (mask_image->alpha_trait == UndefinedPixelTrait)
1118 SetPixelAlpha(mask_image,(Quantum)
1119 GetPixelIntensity(mask_image,q),q);
1120 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1121 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1122 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1123 q+=GetPixelChannels(mask_image);
1125 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1128 mask_view=DestroyCacheView(mask_view);
1129 mask_image->alpha_trait=BlendPixelTrait;
1130 (void) SetImageMask(*image,mask_image,exception);
1133 if (LocaleCompare("clip-path",option+1) == 0)
1135 (void) SyncImageSettings(mogrify_info,*image,exception);
1136 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1137 MagickFalse,exception);
1140 if (LocaleCompare("colorize",option+1) == 0)
1145 (void) SyncImageSettings(mogrify_info,*image,exception);
1146 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1149 if (LocaleCompare("color-matrix",option+1) == 0)
1154 (void) SyncImageSettings(mogrify_info,*image,exception);
1155 kernel=AcquireKernelInfo(argv[i+1],exception);
1156 if (kernel == (KernelInfo *) NULL)
1158 /* FUTURE: check on size of the matrix */
1159 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1160 kernel=DestroyKernelInfo(kernel);
1163 if (LocaleCompare("colors",option+1) == 0)
1166 Reduce the number of colors in the image.
1168 (void) SyncImageSettings(mogrify_info,*image,exception);
1169 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1170 if (quantize_info->number_colors == 0)
1172 if (((*image)->storage_class == DirectClass) ||
1173 (*image)->colors > quantize_info->number_colors)
1174 (void) QuantizeImage(quantize_info,*image,exception);
1176 (void) CompressImageColormap(*image,exception);
1179 if (LocaleCompare("colorspace",option+1) == 0)
1184 (void) SyncImageSettings(mogrify_info,*image,exception);
1187 (void) TransformImageColorspace(*image,sRGBColorspace,
1191 colorspace=(ColorspaceType) ParseCommandOption(
1192 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1193 (void) TransformImageColorspace(*image,colorspace,exception);
1196 if (LocaleCompare("compose",option+1) == 0)
1198 (void) SyncImageSettings(mogrify_info,*image,exception);
1199 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1200 MagickFalse,argv[i+1]);
1203 if (LocaleCompare("connected-component",option+1) == 0)
1205 (void) SyncImageSettings(mogrify_info,*image,exception);
1206 mogrify_image=ConnectedComponentsImage(*image,
1207 (size_t) StringToInteger(argv[i+1]),exception);
1210 if (LocaleCompare("contrast",option+1) == 0)
1212 (void) SyncImageSettings(mogrify_info,*image,exception);
1213 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1214 MagickFalse,exception);
1217 if (LocaleCompare("contrast-stretch",option+1) == 0)
1227 Contrast stretch image.
1229 (void) SyncImageSettings(mogrify_info,*image,exception);
1230 flags=ParseGeometry(argv[i+1],&geometry_info);
1231 black_point=geometry_info.rho;
1232 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1234 if ((flags & PercentValue) != 0)
1236 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1237 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1239 white_point=(double) (*image)->columns*(*image)->rows-
1241 (void) ContrastStretchImage(*image,black_point,white_point,
1245 if (LocaleCompare("convolve",option+1) == 0)
1250 (void) SyncImageSettings(mogrify_info,*image,exception);
1251 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1252 if (kernel_info == (KernelInfo *) NULL)
1254 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1255 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1256 kernel_info,exception);
1257 kernel_info=DestroyKernelInfo(kernel_info);
1260 if (LocaleCompare("crop",option+1) == 0)
1263 Crop a image to a smaller size
1265 (void) SyncImageSettings(mogrify_info,*image,exception);
1266 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1269 if (LocaleCompare("cycle",option+1) == 0)
1272 Cycle an image colormap.
1274 (void) SyncImageSettings(mogrify_info,*image,exception);
1275 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1283 if (LocaleCompare("decipher",option+1) == 0)
1291 (void) SyncImageSettings(mogrify_info,*image,exception);
1292 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1293 if (passkey != (StringInfo *) NULL)
1295 (void) PasskeyDecipherImage(*image,passkey,exception);
1296 passkey=DestroyStringInfo(passkey);
1300 if (LocaleCompare("density",option+1) == 0)
1305 (void) CloneString(&draw_info->density,argv[i+1]);
1308 if (LocaleCompare("depth",option+1) == 0)
1310 (void) SyncImageSettings(mogrify_info,*image,exception);
1313 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1316 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1320 if (LocaleCompare("deskew",option+1) == 0)
1326 Straighten the image.
1328 (void) SyncImageSettings(mogrify_info,*image,exception);
1330 threshold=40.0*QuantumRange/100.0;
1332 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1334 mogrify_image=DeskewImage(*image,threshold,exception);
1337 if (LocaleCompare("despeckle",option+1) == 0)
1340 Reduce the speckles within an image.
1342 (void) SyncImageSettings(mogrify_info,*image,exception);
1343 mogrify_image=DespeckleImage(*image,exception);
1346 if (LocaleCompare("display",option+1) == 0)
1348 (void) CloneString(&draw_info->server_name,argv[i+1]);
1351 if (LocaleCompare("distort",option+1) == 0)
1355 token[MaxTextExtent];
1375 (void) SyncImageSettings(mogrify_info,*image,exception);
1376 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1377 MagickFalse,argv[i+1]);
1378 if (method == ResizeDistortion)
1384 Special Case - Argument is actually a resize geometry!
1385 Convert that to an appropriate distortion argument array.
1387 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1389 resize_args[0]=(double) geometry.width;
1390 resize_args[1]=(double) geometry.height;
1391 mogrify_image=DistortImage(*image,method,(size_t)2,
1392 resize_args,MagickTrue,exception);
1395 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1397 if (args == (char *) NULL)
1400 for (x=0; *p != '\0'; x++)
1402 GetMagickToken(p,&p,token);
1404 GetMagickToken(p,&p,token);
1406 number_arguments=(size_t) x;
1407 arguments=(double *) AcquireQuantumMemory(number_arguments,
1408 sizeof(*arguments));
1409 if (arguments == (double *) NULL)
1410 ThrowWandFatalException(ResourceLimitFatalError,
1411 "MemoryAllocationFailed",(*image)->filename);
1412 (void) ResetMagickMemory(arguments,0,number_arguments*
1413 sizeof(*arguments));
1415 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1417 GetMagickToken(p,&p,token);
1419 GetMagickToken(p,&p,token);
1420 arguments[x]=StringToDouble(token,(char **) NULL);
1422 args=DestroyString(args);
1423 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1424 (*option == '+') ? MagickTrue : MagickFalse,exception);
1425 arguments=(double *) RelinquishMagickMemory(arguments);
1428 if (LocaleCompare("dither",option+1) == 0)
1432 quantize_info->dither_method=NoDitherMethod;
1435 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1436 MagickDitherOptions,MagickFalse,argv[i+1]);
1439 if (LocaleCompare("draw",option+1) == 0)
1444 (void) SyncImageSettings(mogrify_info,*image,exception);
1445 (void) CloneString(&draw_info->primitive,argv[i+1]);
1446 (void) DrawImage(*image,draw_info,exception);
1453 if (LocaleCompare("edge",option+1) == 0)
1456 Enhance edges in the image.
1458 (void) SyncImageSettings(mogrify_info,*image,exception);
1459 flags=ParseGeometry(argv[i+1],&geometry_info);
1460 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1463 if (LocaleCompare("emboss",option+1) == 0)
1468 (void) SyncImageSettings(mogrify_info,*image,exception);
1469 flags=ParseGeometry(argv[i+1],&geometry_info);
1470 if ((flags & SigmaValue) == 0)
1471 geometry_info.sigma=1.0;
1472 mogrify_image=EmbossImage(*image,geometry_info.rho,
1473 geometry_info.sigma,exception);
1476 if (LocaleCompare("encipher",option+1) == 0)
1484 (void) SyncImageSettings(mogrify_info,*image,exception);
1485 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1486 if (passkey != (StringInfo *) NULL)
1488 (void) PasskeyEncipherImage(*image,passkey,exception);
1489 passkey=DestroyStringInfo(passkey);
1493 if (LocaleCompare("encoding",option+1) == 0)
1495 (void) CloneString(&draw_info->encoding,argv[i+1]);
1498 if (LocaleCompare("enhance",option+1) == 0)
1503 (void) SyncImageSettings(mogrify_info,*image,exception);
1504 mogrify_image=EnhanceImage(*image,exception);
1507 if (LocaleCompare("equalize",option+1) == 0)
1512 (void) SyncImageSettings(mogrify_info,*image,exception);
1513 (void) EqualizeImage(*image,exception);
1516 if (LocaleCompare("evaluate",option+1) == 0)
1521 MagickEvaluateOperator
1524 (void) SyncImageSettings(mogrify_info,*image,exception);
1525 op=(MagickEvaluateOperator) ParseCommandOption(
1526 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1527 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1529 (void) EvaluateImage(*image,op,constant,exception);
1532 if (LocaleCompare("extent",option+1) == 0)
1535 Set the image extent.
1537 (void) SyncImageSettings(mogrify_info,*image,exception);
1538 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1539 if (geometry.width == 0)
1540 geometry.width=(*image)->columns;
1541 if (geometry.height == 0)
1542 geometry.height=(*image)->rows;
1543 mogrify_image=ExtentImage(*image,&geometry,exception);
1550 if (LocaleCompare("family",option+1) == 0)
1554 if (draw_info->family != (char *) NULL)
1555 draw_info->family=DestroyString(draw_info->family);
1558 (void) CloneString(&draw_info->family,argv[i+1]);
1561 if (LocaleCompare("features",option+1) == 0)
1565 (void) DeleteImageArtifact(*image,"identify:features");
1568 (void) SetImageArtifact(*image,"vdentify:features",argv[i+1]);
1569 (void) SetImageArtifact(*image,"verbose","true");
1572 if (LocaleCompare("fill",option+1) == 0)
1580 GetPixelInfo(*image,&fill);
1583 (void) QueryColorCompliance("none",AllCompliance,&fill,
1585 draw_info->fill=fill;
1586 if (draw_info->fill_pattern != (Image *) NULL)
1587 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1590 sans=AcquireExceptionInfo();
1591 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1592 sans=DestroyExceptionInfo(sans);
1593 if (status == MagickFalse)
1594 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1597 draw_info->fill=fill=color;
1600 if (LocaleCompare("flip",option+1) == 0)
1603 Flip image scanlines.
1605 (void) SyncImageSettings(mogrify_info,*image,exception);
1606 mogrify_image=FlipImage(*image,exception);
1609 if (LocaleCompare("floodfill",option+1) == 0)
1617 (void) SyncImageSettings(mogrify_info,*image,exception);
1618 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1619 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1621 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1622 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1625 if (LocaleCompare("flop",option+1) == 0)
1628 Flop image scanlines.
1630 (void) SyncImageSettings(mogrify_info,*image,exception);
1631 mogrify_image=FlopImage(*image,exception);
1634 if (LocaleCompare("font",option+1) == 0)
1638 if (draw_info->font != (char *) NULL)
1639 draw_info->font=DestroyString(draw_info->font);
1642 (void) CloneString(&draw_info->font,argv[i+1]);
1645 if (LocaleCompare("format",option+1) == 0)
1650 if (LocaleCompare("frame",option+1) == 0)
1656 Surround image with an ornamental border.
1658 (void) SyncImageSettings(mogrify_info,*image,exception);
1659 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1660 frame_info.width=geometry.width;
1661 frame_info.height=geometry.height;
1662 frame_info.outer_bevel=geometry.x;
1663 frame_info.inner_bevel=geometry.y;
1664 frame_info.x=(ssize_t) frame_info.width;
1665 frame_info.y=(ssize_t) frame_info.height;
1666 frame_info.width=(*image)->columns+2*frame_info.width;
1667 frame_info.height=(*image)->rows+2*frame_info.height;
1668 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1671 if (LocaleCompare("function",option+1) == 0)
1675 token[MaxTextExtent];
1693 Function Modify Image Values
1695 (void) SyncImageSettings(mogrify_info,*image,exception);
1696 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1697 MagickFalse,argv[i+1]);
1698 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1700 if (arguments == (char *) NULL)
1702 p=(char *) arguments;
1703 for (x=0; *p != '\0'; x++)
1705 GetMagickToken(p,&p,token);
1707 GetMagickToken(p,&p,token);
1709 number_parameters=(size_t) x;
1710 parameters=(double *) AcquireQuantumMemory(number_parameters,
1711 sizeof(*parameters));
1712 if (parameters == (double *) NULL)
1713 ThrowWandFatalException(ResourceLimitFatalError,
1714 "MemoryAllocationFailed",(*image)->filename);
1715 (void) ResetMagickMemory(parameters,0,number_parameters*
1716 sizeof(*parameters));
1717 p=(char *) arguments;
1718 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1720 GetMagickToken(p,&p,token);
1722 GetMagickToken(p,&p,token);
1723 parameters[x]=StringToDouble(token,(char **) NULL);
1725 arguments=DestroyString(arguments);
1726 (void) FunctionImage(*image,function,number_parameters,parameters,
1728 parameters=(double *) RelinquishMagickMemory(parameters);
1735 if (LocaleCompare("gamma",option+1) == 0)
1740 (void) SyncImageSettings(mogrify_info,*image,exception);
1742 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1744 (void) GammaImage(*image,StringToDouble(argv[i+1],
1745 (char **) NULL),exception);
1748 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1749 (LocaleCompare("gaussian",option+1) == 0))
1752 Gaussian blur image.
1754 (void) SyncImageSettings(mogrify_info,*image,exception);
1755 flags=ParseGeometry(argv[i+1],&geometry_info);
1756 if ((flags & SigmaValue) == 0)
1757 geometry_info.sigma=1.0;
1758 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1759 geometry_info.sigma,exception);
1762 if (LocaleCompare("geometry",option+1) == 0)
1765 Record Image offset, Resize last image.
1767 (void) SyncImageSettings(mogrify_info,*image,exception);
1770 if ((*image)->geometry != (char *) NULL)
1771 (*image)->geometry=DestroyString((*image)->geometry);
1774 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1775 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1776 (void) CloneString(&(*image)->geometry,argv[i+1]);
1778 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1779 (*image)->filter,exception);
1782 if (LocaleCompare("gravity",option+1) == 0)
1786 draw_info->gravity=UndefinedGravity;
1789 draw_info->gravity=(GravityType) ParseCommandOption(
1790 MagickGravityOptions,MagickFalse,argv[i+1]);
1793 if (LocaleCompare("grayscale",option+1) == 0)
1795 PixelIntensityMethod
1798 (void) SyncImageSettings(mogrify_info,*image,exception);
1799 method=(PixelIntensityMethod) ParseCommandOption(
1800 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1801 (void) GrayscaleImage(*image,method,exception);
1808 if (LocaleCompare("highlight-color",option+1) == 0)
1810 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1813 if (LocaleCompare("hough-lines",option+1) == 0)
1816 Detect edges in the image.
1818 (void) SyncImageSettings(mogrify_info,*image,exception);
1819 flags=ParseGeometry(argv[i+1],&geometry_info);
1820 if ((flags & SigmaValue) == 0)
1821 geometry_info.sigma=geometry_info.rho;
1822 if ((flags & XiValue) == 0)
1823 geometry_info.xi=40;
1824 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1825 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1832 if (LocaleCompare("identify",option+1) == 0)
1837 (void) SyncImageSettings(mogrify_info,*image,exception);
1838 if (format == (char *) NULL)
1840 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1844 text=InterpretImageProperties(mogrify_info,*image,format,
1846 if (text == (char *) NULL)
1848 (void) fputs(text,stdout);
1849 text=DestroyString(text);
1852 if (LocaleCompare("implode",option+1) == 0)
1857 (void) SyncImageSettings(mogrify_info,*image,exception);
1858 (void) ParseGeometry(argv[i+1],&geometry_info);
1859 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1860 interpolate_method,exception);
1863 if (LocaleCompare("interline-spacing",option+1) == 0)
1866 (void) ParseGeometry("0",&geometry_info);
1868 (void) ParseGeometry(argv[i+1],&geometry_info);
1869 draw_info->interline_spacing=geometry_info.rho;
1872 if (LocaleCompare("interpolate",option+1) == 0)
1874 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1875 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1878 if (LocaleCompare("interword-spacing",option+1) == 0)
1881 (void) ParseGeometry("0",&geometry_info);
1883 (void) ParseGeometry(argv[i+1],&geometry_info);
1884 draw_info->interword_spacing=geometry_info.rho;
1887 if (LocaleCompare("interpolative-resize",option+1) == 0)
1890 Interpolative resize image.
1892 (void) SyncImageSettings(mogrify_info,*image,exception);
1893 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1894 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1895 geometry.height,interpolate_method,exception);
1902 if (LocaleCompare("kerning",option+1) == 0)
1905 (void) ParseGeometry("0",&geometry_info);
1907 (void) ParseGeometry(argv[i+1],&geometry_info);
1908 draw_info->kerning=geometry_info.rho;
1911 if (LocaleCompare("kuwahara",option+1) == 0)
1914 Edge preserving blur.
1916 (void) SyncImageSettings(mogrify_info,*image,exception);
1917 flags=ParseGeometry(argv[i+1],&geometry_info);
1918 if ((flags & SigmaValue) == 0)
1919 geometry_info.sigma=geometry_info.rho-0.5;
1920 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1921 geometry_info.sigma,exception);
1928 if (LocaleCompare("lat",option+1) == 0)
1931 Local adaptive threshold image.
1933 (void) SyncImageSettings(mogrify_info,*image,exception);
1934 flags=ParseGeometry(argv[i+1],&geometry_info);
1935 if ((flags & PercentValue) != 0)
1936 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1937 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1938 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1939 geometry_info.xi,exception);
1942 if (LocaleCompare("level",option+1) == 0)
1955 (void) SyncImageSettings(mogrify_info,*image,exception);
1956 flags=ParseGeometry(argv[i+1],&geometry_info);
1957 black_point=geometry_info.rho;
1958 white_point=(double) QuantumRange;
1959 if ((flags & SigmaValue) != 0)
1960 white_point=geometry_info.sigma;
1962 if ((flags & XiValue) != 0)
1963 gamma=geometry_info.xi;
1964 if ((flags & PercentValue) != 0)
1966 black_point*=(double) (QuantumRange/100.0);
1967 white_point*=(double) (QuantumRange/100.0);
1969 if ((flags & SigmaValue) == 0)
1970 white_point=(double) QuantumRange-black_point;
1971 if ((*option == '+') || ((flags & AspectValue) != 0))
1972 (void) LevelizeImage(*image,black_point,white_point,gamma,
1975 (void) LevelImage(*image,black_point,white_point,gamma,
1979 if (LocaleCompare("level-colors",option+1) == 0)
1982 token[MaxTextExtent];
1991 p=(const char *) argv[i+1];
1992 GetMagickToken(p,&p,token); /* get black point color */
1993 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1994 (void) QueryColorCompliance(token,AllCompliance,
1995 &black_point,exception);
1997 (void) QueryColorCompliance("#000000",AllCompliance,
1998 &black_point,exception);
1999 if (isalpha((int) token[0]) || (token[0] == '#'))
2000 GetMagickToken(p,&p,token);
2002 white_point=black_point; /* set everything to that color */
2005 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2006 GetMagickToken(p,&p,token); /* Get white point color. */
2007 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2008 (void) QueryColorCompliance(token,AllCompliance,
2009 &white_point,exception);
2011 (void) QueryColorCompliance("#ffffff",AllCompliance,
2012 &white_point,exception);
2014 (void) LevelImageColors(*image,&black_point,&white_point,
2015 *option == '+' ? MagickTrue : MagickFalse,exception);
2018 if (LocaleCompare("linear-stretch",option+1) == 0)
2027 (void) SyncImageSettings(mogrify_info,*image,exception);
2028 flags=ParseGeometry(argv[i+1],&geometry_info);
2029 black_point=geometry_info.rho;
2030 white_point=(double) (*image)->columns*(*image)->rows;
2031 if ((flags & SigmaValue) != 0)
2032 white_point=geometry_info.sigma;
2033 if ((flags & PercentValue) != 0)
2035 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2036 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2038 if ((flags & SigmaValue) == 0)
2039 white_point=(double) (*image)->columns*(*image)->rows-
2041 (void) LinearStretchImage(*image,black_point,white_point,exception);
2044 if (LocaleCompare("liquid-rescale",option+1) == 0)
2047 Liquid rescale image.
2049 (void) SyncImageSettings(mogrify_info,*image,exception);
2050 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2051 if ((flags & XValue) == 0)
2053 if ((flags & YValue) == 0)
2055 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2056 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2059 if (LocaleCompare("lowlight-color",option+1) == 0)
2061 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2068 if (LocaleCompare("magnify",option+1) == 0)
2073 (void) SyncImageSettings(mogrify_info,*image,exception);
2074 mogrify_image=MagnifyImage(*image,exception);
2077 if (LocaleCompare("map",option+1) == 0)
2083 Transform image colors to match this set of colors.
2085 (void) SyncImageSettings(mogrify_info,*image,exception);
2088 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2089 if (remap_image == (Image *) NULL)
2091 (void) RemapImage(quantize_info,*image,remap_image,exception);
2092 remap_image=DestroyImage(remap_image);
2095 if (LocaleCompare("mask",option+1) == 0)
2100 (void) SyncImageSettings(mogrify_info,*image,exception);
2106 (void) SetImageMask(*image,(Image *) NULL,exception);
2112 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2113 if (mask == (Image *) NULL)
2115 (void) SetImageMask(*image,mask,exception);
2116 mask=DestroyImage(mask);
2119 if (LocaleCompare("matte",option+1) == 0)
2121 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2122 SetAlphaChannel : DeactivateAlphaChannel,exception);
2125 if (LocaleCompare("mean-shift",option+1) == 0)
2128 Detect edges in the image.
2130 (void) SyncImageSettings(mogrify_info,*image,exception);
2131 flags=ParseGeometry(argv[i+1],&geometry_info);
2132 if ((flags & SigmaValue) == 0)
2133 geometry_info.sigma=geometry_info.rho;
2134 if ((flags & XiValue) == 0)
2135 geometry_info.xi=0.10*QuantumRange;
2136 if ((flags & PercentValue) != 0)
2137 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2138 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2139 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2142 if (LocaleCompare("median",option+1) == 0)
2145 Median filter image.
2147 (void) SyncImageSettings(mogrify_info,*image,exception);
2148 flags=ParseGeometry(argv[i+1],&geometry_info);
2149 if ((flags & SigmaValue) == 0)
2150 geometry_info.sigma=geometry_info.rho;
2151 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2152 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2155 if (LocaleCompare("mode",option+1) == 0)
2160 (void) SyncImageSettings(mogrify_info,*image,exception);
2161 flags=ParseGeometry(argv[i+1],&geometry_info);
2162 if ((flags & SigmaValue) == 0)
2163 geometry_info.sigma=geometry_info.rho;
2164 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2165 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2168 if (LocaleCompare("modulate",option+1) == 0)
2170 (void) SyncImageSettings(mogrify_info,*image,exception);
2171 (void) ModulateImage(*image,argv[i+1],exception);
2174 if (LocaleCompare("moments",option+1) == 0)
2178 (void) DeleteImageArtifact(*image,"identify:moments");
2181 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2182 (void) SetImageArtifact(*image,"verbose","true");
2185 if (LocaleCompare("monitor",option+1) == 0)
2189 (void) SetImageProgressMonitor(*image,
2190 (MagickProgressMonitor) NULL,(void *) NULL);
2193 (void) SetImageProgressMonitor(*image,MonitorProgress,
2197 if (LocaleCompare("monochrome",option+1) == 0)
2199 (void) SyncImageSettings(mogrify_info,*image,exception);
2200 (void) SetImageType(*image,BilevelType,exception);
2203 if (LocaleCompare("morphology",option+1) == 0)
2206 token[MaxTextExtent];
2221 Morphological Image Operation
2223 (void) SyncImageSettings(mogrify_info,*image,exception);
2225 GetMagickToken(p,&p,token);
2226 method=(MorphologyMethod) ParseCommandOption(
2227 MagickMorphologyOptions,MagickFalse,token);
2229 GetMagickToken(p,&p,token);
2230 if ((*p == ':') || (*p == ','))
2231 GetMagickToken(p,&p,token);
2233 iterations=(ssize_t) StringToLong(p);
2234 kernel=AcquireKernelInfo(argv[i+2],exception);
2235 if (kernel == (KernelInfo *) NULL)
2237 (void) ThrowMagickException(exception,GetMagickModule(),
2238 OptionError,"UnabletoParseKernel","morphology");
2242 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2244 kernel=DestroyKernelInfo(kernel);
2247 if (LocaleCompare("motion-blur",option+1) == 0)
2252 (void) SyncImageSettings(mogrify_info,*image,exception);
2253 flags=ParseGeometry(argv[i+1],&geometry_info);
2254 if ((flags & SigmaValue) == 0)
2255 geometry_info.sigma=1.0;
2256 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2257 geometry_info.sigma,geometry_info.xi,exception);
2264 if (LocaleCompare("negate",option+1) == 0)
2266 (void) SyncImageSettings(mogrify_info,*image,exception);
2267 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2268 MagickFalse,exception);
2271 if (LocaleCompare("noise",option+1) == 0)
2273 (void) SyncImageSettings(mogrify_info,*image,exception);
2276 flags=ParseGeometry(argv[i+1],&geometry_info);
2277 if ((flags & SigmaValue) == 0)
2278 geometry_info.sigma=geometry_info.rho;
2279 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2280 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2287 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2288 MagickFalse,argv[i+1]);
2289 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2293 if (LocaleCompare("normalize",option+1) == 0)
2295 (void) SyncImageSettings(mogrify_info,*image,exception);
2296 (void) NormalizeImage(*image,exception);
2303 if (LocaleCompare("opaque",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image,exception);
2309 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2311 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2312 MagickFalse : MagickTrue,exception);
2315 if (LocaleCompare("ordered-dither",option+1) == 0)
2317 (void) SyncImageSettings(mogrify_info,*image,exception);
2318 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2325 if (LocaleCompare("paint",option+1) == 0)
2327 (void) SyncImageSettings(mogrify_info,*image,exception);
2328 (void) ParseGeometry(argv[i+1],&geometry_info);
2329 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2330 geometry_info.sigma,exception);
2333 if (LocaleCompare("perceptible",option+1) == 0)
2338 (void) SyncImageSettings(mogrify_info,*image,exception);
2339 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2340 (char **) NULL),exception);
2343 if (LocaleCompare("pointsize",option+1) == 0)
2346 (void) ParseGeometry("12",&geometry_info);
2348 (void) ParseGeometry(argv[i+1],&geometry_info);
2349 draw_info->pointsize=geometry_info.rho;
2352 if (LocaleCompare("polaroid",option+1) == 0)
2364 Simulate a Polaroid picture.
2366 (void) SyncImageSettings(mogrify_info,*image,exception);
2367 random_info=AcquireRandomInfo();
2368 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2369 random_info=DestroyRandomInfo(random_info);
2372 SetGeometryInfo(&geometry_info);
2373 flags=ParseGeometry(argv[i+1],&geometry_info);
2374 angle=geometry_info.rho;
2376 caption=GetImageProperty(*image,"caption",exception);
2377 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2378 interpolate_method,exception);
2381 if (LocaleCompare("posterize",option+1) == 0)
2386 (void) SyncImageSettings(mogrify_info,*image,exception);
2387 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2388 quantize_info->dither_method,exception);
2391 if (LocaleCompare("preview",option+1) == 0)
2399 (void) SyncImageSettings(mogrify_info,*image,exception);
2401 preview_type=UndefinedPreview;
2403 preview_type=(PreviewType) ParseCommandOption(
2404 MagickPreviewOptions,MagickFalse,argv[i+1]);
2405 mogrify_image=PreviewImage(*image,preview_type,exception);
2408 if (LocaleCompare("profile",option+1) == 0)
2422 (void) SyncImageSettings(mogrify_info,*image,exception);
2426 Remove a profile from the image.
2428 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2433 Associate a profile with the image.
2435 profile_info=CloneImageInfo(mogrify_info);
2436 profile=GetImageProfile(*image,"iptc");
2437 if (profile != (StringInfo *) NULL)
2438 profile_info->profile=(void *) CloneStringInfo(profile);
2439 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2440 profile_info=DestroyImageInfo(profile_info);
2441 if (profile_image == (Image *) NULL)
2446 profile_info=CloneImageInfo(mogrify_info);
2447 (void) CopyMagickString(profile_info->filename,argv[i+1],
2449 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2450 if (profile != (StringInfo *) NULL)
2452 (void) ProfileImage(*image,profile_info->magick,
2453 GetStringInfoDatum(profile),(size_t)
2454 GetStringInfoLength(profile),exception);
2455 profile=DestroyStringInfo(profile);
2457 profile_info=DestroyImageInfo(profile_info);
2460 ResetImageProfileIterator(profile_image);
2461 name=GetNextImageProfile(profile_image);
2462 while (name != (const char *) NULL)
2464 profile=GetImageProfile(profile_image,name);
2465 if (profile != (StringInfo *) NULL)
2466 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2467 (size_t) GetStringInfoLength(profile),exception);
2468 name=GetNextImageProfile(profile_image);
2470 profile_image=DestroyImage(profile_image);
2477 if (LocaleCompare("quantize",option+1) == 0)
2481 quantize_info->colorspace=UndefinedColorspace;
2484 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2485 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2492 if (LocaleCompare("rotational-blur",option+1) == 0)
2495 Rotational blur image.
2497 (void) SyncImageSettings(mogrify_info,*image,exception);
2498 flags=ParseGeometry(argv[i+1],&geometry_info);
2499 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,exception);
2502 if (LocaleCompare("raise",option+1) == 0)
2505 Surround image with a raise of solid color.
2507 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2508 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2509 MagickFalse,exception);
2512 if (LocaleCompare("random-threshold",option+1) == 0)
2517 (void) SyncImageSettings(mogrify_info,*image,exception);
2518 (void) RandomThresholdImage(*image,argv[i+1],exception);
2521 if (LocaleCompare("region",option+1) == 0)
2523 (void) SyncImageSettings(mogrify_info,*image,exception);
2524 if (region_image != (Image *) NULL)
2529 (void) CompositeImage(region_image,*image,
2530 region_image->alpha_trait != UndefinedPixelTrait ?
2531 CopyCompositeOp : OverCompositeOp,MagickTrue,
2532 region_geometry.x,region_geometry.y,exception);
2533 *image=DestroyImage(*image);
2534 *image=region_image;
2535 region_image = (Image *) NULL;
2540 Apply transformations to a selected region of the image.
2542 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2544 mogrify_image=CropImage(*image,®ion_geometry,exception);
2545 if (mogrify_image == (Image *) NULL)
2547 region_image=(*image);
2548 *image=mogrify_image;
2549 mogrify_image=(Image *) NULL;
2552 if (LocaleCompare("render",option+1) == 0)
2554 (void) SyncImageSettings(mogrify_info,*image,exception);
2555 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2558 if (LocaleCompare("remap",option+1) == 0)
2564 Transform image colors to match this set of colors.
2566 (void) SyncImageSettings(mogrify_info,*image,exception);
2569 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2570 if (remap_image == (Image *) NULL)
2572 (void) RemapImage(quantize_info,*image,remap_image,exception);
2573 remap_image=DestroyImage(remap_image);
2576 if (LocaleCompare("repage",option+1) == 0)
2580 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2583 (void) ResetImagePage(*image,argv[i+1]);
2586 if (LocaleCompare("resample",option+1) == 0)
2591 (void) SyncImageSettings(mogrify_info,*image,exception);
2592 flags=ParseGeometry(argv[i+1],&geometry_info);
2593 if ((flags & SigmaValue) == 0)
2594 geometry_info.sigma=geometry_info.rho;
2595 mogrify_image=ResampleImage(*image,geometry_info.rho,
2596 geometry_info.sigma,(*image)->filter,exception);
2599 if (LocaleCompare("resize",option+1) == 0)
2604 (void) SyncImageSettings(mogrify_info,*image,exception);
2605 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2606 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2607 (*image)->filter,exception);
2610 if (LocaleCompare("roll",option+1) == 0)
2615 (void) SyncImageSettings(mogrify_info,*image,exception);
2616 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2617 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2620 if (LocaleCompare("rotate",option+1) == 0)
2626 Check for conditional image rotation.
2628 (void) SyncImageSettings(mogrify_info,*image,exception);
2629 if (strchr(argv[i+1],'>') != (char *) NULL)
2630 if ((*image)->columns <= (*image)->rows)
2632 if (strchr(argv[i+1],'<') != (char *) NULL)
2633 if ((*image)->columns >= (*image)->rows)
2638 geometry=ConstantString(argv[i+1]);
2639 (void) SubstituteString(&geometry,">","");
2640 (void) SubstituteString(&geometry,"<","");
2641 (void) ParseGeometry(geometry,&geometry_info);
2642 geometry=DestroyString(geometry);
2643 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2650 if (LocaleCompare("sample",option+1) == 0)
2653 Sample image with pixel replication.
2655 (void) SyncImageSettings(mogrify_info,*image,exception);
2656 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2657 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2661 if (LocaleCompare("scale",option+1) == 0)
2666 (void) SyncImageSettings(mogrify_info,*image,exception);
2667 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2668 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2672 if (LocaleCompare("selective-blur",option+1) == 0)
2675 Selectively blur pixels within a contrast threshold.
2677 (void) SyncImageSettings(mogrify_info,*image,exception);
2678 flags=ParseGeometry(argv[i+1],&geometry_info);
2679 if ((flags & PercentValue) != 0)
2680 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2681 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2682 geometry_info.sigma,geometry_info.xi,exception);
2685 if (LocaleCompare("separate",option+1) == 0)
2688 Break channels into separate images.
2690 (void) SyncImageSettings(mogrify_info,*image,exception);
2691 mogrify_image=SeparateImages(*image,exception);
2694 if (LocaleCompare("sepia-tone",option+1) == 0)
2702 (void) SyncImageSettings(mogrify_info,*image,exception);
2703 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2705 mogrify_image=SepiaToneImage(*image,threshold,exception);
2708 if (LocaleCompare("segment",option+1) == 0)
2713 (void) SyncImageSettings(mogrify_info,*image,exception);
2714 flags=ParseGeometry(argv[i+1],&geometry_info);
2715 if ((flags & SigmaValue) == 0)
2716 geometry_info.sigma=1.0;
2717 (void) SegmentImage(*image,(*image)->colorspace,
2718 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2722 if (LocaleCompare("set",option+1) == 0)
2732 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2733 (void) DeleteImageRegistry(argv[i+1]+9);
2735 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2737 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2738 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2741 (void) DeleteImageProperty(*image,argv[i+1]);
2744 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2746 if (value == (char *) NULL)
2748 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2749 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2752 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2754 (void) SetImageOption(image_info,argv[i+1]+7,value);
2755 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2756 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2759 (void) SetImageProperty(*image,argv[i+1],value,exception);
2760 value=DestroyString(value);
2763 if (LocaleCompare("shade",option+1) == 0)
2768 (void) SyncImageSettings(mogrify_info,*image,exception);
2769 flags=ParseGeometry(argv[i+1],&geometry_info);
2770 if ((flags & SigmaValue) == 0)
2771 geometry_info.sigma=1.0;
2772 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2773 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2776 if (LocaleCompare("shadow",option+1) == 0)
2781 (void) SyncImageSettings(mogrify_info,*image,exception);
2782 flags=ParseGeometry(argv[i+1],&geometry_info);
2783 if ((flags & SigmaValue) == 0)
2784 geometry_info.sigma=1.0;
2785 if ((flags & XiValue) == 0)
2786 geometry_info.xi=4.0;
2787 if ((flags & PsiValue) == 0)
2788 geometry_info.psi=4.0;
2789 mogrify_image=ShadowImage(*image,geometry_info.rho,
2790 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2791 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2794 if (LocaleCompare("sharpen",option+1) == 0)
2799 (void) SyncImageSettings(mogrify_info,*image,exception);
2800 flags=ParseGeometry(argv[i+1],&geometry_info);
2801 if ((flags & SigmaValue) == 0)
2802 geometry_info.sigma=1.0;
2803 if ((flags & XiValue) == 0)
2804 geometry_info.xi=0.0;
2805 mogrify_image=SharpenImage(*image,geometry_info.rho,
2806 geometry_info.sigma,exception);
2809 if (LocaleCompare("shave",option+1) == 0)
2812 Shave the image edges.
2814 (void) SyncImageSettings(mogrify_info,*image,exception);
2815 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2816 mogrify_image=ShaveImage(*image,&geometry,exception);
2819 if (LocaleCompare("shear",option+1) == 0)
2824 (void) SyncImageSettings(mogrify_info,*image,exception);
2825 flags=ParseGeometry(argv[i+1],&geometry_info);
2826 if ((flags & SigmaValue) == 0)
2827 geometry_info.sigma=geometry_info.rho;
2828 mogrify_image=ShearImage(*image,geometry_info.rho,
2829 geometry_info.sigma,exception);
2832 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2835 Sigmoidal non-linearity contrast control.
2837 (void) SyncImageSettings(mogrify_info,*image,exception);
2838 flags=ParseGeometry(argv[i+1],&geometry_info);
2839 if ((flags & SigmaValue) == 0)
2840 geometry_info.sigma=(double) QuantumRange/2.0;
2841 if ((flags & PercentValue) != 0)
2842 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2844 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2845 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2849 if (LocaleCompare("sketch",option+1) == 0)
2854 (void) SyncImageSettings(mogrify_info,*image,exception);
2855 flags=ParseGeometry(argv[i+1],&geometry_info);
2856 if ((flags & SigmaValue) == 0)
2857 geometry_info.sigma=1.0;
2858 mogrify_image=SketchImage(*image,geometry_info.rho,
2859 geometry_info.sigma,geometry_info.xi,exception);
2862 if (LocaleCompare("solarize",option+1) == 0)
2867 (void) SyncImageSettings(mogrify_info,*image,exception);
2868 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2870 (void) SolarizeImage(*image,threshold,exception);
2873 if (LocaleCompare("sparse-color",option+1) == 0)
2882 Sparse Color Interpolated Gradient
2884 (void) SyncImageSettings(mogrify_info,*image,exception);
2885 method=(SparseColorMethod) ParseCommandOption(
2886 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2887 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2889 if (arguments == (char *) NULL)
2891 mogrify_image=SparseColorOption(*image,method,arguments,
2892 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2893 arguments=DestroyString(arguments);
2896 if (LocaleCompare("splice",option+1) == 0)
2899 Splice a solid color into the image.
2901 (void) SyncImageSettings(mogrify_info,*image,exception);
2902 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2903 mogrify_image=SpliceImage(*image,&geometry,exception);
2906 if (LocaleCompare("spread",option+1) == 0)
2911 (void) SyncImageSettings(mogrify_info,*image,exception);
2912 (void) ParseGeometry(argv[i+1],&geometry_info);
2913 mogrify_image=SpreadImage(*image,geometry_info.rho,
2914 interpolate_method,exception);
2917 if (LocaleCompare("statistic",option+1) == 0)
2922 (void) SyncImageSettings(mogrify_info,*image,exception);
2923 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2924 MagickFalse,argv[i+1]);
2925 (void) ParseGeometry(argv[i+2],&geometry_info);
2926 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2927 (size_t) geometry_info.sigma,exception);
2930 if (LocaleCompare("stretch",option+1) == 0)
2934 draw_info->stretch=UndefinedStretch;
2937 draw_info->stretch=(StretchType) ParseCommandOption(
2938 MagickStretchOptions,MagickFalse,argv[i+1]);
2941 if (LocaleCompare("strip",option+1) == 0)
2944 Strip image of profiles and comments.
2946 (void) SyncImageSettings(mogrify_info,*image,exception);
2947 (void) StripImage(*image,exception);
2950 if (LocaleCompare("stroke",option+1) == 0)
2960 (void) QueryColorCompliance("none",AllCompliance,
2961 &draw_info->stroke,exception);
2962 if (draw_info->stroke_pattern != (Image *) NULL)
2963 draw_info->stroke_pattern=DestroyImage(
2964 draw_info->stroke_pattern);
2967 sans=AcquireExceptionInfo();
2968 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2969 sans=DestroyExceptionInfo(sans);
2970 if (status == MagickFalse)
2971 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2974 draw_info->stroke=color;
2977 if (LocaleCompare("strokewidth",option+1) == 0)
2979 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2982 if (LocaleCompare("style",option+1) == 0)
2986 draw_info->style=UndefinedStyle;
2989 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2990 MagickFalse,argv[i+1]);
2993 if (LocaleCompare("swirl",option+1) == 0)
2998 (void) SyncImageSettings(mogrify_info,*image,exception);
2999 (void) ParseGeometry(argv[i+1],&geometry_info);
3000 mogrify_image=SwirlImage(*image,geometry_info.rho,
3001 interpolate_method,exception);
3008 if (LocaleCompare("threshold",option+1) == 0)
3016 (void) SyncImageSettings(mogrify_info,*image,exception);
3018 threshold=(double) QuantumRange/2;
3020 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3022 (void) BilevelImage(*image,threshold,exception);
3025 if (LocaleCompare("thumbnail",option+1) == 0)
3030 (void) SyncImageSettings(mogrify_info,*image,exception);
3031 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3032 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3036 if (LocaleCompare("tile",option+1) == 0)
3040 if (draw_info->fill_pattern != (Image *) NULL)
3041 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3044 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3048 if (LocaleCompare("tint",option+1) == 0)
3053 (void) SyncImageSettings(mogrify_info,*image,exception);
3054 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3057 if (LocaleCompare("transform",option+1) == 0)
3060 Affine transform image.
3062 (void) SyncImageSettings(mogrify_info,*image,exception);
3063 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3067 if (LocaleCompare("transparent",option+1) == 0)
3072 (void) SyncImageSettings(mogrify_info,*image,exception);
3073 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3075 (void) TransparentPaintImage(*image,&target,(Quantum)
3076 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3080 if (LocaleCompare("transpose",option+1) == 0)
3083 Transpose image scanlines.
3085 (void) SyncImageSettings(mogrify_info,*image,exception);
3086 mogrify_image=TransposeImage(*image,exception);
3089 if (LocaleCompare("transverse",option+1) == 0)
3092 Transverse image scanlines.
3094 (void) SyncImageSettings(mogrify_info,*image,exception);
3095 mogrify_image=TransverseImage(*image,exception);
3098 if (LocaleCompare("treedepth",option+1) == 0)
3100 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3103 if (LocaleCompare("trim",option+1) == 0)
3108 (void) SyncImageSettings(mogrify_info,*image,exception);
3109 mogrify_image=TrimImage(*image,exception);
3112 if (LocaleCompare("type",option+1) == 0)
3117 (void) SyncImageSettings(mogrify_info,*image,exception);
3121 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3123 (*image)->type=UndefinedType;
3124 (void) SetImageType(*image,type,exception);
3131 if (LocaleCompare("undercolor",option+1) == 0)
3133 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3134 &draw_info->undercolor,exception);
3137 if (LocaleCompare("unique",option+1) == 0)
3141 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3144 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3145 (void) SetImageArtifact(*image,"verbose","true");
3148 if (LocaleCompare("unique-colors",option+1) == 0)
3151 Unique image colors.
3153 (void) SyncImageSettings(mogrify_info,*image,exception);
3154 mogrify_image=UniqueImageColors(*image,exception);
3157 if (LocaleCompare("unsharp",option+1) == 0)
3162 (void) SyncImageSettings(mogrify_info,*image,exception);
3163 flags=ParseGeometry(argv[i+1],&geometry_info);
3164 if ((flags & SigmaValue) == 0)
3165 geometry_info.sigma=1.0;
3166 if ((flags & XiValue) == 0)
3167 geometry_info.xi=1.0;
3168 if ((flags & PsiValue) == 0)
3169 geometry_info.psi=0.05;
3170 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3171 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3179 if (LocaleCompare("verbose",option+1) == 0)
3181 (void) SetImageArtifact(*image,option+1,
3182 *option == '+' ? "false" : "true");
3185 if (LocaleCompare("vignette",option+1) == 0)
3190 (void) SyncImageSettings(mogrify_info,*image,exception);
3191 flags=ParseGeometry(argv[i+1],&geometry_info);
3192 if ((flags & SigmaValue) == 0)
3193 geometry_info.sigma=1.0;
3194 if ((flags & XiValue) == 0)
3195 geometry_info.xi=0.1*(*image)->columns;
3196 if ((flags & PsiValue) == 0)
3197 geometry_info.psi=0.1*(*image)->rows;
3198 if ((flags & PercentValue) != 0)
3200 geometry_info.xi*=(double) (*image)->columns/100.0;
3201 geometry_info.psi*=(double) (*image)->rows/100.0;
3203 mogrify_image=VignetteImage(*image,geometry_info.rho,
3204 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3205 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3208 if (LocaleCompare("virtual-pixel",option+1) == 0)
3212 (void) SetImageVirtualPixelMethod(*image,
3213 UndefinedVirtualPixelMethod,exception);
3216 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3217 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3218 argv[i+1]),exception);
3225 if (LocaleCompare("wave",option+1) == 0)
3230 (void) SyncImageSettings(mogrify_info,*image,exception);
3231 flags=ParseGeometry(argv[i+1],&geometry_info);
3232 if ((flags & SigmaValue) == 0)
3233 geometry_info.sigma=1.0;
3234 mogrify_image=WaveImage(*image,geometry_info.rho,
3235 geometry_info.sigma,interpolate_method,exception);
3238 if (LocaleCompare("weight",option+1) == 0)
3240 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3241 if (LocaleCompare(argv[i+1],"all") == 0)
3242 draw_info->weight=0;
3243 if (LocaleCompare(argv[i+1],"bold") == 0)
3244 draw_info->weight=700;
3245 if (LocaleCompare(argv[i+1],"bolder") == 0)
3246 if (draw_info->weight <= 800)
3247 draw_info->weight+=100;
3248 if (LocaleCompare(argv[i+1],"lighter") == 0)
3249 if (draw_info->weight >= 100)
3250 draw_info->weight-=100;
3251 if (LocaleCompare(argv[i+1],"normal") == 0)
3252 draw_info->weight=400;
3255 if (LocaleCompare("white-threshold",option+1) == 0)
3258 White threshold image.
3260 (void) SyncImageSettings(mogrify_info,*image,exception);
3261 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3270 Replace current image with any image that was generated
3272 if (mogrify_image != (Image *) NULL)
3273 ReplaceImageInListReturnLast(image,mogrify_image);
3276 if (region_image != (Image *) NULL)
3279 Composite transformed region onto image.
3281 (void) SyncImageSettings(mogrify_info,*image,exception);
3282 (void) CompositeImage(region_image,*image,
3283 region_image->alpha_trait != UndefinedPixelTrait ? CopyCompositeOp :
3284 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3286 *image=DestroyImage(*image);
3287 *image=region_image;
3288 region_image = (Image *) NULL;
3293 quantize_info=DestroyQuantizeInfo(quantize_info);
3294 draw_info=DestroyDrawInfo(draw_info);
3295 mogrify_info=DestroyImageInfo(mogrify_info);
3296 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3297 return(status == 0 ? MagickFalse : MagickTrue);
3301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3305 + M o g r i f y I m a g e C o m m a n d %
3309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3311 % MogrifyImageCommand() transforms an image or a sequence of images. These
3312 % transforms include image scaling, image rotation, color reduction, and
3313 % others. The transmogrified image overwrites the original image.
3315 % The format of the MogrifyImageCommand method is:
3317 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3318 % const char **argv,char **metadata,ExceptionInfo *exception)
3320 % A description of each parameter follows:
3322 % o image_info: the image info.
3324 % o argc: the number of elements in the argument vector.
3326 % o argv: A text array containing the command line arguments.
3328 % o metadata: any metadata is returned here.
3330 % o exception: return any errors or warnings in this structure.
3334 static MagickBooleanType MogrifyUsage(void)
3337 *channel_operators[]=
3339 "-channel-fx expression",
3340 " exchange, extract, or transfer one or more image channels",
3341 "-separate separate an image channel into a grayscale image",
3346 "-debug events display copious debugging information",
3347 "-distribute-cache port",
3348 " distributed pixel cache spanning one or more servers",
3349 "-help print program options",
3350 "-list type print a list of supported option arguments",
3351 "-log format format of debugging information",
3352 "-version print version information",
3357 "-adaptive-blur geometry",
3358 " adaptively blur pixels; decrease effect near edges",
3359 "-adaptive-resize geometry",
3360 " adaptively resize image using 'mesh' interpolation",
3361 "-adaptive-sharpen geometry",
3362 " adaptively sharpen pixels; increase effect near edges",
3363 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3364 " transparent, extract, background, or shape",
3365 "-annotate geometry text",
3366 " annotate the image with text",
3367 "-auto-gamma automagically adjust gamma level of image",
3368 "-auto-level automagically adjust color levels of image",
3369 "-auto-orient automagically orient (rotate) image",
3370 "-bench iterations measure performance",
3371 "-black-threshold value",
3372 " force all pixels below the threshold into black",
3373 "-blue-shift simulate a scene at nighttime in the moonlight",
3374 "-blur geometry reduce image noise and reduce detail levels",
3375 "-border geometry surround image with a border of color",
3376 "-bordercolor color border color",
3377 "-brightness-contrast geometry",
3378 " improve brightness / contrast of the image",
3379 "-canny geometry detect edges in the image",
3380 "-cdl filename color correct with a color decision list",
3381 "-channel mask set the image channel mask",
3382 "-charcoal geometry simulate a charcoal drawing",
3383 "-chop geometry remove pixels from the image interior",
3384 "-clamp keep pixel values in range (0-QuantumRange)",
3385 "-clip clip along the first path from the 8BIM profile",
3386 "-clip-mask filename associate a clip mask with the image",
3387 "-clip-path id clip along a named path from the 8BIM profile",
3388 "-colorize value colorize the image with the fill color",
3389 "-color-matrix matrix apply color correction to the image",
3390 "-connected-components connectivity",
3391 " connected-components uniquely labeled",
3392 "-contrast enhance or reduce the image contrast",
3393 "-contrast-stretch geometry",
3394 " improve contrast by 'stretching' the intensity range",
3395 "-convolve coefficients",
3396 " apply a convolution kernel to the image",
3397 "-cycle amount cycle the image colormap",
3398 "-decipher filename convert cipher pixels to plain pixels",
3399 "-deskew threshold straighten an image",
3400 "-despeckle reduce the speckles within an image",
3401 "-distort method args",
3402 " distort images according to given method ad args",
3403 "-draw string annotate the image with a graphic primitive",
3404 "-edge radius apply a filter to detect edges in the image",
3405 "-encipher filename convert plain pixels to cipher pixels",
3406 "-emboss radius emboss an image",
3407 "-enhance apply a digital filter to enhance a noisy image",
3408 "-equalize perform histogram equalization to an image",
3409 "-evaluate operator value",
3410 " evaluate an arithmetic, relational, or logical expression",
3411 "-extent geometry set the image size",
3412 "-extract geometry extract area from image",
3413 "-fft implements the discrete Fourier transform (DFT)",
3414 "-flip flip image vertically",
3415 "-floodfill geometry color",
3416 " floodfill the image with color",
3417 "-flop flop image horizontally",
3418 "-frame geometry surround image with an ornamental border",
3419 "-function name parameters",
3420 " apply function over image values",
3421 "-gamma value level of gamma correction",
3422 "-gaussian-blur geometry",
3423 " reduce image noise and reduce detail levels",
3424 "-geometry geometry preferred size or location of the image",
3425 "-grayscale method convert image to grayscale",
3426 "-hough-lines geometry",
3427 " identify lines in the image",
3428 "-identify identify the format and characteristics of the image",
3429 "-ift implements the inverse discrete Fourier transform (DFT)",
3430 "-implode amount implode image pixels about the center",
3431 "-interpolative-resize geometry",
3432 " resize image using interpolation",
3433 "-kuwahara geometry edge preserving noise reduction filter",
3434 "-lat geometry local adaptive thresholding",
3435 "-level value adjust the level of image contrast",
3436 "-level-colors color,color",
3437 " level image with the given colors",
3438 "-linear-stretch geometry",
3439 " improve contrast by 'stretching with saturation'",
3440 "-liquid-rescale geometry",
3441 " rescale image with seam-carving",
3442 "-magnify double the size of the image with pixel art scaling",
3443 "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3444 "-median geometry apply a median filter to the image",
3445 "-mode geometry make each pixel the 'predominant color' of the",
3447 "-modulate value vary the brightness, saturation, and hue",
3448 "-monochrome transform image to black and white",
3449 "-morphology method kernel",
3450 " apply a morphology method to the image",
3451 "-motion-blur geometry",
3452 " simulate motion blur",
3453 "-negate replace every pixel with its complementary color ",
3454 "-noise geometry add or reduce noise in an image",
3455 "-normalize transform image to span the full range of colors",
3456 "-opaque color change this color to the fill color",
3457 "-ordered-dither NxN",
3458 " add a noise pattern to the image with specific",
3460 "-paint radius simulate an oil painting",
3461 "-perceptible epsilon",
3462 " pixel value less than |epsilon| become epsilon or",
3464 "-polaroid angle simulate a Polaroid picture",
3465 "-posterize levels reduce the image to a limited number of color levels",
3466 "-profile filename add, delete, or apply an image profile",
3467 "-quantize colorspace reduce colors in this colorspace",
3468 "-raise value lighten/darken image edges to create a 3-D effect",
3469 "-random-threshold low,high",
3470 " random threshold the image",
3471 "-region geometry apply options to a portion of the image",
3472 "-render render vector graphics",
3473 "-repage geometry size and location of an image canvas",
3474 "-resample geometry change the resolution of an image",
3475 "-resize geometry resize the image",
3476 "-roll geometry roll an image vertically or horizontally",
3477 "-rotate degrees apply Paeth rotation to the image",
3478 "-rotational-blur angle",
3479 " rotational blur the image",
3480 "-sample geometry scale image with pixel sampling",
3481 "-scale geometry scale the image",
3482 "-segment values segment an image",
3483 "-selective-blur geometry",
3484 " selectively blur pixels within a contrast threshold",
3485 "-sepia-tone threshold",
3486 " simulate a sepia-toned photo",
3487 "-set property value set an image property",
3488 "-shade degrees shade the image using a distant light source",
3489 "-shadow geometry simulate an image shadow",
3490 "-sharpen geometry sharpen the image",
3491 "-shave geometry shave pixels from the image edges",
3492 "-shear geometry slide one edge of the image along the X or Y axis",
3493 "-sigmoidal-contrast geometry",
3494 " increase the contrast without saturating highlights or",
3496 "-sketch geometry simulate a pencil sketch",
3497 "-solarize threshold negate all pixels above the threshold level",
3498 "-sparse-color method args",
3499 " fill in a image based on a few color points",
3500 "-splice geometry splice the background color into the image",
3501 "-spread radius displace image pixels by a random amount",
3502 "-statistic type radius",
3503 " replace each pixel with corresponding statistic from the neighborhood",
3504 "-strip strip image of all profiles and comments",
3505 "-swirl degrees swirl image pixels about the center",
3506 "-threshold value threshold the image",
3507 "-thumbnail geometry create a thumbnail of the image",
3508 "-tile filename tile image when filling a graphic primitive",
3509 "-tint value tint the image with the fill color",
3510 "-transform affine transform image",
3511 "-transparent color make this color transparent within the image",
3512 "-transpose flip image vertically and rotate 90 degrees",
3513 "-transverse flop image horizontally and rotate 270 degrees",
3514 "-trim trim image edges",
3515 "-type type image type",
3516 "-unique-colors discard all but one of any pixel color",
3517 "-unsharp geometry sharpen the image",
3518 "-vignette geometry soften the edges of the image in vignette style",
3519 "-wave geometry alter an image along a sine wave",
3520 "-white-threshold value",
3521 " force all pixels above the threshold into white",
3524 *sequence_operators[]=
3526 "-affinity filename transform image colors to match this set of colors",
3527 "-append append an image sequence",
3528 "-clut apply a color lookup table to the image",
3529 "-coalesce merge a sequence of images",
3530 "-combine combine a sequence of images",
3531 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3532 "-complex operator perform complex mathematics on an image sequence",
3533 "-composite composite image",
3534 "-crop geometry cut out a rectangular region of the image",
3535 "-deconstruct break down an image sequence into constituent parts",
3536 "-evaluate-sequence operator",
3537 " evaluate an arithmetic, relational, or logical expression",
3538 "-flatten flatten a sequence of images",
3539 "-fx expression apply mathematical expression to an image channel(s)",
3540 "-hald-clut apply a Hald color lookup table to the image",
3541 "-layers method optimize, merge, or compare image layers",
3542 "-morph value morph an image sequence",
3543 "-mosaic create a mosaic from an image sequence",
3544 "-poly terms build a polynomial from the image sequence and the corresponding",
3545 " terms (coefficients and degree pairs).",
3546 "-print string interpret string and print to console",
3547 "-process arguments process the image with a custom image filter",
3548 "-smush geometry smush an image sequence together",
3549 "-write filename write images to this file",
3554 "-adjoin join images into a single multi-image file",
3555 "-affine matrix affine transform matrix",
3556 "-alpha option activate, deactivate, reset, or set the alpha channel",
3557 "-antialias remove pixel-aliasing",
3558 "-authenticate password",
3559 " decipher image with this password",
3560 "-attenuate value lessen (or intensify) when adding noise to an image",
3561 "-background color background color",
3562 "-bias value add bias when convolving an image",
3563 "-black-point-compensation",
3564 " use black point compensation",
3565 "-blue-primary point chromaticity blue primary point",
3566 "-bordercolor color border color",
3567 "-caption string assign a caption to an image",
3568 "-colors value preferred number of colors in the image",
3569 "-colorspace type alternate image colorspace",
3570 "-comment string annotate image with comment",
3571 "-compose operator set image composite operator",
3572 "-compress type type of pixel compression when writing the image",
3573 "-define format:option=value",
3574 " define one or more image format options",
3575 "-delay value display the next image after pausing",
3576 "-density geometry horizontal and vertical density of the image",
3577 "-depth value image depth",
3578 "-direction type render text right-to-left or left-to-right",
3579 "-display server get image or font from this X server",
3580 "-dispose method layer disposal method",
3581 "-dither method apply error diffusion to image",
3582 "-encoding type text encoding type",
3583 "-endian type endianness (MSB or LSB) of the image",
3584 "-family name render text with this font family",
3585 "-features distance analyze image features (e.g. contrast, correlation)",
3586 "-fill color color to use when filling a graphic primitive",
3587 "-filter type use this filter when resizing an image",
3588 "-font name render text with this font",
3589 "-format \"string\" output formatted image characteristics",
3590 "-fuzz distance colors within this distance are considered equal",
3591 "-gravity type horizontal and vertical text placement",
3592 "-green-primary point chromaticity green primary point",
3593 "-intensity method method to generate an intensity value from a pixel",
3594 "-intent type type of rendering intent when managing the image color",
3595 "-interlace type type of image interlacing scheme",
3596 "-interline-spacing value",
3597 " set the space between two text lines",
3598 "-interpolate method pixel color interpolation method",
3599 "-interword-spacing value",
3600 " set the space between two words",
3601 "-kerning value set the space between two letters",
3602 "-label string assign a label to an image",
3603 "-limit type value pixel cache resource limit",
3604 "-loop iterations add Netscape loop extension to your GIF animation",
3605 "-mask filename associate a mask with the image",
3606 "-matte store matte channel if the image has one",
3607 "-mattecolor color frame color",
3608 "-monitor monitor progress",
3609 "-orient type image orientation",
3610 "-page geometry size and location of an image canvas (setting)",
3611 "-path path write images to this path on disk",
3612 "-ping efficiently determine image attributes",
3613 "-pointsize value font point size",
3614 "-precision value maximum number of significant digits to print",
3615 "-preview type image preview type",
3616 "-quality value JPEG/MIFF/PNG compression level",
3617 "-quiet suppress all warning messages",
3618 "-red-primary point chromaticity red primary point",
3619 "-regard-warnings pay attention to warning messages",
3620 "-remap filename transform image colors to match this set of colors",
3621 "-respect-parentheses settings remain in effect until parenthesis boundary",
3622 "-sampling-factor geometry",
3623 " horizontal and vertical sampling factor",
3624 "-scene value image scene number",
3625 "-seed value seed a new sequence of pseudo-random numbers",
3626 "-size geometry width and height of image",
3627 "-stretch type render text with this font stretch",
3628 "-stroke color graphic primitive stroke color",
3629 "-strokewidth value graphic primitive stroke width",
3630 "-style type render text with this font style",
3631 "-synchronize synchronize image to storage device",
3632 "-taint declare the image as modified",
3633 "-texture filename name of texture to tile onto the image background",
3634 "-tile-offset geometry",
3636 "-treedepth value color tree depth",
3637 "-transparent-color color",
3638 " transparent color",
3639 "-undercolor color annotation bounding box color",
3640 "-units type the units of image resolution",
3641 "-verbose print detailed information about the image",
3642 "-view FlashPix viewing transforms",
3643 "-virtual-pixel method",
3644 " virtual pixel access method",
3645 "-weight type render text with this font weight",
3646 "-white-point point chromaticity white point",
3651 "-delete indexes delete the image from the image sequence",
3652 "-duplicate count,indexes",
3653 " duplicate an image one or more times",
3654 "-insert index insert last image into the image sequence",
3655 "-reverse reverse image sequence",
3656 "-swap indexes swap two images in the image sequence",
3663 ListMagickVersion(stdout);
3664 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3666 (void) printf("\nImage Settings:\n");
3667 for (p=settings; *p != (char *) NULL; p++)
3668 (void) printf(" %s\n",*p);
3669 (void) printf("\nImage Operators:\n");
3670 for (p=operators; *p != (char *) NULL; p++)
3671 (void) printf(" %s\n",*p);
3672 (void) printf("\nImage Channel Operators:\n");
3673 for (p=channel_operators; *p != (char *) NULL; p++)
3674 (void) printf(" %s\n",*p);
3675 (void) printf("\nImage Sequence Operators:\n");
3676 for (p=sequence_operators; *p != (char *) NULL; p++)
3677 (void) printf(" %s\n",*p);
3678 (void) printf("\nImage Stack Operators:\n");
3679 for (p=stack_operators; *p != (char *) NULL; p++)
3680 (void) printf(" %s\n",*p);
3681 (void) printf("\nMiscellaneous Options:\n");
3682 for (p=miscellaneous; *p != (char *) NULL; p++)
3683 (void) printf(" %s\n",*p);
3685 "\nBy default, the image format of 'file' is determined by its magic\n");
3687 "number. To specify a particular image format, precede the filename\n");
3689 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3691 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3692 (void) printf("'-' for standard input or output.\n");
3693 return(MagickFalse);
3696 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3697 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3699 #define DestroyMogrify() \
3701 if (format != (char *) NULL) \
3702 format=DestroyString(format); \
3703 if (path != (char *) NULL) \
3704 path=DestroyString(path); \
3705 DestroyImageStack(); \
3706 for (i=0; i < (ssize_t) argc; i++) \
3707 argv[i]=DestroyString(argv[i]); \
3708 argv=(char **) RelinquishMagickMemory(argv); \
3710 #define ThrowMogrifyException(asperity,tag,option) \
3712 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3715 return(MagickFalse); \
3717 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3719 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3720 "InvalidArgument","'%s': %s",argument,option); \
3722 return(MagickFalse); \
3734 image_stack[MaxImageStackDepth+1];
3742 respect_parenthesis;
3757 assert(image_info != (ImageInfo *) NULL);
3758 assert(image_info->signature == MagickSignature);
3759 if (image_info->debug != MagickFalse)
3760 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3761 assert(exception != (ExceptionInfo *) NULL);
3765 if ((LocaleCompare("version",option+1) == 0) ||
3766 (LocaleCompare("-version",option+1) == 0))
3768 ListMagickVersion(stdout);
3769 return(MagickFalse);
3773 return(MogrifyUsage());
3774 format=(char *) NULL;
3776 global_colormap=MagickFalse;
3780 option=(char *) NULL;
3782 respect_parenthesis=MagickFalse;
3787 ReadCommandlLine(argc,&argv);
3788 status=ExpandFilenames(&argc,&argv);
3789 if (status == MagickFalse)
3790 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3791 GetExceptionMessage(errno));
3792 for (i=1; i < (ssize_t) argc; i++)
3795 if (LocaleCompare(option,"(") == 0)
3797 FireImageStack(MagickFalse,MagickTrue,pend);
3798 if (k == MaxImageStackDepth)
3799 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3804 if (LocaleCompare(option,")") == 0)
3806 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3808 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3812 if (IsCommandOption(option) == MagickFalse)
3815 backup_filename[MaxTextExtent],
3822 Option is a file name: begin by reading image from specified file.
3824 FireImageStack(MagickFalse,MagickFalse,pend);
3826 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3828 images=ReadImages(image_info,filename,exception);
3829 status&=(images != (Image *) NULL) &&
3830 (exception->severity < ErrorException);
3831 if (images == (Image *) NULL)
3833 if (format != (char *) NULL)
3834 (void) CopyMagickString(images->filename,images->magick_filename,
3836 if (path != (char *) NULL)
3838 GetPathComponent(option,TailPath,filename);
3839 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3840 path,*DirectorySeparator,filename);
3842 if (format != (char *) NULL)
3843 AppendImageFormat(format,images->filename);
3844 AppendImageStack(images);
3845 FinalizeImageSettings(image_info,image,MagickFalse);
3846 if (global_colormap != MagickFalse)
3851 quantize_info=AcquireQuantizeInfo(image_info);
3852 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3853 quantize_info=DestroyQuantizeInfo(quantize_info);
3855 *backup_filename='\0';
3856 if ((LocaleCompare(image->filename,"-") != 0) &&
3857 (IsPathWritable(image->filename) != MagickFalse))
3863 Rename image file as backup.
3865 (void) CopyMagickString(backup_filename,image->filename,
3867 for (i=0; i < 6; i++)
3869 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3870 if (IsPathAccessible(backup_filename) == MagickFalse)
3873 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3874 (rename_utf8(image->filename,backup_filename) != 0))
3875 *backup_filename='\0';
3878 Write transmogrified image to disk.
3880 image_info->synchronize=MagickTrue;
3881 status&=WriteImages(image_info,image,image->filename,exception);
3882 if ((status != MagickFalse) && (*backup_filename != '\0'))
3883 (void) remove_utf8(backup_filename);
3884 RemoveAllImageStack();
3887 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3888 switch (*(option+1))
3892 if (LocaleCompare("adaptive-blur",option+1) == 0)
3895 if (i == (ssize_t) argc)
3896 ThrowMogrifyException(OptionError,"MissingArgument",option);
3897 if (IsGeometry(argv[i]) == MagickFalse)
3898 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3901 if (LocaleCompare("adaptive-resize",option+1) == 0)
3904 if (i == (ssize_t) argc)
3905 ThrowMogrifyException(OptionError,"MissingArgument",option);
3906 if (IsGeometry(argv[i]) == MagickFalse)
3907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3910 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3913 if (i == (ssize_t) argc)
3914 ThrowMogrifyException(OptionError,"MissingArgument",option);
3915 if (IsGeometry(argv[i]) == MagickFalse)
3916 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3919 if (LocaleCompare("affine",option+1) == 0)
3924 if (i == (ssize_t) argc)
3925 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (LocaleCompare("alpha",option+1) == 0)
3936 if (i == (ssize_t) argc)
3937 ThrowMogrifyException(OptionError,"MissingArgument",option);
3938 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
3940 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
3944 if (LocaleCompare("annotate",option+1) == 0)
3949 if (i == (ssize_t) argc)
3950 ThrowMogrifyException(OptionError,"MissingArgument",option);
3951 if (IsGeometry(argv[i]) == MagickFalse)
3952 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 if (i == (ssize_t) argc)
3954 ThrowMogrifyException(OptionError,"MissingArgument",option);
3958 if (LocaleCompare("antialias",option+1) == 0)
3960 if (LocaleCompare("append",option+1) == 0)
3962 if (LocaleCompare("attenuate",option+1) == 0)
3967 if (i == (ssize_t) argc)
3968 ThrowMogrifyException(OptionError,"MissingArgument",option);
3969 if (IsGeometry(argv[i]) == MagickFalse)
3970 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3973 if (LocaleCompare("authenticate",option+1) == 0)
3978 if (i == (ssize_t) argc)
3979 ThrowMogrifyException(OptionError,"MissingArgument",option);
3982 if (LocaleCompare("auto-gamma",option+1) == 0)
3984 if (LocaleCompare("auto-level",option+1) == 0)
3986 if (LocaleCompare("auto-orient",option+1) == 0)
3988 if (LocaleCompare("average",option+1) == 0)
3990 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3994 if (LocaleCompare("background",option+1) == 0)
3999 if (i == (ssize_t) argc)
4000 ThrowMogrifyException(OptionError,"MissingArgument",option);
4003 if (LocaleCompare("bias",option+1) == 0)
4008 if (i == (ssize_t) argc)
4009 ThrowMogrifyException(OptionError,"MissingArgument",option);
4010 if (IsGeometry(argv[i]) == MagickFalse)
4011 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4014 if (LocaleCompare("black-point-compensation",option+1) == 0)
4016 if (LocaleCompare("black-threshold",option+1) == 0)
4021 if (i == (ssize_t) argc)
4022 ThrowMogrifyException(OptionError,"MissingArgument",option);
4023 if (IsGeometry(argv[i]) == MagickFalse)
4024 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4027 if (LocaleCompare("blue-primary",option+1) == 0)
4032 if (i == (ssize_t) argc)
4033 ThrowMogrifyException(OptionError,"MissingArgument",option);
4034 if (IsGeometry(argv[i]) == MagickFalse)
4035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4038 if (LocaleCompare("blue-shift",option+1) == 0)
4041 if (i == (ssize_t) argc)
4042 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (IsGeometry(argv[i]) == MagickFalse)
4044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4047 if (LocaleCompare("blur",option+1) == 0)
4050 if (i == (ssize_t) argc)
4051 ThrowMogrifyException(OptionError,"MissingArgument",option);
4052 if (IsGeometry(argv[i]) == MagickFalse)
4053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4056 if (LocaleCompare("border",option+1) == 0)
4061 if (i == (ssize_t) argc)
4062 ThrowMogrifyException(OptionError,"MissingArgument",option);
4063 if (IsGeometry(argv[i]) == MagickFalse)
4064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4067 if (LocaleCompare("bordercolor",option+1) == 0)
4072 if (i == (ssize_t) argc)
4073 ThrowMogrifyException(OptionError,"MissingArgument",option);
4076 if (LocaleCompare("box",option+1) == 0)
4081 if (i == (ssize_t) argc)
4082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4085 if (LocaleCompare("brightness-contrast",option+1) == 0)
4088 if (i == (ssize_t) argc)
4089 ThrowMogrifyException(OptionError,"MissingArgument",option);
4090 if (IsGeometry(argv[i]) == MagickFalse)
4091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4094 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4098 if (LocaleCompare("cache",option+1) == 0)
4103 if (i == (ssize_t) argc)
4104 ThrowMogrifyException(OptionError,"MissingArgument",option);
4105 if (IsGeometry(argv[i]) == MagickFalse)
4106 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4109 if (LocaleCompare("canny",option+1) == 0)
4114 if (i == (ssize_t) argc)
4115 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 if (IsGeometry(argv[i]) == MagickFalse)
4117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4120 if (LocaleCompare("caption",option+1) == 0)
4125 if (i == (ssize_t) argc)
4126 ThrowMogrifyException(OptionError,"MissingArgument",option);
4129 if (LocaleCompare("channel",option+1) == 0)
4137 if (i == (ssize_t) argc)
4138 ThrowMogrifyException(OptionError,"MissingArgument",option);
4139 channel=ParseChannelOption(argv[i]);
4141 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4145 if (LocaleCompare("channel-fx",option+1) == 0)
4153 if (i == (ssize_t) argc)
4154 ThrowMogrifyException(OptionError,"MissingArgument",option);
4155 channel=ParsePixelChannelOption(argv[i]);
4157 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4161 if (LocaleCompare("cdl",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (LocaleCompare("charcoal",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("chop",option+1) == 0)
4186 if (i == (ssize_t) argc)
4187 ThrowMogrifyException(OptionError,"MissingArgument",option);
4188 if (IsGeometry(argv[i]) == MagickFalse)
4189 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4192 if (LocaleCompare("clamp",option+1) == 0)
4194 if (LocaleCompare("clip",option+1) == 0)
4196 if (LocaleCompare("clip-mask",option+1) == 0)
4201 if (i == (ssize_t) argc)
4202 ThrowMogrifyException(OptionError,"MissingArgument",option);
4205 if (LocaleCompare("clut",option+1) == 0)
4207 if (LocaleCompare("coalesce",option+1) == 0)
4209 if (LocaleCompare("colorize",option+1) == 0)
4214 if (i == (ssize_t) argc)
4215 ThrowMogrifyException(OptionError,"MissingArgument",option);
4216 if (IsGeometry(argv[i]) == MagickFalse)
4217 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4220 if (LocaleCompare("color-matrix",option+1) == 0)
4228 if (i == (ssize_t) argc)
4229 ThrowMogrifyException(OptionError,"MissingArgument",option);
4230 kernel_info=AcquireKernelInfo(argv[i],exception);
4231 if (kernel_info == (KernelInfo *) NULL)
4232 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4233 kernel_info=DestroyKernelInfo(kernel_info);
4236 if (LocaleCompare("colors",option+1) == 0)
4241 if (i == (ssize_t) argc)
4242 ThrowMogrifyException(OptionError,"MissingArgument",option);
4243 if (IsGeometry(argv[i]) == MagickFalse)
4244 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4247 if (LocaleCompare("colorspace",option+1) == 0)
4255 if (i == (ssize_t) argc)
4256 ThrowMogrifyException(OptionError,"MissingArgument",option);
4257 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4260 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4264 if (LocaleCompare("combine",option+1) == 0)
4272 if (i == (ssize_t) argc)
4273 ThrowMogrifyException(OptionError,"MissingArgument",option);
4274 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4277 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4281 if (LocaleCompare("compare",option+1) == 0)
4283 if (LocaleCompare("comment",option+1) == 0)
4288 if (i == (ssize_t) argc)
4289 ThrowMogrifyException(OptionError,"MissingArgument",option);
4292 if (LocaleCompare("composite",option+1) == 0)
4294 if (LocaleCompare("compress",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4307 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4311 if (LocaleCompare("concurrent",option+1) == 0)
4313 if (LocaleCompare("connected-components",option+1) == 0)
4316 if (i == (ssize_t) argc)
4317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 if (IsGeometry(argv[i]) == MagickFalse)
4319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4322 if (LocaleCompare("contrast",option+1) == 0)
4324 if (LocaleCompare("contrast-stretch",option+1) == 0)
4327 if (i == (ssize_t) argc)
4328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4329 if (IsGeometry(argv[i]) == MagickFalse)
4330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4333 if (LocaleCompare("convolve",option+1) == 0)
4341 if (i == (ssize_t) argc)
4342 ThrowMogrifyException(OptionError,"MissingArgument",option);
4343 kernel_info=AcquireKernelInfo(argv[i],exception);
4344 if (kernel_info == (KernelInfo *) NULL)
4345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4346 kernel_info=DestroyKernelInfo(kernel_info);
4349 if (LocaleCompare("crop",option+1) == 0)
4354 if (i == (ssize_t) argc)
4355 ThrowMogrifyException(OptionError,"MissingArgument",option);
4356 if (IsGeometry(argv[i]) == MagickFalse)
4357 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4360 if (LocaleCompare("cycle",option+1) == 0)
4365 if (i == (ssize_t) argc)
4366 ThrowMogrifyException(OptionError,"MissingArgument",option);
4367 if (IsGeometry(argv[i]) == MagickFalse)
4368 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4371 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4375 if (LocaleCompare("decipher",option+1) == 0)
4380 if (i == (ssize_t) argc)
4381 ThrowMogrifyException(OptionError,"MissingArgument",option);
4384 if (LocaleCompare("deconstruct",option+1) == 0)
4386 if (LocaleCompare("debug",option+1) == 0)
4394 if (i == (ssize_t) argc)
4395 ThrowMogrifyException(OptionError,"MissingArgument",option);
4396 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4398 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4400 (void) SetLogEventMask(argv[i]);
4403 if (LocaleCompare("define",option+1) == 0)
4406 if (i == (ssize_t) argc)
4407 ThrowMogrifyException(OptionError,"MissingArgument",option);
4413 define=GetImageOption(image_info,argv[i]);
4414 if (define == (const char *) NULL)
4415 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4420 if (LocaleCompare("delay",option+1) == 0)
4425 if (i == (ssize_t) argc)
4426 ThrowMogrifyException(OptionError,"MissingArgument",option);
4427 if (IsGeometry(argv[i]) == MagickFalse)
4428 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4431 if (LocaleCompare("delete",option+1) == 0)
4436 if (i == (ssize_t) argc)
4437 ThrowMogrifyException(OptionError,"MissingArgument",option);
4438 if (IsGeometry(argv[i]) == MagickFalse)
4439 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4442 if (LocaleCompare("density",option+1) == 0)
4447 if (i == (ssize_t) argc)
4448 ThrowMogrifyException(OptionError,"MissingArgument",option);
4449 if (IsGeometry(argv[i]) == MagickFalse)
4450 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4453 if (LocaleCompare("depth",option+1) == 0)
4458 if (i == (ssize_t) argc)
4459 ThrowMogrifyException(OptionError,"MissingArgument",option);
4460 if (IsGeometry(argv[i]) == MagickFalse)
4461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4464 if (LocaleCompare("deskew",option+1) == 0)
4469 if (i == (ssize_t) argc)
4470 ThrowMogrifyException(OptionError,"MissingArgument",option);
4471 if (IsGeometry(argv[i]) == MagickFalse)
4472 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4475 if (LocaleCompare("despeckle",option+1) == 0)
4477 if (LocaleCompare("dft",option+1) == 0)
4479 if (LocaleCompare("direction",option+1) == 0)
4487 if (i == (ssize_t) argc)
4488 ThrowMogrifyException(OptionError,"MissingArgument",option);
4489 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4492 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4496 if (LocaleCompare("display",option+1) == 0)
4501 if (i == (ssize_t) argc)
4502 ThrowMogrifyException(OptionError,"MissingArgument",option);
4505 if (LocaleCompare("dispose",option+1) == 0)
4513 if (i == (ssize_t) argc)
4514 ThrowMogrifyException(OptionError,"MissingArgument",option);
4515 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4517 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4521 if (LocaleCompare("distort",option+1) == 0)
4527 if (i == (ssize_t) argc)
4528 ThrowMogrifyException(OptionError,"MissingArgument",option);
4529 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4531 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4534 if (i == (ssize_t) argc)
4535 ThrowMogrifyException(OptionError,"MissingArgument",option);
4538 if (LocaleCompare("dither",option+1) == 0)
4546 if (i == (ssize_t) argc)
4547 ThrowMogrifyException(OptionError,"MissingArgument",option);
4548 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4550 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4554 if (LocaleCompare("draw",option+1) == 0)
4559 if (i == (ssize_t) argc)
4560 ThrowMogrifyException(OptionError,"MissingArgument",option);
4563 if (LocaleCompare("duplicate",option+1) == 0)
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4570 if (IsGeometry(argv[i]) == MagickFalse)
4571 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4574 if (LocaleCompare("duration",option+1) == 0)
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (IsGeometry(argv[i]) == MagickFalse)
4582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4585 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4589 if (LocaleCompare("edge",option+1) == 0)
4594 if (i == (ssize_t) argc)
4595 ThrowMogrifyException(OptionError,"MissingArgument",option);
4596 if (IsGeometry(argv[i]) == MagickFalse)
4597 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4600 if (LocaleCompare("emboss",option+1) == 0)
4605 if (i == (ssize_t) argc)
4606 ThrowMogrifyException(OptionError,"MissingArgument",option);
4607 if (IsGeometry(argv[i]) == MagickFalse)
4608 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4611 if (LocaleCompare("encipher",option+1) == 0)
4616 if (i == (ssize_t) argc)
4617 ThrowMogrifyException(OptionError,"MissingArgument",option);
4620 if (LocaleCompare("encoding",option+1) == 0)
4625 if (i == (ssize_t) argc)
4626 ThrowMogrifyException(OptionError,"MissingArgument",option);
4629 if (LocaleCompare("endian",option+1) == 0)
4637 if (i == (ssize_t) argc)
4638 ThrowMogrifyException(OptionError,"MissingArgument",option);
4639 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4641 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4645 if (LocaleCompare("enhance",option+1) == 0)
4647 if (LocaleCompare("equalize",option+1) == 0)
4649 if (LocaleCompare("evaluate",option+1) == 0)
4657 if (i == (ssize_t) argc)
4658 ThrowMogrifyException(OptionError,"MissingArgument",option);
4659 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4661 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4664 if (i == (ssize_t) argc)
4665 ThrowMogrifyException(OptionError,"MissingArgument",option);
4666 if (IsGeometry(argv[i]) == MagickFalse)
4667 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4670 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4678 if (i == (ssize_t) argc)
4679 ThrowMogrifyException(OptionError,"MissingArgument",option);
4680 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4682 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4686 if (LocaleCompare("extent",option+1) == 0)
4691 if (i == (ssize_t) argc)
4692 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 if (IsGeometry(argv[i]) == MagickFalse)
4694 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4697 if (LocaleCompare("extract",option+1) == 0)
4702 if (i == (ssize_t) argc)
4703 ThrowMogrifyException(OptionError,"MissingArgument",option);
4704 if (IsGeometry(argv[i]) == MagickFalse)
4705 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4708 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4712 if (LocaleCompare("family",option+1) == 0)
4717 if (i == (ssize_t) argc)
4718 ThrowMogrifyException(OptionError,"MissingArgument",option);
4721 if (LocaleCompare("features",option+1) == 0)
4726 if (i == (ssize_t) argc)
4727 ThrowMogrifyException(OptionError,"MissingArgument",option);
4728 if (IsGeometry(argv[i]) == MagickFalse)
4729 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4732 if (LocaleCompare("fill",option+1) == 0)
4737 if (i == (ssize_t) argc)
4738 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 if (LocaleCompare("filter",option+1) == 0)
4749 if (i == (ssize_t) argc)
4750 ThrowMogrifyException(OptionError,"MissingArgument",option);
4751 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4753 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4757 if (LocaleCompare("flatten",option+1) == 0)
4759 if (LocaleCompare("flip",option+1) == 0)
4761 if (LocaleCompare("flop",option+1) == 0)
4763 if (LocaleCompare("floodfill",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,"MissingArgument",option);
4770 if (IsGeometry(argv[i]) == MagickFalse)
4771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4773 if (i == (ssize_t) argc)
4774 ThrowMogrifyException(OptionError,"MissingArgument",option);
4777 if (LocaleCompare("font",option+1) == 0)
4782 if (i == (ssize_t) argc)
4783 ThrowMogrifyException(OptionError,"MissingArgument",option);
4786 if (LocaleCompare("format",option+1) == 0)
4788 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4789 (void) CloneString(&format,(char *) NULL);
4793 if (i == (ssize_t) argc)
4794 ThrowMogrifyException(OptionError,"MissingArgument",option);
4795 (void) CloneString(&format,argv[i]);
4796 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4797 (void) ConcatenateMagickString(image_info->filename,":",
4799 (void) SetImageInfo(image_info,0,exception);
4800 if (*image_info->magick == '\0')
4801 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4805 if (LocaleCompare("frame",option+1) == 0)
4810 if (i == (ssize_t) argc)
4811 ThrowMogrifyException(OptionError,"MissingArgument",option);
4812 if (IsGeometry(argv[i]) == MagickFalse)
4813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816 if (LocaleCompare("function",option+1) == 0)
4824 if (i == (ssize_t) argc)
4825 ThrowMogrifyException(OptionError,"MissingArgument",option);
4826 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4828 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4830 if (i == (ssize_t) argc)
4831 ThrowMogrifyException(OptionError,"MissingArgument",option);
4834 if (LocaleCompare("fuzz",option+1) == 0)
4839 if (i == (ssize_t) argc)
4840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4845 if (LocaleCompare("fx",option+1) == 0)
4850 if (i == (ssize_t) argc)
4851 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4858 if (LocaleCompare("gamma",option+1) == 0)
4861 if (i == (ssize_t) argc)
4862 ThrowMogrifyException(OptionError,"MissingArgument",option);
4863 if (IsGeometry(argv[i]) == MagickFalse)
4864 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4867 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4868 (LocaleCompare("gaussian",option+1) == 0))
4871 if (i == (ssize_t) argc)
4872 ThrowMogrifyException(OptionError,"MissingArgument",option);
4873 if (IsGeometry(argv[i]) == MagickFalse)
4874 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4877 if (LocaleCompare("geometry",option+1) == 0)
4882 if (i == (ssize_t) argc)
4883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 if (IsGeometry(argv[i]) == MagickFalse)
4885 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4888 if (LocaleCompare("gravity",option+1) == 0)
4896 if (i == (ssize_t) argc)
4897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4898 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
4901 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4905 if (LocaleCompare("grayscale",option+1) == 0)
4913 if (i == (ssize_t) argc)
4914 ThrowMogrifyException(OptionError,"MissingArgument",option);
4915 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4918 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
4922 if (LocaleCompare("green-primary",option+1) == 0)
4927 if (i == (ssize_t) argc)
4928 ThrowMogrifyException(OptionError,"MissingArgument",option);
4929 if (IsGeometry(argv[i]) == MagickFalse)
4930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4933 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4937 if (LocaleCompare("hald-clut",option+1) == 0)
4939 if ((LocaleCompare("help",option+1) == 0) ||
4940 (LocaleCompare("-help",option+1) == 0))
4941 return(MogrifyUsage());
4942 if (LocaleCompare("hough-lines",option+1) == 0)
4947 if (i == (ssize_t) argc)
4948 ThrowMogrifyException(OptionError,"MissingArgument",option);
4949 if (IsGeometry(argv[i]) == MagickFalse)
4950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4953 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4957 if (LocaleCompare("identify",option+1) == 0)
4959 if (LocaleCompare("idft",option+1) == 0)
4961 if (LocaleCompare("implode",option+1) == 0)
4966 if (i == (ssize_t) argc)
4967 ThrowMogrifyException(OptionError,"MissingArgument",option);
4968 if (IsGeometry(argv[i]) == MagickFalse)
4969 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4972 if (LocaleCompare("intensity",option+1) == 0)
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4982 intensity=ParseCommandOption(MagickPixelIntensityOptions,
4983 MagickFalse,argv[i]);
4985 ThrowMogrifyException(OptionError,
4986 "UnrecognizedPixelIntensityMethod",argv[i]);
4989 if (LocaleCompare("intent",option+1) == 0)
4997 if (i == (ssize_t) argc)
4998 ThrowMogrifyException(OptionError,"MissingArgument",option);
4999 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5001 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5005 if (LocaleCompare("interlace",option+1) == 0)
5013 if (i == (ssize_t) argc)
5014 ThrowMogrifyException(OptionError,"MissingArgument",option);
5015 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5018 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5022 if (LocaleCompare("interline-spacing",option+1) == 0)
5027 if (i == (ssize_t) argc)
5028 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 if (IsGeometry(argv[i]) == MagickFalse)
5030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5033 if (LocaleCompare("interpolate",option+1) == 0)
5041 if (i == (ssize_t) argc)
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5043 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5045 if (interpolate < 0)
5046 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5050 if (LocaleCompare("interword-spacing",option+1) == 0)
5055 if (i == (ssize_t) argc)
5056 ThrowMogrifyException(OptionError,"MissingArgument",option);
5057 if (IsGeometry(argv[i]) == MagickFalse)
5058 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5061 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5065 if (LocaleCompare("kerning",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("kuwahara",option+1) == 0)
5079 if (i == (ssize_t) argc)
5080 ThrowMogrifyException(OptionError,"MissingArgument",option);
5081 if (IsGeometry(argv[i]) == MagickFalse)
5082 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5085 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5089 if (LocaleCompare("label",option+1) == 0)
5094 if (i == (ssize_t) argc)
5095 ThrowMogrifyException(OptionError,"MissingArgument",option);
5098 if (LocaleCompare("lat",option+1) == 0)
5103 if (i == (ssize_t) argc)
5104 ThrowMogrifyException(OptionError,"MissingArgument",option);
5105 if (IsGeometry(argv[i]) == MagickFalse)
5106 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5108 if (LocaleCompare("layers",option+1) == 0)
5116 if (i == (ssize_t) argc)
5117 ThrowMogrifyException(OptionError,"MissingArgument",option);
5118 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5120 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5124 if (LocaleCompare("level",option+1) == 0)
5127 if (i == (ssize_t) argc)
5128 ThrowMogrifyException(OptionError,"MissingArgument",option);
5129 if (IsGeometry(argv[i]) == MagickFalse)
5130 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5133 if (LocaleCompare("level-colors",option+1) == 0)
5136 if (i == (ssize_t) argc)
5137 ThrowMogrifyException(OptionError,"MissingArgument",option);
5140 if (LocaleCompare("limit",option+1) == 0)
5154 if (i == (ssize_t) argc)
5155 ThrowMogrifyException(OptionError,"MissingArgument",option);
5156 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5159 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5162 if (i == (ssize_t) argc)
5163 ThrowMogrifyException(OptionError,"MissingArgument",option);
5164 value=StringToDouble(argv[i],&p);
5166 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5170 if (LocaleCompare("liquid-rescale",option+1) == 0)
5173 if (i == (ssize_t) argc)
5174 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 if (IsGeometry(argv[i]) == MagickFalse)
5176 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5179 if (LocaleCompare("list",option+1) == 0)
5187 if (i == (ssize_t) argc)
5188 ThrowMogrifyException(OptionError,"MissingArgument",option);
5189 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5191 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5192 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5194 return(status == 0 ? MagickTrue : MagickFalse);
5196 if (LocaleCompare("log",option+1) == 0)
5201 if ((i == (ssize_t) argc) ||
5202 (strchr(argv[i],'%') == (char *) NULL))
5203 ThrowMogrifyException(OptionError,"MissingArgument",option);
5206 if (LocaleCompare("loop",option+1) == 0)
5211 if (i == (ssize_t) argc)
5212 ThrowMogrifyException(OptionError,"MissingArgument",option);
5213 if (IsGeometry(argv[i]) == MagickFalse)
5214 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5217 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5221 if (LocaleCompare("map",option+1) == 0)
5223 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5227 if (i == (ssize_t) argc)
5228 ThrowMogrifyException(OptionError,"MissingArgument",option);
5231 if (LocaleCompare("mask",option+1) == 0)
5236 if (i == (ssize_t) argc)
5237 ThrowMogrifyException(OptionError,"MissingArgument",option);
5240 if (LocaleCompare("matte",option+1) == 0)
5242 if (LocaleCompare("mattecolor",option+1) == 0)
5247 if (i == (ssize_t) argc)
5248 ThrowMogrifyException(OptionError,"MissingArgument",option);
5251 if (LocaleCompare("maximum",option+1) == 0)
5253 if (LocaleCompare("mean-shift",option+1) == 0)
5258 if (i == (ssize_t) argc)
5259 ThrowMogrifyException(OptionError,"MissingArgument",option);
5260 if (IsGeometry(argv[i]) == MagickFalse)
5261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5264 if (LocaleCompare("median",option+1) == 0)
5269 if (i == (ssize_t) argc)
5270 ThrowMogrifyException(OptionError,"MissingArgument",option);
5271 if (IsGeometry(argv[i]) == MagickFalse)
5272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5275 if (LocaleCompare("metric",option+1) == 0)
5283 if (i == (ssize_t) argc)
5284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5285 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5287 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5291 if (LocaleCompare("minimum",option+1) == 0)
5293 if (LocaleCompare("modulate",option+1) == 0)
5298 if (i == (ssize_t) argc)
5299 ThrowMogrifyException(OptionError,"MissingArgument",option);
5300 if (IsGeometry(argv[i]) == MagickFalse)
5301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5304 if (LocaleCompare("mode",option+1) == 0)
5309 if (i == (ssize_t) argc)
5310 ThrowMogrifyException(OptionError,"MissingArgument",option);
5311 if (IsGeometry(argv[i]) == MagickFalse)
5312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5315 if (LocaleCompare("monitor",option+1) == 0)
5317 if (LocaleCompare("monochrome",option+1) == 0)
5319 if (LocaleCompare("morph",option+1) == 0)
5324 if (i == (ssize_t) argc)
5325 ThrowMogrifyException(OptionError,"MissingArgument",option);
5326 if (IsGeometry(argv[i]) == MagickFalse)
5327 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5330 if (LocaleCompare("morphology",option+1) == 0)
5333 token[MaxTextExtent];
5342 if (i == (ssize_t) argc)
5343 ThrowMogrifyException(OptionError,"MissingArgument",option);
5344 GetMagickToken(argv[i],NULL,token);
5345 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5347 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5350 if (i == (ssize_t) argc)
5351 ThrowMogrifyException(OptionError,"MissingArgument",option);
5352 kernel_info=AcquireKernelInfo(argv[i],exception);
5353 if (kernel_info == (KernelInfo *) NULL)
5354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5355 kernel_info=DestroyKernelInfo(kernel_info);
5358 if (LocaleCompare("mosaic",option+1) == 0)
5360 if (LocaleCompare("motion-blur",option+1) == 0)
5365 if (i == (ssize_t) argc)
5366 ThrowMogrifyException(OptionError,"MissingArgument",option);
5367 if (IsGeometry(argv[i]) == MagickFalse)
5368 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5371 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5375 if (LocaleCompare("negate",option+1) == 0)
5377 if (LocaleCompare("noise",option+1) == 0)
5380 if (i == (ssize_t) argc)
5381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5387 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5389 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5397 if (LocaleCompare("noop",option+1) == 0)
5399 if (LocaleCompare("normalize",option+1) == 0)
5401 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5405 if (LocaleCompare("opaque",option+1) == 0)
5408 if (i == (ssize_t) argc)
5409 ThrowMogrifyException(OptionError,"MissingArgument",option);
5412 if (LocaleCompare("ordered-dither",option+1) == 0)
5417 if (i == (ssize_t) argc)
5418 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 if (LocaleCompare("orient",option+1) == 0)
5426 orientation=UndefinedOrientation;
5430 if (i == (ssize_t) argc)
5431 ThrowMogrifyException(OptionError,"MissingArgument",option);
5432 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5434 if (orientation < 0)
5435 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5439 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5443 if (LocaleCompare("page",option+1) == 0)
5448 if (i == (ssize_t) argc)
5449 ThrowMogrifyException(OptionError,"MissingArgument",option);
5452 if (LocaleCompare("paint",option+1) == 0)
5457 if (i == (ssize_t) argc)
5458 ThrowMogrifyException(OptionError,"MissingArgument",option);
5459 if (IsGeometry(argv[i]) == MagickFalse)
5460 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5463 if (LocaleCompare("path",option+1) == 0)
5465 (void) CloneString(&path,(char *) NULL);
5469 if (i == (ssize_t) argc)
5470 ThrowMogrifyException(OptionError,"MissingArgument",option);
5471 (void) CloneString(&path,argv[i]);
5474 if (LocaleCompare("perceptible",option+1) == 0)
5479 if (i == (ssize_t) argc)
5480 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (IsGeometry(argv[i]) == MagickFalse)
5482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5485 if (LocaleCompare("pointsize",option+1) == 0)
5490 if (i == (ssize_t) argc)
5491 ThrowMogrifyException(OptionError,"MissingArgument",option);
5492 if (IsGeometry(argv[i]) == MagickFalse)
5493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5496 if (LocaleCompare("polaroid",option+1) == 0)
5501 if (i == (ssize_t) argc)
5502 ThrowMogrifyException(OptionError,"MissingArgument",option);
5503 if (IsGeometry(argv[i]) == MagickFalse)
5504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5507 if (LocaleCompare("poly",option+1) == 0)
5512 if (i == (ssize_t) argc)
5513 ThrowMogrifyException(OptionError,"MissingArgument",option);
5514 if (IsGeometry(argv[i]) == MagickFalse)
5515 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5518 if (LocaleCompare("posterize",option+1) == 0)
5523 if (i == (ssize_t) argc)
5524 ThrowMogrifyException(OptionError,"MissingArgument",option);
5525 if (IsGeometry(argv[i]) == MagickFalse)
5526 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5529 if (LocaleCompare("precision",option+1) == 0)
5534 if (i == (ssize_t) argc)
5535 ThrowMogrifyException(OptionError,"MissingArgument",option);
5536 if (IsGeometry(argv[i]) == MagickFalse)
5537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5540 if (LocaleCompare("print",option+1) == 0)
5545 if (i == (ssize_t) argc)
5546 ThrowMogrifyException(OptionError,"MissingArgument",option);
5549 if (LocaleCompare("process",option+1) == 0)
5554 if (i == (ssize_t) argc)
5555 ThrowMogrifyException(OptionError,"MissingArgument",option);
5558 if (LocaleCompare("profile",option+1) == 0)
5561 if (i == (ssize_t) argc)
5562 ThrowMogrifyException(OptionError,"MissingArgument",option);
5565 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5569 if (LocaleCompare("quality",option+1) == 0)
5574 if (i == (ssize_t) argc)
5575 ThrowMogrifyException(OptionError,"MissingArgument",option);
5576 if (IsGeometry(argv[i]) == MagickFalse)
5577 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5580 if (LocaleCompare("quantize",option+1) == 0)
5588 if (i == (ssize_t) argc)
5589 ThrowMogrifyException(OptionError,"MissingArgument",option);
5590 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5593 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5597 if (LocaleCompare("quiet",option+1) == 0)
5599 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5603 if (LocaleCompare("rotational-blur",option+1) == 0)
5606 if (i == (ssize_t) argc)
5607 ThrowMogrifyException(OptionError,"MissingArgument",option);
5608 if (IsGeometry(argv[i]) == MagickFalse)
5609 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5612 if (LocaleCompare("raise",option+1) == 0)
5615 if (i == (ssize_t) argc)
5616 ThrowMogrifyException(OptionError,"MissingArgument",option);
5617 if (IsGeometry(argv[i]) == MagickFalse)
5618 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5621 if (LocaleCompare("random-threshold",option+1) == 0)
5626 if (i == (ssize_t) argc)
5627 ThrowMogrifyException(OptionError,"MissingArgument",option);
5628 if (IsGeometry(argv[i]) == MagickFalse)
5629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5632 if (LocaleCompare("red-primary",option+1) == 0)
5637 if (i == (ssize_t) argc)
5638 ThrowMogrifyException(OptionError,"MissingArgument",option);
5639 if (IsGeometry(argv[i]) == MagickFalse)
5640 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleCompare("regard-warnings",option+1) == 0)
5644 if (LocaleCompare("region",option+1) == 0)
5649 if (i == (ssize_t) argc)
5650 ThrowMogrifyException(OptionError,"MissingArgument",option);
5651 if (IsGeometry(argv[i]) == MagickFalse)
5652 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5655 if (LocaleCompare("remap",option+1) == 0)
5660 if (i == (ssize_t) argc)
5661 ThrowMogrifyException(OptionError,"MissingArgument",option);
5664 if (LocaleCompare("render",option+1) == 0)
5666 if (LocaleCompare("repage",option+1) == 0)
5671 if (i == (ssize_t) argc)
5672 ThrowMogrifyException(OptionError,"MissingArgument",option);
5673 if (IsGeometry(argv[i]) == MagickFalse)
5674 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5677 if (LocaleCompare("resample",option+1) == 0)
5682 if (i == (ssize_t) argc)
5683 ThrowMogrifyException(OptionError,"MissingArgument",option);
5684 if (IsGeometry(argv[i]) == MagickFalse)
5685 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5688 if (LocaleCompare("resize",option+1) == 0)
5693 if (i == (ssize_t) argc)
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 if (IsGeometry(argv[i]) == MagickFalse)
5696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5701 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5704 if (LocaleCompare("reverse",option+1) == 0)
5706 if (LocaleCompare("roll",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("rotate",option+1) == 0)
5720 if (i == (ssize_t) argc)
5721 ThrowMogrifyException(OptionError,"MissingArgument",option);
5722 if (IsGeometry(argv[i]) == MagickFalse)
5723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5726 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5730 if (LocaleCompare("sample",option+1) == 0)
5735 if (i == (ssize_t) argc)
5736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 if (IsGeometry(argv[i]) == MagickFalse)
5738 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5741 if (LocaleCompare("sampling-factor",option+1) == 0)
5746 if (i == (ssize_t) argc)
5747 ThrowMogrifyException(OptionError,"MissingArgument",option);
5748 if (IsGeometry(argv[i]) == MagickFalse)
5749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5752 if (LocaleCompare("scale",option+1) == 0)
5757 if (i == (ssize_t) argc)
5758 ThrowMogrifyException(OptionError,"MissingArgument",option);
5759 if (IsGeometry(argv[i]) == MagickFalse)
5760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5763 if (LocaleCompare("scene",option+1) == 0)
5768 if (i == (ssize_t) argc)
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5770 if (IsGeometry(argv[i]) == MagickFalse)
5771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5774 if (LocaleCompare("seed",option+1) == 0)
5779 if (i == (ssize_t) argc)
5780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5781 if (IsGeometry(argv[i]) == MagickFalse)
5782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5785 if (LocaleCompare("segment",option+1) == 0)
5790 if (i == (ssize_t) argc)
5791 ThrowMogrifyException(OptionError,"MissingArgument",option);
5792 if (IsGeometry(argv[i]) == MagickFalse)
5793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5796 if (LocaleCompare("selective-blur",option+1) == 0)
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5801 if (IsGeometry(argv[i]) == MagickFalse)
5802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5805 if (LocaleCompare("separate",option+1) == 0)
5807 if (LocaleCompare("sepia-tone",option+1) == 0)
5812 if (i == (ssize_t) argc)
5813 ThrowMogrifyException(OptionError,"MissingArgument",option);
5814 if (IsGeometry(argv[i]) == MagickFalse)
5815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5818 if (LocaleCompare("set",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5826 if (i == (ssize_t) argc)
5827 ThrowMogrifyException(OptionError,"MissingArgument",option);
5830 if (LocaleCompare("shade",option+1) == 0)
5833 if (i == (ssize_t) argc)
5834 ThrowMogrifyException(OptionError,"MissingArgument",option);
5835 if (IsGeometry(argv[i]) == MagickFalse)
5836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5839 if (LocaleCompare("shadow",option+1) == 0)
5844 if (i == (ssize_t) argc)
5845 ThrowMogrifyException(OptionError,"MissingArgument",option);
5846 if (IsGeometry(argv[i]) == MagickFalse)
5847 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5850 if (LocaleCompare("sharpen",option+1) == 0)
5853 if (i == (ssize_t) argc)
5854 ThrowMogrifyException(OptionError,"MissingArgument",option);
5855 if (IsGeometry(argv[i]) == MagickFalse)
5856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5859 if (LocaleCompare("shave",option+1) == 0)
5864 if (i == (ssize_t) argc)
5865 ThrowMogrifyException(OptionError,"MissingArgument",option);
5866 if (IsGeometry(argv[i]) == MagickFalse)
5867 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5870 if (LocaleCompare("shear",option+1) == 0)
5873 if (i == (ssize_t) argc)
5874 ThrowMogrifyException(OptionError,"MissingArgument",option);
5875 if (IsGeometry(argv[i]) == MagickFalse)
5876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5879 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5882 if (i == (ssize_t) argc)
5883 ThrowMogrifyException(OptionError,"MissingArgument",option);
5884 if (IsGeometry(argv[i]) == MagickFalse)
5885 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5888 if (LocaleCompare("size",option+1) == 0)
5893 if (i == (ssize_t) argc)
5894 ThrowMogrifyException(OptionError,"MissingArgument",option);
5895 if (IsGeometry(argv[i]) == MagickFalse)
5896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5899 if (LocaleCompare("sketch",option+1) == 0)
5904 if (i == (ssize_t) argc)
5905 ThrowMogrifyException(OptionError,"MissingArgument",option);
5906 if (IsGeometry(argv[i]) == MagickFalse)
5907 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5910 if (LocaleCompare("smush",option+1) == 0)
5913 if (i == (ssize_t) argc)
5914 ThrowMogrifyException(OptionError,"MissingArgument",option);
5915 if (IsGeometry(argv[i]) == MagickFalse)
5916 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5920 if (LocaleCompare("solarize",option+1) == 0)
5925 if (i == (ssize_t) argc)
5926 ThrowMogrifyException(OptionError,"MissingArgument",option);
5927 if (IsGeometry(argv[i]) == MagickFalse)
5928 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5931 if (LocaleCompare("sparse-color",option+1) == 0)
5937 if (i == (ssize_t) argc)
5938 ThrowMogrifyException(OptionError,"MissingArgument",option);
5939 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5941 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5944 if (i == (ssize_t) argc)
5945 ThrowMogrifyException(OptionError,"MissingArgument",option);
5948 if (LocaleCompare("splice",option+1) == 0)
5953 if (i == (ssize_t) argc)
5954 ThrowMogrifyException(OptionError,"MissingArgument",option);
5955 if (IsGeometry(argv[i]) == MagickFalse)
5956 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5959 if (LocaleCompare("spread",option+1) == 0)
5964 if (i == (ssize_t) argc)
5965 ThrowMogrifyException(OptionError,"MissingArgument",option);
5966 if (IsGeometry(argv[i]) == MagickFalse)
5967 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5970 if (LocaleCompare("statistic",option+1) == 0)
5978 if (i == (ssize_t) argc)
5979 ThrowMogrifyException(OptionError,"MissingArgument",option);
5980 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5982 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5985 if (i == (ssize_t) argc)
5986 ThrowMogrifyException(OptionError,"MissingArgument",option);
5987 if (IsGeometry(argv[i]) == MagickFalse)
5988 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5991 if (LocaleCompare("stretch",option+1) == 0)
5999 if (i == (ssize_t) argc)
6000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6001 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6003 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6007 if (LocaleCompare("strip",option+1) == 0)
6009 if (LocaleCompare("stroke",option+1) == 0)
6014 if (i == (ssize_t) argc)
6015 ThrowMogrifyException(OptionError,"MissingArgument",option);
6018 if (LocaleCompare("strokewidth",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6025 if (IsGeometry(argv[i]) == MagickFalse)
6026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6029 if (LocaleCompare("style",option+1) == 0)
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,"MissingArgument",option);
6039 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6041 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6045 if (LocaleCompare("swap",option+1) == 0)
6050 if (i == (ssize_t) argc)
6051 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6056 if (LocaleCompare("swirl",option+1) == 0)
6061 if (i == (ssize_t) argc)
6062 ThrowMogrifyException(OptionError,"MissingArgument",option);
6063 if (IsGeometry(argv[i]) == MagickFalse)
6064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6067 if (LocaleCompare("synchronize",option+1) == 0)
6069 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6073 if (LocaleCompare("taint",option+1) == 0)
6075 if (LocaleCompare("texture",option+1) == 0)
6080 if (i == (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,"MissingArgument",option);
6084 if (LocaleCompare("tile",option+1) == 0)
6089 if (i == (ssize_t) argc)
6090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6093 if (LocaleCompare("tile-offset",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6104 if (LocaleCompare("tint",option+1) == 0)
6109 if (i == (ssize_t) argc)
6110 ThrowMogrifyException(OptionError,"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6115 if (LocaleCompare("transform",option+1) == 0)
6117 if (LocaleCompare("transpose",option+1) == 0)
6119 if (LocaleCompare("transverse",option+1) == 0)
6121 if (LocaleCompare("threshold",option+1) == 0)
6126 if (i == (ssize_t) argc)
6127 ThrowMogrifyException(OptionError,"MissingArgument",option);
6128 if (IsGeometry(argv[i]) == MagickFalse)
6129 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6132 if (LocaleCompare("thumbnail",option+1) == 0)
6137 if (i == (ssize_t) argc)
6138 ThrowMogrifyException(OptionError,"MissingArgument",option);
6139 if (IsGeometry(argv[i]) == MagickFalse)
6140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6143 if (LocaleCompare("transparent",option+1) == 0)
6146 if (i == (ssize_t) argc)
6147 ThrowMogrifyException(OptionError,"MissingArgument",option);
6150 if (LocaleCompare("transparent-color",option+1) == 0)
6155 if (i == (ssize_t) argc)
6156 ThrowMogrifyException(OptionError,"MissingArgument",option);
6159 if (LocaleCompare("treedepth",option+1) == 0)
6164 if (i == (ssize_t) argc)
6165 ThrowMogrifyException(OptionError,"MissingArgument",option);
6166 if (IsGeometry(argv[i]) == MagickFalse)
6167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6170 if (LocaleCompare("trim",option+1) == 0)
6172 if (LocaleCompare("type",option+1) == 0)
6180 if (i == (ssize_t) argc)
6181 ThrowMogrifyException(OptionError,"MissingArgument",option);
6182 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6184 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6188 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6192 if (LocaleCompare("undercolor",option+1) == 0)
6197 if (i == (ssize_t) argc)
6198 ThrowMogrifyException(OptionError,"MissingArgument",option);
6201 if (LocaleCompare("unique-colors",option+1) == 0)
6203 if (LocaleCompare("units",option+1) == 0)
6211 if (i == (ssize_t) argc)
6212 ThrowMogrifyException(OptionError,"MissingArgument",option);
6213 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6216 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6220 if (LocaleCompare("unsharp",option+1) == 0)
6223 if (i == (ssize_t) argc)
6224 ThrowMogrifyException(OptionError,"MissingArgument",option);
6225 if (IsGeometry(argv[i]) == MagickFalse)
6226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6229 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6233 if (LocaleCompare("verbose",option+1) == 0)
6235 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6238 if ((LocaleCompare("version",option+1) == 0) ||
6239 (LocaleCompare("-version",option+1) == 0))
6241 ListMagickVersion(stdout);
6244 if (LocaleCompare("view",option+1) == 0)
6249 if (i == (ssize_t) argc)
6250 ThrowMogrifyException(OptionError,"MissingArgument",option);
6253 if (LocaleCompare("vignette",option+1) == 0)
6258 if (i == (ssize_t) argc)
6259 ThrowMogrifyException(OptionError,"MissingArgument",option);
6260 if (IsGeometry(argv[i]) == MagickFalse)
6261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6264 if (LocaleCompare("virtual-pixel",option+1) == 0)
6272 if (i == (ssize_t) argc)
6273 ThrowMogrifyException(OptionError,"MissingArgument",option);
6274 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6277 ThrowMogrifyException(OptionError,
6278 "UnrecognizedVirtualPixelMethod",argv[i]);
6281 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6285 if (LocaleCompare("wave",option+1) == 0)
6288 if (i == (ssize_t) argc)
6289 ThrowMogrifyException(OptionError,"MissingArgument",option);
6290 if (IsGeometry(argv[i]) == MagickFalse)
6291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6294 if (LocaleCompare("weight",option+1) == 0)
6299 if (i == (ssize_t) argc)
6300 ThrowMogrifyException(OptionError,"MissingArgument",option);
6303 if (LocaleCompare("white-point",option+1) == 0)
6308 if (i == (ssize_t) argc)
6309 ThrowMogrifyException(OptionError,"MissingArgument",option);
6310 if (IsGeometry(argv[i]) == MagickFalse)
6311 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6314 if (LocaleCompare("white-threshold",option+1) == 0)
6319 if (i == (ssize_t) argc)
6320 ThrowMogrifyException(OptionError,"MissingArgument",option);
6321 if (IsGeometry(argv[i]) == MagickFalse)
6322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6325 if (LocaleCompare("write",option+1) == 0)
6328 if (i == (ssize_t) argc)
6329 ThrowMogrifyException(OptionError,"MissingArgument",option);
6332 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6337 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6339 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6340 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6341 if (fire != MagickFalse)
6342 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6345 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6346 if (i != (ssize_t) argc)
6347 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6349 return(status != 0 ? MagickTrue : MagickFalse);
6353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6357 + M o g r i f y I m a g e I n f o %
6361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6363 % MogrifyImageInfo() applies image processing settings to the image as
6364 % prescribed by command line options.
6366 % The format of the MogrifyImageInfo method is:
6368 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6369 % const char **argv,ExceptionInfo *exception)
6371 % A description of each parameter follows:
6373 % o image_info: the image info..
6375 % o argc: Specifies a pointer to an integer describing the number of
6376 % elements in the argument vector.
6378 % o argv: Specifies a pointer to a text array containing the command line
6381 % o exception: return any errors or warnings in this structure.
6384 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6385 const int argc,const char **argv,ExceptionInfo *exception)
6400 Initialize method variables.
6402 assert(image_info != (ImageInfo *) NULL);
6403 assert(image_info->signature == MagickSignature);
6404 if (image_info->debug != MagickFalse)
6405 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6406 image_info->filename);
6410 Set the image settings.
6412 for (i=0; i < (ssize_t) argc; i++)
6415 if (IsCommandOption(option) == MagickFalse)
6417 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6418 count=MagickMax(count,0L);
6419 if ((i+count) >= (ssize_t) argc)
6421 switch (*(option+1))
6425 if (LocaleCompare("adjoin",option+1) == 0)
6427 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6430 if (LocaleCompare("antialias",option+1) == 0)
6432 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6435 if (LocaleCompare("authenticate",option+1) == 0)
6438 (void) DeleteImageOption(image_info,option+1);
6440 (void) SetImageOption(image_info,option+1,argv[i+1]);
6447 if (LocaleCompare("background",option+1) == 0)
6451 (void) DeleteImageOption(image_info,option+1);
6452 (void) QueryColorCompliance(MogrifyBackgroundColor,
6453 AllCompliance,&image_info->background_color,exception);
6456 (void) SetImageOption(image_info,option+1,argv[i+1]);
6457 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6458 &image_info->background_color,exception);
6461 if (LocaleCompare("bias",option+1) == 0)
6465 (void) SetImageOption(image_info,option+1,"0.0");
6468 (void) SetImageOption(image_info,option+1,argv[i+1]);
6471 if (LocaleCompare("black-point-compensation",option+1) == 0)
6475 (void) SetImageOption(image_info,option+1,"false");
6478 (void) SetImageOption(image_info,option+1,"true");
6481 if (LocaleCompare("blue-primary",option+1) == 0)
6485 (void) SetImageOption(image_info,option+1,"0.0");
6488 (void) SetImageOption(image_info,option+1,argv[i+1]);
6491 if (LocaleCompare("bordercolor",option+1) == 0)
6495 (void) DeleteImageOption(image_info,option+1);
6496 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6497 &image_info->border_color,exception);
6500 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6501 &image_info->border_color,exception);
6502 (void) SetImageOption(image_info,option+1,argv[i+1]);
6505 if (LocaleCompare("box",option+1) == 0)
6509 (void) SetImageOption(image_info,"undercolor","none");
6512 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6519 if (LocaleCompare("cache",option+1) == 0)
6524 limit=MagickResourceInfinity;
6525 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6526 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6528 (void) SetMagickResourceLimit(MemoryResource,limit);
6529 (void) SetMagickResourceLimit(MapResource,2*limit);
6532 if (LocaleCompare("caption",option+1) == 0)
6536 (void) DeleteImageOption(image_info,option+1);
6539 (void) SetImageOption(image_info,option+1,argv[i+1]);
6542 if (LocaleCompare("colorspace",option+1) == 0)
6546 image_info->colorspace=UndefinedColorspace;
6547 (void) SetImageOption(image_info,option+1,"undefined");
6550 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6551 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6552 (void) SetImageOption(image_info,option+1,argv[i+1]);
6555 if (LocaleCompare("comment",option+1) == 0)
6559 (void) DeleteImageOption(image_info,option+1);
6562 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 if (LocaleCompare("compose",option+1) == 0)
6569 (void) SetImageOption(image_info,option+1,"undefined");
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("compress",option+1) == 0)
6579 image_info->compression=UndefinedCompression;
6580 (void) SetImageOption(image_info,option+1,"undefined");
6583 image_info->compression=(CompressionType) ParseCommandOption(
6584 MagickCompressOptions,MagickFalse,argv[i+1]);
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6592 if (LocaleCompare("debug",option+1) == 0)
6595 (void) SetLogEventMask("none");
6597 (void) SetLogEventMask(argv[i+1]);
6598 image_info->debug=IsEventLogging();
6601 if (LocaleCompare("define",option+1) == 0)
6605 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6606 (void) DeleteImageRegistry(argv[i+1]+9);
6608 (void) DeleteImageOption(image_info,argv[i+1]);
6611 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6613 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6617 (void) DefineImageOption(image_info,argv[i+1]);
6620 if (LocaleCompare("delay",option+1) == 0)
6624 (void) SetImageOption(image_info,option+1,"0");
6627 (void) SetImageOption(image_info,option+1,argv[i+1]);
6630 if (LocaleCompare("density",option+1) == 0)
6637 if (image_info->density != (char *) NULL)
6638 image_info->density=DestroyString(image_info->density);
6639 (void) SetImageOption(image_info,option+1,"72");
6642 (void) CloneString(&image_info->density,argv[i+1]);
6643 (void) SetImageOption(image_info,option+1,argv[i+1]);
6646 if (LocaleCompare("depth",option+1) == 0)
6650 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6653 image_info->depth=StringToUnsignedLong(argv[i+1]);
6656 if (LocaleCompare("direction",option+1) == 0)
6660 (void) SetImageOption(image_info,option+1,"undefined");
6663 (void) SetImageOption(image_info,option+1,argv[i+1]);
6666 if (LocaleCompare("display",option+1) == 0)
6670 if (image_info->server_name != (char *) NULL)
6671 image_info->server_name=DestroyString(
6672 image_info->server_name);
6675 (void) CloneString(&image_info->server_name,argv[i+1]);
6678 if (LocaleCompare("dispose",option+1) == 0)
6682 (void) SetImageOption(image_info,option+1,"undefined");
6685 (void) SetImageOption(image_info,option+1,argv[i+1]);
6688 if (LocaleCompare("dither",option+1) == 0)
6692 image_info->dither=MagickFalse;
6693 (void) SetImageOption(image_info,option+1,"none");
6696 (void) SetImageOption(image_info,option+1,argv[i+1]);
6697 image_info->dither=MagickTrue;
6704 if (LocaleCompare("encoding",option+1) == 0)
6708 (void) SetImageOption(image_info,option+1,"undefined");
6711 (void) SetImageOption(image_info,option+1,argv[i+1]);
6714 if (LocaleCompare("endian",option+1) == 0)
6718 image_info->endian=UndefinedEndian;
6719 (void) SetImageOption(image_info,option+1,"undefined");
6722 image_info->endian=(EndianType) ParseCommandOption(
6723 MagickEndianOptions,MagickFalse,argv[i+1]);
6724 (void) SetImageOption(image_info,option+1,argv[i+1]);
6727 if (LocaleCompare("extract",option+1) == 0)
6730 Set image extract geometry.
6734 if (image_info->extract != (char *) NULL)
6735 image_info->extract=DestroyString(image_info->extract);
6738 (void) CloneString(&image_info->extract,argv[i+1]);
6745 if (LocaleCompare("fill",option+1) == 0)
6749 (void) SetImageOption(image_info,option+1,"none");
6752 (void) SetImageOption(image_info,option+1,argv[i+1]);
6755 if (LocaleCompare("filter",option+1) == 0)
6759 (void) SetImageOption(image_info,option+1,"undefined");
6762 (void) SetImageOption(image_info,option+1,argv[i+1]);
6765 if (LocaleCompare("font",option+1) == 0)
6769 if (image_info->font != (char *) NULL)
6770 image_info->font=DestroyString(image_info->font);
6773 (void) CloneString(&image_info->font,argv[i+1]);
6776 if (LocaleCompare("format",option+1) == 0)
6781 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6782 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6783 image_info->ping=MagickFalse;
6784 (void) SetImageOption(image_info,option+1,argv[i+1]);
6787 if (LocaleCompare("fuzz",option+1) == 0)
6791 image_info->fuzz=0.0;
6792 (void) SetImageOption(image_info,option+1,"0");
6795 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6797 (void) SetImageOption(image_info,option+1,argv[i+1]);
6804 if (LocaleCompare("gravity",option+1) == 0)
6808 (void) SetImageOption(image_info,option+1,"undefined");
6811 (void) SetImageOption(image_info,option+1,argv[i+1]);
6814 if (LocaleCompare("green-primary",option+1) == 0)
6818 (void) SetImageOption(image_info,option+1,"0.0");
6821 (void) SetImageOption(image_info,option+1,argv[i+1]);
6828 if (LocaleCompare("intensity",option+1) == 0)
6832 (void) SetImageOption(image_info,option+1,"undefined");
6835 (void) SetImageOption(image_info,option+1,argv[i+1]);
6838 if (LocaleCompare("intent",option+1) == 0)
6842 (void) SetImageOption(image_info,option+1,"undefined");
6845 (void) SetImageOption(image_info,option+1,argv[i+1]);
6848 if (LocaleCompare("interlace",option+1) == 0)
6852 image_info->interlace=UndefinedInterlace;
6853 (void) SetImageOption(image_info,option+1,"undefined");
6856 image_info->interlace=(InterlaceType) ParseCommandOption(
6857 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6858 (void) SetImageOption(image_info,option+1,argv[i+1]);
6861 if (LocaleCompare("interline-spacing",option+1) == 0)
6865 (void) SetImageOption(image_info,option+1,"undefined");
6868 (void) SetImageOption(image_info,option+1,argv[i+1]);
6871 if (LocaleCompare("interpolate",option+1) == 0)
6875 (void) SetImageOption(image_info,option+1,"undefined");
6878 (void) SetImageOption(image_info,option+1,argv[i+1]);
6881 if (LocaleCompare("interword-spacing",option+1) == 0)
6885 (void) SetImageOption(image_info,option+1,"undefined");
6888 (void) SetImageOption(image_info,option+1,argv[i+1]);
6895 if (LocaleCompare("kerning",option+1) == 0)
6899 (void) SetImageOption(image_info,option+1,"undefined");
6902 (void) SetImageOption(image_info,option+1,argv[i+1]);
6909 if (LocaleCompare("label",option+1) == 0)
6913 (void) DeleteImageOption(image_info,option+1);
6916 (void) SetImageOption(image_info,option+1,argv[i+1]);
6919 if (LocaleCompare("limit",option+1) == 0)
6929 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6930 MagickFalse,argv[i+1]);
6931 limit=MagickResourceInfinity;
6932 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6933 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6934 (void) SetMagickResourceLimit(type,limit);
6937 if (LocaleCompare("list",option+1) == 0)
6943 Display configuration list.
6945 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6948 case MagickCoderOptions:
6950 (void) ListCoderInfo((FILE *) NULL,exception);
6953 case MagickColorOptions:
6955 (void) ListColorInfo((FILE *) NULL,exception);
6958 case MagickConfigureOptions:
6960 (void) ListConfigureInfo((FILE *) NULL,exception);
6963 case MagickDelegateOptions:
6965 (void) ListDelegateInfo((FILE *) NULL,exception);
6968 case MagickFontOptions:
6970 (void) ListTypeInfo((FILE *) NULL,exception);
6973 case MagickFormatOptions:
6975 (void) ListMagickInfo((FILE *) NULL,exception);
6978 case MagickLocaleOptions:
6980 (void) ListLocaleInfo((FILE *) NULL,exception);
6983 case MagickLogOptions:
6985 (void) ListLogInfo((FILE *) NULL,exception);
6988 case MagickMagicOptions:
6990 (void) ListMagicInfo((FILE *) NULL,exception);
6993 case MagickMimeOptions:
6995 (void) ListMimeInfo((FILE *) NULL,exception);
6998 case MagickModuleOptions:
7000 (void) ListModuleInfo((FILE *) NULL,exception);
7003 case MagickPolicyOptions:
7005 (void) ListPolicyInfo((FILE *) NULL,exception);
7008 case MagickResourceOptions:
7010 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7013 case MagickThresholdOptions:
7015 (void) ListThresholdMaps((FILE *) NULL,exception);
7020 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7027 if (LocaleCompare("log",option+1) == 0)
7031 (void) SetLogFormat(argv[i+1]);
7034 if (LocaleCompare("loop",option+1) == 0)
7038 (void) SetImageOption(image_info,option+1,"0");
7041 (void) SetImageOption(image_info,option+1,argv[i+1]);
7048 if (LocaleCompare("matte",option+1) == 0)
7052 (void) SetImageOption(image_info,option+1,"false");
7055 (void) SetImageOption(image_info,option+1,"true");
7058 if (LocaleCompare("mattecolor",option+1) == 0)
7062 (void) SetImageOption(image_info,option+1,argv[i+1]);
7063 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
7064 &image_info->matte_color,exception);
7067 (void) SetImageOption(image_info,option+1,argv[i+1]);
7068 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7069 &image_info->matte_color,exception);
7072 if (LocaleCompare("metric",option+1) == 0)
7075 (void) DeleteImageOption(image_info,option+1);
7077 (void) SetImageOption(image_info,option+1,argv[i+1]);
7080 if (LocaleCompare("monitor",option+1) == 0)
7082 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7086 if (LocaleCompare("monochrome",option+1) == 0)
7088 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7095 if (LocaleCompare("orient",option+1) == 0)
7099 image_info->orientation=UndefinedOrientation;
7100 (void) SetImageOption(image_info,option+1,"undefined");
7103 image_info->orientation=(OrientationType) ParseCommandOption(
7104 MagickOrientationOptions,MagickFalse,argv[i+1]);
7105 (void) SetImageOption(image_info,option+1,argv[i+1]);
7111 if (LocaleCompare("page",option+1) == 0)
7115 page[MaxTextExtent];
7128 (void) DeleteImageOption(image_info,option+1);
7129 (void) CloneString(&image_info->page,(char *) NULL);
7132 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7133 image_option=GetImageOption(image_info,"page");
7134 if (image_option != (const char *) NULL)
7135 flags=ParseAbsoluteGeometry(image_option,&geometry);
7136 canonical_page=GetPageGeometry(argv[i+1]);
7137 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7138 canonical_page=DestroyString(canonical_page);
7139 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
7140 (unsigned long) geometry.width,(unsigned long) geometry.height);
7141 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7142 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7143 (unsigned long) geometry.width,(unsigned long) geometry.height,
7144 (long) geometry.x,(long) geometry.y);
7145 (void) SetImageOption(image_info,option+1,page);
7146 (void) CloneString(&image_info->page,page);
7149 if (LocaleCompare("ping",option+1) == 0)
7151 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7154 if (LocaleCompare("pointsize",option+1) == 0)
7157 geometry_info.rho=0.0;
7159 (void) ParseGeometry(argv[i+1],&geometry_info);
7160 image_info->pointsize=geometry_info.rho;
7163 if (LocaleCompare("precision",option+1) == 0)
7165 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7168 if (LocaleCompare("preview",option+1) == 0)
7175 image_info->preview_type=UndefinedPreview;
7178 image_info->preview_type=(PreviewType) ParseCommandOption(
7179 MagickPreviewOptions,MagickFalse,argv[i+1]);
7186 if (LocaleCompare("quality",option+1) == 0)
7189 Set image compression quality.
7193 image_info->quality=UndefinedCompressionQuality;
7194 (void) SetImageOption(image_info,option+1,"0");
7197 image_info->quality=StringToUnsignedLong(argv[i+1]);
7198 (void) SetImageOption(image_info,option+1,argv[i+1]);
7201 if (LocaleCompare("quiet",option+1) == 0)
7203 static WarningHandler
7204 warning_handler = (WarningHandler) NULL;
7209 Restore error or warning messages.
7211 warning_handler=SetWarningHandler(warning_handler);
7215 Suppress error or warning messages.
7217 warning_handler=SetWarningHandler((WarningHandler) NULL);
7224 if (LocaleCompare("red-primary",option+1) == 0)
7228 (void) SetImageOption(image_info,option+1,"0.0");
7231 (void) SetImageOption(image_info,option+1,argv[i+1]);
7238 if (LocaleCompare("sampling-factor",option+1) == 0)
7241 Set image sampling factor.
7245 if (image_info->sampling_factor != (char *) NULL)
7246 image_info->sampling_factor=DestroyString(
7247 image_info->sampling_factor);
7250 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7253 if (LocaleCompare("scene",option+1) == 0)
7260 image_info->scene=0;
7261 (void) SetImageOption(image_info,option+1,"0");
7264 image_info->scene=StringToUnsignedLong(argv[i+1]);
7265 (void) SetImageOption(image_info,option+1,argv[i+1]);
7268 if (LocaleCompare("seed",option+1) == 0)
7275 seed=(unsigned long) time((time_t *) NULL);
7276 SetRandomSecretKey(seed);
7279 seed=StringToUnsignedLong(argv[i+1]);
7280 SetRandomSecretKey(seed);
7283 if (LocaleCompare("size",option+1) == 0)
7287 if (image_info->size != (char *) NULL)
7288 image_info->size=DestroyString(image_info->size);
7291 (void) CloneString(&image_info->size,argv[i+1]);
7294 if (LocaleCompare("stroke",option+1) == 0)
7298 (void) SetImageOption(image_info,option+1,"none");
7301 (void) SetImageOption(image_info,option+1,argv[i+1]);
7304 if (LocaleCompare("strokewidth",option+1) == 0)
7308 (void) SetImageOption(image_info,option+1,"0");
7311 (void) SetImageOption(image_info,option+1,argv[i+1]);
7314 if (LocaleCompare("synchronize",option+1) == 0)
7318 image_info->synchronize=MagickFalse;
7321 image_info->synchronize=MagickTrue;
7328 if (LocaleCompare("taint",option+1) == 0)
7332 (void) SetImageOption(image_info,option+1,"false");
7335 (void) SetImageOption(image_info,option+1,"true");
7338 if (LocaleCompare("texture",option+1) == 0)
7342 if (image_info->texture != (char *) NULL)
7343 image_info->texture=DestroyString(image_info->texture);
7346 (void) CloneString(&image_info->texture,argv[i+1]);
7349 if (LocaleCompare("tile-offset",option+1) == 0)
7352 (void) SetImageOption(image_info,option+1,"0");
7354 (void) SetImageOption(image_info,option+1,argv[i+1]);
7357 if (LocaleCompare("transparent-color",option+1) == 0)
7361 (void) QueryColorCompliance("none",AllCompliance,
7362 &image_info->transparent_color,exception);
7363 (void) SetImageOption(image_info,option+1,"none");
7366 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7367 &image_info->transparent_color,exception);
7368 (void) SetImageOption(image_info,option+1,argv[i+1]);
7371 if (LocaleCompare("type",option+1) == 0)
7375 image_info->type=UndefinedType;
7376 (void) SetImageOption(image_info,option+1,"undefined");
7379 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7380 MagickFalse,argv[i+1]);
7381 (void) SetImageOption(image_info,option+1,argv[i+1]);
7388 if (LocaleCompare("undercolor",option+1) == 0)
7391 (void) DeleteImageOption(image_info,option+1);
7393 (void) SetImageOption(image_info,option+1,argv[i+1]);
7396 if (LocaleCompare("units",option+1) == 0)
7400 image_info->units=UndefinedResolution;
7401 (void) SetImageOption(image_info,option+1,"undefined");
7404 image_info->units=(ResolutionType) ParseCommandOption(
7405 MagickResolutionOptions,MagickFalse,argv[i+1]);
7406 (void) SetImageOption(image_info,option+1,argv[i+1]);
7413 if (LocaleCompare("verbose",option+1) == 0)
7417 image_info->verbose=MagickFalse;
7420 image_info->verbose=MagickTrue;
7421 image_info->ping=MagickFalse;
7424 if (LocaleCompare("view",option+1) == 0)
7428 if (image_info->view != (char *) NULL)
7429 image_info->view=DestroyString(image_info->view);
7432 (void) CloneString(&image_info->view,argv[i+1]);
7435 if (LocaleCompare("virtual-pixel",option+1) == 0)
7438 (void) SetImageOption(image_info,option+1,"undefined");
7440 (void) SetImageOption(image_info,option+1,argv[i+1]);
7447 if (LocaleCompare("white-point",option+1) == 0)
7450 (void) SetImageOption(image_info,option+1,"0.0");
7452 (void) SetImageOption(image_info,option+1,argv[i+1]);
7466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7470 + M o g r i f y I m a g e L i s t %
7474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7476 % MogrifyImageList() applies any command line options that might affect the
7477 % entire image list (e.g. -append, -coalesce, etc.).
7479 % The format of the MogrifyImage method is:
7481 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7482 % const char **argv,Image **images,ExceptionInfo *exception)
7484 % A description of each parameter follows:
7486 % o image_info: the image info..
7488 % o argc: Specifies a pointer to an integer describing the number of
7489 % elements in the argument vector.
7491 % o argv: Specifies a pointer to a text array containing the command line
7494 % o images: pointer to pointer of the first image in image list.
7496 % o exception: return any errors or warnings in this structure.
7499 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7500 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7511 PixelInterpolateMethod
7525 Apply options to the image list.
7527 assert(image_info != (ImageInfo *) NULL);
7528 assert(image_info->signature == MagickSignature);
7529 assert(images != (Image **) NULL);
7530 assert((*images)->previous == (Image *) NULL);
7531 assert((*images)->signature == MagickSignature);
7532 if ((*images)->debug != MagickFalse)
7533 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7534 (*images)->filename);
7535 if ((argc <= 0) || (*argv == (char *) NULL))
7537 interpolate_method=UndefinedInterpolatePixel;
7538 mogrify_info=CloneImageInfo(image_info);
7539 quantize_info=AcquireQuantizeInfo(mogrify_info);
7541 for (i=0; i < (ssize_t) argc; i++)
7543 if (*images == (Image *) NULL)
7546 if (IsCommandOption(option) == MagickFalse)
7548 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7549 count=MagickMax(count,0L);
7550 if ((i+count) >= (ssize_t) argc)
7552 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7553 switch (*(option+1))
7557 if (LocaleCompare("affinity",option+1) == 0)
7559 (void) SyncImagesSettings(mogrify_info,*images,exception);
7562 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7569 if (LocaleCompare("append",option+1) == 0)
7574 (void) SyncImagesSettings(mogrify_info,*images,exception);
7575 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7576 MagickFalse,exception);
7577 if (append_image == (Image *) NULL)
7582 *images=DestroyImageList(*images);
7583 *images=append_image;
7586 if (LocaleCompare("average",option+1) == 0)
7592 Average an image sequence (deprecated).
7594 (void) SyncImagesSettings(mogrify_info,*images,exception);
7595 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7597 if (average_image == (Image *) NULL)
7602 *images=DestroyImageList(*images);
7603 *images=average_image;
7610 if (LocaleCompare("channel-fx",option+1) == 0)
7615 (void) SyncImagesSettings(mogrify_info,*images,exception);
7616 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7617 if (channel_image == (Image *) NULL)
7622 *images=DestroyImageList(*images);
7623 *images=channel_image;
7626 if (LocaleCompare("clut",option+1) == 0)
7632 (void) SyncImagesSettings(mogrify_info,*images,exception);
7633 image=RemoveFirstImageFromList(images);
7634 clut_image=RemoveFirstImageFromList(images);
7635 if (clut_image == (Image *) NULL)
7640 (void) ClutImage(image,clut_image,interpolate_method,exception);
7641 clut_image=DestroyImage(clut_image);
7642 *images=DestroyImageList(*images);
7646 if (LocaleCompare("coalesce",option+1) == 0)
7651 (void) SyncImagesSettings(mogrify_info,*images,exception);
7652 coalesce_image=CoalesceImages(*images,exception);
7653 if (coalesce_image == (Image *) NULL)
7658 *images=DestroyImageList(*images);
7659 *images=coalesce_image;
7662 if (LocaleCompare("combine",option+1) == 0)
7670 (void) SyncImagesSettings(mogrify_info,*images,exception);
7671 colorspace=(ColorspaceType) ParseCommandOption(
7672 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7673 combine_image=CombineImages(*images,colorspace,exception);
7674 if (combine_image == (Image *) NULL)
7679 *images=DestroyImageList(*images);
7680 *images=combine_image;
7683 if (LocaleCompare("compare",option+1) == 0)
7700 Mathematically and visually annotate the difference between an
7701 image and its reconstruction.
7703 (void) SyncImagesSettings(mogrify_info,*images,exception);
7704 image=RemoveFirstImageFromList(images);
7705 reconstruct_image=RemoveFirstImageFromList(images);
7706 if (reconstruct_image == (Image *) NULL)
7711 metric=UndefinedErrorMetric;
7712 option=GetImageOption(image_info,"metric");
7713 if (option != (const char *) NULL)
7714 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7715 MagickFalse,option);
7716 difference_image=CompareImages(image,reconstruct_image,metric,
7717 &distortion,exception);
7718 if (difference_image == (Image *) NULL)
7720 if (*images != (Image *) NULL)
7721 *images=DestroyImage(*images);
7722 *images=difference_image;
7725 if (LocaleCompare("complex",option+1) == 0)
7733 (void) SyncImageSettings(mogrify_info,*images,exception);
7734 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7735 MagickFalse,argv[i+1]);
7736 complex_images=ComplexImages(*images,op,exception);
7737 if (complex_images == (Image *) NULL)
7742 *images=DestroyImageList(*images);
7743 *images=complex_images;
7746 if (LocaleCompare("composite",option+1) == 0)
7762 (void) SyncImagesSettings(mogrify_info,*images,exception);
7763 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7764 if (value == (const char *) NULL)
7765 clip_to_self=MagickTrue;
7767 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7768 "compose:clip-to-self")); /* if this is true */
7769 if (IsMagickFalse(clip_to_self)) /* or */
7770 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7771 mogrify_info,"compose:outside-overlay"))) ? MagickTrue :
7772 MagickFalse; /* this false */
7773 image=RemoveFirstImageFromList(images);
7774 composite_image=RemoveFirstImageFromList(images);
7775 if (composite_image == (Image *) NULL)
7780 (void) TransformImage(&composite_image,(char *) NULL,
7781 composite_image->geometry,exception);
7782 SetGeometry(composite_image,&geometry);
7783 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7784 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7786 mask_image=RemoveFirstImageFromList(images);
7787 if (mask_image != (Image *) NULL)
7789 if ((image->compose != DisplaceCompositeOp) &&
7790 (image->compose != DistortCompositeOp))
7791 status&=CompositeImage(composite_image,mask_image,
7792 IntensityCompositeOp,MagickTrue,0,0,exception);
7794 status&=CompositeImage(composite_image,mask_image,
7795 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7796 mask_image=DestroyImage(mask_image);
7798 (void) CompositeImage(image,composite_image,image->compose,
7799 clip_to_self,geometry.x,geometry.y,exception);
7800 composite_image=DestroyImage(composite_image);
7801 *images=DestroyImageList(*images);
7809 if (LocaleCompare("deconstruct",option+1) == 0)
7814 (void) SyncImagesSettings(mogrify_info,*images,exception);
7815 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7817 if (deconstruct_image == (Image *) NULL)
7822 *images=DestroyImageList(*images);
7823 *images=deconstruct_image;
7826 if (LocaleCompare("delete",option+1) == 0)
7829 DeleteImages(images,"-1",exception);
7831 DeleteImages(images,argv[i+1],exception);
7834 if (LocaleCompare("dither",option+1) == 0)
7838 quantize_info->dither_method=NoDitherMethod;
7841 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7842 MagickDitherOptions,MagickFalse,argv[i+1]);
7845 if (LocaleCompare("duplicate",option+1) == 0)
7851 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7860 number_duplicates=(size_t) StringToLong(argv[i+1]);
7861 p=strchr(argv[i+1],',');
7862 if (p == (const char *) NULL)
7863 duplicate_images=DuplicateImages(*images,number_duplicates,
7866 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7869 AppendImageToList(images, duplicate_images);
7870 (void) SyncImagesSettings(mogrify_info,*images,exception);
7877 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7882 MagickEvaluateOperator
7885 (void) SyncImageSettings(mogrify_info,*images,exception);
7886 op=(MagickEvaluateOperator) ParseCommandOption(
7887 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7888 evaluate_image=EvaluateImages(*images,op,exception);
7889 if (evaluate_image == (Image *) NULL)
7894 *images=DestroyImageList(*images);
7895 *images=evaluate_image;
7902 if (LocaleCompare("fft",option+1) == 0)
7908 Implements the discrete Fourier transform (DFT).
7910 (void) SyncImageSettings(mogrify_info,*images,exception);
7911 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7912 MagickTrue : MagickFalse,exception);
7913 if (fourier_image == (Image *) NULL)
7915 *images=DestroyImage(*images);
7916 *images=fourier_image;
7919 if (LocaleCompare("flatten",option+1) == 0)
7924 (void) SyncImagesSettings(mogrify_info,*images,exception);
7925 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7926 if (flatten_image == (Image *) NULL)
7928 *images=DestroyImageList(*images);
7929 *images=flatten_image;
7932 if (LocaleCompare("fx",option+1) == 0)
7937 (void) SyncImagesSettings(mogrify_info,*images,exception);
7938 fx_image=FxImage(*images,argv[i+1],exception);
7939 if (fx_image == (Image *) NULL)
7944 *images=DestroyImageList(*images);
7952 if (LocaleCompare("hald-clut",option+1) == 0)
7958 (void) SyncImagesSettings(mogrify_info,*images,exception);
7959 image=RemoveFirstImageFromList(images);
7960 hald_image=RemoveFirstImageFromList(images);
7961 if (hald_image == (Image *) NULL)
7966 (void) HaldClutImage(image,hald_image,exception);
7967 hald_image=DestroyImage(hald_image);
7968 if (*images != (Image *) NULL)
7969 *images=DestroyImageList(*images);
7977 if (LocaleCompare("ift",option+1) == 0)
7985 Implements the inverse fourier discrete Fourier transform (DFT).
7987 (void) SyncImagesSettings(mogrify_info,*images,exception);
7988 magnitude_image=RemoveFirstImageFromList(images);
7989 phase_image=RemoveFirstImageFromList(images);
7990 if (phase_image == (Image *) NULL)
7995 fourier_image=InverseFourierTransformImage(magnitude_image,
7996 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7997 if (fourier_image == (Image *) NULL)
7999 if (*images != (Image *) NULL)
8000 *images=DestroyImage(*images);
8001 *images=fourier_image;
8004 if (LocaleCompare("insert",option+1) == 0)
8012 index=(ssize_t) StringToLong(argv[i+1]);
8013 p=RemoveLastImageFromList(images);
8014 if (p == (Image *) NULL)
8016 (void) ThrowMagickException(exception,GetMagickModule(),
8017 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8023 PrependImageToList(images,q);
8025 if (index == (ssize_t) GetImageListLength(*images))
8026 AppendImageToList(images,q);
8029 q=GetImageFromList(*images,index-1);
8030 if (q == (Image *) NULL)
8032 (void) ThrowMagickException(exception,GetMagickModule(),
8033 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8037 InsertImageInList(&q,p);
8039 *images=GetFirstImageInList(q);
8042 if (LocaleCompare("interpolate",option+1) == 0)
8044 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8045 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8052 if (LocaleCompare("layers",option+1) == 0)
8060 (void) SyncImagesSettings(mogrify_info,*images,exception);
8061 layers=(Image *) NULL;
8062 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8063 MagickFalse,argv[i+1]);
8068 layers=CoalesceImages(*images,exception);
8071 case CompareAnyLayer:
8072 case CompareClearLayer:
8073 case CompareOverlayLayer:
8076 layers=CompareImagesLayers(*images,method,exception);
8082 case TrimBoundsLayer:
8084 layers=MergeImageLayers(*images,method,exception);
8089 layers=DisposeImages(*images,exception);
8092 case OptimizeImageLayer:
8094 layers=OptimizeImageLayers(*images,exception);
8097 case OptimizePlusLayer:
8099 layers=OptimizePlusImageLayers(*images,exception);
8102 case OptimizeTransLayer:
8104 OptimizeImageTransparency(*images,exception);
8107 case RemoveDupsLayer:
8109 RemoveDuplicateLayers(images,exception);
8112 case RemoveZeroLayer:
8114 RemoveZeroDelayLayers(images,exception);
8120 General Purpose, GIF Animation Optimizer.
8122 layers=CoalesceImages(*images,exception);
8123 if (layers == (Image *) NULL)
8128 *images=DestroyImageList(*images);
8130 layers=OptimizeImageLayers(*images,exception);
8131 if (layers == (Image *) NULL)
8136 *images=DestroyImageList(*images);
8138 layers=(Image *) NULL;
8139 OptimizeImageTransparency(*images,exception);
8140 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8144 case CompositeLayer:
8156 Split image sequence at the first 'NULL:' image.
8159 while (source != (Image *) NULL)
8161 source=GetNextImageInList(source);
8162 if ((source != (Image *) NULL) &&
8163 (LocaleCompare(source->magick,"NULL") == 0))
8166 if (source != (Image *) NULL)
8168 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8169 (GetNextImageInList(source) == (Image *) NULL))
8170 source=(Image *) NULL;
8174 Separate the two lists, junk the null: image.
8176 source=SplitImageList(source->previous);
8177 DeleteImageFromList(&source);
8180 if (source == (Image *) NULL)
8182 (void) ThrowMagickException(exception,GetMagickModule(),
8183 OptionError,"MissingNullSeparator","layers Composite");
8188 Adjust offset with gravity and virtual canvas.
8190 SetGeometry(*images,&geometry);
8191 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8192 geometry.width=source->page.width != 0 ?
8193 source->page.width : source->columns;
8194 geometry.height=source->page.height != 0 ?
8195 source->page.height : source->rows;
8196 GravityAdjustGeometry((*images)->page.width != 0 ?
8197 (*images)->page.width : (*images)->columns,
8198 (*images)->page.height != 0 ? (*images)->page.height :
8199 (*images)->rows,(*images)->gravity,&geometry);
8200 compose=OverCompositeOp;
8201 option=GetImageOption(mogrify_info,"compose");
8202 if (option != (const char *) NULL)
8203 compose=(CompositeOperator) ParseCommandOption(
8204 MagickComposeOptions,MagickFalse,option);
8205 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8207 source=DestroyImageList(source);
8211 if (layers == (Image *) NULL)
8213 *images=DestroyImageList(*images);
8221 if (LocaleCompare("map",option+1) == 0)
8223 (void) SyncImagesSettings(mogrify_info,*images,exception);
8226 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8233 if (LocaleCompare("maximum",option+1) == 0)
8239 Maximum image sequence (deprecated).
8241 (void) SyncImagesSettings(mogrify_info,*images,exception);
8242 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8243 if (maximum_image == (Image *) NULL)
8248 *images=DestroyImageList(*images);
8249 *images=maximum_image;
8252 if (LocaleCompare("minimum",option+1) == 0)
8258 Minimum image sequence (deprecated).
8260 (void) SyncImagesSettings(mogrify_info,*images,exception);
8261 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8262 if (minimum_image == (Image *) NULL)
8267 *images=DestroyImageList(*images);
8268 *images=minimum_image;
8271 if (LocaleCompare("morph",option+1) == 0)
8276 (void) SyncImagesSettings(mogrify_info,*images,exception);
8277 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8279 if (morph_image == (Image *) NULL)
8284 *images=DestroyImageList(*images);
8285 *images=morph_image;
8288 if (LocaleCompare("mosaic",option+1) == 0)
8293 (void) SyncImagesSettings(mogrify_info,*images,exception);
8294 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8295 if (mosaic_image == (Image *) NULL)
8300 *images=DestroyImageList(*images);
8301 *images=mosaic_image;
8308 if (LocaleCompare("poly",option+1) == 0)
8312 token[MaxTextExtent];
8332 (void) SyncImageSettings(mogrify_info,*images,exception);
8333 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8335 if (args == (char *) NULL)
8338 for (x=0; *p != '\0'; x++)
8340 GetMagickToken(p,&p,token);
8342 GetMagickToken(p,&p,token);
8344 number_arguments=(size_t) x;
8345 arguments=(double *) AcquireQuantumMemory(number_arguments,
8346 sizeof(*arguments));
8347 if (arguments == (double *) NULL)
8348 ThrowWandFatalException(ResourceLimitFatalError,
8349 "MemoryAllocationFailed",(*images)->filename);
8350 (void) ResetMagickMemory(arguments,0,number_arguments*
8351 sizeof(*arguments));
8353 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8355 GetMagickToken(p,&p,token);
8357 GetMagickToken(p,&p,token);
8358 arguments[x]=StringToDouble(token,(char **) NULL);
8360 args=DestroyString(args);
8361 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8362 arguments,exception);
8363 arguments=(double *) RelinquishMagickMemory(arguments);
8364 if (polynomial_image == (Image *) NULL)
8369 *images=DestroyImageList(*images);
8370 *images=polynomial_image;
8372 if (LocaleCompare("print",option+1) == 0)
8377 (void) SyncImagesSettings(mogrify_info,*images,exception);
8378 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8380 if (string == (char *) NULL)
8382 (void) FormatLocaleFile(stdout,"%s",string);
8383 string=DestroyString(string);
8385 if (LocaleCompare("process",option+1) == 0)
8394 (void) SyncImagesSettings(mogrify_info,*images,exception);
8395 arguments=StringToArgv(argv[i+1],&number_arguments);
8396 if (arguments == (char **) NULL)
8398 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8419 Support old style syntax, filter="-option arg".
8421 length=strlen(argv[i+1]);
8422 token=(char *) NULL;
8423 if (~length >= (MaxTextExtent-1))
8424 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8426 if (token == (char *) NULL)
8429 arguments=argv[i+1];
8430 token_info=AcquireTokenInfo();
8431 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8432 "\"",'\0',&breaker,&next,"e);
8433 token_info=DestroyTokenInfo(token_info);
8439 argv=(&(arguments[next]));
8440 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8443 token=DestroyString(token);
8446 (void) SubstituteString(&arguments[1],"-","");
8447 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8448 number_arguments-2,(const char **) arguments+2,exception);
8449 for (j=0; j < number_arguments; j++)
8450 arguments[j]=DestroyString(arguments[j]);
8451 arguments=(char **) RelinquishMagickMemory(arguments);
8458 if (LocaleCompare("reverse",option+1) == 0)
8460 ReverseImageList(images);
8467 if (LocaleCompare("smush",option+1) == 0)
8475 (void) SyncImagesSettings(mogrify_info,*images,exception);
8476 offset=(ssize_t) StringToLong(argv[i+1]);
8477 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8478 MagickFalse,offset,exception);
8479 if (smush_image == (Image *) NULL)
8484 *images=DestroyImageList(*images);
8485 *images=smush_image;
8488 if (LocaleCompare("swap",option+1) == 0)
8509 flags=ParseGeometry(argv[i+1],&geometry_info);
8510 index=(ssize_t) geometry_info.rho;
8511 if ((flags & SigmaValue) != 0)
8512 swap_index=(ssize_t) geometry_info.sigma;
8514 p=GetImageFromList(*images,index);
8515 q=GetImageFromList(*images,swap_index);
8516 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8518 (void) ThrowMagickException(exception,GetMagickModule(),
8519 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8525 swap=CloneImage(p,0,0,MagickTrue,exception);
8526 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8527 ReplaceImageInList(&q,swap);
8528 *images=GetFirstImageInList(q);
8535 if (LocaleCompare("write",option+1) == 0)
8546 (void) SyncImagesSettings(mogrify_info,*images,exception);
8547 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8548 (void) DeleteImageRegistry(key);
8549 write_images=(*images);
8551 write_images=CloneImageList(*images,exception);
8552 write_info=CloneImageInfo(mogrify_info);
8553 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8554 write_info=DestroyImageInfo(write_info);
8556 write_images=DestroyImageList(write_images);
8566 quantize_info=DestroyQuantizeInfo(quantize_info);
8567 mogrify_info=DestroyImageInfo(mogrify_info);
8568 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8569 return(status != 0 ? MagickTrue : MagickFalse);
8573 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8577 + M o g r i f y I m a g e s %
8581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8583 % MogrifyImages() applies image processing options to a sequence of images as
8584 % prescribed by command line options.
8586 % The format of the MogrifyImage method is:
8588 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8589 % const MagickBooleanType post,const int argc,const char **argv,
8590 % Image **images,Exceptioninfo *exception)
8592 % A description of each parameter follows:
8594 % o image_info: the image info..
8596 % o post: If true, post process image list operators otherwise pre-process.
8598 % o argc: Specifies a pointer to an integer describing the number of
8599 % elements in the argument vector.
8601 % o argv: Specifies a pointer to a text array containing the command line
8604 % o images: pointer to a pointer of the first image in image list.
8606 % o exception: return any errors or warnings in this structure.
8609 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8610 const MagickBooleanType post,const int argc,const char **argv,
8611 Image **images,ExceptionInfo *exception)
8613 #define MogrifyImageTag "Mogrify/Image"
8627 assert(image_info != (ImageInfo *) NULL);
8628 assert(image_info->signature == MagickSignature);
8629 if (images == (Image **) NULL)
8630 return(MogrifyImage(image_info,argc,argv,images,exception));
8631 assert((*images)->previous == (Image *) NULL);
8632 assert((*images)->signature == MagickSignature);
8633 if ((*images)->debug != MagickFalse)
8634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8635 (*images)->filename);
8636 if ((argc <= 0) || (*argv == (char *) NULL))
8638 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8642 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8646 Pre-process multi-image sequence operators
8648 if (post == MagickFalse)
8649 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8651 For each image, process simple single image operators
8654 n=GetImageListLength(*images);
8658 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8659 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8661 status&=MogrifyImage(image_info,argc,argv,images,exception);
8662 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8663 if (proceed == MagickFalse)
8665 if ( (*images)->next == (Image *) NULL )
8667 *images=(*images)->next;
8670 assert( *images != (Image *) NULL );
8672 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8673 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8676 Post-process, multi-image sequence operators
8678 *images=GetFirstImageInList(*images);
8679 if (post != MagickFalse)
8680 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8681 return(status != 0 ? MagickTrue : MagickFalse);