2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
13 % MagickWand Module Methods %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/magick-wand-private.h"
50 #include "MagickWand/mogrify-private.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/string-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/utility-private.h"
61 MogrifyBackgroundColor[] = "#ffffff", /* white */
62 MogrifyBorderColor[] = "#dfdfdf", /* gray */
63 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
68 #define UndefinedCompressionQuality 0UL
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % M a g i c k C o m m a n d G e n e s i s %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % MagickCommandGenesis() applies image processing options to an image as
82 % prescribed by command line options.
84 % It wiil look for special options like "-debug", "-bench", and
85 % "-distribute-cache" that needs to be applied even before the main
86 % processing begins, and may completely overrule normal command processing.
87 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
88 % and are typically ignored (as they have been handled) if seen later.
90 % The format of the MagickCommandGenesis method is:
92 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
93 % MagickCommand command,int argc,char **argv,char **metadata,
94 % ExceptionInfo *exception)
96 % A description of each parameter follows:
98 % o image_info: the image info.
100 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
101 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
102 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
103 % DisplayImageCommand, or AnimateImageCommand.
105 % o argc: Specifies a pointer to an integer describing the number of
106 % elements in the argument vector.
108 % o argv: Specifies a pointer to a text array containing the command line
111 % o metadata: any metadata is returned here.
113 % o exception: return any errors or warnings in this structure.
116 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
117 MagickCommand command,int argc,char **argv,char **metadata,
118 ExceptionInfo *exception)
142 (void) setlocale(LC_ALL,"");
143 (void) setlocale(LC_NUMERIC,"C");
144 concurrent=MagickFalse;
148 regard_warnings=MagickFalse;
149 for (i=1; i < (ssize_t) (argc-1); i++)
152 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
154 if (LocaleCompare("-bench",option) == 0)
155 iterations=StringToUnsignedLong(argv[++i]);
156 if (LocaleCompare("-concurrent",option) == 0)
157 concurrent=MagickTrue;
158 if (LocaleCompare("-debug",option) == 0)
159 (void) SetLogEventMask(argv[++i]);
160 if (LocaleCompare("-distribute-cache",option) == 0)
162 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
165 if (LocaleCompare("-duration",option) == 0)
166 duration=StringToDouble(argv[++i],(char **) NULL);
167 if (LocaleCompare("-regard-warnings",option) == 0)
168 regard_warnings=MagickTrue;
172 status=command(image_info,argc,argv,metadata,exception);
173 if (exception->severity != UndefinedException)
175 if ((exception->severity > ErrorException) ||
176 (regard_warnings != MagickFalse))
178 CatchException(exception);
180 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
182 (void) fputs(*metadata,stdout);
183 *metadata=DestroyString(*metadata);
187 number_threads=GetOpenMPMaximumThreads();
189 for (n=1; n <= (ssize_t) number_threads; n++)
199 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
200 timer=AcquireTimerInfo();
201 if (concurrent == MagickFalse)
203 for (i=0; i < (ssize_t) iterations; i++)
205 if (status != MagickFalse)
209 if (GetElapsedTime(timer) > duration)
211 (void) ContinueTimer(timer);
213 status=command(image_info,argc,argv,metadata,exception);
214 if (exception->severity != UndefinedException)
216 if ((exception->severity > ErrorException) ||
217 (regard_warnings != MagickFalse))
219 CatchException(exception);
221 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
223 (void) fputs(*metadata,stdout);
224 *metadata=DestroyString(*metadata);
231 #if defined(MAGICKCORE_OPENMP_SUPPORT)
232 # pragma omp parallel for shared(status)
234 for (i=0; i < (ssize_t) iterations; i++)
236 if (status != MagickFalse)
240 if (GetElapsedTime(timer) > duration)
242 (void) ContinueTimer(timer);
244 status=command(image_info,argc,argv,metadata,exception);
245 #if defined(MAGICKCORE_OPENMP_SUPPORT)
246 # pragma omp critical (MagickCore_CommandGenesis)
249 if (exception->severity != UndefinedException)
251 if ((exception->severity > ErrorException) ||
252 (regard_warnings != MagickFalse))
254 CatchException(exception);
256 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
258 (void) fputs(*metadata,stdout);
259 *metadata=DestroyString(*metadata);
264 user_time=GetUserTime(timer);
265 parallel=GetElapsedTime(timer);
270 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
271 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
272 (void) FormatLocaleFile(stderr,
273 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
274 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
275 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
276 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
277 timer=DestroyTimerInfo(timer);
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 + M o g r i f y I m a g e %
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 % MogrifyImage() applies simple single image processing options to a single
294 % image that may be part of a large list, but also handles any 'region'
297 % The image in the list may be modified in three different ways...
299 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
300 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
301 % * replace by a list of images (only the -separate option!)
303 % In each case the result is returned into the list, and a pointer to the
304 % modified image (last image added if replaced by a list of images) is
307 % ASIDE: The -crop is present but restricted to non-tile single image crops
309 % This means if all the images are being processed (such as by
310 % MogrifyImages(), next image to be processed will be as per the pointer
311 % (*image)->next. Also the image list may grow as a result of some specific
312 % operations but as images are never merged or deleted, it will never shrink
313 % in length. Typically the list will remain the same length.
315 % WARNING: As the image pointed to may be replaced, the first image in the
316 % list may also change. GetFirstImageInList() should be used by caller if
317 % they wish return the Image pointer to the first image in list.
320 % The format of the MogrifyImage method is:
322 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
323 % const char **argv,Image **image)
325 % A description of each parameter follows:
327 % o image_info: the image info..
329 % o argc: Specifies a pointer to an integer describing the number of
330 % elements in the argument vector.
332 % o argv: Specifies a pointer to a text array containing the command line
335 % o image: the image.
337 % o exception: return any errors or warnings in this structure.
341 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
342 ExceptionInfo *exception)
357 Read an image into a image cache (for repeated usage) if not already in
358 cache. Then return the image that is in the cache.
360 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
361 sans_exception=AcquireExceptionInfo();
362 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
363 sans_exception=DestroyExceptionInfo(sans_exception);
364 if (image != (Image *) NULL)
366 read_info=CloneImageInfo(image_info);
367 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
368 image=ReadImage(read_info,exception);
369 read_info=DestroyImageInfo(read_info);
370 if (image != (Image *) NULL)
371 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
375 static inline MagickBooleanType IsPathWritable(const char *path)
377 if (IsPathAccessible(path) == MagickFalse)
379 if (access_utf8(path,W_OK) != 0)
384 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
391 static MagickBooleanType MonitorProgress(const char *text,
392 const MagickOffsetType offset,const MagickSizeType extent,
393 void *wand_unused(client_data))
396 message[MaxTextExtent],
407 (void) CopyMagickMemory(tag,text,MaxTextExtent);
409 if (p != (char *) NULL)
411 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
412 locale_message=GetLocaleMessage(message);
413 if (locale_message == message)
415 if (p == (char *) NULL)
416 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
417 locale_message,(long) offset,(unsigned long) extent,(long)
418 (100L*offset/(extent-1)));
420 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
421 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
422 (100L*offset/(extent-1)));
423 if (offset == (MagickOffsetType) (extent-1))
424 (void) FormatLocaleFile(stderr,"\n");
425 (void) fflush(stderr);
429 static Image *SparseColorOption(const Image *image,
430 const SparseColorMethod method,const char *arguments,
431 const MagickBooleanType color_from_image,ExceptionInfo *exception)
434 token[MaxTextExtent];
459 SparseColorOption() parses the complex -sparse-color argument into an an
460 array of floating point values then calls SparseColorImage(). Argument is
461 a complex mix of floating-point pixel coodinates, and color specifications
462 (or direct floating point numbers). The number of floats needed to
463 represent a color varies depending on the current channel setting.
465 assert(image != (Image *) NULL);
466 assert(image->signature == MagickSignature);
467 if (image->debug != MagickFalse)
468 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
469 assert(exception != (ExceptionInfo *) NULL);
470 assert(exception->signature == MagickSignature);
472 Limit channels according to image - and add up number of color channel.
475 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
477 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
479 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
481 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
482 (image->colorspace == CMYKColorspace))
484 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
485 (image->alpha_trait == BlendPixelTrait))
489 Read string, to determine number of arguments needed,
495 GetMagickToken(p,&p,token);
496 if ( token[0] == ',' ) continue;
497 if ( isalpha((int) token[0]) || token[0] == '#' ) {
498 if ( color_from_image ) {
499 (void) ThrowMagickException(exception,GetMagickModule(),
500 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
501 "Color arg given, when colors are coming from image");
502 return( (Image *)NULL);
504 x += number_colors; /* color argument */
507 x++; /* floating point argument */
511 if ( color_from_image ) {
512 /* just the control points are being given */
513 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
514 number_arguments=(x/2)*(2+number_colors);
517 /* control points and color values */
518 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
522 (void) ThrowMagickException(exception,GetMagickModule(),
523 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
524 "Invalid number of Arguments");
525 return( (Image *)NULL);
528 /* Allocate and fill in the floating point arguments */
529 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
530 sizeof(*sparse_arguments));
531 if (sparse_arguments == (double *) NULL) {
532 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
533 "MemoryAllocationFailed","%s","SparseColorOption");
534 return( (Image *)NULL);
536 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
537 sizeof(*sparse_arguments));
540 while( *p != '\0' && x < number_arguments ) {
542 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
543 if ( token[0] == '\0' ) break;
544 if ( isalpha((int) token[0]) || token[0] == '#' ) {
545 (void) ThrowMagickException(exception,GetMagickModule(),
546 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
547 "Color found, instead of X-coord");
551 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
553 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
554 if ( token[0] == '\0' ) break;
555 if ( isalpha((int) token[0]) || token[0] == '#' ) {
556 (void) ThrowMagickException(exception,GetMagickModule(),
557 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
558 "Color found, instead of Y-coord");
562 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
563 /* color values for this control point */
565 if ( (color_from_image ) {
566 /* get color from image */
572 /* color name or function given in string argument */
573 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
574 if ( token[0] == '\0' ) break;
575 if ( isalpha((int) token[0]) || token[0] == '#' ) {
576 /* Color string given */
577 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
578 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
579 sparse_arguments[x++] = QuantumScale*color.red;
580 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
581 sparse_arguments[x++] = QuantumScale*color.green;
582 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
583 sparse_arguments[x++] = QuantumScale*color.blue;
584 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
585 (image->colorspace == CMYKColorspace))
586 sparse_arguments[x++] = QuantumScale*color.black;
587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
588 (image->alpha_trait == BlendPixelTrait))
589 sparse_arguments[x++] = QuantumScale*color.alpha;
592 /* Colors given as a set of floating point values - experimental */
593 /* NB: token contains the first floating point value to use! */
594 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
596 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
597 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
599 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
600 token[0] = ','; /* used this token - get another */
602 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
604 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
605 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
607 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
608 token[0] = ','; /* used this token - get another */
610 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
612 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
613 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
615 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
616 token[0] = ','; /* used this token - get another */
618 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
619 (image->colorspace == CMYKColorspace))
621 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
622 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
624 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
625 token[0] = ','; /* used this token - get another */
627 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
628 (image->alpha_trait == BlendPixelTrait))
630 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
631 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
633 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
634 token[0] = ','; /* used this token - get another */
639 if ( number_arguments != x && !error ) {
640 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
641 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
642 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
643 return( (Image *)NULL);
646 return( (Image *)NULL);
648 /* Call the Interpolation function with the parsed arguments */
649 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
651 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
652 return( sparse_image );
655 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
656 const char **argv,Image **image,ExceptionInfo *exception)
689 PixelInterpolateMethod
703 Initialize method variables.
705 assert(image_info != (const ImageInfo *) NULL);
706 assert(image_info->signature == MagickSignature);
707 assert(image != (Image **) NULL);
708 assert((*image)->signature == MagickSignature);
709 if ((*image)->debug != MagickFalse)
710 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
713 mogrify_info=CloneImageInfo(image_info);
714 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
715 quantize_info=AcquireQuantizeInfo(mogrify_info);
716 SetGeometryInfo(&geometry_info);
717 GetPixelInfo(*image,&fill);
718 fill=(*image)->background_color;
720 compose=(*image)->compose;
721 interpolate_method=UndefinedInterpolatePixel;
722 format=GetImageOption(mogrify_info,"format");
723 SetGeometry(*image,®ion_geometry);
724 region_image=NewImageList();
726 Transmogrify the image.
728 for (i=0; i < (ssize_t) argc; i++)
737 if (IsCommandOption(option) == MagickFalse)
739 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
741 if ((i+count) >= (ssize_t) argc)
743 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
744 mogrify_image=(Image *)NULL;
749 if (LocaleCompare("adaptive-blur",option+1) == 0)
754 (void) SyncImageSettings(mogrify_info,*image,exception);
755 flags=ParseGeometry(argv[i+1],&geometry_info);
756 if ((flags & SigmaValue) == 0)
757 geometry_info.sigma=1.0;
758 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
759 geometry_info.sigma,exception);
762 if (LocaleCompare("adaptive-resize",option+1) == 0)
765 Adaptive resize image.
767 (void) SyncImageSettings(mogrify_info,*image,exception);
768 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
769 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
770 geometry.height,exception);
773 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
776 Adaptive sharpen image.
778 (void) SyncImageSettings(mogrify_info,*image,exception);
779 flags=ParseGeometry(argv[i+1],&geometry_info);
780 if ((flags & SigmaValue) == 0)
781 geometry_info.sigma=1.0;
782 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
783 geometry_info.sigma,exception);
786 if (LocaleCompare("affine",option+1) == 0)
793 GetAffineMatrix(&draw_info->affine);
796 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
799 if (LocaleCompare("alpha",option+1) == 0)
804 (void) SyncImageSettings(mogrify_info,*image,exception);
805 alpha_type=(AlphaChannelOption) ParseCommandOption(
806 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
807 (void) SetImageAlphaChannel(*image,alpha_type,exception);
810 if (LocaleCompare("annotate",option+1) == 0)
814 geometry[MaxTextExtent];
819 (void) SyncImageSettings(mogrify_info,*image,exception);
820 SetGeometryInfo(&geometry_info);
821 flags=ParseGeometry(argv[i+1],&geometry_info);
822 if ((flags & SigmaValue) == 0)
823 geometry_info.sigma=geometry_info.rho;
824 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
826 if (text == (char *) NULL)
828 (void) CloneString(&draw_info->text,text);
829 text=DestroyString(text);
830 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
831 geometry_info.xi,geometry_info.psi);
832 (void) CloneString(&draw_info->geometry,geometry);
833 draw_info->affine.sx=cos(DegreesToRadians(
834 fmod(geometry_info.rho,360.0)));
835 draw_info->affine.rx=sin(DegreesToRadians(
836 fmod(geometry_info.rho,360.0)));
837 draw_info->affine.ry=(-sin(DegreesToRadians(
838 fmod(geometry_info.sigma,360.0))));
839 draw_info->affine.sy=cos(DegreesToRadians(
840 fmod(geometry_info.sigma,360.0)));
841 (void) AnnotateImage(*image,draw_info,exception);
844 if (LocaleCompare("antialias",option+1) == 0)
846 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
848 draw_info->text_antialias=(*option == '-') ? MagickTrue :
852 if (LocaleCompare("attenuate",option+1) == 0)
859 attenuate=StringToDouble(argv[i+1],(char **) NULL);
862 if (LocaleCompare("auto-gamma",option+1) == 0)
865 Auto Adjust Gamma of image based on its mean
867 (void) SyncImageSettings(mogrify_info,*image,exception);
868 (void) AutoGammaImage(*image,exception);
871 if (LocaleCompare("auto-level",option+1) == 0)
874 Perfectly Normalize (max/min stretch) the image
876 (void) SyncImageSettings(mogrify_info,*image,exception);
877 (void) AutoLevelImage(*image,exception);
880 if (LocaleCompare("auto-orient",option+1) == 0)
882 (void) SyncImageSettings(mogrify_info,*image,exception);
883 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
891 if (LocaleCompare("black-threshold",option+1) == 0)
894 Black threshold image.
896 (void) SyncImageSettings(mogrify_info,*image,exception);
897 (void) BlackThresholdImage(*image,argv[i+1],exception);
900 if (LocaleCompare("blue-shift",option+1) == 0)
905 (void) SyncImageSettings(mogrify_info,*image,exception);
906 geometry_info.rho=1.5;
908 flags=ParseGeometry(argv[i+1],&geometry_info);
909 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
912 if (LocaleCompare("blur",option+1) == 0)
917 (void) SyncImageSettings(mogrify_info,*image,exception);
918 flags=ParseGeometry(argv[i+1],&geometry_info);
919 if ((flags & SigmaValue) == 0)
920 geometry_info.sigma=1.0;
921 if ((flags & XiValue) == 0)
922 geometry_info.xi=0.0;
923 mogrify_image=BlurImage(*image,geometry_info.rho,
924 geometry_info.sigma,exception);
927 if (LocaleCompare("border",option+1) == 0)
930 Surround image with a border of solid color.
932 (void) SyncImageSettings(mogrify_info,*image,exception);
933 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
934 mogrify_image=BorderImage(*image,&geometry,compose,exception);
937 if (LocaleCompare("bordercolor",option+1) == 0)
941 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
942 &draw_info->border_color,exception);
945 (void) QueryColorCompliance(argv[i+1],AllCompliance,
946 &draw_info->border_color,exception);
949 if (LocaleCompare("box",option+1) == 0)
951 (void) QueryColorCompliance(argv[i+1],AllCompliance,
952 &draw_info->undercolor,exception);
955 if (LocaleCompare("brightness-contrast",option+1) == 0)
968 Brightness / contrast image.
970 (void) SyncImageSettings(mogrify_info,*image,exception);
971 flags=ParseGeometry(argv[i+1],&geometry_info);
972 brightness=geometry_info.rho;
974 if ((flags & SigmaValue) != 0)
975 contrast=geometry_info.sigma;
976 (void) BrightnessContrastImage(*image,brightness,contrast,
984 if (LocaleCompare("cdl",option+1) == 0)
987 *color_correction_collection;
990 Color correct with a color decision list.
992 (void) SyncImageSettings(mogrify_info,*image,exception);
993 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
994 if (color_correction_collection == (char *) NULL)
996 (void) ColorDecisionListImage(*image,color_correction_collection,
1000 if (LocaleCompare("charcoal",option+1) == 0)
1005 (void) SyncImageSettings(mogrify_info,*image,exception);
1006 flags=ParseGeometry(argv[i+1],&geometry_info);
1007 if ((flags & SigmaValue) == 0)
1008 geometry_info.sigma=1.0;
1009 if ((flags & XiValue) == 0)
1010 geometry_info.xi=1.0;
1011 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1012 geometry_info.sigma,exception);
1015 if (LocaleCompare("chop",option+1) == 0)
1020 (void) SyncImageSettings(mogrify_info,*image,exception);
1021 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1022 mogrify_image=ChopImage(*image,&geometry,exception);
1025 if (LocaleCompare("perceptible",option+1) == 0)
1030 (void) SyncImageSettings(mogrify_info,*image,exception);
1031 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
1032 (char **) NULL),exception);
1035 if (LocaleCompare("clip",option+1) == 0)
1037 (void) SyncImageSettings(mogrify_info,*image,exception);
1040 (void) SetImageMask(*image,(Image *) NULL,exception);
1043 (void) ClipImage(*image,exception);
1046 if (LocaleCompare("clip-mask",option+1) == 0)
1063 (void) SyncImageSettings(mogrify_info,*image,exception);
1069 (void) SetImageMask(*image,(Image *) NULL,exception);
1074 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1076 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1077 if (mask_image == (Image *) NULL)
1079 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1080 return(MagickFalse);
1081 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1082 for (y=0; y < (ssize_t) mask_image->rows; y++)
1084 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1086 if (q == (Quantum *) NULL)
1088 for (x=0; x < (ssize_t) mask_image->columns; x++)
1090 if (mask_image->alpha_trait != BlendPixelTrait)
1091 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1092 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1093 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1094 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1095 q+=GetPixelChannels(mask_image);
1097 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1100 mask_view=DestroyCacheView(mask_view);
1101 mask_image->alpha_trait=BlendPixelTrait;
1102 (void) SetImageMask(*image,mask_image,exception);
1105 if (LocaleCompare("clip-path",option+1) == 0)
1107 (void) SyncImageSettings(mogrify_info,*image,exception);
1108 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1109 MagickFalse,exception);
1112 if (LocaleCompare("colorize",option+1) == 0)
1117 (void) SyncImageSettings(mogrify_info,*image,exception);
1118 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1121 if (LocaleCompare("color-matrix",option+1) == 0)
1126 (void) SyncImageSettings(mogrify_info,*image,exception);
1127 kernel=AcquireKernelInfo(argv[i+1]);
1128 if (kernel == (KernelInfo *) NULL)
1130 /* FUTURE: check on size of the matrix */
1131 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1132 kernel=DestroyKernelInfo(kernel);
1135 if (LocaleCompare("colors",option+1) == 0)
1138 Reduce the number of colors in the image.
1140 (void) SyncImageSettings(mogrify_info,*image,exception);
1141 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1142 if (quantize_info->number_colors == 0)
1144 if (((*image)->storage_class == DirectClass) ||
1145 (*image)->colors > quantize_info->number_colors)
1146 (void) QuantizeImage(quantize_info,*image,exception);
1148 (void) CompressImageColormap(*image,exception);
1151 if (LocaleCompare("colorspace",option+1) == 0)
1156 (void) SyncImageSettings(mogrify_info,*image,exception);
1159 (void) TransformImageColorspace(*image,sRGBColorspace,
1163 colorspace=(ColorspaceType) ParseCommandOption(
1164 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1165 (void) TransformImageColorspace(*image,colorspace,exception);
1168 if (LocaleCompare("compose",option+1) == 0)
1170 (void) SyncImageSettings(mogrify_info,*image,exception);
1171 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1172 MagickFalse,argv[i+1]);
1175 if (LocaleCompare("contrast",option+1) == 0)
1177 (void) SyncImageSettings(mogrify_info,*image,exception);
1178 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1179 MagickFalse,exception);
1182 if (LocaleCompare("contrast-stretch",option+1) == 0)
1192 Contrast stretch image.
1194 (void) SyncImageSettings(mogrify_info,*image,exception);
1195 flags=ParseGeometry(argv[i+1],&geometry_info);
1196 black_point=geometry_info.rho;
1197 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1199 if ((flags & PercentValue) != 0)
1201 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1202 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1204 white_point=(double) (*image)->columns*(*image)->rows-
1206 (void) ContrastStretchImage(*image,black_point,white_point,
1210 if (LocaleCompare("convolve",option+1) == 0)
1215 (void) SyncImageSettings(mogrify_info,*image,exception);
1216 kernel_info=AcquireKernelInfo(argv[i+1]);
1217 if (kernel_info == (KernelInfo *) NULL)
1219 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1220 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1221 kernel_info,exception);
1222 kernel_info=DestroyKernelInfo(kernel_info);
1225 if (LocaleCompare("crop",option+1) == 0)
1228 Crop a image to a smaller size
1230 (void) SyncImageSettings(mogrify_info,*image,exception);
1231 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1234 if (LocaleCompare("cycle",option+1) == 0)
1237 Cycle an image colormap.
1239 (void) SyncImageSettings(mogrify_info,*image,exception);
1240 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1248 if (LocaleCompare("decipher",option+1) == 0)
1256 (void) SyncImageSettings(mogrify_info,*image,exception);
1257 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1258 if (passkey != (StringInfo *) NULL)
1260 (void) PasskeyDecipherImage(*image,passkey,exception);
1261 passkey=DestroyStringInfo(passkey);
1265 if (LocaleCompare("density",option+1) == 0)
1270 (void) CloneString(&draw_info->density,argv[i+1]);
1273 if (LocaleCompare("depth",option+1) == 0)
1275 (void) SyncImageSettings(mogrify_info,*image,exception);
1278 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1281 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1285 if (LocaleCompare("deskew",option+1) == 0)
1291 Straighten the image.
1293 (void) SyncImageSettings(mogrify_info,*image,exception);
1295 threshold=40.0*QuantumRange/100.0;
1297 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1299 mogrify_image=DeskewImage(*image,threshold,exception);
1302 if (LocaleCompare("despeckle",option+1) == 0)
1305 Reduce the speckles within an image.
1307 (void) SyncImageSettings(mogrify_info,*image,exception);
1308 mogrify_image=DespeckleImage(*image,exception);
1311 if (LocaleCompare("display",option+1) == 0)
1313 (void) CloneString(&draw_info->server_name,argv[i+1]);
1316 if (LocaleCompare("distort",option+1) == 0)
1320 token[MaxTextExtent];
1340 (void) SyncImageSettings(mogrify_info,*image,exception);
1341 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1342 MagickFalse,argv[i+1]);
1343 if (method == ResizeDistortion)
1349 Special Case - Argument is actually a resize geometry!
1350 Convert that to an appropriate distortion argument array.
1352 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1354 resize_args[0]=(double) geometry.width;
1355 resize_args[1]=(double) geometry.height;
1356 mogrify_image=DistortImage(*image,method,(size_t)2,
1357 resize_args,MagickTrue,exception);
1360 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1362 if (args == (char *) NULL)
1365 for (x=0; *p != '\0'; x++)
1367 GetMagickToken(p,&p,token);
1369 GetMagickToken(p,&p,token);
1371 number_arguments=(size_t) x;
1372 arguments=(double *) AcquireQuantumMemory(number_arguments,
1373 sizeof(*arguments));
1374 if (arguments == (double *) NULL)
1375 ThrowWandFatalException(ResourceLimitFatalError,
1376 "MemoryAllocationFailed",(*image)->filename);
1377 (void) ResetMagickMemory(arguments,0,number_arguments*
1378 sizeof(*arguments));
1380 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1382 GetMagickToken(p,&p,token);
1384 GetMagickToken(p,&p,token);
1385 arguments[x]=StringToDouble(token,(char **) NULL);
1387 args=DestroyString(args);
1388 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1389 (*option == '+') ? MagickTrue : MagickFalse,exception);
1390 arguments=(double *) RelinquishMagickMemory(arguments);
1393 if (LocaleCompare("dither",option+1) == 0)
1397 quantize_info->dither_method=NoDitherMethod;
1400 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1401 MagickDitherOptions,MagickFalse,argv[i+1]);
1404 if (LocaleCompare("draw",option+1) == 0)
1409 (void) SyncImageSettings(mogrify_info,*image,exception);
1410 (void) CloneString(&draw_info->primitive,argv[i+1]);
1411 (void) DrawImage(*image,draw_info,exception);
1418 if (LocaleCompare("edge",option+1) == 0)
1421 Enhance edges in the image.
1423 (void) SyncImageSettings(mogrify_info,*image,exception);
1424 flags=ParseGeometry(argv[i+1],&geometry_info);
1425 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1428 if (LocaleCompare("emboss",option+1) == 0)
1433 (void) SyncImageSettings(mogrify_info,*image,exception);
1434 flags=ParseGeometry(argv[i+1],&geometry_info);
1435 if ((flags & SigmaValue) == 0)
1436 geometry_info.sigma=1.0;
1437 mogrify_image=EmbossImage(*image,geometry_info.rho,
1438 geometry_info.sigma,exception);
1441 if (LocaleCompare("encipher",option+1) == 0)
1449 (void) SyncImageSettings(mogrify_info,*image,exception);
1450 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1451 if (passkey != (StringInfo *) NULL)
1453 (void) PasskeyEncipherImage(*image,passkey,exception);
1454 passkey=DestroyStringInfo(passkey);
1458 if (LocaleCompare("encoding",option+1) == 0)
1460 (void) CloneString(&draw_info->encoding,argv[i+1]);
1463 if (LocaleCompare("enhance",option+1) == 0)
1468 (void) SyncImageSettings(mogrify_info,*image,exception);
1469 mogrify_image=EnhanceImage(*image,exception);
1472 if (LocaleCompare("equalize",option+1) == 0)
1477 (void) SyncImageSettings(mogrify_info,*image,exception);
1478 (void) EqualizeImage(*image,exception);
1481 if (LocaleCompare("evaluate",option+1) == 0)
1486 MagickEvaluateOperator
1489 (void) SyncImageSettings(mogrify_info,*image,exception);
1490 op=(MagickEvaluateOperator) ParseCommandOption(
1491 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1492 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1494 (void) EvaluateImage(*image,op,constant,exception);
1497 if (LocaleCompare("extent",option+1) == 0)
1500 Set the image extent.
1502 (void) SyncImageSettings(mogrify_info,*image,exception);
1503 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1504 if (geometry.width == 0)
1505 geometry.width=(*image)->columns;
1506 if (geometry.height == 0)
1507 geometry.height=(*image)->rows;
1508 mogrify_image=ExtentImage(*image,&geometry,exception);
1515 if (LocaleCompare("family",option+1) == 0)
1519 if (draw_info->family != (char *) NULL)
1520 draw_info->family=DestroyString(draw_info->family);
1523 (void) CloneString(&draw_info->family,argv[i+1]);
1526 if (LocaleCompare("features",option+1) == 0)
1530 (void) DeleteImageArtifact(*image,"identify:features");
1533 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1536 if (LocaleCompare("fill",option+1) == 0)
1544 GetPixelInfo(*image,&fill);
1547 (void) QueryColorCompliance("none",AllCompliance,&fill,
1549 draw_info->fill=fill;
1550 if (draw_info->fill_pattern != (Image *) NULL)
1551 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1554 sans=AcquireExceptionInfo();
1555 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1556 sans=DestroyExceptionInfo(sans);
1557 if (status == MagickFalse)
1558 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1561 draw_info->fill=fill=color;
1564 if (LocaleCompare("flip",option+1) == 0)
1567 Flip image scanlines.
1569 (void) SyncImageSettings(mogrify_info,*image,exception);
1570 mogrify_image=FlipImage(*image,exception);
1573 if (LocaleCompare("floodfill",option+1) == 0)
1581 (void) SyncImageSettings(mogrify_info,*image,exception);
1582 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1583 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1585 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1586 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1589 if (LocaleCompare("flop",option+1) == 0)
1592 Flop image scanlines.
1594 (void) SyncImageSettings(mogrify_info,*image,exception);
1595 mogrify_image=FlopImage(*image,exception);
1598 if (LocaleCompare("font",option+1) == 0)
1602 if (draw_info->font != (char *) NULL)
1603 draw_info->font=DestroyString(draw_info->font);
1606 (void) CloneString(&draw_info->font,argv[i+1]);
1609 if (LocaleCompare("format",option+1) == 0)
1614 if (LocaleCompare("frame",option+1) == 0)
1620 Surround image with an ornamental border.
1622 (void) SyncImageSettings(mogrify_info,*image,exception);
1623 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1624 frame_info.width=geometry.width;
1625 frame_info.height=geometry.height;
1626 frame_info.outer_bevel=geometry.x;
1627 frame_info.inner_bevel=geometry.y;
1628 frame_info.x=(ssize_t) frame_info.width;
1629 frame_info.y=(ssize_t) frame_info.height;
1630 frame_info.width=(*image)->columns+2*frame_info.width;
1631 frame_info.height=(*image)->rows+2*frame_info.height;
1632 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1635 if (LocaleCompare("function",option+1) == 0)
1639 token[MaxTextExtent];
1657 Function Modify Image Values
1659 (void) SyncImageSettings(mogrify_info,*image,exception);
1660 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1661 MagickFalse,argv[i+1]);
1662 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1664 if (arguments == (char *) NULL)
1666 p=(char *) arguments;
1667 for (x=0; *p != '\0'; x++)
1669 GetMagickToken(p,&p,token);
1671 GetMagickToken(p,&p,token);
1673 number_parameters=(size_t) x;
1674 parameters=(double *) AcquireQuantumMemory(number_parameters,
1675 sizeof(*parameters));
1676 if (parameters == (double *) NULL)
1677 ThrowWandFatalException(ResourceLimitFatalError,
1678 "MemoryAllocationFailed",(*image)->filename);
1679 (void) ResetMagickMemory(parameters,0,number_parameters*
1680 sizeof(*parameters));
1681 p=(char *) arguments;
1682 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1684 GetMagickToken(p,&p,token);
1686 GetMagickToken(p,&p,token);
1687 parameters[x]=StringToDouble(token,(char **) NULL);
1689 arguments=DestroyString(arguments);
1690 (void) FunctionImage(*image,function,number_parameters,parameters,
1692 parameters=(double *) RelinquishMagickMemory(parameters);
1699 if (LocaleCompare("gamma",option+1) == 0)
1704 (void) SyncImageSettings(mogrify_info,*image,exception);
1706 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1708 (void) GammaImage(*image,StringToDouble(argv[i+1],
1709 (char **) NULL),exception);
1712 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1713 (LocaleCompare("gaussian",option+1) == 0))
1716 Gaussian blur image.
1718 (void) SyncImageSettings(mogrify_info,*image,exception);
1719 flags=ParseGeometry(argv[i+1],&geometry_info);
1720 if ((flags & SigmaValue) == 0)
1721 geometry_info.sigma=1.0;
1722 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1723 geometry_info.sigma,exception);
1726 if (LocaleCompare("geometry",option+1) == 0)
1729 Record Image offset, Resize last image.
1731 (void) SyncImageSettings(mogrify_info,*image,exception);
1734 if ((*image)->geometry != (char *) NULL)
1735 (*image)->geometry=DestroyString((*image)->geometry);
1738 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1739 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1740 (void) CloneString(&(*image)->geometry,argv[i+1]);
1742 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1743 (*image)->filter,exception);
1746 if (LocaleCompare("gravity",option+1) == 0)
1750 draw_info->gravity=UndefinedGravity;
1753 draw_info->gravity=(GravityType) ParseCommandOption(
1754 MagickGravityOptions,MagickFalse,argv[i+1]);
1757 if (LocaleCompare("grayscale",option+1) == 0)
1759 PixelIntensityMethod
1762 (void) SyncImageSettings(mogrify_info,*image,exception);
1763 method=(PixelIntensityMethod) ParseCommandOption(
1764 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1765 (void) GrayscaleImage(*image,method,exception);
1772 if (LocaleCompare("highlight-color",option+1) == 0)
1774 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1781 if (LocaleCompare("identify",option+1) == 0)
1786 (void) SyncImageSettings(mogrify_info,*image,exception);
1787 if (format == (char *) NULL)
1789 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1793 text=InterpretImageProperties(mogrify_info,*image,format,
1795 if (text == (char *) NULL)
1797 (void) fputs(text,stdout);
1798 text=DestroyString(text);
1801 if (LocaleCompare("implode",option+1) == 0)
1806 (void) SyncImageSettings(mogrify_info,*image,exception);
1807 (void) ParseGeometry(argv[i+1],&geometry_info);
1808 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1809 interpolate_method,exception);
1812 if (LocaleCompare("interline-spacing",option+1) == 0)
1815 (void) ParseGeometry("0",&geometry_info);
1817 (void) ParseGeometry(argv[i+1],&geometry_info);
1818 draw_info->interline_spacing=geometry_info.rho;
1821 if (LocaleCompare("interpolate",option+1) == 0)
1823 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1824 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1827 if (LocaleCompare("interword-spacing",option+1) == 0)
1830 (void) ParseGeometry("0",&geometry_info);
1832 (void) ParseGeometry(argv[i+1],&geometry_info);
1833 draw_info->interword_spacing=geometry_info.rho;
1836 if (LocaleCompare("interpolative-resize",option+1) == 0)
1839 Interpolative resize image.
1841 (void) SyncImageSettings(mogrify_info,*image,exception);
1842 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1843 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1844 geometry.height,interpolate_method,exception);
1851 if (LocaleCompare("kerning",option+1) == 0)
1854 (void) ParseGeometry("0",&geometry_info);
1856 (void) ParseGeometry(argv[i+1],&geometry_info);
1857 draw_info->kerning=geometry_info.rho;
1864 if (LocaleCompare("lat",option+1) == 0)
1867 Local adaptive threshold image.
1869 (void) SyncImageSettings(mogrify_info,*image,exception);
1870 flags=ParseGeometry(argv[i+1],&geometry_info);
1871 if ((flags & PercentValue) != 0)
1872 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1873 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1874 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1875 geometry_info.xi,exception);
1878 if (LocaleCompare("level",option+1) == 0)
1891 (void) SyncImageSettings(mogrify_info,*image,exception);
1892 flags=ParseGeometry(argv[i+1],&geometry_info);
1893 black_point=geometry_info.rho;
1894 white_point=(double) QuantumRange;
1895 if ((flags & SigmaValue) != 0)
1896 white_point=geometry_info.sigma;
1898 if ((flags & XiValue) != 0)
1899 gamma=geometry_info.xi;
1900 if ((flags & PercentValue) != 0)
1902 black_point*=(double) (QuantumRange/100.0);
1903 white_point*=(double) (QuantumRange/100.0);
1905 if ((flags & SigmaValue) == 0)
1906 white_point=(double) QuantumRange-black_point;
1907 if ((*option == '+') || ((flags & AspectValue) != 0))
1908 (void) LevelizeImage(*image,black_point,white_point,gamma,
1911 (void) LevelImage(*image,black_point,white_point,gamma,
1915 if (LocaleCompare("level-colors",option+1) == 0)
1918 token[MaxTextExtent];
1927 p=(const char *) argv[i+1];
1928 GetMagickToken(p,&p,token); /* get black point color */
1929 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1930 (void) QueryColorCompliance(token,AllCompliance,
1931 &black_point,exception);
1933 (void) QueryColorCompliance("#000000",AllCompliance,
1934 &black_point,exception);
1935 if (isalpha((int) token[0]) || (token[0] == '#'))
1936 GetMagickToken(p,&p,token);
1938 white_point=black_point; /* set everything to that color */
1941 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1942 GetMagickToken(p,&p,token); /* Get white point color. */
1943 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1944 (void) QueryColorCompliance(token,AllCompliance,
1945 &white_point,exception);
1947 (void) QueryColorCompliance("#ffffff",AllCompliance,
1948 &white_point,exception);
1950 (void) LevelImageColors(*image,&black_point,&white_point,
1951 *option == '+' ? MagickTrue : MagickFalse,exception);
1954 if (LocaleCompare("linear-stretch",option+1) == 0)
1963 (void) SyncImageSettings(mogrify_info,*image,exception);
1964 flags=ParseGeometry(argv[i+1],&geometry_info);
1965 black_point=geometry_info.rho;
1966 white_point=(double) (*image)->columns*(*image)->rows;
1967 if ((flags & SigmaValue) != 0)
1968 white_point=geometry_info.sigma;
1969 if ((flags & PercentValue) != 0)
1971 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1972 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1974 if ((flags & SigmaValue) == 0)
1975 white_point=(double) (*image)->columns*(*image)->rows-
1977 (void) LinearStretchImage(*image,black_point,white_point,exception);
1980 if (LocaleCompare("liquid-rescale",option+1) == 0)
1983 Liquid rescale image.
1985 (void) SyncImageSettings(mogrify_info,*image,exception);
1986 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1987 if ((flags & XValue) == 0)
1989 if ((flags & YValue) == 0)
1991 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1992 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1995 if (LocaleCompare("lowlight-color",option+1) == 0)
1997 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2004 if (LocaleCompare("magnify",option+1) == 0)
2009 (void) SyncImageSettings(mogrify_info,*image,exception);
2010 mogrify_image=MagnifyImage(*image,exception);
2013 if (LocaleCompare("map",option+1) == 0)
2019 Transform image colors to match this set of colors.
2021 (void) SyncImageSettings(mogrify_info,*image,exception);
2024 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2025 if (remap_image == (Image *) NULL)
2027 (void) RemapImage(quantize_info,*image,remap_image,exception);
2028 remap_image=DestroyImage(remap_image);
2031 if (LocaleCompare("mask",option+1) == 0)
2036 (void) SyncImageSettings(mogrify_info,*image,exception);
2042 (void) SetImageMask(*image,(Image *) NULL,exception);
2048 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2049 if (mask == (Image *) NULL)
2051 (void) SetImageMask(*image,mask,exception);
2052 mask=DestroyImage(mask);
2055 if (LocaleCompare("matte",option+1) == 0)
2057 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2058 SetAlphaChannel : DeactivateAlphaChannel,exception);
2061 if (LocaleCompare("median",option+1) == 0)
2064 Median filter image.
2066 (void) SyncImageSettings(mogrify_info,*image,exception);
2067 flags=ParseGeometry(argv[i+1],&geometry_info);
2068 if ((flags & SigmaValue) == 0)
2069 geometry_info.sigma=geometry_info.rho;
2070 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2071 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2074 if (LocaleCompare("mode",option+1) == 0)
2079 (void) SyncImageSettings(mogrify_info,*image,exception);
2080 flags=ParseGeometry(argv[i+1],&geometry_info);
2081 if ((flags & SigmaValue) == 0)
2082 geometry_info.sigma=geometry_info.rho;
2083 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2084 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2087 if (LocaleCompare("modulate",option+1) == 0)
2089 (void) SyncImageSettings(mogrify_info,*image,exception);
2090 (void) ModulateImage(*image,argv[i+1],exception);
2093 if (LocaleCompare("moments",option+1) == 0)
2097 (void) DeleteImageArtifact(*image,"identify:moments");
2100 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2103 if (LocaleCompare("monitor",option+1) == 0)
2107 (void) SetImageProgressMonitor(*image,
2108 (MagickProgressMonitor) NULL,(void *) NULL);
2111 (void) SetImageProgressMonitor(*image,MonitorProgress,
2115 if (LocaleCompare("monochrome",option+1) == 0)
2117 (void) SyncImageSettings(mogrify_info,*image,exception);
2118 (void) SetImageType(*image,BilevelType,exception);
2121 if (LocaleCompare("morphology",option+1) == 0)
2124 token[MaxTextExtent];
2139 Morphological Image Operation
2141 (void) SyncImageSettings(mogrify_info,*image,exception);
2143 GetMagickToken(p,&p,token);
2144 method=(MorphologyMethod) ParseCommandOption(
2145 MagickMorphologyOptions,MagickFalse,token);
2147 GetMagickToken(p,&p,token);
2148 if ((*p == ':') || (*p == ','))
2149 GetMagickToken(p,&p,token);
2151 iterations=(ssize_t) StringToLong(p);
2152 kernel=AcquireKernelInfo(argv[i+2]);
2153 if (kernel == (KernelInfo *) NULL)
2155 (void) ThrowMagickException(exception,GetMagickModule(),
2156 OptionError,"UnabletoParseKernel","morphology");
2160 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2162 kernel=DestroyKernelInfo(kernel);
2165 if (LocaleCompare("motion-blur",option+1) == 0)
2170 (void) SyncImageSettings(mogrify_info,*image,exception);
2171 flags=ParseGeometry(argv[i+1],&geometry_info);
2172 if ((flags & SigmaValue) == 0)
2173 geometry_info.sigma=1.0;
2174 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2175 geometry_info.sigma,geometry_info.xi,exception);
2182 if (LocaleCompare("negate",option+1) == 0)
2184 (void) SyncImageSettings(mogrify_info,*image,exception);
2185 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2186 MagickFalse,exception);
2189 if (LocaleCompare("noise",option+1) == 0)
2191 (void) SyncImageSettings(mogrify_info,*image,exception);
2194 flags=ParseGeometry(argv[i+1],&geometry_info);
2195 if ((flags & SigmaValue) == 0)
2196 geometry_info.sigma=geometry_info.rho;
2197 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2198 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2205 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2206 MagickFalse,argv[i+1]);
2207 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2211 if (LocaleCompare("normalize",option+1) == 0)
2213 (void) SyncImageSettings(mogrify_info,*image,exception);
2214 (void) NormalizeImage(*image,exception);
2221 if (LocaleCompare("opaque",option+1) == 0)
2226 (void) SyncImageSettings(mogrify_info,*image,exception);
2227 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2229 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2230 MagickFalse : MagickTrue,exception);
2233 if (LocaleCompare("ordered-dither",option+1) == 0)
2235 (void) SyncImageSettings(mogrify_info,*image,exception);
2236 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2243 if (LocaleCompare("paint",option+1) == 0)
2245 (void) SyncImageSettings(mogrify_info,*image,exception);
2246 (void) ParseGeometry(argv[i+1],&geometry_info);
2247 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2248 geometry_info.sigma,exception);
2251 if (LocaleCompare("pointsize",option+1) == 0)
2254 (void) ParseGeometry("12",&geometry_info);
2256 (void) ParseGeometry(argv[i+1],&geometry_info);
2257 draw_info->pointsize=geometry_info.rho;
2260 if (LocaleCompare("polaroid",option+1) == 0)
2272 Simulate a Polaroid picture.
2274 (void) SyncImageSettings(mogrify_info,*image,exception);
2275 random_info=AcquireRandomInfo();
2276 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2277 random_info=DestroyRandomInfo(random_info);
2280 SetGeometryInfo(&geometry_info);
2281 flags=ParseGeometry(argv[i+1],&geometry_info);
2282 angle=geometry_info.rho;
2284 caption=GetImageProperty(*image,"caption",exception);
2285 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2286 interpolate_method,exception);
2289 if (LocaleCompare("posterize",option+1) == 0)
2294 (void) SyncImageSettings(mogrify_info,*image,exception);
2295 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2296 quantize_info->dither_method,exception);
2299 if (LocaleCompare("preview",option+1) == 0)
2307 (void) SyncImageSettings(mogrify_info,*image,exception);
2309 preview_type=UndefinedPreview;
2311 preview_type=(PreviewType) ParseCommandOption(
2312 MagickPreviewOptions,MagickFalse,argv[i+1]);
2313 mogrify_image=PreviewImage(*image,preview_type,exception);
2316 if (LocaleCompare("profile",option+1) == 0)
2330 (void) SyncImageSettings(mogrify_info,*image,exception);
2334 Remove a profile from the image.
2336 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2341 Associate a profile with the image.
2343 profile_info=CloneImageInfo(mogrify_info);
2344 profile=GetImageProfile(*image,"iptc");
2345 if (profile != (StringInfo *) NULL)
2346 profile_info->profile=(void *) CloneStringInfo(profile);
2347 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2348 profile_info=DestroyImageInfo(profile_info);
2349 if (profile_image == (Image *) NULL)
2354 profile_info=CloneImageInfo(mogrify_info);
2355 (void) CopyMagickString(profile_info->filename,argv[i+1],
2357 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2358 if (profile != (StringInfo *) NULL)
2360 (void) ProfileImage(*image,profile_info->magick,
2361 GetStringInfoDatum(profile),(size_t)
2362 GetStringInfoLength(profile),exception);
2363 profile=DestroyStringInfo(profile);
2365 profile_info=DestroyImageInfo(profile_info);
2368 ResetImageProfileIterator(profile_image);
2369 name=GetNextImageProfile(profile_image);
2370 while (name != (const char *) NULL)
2372 profile=GetImageProfile(profile_image,name);
2373 if (profile != (StringInfo *) NULL)
2374 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2375 (size_t) GetStringInfoLength(profile),exception);
2376 name=GetNextImageProfile(profile_image);
2378 profile_image=DestroyImage(profile_image);
2385 if (LocaleCompare("quantize",option+1) == 0)
2389 quantize_info->colorspace=UndefinedColorspace;
2392 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2393 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2400 if (LocaleCompare("radial-blur",option+1) == 0)
2405 (void) SyncImageSettings(mogrify_info,*image,exception);
2406 flags=ParseGeometry(argv[i+1],&geometry_info);
2407 mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception);
2410 if (LocaleCompare("raise",option+1) == 0)
2413 Surround image with a raise of solid color.
2415 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2416 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2417 MagickFalse,exception);
2420 if (LocaleCompare("random-threshold",option+1) == 0)
2425 (void) SyncImageSettings(mogrify_info,*image,exception);
2426 (void) RandomThresholdImage(*image,argv[i+1],exception);
2429 if (LocaleCompare("region",option+1) == 0)
2431 (void) SyncImageSettings(mogrify_info,*image,exception);
2432 if (region_image != (Image *) NULL)
2437 (void) CompositeImage(region_image,*image,
2438 region_image->alpha_trait == BlendPixelTrait ?
2439 CopyCompositeOp : OverCompositeOp,MagickTrue,
2440 region_geometry.x,region_geometry.y,exception);
2441 *image=DestroyImage(*image);
2442 *image=region_image;
2443 region_image = (Image *) NULL;
2448 Apply transformations to a selected region of the image.
2450 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2452 mogrify_image=CropImage(*image,®ion_geometry,exception);
2453 if (mogrify_image == (Image *) NULL)
2455 region_image=(*image);
2456 *image=mogrify_image;
2457 mogrify_image=(Image *) NULL;
2460 if (LocaleCompare("render",option+1) == 0)
2462 (void) SyncImageSettings(mogrify_info,*image,exception);
2463 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2466 if (LocaleCompare("remap",option+1) == 0)
2472 Transform image colors to match this set of colors.
2474 (void) SyncImageSettings(mogrify_info,*image,exception);
2477 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2478 if (remap_image == (Image *) NULL)
2480 (void) RemapImage(quantize_info,*image,remap_image,exception);
2481 remap_image=DestroyImage(remap_image);
2484 if (LocaleCompare("repage",option+1) == 0)
2488 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2491 (void) ResetImagePage(*image,argv[i+1]);
2494 if (LocaleCompare("resample",option+1) == 0)
2499 (void) SyncImageSettings(mogrify_info,*image,exception);
2500 flags=ParseGeometry(argv[i+1],&geometry_info);
2501 if ((flags & SigmaValue) == 0)
2502 geometry_info.sigma=geometry_info.rho;
2503 mogrify_image=ResampleImage(*image,geometry_info.rho,
2504 geometry_info.sigma,(*image)->filter,exception);
2507 if (LocaleCompare("resize",option+1) == 0)
2512 (void) SyncImageSettings(mogrify_info,*image,exception);
2513 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2514 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2515 (*image)->filter,exception);
2518 if (LocaleCompare("roll",option+1) == 0)
2523 (void) SyncImageSettings(mogrify_info,*image,exception);
2524 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2525 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2528 if (LocaleCompare("rotate",option+1) == 0)
2534 Check for conditional image rotation.
2536 (void) SyncImageSettings(mogrify_info,*image,exception);
2537 if (strchr(argv[i+1],'>') != (char *) NULL)
2538 if ((*image)->columns <= (*image)->rows)
2540 if (strchr(argv[i+1],'<') != (char *) NULL)
2541 if ((*image)->columns >= (*image)->rows)
2546 geometry=ConstantString(argv[i+1]);
2547 (void) SubstituteString(&geometry,">","");
2548 (void) SubstituteString(&geometry,"<","");
2549 (void) ParseGeometry(geometry,&geometry_info);
2550 geometry=DestroyString(geometry);
2551 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2558 if (LocaleCompare("sample",option+1) == 0)
2561 Sample image with pixel replication.
2563 (void) SyncImageSettings(mogrify_info,*image,exception);
2564 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2565 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2569 if (LocaleCompare("scale",option+1) == 0)
2574 (void) SyncImageSettings(mogrify_info,*image,exception);
2575 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2576 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2580 if (LocaleCompare("selective-blur",option+1) == 0)
2583 Selectively blur pixels within a contrast threshold.
2585 (void) SyncImageSettings(mogrify_info,*image,exception);
2586 flags=ParseGeometry(argv[i+1],&geometry_info);
2587 if ((flags & PercentValue) != 0)
2588 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2589 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2590 geometry_info.sigma,geometry_info.xi,exception);
2593 if (LocaleCompare("separate",option+1) == 0)
2596 Break channels into separate images.
2598 (void) SyncImageSettings(mogrify_info,*image,exception);
2599 mogrify_image=SeparateImages(*image,exception);
2602 if (LocaleCompare("sepia-tone",option+1) == 0)
2610 (void) SyncImageSettings(mogrify_info,*image,exception);
2611 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2613 mogrify_image=SepiaToneImage(*image,threshold,exception);
2616 if (LocaleCompare("segment",option+1) == 0)
2621 (void) SyncImageSettings(mogrify_info,*image,exception);
2622 flags=ParseGeometry(argv[i+1],&geometry_info);
2623 if ((flags & SigmaValue) == 0)
2624 geometry_info.sigma=1.0;
2625 (void) SegmentImage(*image,(*image)->colorspace,
2626 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2630 if (LocaleCompare("set",option+1) == 0)
2640 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2641 (void) DeleteImageRegistry(argv[i+1]+9);
2643 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2645 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2646 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2649 (void) DeleteImageProperty(*image,argv[i+1]);
2652 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2654 if (value == (char *) NULL)
2656 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2657 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2660 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2662 (void) SetImageOption(image_info,argv[i+1]+7,value);
2663 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2664 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2667 (void) SetImageProperty(*image,argv[i+1],value,exception);
2668 value=DestroyString(value);
2671 if (LocaleCompare("shade",option+1) == 0)
2676 (void) SyncImageSettings(mogrify_info,*image,exception);
2677 flags=ParseGeometry(argv[i+1],&geometry_info);
2678 if ((flags & SigmaValue) == 0)
2679 geometry_info.sigma=1.0;
2680 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2681 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2684 if (LocaleCompare("shadow",option+1) == 0)
2689 (void) SyncImageSettings(mogrify_info,*image,exception);
2690 flags=ParseGeometry(argv[i+1],&geometry_info);
2691 if ((flags & SigmaValue) == 0)
2692 geometry_info.sigma=1.0;
2693 if ((flags & XiValue) == 0)
2694 geometry_info.xi=4.0;
2695 if ((flags & PsiValue) == 0)
2696 geometry_info.psi=4.0;
2697 mogrify_image=ShadowImage(*image,geometry_info.rho,
2698 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2699 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2702 if (LocaleCompare("sharpen",option+1) == 0)
2707 (void) SyncImageSettings(mogrify_info,*image,exception);
2708 flags=ParseGeometry(argv[i+1],&geometry_info);
2709 if ((flags & SigmaValue) == 0)
2710 geometry_info.sigma=1.0;
2711 if ((flags & XiValue) == 0)
2712 geometry_info.xi=0.0;
2713 mogrify_image=SharpenImage(*image,geometry_info.rho,
2714 geometry_info.sigma,exception);
2717 if (LocaleCompare("shave",option+1) == 0)
2720 Shave the image edges.
2722 (void) SyncImageSettings(mogrify_info,*image,exception);
2723 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2724 mogrify_image=ShaveImage(*image,&geometry,exception);
2727 if (LocaleCompare("shear",option+1) == 0)
2732 (void) SyncImageSettings(mogrify_info,*image,exception);
2733 flags=ParseGeometry(argv[i+1],&geometry_info);
2734 if ((flags & SigmaValue) == 0)
2735 geometry_info.sigma=geometry_info.rho;
2736 mogrify_image=ShearImage(*image,geometry_info.rho,
2737 geometry_info.sigma,exception);
2740 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2743 Sigmoidal non-linearity contrast control.
2745 (void) SyncImageSettings(mogrify_info,*image,exception);
2746 flags=ParseGeometry(argv[i+1],&geometry_info);
2747 if ((flags & SigmaValue) == 0)
2748 geometry_info.sigma=(double) QuantumRange/2.0;
2749 if ((flags & PercentValue) != 0)
2750 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2752 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2753 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2757 if (LocaleCompare("sketch",option+1) == 0)
2762 (void) SyncImageSettings(mogrify_info,*image,exception);
2763 flags=ParseGeometry(argv[i+1],&geometry_info);
2764 if ((flags & SigmaValue) == 0)
2765 geometry_info.sigma=1.0;
2766 mogrify_image=SketchImage(*image,geometry_info.rho,
2767 geometry_info.sigma,geometry_info.xi,exception);
2770 if (LocaleCompare("solarize",option+1) == 0)
2775 (void) SyncImageSettings(mogrify_info,*image,exception);
2776 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2778 (void) SolarizeImage(*image,threshold,exception);
2781 if (LocaleCompare("sparse-color",option+1) == 0)
2790 Sparse Color Interpolated Gradient
2792 (void) SyncImageSettings(mogrify_info,*image,exception);
2793 method=(SparseColorMethod) ParseCommandOption(
2794 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2795 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2797 if (arguments == (char *) NULL)
2799 mogrify_image=SparseColorOption(*image,method,arguments,
2800 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2801 arguments=DestroyString(arguments);
2804 if (LocaleCompare("splice",option+1) == 0)
2807 Splice a solid color into the image.
2809 (void) SyncImageSettings(mogrify_info,*image,exception);
2810 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2811 mogrify_image=SpliceImage(*image,&geometry,exception);
2814 if (LocaleCompare("spread",option+1) == 0)
2819 (void) SyncImageSettings(mogrify_info,*image,exception);
2820 (void) ParseGeometry(argv[i+1],&geometry_info);
2821 mogrify_image=SpreadImage(*image,geometry_info.rho,
2822 interpolate_method,exception);
2825 if (LocaleCompare("statistic",option+1) == 0)
2830 (void) SyncImageSettings(mogrify_info,*image,exception);
2831 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2832 MagickFalse,argv[i+1]);
2833 (void) ParseGeometry(argv[i+2],&geometry_info);
2834 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2835 (size_t) geometry_info.sigma,exception);
2838 if (LocaleCompare("stretch",option+1) == 0)
2842 draw_info->stretch=UndefinedStretch;
2845 draw_info->stretch=(StretchType) ParseCommandOption(
2846 MagickStretchOptions,MagickFalse,argv[i+1]);
2849 if (LocaleCompare("strip",option+1) == 0)
2852 Strip image of profiles and comments.
2854 (void) SyncImageSettings(mogrify_info,*image,exception);
2855 (void) StripImage(*image,exception);
2858 if (LocaleCompare("stroke",option+1) == 0)
2868 (void) QueryColorCompliance("none",AllCompliance,
2869 &draw_info->stroke,exception);
2870 if (draw_info->stroke_pattern != (Image *) NULL)
2871 draw_info->stroke_pattern=DestroyImage(
2872 draw_info->stroke_pattern);
2875 sans=AcquireExceptionInfo();
2876 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2877 sans=DestroyExceptionInfo(sans);
2878 if (status == MagickFalse)
2879 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2882 draw_info->stroke=color;
2885 if (LocaleCompare("strokewidth",option+1) == 0)
2887 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2890 if (LocaleCompare("style",option+1) == 0)
2894 draw_info->style=UndefinedStyle;
2897 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2898 MagickFalse,argv[i+1]);
2901 if (LocaleCompare("swirl",option+1) == 0)
2906 (void) SyncImageSettings(mogrify_info,*image,exception);
2907 (void) ParseGeometry(argv[i+1],&geometry_info);
2908 mogrify_image=SwirlImage(*image,geometry_info.rho,
2909 interpolate_method,exception);
2916 if (LocaleCompare("threshold",option+1) == 0)
2924 (void) SyncImageSettings(mogrify_info,*image,exception);
2926 threshold=(double) QuantumRange/2;
2928 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2930 (void) BilevelImage(*image,threshold,exception);
2933 if (LocaleCompare("thumbnail",option+1) == 0)
2938 (void) SyncImageSettings(mogrify_info,*image,exception);
2939 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2940 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2944 if (LocaleCompare("tile",option+1) == 0)
2948 if (draw_info->fill_pattern != (Image *) NULL)
2949 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2952 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2956 if (LocaleCompare("tint",option+1) == 0)
2961 (void) SyncImageSettings(mogrify_info,*image,exception);
2962 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2965 if (LocaleCompare("transform",option+1) == 0)
2968 Affine transform image.
2970 (void) SyncImageSettings(mogrify_info,*image,exception);
2971 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2975 if (LocaleCompare("transparent",option+1) == 0)
2980 (void) SyncImageSettings(mogrify_info,*image,exception);
2981 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2983 (void) TransparentPaintImage(*image,&target,(Quantum)
2984 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2988 if (LocaleCompare("transpose",option+1) == 0)
2991 Transpose image scanlines.
2993 (void) SyncImageSettings(mogrify_info,*image,exception);
2994 mogrify_image=TransposeImage(*image,exception);
2997 if (LocaleCompare("transverse",option+1) == 0)
3000 Transverse image scanlines.
3002 (void) SyncImageSettings(mogrify_info,*image,exception);
3003 mogrify_image=TransverseImage(*image,exception);
3006 if (LocaleCompare("treedepth",option+1) == 0)
3008 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3011 if (LocaleCompare("trim",option+1) == 0)
3016 (void) SyncImageSettings(mogrify_info,*image,exception);
3017 mogrify_image=TrimImage(*image,exception);
3020 if (LocaleCompare("type",option+1) == 0)
3025 (void) SyncImageSettings(mogrify_info,*image,exception);
3029 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3031 (*image)->type=UndefinedType;
3032 (void) SetImageType(*image,type,exception);
3039 if (LocaleCompare("undercolor",option+1) == 0)
3041 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3042 &draw_info->undercolor,exception);
3045 if (LocaleCompare("unique",option+1) == 0)
3049 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3052 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3053 (void) SetImageArtifact(*image,"verbose","true");
3056 if (LocaleCompare("unique-colors",option+1) == 0)
3059 Unique image colors.
3061 (void) SyncImageSettings(mogrify_info,*image,exception);
3062 mogrify_image=UniqueImageColors(*image,exception);
3065 if (LocaleCompare("unsharp",option+1) == 0)
3070 (void) SyncImageSettings(mogrify_info,*image,exception);
3071 flags=ParseGeometry(argv[i+1],&geometry_info);
3072 if ((flags & SigmaValue) == 0)
3073 geometry_info.sigma=1.0;
3074 if ((flags & XiValue) == 0)
3075 geometry_info.xi=1.0;
3076 if ((flags & PsiValue) == 0)
3077 geometry_info.psi=0.05;
3078 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3079 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3087 if (LocaleCompare("verbose",option+1) == 0)
3089 (void) SetImageArtifact(*image,option+1,
3090 *option == '+' ? "false" : "true");
3093 if (LocaleCompare("vignette",option+1) == 0)
3098 (void) SyncImageSettings(mogrify_info,*image,exception);
3099 flags=ParseGeometry(argv[i+1],&geometry_info);
3100 if ((flags & SigmaValue) == 0)
3101 geometry_info.sigma=1.0;
3102 if ((flags & XiValue) == 0)
3103 geometry_info.xi=0.1*(*image)->columns;
3104 if ((flags & PsiValue) == 0)
3105 geometry_info.psi=0.1*(*image)->rows;
3106 if ((flags & PercentValue) != 0)
3108 geometry_info.xi*=(double) (*image)->columns/100.0;
3109 geometry_info.psi*=(double) (*image)->rows/100.0;
3111 mogrify_image=VignetteImage(*image,geometry_info.rho,
3112 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3113 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3116 if (LocaleCompare("virtual-pixel",option+1) == 0)
3120 (void) SetImageVirtualPixelMethod(*image,
3121 UndefinedVirtualPixelMethod,exception);
3124 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3125 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3126 argv[i+1]),exception);
3133 if (LocaleCompare("wave",option+1) == 0)
3138 (void) SyncImageSettings(mogrify_info,*image,exception);
3139 flags=ParseGeometry(argv[i+1],&geometry_info);
3140 if ((flags & SigmaValue) == 0)
3141 geometry_info.sigma=1.0;
3142 mogrify_image=WaveImage(*image,geometry_info.rho,
3143 geometry_info.sigma,interpolate_method,exception);
3146 if (LocaleCompare("weight",option+1) == 0)
3148 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3149 if (LocaleCompare(argv[i+1],"all") == 0)
3150 draw_info->weight=0;
3151 if (LocaleCompare(argv[i+1],"bold") == 0)
3152 draw_info->weight=700;
3153 if (LocaleCompare(argv[i+1],"bolder") == 0)
3154 if (draw_info->weight <= 800)
3155 draw_info->weight+=100;
3156 if (LocaleCompare(argv[i+1],"lighter") == 0)
3157 if (draw_info->weight >= 100)
3158 draw_info->weight-=100;
3159 if (LocaleCompare(argv[i+1],"normal") == 0)
3160 draw_info->weight=400;
3163 if (LocaleCompare("white-threshold",option+1) == 0)
3166 White threshold image.
3168 (void) SyncImageSettings(mogrify_info,*image,exception);
3169 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3178 Replace current image with any image that was generated
3180 if (mogrify_image != (Image *) NULL)
3181 ReplaceImageInListReturnLast(image,mogrify_image);
3184 if (region_image != (Image *) NULL)
3187 Composite transformed region onto image.
3189 (void) SyncImageSettings(mogrify_info,*image,exception);
3190 (void) CompositeImage(region_image,*image,
3191 region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp :
3192 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3194 *image=DestroyImage(*image);
3195 *image=region_image;
3196 region_image = (Image *) NULL;
3201 quantize_info=DestroyQuantizeInfo(quantize_info);
3202 draw_info=DestroyDrawInfo(draw_info);
3203 mogrify_info=DestroyImageInfo(mogrify_info);
3204 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3205 return(status == 0 ? MagickFalse : MagickTrue);
3209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3213 + M o g r i f y I m a g e C o m m a n d %
3217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3219 % MogrifyImageCommand() transforms an image or a sequence of images. These
3220 % transforms include image scaling, image rotation, color reduction, and
3221 % others. The transmogrified image overwrites the original image.
3223 % The format of the MogrifyImageCommand method is:
3225 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3226 % const char **argv,char **metadata,ExceptionInfo *exception)
3228 % A description of each parameter follows:
3230 % o image_info: the image info.
3232 % o argc: the number of elements in the argument vector.
3234 % o argv: A text array containing the command line arguments.
3236 % o metadata: any metadata is returned here.
3238 % o exception: return any errors or warnings in this structure.
3242 static MagickBooleanType MogrifyUsage(void)
3245 *channel_operators[]=
3247 "-channel-fx expression",
3248 " exchange, extract, or transfer one or more image channels",
3249 "-separate separate an image channel into a grayscale image",
3254 "-debug events display copious debugging information",
3255 "-distribute-cache port",
3256 " distributed pixel cache spanning one or more servers",
3257 "-help print program options",
3258 "-list type print a list of supported option arguments",
3259 "-log format format of debugging information",
3260 "-version print version information",
3265 "-adaptive-blur geometry",
3266 " adaptively blur pixels; decrease effect near edges",
3267 "-adaptive-resize geometry",
3268 " adaptively resize image using 'mesh' interpolation",
3269 "-adaptive-sharpen geometry",
3270 " adaptively sharpen pixels; increase effect near edges",
3271 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3272 " transparent, extract, background, or shape",
3273 "-annotate geometry text",
3274 " annotate the image with text",
3275 "-auto-gamma automagically adjust gamma level of image",
3276 "-auto-level automagically adjust color levels of image",
3277 "-auto-orient automagically orient (rotate) image",
3278 "-bench iterations measure performance",
3279 "-black-threshold value",
3280 " force all pixels below the threshold into black",
3281 "-blue-shift simulate a scene at nighttime in the moonlight",
3282 "-blur geometry reduce image noise and reduce detail levels",
3283 "-border geometry surround image with a border of color",
3284 "-bordercolor color border color",
3285 "-brightness-contrast geometry",
3286 " improve brightness / contrast of the image",
3287 "-cdl filename color correct with a color decision list",
3288 "-charcoal geometry simulate a charcoal drawing",
3289 "-chop geometry remove pixels from the image interior",
3290 "-clamp keep pixel values in range (0-QuantumRange)",
3291 "-clip clip along the first path from the 8BIM profile",
3292 "-clip-mask filename associate a clip mask with the image",
3293 "-clip-path id clip along a named path from the 8BIM profile",
3294 "-colorize value colorize the image with the fill color",
3295 "-color-matrix matrix apply color correction to the image",
3296 "-contrast enhance or reduce the image contrast",
3297 "-contrast-stretch geometry",
3298 " improve contrast by 'stretching' the intensity range",
3299 "-convolve coefficients",
3300 " apply a convolution kernel to the image",
3301 "-cycle amount cycle the image colormap",
3302 "-decipher filename convert cipher pixels to plain pixels",
3303 "-deskew threshold straighten an image",
3304 "-despeckle reduce the speckles within an image",
3305 "-distort method args",
3306 " distort images according to given method ad args",
3307 "-draw string annotate the image with a graphic primitive",
3308 "-edge radius apply a filter to detect edges in the image",
3309 "-encipher filename convert plain pixels to cipher pixels",
3310 "-emboss radius emboss an image",
3311 "-enhance apply a digital filter to enhance a noisy image",
3312 "-equalize perform histogram equalization to an image",
3313 "-evaluate operator value",
3314 " evaluate an arithmetic, relational, or logical expression",
3315 "-extent geometry set the image size",
3316 "-extract geometry extract area from image",
3317 "-fft implements the discrete Fourier transform (DFT)",
3318 "-flip flip image vertically",
3319 "-floodfill geometry color",
3320 " floodfill the image with color",
3321 "-flop flop image horizontally",
3322 "-frame geometry surround image with an ornamental border",
3323 "-function name parameters",
3324 " apply function over image values",
3325 "-gamma value level of gamma correction",
3326 "-gaussian-blur geometry",
3327 " reduce image noise and reduce detail levels",
3328 "-geometry geometry preferred size or location of the image",
3329 "-grayscale method convert image to grayscale",
3330 "-identify identify the format and characteristics of the image",
3331 "-ift implements the inverse discrete Fourier transform (DFT)",
3332 "-implode amount implode image pixels about the center",
3333 "-interpolative-resize geometry",
3334 " resize image using interpolation",
3335 "-lat geometry local adaptive thresholding",
3336 "-level value adjust the level of image contrast",
3337 "-level-colors color,color",
3338 " level image with the given colors",
3339 "-linear-stretch geometry",
3340 " improve contrast by 'stretching with saturation'",
3341 "-liquid-rescale geometry",
3342 " rescale image with seam-carving",
3343 "-magnify double the size of the image with pixel art scaling",
3344 "-median geometry apply a median filter to the image",
3345 "-mode geometry make each pixel the 'predominant color' of the",
3347 "-modulate value vary the brightness, saturation, and hue",
3348 "-monochrome transform image to black and white",
3349 "-morphology method kernel",
3350 " apply a morphology method to the image",
3351 "-motion-blur geometry",
3352 " simulate motion blur",
3353 "-negate replace every pixel with its complementary color ",
3354 "-noise geometry add or reduce noise in an image",
3355 "-normalize transform image to span the full range of colors",
3356 "-opaque color change this color to the fill color",
3357 "-ordered-dither NxN",
3358 " add a noise pattern to the image with specific",
3360 "-paint radius simulate an oil painting",
3361 "-perceptible epsilon",
3362 " pixel value less than |epsilon| become epsilon or",
3364 "-polaroid angle simulate a Polaroid picture",
3365 "-posterize levels reduce the image to a limited number of color levels",
3366 "-profile filename add, delete, or apply an image profile",
3367 "-quantize colorspace reduce colors in this colorspace",
3368 "-radial-blur angle radial blur the image",
3369 "-raise value lighten/darken image edges to create a 3-D effect",
3370 "-random-threshold low,high",
3371 " random threshold the image",
3372 "-region geometry apply options to a portion of the image",
3373 "-render render vector graphics",
3374 "-repage geometry size and location of an image canvas",
3375 "-resample geometry change the resolution of an image",
3376 "-resize geometry resize the image",
3377 "-roll geometry roll an image vertically or horizontally",
3378 "-rotate degrees apply Paeth rotation to the image",
3379 "-sample geometry scale image with pixel sampling",
3380 "-scale geometry scale the image",
3381 "-segment values segment an image",
3382 "-selective-blur geometry",
3383 " selectively blur pixels within a contrast threshold",
3384 "-sepia-tone threshold",
3385 " simulate a sepia-toned photo",
3386 "-set property value set an image property",
3387 "-shade degrees shade the image using a distant light source",
3388 "-shadow geometry simulate an image shadow",
3389 "-sharpen geometry sharpen the image",
3390 "-shave geometry shave pixels from the image edges",
3391 "-shear geometry slide one edge of the image along the X or Y axis",
3392 "-sigmoidal-contrast geometry",
3393 " increase the contrast without saturating highlights or",
3395 "-sketch geometry simulate a pencil sketch",
3396 "-solarize threshold negate all pixels above the threshold level",
3397 "-sparse-color method args",
3398 " fill in a image based on a few color points",
3399 "-splice geometry splice the background color into the image",
3400 "-spread radius displace image pixels by a random amount",
3401 "-statistic type radius",
3402 " replace each pixel with corresponding statistic from the neighborhood",
3403 "-strip strip image of all profiles and comments",
3404 "-swirl degrees swirl image pixels about the center",
3405 "-threshold value threshold the image",
3406 "-thumbnail geometry create a thumbnail of the image",
3407 "-tile filename tile image when filling a graphic primitive",
3408 "-tint value tint the image with the fill color",
3409 "-transform affine transform image",
3410 "-transparent color make this color transparent within the image",
3411 "-transpose flip image vertically and rotate 90 degrees",
3412 "-transverse flop image horizontally and rotate 270 degrees",
3413 "-trim trim image edges",
3414 "-type type image type",
3415 "-unique-colors discard all but one of any pixel color",
3416 "-unsharp geometry sharpen the image",
3417 "-vignette geometry soften the edges of the image in vignette style",
3418 "-wave geometry alter an image along a sine wave",
3419 "-white-threshold value",
3420 " force all pixels above the threshold into white",
3423 *sequence_operators[]=
3425 "-affinity filename transform image colors to match this set of colors",
3426 "-append append an image sequence",
3427 "-clut apply a color lookup table to the image",
3428 "-coalesce merge a sequence of images",
3429 "-combine combine a sequence of images",
3430 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3431 "-complex operator perform complex mathematics on an image sequence",
3432 "-composite composite image",
3433 "-crop geometry cut out a rectangular region of the image",
3434 "-deconstruct break down an image sequence into constituent parts",
3435 "-evaluate-sequence operator",
3436 " evaluate an arithmetic, relational, or logical expression",
3437 "-flatten flatten a sequence of images",
3438 "-fx expression apply mathematical expression to an image channel(s)",
3439 "-hald-clut apply a Hald color lookup table to the image",
3440 "-layers method optimize, merge, or compare image layers",
3441 "-morph value morph an image sequence",
3442 "-mosaic create a mosaic from an image sequence",
3443 "-poly terms build a polynomial from the image sequence and the corresponding",
3444 " terms (coefficients and degree pairs).",
3445 "-print string interpret string and print to console",
3446 "-process arguments process the image with a custom image filter",
3447 "-smush geometry smush an image sequence together",
3448 "-write filename write images to this file",
3453 "-adjoin join images into a single multi-image file",
3454 "-affine matrix affine transform matrix",
3455 "-alpha option activate, deactivate, reset, or set the alpha channel",
3456 "-antialias remove pixel-aliasing",
3457 "-authenticate password",
3458 " decipher image with this password",
3459 "-attenuate value lessen (or intensify) when adding noise to an image",
3460 "-background color background color",
3461 "-bias value add bias when convolving an image",
3462 "-black-point-compensation",
3463 " use black point compensation",
3464 "-blue-primary point chromaticity blue primary point",
3465 "-bordercolor color border color",
3466 "-caption string assign a caption to an image",
3467 "-channel type apply option to select image channels",
3468 "-colors value preferred number of colors in the image",
3469 "-colorspace type alternate image colorspace",
3470 "-comment string annotate image with comment",
3471 "-compose operator set image composite operator",
3472 "-compress type type of pixel compression when writing the image",
3473 "-define format:option=value",
3474 " define one or more image format options",
3475 "-delay value display the next image after pausing",
3476 "-density geometry horizontal and vertical density of the image",
3477 "-depth value image depth",
3478 "-direction type render text right-to-left or left-to-right",
3479 "-display server get image or font from this X server",
3480 "-dispose method layer disposal method",
3481 "-dither method apply error diffusion to image",
3482 "-encoding type text encoding type",
3483 "-endian type endianness (MSB or LSB) of the image",
3484 "-family name render text with this font family",
3485 "-features distance analyze image features (e.g. contrast, correlation)",
3486 "-fill color color to use when filling a graphic primitive",
3487 "-filter type use this filter when resizing an image",
3488 "-font name render text with this font",
3489 "-format \"string\" output formatted image characteristics",
3490 "-fuzz distance colors within this distance are considered equal",
3491 "-gravity type horizontal and vertical text placement",
3492 "-green-primary point chromaticity green primary point",
3493 "-intensity method method to generate an intensity value from a pixel",
3494 "-intent type type of rendering intent when managing the image color",
3495 "-interlace type type of image interlacing scheme",
3496 "-interline-spacing value",
3497 " set the space between two text lines",
3498 "-interpolate method pixel color interpolation method",
3499 "-interword-spacing value",
3500 " set the space between two words",
3501 "-kerning value set the space between two letters",
3502 "-label string assign a label to an image",
3503 "-limit type value pixel cache resource limit",
3504 "-loop iterations add Netscape loop extension to your GIF animation",
3505 "-mask filename associate a mask with the image",
3506 "-matte store matte channel if the image has one",
3507 "-mattecolor color frame color",
3508 "-monitor monitor progress",
3509 "-orient type image orientation",
3510 "-page geometry size and location of an image canvas (setting)",
3511 "-path path write images to this path on disk",
3512 "-ping efficiently determine image attributes",
3513 "-pointsize value font point size",
3514 "-precision value maximum number of significant digits to print",
3515 "-preview type image preview type",
3516 "-quality value JPEG/MIFF/PNG compression level",
3517 "-quiet suppress all warning messages",
3518 "-red-primary point chromaticity red primary point",
3519 "-regard-warnings pay attention to warning messages",
3520 "-remap filename transform image colors to match this set of colors",
3521 "-respect-parentheses settings remain in effect until parenthesis boundary",
3522 "-sampling-factor geometry",
3523 " horizontal and vertical sampling factor",
3524 "-scene value image scene number",
3525 "-seed value seed a new sequence of pseudo-random numbers",
3526 "-size geometry width and height of image",
3527 "-stretch type render text with this font stretch",
3528 "-stroke color graphic primitive stroke color",
3529 "-strokewidth value graphic primitive stroke width",
3530 "-style type render text with this font style",
3531 "-synchronize synchronize image to storage device",
3532 "-taint declare the image as modified",
3533 "-texture filename name of texture to tile onto the image background",
3534 "-tile-offset geometry",
3536 "-treedepth value color tree depth",
3537 "-transparent-color color",
3538 " transparent color",
3539 "-undercolor color annotation bounding box color",
3540 "-units type the units of image resolution",
3541 "-verbose print detailed information about the image",
3542 "-view FlashPix viewing transforms",
3543 "-virtual-pixel method",
3544 " virtual pixel access method",
3545 "-weight type render text with this font weight",
3546 "-white-point point chromaticity white point",
3551 "-delete indexes delete the image from the image sequence",
3552 "-duplicate count,indexes",
3553 " duplicate an image one or more times",
3554 "-insert index insert last image into the image sequence",
3555 "-reverse reverse image sequence",
3556 "-swap indexes swap two images in the image sequence",
3563 ListMagickVersion(stdout);
3564 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3566 (void) printf("\nImage Settings:\n");
3567 for (p=settings; *p != (char *) NULL; p++)
3568 (void) printf(" %s\n",*p);
3569 (void) printf("\nImage Operators:\n");
3570 for (p=operators; *p != (char *) NULL; p++)
3571 (void) printf(" %s\n",*p);
3572 (void) printf("\nImage Channel Operators:\n");
3573 for (p=channel_operators; *p != (char *) NULL; p++)
3574 (void) printf(" %s\n",*p);
3575 (void) printf("\nImage Sequence Operators:\n");
3576 for (p=sequence_operators; *p != (char *) NULL; p++)
3577 (void) printf(" %s\n",*p);
3578 (void) printf("\nImage Stack Operators:\n");
3579 for (p=stack_operators; *p != (char *) NULL; p++)
3580 (void) printf(" %s\n",*p);
3581 (void) printf("\nMiscellaneous Options:\n");
3582 for (p=miscellaneous; *p != (char *) NULL; p++)
3583 (void) printf(" %s\n",*p);
3585 "\nBy default, the image format of 'file' is determined by its magic\n");
3587 "number. To specify a particular image format, precede the filename\n");
3589 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3591 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3592 (void) printf("'-' for standard input or output.\n");
3593 return(MagickFalse);
3596 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3597 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3599 #define DestroyMogrify() \
3601 if (format != (char *) NULL) \
3602 format=DestroyString(format); \
3603 if (path != (char *) NULL) \
3604 path=DestroyString(path); \
3605 DestroyImageStack(); \
3606 for (i=0; i < (ssize_t) argc; i++) \
3607 argv[i]=DestroyString(argv[i]); \
3608 argv=(char **) RelinquishMagickMemory(argv); \
3610 #define ThrowMogrifyException(asperity,tag,option) \
3612 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3615 return(MagickFalse); \
3617 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3619 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3620 "InvalidArgument","'%s': %s",argument,option); \
3622 return(MagickFalse); \
3634 image_stack[MaxImageStackDepth+1];
3642 respect_parenthesis;
3657 assert(image_info != (ImageInfo *) NULL);
3658 assert(image_info->signature == MagickSignature);
3659 if (image_info->debug != MagickFalse)
3660 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3661 assert(exception != (ExceptionInfo *) NULL);
3665 if ((LocaleCompare("version",option+1) == 0) ||
3666 (LocaleCompare("-version",option+1) == 0))
3668 ListMagickVersion(stdout);
3669 return(MagickFalse);
3673 return(MogrifyUsage());
3674 format=(char *) NULL;
3676 global_colormap=MagickFalse;
3680 option=(char *) NULL;
3682 respect_parenthesis=MagickFalse;
3687 ReadCommandlLine(argc,&argv);
3688 status=ExpandFilenames(&argc,&argv);
3689 if (status == MagickFalse)
3690 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3691 GetExceptionMessage(errno));
3692 for (i=1; i < (ssize_t) argc; i++)
3695 if (LocaleCompare(option,"(") == 0)
3697 FireImageStack(MagickFalse,MagickTrue,pend);
3698 if (k == MaxImageStackDepth)
3699 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3704 if (LocaleCompare(option,")") == 0)
3706 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3708 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3712 if (IsCommandOption(option) == MagickFalse)
3715 backup_filename[MaxTextExtent],
3722 Option is a file name: begin by reading image from specified file.
3724 FireImageStack(MagickFalse,MagickFalse,pend);
3726 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3728 images=ReadImages(image_info,filename,exception);
3729 status&=(images != (Image *) NULL) &&
3730 (exception->severity < ErrorException);
3731 if (images == (Image *) NULL)
3733 if (format != (char *) NULL)
3734 (void) CopyMagickString(images->filename,images->magick_filename,
3736 if (path != (char *) NULL)
3738 GetPathComponent(option,TailPath,filename);
3739 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3740 path,*DirectorySeparator,filename);
3742 if (format != (char *) NULL)
3743 AppendImageFormat(format,images->filename);
3744 AppendImageStack(images);
3745 FinalizeImageSettings(image_info,image,MagickFalse);
3746 if (global_colormap != MagickFalse)
3751 quantize_info=AcquireQuantizeInfo(image_info);
3752 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3753 quantize_info=DestroyQuantizeInfo(quantize_info);
3755 *backup_filename='\0';
3756 if ((LocaleCompare(image->filename,"-") != 0) &&
3757 (IsPathWritable(image->filename) != MagickFalse))
3763 Rename image file as backup.
3765 (void) CopyMagickString(backup_filename,image->filename,
3767 for (i=0; i < 6; i++)
3769 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3770 if (IsPathAccessible(backup_filename) == MagickFalse)
3773 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3774 (rename_utf8(image->filename,backup_filename) != 0))
3775 *backup_filename='\0';
3778 Write transmogrified image to disk.
3780 image_info->synchronize=MagickTrue;
3781 status&=WriteImages(image_info,image,image->filename,exception);
3782 if ((status == MagickFalse) && (*backup_filename != '\0'))
3783 (void) remove_utf8(backup_filename);
3784 RemoveAllImageStack();
3787 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3788 switch (*(option+1))
3792 if (LocaleCompare("adaptive-blur",option+1) == 0)
3795 if (i == (ssize_t) argc)
3796 ThrowMogrifyException(OptionError,"MissingArgument",option);
3797 if (IsGeometry(argv[i]) == MagickFalse)
3798 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3801 if (LocaleCompare("adaptive-resize",option+1) == 0)
3804 if (i == (ssize_t) argc)
3805 ThrowMogrifyException(OptionError,"MissingArgument",option);
3806 if (IsGeometry(argv[i]) == MagickFalse)
3807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3810 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3813 if (i == (ssize_t) argc)
3814 ThrowMogrifyException(OptionError,"MissingArgument",option);
3815 if (IsGeometry(argv[i]) == MagickFalse)
3816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3819 if (LocaleCompare("affine",option+1) == 0)
3824 if (i == (ssize_t) argc)
3825 ThrowMogrifyException(OptionError,"MissingArgument",option);
3828 if (LocaleCompare("alpha",option+1) == 0)
3836 if (i == (ssize_t) argc)
3837 ThrowMogrifyException(OptionError,"MissingArgument",option);
3838 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
3840 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
3844 if (LocaleCompare("annotate",option+1) == 0)
3849 if (i == (ssize_t) argc)
3850 ThrowMogrifyException(OptionError,"MissingArgument",option);
3851 if (IsGeometry(argv[i]) == MagickFalse)
3852 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3853 if (i == (ssize_t) argc)
3854 ThrowMogrifyException(OptionError,"MissingArgument",option);
3858 if (LocaleCompare("antialias",option+1) == 0)
3860 if (LocaleCompare("append",option+1) == 0)
3862 if (LocaleCompare("attenuate",option+1) == 0)
3867 if (i == (ssize_t) (argc-1))
3868 ThrowMogrifyException(OptionError,"MissingArgument",option);
3869 if (IsGeometry(argv[i]) == MagickFalse)
3870 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3873 if (LocaleCompare("authenticate",option+1) == 0)
3878 if (i == (ssize_t) argc)
3879 ThrowMogrifyException(OptionError,"MissingArgument",option);
3882 if (LocaleCompare("auto-gamma",option+1) == 0)
3884 if (LocaleCompare("auto-level",option+1) == 0)
3886 if (LocaleCompare("auto-orient",option+1) == 0)
3888 if (LocaleCompare("average",option+1) == 0)
3890 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3894 if (LocaleCompare("background",option+1) == 0)
3899 if (i == (ssize_t) argc)
3900 ThrowMogrifyException(OptionError,"MissingArgument",option);
3903 if (LocaleCompare("bias",option+1) == 0)
3908 if (i == (ssize_t) (argc-1))
3909 ThrowMogrifyException(OptionError,"MissingArgument",option);
3910 if (IsGeometry(argv[i]) == MagickFalse)
3911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3914 if (LocaleCompare("black-point-compensation",option+1) == 0)
3916 if (LocaleCompare("black-threshold",option+1) == 0)
3921 if (i == (ssize_t) argc)
3922 ThrowMogrifyException(OptionError,"MissingArgument",option);
3923 if (IsGeometry(argv[i]) == MagickFalse)
3924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3927 if (LocaleCompare("blue-primary",option+1) == 0)
3932 if (i == (ssize_t) argc)
3933 ThrowMogrifyException(OptionError,"MissingArgument",option);
3934 if (IsGeometry(argv[i]) == MagickFalse)
3935 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3938 if (LocaleCompare("blue-shift",option+1) == 0)
3941 if (i == (ssize_t) argc)
3942 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (IsGeometry(argv[i]) == MagickFalse)
3944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3947 if (LocaleCompare("blur",option+1) == 0)
3950 if (i == (ssize_t) argc)
3951 ThrowMogrifyException(OptionError,"MissingArgument",option);
3952 if (IsGeometry(argv[i]) == MagickFalse)
3953 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3956 if (LocaleCompare("border",option+1) == 0)
3961 if (i == (ssize_t) argc)
3962 ThrowMogrifyException(OptionError,"MissingArgument",option);
3963 if (IsGeometry(argv[i]) == MagickFalse)
3964 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3967 if (LocaleCompare("bordercolor",option+1) == 0)
3972 if (i == (ssize_t) argc)
3973 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (LocaleCompare("box",option+1) == 0)
3981 if (i == (ssize_t) argc)
3982 ThrowMogrifyException(OptionError,"MissingArgument",option);
3985 if (LocaleCompare("brightness-contrast",option+1) == 0)
3988 if (i == (ssize_t) argc)
3989 ThrowMogrifyException(OptionError,"MissingArgument",option);
3990 if (IsGeometry(argv[i]) == MagickFalse)
3991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3994 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3998 if (LocaleCompare("cache",option+1) == 0)
4003 if (i == (ssize_t) argc)
4004 ThrowMogrifyException(OptionError,"MissingArgument",option);
4005 if (IsGeometry(argv[i]) == MagickFalse)
4006 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4009 if (LocaleCompare("caption",option+1) == 0)
4014 if (i == (ssize_t) argc)
4015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4018 if (LocaleCompare("channel",option+1) == 0)
4026 if (i == (ssize_t) (argc-1))
4027 ThrowMogrifyException(OptionError,"MissingArgument",option);
4028 channel=ParseChannelOption(argv[i]);
4030 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4034 if (LocaleCompare("channel-fx",option+1) == 0)
4042 if (i == (ssize_t) (argc-1))
4043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4044 channel=ParsePixelChannelOption(argv[i]);
4046 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4050 if (LocaleCompare("cdl",option+1) == 0)
4055 if (i == (ssize_t) (argc-1))
4056 ThrowMogrifyException(OptionError,"MissingArgument",option);
4059 if (LocaleCompare("charcoal",option+1) == 0)
4064 if (i == (ssize_t) argc)
4065 ThrowMogrifyException(OptionError,"MissingArgument",option);
4066 if (IsGeometry(argv[i]) == MagickFalse)
4067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4070 if (LocaleCompare("chop",option+1) == 0)
4075 if (i == (ssize_t) argc)
4076 ThrowMogrifyException(OptionError,"MissingArgument",option);
4077 if (IsGeometry(argv[i]) == MagickFalse)
4078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4081 if (LocaleCompare("clamp",option+1) == 0)
4083 if (LocaleCompare("clip",option+1) == 0)
4085 if (LocaleCompare("clip-mask",option+1) == 0)
4090 if (i == (ssize_t) argc)
4091 ThrowMogrifyException(OptionError,"MissingArgument",option);
4094 if (LocaleCompare("clut",option+1) == 0)
4096 if (LocaleCompare("coalesce",option+1) == 0)
4098 if (LocaleCompare("colorize",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("color-matrix",option+1) == 0)
4117 if (i == (ssize_t) (argc-1))
4118 ThrowMogrifyException(OptionError,"MissingArgument",option);
4119 kernel_info=AcquireKernelInfo(argv[i]);
4120 if (kernel_info == (KernelInfo *) NULL)
4121 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4122 kernel_info=DestroyKernelInfo(kernel_info);
4125 if (LocaleCompare("colors",option+1) == 0)
4130 if (i == (ssize_t) argc)
4131 ThrowMogrifyException(OptionError,"MissingArgument",option);
4132 if (IsGeometry(argv[i]) == MagickFalse)
4133 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4136 if (LocaleCompare("colorspace",option+1) == 0)
4144 if (i == (ssize_t) argc)
4145 ThrowMogrifyException(OptionError,"MissingArgument",option);
4146 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4149 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4153 if (LocaleCompare("combine",option+1) == 0)
4161 if (i == (ssize_t) argc)
4162 ThrowMogrifyException(OptionError,"MissingArgument",option);
4163 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4166 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4170 if (LocaleCompare("compare",option+1) == 0)
4172 if (LocaleCompare("comment",option+1) == 0)
4177 if (i == (ssize_t) argc)
4178 ThrowMogrifyException(OptionError,"MissingArgument",option);
4181 if (LocaleCompare("composite",option+1) == 0)
4183 if (LocaleCompare("compress",option+1) == 0)
4191 if (i == (ssize_t) argc)
4192 ThrowMogrifyException(OptionError,"MissingArgument",option);
4193 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4196 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4200 if (LocaleCompare("concurrent",option+1) == 0)
4202 if (LocaleCompare("contrast",option+1) == 0)
4204 if (LocaleCompare("contrast-stretch",option+1) == 0)
4207 if (i == (ssize_t) argc)
4208 ThrowMogrifyException(OptionError,"MissingArgument",option);
4209 if (IsGeometry(argv[i]) == MagickFalse)
4210 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4213 if (LocaleCompare("convolve",option+1) == 0)
4221 if (i == (ssize_t) argc)
4222 ThrowMogrifyException(OptionError,"MissingArgument",option);
4223 kernel_info=AcquireKernelInfo(argv[i]);
4224 if (kernel_info == (KernelInfo *) NULL)
4225 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4226 kernel_info=DestroyKernelInfo(kernel_info);
4229 if (LocaleCompare("crop",option+1) == 0)
4234 if (i == (ssize_t) argc)
4235 ThrowMogrifyException(OptionError,"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4240 if (LocaleCompare("cycle",option+1) == 0)
4245 if (i == (ssize_t) argc)
4246 ThrowMogrifyException(OptionError,"MissingArgument",option);
4247 if (IsGeometry(argv[i]) == MagickFalse)
4248 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4251 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4255 if (LocaleCompare("decipher",option+1) == 0)
4260 if (i == (ssize_t) (argc-1))
4261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4264 if (LocaleCompare("deconstruct",option+1) == 0)
4266 if (LocaleCompare("debug",option+1) == 0)
4274 if (i == (ssize_t) argc)
4275 ThrowMogrifyException(OptionError,"MissingArgument",option);
4276 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4278 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4280 (void) SetLogEventMask(argv[i]);
4283 if (LocaleCompare("define",option+1) == 0)
4286 if (i == (ssize_t) argc)
4287 ThrowMogrifyException(OptionError,"MissingArgument",option);
4293 define=GetImageOption(image_info,argv[i]);
4294 if (define == (const char *) NULL)
4295 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4300 if (LocaleCompare("delay",option+1) == 0)
4305 if (i == (ssize_t) argc)
4306 ThrowMogrifyException(OptionError,"MissingArgument",option);
4307 if (IsGeometry(argv[i]) == MagickFalse)
4308 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4311 if (LocaleCompare("delete",option+1) == 0)
4316 if (i == (ssize_t) (argc-1))
4317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 if (IsGeometry(argv[i]) == MagickFalse)
4319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4322 if (LocaleCompare("density",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("depth",option+1) == 0)
4338 if (i == (ssize_t) argc)
4339 ThrowMogrifyException(OptionError,"MissingArgument",option);
4340 if (IsGeometry(argv[i]) == MagickFalse)
4341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4344 if (LocaleCompare("deskew",option+1) == 0)
4349 if (i == (ssize_t) argc)
4350 ThrowMogrifyException(OptionError,"MissingArgument",option);
4351 if (IsGeometry(argv[i]) == MagickFalse)
4352 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4355 if (LocaleCompare("despeckle",option+1) == 0)
4357 if (LocaleCompare("dft",option+1) == 0)
4359 if (LocaleCompare("direction",option+1) == 0)
4367 if (i == (ssize_t) argc)
4368 ThrowMogrifyException(OptionError,"MissingArgument",option);
4369 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4372 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4376 if (LocaleCompare("display",option+1) == 0)
4381 if (i == (ssize_t) argc)
4382 ThrowMogrifyException(OptionError,"MissingArgument",option);
4385 if (LocaleCompare("dispose",option+1) == 0)
4393 if (i == (ssize_t) argc)
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4395 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4397 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4401 if (LocaleCompare("distort",option+1) == 0)
4407 if (i == (ssize_t) argc)
4408 ThrowMogrifyException(OptionError,"MissingArgument",option);
4409 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4411 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4414 if (i == (ssize_t) (argc-1))
4415 ThrowMogrifyException(OptionError,"MissingArgument",option);
4418 if (LocaleCompare("dither",option+1) == 0)
4426 if (i == (ssize_t) argc)
4427 ThrowMogrifyException(OptionError,"MissingArgument",option);
4428 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4430 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4434 if (LocaleCompare("draw",option+1) == 0)
4439 if (i == (ssize_t) argc)
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4443 if (LocaleCompare("duplicate",option+1) == 0)
4448 if (i == (ssize_t) (argc-1))
4449 ThrowMogrifyException(OptionError,"MissingArgument",option);
4450 if (IsGeometry(argv[i]) == MagickFalse)
4451 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4454 if (LocaleCompare("duration",option+1) == 0)
4459 if (i == (ssize_t) (argc-1))
4460 ThrowMogrifyException(OptionError,"MissingArgument",option);
4461 if (IsGeometry(argv[i]) == MagickFalse)
4462 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4465 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4469 if (LocaleCompare("edge",option+1) == 0)
4474 if (i == (ssize_t) argc)
4475 ThrowMogrifyException(OptionError,"MissingArgument",option);
4476 if (IsGeometry(argv[i]) == MagickFalse)
4477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4480 if (LocaleCompare("emboss",option+1) == 0)
4485 if (i == (ssize_t) argc)
4486 ThrowMogrifyException(OptionError,"MissingArgument",option);
4487 if (IsGeometry(argv[i]) == MagickFalse)
4488 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4491 if (LocaleCompare("encipher",option+1) == 0)
4496 if (i == (ssize_t) argc)
4497 ThrowMogrifyException(OptionError,"MissingArgument",option);
4500 if (LocaleCompare("encoding",option+1) == 0)
4505 if (i == (ssize_t) argc)
4506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4509 if (LocaleCompare("endian",option+1) == 0)
4517 if (i == (ssize_t) argc)
4518 ThrowMogrifyException(OptionError,"MissingArgument",option);
4519 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4521 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4525 if (LocaleCompare("enhance",option+1) == 0)
4527 if (LocaleCompare("equalize",option+1) == 0)
4529 if (LocaleCompare("evaluate",option+1) == 0)
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4541 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4544 if (i == (ssize_t) (argc-1))
4545 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 if (IsGeometry(argv[i]) == MagickFalse)
4547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4550 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4558 if (i == (ssize_t) argc)
4559 ThrowMogrifyException(OptionError,"MissingArgument",option);
4560 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4562 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4566 if (LocaleCompare("extent",option+1) == 0)
4571 if (i == (ssize_t) argc)
4572 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 if (IsGeometry(argv[i]) == MagickFalse)
4574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4577 if (LocaleCompare("extract",option+1) == 0)
4582 if (i == (ssize_t) argc)
4583 ThrowMogrifyException(OptionError,"MissingArgument",option);
4584 if (IsGeometry(argv[i]) == MagickFalse)
4585 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4588 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4592 if (LocaleCompare("family",option+1) == 0)
4597 if (i == (ssize_t) (argc-1))
4598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4601 if (LocaleCompare("features",option+1) == 0)
4606 if (i == (ssize_t) (argc-1))
4607 ThrowMogrifyException(OptionError,"MissingArgument",option);
4608 if (IsGeometry(argv[i]) == MagickFalse)
4609 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4612 if (LocaleCompare("fill",option+1) == 0)
4617 if (i == (ssize_t) argc)
4618 ThrowMogrifyException(OptionError,"MissingArgument",option);
4621 if (LocaleCompare("filter",option+1) == 0)
4629 if (i == (ssize_t) argc)
4630 ThrowMogrifyException(OptionError,"MissingArgument",option);
4631 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4633 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4637 if (LocaleCompare("flatten",option+1) == 0)
4639 if (LocaleCompare("flip",option+1) == 0)
4641 if (LocaleCompare("flop",option+1) == 0)
4643 if (LocaleCompare("floodfill",option+1) == 0)
4648 if (i == (ssize_t) argc)
4649 ThrowMogrifyException(OptionError,"MissingArgument",option);
4650 if (IsGeometry(argv[i]) == MagickFalse)
4651 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4653 if (i == (ssize_t) argc)
4654 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 if (LocaleCompare("font",option+1) == 0)
4662 if (i == (ssize_t) argc)
4663 ThrowMogrifyException(OptionError,"MissingArgument",option);
4666 if (LocaleCompare("format",option+1) == 0)
4668 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4669 (void) CloneString(&format,(char *) NULL);
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,"MissingArgument",option);
4675 (void) CloneString(&format,argv[i]);
4676 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4677 (void) ConcatenateMagickString(image_info->filename,":",
4679 (void) SetImageInfo(image_info,0,exception);
4680 if (*image_info->magick == '\0')
4681 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4685 if (LocaleCompare("frame",option+1) == 0)
4690 if (i == (ssize_t) argc)
4691 ThrowMogrifyException(OptionError,"MissingArgument",option);
4692 if (IsGeometry(argv[i]) == MagickFalse)
4693 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4696 if (LocaleCompare("function",option+1) == 0)
4704 if (i == (ssize_t) argc)
4705 ThrowMogrifyException(OptionError,"MissingArgument",option);
4706 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4708 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4710 if (i == (ssize_t) (argc-1))
4711 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 if (LocaleCompare("fuzz",option+1) == 0)
4719 if (i == (ssize_t) argc)
4720 ThrowMogrifyException(OptionError,"MissingArgument",option);
4721 if (IsGeometry(argv[i]) == MagickFalse)
4722 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4725 if (LocaleCompare("fx",option+1) == 0)
4730 if (i == (ssize_t) (argc-1))
4731 ThrowMogrifyException(OptionError,"MissingArgument",option);
4734 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4738 if (LocaleCompare("gamma",option+1) == 0)
4741 if (i == (ssize_t) argc)
4742 ThrowMogrifyException(OptionError,"MissingArgument",option);
4743 if (IsGeometry(argv[i]) == MagickFalse)
4744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4747 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4748 (LocaleCompare("gaussian",option+1) == 0))
4751 if (i == (ssize_t) argc)
4752 ThrowMogrifyException(OptionError,"MissingArgument",option);
4753 if (IsGeometry(argv[i]) == MagickFalse)
4754 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757 if (LocaleCompare("geometry",option+1) == 0)
4762 if (i == (ssize_t) argc)
4763 ThrowMogrifyException(OptionError,"MissingArgument",option);
4764 if (IsGeometry(argv[i]) == MagickFalse)
4765 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4768 if (LocaleCompare("gravity",option+1) == 0)
4776 if (i == (ssize_t) argc)
4777 ThrowMogrifyException(OptionError,"MissingArgument",option);
4778 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
4781 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4785 if (LocaleCompare("grayscale",option+1) == 0)
4793 if (i == (ssize_t) (argc-1))
4794 ThrowMogrifyException(OptionError,"MissingArgument",option);
4795 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4798 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
4802 if (LocaleCompare("green-primary",option+1) == 0)
4807 if (i == (ssize_t) argc)
4808 ThrowMogrifyException(OptionError,"MissingArgument",option);
4809 if (IsGeometry(argv[i]) == MagickFalse)
4810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4813 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4817 if (LocaleCompare("hald-clut",option+1) == 0)
4819 if ((LocaleCompare("help",option+1) == 0) ||
4820 (LocaleCompare("-help",option+1) == 0))
4821 return(MogrifyUsage());
4822 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4826 if (LocaleCompare("identify",option+1) == 0)
4828 if (LocaleCompare("idft",option+1) == 0)
4830 if (LocaleCompare("implode",option+1) == 0)
4835 if (i == (ssize_t) argc)
4836 ThrowMogrifyException(OptionError,"MissingArgument",option);
4837 if (IsGeometry(argv[i]) == MagickFalse)
4838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4841 if (LocaleCompare("intensity",option+1) == 0)
4849 if (i == (ssize_t) (argc-1))
4850 ThrowMogrifyException(OptionError,"MissingArgument",option);
4851 intensity=ParseCommandOption(MagickPixelIntensityOptions,
4852 MagickFalse,argv[i]);
4854 ThrowMogrifyException(OptionError,
4855 "UnrecognizedPixelIntensityMethod",argv[i]);
4858 if (LocaleCompare("intent",option+1) == 0)
4866 if (i == (ssize_t) (argc-1))
4867 ThrowMogrifyException(OptionError,"MissingArgument",option);
4868 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4870 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4874 if (LocaleCompare("interlace",option+1) == 0)
4882 if (i == (ssize_t) argc)
4883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4887 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4891 if (LocaleCompare("interline-spacing",option+1) == 0)
4896 if (i == (ssize_t) (argc-1))
4897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4898 if (IsGeometry(argv[i]) == MagickFalse)
4899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4902 if (LocaleCompare("interpolate",option+1) == 0)
4910 if (i == (ssize_t) argc)
4911 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4914 if (interpolate < 0)
4915 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4919 if (LocaleCompare("interword-spacing",option+1) == 0)
4924 if (i == (ssize_t) (argc-1))
4925 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 if (IsGeometry(argv[i]) == MagickFalse)
4927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4930 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4934 if (LocaleCompare("kerning",option+1) == 0)
4939 if (i == (ssize_t) (argc-1))
4940 ThrowMogrifyException(OptionError,"MissingArgument",option);
4941 if (IsGeometry(argv[i]) == MagickFalse)
4942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4945 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4949 if (LocaleCompare("label",option+1) == 0)
4954 if (i == (ssize_t) argc)
4955 ThrowMogrifyException(OptionError,"MissingArgument",option);
4958 if (LocaleCompare("lat",option+1) == 0)
4963 if (i == (ssize_t) argc)
4964 ThrowMogrifyException(OptionError,"MissingArgument",option);
4965 if (IsGeometry(argv[i]) == MagickFalse)
4966 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4968 if (LocaleCompare("layers",option+1) == 0)
4976 if (i == (ssize_t) (argc-1))
4977 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4980 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4984 if (LocaleCompare("level",option+1) == 0)
4987 if (i == (ssize_t) argc)
4988 ThrowMogrifyException(OptionError,"MissingArgument",option);
4989 if (IsGeometry(argv[i]) == MagickFalse)
4990 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4993 if (LocaleCompare("level-colors",option+1) == 0)
4996 if (i == (ssize_t) argc)
4997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5000 if (LocaleCompare("limit",option+1) == 0)
5014 if (i == (ssize_t) argc)
5015 ThrowMogrifyException(OptionError,"MissingArgument",option);
5016 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5019 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5022 if (i == (ssize_t) argc)
5023 ThrowMogrifyException(OptionError,"MissingArgument",option);
5024 value=StringToDouble(argv[i],&p);
5026 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5030 if (LocaleCompare("liquid-rescale",option+1) == 0)
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,"MissingArgument",option);
5035 if (IsGeometry(argv[i]) == MagickFalse)
5036 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5039 if (LocaleCompare("list",option+1) == 0)
5047 if (i == (ssize_t) argc)
5048 ThrowMogrifyException(OptionError,"MissingArgument",option);
5049 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5051 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5052 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5054 return(status != 0 ? MagickFalse : MagickTrue);
5056 if (LocaleCompare("log",option+1) == 0)
5061 if ((i == (ssize_t) argc) ||
5062 (strchr(argv[i],'%') == (char *) NULL))
5063 ThrowMogrifyException(OptionError,"MissingArgument",option);
5066 if (LocaleCompare("loop",option+1) == 0)
5071 if (i == (ssize_t) argc)
5072 ThrowMogrifyException(OptionError,"MissingArgument",option);
5073 if (IsGeometry(argv[i]) == MagickFalse)
5074 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5077 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5081 if (LocaleCompare("map",option+1) == 0)
5083 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5087 if (i == (ssize_t) argc)
5088 ThrowMogrifyException(OptionError,"MissingArgument",option);
5091 if (LocaleCompare("mask",option+1) == 0)
5096 if (i == (ssize_t) argc)
5097 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 if (LocaleCompare("matte",option+1) == 0)
5102 if (LocaleCompare("mattecolor",option+1) == 0)
5107 if (i == (ssize_t) argc)
5108 ThrowMogrifyException(OptionError,"MissingArgument",option);
5111 if (LocaleCompare("maximum",option+1) == 0)
5113 if (LocaleCompare("metric",option+1) == 0)
5121 if (i == (ssize_t) argc)
5122 ThrowMogrifyException(OptionError,"MissingArgument",option);
5123 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5125 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5129 if (LocaleCompare("minimum",option+1) == 0)
5131 if (LocaleCompare("modulate",option+1) == 0)
5136 if (i == (ssize_t) argc)
5137 ThrowMogrifyException(OptionError,"MissingArgument",option);
5138 if (IsGeometry(argv[i]) == MagickFalse)
5139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5142 if (LocaleCompare("median",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5149 if (IsGeometry(argv[i]) == MagickFalse)
5150 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5153 if (LocaleCompare("mode",option+1) == 0)
5158 if (i == (ssize_t) argc)
5159 ThrowMogrifyException(OptionError,"MissingArgument",option);
5160 if (IsGeometry(argv[i]) == MagickFalse)
5161 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5164 if (LocaleCompare("monitor",option+1) == 0)
5166 if (LocaleCompare("monochrome",option+1) == 0)
5168 if (LocaleCompare("morph",option+1) == 0)
5173 if (i == (ssize_t) (argc-1))
5174 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 if (IsGeometry(argv[i]) == MagickFalse)
5176 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5179 if (LocaleCompare("morphology",option+1) == 0)
5182 token[MaxTextExtent];
5191 if (i == (ssize_t) argc)
5192 ThrowMogrifyException(OptionError,"MissingArgument",option);
5193 GetMagickToken(argv[i],NULL,token);
5194 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5196 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5199 if (i == (ssize_t) (argc-1))
5200 ThrowMogrifyException(OptionError,"MissingArgument",option);
5201 kernel_info=AcquireKernelInfo(argv[i]);
5202 if (kernel_info == (KernelInfo *) NULL)
5203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5204 kernel_info=DestroyKernelInfo(kernel_info);
5207 if (LocaleCompare("mosaic",option+1) == 0)
5209 if (LocaleCompare("motion-blur",option+1) == 0)
5214 if (i == (ssize_t) argc)
5215 ThrowMogrifyException(OptionError,"MissingArgument",option);
5216 if (IsGeometry(argv[i]) == MagickFalse)
5217 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5220 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5224 if (LocaleCompare("negate",option+1) == 0)
5226 if (LocaleCompare("noise",option+1) == 0)
5229 if (i == (ssize_t) argc)
5230 ThrowMogrifyException(OptionError,"MissingArgument",option);
5236 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5238 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5242 if (IsGeometry(argv[i]) == MagickFalse)
5243 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5246 if (LocaleCompare("noop",option+1) == 0)
5248 if (LocaleCompare("normalize",option+1) == 0)
5250 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5254 if (LocaleCompare("opaque",option+1) == 0)
5257 if (i == (ssize_t) argc)
5258 ThrowMogrifyException(OptionError,"MissingArgument",option);
5261 if (LocaleCompare("ordered-dither",option+1) == 0)
5266 if (i == (ssize_t) argc)
5267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5270 if (LocaleCompare("orient",option+1) == 0)
5275 orientation=UndefinedOrientation;
5279 if (i == (ssize_t) (argc-1))
5280 ThrowMogrifyException(OptionError,"MissingArgument",option);
5281 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5283 if (orientation < 0)
5284 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5288 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5292 if (LocaleCompare("page",option+1) == 0)
5297 if (i == (ssize_t) argc)
5298 ThrowMogrifyException(OptionError,"MissingArgument",option);
5301 if (LocaleCompare("paint",option+1) == 0)
5306 if (i == (ssize_t) argc)
5307 ThrowMogrifyException(OptionError,"MissingArgument",option);
5308 if (IsGeometry(argv[i]) == MagickFalse)
5309 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5312 if (LocaleCompare("path",option+1) == 0)
5314 (void) CloneString(&path,(char *) NULL);
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,"MissingArgument",option);
5320 (void) CloneString(&path,argv[i]);
5323 if (LocaleCompare("perceptible",option+1) == 0)
5328 if (i == (ssize_t) argc)
5329 ThrowMogrifyException(OptionError,"MissingArgument",option);
5330 if (IsGeometry(argv[i]) == MagickFalse)
5331 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5334 if (LocaleCompare("pointsize",option+1) == 0)
5339 if (i == (ssize_t) argc)
5340 ThrowMogrifyException(OptionError,"MissingArgument",option);
5341 if (IsGeometry(argv[i]) == MagickFalse)
5342 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5345 if (LocaleCompare("polaroid",option+1) == 0)
5350 if (i == (ssize_t) argc)
5351 ThrowMogrifyException(OptionError,"MissingArgument",option);
5352 if (IsGeometry(argv[i]) == MagickFalse)
5353 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5356 if (LocaleCompare("poly",option+1) == 0)
5361 if (i == (ssize_t) argc)
5362 ThrowMogrifyException(OptionError,"MissingArgument",option);
5363 if (IsGeometry(argv[i]) == MagickFalse)
5364 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5367 if (LocaleCompare("posterize",option+1) == 0)
5372 if (i == (ssize_t) argc)
5373 ThrowMogrifyException(OptionError,"MissingArgument",option);
5374 if (IsGeometry(argv[i]) == MagickFalse)
5375 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5378 if (LocaleCompare("precision",option+1) == 0)
5383 if (i == (ssize_t) argc)
5384 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (IsGeometry(argv[i]) == MagickFalse)
5386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5389 if (LocaleCompare("print",option+1) == 0)
5394 if (i == (ssize_t) argc)
5395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5398 if (LocaleCompare("process",option+1) == 0)
5403 if (i == (ssize_t) (argc-1))
5404 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 if (LocaleCompare("profile",option+1) == 0)
5410 if (i == (ssize_t) argc)
5411 ThrowMogrifyException(OptionError,"MissingArgument",option);
5414 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5418 if (LocaleCompare("quality",option+1) == 0)
5423 if (i == (ssize_t) argc)
5424 ThrowMogrifyException(OptionError,"MissingArgument",option);
5425 if (IsGeometry(argv[i]) == MagickFalse)
5426 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5429 if (LocaleCompare("quantize",option+1) == 0)
5437 if (i == (ssize_t) (argc-1))
5438 ThrowMogrifyException(OptionError,"MissingArgument",option);
5439 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5442 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5446 if (LocaleCompare("quiet",option+1) == 0)
5448 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5452 if (LocaleCompare("radial-blur",option+1) == 0)
5455 if (i == (ssize_t) argc)
5456 ThrowMogrifyException(OptionError,"MissingArgument",option);
5457 if (IsGeometry(argv[i]) == MagickFalse)
5458 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5461 if (LocaleCompare("raise",option+1) == 0)
5464 if (i == (ssize_t) argc)
5465 ThrowMogrifyException(OptionError,"MissingArgument",option);
5466 if (IsGeometry(argv[i]) == MagickFalse)
5467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5470 if (LocaleCompare("random-threshold",option+1) == 0)
5475 if (i == (ssize_t) argc)
5476 ThrowMogrifyException(OptionError,"MissingArgument",option);
5477 if (IsGeometry(argv[i]) == MagickFalse)
5478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5481 if (LocaleCompare("red-primary",option+1) == 0)
5486 if (i == (ssize_t) argc)
5487 ThrowMogrifyException(OptionError,"MissingArgument",option);
5488 if (IsGeometry(argv[i]) == MagickFalse)
5489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5491 if (LocaleCompare("regard-warnings",option+1) == 0)
5493 if (LocaleCompare("region",option+1) == 0)
5498 if (i == (ssize_t) argc)
5499 ThrowMogrifyException(OptionError,"MissingArgument",option);
5500 if (IsGeometry(argv[i]) == MagickFalse)
5501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5504 if (LocaleCompare("remap",option+1) == 0)
5509 if (i == (ssize_t) (argc-1))
5510 ThrowMogrifyException(OptionError,"MissingArgument",option);
5513 if (LocaleCompare("render",option+1) == 0)
5515 if (LocaleCompare("repage",option+1) == 0)
5520 if (i == (ssize_t) argc)
5521 ThrowMogrifyException(OptionError,"MissingArgument",option);
5522 if (IsGeometry(argv[i]) == MagickFalse)
5523 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5526 if (LocaleCompare("resample",option+1) == 0)
5531 if (i == (ssize_t) argc)
5532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 if (IsGeometry(argv[i]) == MagickFalse)
5534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 if (LocaleCompare("resize",option+1) == 0)
5542 if (i == (ssize_t) argc)
5543 ThrowMogrifyException(OptionError,"MissingArgument",option);
5544 if (IsGeometry(argv[i]) == MagickFalse)
5545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5548 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5550 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5553 if (LocaleCompare("reverse",option+1) == 0)
5555 if (LocaleCompare("roll",option+1) == 0)
5560 if (i == (ssize_t) argc)
5561 ThrowMogrifyException(OptionError,"MissingArgument",option);
5562 if (IsGeometry(argv[i]) == MagickFalse)
5563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5566 if (LocaleCompare("rotate",option+1) == 0)
5569 if (i == (ssize_t) argc)
5570 ThrowMogrifyException(OptionError,"MissingArgument",option);
5571 if (IsGeometry(argv[i]) == MagickFalse)
5572 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5575 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5579 if (LocaleCompare("sample",option+1) == 0)
5584 if (i == (ssize_t) argc)
5585 ThrowMogrifyException(OptionError,"MissingArgument",option);
5586 if (IsGeometry(argv[i]) == MagickFalse)
5587 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5590 if (LocaleCompare("sampling-factor",option+1) == 0)
5595 if (i == (ssize_t) argc)
5596 ThrowMogrifyException(OptionError,"MissingArgument",option);
5597 if (IsGeometry(argv[i]) == MagickFalse)
5598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5601 if (LocaleCompare("scale",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("scene",option+1) == 0)
5617 if (i == (ssize_t) argc)
5618 ThrowMogrifyException(OptionError,"MissingArgument",option);
5619 if (IsGeometry(argv[i]) == MagickFalse)
5620 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5623 if (LocaleCompare("seed",option+1) == 0)
5628 if (i == (ssize_t) argc)
5629 ThrowMogrifyException(OptionError,"MissingArgument",option);
5630 if (IsGeometry(argv[i]) == MagickFalse)
5631 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5634 if (LocaleCompare("segment",option+1) == 0)
5639 if (i == (ssize_t) argc)
5640 ThrowMogrifyException(OptionError,"MissingArgument",option);
5641 if (IsGeometry(argv[i]) == MagickFalse)
5642 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5645 if (LocaleCompare("selective-blur",option+1) == 0)
5648 if (i == (ssize_t) argc)
5649 ThrowMogrifyException(OptionError,"MissingArgument",option);
5650 if (IsGeometry(argv[i]) == MagickFalse)
5651 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5654 if (LocaleCompare("separate",option+1) == 0)
5656 if (LocaleCompare("sepia-tone",option+1) == 0)
5661 if (i == (ssize_t) argc)
5662 ThrowMogrifyException(OptionError,"MissingArgument",option);
5663 if (IsGeometry(argv[i]) == MagickFalse)
5664 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5667 if (LocaleCompare("set",option+1) == 0)
5670 if (i == (ssize_t) argc)
5671 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 if (i == (ssize_t) argc)
5676 ThrowMogrifyException(OptionError,"MissingArgument",option);
5679 if (LocaleCompare("shade",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("shadow",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 (LocaleCompare("sharpen",option+1) == 0)
5702 if (i == (ssize_t) argc)
5703 ThrowMogrifyException(OptionError,"MissingArgument",option);
5704 if (IsGeometry(argv[i]) == MagickFalse)
5705 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5708 if (LocaleCompare("shave",option+1) == 0)
5713 if (i == (ssize_t) argc)
5714 ThrowMogrifyException(OptionError,"MissingArgument",option);
5715 if (IsGeometry(argv[i]) == MagickFalse)
5716 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5719 if (LocaleCompare("shear",option+1) == 0)
5722 if (i == (ssize_t) argc)
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5724 if (IsGeometry(argv[i]) == MagickFalse)
5725 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5728 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5731 if (i == (ssize_t) (argc-1))
5732 ThrowMogrifyException(OptionError,"MissingArgument",option);
5733 if (IsGeometry(argv[i]) == MagickFalse)
5734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5737 if (LocaleCompare("size",option+1) == 0)
5742 if (i == (ssize_t) argc)
5743 ThrowMogrifyException(OptionError,"MissingArgument",option);
5744 if (IsGeometry(argv[i]) == MagickFalse)
5745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 if (LocaleCompare("sketch",option+1) == 0)
5753 if (i == (ssize_t) argc)
5754 ThrowMogrifyException(OptionError,"MissingArgument",option);
5755 if (IsGeometry(argv[i]) == MagickFalse)
5756 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5759 if (LocaleCompare("smush",option+1) == 0)
5762 if (i == (ssize_t) argc)
5763 ThrowMogrifyException(OptionError,"MissingArgument",option);
5764 if (IsGeometry(argv[i]) == MagickFalse)
5765 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5769 if (LocaleCompare("solarize",option+1) == 0)
5774 if (i == (ssize_t) argc)
5775 ThrowMogrifyException(OptionError,"MissingArgument",option);
5776 if (IsGeometry(argv[i]) == MagickFalse)
5777 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5780 if (LocaleCompare("sparse-color",option+1) == 0)
5786 if (i == (ssize_t) argc)
5787 ThrowMogrifyException(OptionError,"MissingArgument",option);
5788 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5790 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5793 if (i == (ssize_t) (argc-1))
5794 ThrowMogrifyException(OptionError,"MissingArgument",option);
5797 if (LocaleCompare("splice",option+1) == 0)
5802 if (i == (ssize_t) argc)
5803 ThrowMogrifyException(OptionError,"MissingArgument",option);
5804 if (IsGeometry(argv[i]) == MagickFalse)
5805 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5808 if (LocaleCompare("spread",option+1) == 0)
5813 if (i == (ssize_t) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5815 if (IsGeometry(argv[i]) == MagickFalse)
5816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5819 if (LocaleCompare("statistic",option+1) == 0)
5827 if (i == (ssize_t) argc)
5828 ThrowMogrifyException(OptionError,"MissingArgument",option);
5829 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5831 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5834 if (i == (ssize_t) (argc-1))
5835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5836 if (IsGeometry(argv[i]) == MagickFalse)
5837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5840 if (LocaleCompare("stretch",option+1) == 0)
5848 if (i == (ssize_t) (argc-1))
5849 ThrowMogrifyException(OptionError,"MissingArgument",option);
5850 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5852 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5856 if (LocaleCompare("strip",option+1) == 0)
5858 if (LocaleCompare("stroke",option+1) == 0)
5863 if (i == (ssize_t) argc)
5864 ThrowMogrifyException(OptionError,"MissingArgument",option);
5867 if (LocaleCompare("strokewidth",option+1) == 0)
5872 if (i == (ssize_t) argc)
5873 ThrowMogrifyException(OptionError,"MissingArgument",option);
5874 if (IsGeometry(argv[i]) == MagickFalse)
5875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5878 if (LocaleCompare("style",option+1) == 0)
5886 if (i == (ssize_t) (argc-1))
5887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5890 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5894 if (LocaleCompare("swap",option+1) == 0)
5899 if (i == (ssize_t) (argc-1))
5900 ThrowMogrifyException(OptionError,"MissingArgument",option);
5901 if (IsGeometry(argv[i]) == MagickFalse)
5902 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5905 if (LocaleCompare("swirl",option+1) == 0)
5910 if (i == (ssize_t) argc)
5911 ThrowMogrifyException(OptionError,"MissingArgument",option);
5912 if (IsGeometry(argv[i]) == MagickFalse)
5913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5916 if (LocaleCompare("synchronize",option+1) == 0)
5918 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5922 if (LocaleCompare("taint",option+1) == 0)
5924 if (LocaleCompare("texture",option+1) == 0)
5929 if (i == (ssize_t) argc)
5930 ThrowMogrifyException(OptionError,"MissingArgument",option);
5933 if (LocaleCompare("tile",option+1) == 0)
5938 if (i == (ssize_t) (argc-1))
5939 ThrowMogrifyException(OptionError,"MissingArgument",option);
5942 if (LocaleCompare("tile-offset",option+1) == 0)
5947 if (i == (ssize_t) argc)
5948 ThrowMogrifyException(OptionError,"MissingArgument",option);
5949 if (IsGeometry(argv[i]) == MagickFalse)
5950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5953 if (LocaleCompare("tint",option+1) == 0)
5958 if (i == (ssize_t) (argc-1))
5959 ThrowMogrifyException(OptionError,"MissingArgument",option);
5960 if (IsGeometry(argv[i]) == MagickFalse)
5961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5964 if (LocaleCompare("transform",option+1) == 0)
5966 if (LocaleCompare("transpose",option+1) == 0)
5968 if (LocaleCompare("transverse",option+1) == 0)
5970 if (LocaleCompare("threshold",option+1) == 0)
5975 if (i == (ssize_t) argc)
5976 ThrowMogrifyException(OptionError,"MissingArgument",option);
5977 if (IsGeometry(argv[i]) == MagickFalse)
5978 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5981 if (LocaleCompare("thumbnail",option+1) == 0)
5986 if (i == (ssize_t) argc)
5987 ThrowMogrifyException(OptionError,"MissingArgument",option);
5988 if (IsGeometry(argv[i]) == MagickFalse)
5989 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5992 if (LocaleCompare("transparent",option+1) == 0)
5995 if (i == (ssize_t) argc)
5996 ThrowMogrifyException(OptionError,"MissingArgument",option);
5999 if (LocaleCompare("transparent-color",option+1) == 0)
6004 if (i == (ssize_t) (argc-1))
6005 ThrowMogrifyException(OptionError,"MissingArgument",option);
6008 if (LocaleCompare("treedepth",option+1) == 0)
6013 if (i == (ssize_t) argc)
6014 ThrowMogrifyException(OptionError,"MissingArgument",option);
6015 if (IsGeometry(argv[i]) == MagickFalse)
6016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6019 if (LocaleCompare("trim",option+1) == 0)
6021 if (LocaleCompare("type",option+1) == 0)
6029 if (i == (ssize_t) argc)
6030 ThrowMogrifyException(OptionError,"MissingArgument",option);
6031 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6033 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6037 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6041 if (LocaleCompare("undercolor",option+1) == 0)
6046 if (i == (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6050 if (LocaleCompare("unique-colors",option+1) == 0)
6052 if (LocaleCompare("units",option+1) == 0)
6060 if (i == (ssize_t) argc)
6061 ThrowMogrifyException(OptionError,"MissingArgument",option);
6062 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6065 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6069 if (LocaleCompare("unsharp",option+1) == 0)
6072 if (i == (ssize_t) argc)
6073 ThrowMogrifyException(OptionError,"MissingArgument",option);
6074 if (IsGeometry(argv[i]) == MagickFalse)
6075 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6078 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6082 if (LocaleCompare("verbose",option+1) == 0)
6084 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6087 if ((LocaleCompare("version",option+1) == 0) ||
6088 (LocaleCompare("-version",option+1) == 0))
6090 ListMagickVersion(stdout);
6093 if (LocaleCompare("view",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6102 if (LocaleCompare("vignette",option+1) == 0)
6107 if (i == (ssize_t) argc)
6108 ThrowMogrifyException(OptionError,"MissingArgument",option);
6109 if (IsGeometry(argv[i]) == MagickFalse)
6110 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6113 if (LocaleCompare("virtual-pixel",option+1) == 0)
6121 if (i == (ssize_t) argc)
6122 ThrowMogrifyException(OptionError,"MissingArgument",option);
6123 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6126 ThrowMogrifyException(OptionError,
6127 "UnrecognizedVirtualPixelMethod",argv[i]);
6130 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6134 if (LocaleCompare("wave",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("weight",option+1) == 0)
6148 if (i == (ssize_t) (argc-1))
6149 ThrowMogrifyException(OptionError,"MissingArgument",option);
6152 if (LocaleCompare("white-point",option+1) == 0)
6157 if (i == (ssize_t) argc)
6158 ThrowMogrifyException(OptionError,"MissingArgument",option);
6159 if (IsGeometry(argv[i]) == MagickFalse)
6160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6163 if (LocaleCompare("white-threshold",option+1) == 0)
6168 if (i == (ssize_t) argc)
6169 ThrowMogrifyException(OptionError,"MissingArgument",option);
6170 if (IsGeometry(argv[i]) == MagickFalse)
6171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6174 if (LocaleCompare("write",option+1) == 0)
6177 if (i == (ssize_t) (argc-1))
6178 ThrowMogrifyException(OptionError,"MissingArgument",option);
6181 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6186 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6188 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6189 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6190 if (fire != MagickFalse)
6191 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6194 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6195 if (i != (ssize_t) argc)
6196 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6198 return(status != 0 ? MagickTrue : MagickFalse);
6202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6206 + M o g r i f y I m a g e I n f o %
6210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6212 % MogrifyImageInfo() applies image processing settings to the image as
6213 % prescribed by command line options.
6215 % The format of the MogrifyImageInfo method is:
6217 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6218 % const char **argv,ExceptionInfo *exception)
6220 % A description of each parameter follows:
6222 % o image_info: the image info..
6224 % o argc: Specifies a pointer to an integer describing the number of
6225 % elements in the argument vector.
6227 % o argv: Specifies a pointer to a text array containing the command line
6230 % o exception: return any errors or warnings in this structure.
6233 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6234 const int argc,const char **argv,ExceptionInfo *exception)
6249 Initialize method variables.
6251 assert(image_info != (ImageInfo *) NULL);
6252 assert(image_info->signature == MagickSignature);
6253 if (image_info->debug != MagickFalse)
6254 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6255 image_info->filename);
6259 Set the image settings.
6261 for (i=0; i < (ssize_t) argc; i++)
6264 if (IsCommandOption(option) == MagickFalse)
6266 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6267 count=MagickMax(count,0L);
6268 if ((i+count) >= (ssize_t) argc)
6270 switch (*(option+1))
6274 if (LocaleCompare("adjoin",option+1) == 0)
6276 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6279 if (LocaleCompare("antialias",option+1) == 0)
6281 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6284 if (LocaleCompare("authenticate",option+1) == 0)
6287 (void) DeleteImageOption(image_info,option+1);
6289 (void) SetImageOption(image_info,option+1,argv[i+1]);
6296 if (LocaleCompare("background",option+1) == 0)
6300 (void) DeleteImageOption(image_info,option+1);
6301 (void) QueryColorCompliance(MogrifyBackgroundColor,
6302 AllCompliance,&image_info->background_color,exception);
6305 (void) SetImageOption(image_info,option+1,argv[i+1]);
6306 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6307 &image_info->background_color,exception);
6310 if (LocaleCompare("bias",option+1) == 0)
6314 (void) SetImageOption(image_info,option+1,"0.0");
6317 (void) SetImageOption(image_info,option+1,argv[i+1]);
6320 if (LocaleCompare("black-point-compensation",option+1) == 0)
6324 (void) SetImageOption(image_info,option+1,"false");
6327 (void) SetImageOption(image_info,option+1,"true");
6330 if (LocaleCompare("blue-primary",option+1) == 0)
6334 (void) SetImageOption(image_info,option+1,"0.0");
6337 (void) SetImageOption(image_info,option+1,argv[i+1]);
6340 if (LocaleCompare("bordercolor",option+1) == 0)
6344 (void) DeleteImageOption(image_info,option+1);
6345 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6346 &image_info->border_color,exception);
6349 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6350 &image_info->border_color,exception);
6351 (void) SetImageOption(image_info,option+1,argv[i+1]);
6354 if (LocaleCompare("box",option+1) == 0)
6358 (void) SetImageOption(image_info,"undercolor","none");
6361 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6368 if (LocaleCompare("cache",option+1) == 0)
6373 limit=MagickResourceInfinity;
6374 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6375 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6377 (void) SetMagickResourceLimit(MemoryResource,limit);
6378 (void) SetMagickResourceLimit(MapResource,2*limit);
6381 if (LocaleCompare("caption",option+1) == 0)
6385 (void) DeleteImageOption(image_info,option+1);
6388 (void) SetImageOption(image_info,option+1,argv[i+1]);
6391 if (LocaleCompare("channel",option+1) == 0)
6395 image_info->channel=DefaultChannels;
6396 (void) SetImageOption(image_info,option+1,"default");
6399 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6400 (void) SetImageOption(image_info,option+1,argv[i+1]);
6403 if (LocaleCompare("colorspace",option+1) == 0)
6407 image_info->colorspace=UndefinedColorspace;
6408 (void) SetImageOption(image_info,option+1,"undefined");
6411 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6412 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6413 (void) SetImageOption(image_info,option+1,argv[i+1]);
6416 if (LocaleCompare("comment",option+1) == 0)
6420 (void) DeleteImageOption(image_info,option+1);
6423 (void) SetImageOption(image_info,option+1,argv[i+1]);
6426 if (LocaleCompare("compose",option+1) == 0)
6430 (void) SetImageOption(image_info,option+1,"undefined");
6433 (void) SetImageOption(image_info,option+1,argv[i+1]);
6436 if (LocaleCompare("compress",option+1) == 0)
6440 image_info->compression=UndefinedCompression;
6441 (void) SetImageOption(image_info,option+1,"undefined");
6444 image_info->compression=(CompressionType) ParseCommandOption(
6445 MagickCompressOptions,MagickFalse,argv[i+1]);
6446 (void) SetImageOption(image_info,option+1,argv[i+1]);
6453 if (LocaleCompare("debug",option+1) == 0)
6456 (void) SetLogEventMask("none");
6458 (void) SetLogEventMask(argv[i+1]);
6459 image_info->debug=IsEventLogging();
6462 if (LocaleCompare("define",option+1) == 0)
6466 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6467 (void) DeleteImageRegistry(argv[i+1]+9);
6469 (void) DeleteImageOption(image_info,argv[i+1]);
6472 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6474 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6478 (void) DefineImageOption(image_info,argv[i+1]);
6481 if (LocaleCompare("delay",option+1) == 0)
6485 (void) SetImageOption(image_info,option+1,"0");
6488 (void) SetImageOption(image_info,option+1,argv[i+1]);
6491 if (LocaleCompare("density",option+1) == 0)
6498 if (image_info->density != (char *) NULL)
6499 image_info->density=DestroyString(image_info->density);
6500 (void) SetImageOption(image_info,option+1,"72");
6503 (void) CloneString(&image_info->density,argv[i+1]);
6504 (void) SetImageOption(image_info,option+1,argv[i+1]);
6507 if (LocaleCompare("depth",option+1) == 0)
6511 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6514 image_info->depth=StringToUnsignedLong(argv[i+1]);
6517 if (LocaleCompare("direction",option+1) == 0)
6521 (void) SetImageOption(image_info,option+1,"undefined");
6524 (void) SetImageOption(image_info,option+1,argv[i+1]);
6527 if (LocaleCompare("display",option+1) == 0)
6531 if (image_info->server_name != (char *) NULL)
6532 image_info->server_name=DestroyString(
6533 image_info->server_name);
6536 (void) CloneString(&image_info->server_name,argv[i+1]);
6539 if (LocaleCompare("dispose",option+1) == 0)
6543 (void) SetImageOption(image_info,option+1,"undefined");
6546 (void) SetImageOption(image_info,option+1,argv[i+1]);
6549 if (LocaleCompare("dither",option+1) == 0)
6553 image_info->dither=MagickFalse;
6554 (void) SetImageOption(image_info,option+1,"none");
6557 (void) SetImageOption(image_info,option+1,argv[i+1]);
6558 image_info->dither=MagickTrue;
6565 if (LocaleCompare("encoding",option+1) == 0)
6569 (void) SetImageOption(image_info,option+1,"undefined");
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("endian",option+1) == 0)
6579 image_info->endian=UndefinedEndian;
6580 (void) SetImageOption(image_info,option+1,"undefined");
6583 image_info->endian=(EndianType) ParseCommandOption(
6584 MagickEndianOptions,MagickFalse,argv[i+1]);
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 if (LocaleCompare("extract",option+1) == 0)
6591 Set image extract geometry.
6595 if (image_info->extract != (char *) NULL)
6596 image_info->extract=DestroyString(image_info->extract);
6599 (void) CloneString(&image_info->extract,argv[i+1]);
6606 if (LocaleCompare("fill",option+1) == 0)
6610 (void) SetImageOption(image_info,option+1,"none");
6613 (void) SetImageOption(image_info,option+1,argv[i+1]);
6616 if (LocaleCompare("filter",option+1) == 0)
6620 (void) SetImageOption(image_info,option+1,"undefined");
6623 (void) SetImageOption(image_info,option+1,argv[i+1]);
6626 if (LocaleCompare("font",option+1) == 0)
6630 if (image_info->font != (char *) NULL)
6631 image_info->font=DestroyString(image_info->font);
6634 (void) CloneString(&image_info->font,argv[i+1]);
6637 if (LocaleCompare("format",option+1) == 0)
6642 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6643 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6644 image_info->ping=MagickFalse;
6645 (void) SetImageOption(image_info,option+1,argv[i+1]);
6648 if (LocaleCompare("fuzz",option+1) == 0)
6652 image_info->fuzz=0.0;
6653 (void) SetImageOption(image_info,option+1,"0");
6656 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6665 if (LocaleCompare("gravity",option+1) == 0)
6669 (void) SetImageOption(image_info,option+1,"undefined");
6672 (void) SetImageOption(image_info,option+1,argv[i+1]);
6675 if (LocaleCompare("green-primary",option+1) == 0)
6679 (void) SetImageOption(image_info,option+1,"0.0");
6682 (void) SetImageOption(image_info,option+1,argv[i+1]);
6689 if (LocaleCompare("intensity",option+1) == 0)
6693 (void) SetImageOption(image_info,option+1,"undefined");
6696 (void) SetImageOption(image_info,option+1,argv[i+1]);
6699 if (LocaleCompare("intent",option+1) == 0)
6703 (void) SetImageOption(image_info,option+1,"undefined");
6706 (void) SetImageOption(image_info,option+1,argv[i+1]);
6709 if (LocaleCompare("interlace",option+1) == 0)
6713 image_info->interlace=UndefinedInterlace;
6714 (void) SetImageOption(image_info,option+1,"undefined");
6717 image_info->interlace=(InterlaceType) ParseCommandOption(
6718 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6719 (void) SetImageOption(image_info,option+1,argv[i+1]);
6722 if (LocaleCompare("interline-spacing",option+1) == 0)
6726 (void) SetImageOption(image_info,option+1,"undefined");
6729 (void) SetImageOption(image_info,option+1,argv[i+1]);
6732 if (LocaleCompare("interpolate",option+1) == 0)
6736 (void) SetImageOption(image_info,option+1,"undefined");
6739 (void) SetImageOption(image_info,option+1,argv[i+1]);
6742 if (LocaleCompare("interword-spacing",option+1) == 0)
6746 (void) SetImageOption(image_info,option+1,"undefined");
6749 (void) SetImageOption(image_info,option+1,argv[i+1]);
6756 if (LocaleCompare("kerning",option+1) == 0)
6760 (void) SetImageOption(image_info,option+1,"undefined");
6763 (void) SetImageOption(image_info,option+1,argv[i+1]);
6770 if (LocaleCompare("label",option+1) == 0)
6774 (void) DeleteImageOption(image_info,option+1);
6777 (void) SetImageOption(image_info,option+1,argv[i+1]);
6780 if (LocaleCompare("limit",option+1) == 0)
6790 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6791 MagickFalse,argv[i+1]);
6792 limit=MagickResourceInfinity;
6793 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6794 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6795 (void) SetMagickResourceLimit(type,limit);
6798 if (LocaleCompare("list",option+1) == 0)
6804 Display configuration list.
6806 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6809 case MagickCoderOptions:
6811 (void) ListCoderInfo((FILE *) NULL,exception);
6814 case MagickColorOptions:
6816 (void) ListColorInfo((FILE *) NULL,exception);
6819 case MagickConfigureOptions:
6821 (void) ListConfigureInfo((FILE *) NULL,exception);
6824 case MagickDelegateOptions:
6826 (void) ListDelegateInfo((FILE *) NULL,exception);
6829 case MagickFontOptions:
6831 (void) ListTypeInfo((FILE *) NULL,exception);
6834 case MagickFormatOptions:
6836 (void) ListMagickInfo((FILE *) NULL,exception);
6839 case MagickLocaleOptions:
6841 (void) ListLocaleInfo((FILE *) NULL,exception);
6844 case MagickLogOptions:
6846 (void) ListLogInfo((FILE *) NULL,exception);
6849 case MagickMagicOptions:
6851 (void) ListMagicInfo((FILE *) NULL,exception);
6854 case MagickMimeOptions:
6856 (void) ListMimeInfo((FILE *) NULL,exception);
6859 case MagickModuleOptions:
6861 (void) ListModuleInfo((FILE *) NULL,exception);
6864 case MagickPolicyOptions:
6866 (void) ListPolicyInfo((FILE *) NULL,exception);
6869 case MagickResourceOptions:
6871 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6874 case MagickThresholdOptions:
6876 (void) ListThresholdMaps((FILE *) NULL,exception);
6881 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6888 if (LocaleCompare("log",option+1) == 0)
6892 (void) SetLogFormat(argv[i+1]);
6895 if (LocaleCompare("loop",option+1) == 0)
6899 (void) SetImageOption(image_info,option+1,"0");
6902 (void) SetImageOption(image_info,option+1,argv[i+1]);
6909 if (LocaleCompare("matte",option+1) == 0)
6913 (void) SetImageOption(image_info,option+1,"false");
6916 (void) SetImageOption(image_info,option+1,"true");
6919 if (LocaleCompare("mattecolor",option+1) == 0)
6923 (void) SetImageOption(image_info,option+1,argv[i+1]);
6924 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6925 &image_info->matte_color,exception);
6928 (void) SetImageOption(image_info,option+1,argv[i+1]);
6929 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6930 &image_info->matte_color,exception);
6933 if (LocaleCompare("metric",option+1) == 0)
6936 (void) DeleteImageOption(image_info,option+1);
6938 (void) SetImageOption(image_info,option+1,argv[i+1]);
6941 if (LocaleCompare("monitor",option+1) == 0)
6943 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6947 if (LocaleCompare("monochrome",option+1) == 0)
6949 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6956 if (LocaleCompare("orient",option+1) == 0)
6960 image_info->orientation=UndefinedOrientation;
6961 (void) SetImageOption(image_info,option+1,"undefined");
6964 image_info->orientation=(OrientationType) ParseCommandOption(
6965 MagickOrientationOptions,MagickFalse,argv[i+1]);
6966 (void) SetImageOption(image_info,option+1,argv[i+1]);
6972 if (LocaleCompare("page",option+1) == 0)
6976 page[MaxTextExtent];
6989 (void) DeleteImageOption(image_info,option+1);
6990 (void) CloneString(&image_info->page,(char *) NULL);
6993 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6994 image_option=GetImageOption(image_info,"page");
6995 if (image_option != (const char *) NULL)
6996 flags=ParseAbsoluteGeometry(image_option,&geometry);
6997 canonical_page=GetPageGeometry(argv[i+1]);
6998 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6999 canonical_page=DestroyString(canonical_page);
7000 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
7001 (unsigned long) geometry.width,(unsigned long) geometry.height);
7002 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7003 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
7004 (unsigned long) geometry.width,(unsigned long) geometry.height,
7005 (long) geometry.x,(long) geometry.y);
7006 (void) SetImageOption(image_info,option+1,page);
7007 (void) CloneString(&image_info->page,page);
7010 if (LocaleCompare("ping",option+1) == 0)
7012 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7015 if (LocaleCompare("pointsize",option+1) == 0)
7018 geometry_info.rho=0.0;
7020 (void) ParseGeometry(argv[i+1],&geometry_info);
7021 image_info->pointsize=geometry_info.rho;
7024 if (LocaleCompare("precision",option+1) == 0)
7026 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7029 if (LocaleCompare("preview",option+1) == 0)
7036 image_info->preview_type=UndefinedPreview;
7039 image_info->preview_type=(PreviewType) ParseCommandOption(
7040 MagickPreviewOptions,MagickFalse,argv[i+1]);
7047 if (LocaleCompare("quality",option+1) == 0)
7050 Set image compression quality.
7054 image_info->quality=UndefinedCompressionQuality;
7055 (void) SetImageOption(image_info,option+1,"0");
7058 image_info->quality=StringToUnsignedLong(argv[i+1]);
7059 (void) SetImageOption(image_info,option+1,argv[i+1]);
7062 if (LocaleCompare("quiet",option+1) == 0)
7064 static WarningHandler
7065 warning_handler = (WarningHandler) NULL;
7070 Restore error or warning messages.
7072 warning_handler=SetWarningHandler(warning_handler);
7076 Suppress error or warning messages.
7078 warning_handler=SetWarningHandler((WarningHandler) NULL);
7085 if (LocaleCompare("red-primary",option+1) == 0)
7089 (void) SetImageOption(image_info,option+1,"0.0");
7092 (void) SetImageOption(image_info,option+1,argv[i+1]);
7099 if (LocaleCompare("sampling-factor",option+1) == 0)
7102 Set image sampling factor.
7106 if (image_info->sampling_factor != (char *) NULL)
7107 image_info->sampling_factor=DestroyString(
7108 image_info->sampling_factor);
7111 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7114 if (LocaleCompare("scene",option+1) == 0)
7121 image_info->scene=0;
7122 (void) SetImageOption(image_info,option+1,"0");
7125 image_info->scene=StringToUnsignedLong(argv[i+1]);
7126 (void) SetImageOption(image_info,option+1,argv[i+1]);
7129 if (LocaleCompare("seed",option+1) == 0)
7136 seed=(size_t) time((time_t *) NULL);
7137 SetRandomSecretKey(seed);
7140 seed=StringToUnsignedLong(argv[i+1]);
7141 SetRandomSecretKey(seed);
7144 if (LocaleCompare("size",option+1) == 0)
7148 if (image_info->size != (char *) NULL)
7149 image_info->size=DestroyString(image_info->size);
7152 (void) CloneString(&image_info->size,argv[i+1]);
7155 if (LocaleCompare("stroke",option+1) == 0)
7159 (void) SetImageOption(image_info,option+1,"none");
7162 (void) SetImageOption(image_info,option+1,argv[i+1]);
7165 if (LocaleCompare("strokewidth",option+1) == 0)
7169 (void) SetImageOption(image_info,option+1,"0");
7172 (void) SetImageOption(image_info,option+1,argv[i+1]);
7175 if (LocaleCompare("synchronize",option+1) == 0)
7179 image_info->synchronize=MagickFalse;
7182 image_info->synchronize=MagickTrue;
7189 if (LocaleCompare("taint",option+1) == 0)
7193 (void) SetImageOption(image_info,option+1,"false");
7196 (void) SetImageOption(image_info,option+1,"true");
7199 if (LocaleCompare("texture",option+1) == 0)
7203 if (image_info->texture != (char *) NULL)
7204 image_info->texture=DestroyString(image_info->texture);
7207 (void) CloneString(&image_info->texture,argv[i+1]);
7210 if (LocaleCompare("tile-offset",option+1) == 0)
7213 (void) SetImageOption(image_info,option+1,"0");
7215 (void) SetImageOption(image_info,option+1,argv[i+1]);
7218 if (LocaleCompare("transparent-color",option+1) == 0)
7222 (void) QueryColorCompliance("none",AllCompliance,
7223 &image_info->transparent_color,exception);
7224 (void) SetImageOption(image_info,option+1,"none");
7227 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7228 &image_info->transparent_color,exception);
7229 (void) SetImageOption(image_info,option+1,argv[i+1]);
7232 if (LocaleCompare("type",option+1) == 0)
7236 image_info->type=UndefinedType;
7237 (void) SetImageOption(image_info,option+1,"undefined");
7240 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7241 MagickFalse,argv[i+1]);
7242 (void) SetImageOption(image_info,option+1,argv[i+1]);
7249 if (LocaleCompare("undercolor",option+1) == 0)
7252 (void) DeleteImageOption(image_info,option+1);
7254 (void) SetImageOption(image_info,option+1,argv[i+1]);
7257 if (LocaleCompare("units",option+1) == 0)
7261 image_info->units=UndefinedResolution;
7262 (void) SetImageOption(image_info,option+1,"undefined");
7265 image_info->units=(ResolutionType) ParseCommandOption(
7266 MagickResolutionOptions,MagickFalse,argv[i+1]);
7267 (void) SetImageOption(image_info,option+1,argv[i+1]);
7274 if (LocaleCompare("verbose",option+1) == 0)
7278 image_info->verbose=MagickFalse;
7281 image_info->verbose=MagickTrue;
7282 image_info->ping=MagickFalse;
7285 if (LocaleCompare("view",option+1) == 0)
7289 if (image_info->view != (char *) NULL)
7290 image_info->view=DestroyString(image_info->view);
7293 (void) CloneString(&image_info->view,argv[i+1]);
7296 if (LocaleCompare("virtual-pixel",option+1) == 0)
7299 (void) SetImageOption(image_info,option+1,"undefined");
7301 (void) SetImageOption(image_info,option+1,argv[i+1]);
7308 if (LocaleCompare("white-point",option+1) == 0)
7311 (void) SetImageOption(image_info,option+1,"0.0");
7313 (void) SetImageOption(image_info,option+1,argv[i+1]);
7327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7331 + M o g r i f y I m a g e L i s t %
7335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7337 % MogrifyImageList() applies any command line options that might affect the
7338 % entire image list (e.g. -append, -coalesce, etc.).
7340 % The format of the MogrifyImage method is:
7342 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7343 % const char **argv,Image **images,ExceptionInfo *exception)
7345 % A description of each parameter follows:
7347 % o image_info: the image info..
7349 % o argc: Specifies a pointer to an integer describing the number of
7350 % elements in the argument vector.
7352 % o argv: Specifies a pointer to a text array containing the command line
7355 % o images: pointer to pointer of the first image in image list.
7357 % o exception: return any errors or warnings in this structure.
7360 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7361 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7372 PixelInterpolateMethod
7386 Apply options to the image list.
7388 assert(image_info != (ImageInfo *) NULL);
7389 assert(image_info->signature == MagickSignature);
7390 assert(images != (Image **) NULL);
7391 assert((*images)->previous == (Image *) NULL);
7392 assert((*images)->signature == MagickSignature);
7393 if ((*images)->debug != MagickFalse)
7394 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7395 (*images)->filename);
7396 if ((argc <= 0) || (*argv == (char *) NULL))
7398 interpolate_method=UndefinedInterpolatePixel;
7399 mogrify_info=CloneImageInfo(image_info);
7400 quantize_info=AcquireQuantizeInfo(mogrify_info);
7402 for (i=0; i < (ssize_t) argc; i++)
7404 if (*images == (Image *) NULL)
7407 if (IsCommandOption(option) == MagickFalse)
7409 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7410 count=MagickMax(count,0L);
7411 if ((i+count) >= (ssize_t) argc)
7413 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7414 switch (*(option+1))
7418 if (LocaleCompare("affinity",option+1) == 0)
7420 (void) SyncImagesSettings(mogrify_info,*images,exception);
7423 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7430 if (LocaleCompare("append",option+1) == 0)
7435 (void) SyncImagesSettings(mogrify_info,*images,exception);
7436 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7437 MagickFalse,exception);
7438 if (append_image == (Image *) NULL)
7443 *images=DestroyImageList(*images);
7444 *images=append_image;
7447 if (LocaleCompare("average",option+1) == 0)
7453 Average an image sequence (deprecated).
7455 (void) SyncImagesSettings(mogrify_info,*images,exception);
7456 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7458 if (average_image == (Image *) NULL)
7463 *images=DestroyImageList(*images);
7464 *images=average_image;
7471 if (LocaleCompare("channel-fx",option+1) == 0)
7476 (void) SyncImagesSettings(mogrify_info,*images,exception);
7477 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7478 if (channel_image == (Image *) NULL)
7483 *images=DestroyImageList(*images);
7484 *images=channel_image;
7487 if (LocaleCompare("clut",option+1) == 0)
7493 (void) SyncImagesSettings(mogrify_info,*images,exception);
7494 image=RemoveFirstImageFromList(images);
7495 clut_image=RemoveFirstImageFromList(images);
7496 if (clut_image == (Image *) NULL)
7501 (void) ClutImage(image,clut_image,interpolate_method,exception);
7502 clut_image=DestroyImage(clut_image);
7503 *images=DestroyImageList(*images);
7507 if (LocaleCompare("coalesce",option+1) == 0)
7512 (void) SyncImagesSettings(mogrify_info,*images,exception);
7513 coalesce_image=CoalesceImages(*images,exception);
7514 if (coalesce_image == (Image *) NULL)
7519 *images=DestroyImageList(*images);
7520 *images=coalesce_image;
7523 if (LocaleCompare("combine",option+1) == 0)
7531 (void) SyncImagesSettings(mogrify_info,*images,exception);
7532 colorspace=(ColorspaceType) ParseCommandOption(
7533 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7534 combine_image=CombineImages(*images,colorspace,exception);
7535 if (combine_image == (Image *) NULL)
7540 *images=DestroyImageList(*images);
7541 *images=combine_image;
7544 if (LocaleCompare("compare",option+1) == 0)
7561 Mathematically and visually annotate the difference between an
7562 image and its reconstruction.
7564 (void) SyncImagesSettings(mogrify_info,*images,exception);
7565 image=RemoveFirstImageFromList(images);
7566 reconstruct_image=RemoveFirstImageFromList(images);
7567 if (reconstruct_image == (Image *) NULL)
7572 metric=UndefinedErrorMetric;
7573 option=GetImageOption(image_info,"metric");
7574 if (option != (const char *) NULL)
7575 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7576 MagickFalse,option);
7577 difference_image=CompareImages(image,reconstruct_image,metric,
7578 &distortion,exception);
7579 if (difference_image == (Image *) NULL)
7581 if (*images != (Image *) NULL)
7582 *images=DestroyImage(*images);
7583 *images=difference_image;
7586 if (LocaleCompare("complex",option+1) == 0)
7594 (void) SyncImageSettings(mogrify_info,*images,exception);
7595 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7596 MagickFalse,argv[i+1]);
7597 complex_images=ComplexImages(*images,op,exception);
7598 if (complex_images == (Image *) NULL)
7603 *images=DestroyImageList(*images);
7604 *images=complex_images;
7607 if (LocaleCompare("composite",option+1) == 0)
7623 (void) SyncImagesSettings(mogrify_info,*images,exception);
7624 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7625 if (value == (const char *) NULL)
7626 clip_to_self=MagickTrue;
7628 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7629 "compose:clip-to-self")); /* if this is true */
7630 if (IsMagickFalse(clip_to_self)) /* or */
7631 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7632 mogrify_info,"compose:outside-overlay"))) ? MagickTrue :
7633 MagickFalse; /* this false */
7634 image=RemoveFirstImageFromList(images);
7635 composite_image=RemoveFirstImageFromList(images);
7636 if (composite_image == (Image *) NULL)
7641 (void) TransformImage(&composite_image,(char *) NULL,
7642 composite_image->geometry,exception);
7643 SetGeometry(composite_image,&geometry);
7644 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7645 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7647 mask_image=RemoveFirstImageFromList(images);
7648 if (mask_image != (Image *) NULL)
7650 if ((image->compose == DisplaceCompositeOp) ||
7651 (image->compose == DistortCompositeOp))
7652 status&=CompositeImage(composite_image,mask_image,
7653 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7662 composite_geometry.width=mask_image->columns;
7663 composite_geometry.height=mask_image->rows;
7664 composite_geometry.x=(-geometry.x);
7665 composite_geometry.y=(-geometry.y);
7668 image=ExtentImage(composite_image,&composite_geometry,
7670 if (image != (Image *) NULL)
7672 composite_image=DestroyImage(composite_image);
7673 composite_image=image;
7675 status&=CompositeImage(composite_image,mask_image,
7676 IntensityCompositeOp,MagickTrue,0,0,exception);
7678 mask_image=DestroyImage(mask_image);
7680 (void) CompositeImage(image,composite_image,image->compose,
7681 clip_to_self,geometry.x,geometry.y,exception);
7682 composite_image=DestroyImage(composite_image);
7683 *images=DestroyImageList(*images);
7691 if (LocaleCompare("deconstruct",option+1) == 0)
7696 (void) SyncImagesSettings(mogrify_info,*images,exception);
7697 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7699 if (deconstruct_image == (Image *) NULL)
7704 *images=DestroyImageList(*images);
7705 *images=deconstruct_image;
7708 if (LocaleCompare("delete",option+1) == 0)
7711 DeleteImages(images,"-1",exception);
7713 DeleteImages(images,argv[i+1],exception);
7716 if (LocaleCompare("dither",option+1) == 0)
7720 quantize_info->dither_method=NoDitherMethod;
7723 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7724 MagickDitherOptions,MagickFalse,argv[i+1]);
7727 if (LocaleCompare("duplicate",option+1) == 0)
7733 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7742 number_duplicates=(size_t) StringToLong(argv[i+1]);
7743 p=strchr(argv[i+1],',');
7744 if (p == (const char *) NULL)
7745 duplicate_images=DuplicateImages(*images,number_duplicates,
7748 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7751 AppendImageToList(images, duplicate_images);
7752 (void) SyncImagesSettings(mogrify_info,*images,exception);
7759 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7764 MagickEvaluateOperator
7767 (void) SyncImageSettings(mogrify_info,*images,exception);
7768 op=(MagickEvaluateOperator) ParseCommandOption(
7769 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7770 evaluate_image=EvaluateImages(*images,op,exception);
7771 if (evaluate_image == (Image *) NULL)
7776 *images=DestroyImageList(*images);
7777 *images=evaluate_image;
7784 if (LocaleCompare("fft",option+1) == 0)
7790 Implements the discrete Fourier transform (DFT).
7792 (void) SyncImageSettings(mogrify_info,*images,exception);
7793 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7794 MagickTrue : MagickFalse,exception);
7795 if (fourier_image == (Image *) NULL)
7797 *images=DestroyImage(*images);
7798 *images=fourier_image;
7801 if (LocaleCompare("flatten",option+1) == 0)
7806 (void) SyncImagesSettings(mogrify_info,*images,exception);
7807 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7808 if (flatten_image == (Image *) NULL)
7810 *images=DestroyImageList(*images);
7811 *images=flatten_image;
7814 if (LocaleCompare("fx",option+1) == 0)
7819 (void) SyncImagesSettings(mogrify_info,*images,exception);
7820 fx_image=FxImage(*images,argv[i+1],exception);
7821 if (fx_image == (Image *) NULL)
7826 *images=DestroyImageList(*images);
7834 if (LocaleCompare("hald-clut",option+1) == 0)
7840 (void) SyncImagesSettings(mogrify_info,*images,exception);
7841 image=RemoveFirstImageFromList(images);
7842 hald_image=RemoveFirstImageFromList(images);
7843 if (hald_image == (Image *) NULL)
7848 (void) HaldClutImage(image,hald_image,exception);
7849 hald_image=DestroyImage(hald_image);
7850 if (*images != (Image *) NULL)
7851 *images=DestroyImageList(*images);
7859 if (LocaleCompare("ift",option+1) == 0)
7867 Implements the inverse fourier discrete Fourier transform (DFT).
7869 (void) SyncImagesSettings(mogrify_info,*images,exception);
7870 magnitude_image=RemoveFirstImageFromList(images);
7871 phase_image=RemoveFirstImageFromList(images);
7872 if (phase_image == (Image *) NULL)
7877 fourier_image=InverseFourierTransformImage(magnitude_image,
7878 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7879 if (fourier_image == (Image *) NULL)
7881 if (*images != (Image *) NULL)
7882 *images=DestroyImage(*images);
7883 *images=fourier_image;
7886 if (LocaleCompare("insert",option+1) == 0)
7894 index=(ssize_t) StringToLong(argv[i+1]);
7895 p=RemoveLastImageFromList(images);
7896 if (p == (Image *) NULL)
7898 (void) ThrowMagickException(exception,GetMagickModule(),
7899 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7905 PrependImageToList(images,q);
7907 if (index == (ssize_t) GetImageListLength(*images))
7908 AppendImageToList(images,q);
7911 q=GetImageFromList(*images,index-1);
7912 if (q == (Image *) NULL)
7914 (void) ThrowMagickException(exception,GetMagickModule(),
7915 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7919 InsertImageInList(&q,p);
7921 *images=GetFirstImageInList(q);
7924 if (LocaleCompare("interpolate",option+1) == 0)
7926 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7927 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7934 if (LocaleCompare("layers",option+1) == 0)
7942 (void) SyncImagesSettings(mogrify_info,*images,exception);
7943 layers=(Image *) NULL;
7944 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
7945 MagickFalse,argv[i+1]);
7950 layers=CoalesceImages(*images,exception);
7953 case CompareAnyLayer:
7954 case CompareClearLayer:
7955 case CompareOverlayLayer:
7958 layers=CompareImagesLayers(*images,method,exception);
7964 case TrimBoundsLayer:
7966 layers=MergeImageLayers(*images,method,exception);
7971 layers=DisposeImages(*images,exception);
7974 case OptimizeImageLayer:
7976 layers=OptimizeImageLayers(*images,exception);
7979 case OptimizePlusLayer:
7981 layers=OptimizePlusImageLayers(*images,exception);
7984 case OptimizeTransLayer:
7986 OptimizeImageTransparency(*images,exception);
7989 case RemoveDupsLayer:
7991 RemoveDuplicateLayers(images,exception);
7994 case RemoveZeroLayer:
7996 RemoveZeroDelayLayers(images,exception);
8002 General Purpose, GIF Animation Optimizer.
8004 layers=CoalesceImages(*images,exception);
8005 if (layers == (Image *) NULL)
8010 *images=DestroyImageList(*images);
8012 layers=OptimizeImageLayers(*images,exception);
8013 if (layers == (Image *) NULL)
8018 *images=DestroyImageList(*images);
8020 layers=(Image *) NULL;
8021 OptimizeImageTransparency(*images,exception);
8022 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8026 case CompositeLayer:
8038 Split image sequence at the first 'NULL:' image.
8041 while (source != (Image *) NULL)
8043 source=GetNextImageInList(source);
8044 if ((source != (Image *) NULL) &&
8045 (LocaleCompare(source->magick,"NULL") == 0))
8048 if (source != (Image *) NULL)
8050 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8051 (GetNextImageInList(source) == (Image *) NULL))
8052 source=(Image *) NULL;
8056 Separate the two lists, junk the null: image.
8058 source=SplitImageList(source->previous);
8059 DeleteImageFromList(&source);
8062 if (source == (Image *) NULL)
8064 (void) ThrowMagickException(exception,GetMagickModule(),
8065 OptionError,"MissingNullSeparator","layers Composite");
8070 Adjust offset with gravity and virtual canvas.
8072 SetGeometry(*images,&geometry);
8073 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8074 geometry.width=source->page.width != 0 ?
8075 source->page.width : source->columns;
8076 geometry.height=source->page.height != 0 ?
8077 source->page.height : source->rows;
8078 GravityAdjustGeometry((*images)->page.width != 0 ?
8079 (*images)->page.width : (*images)->columns,
8080 (*images)->page.height != 0 ? (*images)->page.height :
8081 (*images)->rows,(*images)->gravity,&geometry);
8082 compose=OverCompositeOp;
8083 option=GetImageOption(mogrify_info,"compose");
8084 if (option != (const char *) NULL)
8085 compose=(CompositeOperator) ParseCommandOption(
8086 MagickComposeOptions,MagickFalse,option);
8087 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8089 source=DestroyImageList(source);
8093 if (layers == (Image *) NULL)
8095 *images=DestroyImageList(*images);
8103 if (LocaleCompare("map",option+1) == 0)
8105 (void) SyncImagesSettings(mogrify_info,*images,exception);
8108 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8115 if (LocaleCompare("maximum",option+1) == 0)
8121 Maximum image sequence (deprecated).
8123 (void) SyncImagesSettings(mogrify_info,*images,exception);
8124 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8125 if (maximum_image == (Image *) NULL)
8130 *images=DestroyImageList(*images);
8131 *images=maximum_image;
8134 if (LocaleCompare("minimum",option+1) == 0)
8140 Minimum image sequence (deprecated).
8142 (void) SyncImagesSettings(mogrify_info,*images,exception);
8143 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8144 if (minimum_image == (Image *) NULL)
8149 *images=DestroyImageList(*images);
8150 *images=minimum_image;
8153 if (LocaleCompare("morph",option+1) == 0)
8158 (void) SyncImagesSettings(mogrify_info,*images,exception);
8159 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8161 if (morph_image == (Image *) NULL)
8166 *images=DestroyImageList(*images);
8167 *images=morph_image;
8170 if (LocaleCompare("mosaic",option+1) == 0)
8175 (void) SyncImagesSettings(mogrify_info,*images,exception);
8176 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8177 if (mosaic_image == (Image *) NULL)
8182 *images=DestroyImageList(*images);
8183 *images=mosaic_image;
8190 if (LocaleCompare("poly",option+1) == 0)
8194 token[MaxTextExtent];
8214 (void) SyncImageSettings(mogrify_info,*images,exception);
8215 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8217 if (args == (char *) NULL)
8220 for (x=0; *p != '\0'; x++)
8222 GetMagickToken(p,&p,token);
8224 GetMagickToken(p,&p,token);
8226 number_arguments=(size_t) x;
8227 arguments=(double *) AcquireQuantumMemory(number_arguments,
8228 sizeof(*arguments));
8229 if (arguments == (double *) NULL)
8230 ThrowWandFatalException(ResourceLimitFatalError,
8231 "MemoryAllocationFailed",(*images)->filename);
8232 (void) ResetMagickMemory(arguments,0,number_arguments*
8233 sizeof(*arguments));
8235 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8237 GetMagickToken(p,&p,token);
8239 GetMagickToken(p,&p,token);
8240 arguments[x]=StringToDouble(token,(char **) NULL);
8242 args=DestroyString(args);
8243 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8244 arguments,exception);
8245 arguments=(double *) RelinquishMagickMemory(arguments);
8246 if (polynomial_image == (Image *) NULL)
8251 *images=DestroyImageList(*images);
8252 *images=polynomial_image;
8254 if (LocaleCompare("print",option+1) == 0)
8259 (void) SyncImagesSettings(mogrify_info,*images,exception);
8260 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8262 if (string == (char *) NULL)
8264 (void) FormatLocaleFile(stdout,"%s",string);
8265 string=DestroyString(string);
8267 if (LocaleCompare("process",option+1) == 0)
8276 (void) SyncImagesSettings(mogrify_info,*images,exception);
8277 arguments=StringToArgv(argv[i+1],&number_arguments);
8278 if (arguments == (char **) NULL)
8280 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8301 Support old style syntax, filter="-option arg".
8303 length=strlen(argv[i+1]);
8304 token=(char *) NULL;
8305 if (~length >= (MaxTextExtent-1))
8306 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8308 if (token == (char *) NULL)
8311 arguments=argv[i+1];
8312 token_info=AcquireTokenInfo();
8313 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8314 "\"",'\0',&breaker,&next,"e);
8315 token_info=DestroyTokenInfo(token_info);
8321 argv=(&(arguments[next]));
8322 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8325 token=DestroyString(token);
8328 (void) SubstituteString(&arguments[1],"-","");
8329 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8330 number_arguments-2,(const char **) arguments+2,exception);
8331 for (j=0; j < number_arguments; j++)
8332 arguments[j]=DestroyString(arguments[j]);
8333 arguments=(char **) RelinquishMagickMemory(arguments);
8340 if (LocaleCompare("reverse",option+1) == 0)
8342 ReverseImageList(images);
8349 if (LocaleCompare("smush",option+1) == 0)
8357 (void) SyncImagesSettings(mogrify_info,*images,exception);
8358 offset=(ssize_t) StringToLong(argv[i+1]);
8359 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8360 MagickFalse,offset,exception);
8361 if (smush_image == (Image *) NULL)
8366 *images=DestroyImageList(*images);
8367 *images=smush_image;
8370 if (LocaleCompare("swap",option+1) == 0)
8391 flags=ParseGeometry(argv[i+1],&geometry_info);
8392 index=(ssize_t) geometry_info.rho;
8393 if ((flags & SigmaValue) != 0)
8394 swap_index=(ssize_t) geometry_info.sigma;
8396 p=GetImageFromList(*images,index);
8397 q=GetImageFromList(*images,swap_index);
8398 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8400 (void) ThrowMagickException(exception,GetMagickModule(),
8401 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8407 swap=CloneImage(p,0,0,MagickTrue,exception);
8408 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8409 ReplaceImageInList(&q,swap);
8410 *images=GetFirstImageInList(q);
8417 if (LocaleCompare("write",option+1) == 0)
8428 (void) SyncImagesSettings(mogrify_info,*images,exception);
8429 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8430 (void) DeleteImageRegistry(key);
8431 write_images=(*images);
8433 write_images=CloneImageList(*images,exception);
8434 write_info=CloneImageInfo(mogrify_info);
8435 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8436 write_info=DestroyImageInfo(write_info);
8438 write_images=DestroyImageList(write_images);
8448 quantize_info=DestroyQuantizeInfo(quantize_info);
8449 mogrify_info=DestroyImageInfo(mogrify_info);
8450 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8451 return(status != 0 ? MagickTrue : MagickFalse);
8455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8459 + M o g r i f y I m a g e s %
8463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8465 % MogrifyImages() applies image processing options to a sequence of images as
8466 % prescribed by command line options.
8468 % The format of the MogrifyImage method is:
8470 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8471 % const MagickBooleanType post,const int argc,const char **argv,
8472 % Image **images,Exceptioninfo *exception)
8474 % A description of each parameter follows:
8476 % o image_info: the image info..
8478 % o post: If true, post process image list operators otherwise pre-process.
8480 % o argc: Specifies a pointer to an integer describing the number of
8481 % elements in the argument vector.
8483 % o argv: Specifies a pointer to a text array containing the command line
8486 % o images: pointer to a pointer of the first image in image list.
8488 % o exception: return any errors or warnings in this structure.
8491 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8492 const MagickBooleanType post,const int argc,const char **argv,
8493 Image **images,ExceptionInfo *exception)
8495 #define MogrifyImageTag "Mogrify/Image"
8509 assert(image_info != (ImageInfo *) NULL);
8510 assert(image_info->signature == MagickSignature);
8511 if (images == (Image **) NULL)
8512 return(MogrifyImage(image_info,argc,argv,images,exception));
8513 assert((*images)->previous == (Image *) NULL);
8514 assert((*images)->signature == MagickSignature);
8515 if ((*images)->debug != MagickFalse)
8516 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8517 (*images)->filename);
8518 if ((argc <= 0) || (*argv == (char *) NULL))
8520 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8525 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8530 Pre-process multi-image sequence operators
8532 if (post == MagickFalse)
8533 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8535 For each image, process simple single image operators
8538 n=GetImageListLength(*images);
8542 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8543 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8545 status&=MogrifyImage(image_info,argc,argv,images,exception);
8546 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8547 if (proceed == MagickFalse)
8549 if ( (*images)->next == (Image *) NULL )
8551 *images=(*images)->next;
8554 assert( *images != (Image *) NULL );
8556 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8557 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8561 Post-process, multi-image sequence operators
8563 *images=GetFirstImageInList(*images);
8564 if (post != MagickFalse)
8565 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8566 return(status != 0 ? MagickTrue : MagickFalse);