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-2016 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/magick-wand-private.h"
50 #include "MagickWand/mogrify-private.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/string-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/utility-private.h"
61 MogrifyBackgroundColor[] = "#ffffff", /* white */
62 MogrifyBorderColor[] = "#dfdfdf", /* gray */
63 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
68 #define UndefinedCompressionQuality 0UL
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % M a g i c k C o m m a n d G e n e s i s %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % MagickCommandGenesis() applies image processing options to an image as
82 % prescribed by command line options.
84 % It wiil look for special options like "-debug", "-bench", and
85 % "-distribute-cache" that needs to be applied even before the main
86 % processing begins, and may completely overrule normal command processing.
87 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
88 % and are typically ignored (as they have been handled) if seen later.
90 % The format of the MagickCommandGenesis method is:
92 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
93 % MagickCommand command,int argc,char **argv,char **metadata,
94 % ExceptionInfo *exception)
96 % A description of each parameter follows:
98 % o image_info: the image info.
100 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
101 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
102 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
103 % DisplayImageCommand, or AnimateImageCommand.
105 % o argc: Specifies a pointer to an integer describing the number of
106 % elements in the argument vector.
108 % o argv: Specifies a pointer to a text array containing the command line
111 % o metadata: any metadata is returned here.
113 % o exception: return any errors or warnings in this structure.
116 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
117 MagickCommand command,int argc,char **argv,char **metadata,
118 ExceptionInfo *exception)
142 (void) setlocale(LC_ALL,"");
143 (void) setlocale(LC_NUMERIC,"C");
144 concurrent=MagickFalse;
148 regard_warnings=MagickFalse;
149 for (i=1; i < (ssize_t) (argc-1); i++)
152 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
154 if (LocaleCompare("-bench",option) == 0)
155 iterations=StringToUnsignedLong(argv[++i]);
156 if (LocaleCompare("-concurrent",option) == 0)
157 concurrent=MagickTrue;
158 if (LocaleCompare("-debug",option) == 0)
159 (void) SetLogEventMask(argv[++i]);
160 if (LocaleCompare("-distribute-cache",option) == 0)
162 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
165 if (LocaleCompare("-duration",option) == 0)
166 duration=StringToDouble(argv[++i],(char **) NULL);
167 if (LocaleCompare("-regard-warnings",option) == 0)
168 regard_warnings=MagickTrue;
172 status=command(image_info,argc,argv,metadata,exception);
173 if (exception->severity != UndefinedException)
175 if ((exception->severity > ErrorException) ||
176 (regard_warnings != MagickFalse))
178 CatchException(exception);
180 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
182 (void) fputs(*metadata,stdout);
183 *metadata=DestroyString(*metadata);
187 number_threads=GetOpenMPMaximumThreads();
189 for (n=1; n <= (ssize_t) number_threads; n++)
199 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
200 timer=AcquireTimerInfo();
201 if (concurrent == MagickFalse)
203 for (i=0; i < (ssize_t) iterations; i++)
205 if (status == MagickFalse)
209 if (GetElapsedTime(timer) > duration)
211 (void) ContinueTimer(timer);
213 status=command(image_info,argc,argv,metadata,exception);
214 if (exception->severity != UndefinedException)
216 if ((exception->severity > ErrorException) ||
217 (regard_warnings != MagickFalse))
219 CatchException(exception);
221 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
223 (void) fputs(*metadata,stdout);
224 *metadata=DestroyString(*metadata);
231 #if defined(MAGICKCORE_OPENMP_SUPPORT)
232 # pragma omp parallel for shared(status)
234 for (i=0; i < (ssize_t) iterations; i++)
236 if (status == MagickFalse)
240 if (GetElapsedTime(timer) > duration)
242 (void) ContinueTimer(timer);
244 status=command(image_info,argc,argv,metadata,exception);
245 #if defined(MAGICKCORE_OPENMP_SUPPORT)
246 # pragma omp critical (MagickCore_MagickCommandGenesis)
249 if (exception->severity != UndefinedException)
251 if ((exception->severity > ErrorException) ||
252 (regard_warnings != MagickFalse))
254 CatchException(exception);
256 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
258 (void) fputs(*metadata,stdout);
259 *metadata=DestroyString(*metadata);
264 user_time=GetUserTime(timer);
265 parallel=GetElapsedTime(timer);
270 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
271 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
272 (void) FormatLocaleFile(stderr,
273 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
274 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
275 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
276 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
277 timer=DestroyTimerInfo(timer);
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 + M o g r i f y I m a g e %
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 % MogrifyImage() applies simple single image processing options to a single
294 % image that may be part of a large list, but also handles any 'region'
297 % The image in the list may be modified in three different ways...
299 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
300 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
301 % * replace by a list of images (only the -separate option!)
303 % In each case the result is returned into the list, and a pointer to the
304 % modified image (last image added if replaced by a list of images) is
307 % ASIDE: The -crop is present but restricted to non-tile single image crops
309 % This means if all the images are being processed (such as by
310 % MogrifyImages(), next image to be processed will be as per the pointer
311 % (*image)->next. Also the image list may grow as a result of some specific
312 % operations but as images are never merged or deleted, it will never shrink
313 % in length. Typically the list will remain the same length.
315 % WARNING: As the image pointed to may be replaced, the first image in the
316 % list may also change. GetFirstImageInList() should be used by caller if
317 % they wish return the Image pointer to the first image in list.
320 % The format of the MogrifyImage method is:
322 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
323 % const char **argv,Image **image)
325 % A description of each parameter follows:
327 % o image_info: the image info..
329 % o argc: Specifies a pointer to an integer describing the number of
330 % elements in the argument vector.
332 % o argv: Specifies a pointer to a text array containing the command line
335 % o image: the image.
337 % o exception: return any errors or warnings in this structure.
341 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
342 ExceptionInfo *exception)
345 key[MagickPathExtent];
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,MagickPathExtent,"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,MagickPathExtent);
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 MagickBooleanType MonitorProgress(const char *text,
385 const MagickOffsetType offset,const MagickSizeType extent,
386 void *wand_unused(client_data))
389 message[MagickPathExtent],
390 tag[MagickPathExtent];
398 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
400 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
402 (void) CopyMagickMemory(tag,text,MagickPathExtent);
404 if (p != (char *) NULL)
406 (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
407 locale_message=GetLocaleMessage(message);
408 if (locale_message == message)
410 if (p == (char *) NULL)
411 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
412 locale_message,(long) offset,(unsigned long) extent,(long)
413 (100L*offset/(extent-1)));
415 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
416 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
417 (100L*offset/(extent-1)));
418 if (offset == (MagickOffsetType) (extent-1))
419 (void) FormatLocaleFile(stderr,"\n");
420 (void) fflush(stderr);
424 static Image *SparseColorOption(const Image *image,
425 const SparseColorMethod method,const char *arguments,
426 const MagickBooleanType color_from_image,ExceptionInfo *exception)
429 token[MagickPathExtent];
454 SparseColorOption() parses the complex -sparse-color argument into an an
455 array of floating point values then calls SparseColorImage(). Argument is
456 a complex mix of floating-point pixel coodinates, and color specifications
457 (or direct floating point numbers). The number of floats needed to
458 represent a color varies depending on the current channel setting.
460 assert(image != (Image *) NULL);
461 assert(image->signature == MagickCoreSignature);
462 if (image->debug != MagickFalse)
463 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
464 assert(exception != (ExceptionInfo *) NULL);
465 assert(exception->signature == MagickCoreSignature);
467 Limit channels according to image - and add up number of color channel.
470 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
472 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
474 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
476 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
477 (image->colorspace == CMYKColorspace))
479 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
480 (image->alpha_trait != UndefinedPixelTrait))
484 Read string, to determine number of arguments needed,
490 GetMagickToken(p,&p,token);
491 if ( token[0] == ',' ) continue;
492 if ( isalpha((int) token[0]) || token[0] == '#' ) {
493 if ( color_from_image ) {
494 (void) ThrowMagickException(exception,GetMagickModule(),
495 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
496 "Color arg given, when colors are coming from image");
497 return( (Image *) NULL);
499 x += number_colors; /* color argument */
502 x++; /* floating point argument */
506 if ( color_from_image ) {
507 /* just the control points are being given */
508 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
509 number_arguments=(x/2)*(2+number_colors);
512 /* control points and color values */
513 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
517 (void) ThrowMagickException(exception,GetMagickModule(),
518 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
519 "Invalid number of Arguments");
520 return( (Image *) NULL);
523 /* Allocate and fill in the floating point arguments */
524 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
525 sizeof(*sparse_arguments));
526 if (sparse_arguments == (double *) NULL) {
527 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
528 "MemoryAllocationFailed","%s","SparseColorOption");
529 return( (Image *) NULL);
531 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
532 sizeof(*sparse_arguments));
535 while( *p != '\0' && x < number_arguments ) {
537 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
538 if ( token[0] == '\0' ) break;
539 if ( isalpha((int) token[0]) || token[0] == '#' ) {
540 (void) ThrowMagickException(exception,GetMagickModule(),
541 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
542 "Color found, instead of X-coord");
546 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
548 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
549 if ( token[0] == '\0' ) break;
550 if ( isalpha((int) token[0]) || token[0] == '#' ) {
551 (void) ThrowMagickException(exception,GetMagickModule(),
552 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
553 "Color found, instead of Y-coord");
557 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
558 /* color values for this control point */
560 if ( (color_from_image ) {
561 /* get color from image */
567 /* color name or function given in string argument */
568 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
569 if ( token[0] == '\0' ) break;
570 if ( isalpha((int) token[0]) || token[0] == '#' ) {
571 /* Color string given */
572 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
573 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
574 sparse_arguments[x++] = QuantumScale*color.red;
575 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
576 sparse_arguments[x++] = QuantumScale*color.green;
577 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
578 sparse_arguments[x++] = QuantumScale*color.blue;
579 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
580 (image->colorspace == CMYKColorspace))
581 sparse_arguments[x++] = QuantumScale*color.black;
582 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
583 (image->alpha_trait != UndefinedPixelTrait))
584 sparse_arguments[x++] = QuantumScale*color.alpha;
587 /* Colors given as a set of floating point values - experimental */
588 /* NB: token contains the first floating point value to use! */
589 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
591 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
592 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
594 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
595 token[0] = ','; /* used this token - get another */
597 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
599 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
600 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
602 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
603 token[0] = ','; /* used this token - get another */
605 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
607 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
608 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
610 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
611 token[0] = ','; /* used this token - get another */
613 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
614 (image->colorspace == CMYKColorspace))
616 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
617 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
619 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
620 token[0] = ','; /* used this token - get another */
622 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
623 (image->alpha_trait != UndefinedPixelTrait))
625 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
626 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
628 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
629 token[0] = ','; /* used this token - get another */
634 if ( number_arguments != x && !error ) {
635 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
636 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
637 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
638 return( (Image *) NULL);
641 return( (Image *) NULL);
643 /* Call the Interpolation function with the parsed arguments */
644 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
646 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
647 return( sparse_image );
650 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
651 const char **argv,Image **image,ExceptionInfo *exception)
684 PixelInterpolateMethod
698 Initialize method variables.
700 assert(image_info != (const ImageInfo *) NULL);
701 assert(image_info->signature == MagickCoreSignature);
702 assert(image != (Image **) NULL);
703 assert((*image)->signature == MagickCoreSignature);
704 if ((*image)->debug != MagickFalse)
705 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
708 mogrify_info=CloneImageInfo(image_info);
709 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
710 quantize_info=AcquireQuantizeInfo(mogrify_info);
711 SetGeometryInfo(&geometry_info);
712 GetPixelInfo(*image,&fill);
713 fill=(*image)->background_color;
715 compose=(*image)->compose;
716 interpolate_method=UndefinedInterpolatePixel;
717 format=GetImageOption(mogrify_info,"format");
718 SetGeometry(*image,®ion_geometry);
719 region_image=NewImageList();
721 Transmogrify the image.
723 for (i=0; i < (ssize_t) argc; i++)
732 if (IsCommandOption(option) == MagickFalse)
734 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
736 if ((i+count) >= (ssize_t) argc)
738 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
739 mogrify_image=(Image *) NULL;
744 if (LocaleCompare("adaptive-blur",option+1) == 0)
749 (void) SyncImageSettings(mogrify_info,*image,exception);
750 flags=ParseGeometry(argv[i+1],&geometry_info);
751 if ((flags & SigmaValue) == 0)
752 geometry_info.sigma=1.0;
753 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
754 geometry_info.sigma,exception);
757 if (LocaleCompare("adaptive-resize",option+1) == 0)
760 Adaptive resize image.
762 (void) SyncImageSettings(mogrify_info,*image,exception);
763 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
764 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
765 geometry.height,exception);
768 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
771 Adaptive sharpen image.
773 (void) SyncImageSettings(mogrify_info,*image,exception);
774 flags=ParseGeometry(argv[i+1],&geometry_info);
775 if ((flags & SigmaValue) == 0)
776 geometry_info.sigma=1.0;
777 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
778 geometry_info.sigma,exception);
781 if (LocaleCompare("affine",option+1) == 0)
788 GetAffineMatrix(&draw_info->affine);
791 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
794 if (LocaleCompare("alpha",option+1) == 0)
799 (void) SyncImageSettings(mogrify_info,*image,exception);
800 alpha_type=(AlphaChannelOption) ParseCommandOption(
801 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
802 (void) SetImageAlphaChannel(*image,alpha_type,exception);
805 if (LocaleCompare("annotate",option+1) == 0)
809 geometry_str[MagickPathExtent];
814 (void) SyncImageSettings(mogrify_info,*image,exception);
815 SetGeometryInfo(&geometry_info);
816 flags=ParseGeometry(argv[i+1],&geometry_info);
817 if ((flags & SigmaValue) == 0)
818 geometry_info.sigma=geometry_info.rho;
819 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
821 if (text == (char *) NULL)
823 (void) CloneString(&draw_info->text,text);
824 text=DestroyString(text);
825 (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
826 geometry_info.xi,geometry_info.psi);
827 (void) CloneString(&draw_info->geometry,geometry_str);
828 draw_info->affine.sx=cos(DegreesToRadians(
829 fmod(geometry_info.rho,360.0)));
830 draw_info->affine.rx=sin(DegreesToRadians(
831 fmod(geometry_info.rho,360.0)));
832 draw_info->affine.ry=(-sin(DegreesToRadians(
833 fmod(geometry_info.sigma,360.0))));
834 draw_info->affine.sy=cos(DegreesToRadians(
835 fmod(geometry_info.sigma,360.0)));
836 (void) AnnotateImage(*image,draw_info,exception);
839 if (LocaleCompare("antialias",option+1) == 0)
841 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
843 draw_info->text_antialias=(*option == '-') ? MagickTrue :
847 if (LocaleCompare("attenuate",option+1) == 0)
854 attenuate=StringToDouble(argv[i+1],(char **) NULL);
857 if (LocaleCompare("auto-gamma",option+1) == 0)
860 Auto Adjust Gamma of image based on its mean
862 (void) SyncImageSettings(mogrify_info,*image,exception);
863 (void) AutoGammaImage(*image,exception);
866 if (LocaleCompare("auto-level",option+1) == 0)
869 Perfectly Normalize (max/min stretch) the image
871 (void) SyncImageSettings(mogrify_info,*image,exception);
872 (void) AutoLevelImage(*image,exception);
875 if (LocaleCompare("auto-orient",option+1) == 0)
877 (void) SyncImageSettings(mogrify_info,*image,exception);
878 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
886 if (LocaleCompare("black-threshold",option+1) == 0)
889 Black threshold image.
891 (void) SyncImageSettings(mogrify_info,*image,exception);
892 (void) BlackThresholdImage(*image,argv[i+1],exception);
895 if (LocaleCompare("blue-shift",option+1) == 0)
900 (void) SyncImageSettings(mogrify_info,*image,exception);
901 geometry_info.rho=1.5;
903 flags=ParseGeometry(argv[i+1],&geometry_info);
904 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
907 if (LocaleCompare("blur",option+1) == 0)
912 (void) SyncImageSettings(mogrify_info,*image,exception);
913 flags=ParseGeometry(argv[i+1],&geometry_info);
914 if ((flags & SigmaValue) == 0)
915 geometry_info.sigma=1.0;
916 if ((flags & XiValue) == 0)
917 geometry_info.xi=0.0;
918 mogrify_image=BlurImage(*image,geometry_info.rho,
919 geometry_info.sigma,exception);
922 if (LocaleCompare("border",option+1) == 0)
925 Surround image with a border of solid color.
927 (void) SyncImageSettings(mogrify_info,*image,exception);
928 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
929 mogrify_image=BorderImage(*image,&geometry,compose,exception);
932 if (LocaleCompare("bordercolor",option+1) == 0)
936 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
937 &draw_info->border_color,exception);
940 (void) QueryColorCompliance(argv[i+1],AllCompliance,
941 &draw_info->border_color,exception);
944 if (LocaleCompare("box",option+1) == 0)
946 (void) QueryColorCompliance(argv[i+1],AllCompliance,
947 &draw_info->undercolor,exception);
950 if (LocaleCompare("brightness-contrast",option+1) == 0)
957 Brightness / contrast image.
959 (void) SyncImageSettings(mogrify_info,*image,exception);
960 flags=ParseGeometry(argv[i+1],&geometry_info);
961 brightness=geometry_info.rho;
963 if ((flags & SigmaValue) != 0)
964 contrast=geometry_info.sigma;
965 (void) BrightnessContrastImage(*image,brightness,contrast,
973 if (LocaleCompare("canny",option+1) == 0)
976 Detect edges in the image.
978 (void) SyncImageSettings(mogrify_info,*image,exception);
979 flags=ParseGeometry(argv[i+1],&geometry_info);
980 if ((flags & SigmaValue) == 0)
981 geometry_info.sigma=1.0;
982 if ((flags & XiValue) == 0)
983 geometry_info.xi=0.10;
984 if ((flags & PsiValue) == 0)
985 geometry_info.psi=0.30;
986 if ((flags & PercentValue) != 0)
988 geometry_info.xi/=100.0;
989 geometry_info.psi/=100.0;
991 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
992 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
995 if (LocaleCompare("cdl",option+1) == 0)
998 *color_correction_collection;
1001 Color correct with a color decision list.
1003 (void) SyncImageSettings(mogrify_info,*image,exception);
1004 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1005 if (color_correction_collection == (char *) NULL)
1007 (void) ColorDecisionListImage(*image,color_correction_collection,
1011 if (LocaleCompare("channel",option+1) == 0)
1016 (void) SyncImageSettings(mogrify_info,*image,exception);
1019 (void) SetPixelChannelMask(*image,DefaultChannels);
1022 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1023 (void) SetPixelChannelMask(*image,channel);
1026 if (LocaleCompare("charcoal",option+1) == 0)
1031 (void) SyncImageSettings(mogrify_info,*image,exception);
1032 flags=ParseGeometry(argv[i+1],&geometry_info);
1033 if ((flags & SigmaValue) == 0)
1034 geometry_info.sigma=1.0;
1035 if ((flags & XiValue) == 0)
1036 geometry_info.xi=1.0;
1037 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1038 geometry_info.sigma,exception);
1041 if (LocaleCompare("chop",option+1) == 0)
1046 (void) SyncImageSettings(mogrify_info,*image,exception);
1047 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1048 mogrify_image=ChopImage(*image,&geometry,exception);
1051 if (LocaleCompare("clip",option+1) == 0)
1053 (void) SyncImageSettings(mogrify_info,*image,exception);
1056 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
1060 (void) ClipImage(*image,exception);
1063 if (LocaleCompare("clip-mask",option+1) == 0)
1080 (void) SyncImageSettings(mogrify_info,*image,exception);
1086 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
1092 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1094 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1095 if (mask_image == (Image *) NULL)
1097 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1098 return(MagickFalse);
1099 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1100 for (y=0; y < (ssize_t) mask_image->rows; y++)
1102 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1104 if (q == (Quantum *) NULL)
1106 for (x=0; x < (ssize_t) mask_image->columns; x++)
1108 if (mask_image->alpha_trait == UndefinedPixelTrait)
1109 SetPixelAlpha(mask_image,(Quantum)
1110 GetPixelIntensity(mask_image,q),q);
1111 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1112 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1113 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1114 q+=GetPixelChannels(mask_image);
1116 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1119 mask_view=DestroyCacheView(mask_view);
1120 mask_image->alpha_trait=BlendPixelTrait;
1121 (void) SetImageMask(*image,ReadPixelMask,mask_image,exception);
1124 if (LocaleCompare("clip-path",option+1) == 0)
1126 (void) SyncImageSettings(mogrify_info,*image,exception);
1127 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1128 MagickFalse,exception);
1131 if (LocaleCompare("colorize",option+1) == 0)
1136 (void) SyncImageSettings(mogrify_info,*image,exception);
1137 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1140 if (LocaleCompare("color-matrix",option+1) == 0)
1145 (void) SyncImageSettings(mogrify_info,*image,exception);
1146 kernel=AcquireKernelInfo(argv[i+1],exception);
1147 if (kernel == (KernelInfo *) NULL)
1149 /* FUTURE: check on size of the matrix */
1150 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1151 kernel=DestroyKernelInfo(kernel);
1154 if (LocaleCompare("colors",option+1) == 0)
1157 Reduce the number of colors in the image.
1159 (void) SyncImageSettings(mogrify_info,*image,exception);
1160 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1161 if (quantize_info->number_colors == 0)
1163 if (((*image)->storage_class == DirectClass) ||
1164 (*image)->colors > quantize_info->number_colors)
1165 (void) QuantizeImage(quantize_info,*image,exception);
1167 (void) CompressImageColormap(*image,exception);
1170 if (LocaleCompare("colorspace",option+1) == 0)
1175 (void) SyncImageSettings(mogrify_info,*image,exception);
1178 (void) TransformImageColorspace(*image,sRGBColorspace,
1182 colorspace=(ColorspaceType) ParseCommandOption(
1183 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1184 (void) TransformImageColorspace(*image,colorspace,exception);
1187 if (LocaleCompare("compose",option+1) == 0)
1189 (void) SyncImageSettings(mogrify_info,*image,exception);
1190 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1191 MagickFalse,argv[i+1]);
1194 if (LocaleCompare("connected-components",option+1) == 0)
1196 (void) SyncImageSettings(mogrify_info,*image,exception);
1197 mogrify_image=ConnectedComponentsImage(*image,(size_t)
1198 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1201 if (LocaleCompare("contrast",option+1) == 0)
1203 (void) SyncImageSettings(mogrify_info,*image,exception);
1204 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1205 MagickFalse,exception);
1208 if (LocaleCompare("contrast-stretch",option+1) == 0)
1215 Contrast stretch image.
1217 (void) SyncImageSettings(mogrify_info,*image,exception);
1218 flags=ParseGeometry(argv[i+1],&geometry_info);
1219 black_point=geometry_info.rho;
1220 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1222 if ((flags & PercentValue) != 0)
1224 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1225 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1227 white_point=(double) (*image)->columns*(*image)->rows-
1229 (void) ContrastStretchImage(*image,black_point,white_point,
1233 if (LocaleCompare("convolve",option+1) == 0)
1247 (void) SyncImageSettings(mogrify_info,*image,exception);
1248 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1249 if (kernel_info == (KernelInfo *) NULL)
1251 extent=kernel_info->width*kernel_info->height;
1253 for (j=0; j < (ssize_t) extent; j++)
1254 gamma+=kernel_info->values[j];
1255 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1256 for (j=0; j < (ssize_t) extent; j++)
1257 kernel_info->values[j]*=gamma;
1258 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1259 kernel_info,exception);
1260 kernel_info=DestroyKernelInfo(kernel_info);
1263 if (LocaleCompare("crop",option+1) == 0)
1266 Crop a image to a smaller size
1268 (void) SyncImageSettings(mogrify_info,*image,exception);
1269 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1272 if (LocaleCompare("cycle",option+1) == 0)
1275 Cycle an image colormap.
1277 (void) SyncImageSettings(mogrify_info,*image,exception);
1278 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1286 if (LocaleCompare("decipher",option+1) == 0)
1294 (void) SyncImageSettings(mogrify_info,*image,exception);
1295 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1296 if (passkey != (StringInfo *) NULL)
1298 (void) PasskeyDecipherImage(*image,passkey,exception);
1299 passkey=DestroyStringInfo(passkey);
1303 if (LocaleCompare("density",option+1) == 0)
1308 (void) CloneString(&draw_info->density,argv[i+1]);
1311 if (LocaleCompare("depth",option+1) == 0)
1313 (void) SyncImageSettings(mogrify_info,*image,exception);
1316 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1319 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1323 if (LocaleCompare("deskew",option+1) == 0)
1329 Straighten the image.
1331 (void) SyncImageSettings(mogrify_info,*image,exception);
1333 threshold=40.0*QuantumRange/100.0;
1335 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1337 mogrify_image=DeskewImage(*image,threshold,exception);
1340 if (LocaleCompare("despeckle",option+1) == 0)
1343 Reduce the speckles within an image.
1345 (void) SyncImageSettings(mogrify_info,*image,exception);
1346 mogrify_image=DespeckleImage(*image,exception);
1349 if (LocaleCompare("display",option+1) == 0)
1351 (void) CloneString(&draw_info->server_name,argv[i+1]);
1354 if (LocaleCompare("distort",option+1) == 0)
1358 token[MagickPathExtent];
1378 (void) SyncImageSettings(mogrify_info,*image,exception);
1379 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1380 MagickFalse,argv[i+1]);
1381 if (method == ResizeDistortion)
1387 Special Case - Argument is actually a resize geometry!
1388 Convert that to an appropriate distortion argument array.
1390 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1392 resize_args[0]=(double) geometry.width;
1393 resize_args[1]=(double) geometry.height;
1394 mogrify_image=DistortImage(*image,method,(size_t)2,
1395 resize_args,MagickTrue,exception);
1398 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1400 if (args == (char *) NULL)
1403 for (x=0; *p != '\0'; x++)
1405 GetMagickToken(p,&p,token);
1407 GetMagickToken(p,&p,token);
1409 number_arguments=(size_t) x;
1410 arguments=(double *) AcquireQuantumMemory(number_arguments,
1411 sizeof(*arguments));
1412 if (arguments == (double *) NULL)
1413 ThrowWandFatalException(ResourceLimitFatalError,
1414 "MemoryAllocationFailed",(*image)->filename);
1415 (void) ResetMagickMemory(arguments,0,number_arguments*
1416 sizeof(*arguments));
1418 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1420 GetMagickToken(p,&p,token);
1422 GetMagickToken(p,&p,token);
1423 arguments[x]=StringToDouble(token,(char **) NULL);
1425 args=DestroyString(args);
1426 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1427 (*option == '+') ? MagickTrue : MagickFalse,exception);
1428 arguments=(double *) RelinquishMagickMemory(arguments);
1431 if (LocaleCompare("dither",option+1) == 0)
1435 quantize_info->dither_method=NoDitherMethod;
1438 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1439 MagickDitherOptions,MagickFalse,argv[i+1]);
1442 if (LocaleCompare("draw",option+1) == 0)
1447 (void) SyncImageSettings(mogrify_info,*image,exception);
1448 (void) CloneString(&draw_info->primitive,argv[i+1]);
1449 (void) DrawImage(*image,draw_info,exception);
1456 if (LocaleCompare("edge",option+1) == 0)
1459 Enhance edges in the image.
1461 (void) SyncImageSettings(mogrify_info,*image,exception);
1462 flags=ParseGeometry(argv[i+1],&geometry_info);
1463 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1466 if (LocaleCompare("emboss",option+1) == 0)
1471 (void) SyncImageSettings(mogrify_info,*image,exception);
1472 flags=ParseGeometry(argv[i+1],&geometry_info);
1473 if ((flags & SigmaValue) == 0)
1474 geometry_info.sigma=1.0;
1475 mogrify_image=EmbossImage(*image,geometry_info.rho,
1476 geometry_info.sigma,exception);
1479 if (LocaleCompare("encipher",option+1) == 0)
1487 (void) SyncImageSettings(mogrify_info,*image,exception);
1488 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1489 if (passkey != (StringInfo *) NULL)
1491 (void) PasskeyEncipherImage(*image,passkey,exception);
1492 passkey=DestroyStringInfo(passkey);
1496 if (LocaleCompare("encoding",option+1) == 0)
1498 (void) CloneString(&draw_info->encoding,argv[i+1]);
1501 if (LocaleCompare("enhance",option+1) == 0)
1506 (void) SyncImageSettings(mogrify_info,*image,exception);
1507 mogrify_image=EnhanceImage(*image,exception);
1510 if (LocaleCompare("equalize",option+1) == 0)
1515 (void) SyncImageSettings(mogrify_info,*image,exception);
1516 (void) EqualizeImage(*image,exception);
1519 if (LocaleCompare("evaluate",option+1) == 0)
1524 MagickEvaluateOperator
1527 (void) SyncImageSettings(mogrify_info,*image,exception);
1528 op=(MagickEvaluateOperator) ParseCommandOption(
1529 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1530 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1532 (void) EvaluateImage(*image,op,constant,exception);
1535 if (LocaleCompare("extent",option+1) == 0)
1538 Set the image extent.
1540 (void) SyncImageSettings(mogrify_info,*image,exception);
1541 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1542 if (geometry.width == 0)
1543 geometry.width=(*image)->columns;
1544 if (geometry.height == 0)
1545 geometry.height=(*image)->rows;
1546 mogrify_image=ExtentImage(*image,&geometry,exception);
1553 if (LocaleCompare("family",option+1) == 0)
1557 if (draw_info->family != (char *) NULL)
1558 draw_info->family=DestroyString(draw_info->family);
1561 (void) CloneString(&draw_info->family,argv[i+1]);
1564 if (LocaleCompare("features",option+1) == 0)
1568 (void) DeleteImageArtifact(*image,"identify:features");
1571 (void) SetImageArtifact(*image,"vdentify:features",argv[i+1]);
1572 (void) SetImageArtifact(*image,"verbose","true");
1575 if (LocaleCompare("fill",option+1) == 0)
1583 GetPixelInfo(*image,&fill);
1586 (void) QueryColorCompliance("none",AllCompliance,&fill,
1588 draw_info->fill=fill;
1589 if (draw_info->fill_pattern != (Image *) NULL)
1590 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1593 sans=AcquireExceptionInfo();
1594 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1595 sans=DestroyExceptionInfo(sans);
1596 if (status == MagickFalse)
1597 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1600 draw_info->fill=fill=color;
1603 if (LocaleCompare("flip",option+1) == 0)
1606 Flip image scanlines.
1608 (void) SyncImageSettings(mogrify_info,*image,exception);
1609 mogrify_image=FlipImage(*image,exception);
1612 if (LocaleCompare("floodfill",option+1) == 0)
1620 (void) SyncImageSettings(mogrify_info,*image,exception);
1621 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1622 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1624 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1625 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1628 if (LocaleCompare("flop",option+1) == 0)
1631 Flop image scanlines.
1633 (void) SyncImageSettings(mogrify_info,*image,exception);
1634 mogrify_image=FlopImage(*image,exception);
1637 if (LocaleCompare("font",option+1) == 0)
1641 if (draw_info->font != (char *) NULL)
1642 draw_info->font=DestroyString(draw_info->font);
1645 (void) CloneString(&draw_info->font,argv[i+1]);
1648 if (LocaleCompare("format",option+1) == 0)
1653 if (LocaleCompare("frame",option+1) == 0)
1659 Surround image with an ornamental border.
1661 (void) SyncImageSettings(mogrify_info,*image,exception);
1662 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1663 frame_info.width=geometry.width;
1664 frame_info.height=geometry.height;
1665 frame_info.outer_bevel=geometry.x;
1666 frame_info.inner_bevel=geometry.y;
1667 frame_info.x=(ssize_t) frame_info.width;
1668 frame_info.y=(ssize_t) frame_info.height;
1669 frame_info.width=(*image)->columns+2*frame_info.width;
1670 frame_info.height=(*image)->rows+2*frame_info.height;
1671 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1674 if (LocaleCompare("function",option+1) == 0)
1678 token[MagickPathExtent];
1696 Function Modify Image Values
1698 (void) SyncImageSettings(mogrify_info,*image,exception);
1699 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1700 MagickFalse,argv[i+1]);
1701 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1703 if (arguments == (char *) NULL)
1705 p=(char *) arguments;
1706 for (x=0; *p != '\0'; x++)
1708 GetMagickToken(p,&p,token);
1710 GetMagickToken(p,&p,token);
1712 number_parameters=(size_t) x;
1713 parameters=(double *) AcquireQuantumMemory(number_parameters,
1714 sizeof(*parameters));
1715 if (parameters == (double *) NULL)
1716 ThrowWandFatalException(ResourceLimitFatalError,
1717 "MemoryAllocationFailed",(*image)->filename);
1718 (void) ResetMagickMemory(parameters,0,number_parameters*
1719 sizeof(*parameters));
1720 p=(char *) arguments;
1721 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1723 GetMagickToken(p,&p,token);
1725 GetMagickToken(p,&p,token);
1726 parameters[x]=StringToDouble(token,(char **) NULL);
1728 arguments=DestroyString(arguments);
1729 (void) FunctionImage(*image,function,number_parameters,parameters,
1731 parameters=(double *) RelinquishMagickMemory(parameters);
1738 if (LocaleCompare("gamma",option+1) == 0)
1743 (void) SyncImageSettings(mogrify_info,*image,exception);
1745 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1747 (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1751 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1752 (LocaleCompare("gaussian",option+1) == 0))
1755 Gaussian blur image.
1757 (void) SyncImageSettings(mogrify_info,*image,exception);
1758 flags=ParseGeometry(argv[i+1],&geometry_info);
1759 if ((flags & SigmaValue) == 0)
1760 geometry_info.sigma=1.0;
1761 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1762 geometry_info.sigma,exception);
1765 if (LocaleCompare("geometry",option+1) == 0)
1768 Record Image offset, Resize last image.
1770 (void) SyncImageSettings(mogrify_info,*image,exception);
1773 if ((*image)->geometry != (char *) NULL)
1774 (*image)->geometry=DestroyString((*image)->geometry);
1777 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1778 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1779 (void) CloneString(&(*image)->geometry,argv[i+1]);
1781 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1782 (*image)->filter,exception);
1785 if (LocaleCompare("gravity",option+1) == 0)
1789 draw_info->gravity=UndefinedGravity;
1792 draw_info->gravity=(GravityType) ParseCommandOption(
1793 MagickGravityOptions,MagickFalse,argv[i+1]);
1796 if (LocaleCompare("grayscale",option+1) == 0)
1798 PixelIntensityMethod
1801 (void) SyncImageSettings(mogrify_info,*image,exception);
1802 method=(PixelIntensityMethod) ParseCommandOption(
1803 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1804 (void) GrayscaleImage(*image,method,exception);
1811 if (LocaleCompare("highlight-color",option+1) == 0)
1813 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1816 if (LocaleCompare("hough-lines",option+1) == 0)
1819 Detect edges in the image.
1821 (void) SyncImageSettings(mogrify_info,*image,exception);
1822 flags=ParseGeometry(argv[i+1],&geometry_info);
1823 if ((flags & SigmaValue) == 0)
1824 geometry_info.sigma=geometry_info.rho;
1825 if ((flags & XiValue) == 0)
1826 geometry_info.xi=40;
1827 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1828 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1835 if (LocaleCompare("identify",option+1) == 0)
1840 (void) SyncImageSettings(mogrify_info,*image,exception);
1841 if (format == (char *) NULL)
1843 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1847 text=InterpretImageProperties(mogrify_info,*image,format,
1849 if (text == (char *) NULL)
1851 (void) fputs(text,stdout);
1852 text=DestroyString(text);
1855 if (LocaleCompare("implode",option+1) == 0)
1860 (void) SyncImageSettings(mogrify_info,*image,exception);
1861 (void) ParseGeometry(argv[i+1],&geometry_info);
1862 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1863 interpolate_method,exception);
1866 if (LocaleCompare("interline-spacing",option+1) == 0)
1869 (void) ParseGeometry("0",&geometry_info);
1871 (void) ParseGeometry(argv[i+1],&geometry_info);
1872 draw_info->interline_spacing=geometry_info.rho;
1875 if (LocaleCompare("interpolate",option+1) == 0)
1877 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1878 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1881 if (LocaleCompare("interword-spacing",option+1) == 0)
1884 (void) ParseGeometry("0",&geometry_info);
1886 (void) ParseGeometry(argv[i+1],&geometry_info);
1887 draw_info->interword_spacing=geometry_info.rho;
1890 if (LocaleCompare("interpolative-resize",option+1) == 0)
1893 Interpolative resize image.
1895 (void) SyncImageSettings(mogrify_info,*image,exception);
1896 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1897 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1898 geometry.height,interpolate_method,exception);
1905 if (LocaleCompare("kerning",option+1) == 0)
1908 (void) ParseGeometry("0",&geometry_info);
1910 (void) ParseGeometry(argv[i+1],&geometry_info);
1911 draw_info->kerning=geometry_info.rho;
1914 if (LocaleCompare("kuwahara",option+1) == 0)
1917 Edge preserving blur.
1919 (void) SyncImageSettings(mogrify_info,*image,exception);
1920 flags=ParseGeometry(argv[i+1],&geometry_info);
1921 if ((flags & SigmaValue) == 0)
1922 geometry_info.sigma=geometry_info.rho-0.5;
1923 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1924 geometry_info.sigma,exception);
1931 if (LocaleCompare("lat",option+1) == 0)
1934 Local adaptive threshold image.
1936 (void) SyncImageSettings(mogrify_info,*image,exception);
1937 flags=ParseGeometry(argv[i+1],&geometry_info);
1938 if ((flags & PercentValue) != 0)
1939 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1940 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1941 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1942 geometry_info.xi,exception);
1945 if (LocaleCompare("level",option+1) == 0)
1955 (void) SyncImageSettings(mogrify_info,*image,exception);
1956 flags=ParseGeometry(argv[i+1],&geometry_info);
1957 black_point=geometry_info.rho;
1958 white_point=(double) QuantumRange;
1959 if ((flags & SigmaValue) != 0)
1960 white_point=geometry_info.sigma;
1962 if ((flags & XiValue) != 0)
1963 gamma=geometry_info.xi;
1964 if ((flags & PercentValue) != 0)
1966 black_point*=(double) (QuantumRange/100.0);
1967 white_point*=(double) (QuantumRange/100.0);
1969 if ((flags & SigmaValue) == 0)
1970 white_point=(double) QuantumRange-black_point;
1971 if ((*option == '+') || ((flags & AspectValue) != 0))
1972 (void) LevelizeImage(*image,black_point,white_point,gamma,
1975 (void) LevelImage(*image,black_point,white_point,gamma,
1979 if (LocaleCompare("level-colors",option+1) == 0)
1982 token[MagickPathExtent];
1991 p=(const char *) argv[i+1];
1992 GetMagickToken(p,&p,token); /* get black point color */
1993 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1994 (void) QueryColorCompliance(token,AllCompliance,
1995 &black_point,exception);
1997 (void) QueryColorCompliance("#000000",AllCompliance,
1998 &black_point,exception);
1999 if (isalpha((int) token[0]) || (token[0] == '#'))
2000 GetMagickToken(p,&p,token);
2002 white_point=black_point; /* set everything to that color */
2005 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2006 GetMagickToken(p,&p,token); /* Get white point color. */
2007 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2008 (void) QueryColorCompliance(token,AllCompliance,
2009 &white_point,exception);
2011 (void) QueryColorCompliance("#ffffff",AllCompliance,
2012 &white_point,exception);
2014 (void) LevelImageColors(*image,&black_point,&white_point,
2015 *option == '+' ? MagickTrue : MagickFalse,exception);
2018 if (LocaleCompare("linear-stretch",option+1) == 0)
2024 (void) SyncImageSettings(mogrify_info,*image,exception);
2025 flags=ParseGeometry(argv[i+1],&geometry_info);
2026 black_point=geometry_info.rho;
2027 white_point=(double) (*image)->columns*(*image)->rows;
2028 if ((flags & SigmaValue) != 0)
2029 white_point=geometry_info.sigma;
2030 if ((flags & PercentValue) != 0)
2032 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2033 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2035 if ((flags & SigmaValue) == 0)
2036 white_point=(double) (*image)->columns*(*image)->rows-
2038 (void) LinearStretchImage(*image,black_point,white_point,exception);
2041 if (LocaleCompare("liquid-rescale",option+1) == 0)
2044 Liquid rescale image.
2046 (void) SyncImageSettings(mogrify_info,*image,exception);
2047 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2048 if ((flags & XValue) == 0)
2050 if ((flags & YValue) == 0)
2052 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2053 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2056 if (LocaleCompare("local-contrast",option+1) == 0)
2058 (void) SyncImageSettings(mogrify_info,*image,exception);
2059 flags=ParseGeometry(argv[i+1],&geometry_info);
2060 if ((flags & RhoValue) == 0)
2061 geometry_info.rho=10;
2062 if ((flags & SigmaValue) == 0)
2063 geometry_info.sigma=12.5;
2064 if (((flags & RhoValue) == 0) || ((flags & PercentValue) != 0))
2065 geometry_info.rho*=MagickMax((*image)->columns,(*image)->rows)/
2067 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2068 geometry_info.sigma,exception);
2071 if (LocaleCompare("lowlight-color",option+1) == 0)
2073 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2080 if (LocaleCompare("magnify",option+1) == 0)
2085 (void) SyncImageSettings(mogrify_info,*image,exception);
2086 mogrify_image=MagnifyImage(*image,exception);
2089 if (LocaleCompare("map",option+1) == 0)
2095 Transform image colors to match this set of colors.
2097 (void) SyncImageSettings(mogrify_info,*image,exception);
2100 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2101 if (remap_image == (Image *) NULL)
2103 (void) RemapImage(quantize_info,*image,remap_image,exception);
2104 remap_image=DestroyImage(remap_image);
2107 if (LocaleCompare("mask",option+1) == 0)
2112 (void) SyncImageSettings(mogrify_info,*image,exception);
2118 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
2125 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2126 if (mask == (Image *) NULL)
2128 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2129 mask=DestroyImage(mask);
2132 if (LocaleCompare("matte",option+1) == 0)
2134 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2135 SetAlphaChannel : DeactivateAlphaChannel,exception);
2138 if (LocaleCompare("mean-shift",option+1) == 0)
2141 Detect edges in the image.
2143 (void) SyncImageSettings(mogrify_info,*image,exception);
2144 flags=ParseGeometry(argv[i+1],&geometry_info);
2145 if ((flags & SigmaValue) == 0)
2146 geometry_info.sigma=geometry_info.rho;
2147 if ((flags & XiValue) == 0)
2148 geometry_info.xi=0.10*QuantumRange;
2149 if ((flags & PercentValue) != 0)
2150 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2151 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2152 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2155 if (LocaleCompare("median",option+1) == 0)
2158 Median filter image.
2160 (void) SyncImageSettings(mogrify_info,*image,exception);
2161 flags=ParseGeometry(argv[i+1],&geometry_info);
2162 if ((flags & SigmaValue) == 0)
2163 geometry_info.sigma=geometry_info.rho;
2164 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2165 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2168 if (LocaleCompare("mode",option+1) == 0)
2173 (void) SyncImageSettings(mogrify_info,*image,exception);
2174 flags=ParseGeometry(argv[i+1],&geometry_info);
2175 if ((flags & SigmaValue) == 0)
2176 geometry_info.sigma=geometry_info.rho;
2177 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2178 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2181 if (LocaleCompare("modulate",option+1) == 0)
2183 (void) SyncImageSettings(mogrify_info,*image,exception);
2184 (void) ModulateImage(*image,argv[i+1],exception);
2187 if (LocaleCompare("moments",option+1) == 0)
2191 (void) DeleteImageArtifact(*image,"identify:moments");
2194 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2195 (void) SetImageArtifact(*image,"verbose","true");
2198 if (LocaleCompare("monitor",option+1) == 0)
2202 (void) SetImageProgressMonitor(*image,
2203 (MagickProgressMonitor) NULL,(void *) NULL);
2206 (void) SetImageProgressMonitor(*image,MonitorProgress,
2210 if (LocaleCompare("monochrome",option+1) == 0)
2212 (void) SyncImageSettings(mogrify_info,*image,exception);
2213 (void) SetImageType(*image,BilevelType,exception);
2216 if (LocaleCompare("morphology",option+1) == 0)
2219 token[MagickPathExtent];
2234 Morphological Image Operation
2236 (void) SyncImageSettings(mogrify_info,*image,exception);
2238 GetMagickToken(p,&p,token);
2239 method=(MorphologyMethod) ParseCommandOption(
2240 MagickMorphologyOptions,MagickFalse,token);
2242 GetMagickToken(p,&p,token);
2243 if ((*p == ':') || (*p == ','))
2244 GetMagickToken(p,&p,token);
2246 iterations=(ssize_t) StringToLong(p);
2247 kernel=AcquireKernelInfo(argv[i+2],exception);
2248 if (kernel == (KernelInfo *) NULL)
2250 (void) ThrowMagickException(exception,GetMagickModule(),
2251 OptionError,"UnabletoParseKernel","morphology");
2255 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2257 kernel=DestroyKernelInfo(kernel);
2260 if (LocaleCompare("motion-blur",option+1) == 0)
2265 (void) SyncImageSettings(mogrify_info,*image,exception);
2266 flags=ParseGeometry(argv[i+1],&geometry_info);
2267 if ((flags & SigmaValue) == 0)
2268 geometry_info.sigma=1.0;
2269 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2270 geometry_info.sigma,geometry_info.xi,exception);
2277 if (LocaleCompare("negate",option+1) == 0)
2279 (void) SyncImageSettings(mogrify_info,*image,exception);
2280 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2281 MagickFalse,exception);
2284 if (LocaleCompare("noise",option+1) == 0)
2286 (void) SyncImageSettings(mogrify_info,*image,exception);
2289 flags=ParseGeometry(argv[i+1],&geometry_info);
2290 if ((flags & SigmaValue) == 0)
2291 geometry_info.sigma=geometry_info.rho;
2292 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2293 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2300 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2301 MagickFalse,argv[i+1]);
2302 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2306 if (LocaleCompare("normalize",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image,exception);
2309 (void) NormalizeImage(*image,exception);
2316 if (LocaleCompare("opaque",option+1) == 0)
2321 (void) SyncImageSettings(mogrify_info,*image,exception);
2322 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2324 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2325 MagickFalse : MagickTrue,exception);
2328 if (LocaleCompare("ordered-dither",option+1) == 0)
2330 (void) SyncImageSettings(mogrify_info,*image,exception);
2331 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2338 if (LocaleCompare("paint",option+1) == 0)
2340 (void) SyncImageSettings(mogrify_info,*image,exception);
2341 (void) ParseGeometry(argv[i+1],&geometry_info);
2342 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2343 geometry_info.sigma,exception);
2346 if (LocaleCompare("perceptible",option+1) == 0)
2351 (void) SyncImageSettings(mogrify_info,*image,exception);
2352 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2353 (char **) NULL),exception);
2356 if (LocaleCompare("pointsize",option+1) == 0)
2359 (void) ParseGeometry("12",&geometry_info);
2361 (void) ParseGeometry(argv[i+1],&geometry_info);
2362 draw_info->pointsize=geometry_info.rho;
2365 if (LocaleCompare("polaroid",option+1) == 0)
2377 Simulate a Polaroid picture.
2379 (void) SyncImageSettings(mogrify_info,*image,exception);
2380 random_info=AcquireRandomInfo();
2381 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2382 random_info=DestroyRandomInfo(random_info);
2385 SetGeometryInfo(&geometry_info);
2386 flags=ParseGeometry(argv[i+1],&geometry_info);
2387 angle=geometry_info.rho;
2389 caption=GetImageProperty(*image,"caption",exception);
2390 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2391 interpolate_method,exception);
2394 if (LocaleCompare("posterize",option+1) == 0)
2399 (void) SyncImageSettings(mogrify_info,*image,exception);
2400 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2401 quantize_info->dither_method,exception);
2404 if (LocaleCompare("preview",option+1) == 0)
2412 (void) SyncImageSettings(mogrify_info,*image,exception);
2414 preview_type=UndefinedPreview;
2416 preview_type=(PreviewType) ParseCommandOption(
2417 MagickPreviewOptions,MagickFalse,argv[i+1]);
2418 mogrify_image=PreviewImage(*image,preview_type,exception);
2421 if (LocaleCompare("profile",option+1) == 0)
2435 (void) SyncImageSettings(mogrify_info,*image,exception);
2439 Remove a profile from the image.
2441 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2446 Associate a profile with the image.
2448 profile_info=CloneImageInfo(mogrify_info);
2449 profile=GetImageProfile(*image,"iptc");
2450 if (profile != (StringInfo *) NULL)
2451 profile_info->profile=(void *) CloneStringInfo(profile);
2452 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2453 profile_info=DestroyImageInfo(profile_info);
2454 if (profile_image == (Image *) NULL)
2459 profile_info=CloneImageInfo(mogrify_info);
2460 (void) CopyMagickString(profile_info->filename,argv[i+1],
2462 file_data=FileToStringInfo(profile_info->filename,~0UL,
2464 if (file_data != (StringInfo *) NULL)
2466 (void) ProfileImage(*image,profile_info->magick,
2467 GetStringInfoDatum(file_data),
2468 GetStringInfoLength(file_data),exception);
2469 file_data=DestroyStringInfo(file_data);
2471 profile_info=DestroyImageInfo(profile_info);
2474 ResetImageProfileIterator(profile_image);
2475 name=GetNextImageProfile(profile_image);
2476 while (name != (const char *) NULL)
2478 profile=GetImageProfile(profile_image,name);
2479 if (profile != (StringInfo *) NULL)
2480 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2481 (size_t) GetStringInfoLength(profile),exception);
2482 name=GetNextImageProfile(profile_image);
2484 profile_image=DestroyImage(profile_image);
2491 if (LocaleCompare("quantize",option+1) == 0)
2495 quantize_info->colorspace=UndefinedColorspace;
2498 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2499 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2506 if (LocaleCompare("rotational-blur",option+1) == 0)
2509 Rotational blur image.
2511 (void) SyncImageSettings(mogrify_info,*image,exception);
2512 flags=ParseGeometry(argv[i+1],&geometry_info);
2513 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,exception);
2516 if (LocaleCompare("raise",option+1) == 0)
2519 Surround image with a raise of solid color.
2521 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2522 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2523 MagickFalse,exception);
2526 if (LocaleCompare("random-threshold",option+1) == 0)
2531 (void) SyncImageSettings(mogrify_info,*image,exception);
2532 (void) RandomThresholdImage(*image,argv[i+1],exception);
2535 if (LocaleCompare("read-mask",option+1) == 0)
2540 (void) SyncImageSettings(mogrify_info,*image,exception);
2546 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
2553 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2554 if (mask == (Image *) NULL)
2556 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2557 mask=DestroyImage(mask);
2560 if (LocaleCompare("region",option+1) == 0)
2562 (void) SyncImageSettings(mogrify_info,*image,exception);
2563 if (region_image != (Image *) NULL)
2568 (void) CompositeImage(region_image,*image,
2569 region_image->alpha_trait != UndefinedPixelTrait ?
2570 CopyCompositeOp : OverCompositeOp,MagickTrue,
2571 region_geometry.x,region_geometry.y,exception);
2572 *image=DestroyImage(*image);
2573 *image=region_image;
2574 region_image = (Image *) NULL;
2579 Apply transformations to a selected region of the image.
2581 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2583 mogrify_image=CropImage(*image,®ion_geometry,exception);
2584 if (mogrify_image == (Image *) NULL)
2586 region_image=(*image);
2587 *image=mogrify_image;
2588 mogrify_image=(Image *) NULL;
2591 if (LocaleCompare("render",option+1) == 0)
2593 (void) SyncImageSettings(mogrify_info,*image,exception);
2594 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2597 if (LocaleCompare("remap",option+1) == 0)
2603 Transform image colors to match this set of colors.
2605 (void) SyncImageSettings(mogrify_info,*image,exception);
2608 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2609 if (remap_image == (Image *) NULL)
2611 (void) RemapImage(quantize_info,*image,remap_image,exception);
2612 remap_image=DestroyImage(remap_image);
2615 if (LocaleCompare("repage",option+1) == 0)
2619 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2622 (void) ResetImagePage(*image,argv[i+1]);
2625 if (LocaleCompare("resample",option+1) == 0)
2630 (void) SyncImageSettings(mogrify_info,*image,exception);
2631 flags=ParseGeometry(argv[i+1],&geometry_info);
2632 if ((flags & SigmaValue) == 0)
2633 geometry_info.sigma=geometry_info.rho;
2634 mogrify_image=ResampleImage(*image,geometry_info.rho,
2635 geometry_info.sigma,(*image)->filter,exception);
2638 if (LocaleCompare("resize",option+1) == 0)
2643 (void) SyncImageSettings(mogrify_info,*image,exception);
2644 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2645 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2646 (*image)->filter,exception);
2649 if (LocaleCompare("roll",option+1) == 0)
2654 (void) SyncImageSettings(mogrify_info,*image,exception);
2655 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2656 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2659 if (LocaleCompare("rotate",option+1) == 0)
2665 Check for conditional image rotation.
2667 (void) SyncImageSettings(mogrify_info,*image,exception);
2668 if (strchr(argv[i+1],'>') != (char *) NULL)
2669 if ((*image)->columns <= (*image)->rows)
2671 if (strchr(argv[i+1],'<') != (char *) NULL)
2672 if ((*image)->columns >= (*image)->rows)
2677 rotation=ConstantString(argv[i+1]);
2678 (void) SubstituteString(&rotation,">","");
2679 (void) SubstituteString(&rotation,"<","");
2680 (void) ParseGeometry(rotation,&geometry_info);
2681 rotation=DestroyString(rotation);
2682 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2689 if (LocaleCompare("sample",option+1) == 0)
2692 Sample image with pixel replication.
2694 (void) SyncImageSettings(mogrify_info,*image,exception);
2695 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2696 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2700 if (LocaleCompare("scale",option+1) == 0)
2705 (void) SyncImageSettings(mogrify_info,*image,exception);
2706 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2707 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2711 if (LocaleCompare("selective-blur",option+1) == 0)
2714 Selectively blur pixels within a contrast threshold.
2716 (void) SyncImageSettings(mogrify_info,*image,exception);
2717 flags=ParseGeometry(argv[i+1],&geometry_info);
2718 if ((flags & PercentValue) != 0)
2719 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2720 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2721 geometry_info.sigma,geometry_info.xi,exception);
2724 if (LocaleCompare("separate",option+1) == 0)
2727 Break channels into separate images.
2729 (void) SyncImageSettings(mogrify_info,*image,exception);
2730 mogrify_image=SeparateImages(*image,exception);
2733 if (LocaleCompare("sepia-tone",option+1) == 0)
2741 (void) SyncImageSettings(mogrify_info,*image,exception);
2742 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2744 mogrify_image=SepiaToneImage(*image,threshold,exception);
2747 if (LocaleCompare("segment",option+1) == 0)
2752 (void) SyncImageSettings(mogrify_info,*image,exception);
2753 flags=ParseGeometry(argv[i+1],&geometry_info);
2754 if ((flags & SigmaValue) == 0)
2755 geometry_info.sigma=1.0;
2756 (void) SegmentImage(*image,(*image)->colorspace,
2757 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2761 if (LocaleCompare("set",option+1) == 0)
2771 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2772 (void) DeleteImageRegistry(argv[i+1]+9);
2774 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2776 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2777 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2780 (void) DeleteImageProperty(*image,argv[i+1]);
2783 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2785 if (value == (char *) NULL)
2787 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2788 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2791 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2793 (void) SetImageOption(image_info,argv[i+1]+7,value);
2794 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2795 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2798 (void) SetImageProperty(*image,argv[i+1],value,exception);
2799 value=DestroyString(value);
2802 if (LocaleCompare("shade",option+1) == 0)
2807 (void) SyncImageSettings(mogrify_info,*image,exception);
2808 flags=ParseGeometry(argv[i+1],&geometry_info);
2809 if ((flags & SigmaValue) == 0)
2810 geometry_info.sigma=1.0;
2811 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2812 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2815 if (LocaleCompare("shadow",option+1) == 0)
2820 (void) SyncImageSettings(mogrify_info,*image,exception);
2821 flags=ParseGeometry(argv[i+1],&geometry_info);
2822 if ((flags & SigmaValue) == 0)
2823 geometry_info.sigma=1.0;
2824 if ((flags & XiValue) == 0)
2825 geometry_info.xi=4.0;
2826 if ((flags & PsiValue) == 0)
2827 geometry_info.psi=4.0;
2828 mogrify_image=ShadowImage(*image,geometry_info.rho,
2829 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2830 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2833 if (LocaleCompare("sharpen",option+1) == 0)
2838 (void) SyncImageSettings(mogrify_info,*image,exception);
2839 flags=ParseGeometry(argv[i+1],&geometry_info);
2840 if ((flags & SigmaValue) == 0)
2841 geometry_info.sigma=1.0;
2842 if ((flags & XiValue) == 0)
2843 geometry_info.xi=0.0;
2844 mogrify_image=SharpenImage(*image,geometry_info.rho,
2845 geometry_info.sigma,exception);
2848 if (LocaleCompare("shave",option+1) == 0)
2851 Shave the image edges.
2853 (void) SyncImageSettings(mogrify_info,*image,exception);
2854 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2855 mogrify_image=ShaveImage(*image,&geometry,exception);
2858 if (LocaleCompare("shear",option+1) == 0)
2863 (void) SyncImageSettings(mogrify_info,*image,exception);
2864 flags=ParseGeometry(argv[i+1],&geometry_info);
2865 if ((flags & SigmaValue) == 0)
2866 geometry_info.sigma=geometry_info.rho;
2867 mogrify_image=ShearImage(*image,geometry_info.rho,
2868 geometry_info.sigma,exception);
2871 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2874 Sigmoidal non-linearity contrast control.
2876 (void) SyncImageSettings(mogrify_info,*image,exception);
2877 flags=ParseGeometry(argv[i+1],&geometry_info);
2878 if ((flags & SigmaValue) == 0)
2879 geometry_info.sigma=(double) QuantumRange/2.0;
2880 if ((flags & PercentValue) != 0)
2881 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2883 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2884 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2888 if (LocaleCompare("sketch",option+1) == 0)
2893 (void) SyncImageSettings(mogrify_info,*image,exception);
2894 flags=ParseGeometry(argv[i+1],&geometry_info);
2895 if ((flags & SigmaValue) == 0)
2896 geometry_info.sigma=1.0;
2897 mogrify_image=SketchImage(*image,geometry_info.rho,
2898 geometry_info.sigma,geometry_info.xi,exception);
2901 if (LocaleCompare("solarize",option+1) == 0)
2906 (void) SyncImageSettings(mogrify_info,*image,exception);
2907 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2909 (void) SolarizeImage(*image,threshold,exception);
2912 if (LocaleCompare("sparse-color",option+1) == 0)
2921 Sparse Color Interpolated Gradient
2923 (void) SyncImageSettings(mogrify_info,*image,exception);
2924 method=(SparseColorMethod) ParseCommandOption(
2925 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2926 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2928 if (arguments == (char *) NULL)
2930 mogrify_image=SparseColorOption(*image,method,arguments,
2931 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2932 arguments=DestroyString(arguments);
2935 if (LocaleCompare("splice",option+1) == 0)
2938 Splice a solid color into the image.
2940 (void) SyncImageSettings(mogrify_info,*image,exception);
2941 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2942 mogrify_image=SpliceImage(*image,&geometry,exception);
2945 if (LocaleCompare("spread",option+1) == 0)
2950 (void) SyncImageSettings(mogrify_info,*image,exception);
2951 (void) ParseGeometry(argv[i+1],&geometry_info);
2952 mogrify_image=SpreadImage(*image,interpolate_method,
2953 geometry_info.rho,exception);
2956 if (LocaleCompare("statistic",option+1) == 0)
2961 (void) SyncImageSettings(mogrify_info,*image,exception);
2962 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2963 MagickFalse,argv[i+1]);
2964 (void) ParseGeometry(argv[i+2],&geometry_info);
2965 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2966 (size_t) geometry_info.sigma,exception);
2969 if (LocaleCompare("stretch",option+1) == 0)
2973 draw_info->stretch=UndefinedStretch;
2976 draw_info->stretch=(StretchType) ParseCommandOption(
2977 MagickStretchOptions,MagickFalse,argv[i+1]);
2980 if (LocaleCompare("strip",option+1) == 0)
2983 Strip image of profiles and comments.
2985 (void) SyncImageSettings(mogrify_info,*image,exception);
2986 (void) StripImage(*image,exception);
2989 if (LocaleCompare("stroke",option+1) == 0)
2999 (void) QueryColorCompliance("none",AllCompliance,
3000 &draw_info->stroke,exception);
3001 if (draw_info->stroke_pattern != (Image *) NULL)
3002 draw_info->stroke_pattern=DestroyImage(
3003 draw_info->stroke_pattern);
3006 sans=AcquireExceptionInfo();
3007 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
3008 sans=DestroyExceptionInfo(sans);
3009 if (status == MagickFalse)
3010 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3013 draw_info->stroke=color;
3016 if (LocaleCompare("strokewidth",option+1) == 0)
3018 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
3021 if (LocaleCompare("style",option+1) == 0)
3025 draw_info->style=UndefinedStyle;
3028 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3029 MagickFalse,argv[i+1]);
3032 if (LocaleCompare("swirl",option+1) == 0)
3037 (void) SyncImageSettings(mogrify_info,*image,exception);
3038 (void) ParseGeometry(argv[i+1],&geometry_info);
3039 mogrify_image=SwirlImage(*image,geometry_info.rho,
3040 interpolate_method,exception);
3047 if (LocaleCompare("threshold",option+1) == 0)
3055 (void) SyncImageSettings(mogrify_info,*image,exception);
3057 threshold=(double) QuantumRange/2;
3059 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3061 (void) BilevelImage(*image,threshold,exception);
3064 if (LocaleCompare("thumbnail",option+1) == 0)
3069 (void) SyncImageSettings(mogrify_info,*image,exception);
3070 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3071 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3075 if (LocaleCompare("tile",option+1) == 0)
3079 if (draw_info->fill_pattern != (Image *) NULL)
3080 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3083 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3087 if (LocaleCompare("tint",option+1) == 0)
3092 (void) SyncImageSettings(mogrify_info,*image,exception);
3093 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3096 if (LocaleCompare("transform",option+1) == 0)
3099 Affine transform image.
3101 (void) SyncImageSettings(mogrify_info,*image,exception);
3102 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3106 if (LocaleCompare("transparent",option+1) == 0)
3111 (void) SyncImageSettings(mogrify_info,*image,exception);
3112 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3114 (void) TransparentPaintImage(*image,&target,(Quantum)
3115 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3119 if (LocaleCompare("transpose",option+1) == 0)
3122 Transpose image scanlines.
3124 (void) SyncImageSettings(mogrify_info,*image,exception);
3125 mogrify_image=TransposeImage(*image,exception);
3128 if (LocaleCompare("transverse",option+1) == 0)
3131 Transverse image scanlines.
3133 (void) SyncImageSettings(mogrify_info,*image,exception);
3134 mogrify_image=TransverseImage(*image,exception);
3137 if (LocaleCompare("treedepth",option+1) == 0)
3139 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3142 if (LocaleCompare("trim",option+1) == 0)
3147 (void) SyncImageSettings(mogrify_info,*image,exception);
3148 mogrify_image=TrimImage(*image,exception);
3151 if (LocaleCompare("type",option+1) == 0)
3156 (void) SyncImageSettings(mogrify_info,*image,exception);
3160 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3162 (*image)->type=UndefinedType;
3163 (void) SetImageType(*image,type,exception);
3170 if (LocaleCompare("undercolor",option+1) == 0)
3172 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3173 &draw_info->undercolor,exception);
3176 if (LocaleCompare("unique",option+1) == 0)
3180 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3183 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3184 (void) SetImageArtifact(*image,"verbose","true");
3187 if (LocaleCompare("unique-colors",option+1) == 0)
3190 Unique image colors.
3192 (void) SyncImageSettings(mogrify_info,*image,exception);
3193 mogrify_image=UniqueImageColors(*image,exception);
3196 if (LocaleCompare("unsharp",option+1) == 0)
3201 (void) SyncImageSettings(mogrify_info,*image,exception);
3202 flags=ParseGeometry(argv[i+1],&geometry_info);
3203 if ((flags & SigmaValue) == 0)
3204 geometry_info.sigma=1.0;
3205 if ((flags & XiValue) == 0)
3206 geometry_info.xi=1.0;
3207 if ((flags & PsiValue) == 0)
3208 geometry_info.psi=0.05;
3209 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3210 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3218 if (LocaleCompare("verbose",option+1) == 0)
3220 (void) SetImageArtifact(*image,option+1,
3221 *option == '+' ? "false" : "true");
3224 if (LocaleCompare("vignette",option+1) == 0)
3229 (void) SyncImageSettings(mogrify_info,*image,exception);
3230 flags=ParseGeometry(argv[i+1],&geometry_info);
3231 if ((flags & SigmaValue) == 0)
3232 geometry_info.sigma=1.0;
3233 if ((flags & XiValue) == 0)
3234 geometry_info.xi=0.1*(*image)->columns;
3235 if ((flags & PsiValue) == 0)
3236 geometry_info.psi=0.1*(*image)->rows;
3237 if ((flags & PercentValue) != 0)
3239 geometry_info.xi*=(double) (*image)->columns/100.0;
3240 geometry_info.psi*=(double) (*image)->rows/100.0;
3242 mogrify_image=VignetteImage(*image,geometry_info.rho,
3243 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3244 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3247 if (LocaleCompare("virtual-pixel",option+1) == 0)
3251 (void) SetImageVirtualPixelMethod(*image,
3252 UndefinedVirtualPixelMethod,exception);
3255 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3256 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3257 argv[i+1]),exception);
3264 if (LocaleCompare("wave",option+1) == 0)
3269 (void) SyncImageSettings(mogrify_info,*image,exception);
3270 flags=ParseGeometry(argv[i+1],&geometry_info);
3271 if ((flags & SigmaValue) == 0)
3272 geometry_info.sigma=1.0;
3273 mogrify_image=WaveImage(*image,geometry_info.rho,
3274 geometry_info.sigma,interpolate_method,exception);
3277 if (LocaleCompare("weight",option+1) == 0)
3282 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3285 weight=StringToUnsignedLong(argv[i+1]);
3286 draw_info->weight=(size_t) weight;
3289 if (LocaleCompare("white-threshold",option+1) == 0)
3292 White threshold image.
3294 (void) SyncImageSettings(mogrify_info,*image,exception);
3295 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3298 if (LocaleCompare("write-mask",option+1) == 0)
3303 (void) SyncImageSettings(mogrify_info,*image,exception);
3309 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
3316 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3317 if (mask == (Image *) NULL)
3319 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3320 mask=DestroyImage(mask);
3329 Replace current image with any image that was generated
3331 if (mogrify_image != (Image *) NULL)
3332 ReplaceImageInListReturnLast(image,mogrify_image);
3335 if (region_image != (Image *) NULL)
3338 Composite transformed region onto image.
3340 (void) SyncImageSettings(mogrify_info,*image,exception);
3341 (void) CompositeImage(region_image,*image,
3342 region_image->alpha_trait != UndefinedPixelTrait ? CopyCompositeOp :
3343 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y,
3345 *image=DestroyImage(*image);
3346 *image=region_image;
3347 region_image = (Image *) NULL;
3352 quantize_info=DestroyQuantizeInfo(quantize_info);
3353 draw_info=DestroyDrawInfo(draw_info);
3354 mogrify_info=DestroyImageInfo(mogrify_info);
3355 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3356 return(status == 0 ? MagickFalse : MagickTrue);
3360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3364 + M o g r i f y I m a g e C o m m a n d %
3368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3370 % MogrifyImageCommand() transforms an image or a sequence of images. These
3371 % transforms include image scaling, image rotation, color reduction, and
3372 % others. The transmogrified image overwrites the original image.
3374 % The format of the MogrifyImageCommand method is:
3376 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3377 % const char **argv,char **metadata,ExceptionInfo *exception)
3379 % A description of each parameter follows:
3381 % o image_info: the image info.
3383 % o argc: the number of elements in the argument vector.
3385 % o argv: A text array containing the command line arguments.
3387 % o metadata: any metadata is returned here.
3389 % o exception: return any errors or warnings in this structure.
3393 static MagickBooleanType MogrifyUsage(void)
3396 *channel_operators[]=
3398 "-channel-fx expression",
3399 " exchange, extract, or transfer one or more image channels",
3400 "-separate separate an image channel into a grayscale image",
3405 "-debug events display copious debugging information",
3406 "-distribute-cache port",
3407 " distributed pixel cache spanning one or more servers",
3408 "-help print program options",
3409 "-list type print a list of supported option arguments",
3410 "-log format format of debugging information",
3411 "-version print version information",
3416 "-adaptive-blur geometry",
3417 " adaptively blur pixels; decrease effect near edges",
3418 "-adaptive-resize geometry",
3419 " adaptively resize image using 'mesh' interpolation",
3420 "-adaptive-sharpen geometry",
3421 " adaptively sharpen pixels; increase effect near edges",
3422 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3423 " transparent, extract, background, or shape",
3424 "-annotate geometry text",
3425 " annotate the image with text",
3426 "-auto-gamma automagically adjust gamma level of image",
3427 "-auto-level automagically adjust color levels of image",
3428 "-auto-orient automagically orient (rotate) image",
3429 "-bench iterations measure performance",
3430 "-black-threshold value",
3431 " force all pixels below the threshold into black",
3432 "-blue-shift simulate a scene at nighttime in the moonlight",
3433 "-blur geometry reduce image noise and reduce detail levels",
3434 "-border geometry surround image with a border of color",
3435 "-bordercolor color border color",
3436 "-brightness-contrast geometry",
3437 " improve brightness / contrast of the image",
3438 "-canny geometry detect edges in the image",
3439 "-cdl filename color correct with a color decision list",
3440 "-channel mask set the image channel mask",
3441 "-charcoal geometry simulate a charcoal drawing",
3442 "-chop geometry remove pixels from the image interior",
3443 "-clamp keep pixel values in range (0-QuantumRange)",
3444 "-clip clip along the first path from the 8BIM profile",
3445 "-clip-mask filename associate a clip mask with the image",
3446 "-clip-path id clip along a named path from the 8BIM profile",
3447 "-colorize value colorize the image with the fill color",
3448 "-color-matrix matrix apply color correction to the image",
3449 "-connected-components connectivity",
3450 " connected-components uniquely labeled",
3451 "-contrast enhance or reduce the image contrast",
3452 "-contrast-stretch geometry",
3453 " improve contrast by 'stretching' the intensity range",
3454 "-convolve coefficients",
3455 " apply a convolution kernel to the image",
3456 "-cycle amount cycle the image colormap",
3457 "-decipher filename convert cipher pixels to plain pixels",
3458 "-deskew threshold straighten an image",
3459 "-despeckle reduce the speckles within an image",
3460 "-distort method args",
3461 " distort images according to given method ad args",
3462 "-draw string annotate the image with a graphic primitive",
3463 "-edge radius apply a filter to detect edges in the image",
3464 "-encipher filename convert plain pixels to cipher pixels",
3465 "-emboss radius emboss an image",
3466 "-enhance apply a digital filter to enhance a noisy image",
3467 "-equalize perform histogram equalization to an image",
3468 "-evaluate operator value",
3469 " evaluate an arithmetic, relational, or logical expression",
3470 "-extent geometry set the image size",
3471 "-extract geometry extract area from image",
3472 "-fft implements the discrete Fourier transform (DFT)",
3473 "-flip flip image vertically",
3474 "-floodfill geometry color",
3475 " floodfill the image with color",
3476 "-flop flop image horizontally",
3477 "-frame geometry surround image with an ornamental border",
3478 "-function name parameters",
3479 " apply function over image values",
3480 "-gamma value level of gamma correction",
3481 "-gaussian-blur geometry",
3482 " reduce image noise and reduce detail levels",
3483 "-geometry geometry preferred size or location of the image",
3484 "-grayscale method convert image to grayscale",
3485 "-hough-lines geometry",
3486 " identify lines in the image",
3487 "-identify identify the format and characteristics of the image",
3488 "-ift implements the inverse discrete Fourier transform (DFT)",
3489 "-implode amount implode image pixels about the center",
3490 "-interpolative-resize geometry",
3491 " resize image using interpolation",
3492 "-kuwahara geometry edge preserving noise reduction filter",
3493 "-lat geometry local adaptive thresholding",
3494 "-level value adjust the level of image contrast",
3495 "-level-colors color,color",
3496 " level image with the given colors",
3497 "-linear-stretch geometry",
3498 " improve contrast by 'stretching with saturation'",
3499 "-liquid-rescale geometry",
3500 " rescale image with seam-carving",
3501 "-local-contrast geometry",
3502 " enhance local contrast",
3503 "-magnify double the size of the image with pixel art scaling",
3504 "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3505 "-median geometry apply a median filter to the image",
3506 "-mode geometry make each pixel the 'predominant color' of the",
3508 "-modulate value vary the brightness, saturation, and hue",
3509 "-monochrome transform image to black and white",
3510 "-morphology method kernel",
3511 " apply a morphology method to the image",
3512 "-motion-blur geometry",
3513 " simulate motion blur",
3514 "-negate replace every pixel with its complementary color ",
3515 "-noise geometry add or reduce noise in an image",
3516 "-normalize transform image to span the full range of colors",
3517 "-opaque color change this color to the fill color",
3518 "-ordered-dither NxN",
3519 " add a noise pattern to the image with specific",
3521 "-paint radius simulate an oil painting",
3522 "-perceptible epsilon",
3523 " pixel value less than |epsilon| become epsilon or",
3525 "-polaroid angle simulate a Polaroid picture",
3526 "-posterize levels reduce the image to a limited number of color levels",
3527 "-profile filename add, delete, or apply an image profile",
3528 "-quantize colorspace reduce colors in this colorspace",
3529 "-raise value lighten/darken image edges to create a 3-D effect",
3530 "-random-threshold low,high",
3531 " random threshold the image",
3532 "-region geometry apply options to a portion of the image",
3533 "-render render vector graphics",
3534 "-repage geometry size and location of an image canvas",
3535 "-resample geometry change the resolution of an image",
3536 "-resize geometry resize the image",
3537 "-roll geometry roll an image vertically or horizontally",
3538 "-rotate degrees apply Paeth rotation to the image",
3539 "-rotational-blur angle",
3540 " rotational blur the image",
3541 "-sample geometry scale image with pixel sampling",
3542 "-scale geometry scale the image",
3543 "-segment values segment an image",
3544 "-selective-blur geometry",
3545 " selectively blur pixels within a contrast threshold",
3546 "-sepia-tone threshold",
3547 " simulate a sepia-toned photo",
3548 "-set property value set an image property",
3549 "-shade degrees shade the image using a distant light source",
3550 "-shadow geometry simulate an image shadow",
3551 "-sharpen geometry sharpen the image",
3552 "-shave geometry shave pixels from the image edges",
3553 "-shear geometry slide one edge of the image along the X or Y axis",
3554 "-sigmoidal-contrast geometry",
3555 " increase the contrast without saturating highlights or",
3557 "-sketch geometry simulate a pencil sketch",
3558 "-solarize threshold negate all pixels above the threshold level",
3559 "-sparse-color method args",
3560 " fill in a image based on a few color points",
3561 "-splice geometry splice the background color into the image",
3562 "-spread radius displace image pixels by a random amount",
3563 "-statistic type radius",
3564 " replace each pixel with corresponding statistic from the neighborhood",
3565 "-strip strip image of all profiles and comments",
3566 "-swirl degrees swirl image pixels about the center",
3567 "-threshold value threshold the image",
3568 "-thumbnail geometry create a thumbnail of the image",
3569 "-tile filename tile image when filling a graphic primitive",
3570 "-tint value tint the image with the fill color",
3571 "-transform affine transform image",
3572 "-transparent color make this color transparent within the image",
3573 "-transpose flip image vertically and rotate 90 degrees",
3574 "-transverse flop image horizontally and rotate 270 degrees",
3575 "-trim trim image edges",
3576 "-type type image type",
3577 "-unique-colors discard all but one of any pixel color",
3578 "-unsharp geometry sharpen the image",
3579 "-vignette geometry soften the edges of the image in vignette style",
3580 "-wave geometry alter an image along a sine wave",
3581 "-white-threshold value",
3582 " force all pixels above the threshold into white",
3585 *sequence_operators[]=
3587 "-affinity filename transform image colors to match this set of colors",
3588 "-append append an image sequence",
3589 "-clut apply a color lookup table to the image",
3590 "-coalesce merge a sequence of images",
3591 "-combine combine a sequence of images",
3592 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3593 "-complex operator perform complex mathematics on an image sequence",
3594 "-composite composite image",
3595 "-copy geometry offset",
3596 " copy pixels from one area of an image to another",
3597 "-crop geometry cut out a rectangular region of the image",
3598 "-deconstruct break down an image sequence into constituent parts",
3599 "-evaluate-sequence operator",
3600 " evaluate an arithmetic, relational, or logical expression",
3601 "-flatten flatten a sequence of images",
3602 "-fx expression apply mathematical expression to an image channel(s)",
3603 "-hald-clut apply a Hald color lookup table to the image",
3604 "-layers method optimize, merge, or compare image layers",
3605 "-morph value morph an image sequence",
3606 "-mosaic create a mosaic from an image sequence",
3607 "-poly terms build a polynomial from the image sequence and the corresponding",
3608 " terms (coefficients and degree pairs).",
3609 "-print string interpret string and print to console",
3610 "-process arguments process the image with a custom image filter",
3611 "-smush geometry smush an image sequence together",
3612 "-write filename write images to this file",
3617 "-adjoin join images into a single multi-image file",
3618 "-affine matrix affine transform matrix",
3619 "-alpha option activate, deactivate, reset, or set the alpha channel",
3620 "-antialias remove pixel-aliasing",
3621 "-authenticate password",
3622 " decipher image with this password",
3623 "-attenuate value lessen (or intensify) when adding noise to an image",
3624 "-background color background color",
3625 "-bias value add bias when convolving an image",
3626 "-black-point-compensation",
3627 " use black point compensation",
3628 "-blue-primary point chromaticity blue primary point",
3629 "-bordercolor color border color",
3630 "-caption string assign a caption to an image",
3631 "-colors value preferred number of colors in the image",
3632 "-colorspace type alternate image colorspace",
3633 "-comment string annotate image with comment",
3634 "-compose operator set image composite operator",
3635 "-compress type type of pixel compression when writing the image",
3636 "-define format:option=value",
3637 " define one or more image format options",
3638 "-delay value display the next image after pausing",
3639 "-density geometry horizontal and vertical density of the image",
3640 "-depth value image depth",
3641 "-direction type render text right-to-left or left-to-right",
3642 "-display server get image or font from this X server",
3643 "-dispose method layer disposal method",
3644 "-dither method apply error diffusion to image",
3645 "-encoding type text encoding type",
3646 "-endian type endianness (MSB or LSB) of the image",
3647 "-family name render text with this font family",
3648 "-features distance analyze image features (e.g. contrast, correlation)",
3649 "-fill color color to use when filling a graphic primitive",
3650 "-filter type use this filter when resizing an image",
3651 "-font name render text with this font",
3652 "-format \"string\" output formatted image characteristics",
3653 "-fuzz distance colors within this distance are considered equal",
3654 "-gravity type horizontal and vertical text placement",
3655 "-green-primary point chromaticity green primary point",
3656 "-intensity method method to generate an intensity value from a pixel",
3657 "-intent type type of rendering intent when managing the image color",
3658 "-interlace type type of image interlacing scheme",
3659 "-interline-spacing value",
3660 " set the space between two text lines",
3661 "-interpolate method pixel color interpolation method",
3662 "-interword-spacing value",
3663 " set the space between two words",
3664 "-kerning value set the space between two letters",
3665 "-label string assign a label to an image",
3666 "-limit type value pixel cache resource limit",
3667 "-loop iterations add Netscape loop extension to your GIF animation",
3668 "-matte store matte channel if the image has one",
3669 "-mattecolor color frame color",
3670 "-monitor monitor progress",
3671 "-orient type image orientation",
3672 "-page geometry size and location of an image canvas (setting)",
3673 "-path path write images to this path on disk",
3674 "-ping efficiently determine image attributes",
3675 "-pointsize value font point size",
3676 "-precision value maximum number of significant digits to print",
3677 "-preview type image preview type",
3678 "-quality value JPEG/MIFF/PNG compression level",
3679 "-quiet suppress all warning messages",
3680 "-read-mask filename associate a read mask with the image",
3681 "-red-primary point chromaticity red primary point",
3682 "-regard-warnings pay attention to warning messages",
3683 "-remap filename transform image colors to match this set of colors",
3684 "-respect-parentheses settings remain in effect until parenthesis boundary",
3685 "-sampling-factor geometry",
3686 " horizontal and vertical sampling factor",
3687 "-scene value image scene number",
3688 "-seed value seed a new sequence of pseudo-random numbers",
3689 "-size geometry width and height of image",
3690 "-stretch type render text with this font stretch",
3691 "-stroke color graphic primitive stroke color",
3692 "-strokewidth value graphic primitive stroke width",
3693 "-style type render text with this font style",
3694 "-synchronize synchronize image to storage device",
3695 "-taint declare the image as modified",
3696 "-texture filename name of texture to tile onto the image background",
3697 "-tile-offset geometry",
3699 "-treedepth value color tree depth",
3700 "-transparent-color color",
3701 " transparent color",
3702 "-undercolor color annotation bounding box color",
3703 "-units type the units of image resolution",
3704 "-verbose print detailed information about the image",
3705 "-view FlashPix viewing transforms",
3706 "-virtual-pixel method",
3707 " virtual pixel access method",
3708 "-weight type render text with this font weight",
3709 "-white-point point chromaticity white point",
3710 "-write-mask filename associate a write mask with the image",
3715 "-delete indexes delete the image from the image sequence",
3716 "-duplicate count,indexes",
3717 " duplicate an image one or more times",
3718 "-insert index insert last image into the image sequence",
3719 "-reverse reverse image sequence",
3720 "-swap indexes swap two images in the image sequence",
3727 ListMagickVersion(stdout);
3728 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3730 (void) printf("\nImage Settings:\n");
3731 for (p=settings; *p != (char *) NULL; p++)
3732 (void) printf(" %s\n",*p);
3733 (void) printf("\nImage Operators:\n");
3734 for (p=operators; *p != (char *) NULL; p++)
3735 (void) printf(" %s\n",*p);
3736 (void) printf("\nImage Channel Operators:\n");
3737 for (p=channel_operators; *p != (char *) NULL; p++)
3738 (void) printf(" %s\n",*p);
3739 (void) printf("\nImage Sequence Operators:\n");
3740 for (p=sequence_operators; *p != (char *) NULL; p++)
3741 (void) printf(" %s\n",*p);
3742 (void) printf("\nImage Stack Operators:\n");
3743 for (p=stack_operators; *p != (char *) NULL; p++)
3744 (void) printf(" %s\n",*p);
3745 (void) printf("\nMiscellaneous Options:\n");
3746 for (p=miscellaneous; *p != (char *) NULL; p++)
3747 (void) printf(" %s\n",*p);
3749 "\nBy default, the image format of 'file' is determined by its magic\n");
3751 "number. To specify a particular image format, precede the filename\n");
3753 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3755 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3756 (void) printf("'-' for standard input or output.\n");
3757 return(MagickFalse);
3760 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3761 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3763 #define DestroyMogrify() \
3765 if (format != (char *) NULL) \
3766 format=DestroyString(format); \
3767 if (path != (char *) NULL) \
3768 path=DestroyString(path); \
3769 DestroyImageStack(); \
3770 for (i=0; i < (ssize_t) argc; i++) \
3771 argv[i]=DestroyString(argv[i]); \
3772 argv=(char **) RelinquishMagickMemory(argv); \
3774 #define ThrowMogrifyException(asperity,tag,option) \
3776 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3779 return(MagickFalse); \
3781 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3783 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3784 "InvalidArgument","'%s': %s",argument,option); \
3786 return(MagickFalse); \
3798 image_stack[MaxImageStackDepth+1];
3806 respect_parenthesis;
3821 assert(image_info != (ImageInfo *) NULL);
3822 assert(image_info->signature == MagickCoreSignature);
3823 if (image_info->debug != MagickFalse)
3824 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3825 assert(exception != (ExceptionInfo *) NULL);
3829 if ((LocaleCompare("version",option+1) == 0) ||
3830 (LocaleCompare("-version",option+1) == 0))
3832 ListMagickVersion(stdout);
3833 return(MagickFalse);
3837 return(MogrifyUsage());
3838 format=(char *) NULL;
3840 global_colormap=MagickFalse;
3844 option=(char *) NULL;
3846 respect_parenthesis=MagickFalse;
3851 ReadCommandlLine(argc,&argv);
3852 status=ExpandFilenames(&argc,&argv);
3853 if (status == MagickFalse)
3854 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3855 GetExceptionMessage(errno));
3856 for (i=1; i < (ssize_t) argc; i++)
3859 if (LocaleCompare(option,"(") == 0)
3861 FireImageStack(MagickFalse,MagickTrue,pend);
3862 if (k == MaxImageStackDepth)
3863 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3868 if (LocaleCompare(option,")") == 0)
3870 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3872 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3876 if (IsCommandOption(option) == MagickFalse)
3879 backup_filename[MagickPathExtent],
3886 Option is a file name: begin by reading image from specified file.
3888 FireImageStack(MagickFalse,MagickFalse,pend);
3890 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3892 images=ReadImages(image_info,filename,exception);
3893 status&=(images != (Image *) NULL) &&
3894 (exception->severity < ErrorException);
3895 if (images == (Image *) NULL)
3897 if (format != (char *) NULL)
3898 (void) CopyMagickString(images->filename,images->magick_filename,
3900 if (path != (char *) NULL)
3902 GetPathComponent(option,TailPath,filename);
3903 (void) FormatLocaleString(images->filename,MagickPathExtent,"%s%c%s",
3904 path,*DirectorySeparator,filename);
3906 if (format != (char *) NULL)
3907 AppendImageFormat(format,images->filename);
3908 AppendImageStack(images);
3909 FinalizeImageSettings(image_info,image,MagickFalse);
3910 if (global_colormap != MagickFalse)
3915 quantize_info=AcquireQuantizeInfo(image_info);
3916 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3917 quantize_info=DestroyQuantizeInfo(quantize_info);
3919 *backup_filename='\0';
3920 if ((LocaleCompare(image->filename,"-") != 0) &&
3921 (IsPathWritable(image->filename) != MagickFalse))
3924 Rename image file as backup.
3926 (void) CopyMagickString(backup_filename,image->filename,
3928 for (j=0; j < 6; j++)
3930 (void) ConcatenateMagickString(backup_filename,"~",MagickPathExtent);
3931 if (IsPathAccessible(backup_filename) == MagickFalse)
3934 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3935 (rename_utf8(image->filename,backup_filename) != 0))
3936 *backup_filename='\0';
3939 Write transmogrified image to disk.
3941 image_info->synchronize=MagickTrue;
3942 status&=WriteImages(image_info,image,image->filename,exception);
3943 if ((status != MagickFalse) && (*backup_filename != '\0'))
3944 (void) remove_utf8(backup_filename);
3945 RemoveAllImageStack();
3948 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3949 switch (*(option+1))
3953 if (LocaleCompare("adaptive-blur",option+1) == 0)
3956 if (i == (ssize_t) argc)
3957 ThrowMogrifyException(OptionError,"MissingArgument",option);
3958 if (IsGeometry(argv[i]) == MagickFalse)
3959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3962 if (LocaleCompare("adaptive-resize",option+1) == 0)
3965 if (i == (ssize_t) argc)
3966 ThrowMogrifyException(OptionError,"MissingArgument",option);
3967 if (IsGeometry(argv[i]) == MagickFalse)
3968 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3971 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3974 if (i == (ssize_t) argc)
3975 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (IsGeometry(argv[i]) == MagickFalse)
3977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3980 if (LocaleCompare("affine",option+1) == 0)
3985 if (i == (ssize_t) argc)
3986 ThrowMogrifyException(OptionError,"MissingArgument",option);
3989 if (LocaleCompare("alpha",option+1) == 0)
3997 if (i == (ssize_t) argc)
3998 ThrowMogrifyException(OptionError,"MissingArgument",option);
3999 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
4001 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption",
4005 if (LocaleCompare("annotate",option+1) == 0)
4010 if (i == (ssize_t) argc)
4011 ThrowMogrifyException(OptionError,"MissingArgument",option);
4012 if (IsGeometry(argv[i]) == MagickFalse)
4013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4014 if (i == (ssize_t) argc)
4015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4019 if (LocaleCompare("antialias",option+1) == 0)
4021 if (LocaleCompare("append",option+1) == 0)
4023 if (LocaleCompare("attenuate",option+1) == 0)
4028 if (i == (ssize_t) argc)
4029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 if (IsGeometry(argv[i]) == MagickFalse)
4031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4034 if (LocaleCompare("authenticate",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (LocaleCompare("auto-gamma",option+1) == 0)
4045 if (LocaleCompare("auto-level",option+1) == 0)
4047 if (LocaleCompare("auto-orient",option+1) == 0)
4049 if (LocaleCompare("average",option+1) == 0)
4051 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4055 if (LocaleCompare("background",option+1) == 0)
4060 if (i == (ssize_t) argc)
4061 ThrowMogrifyException(OptionError,"MissingArgument",option);
4064 if (LocaleCompare("bias",option+1) == 0)
4069 if (i == (ssize_t) argc)
4070 ThrowMogrifyException(OptionError,"MissingArgument",option);
4071 if (IsGeometry(argv[i]) == MagickFalse)
4072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4075 if (LocaleCompare("black-point-compensation",option+1) == 0)
4077 if (LocaleCompare("black-threshold",option+1) == 0)
4082 if (i == (ssize_t) argc)
4083 ThrowMogrifyException(OptionError,"MissingArgument",option);
4084 if (IsGeometry(argv[i]) == MagickFalse)
4085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4088 if (LocaleCompare("blue-primary",option+1) == 0)
4093 if (i == (ssize_t) argc)
4094 ThrowMogrifyException(OptionError,"MissingArgument",option);
4095 if (IsGeometry(argv[i]) == MagickFalse)
4096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4099 if (LocaleCompare("blue-shift",option+1) == 0)
4102 if (i == (ssize_t) argc)
4103 ThrowMogrifyException(OptionError,"MissingArgument",option);
4104 if (IsGeometry(argv[i]) == MagickFalse)
4105 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4108 if (LocaleCompare("blur",option+1) == 0)
4111 if (i == (ssize_t) argc)
4112 ThrowMogrifyException(OptionError,"MissingArgument",option);
4113 if (IsGeometry(argv[i]) == MagickFalse)
4114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4117 if (LocaleCompare("border",option+1) == 0)
4122 if (i == (ssize_t) argc)
4123 ThrowMogrifyException(OptionError,"MissingArgument",option);
4124 if (IsGeometry(argv[i]) == MagickFalse)
4125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4128 if (LocaleCompare("bordercolor",option+1) == 0)
4133 if (i == (ssize_t) argc)
4134 ThrowMogrifyException(OptionError,"MissingArgument",option);
4137 if (LocaleCompare("box",option+1) == 0)
4142 if (i == (ssize_t) argc)
4143 ThrowMogrifyException(OptionError,"MissingArgument",option);
4146 if (LocaleCompare("brightness-contrast",option+1) == 0)
4149 if (i == (ssize_t) argc)
4150 ThrowMogrifyException(OptionError,"MissingArgument",option);
4151 if (IsGeometry(argv[i]) == MagickFalse)
4152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4155 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4159 if (LocaleCompare("cache",option+1) == 0)
4164 if (i == (ssize_t) argc)
4165 ThrowMogrifyException(OptionError,"MissingArgument",option);
4166 if (IsGeometry(argv[i]) == MagickFalse)
4167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4170 if (LocaleCompare("canny",option+1) == 0)
4175 if (i == (ssize_t) argc)
4176 ThrowMogrifyException(OptionError,"MissingArgument",option);
4177 if (IsGeometry(argv[i]) == MagickFalse)
4178 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4181 if (LocaleCompare("caption",option+1) == 0)
4186 if (i == (ssize_t) argc)
4187 ThrowMogrifyException(OptionError,"MissingArgument",option);
4190 if (LocaleCompare("channel",option+1) == 0)
4198 if (i == (ssize_t) argc)
4199 ThrowMogrifyException(OptionError,"MissingArgument",option);
4200 channel=ParseChannelOption(argv[i]);
4202 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4206 if (LocaleCompare("channel-fx",option+1) == 0)
4214 if (i == (ssize_t) argc)
4215 ThrowMogrifyException(OptionError,"MissingArgument",option);
4216 channel=ParsePixelChannelOption(argv[i]);
4218 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4222 if (LocaleCompare("cdl",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4231 if (LocaleCompare("charcoal",option+1) == 0)
4236 if (i == (ssize_t) argc)
4237 ThrowMogrifyException(OptionError,"MissingArgument",option);
4238 if (IsGeometry(argv[i]) == MagickFalse)
4239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4242 if (LocaleCompare("chop",option+1) == 0)
4247 if (i == (ssize_t) argc)
4248 ThrowMogrifyException(OptionError,"MissingArgument",option);
4249 if (IsGeometry(argv[i]) == MagickFalse)
4250 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4253 if (LocaleCompare("clamp",option+1) == 0)
4255 if (LocaleCompare("clip",option+1) == 0)
4257 if (LocaleCompare("clip-mask",option+1) == 0)
4262 if (i == (ssize_t) argc)
4263 ThrowMogrifyException(OptionError,"MissingArgument",option);
4266 if (LocaleCompare("clut",option+1) == 0)
4268 if (LocaleCompare("coalesce",option+1) == 0)
4270 if (LocaleCompare("colorize",option+1) == 0)
4275 if (i == (ssize_t) argc)
4276 ThrowMogrifyException(OptionError,"MissingArgument",option);
4277 if (IsGeometry(argv[i]) == MagickFalse)
4278 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4281 if (LocaleCompare("color-matrix",option+1) == 0)
4289 if (i == (ssize_t) argc)
4290 ThrowMogrifyException(OptionError,"MissingArgument",option);
4291 kernel_info=AcquireKernelInfo(argv[i],exception);
4292 if (kernel_info == (KernelInfo *) NULL)
4293 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4294 kernel_info=DestroyKernelInfo(kernel_info);
4297 if (LocaleCompare("colors",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 if (IsGeometry(argv[i]) == MagickFalse)
4305 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308 if (LocaleCompare("colorspace",option+1) == 0)
4316 if (i == (ssize_t) argc)
4317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4321 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4325 if (LocaleCompare("combine",option+1) == 0)
4333 if (i == (ssize_t) argc)
4334 ThrowMogrifyException(OptionError,"MissingArgument",option);
4335 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4338 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4342 if (LocaleCompare("compare",option+1) == 0)
4344 if (LocaleCompare("comment",option+1) == 0)
4349 if (i == (ssize_t) argc)
4350 ThrowMogrifyException(OptionError,"MissingArgument",option);
4353 if (LocaleCompare("composite",option+1) == 0)
4355 if (LocaleCompare("compress",option+1) == 0)
4363 if (i == (ssize_t) argc)
4364 ThrowMogrifyException(OptionError,"MissingArgument",option);
4365 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4368 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4372 if (LocaleCompare("concurrent",option+1) == 0)
4374 if (LocaleCompare("connected-components",option+1) == 0)
4377 if (i == (ssize_t) argc)
4378 ThrowMogrifyException(OptionError,"MissingArgument",option);
4379 if (IsGeometry(argv[i]) == MagickFalse)
4380 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4383 if (LocaleCompare("contrast",option+1) == 0)
4385 if (LocaleCompare("contrast-stretch",option+1) == 0)
4388 if (i == (ssize_t) argc)
4389 ThrowMogrifyException(OptionError,"MissingArgument",option);
4390 if (IsGeometry(argv[i]) == MagickFalse)
4391 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4394 if (LocaleCompare("convolve",option+1) == 0)
4402 if (i == (ssize_t) argc)
4403 ThrowMogrifyException(OptionError,"MissingArgument",option);
4404 kernel_info=AcquireKernelInfo(argv[i],exception);
4405 if (kernel_info == (KernelInfo *) NULL)
4406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4407 kernel_info=DestroyKernelInfo(kernel_info);
4410 if (LocaleCompare("copy",option+1) == 0)
4415 if (i == (ssize_t) argc)
4416 ThrowMogrifyException(OptionError,"MissingArgument",option);
4417 if (IsGeometry(argv[i]) == MagickFalse)
4418 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4420 if (i == (ssize_t) argc)
4421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (IsGeometry(argv[i]) == MagickFalse)
4423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4426 if (LocaleCompare("crop",option+1) == 0)
4431 if (i == (ssize_t) argc)
4432 ThrowMogrifyException(OptionError,"MissingArgument",option);
4433 if (IsGeometry(argv[i]) == MagickFalse)
4434 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4437 if (LocaleCompare("cycle",option+1) == 0)
4442 if (i == (ssize_t) argc)
4443 ThrowMogrifyException(OptionError,"MissingArgument",option);
4444 if (IsGeometry(argv[i]) == MagickFalse)
4445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4448 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4452 if (LocaleCompare("decipher",option+1) == 0)
4457 if (i == (ssize_t) argc)
4458 ThrowMogrifyException(OptionError,"MissingArgument",option);
4461 if (LocaleCompare("deconstruct",option+1) == 0)
4463 if (LocaleCompare("debug",option+1) == 0)
4471 if (i == (ssize_t) argc)
4472 ThrowMogrifyException(OptionError,"MissingArgument",option);
4473 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4475 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4477 (void) SetLogEventMask(argv[i]);
4480 if (LocaleCompare("define",option+1) == 0)
4483 if (i == (ssize_t) argc)
4484 ThrowMogrifyException(OptionError,"MissingArgument",option);
4490 define=GetImageOption(image_info,argv[i]);
4491 if (define == (const char *) NULL)
4492 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4497 if (LocaleCompare("delay",option+1) == 0)
4502 if (i == (ssize_t) argc)
4503 ThrowMogrifyException(OptionError,"MissingArgument",option);
4504 if (IsGeometry(argv[i]) == MagickFalse)
4505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4508 if (LocaleCompare("delete",option+1) == 0)
4513 if (i == (ssize_t) argc)
4514 ThrowMogrifyException(OptionError,"MissingArgument",option);
4515 if (IsGeometry(argv[i]) == MagickFalse)
4516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4519 if (LocaleCompare("density",option+1) == 0)
4524 if (i == (ssize_t) argc)
4525 ThrowMogrifyException(OptionError,"MissingArgument",option);
4526 if (IsGeometry(argv[i]) == MagickFalse)
4527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4530 if (LocaleCompare("depth",option+1) == 0)
4535 if (i == (ssize_t) argc)
4536 ThrowMogrifyException(OptionError,"MissingArgument",option);
4537 if (IsGeometry(argv[i]) == MagickFalse)
4538 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4541 if (LocaleCompare("deskew",option+1) == 0)
4546 if (i == (ssize_t) argc)
4547 ThrowMogrifyException(OptionError,"MissingArgument",option);
4548 if (IsGeometry(argv[i]) == MagickFalse)
4549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4552 if (LocaleCompare("despeckle",option+1) == 0)
4554 if (LocaleCompare("dft",option+1) == 0)
4556 if (LocaleCompare("direction",option+1) == 0)
4564 if (i == (ssize_t) argc)
4565 ThrowMogrifyException(OptionError,"MissingArgument",option);
4566 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4569 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4573 if (LocaleCompare("display",option+1) == 0)
4578 if (i == (ssize_t) argc)
4579 ThrowMogrifyException(OptionError,"MissingArgument",option);
4582 if (LocaleCompare("dispose",option+1) == 0)
4590 if (i == (ssize_t) argc)
4591 ThrowMogrifyException(OptionError,"MissingArgument",option);
4592 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4594 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4598 if (LocaleCompare("distort",option+1) == 0)
4604 if (i == (ssize_t) argc)
4605 ThrowMogrifyException(OptionError,"MissingArgument",option);
4606 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4608 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4611 if (i == (ssize_t) argc)
4612 ThrowMogrifyException(OptionError,"MissingArgument",option);
4615 if (LocaleCompare("dither",option+1) == 0)
4623 if (i == (ssize_t) argc)
4624 ThrowMogrifyException(OptionError,"MissingArgument",option);
4625 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4627 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4631 if (LocaleCompare("draw",option+1) == 0)
4636 if (i == (ssize_t) argc)
4637 ThrowMogrifyException(OptionError,"MissingArgument",option);
4640 if (LocaleCompare("duplicate",option+1) == 0)
4645 if (i == (ssize_t) argc)
4646 ThrowMogrifyException(OptionError,"MissingArgument",option);
4647 if (IsGeometry(argv[i]) == MagickFalse)
4648 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4651 if (LocaleCompare("duration",option+1) == 0)
4656 if (i == (ssize_t) argc)
4657 ThrowMogrifyException(OptionError,"MissingArgument",option);
4658 if (IsGeometry(argv[i]) == MagickFalse)
4659 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4662 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4666 if (LocaleCompare("edge",option+1) == 0)
4671 if (i == (ssize_t) argc)
4672 ThrowMogrifyException(OptionError,"MissingArgument",option);
4673 if (IsGeometry(argv[i]) == MagickFalse)
4674 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4677 if (LocaleCompare("emboss",option+1) == 0)
4682 if (i == (ssize_t) argc)
4683 ThrowMogrifyException(OptionError,"MissingArgument",option);
4684 if (IsGeometry(argv[i]) == MagickFalse)
4685 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4688 if (LocaleCompare("encipher",option+1) == 0)
4693 if (i == (ssize_t) argc)
4694 ThrowMogrifyException(OptionError,"MissingArgument",option);
4697 if (LocaleCompare("encoding",option+1) == 0)
4702 if (i == (ssize_t) argc)
4703 ThrowMogrifyException(OptionError,"MissingArgument",option);
4706 if (LocaleCompare("endian",option+1) == 0)
4714 if (i == (ssize_t) argc)
4715 ThrowMogrifyException(OptionError,"MissingArgument",option);
4716 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4718 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4722 if (LocaleCompare("enhance",option+1) == 0)
4724 if (LocaleCompare("equalize",option+1) == 0)
4726 if (LocaleCompare("evaluate",option+1) == 0)
4734 if (i == (ssize_t) argc)
4735 ThrowMogrifyException(OptionError,"MissingArgument",option);
4736 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4738 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
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("evaluate-sequence",option+1) == 0)
4755 if (i == (ssize_t) argc)
4756 ThrowMogrifyException(OptionError,"MissingArgument",option);
4757 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4759 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4763 if (LocaleCompare("extent",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,"MissingArgument",option);
4770 if (IsGeometry(argv[i]) == MagickFalse)
4771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4774 if (LocaleCompare("extract",option+1) == 0)
4779 if (i == (ssize_t) argc)
4780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4781 if (IsGeometry(argv[i]) == MagickFalse)
4782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4785 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4789 if (LocaleCompare("family",option+1) == 0)
4794 if (i == (ssize_t) argc)
4795 ThrowMogrifyException(OptionError,"MissingArgument",option);
4798 if (LocaleCompare("features",option+1) == 0)
4803 if (i == (ssize_t) argc)
4804 ThrowMogrifyException(OptionError,"MissingArgument",option);
4805 if (IsGeometry(argv[i]) == MagickFalse)
4806 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4809 if (LocaleCompare("fill",option+1) == 0)
4814 if (i == (ssize_t) argc)
4815 ThrowMogrifyException(OptionError,"MissingArgument",option);
4818 if (LocaleCompare("filter",option+1) == 0)
4826 if (i == (ssize_t) argc)
4827 ThrowMogrifyException(OptionError,"MissingArgument",option);
4828 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4830 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4834 if (LocaleCompare("flatten",option+1) == 0)
4836 if (LocaleCompare("flip",option+1) == 0)
4838 if (LocaleCompare("flop",option+1) == 0)
4840 if (LocaleCompare("floodfill",option+1) == 0)
4845 if (i == (ssize_t) argc)
4846 ThrowMogrifyException(OptionError,"MissingArgument",option);
4847 if (IsGeometry(argv[i]) == MagickFalse)
4848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4850 if (i == (ssize_t) argc)
4851 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 if (LocaleCompare("font",option+1) == 0)
4859 if (i == (ssize_t) argc)
4860 ThrowMogrifyException(OptionError,"MissingArgument",option);
4863 if (LocaleCompare("format",option+1) == 0)
4865 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4866 (void) CloneString(&format,(char *) NULL);
4870 if (i == (ssize_t) argc)
4871 ThrowMogrifyException(OptionError,"MissingArgument",option);
4872 (void) CloneString(&format,argv[i]);
4873 (void) CopyMagickString(image_info->filename,format,MagickPathExtent);
4874 (void) ConcatenateMagickString(image_info->filename,":",
4876 (void) SetImageInfo(image_info,0,exception);
4877 if (*image_info->magick == '\0')
4878 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4882 if (LocaleCompare("frame",option+1) == 0)
4887 if (i == (ssize_t) argc)
4888 ThrowMogrifyException(OptionError,"MissingArgument",option);
4889 if (IsGeometry(argv[i]) == MagickFalse)
4890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4893 if (LocaleCompare("function",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4903 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4905 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4907 if (i == (ssize_t) argc)
4908 ThrowMogrifyException(OptionError,"MissingArgument",option);
4911 if (LocaleCompare("fuzz",option+1) == 0)
4916 if (i == (ssize_t) argc)
4917 ThrowMogrifyException(OptionError,"MissingArgument",option);
4918 if (IsGeometry(argv[i]) == MagickFalse)
4919 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4922 if (LocaleCompare("fx",option+1) == 0)
4927 if (i == (ssize_t) argc)
4928 ThrowMogrifyException(OptionError,"MissingArgument",option);
4931 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4935 if (LocaleCompare("gamma",option+1) == 0)
4938 if (i == (ssize_t) argc)
4939 ThrowMogrifyException(OptionError,"MissingArgument",option);
4940 if (IsGeometry(argv[i]) == MagickFalse)
4941 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4944 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4945 (LocaleCompare("gaussian",option+1) == 0))
4948 if (i == (ssize_t) argc)
4949 ThrowMogrifyException(OptionError,"MissingArgument",option);
4950 if (IsGeometry(argv[i]) == MagickFalse)
4951 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4954 if (LocaleCompare("geometry",option+1) == 0)
4959 if (i == (ssize_t) argc)
4960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4961 if (IsGeometry(argv[i]) == MagickFalse)
4962 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4965 if (LocaleCompare("gravity",option+1) == 0)
4973 if (i == (ssize_t) argc)
4974 ThrowMogrifyException(OptionError,"MissingArgument",option);
4975 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
4978 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4982 if (LocaleCompare("grayscale",option+1) == 0)
4990 if (i == (ssize_t) argc)
4991 ThrowMogrifyException(OptionError,"MissingArgument",option);
4992 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4995 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
4999 if (LocaleCompare("green-primary",option+1) == 0)
5004 if (i == (ssize_t) argc)
5005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 if (IsGeometry(argv[i]) == MagickFalse)
5007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5010 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5014 if (LocaleCompare("hald-clut",option+1) == 0)
5016 if ((LocaleCompare("help",option+1) == 0) ||
5017 (LocaleCompare("-help",option+1) == 0))
5018 return(MogrifyUsage());
5019 if (LocaleCompare("hough-lines",option+1) == 0)
5024 if (i == (ssize_t) argc)
5025 ThrowMogrifyException(OptionError,"MissingArgument",option);
5026 if (IsGeometry(argv[i]) == MagickFalse)
5027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5030 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5034 if (LocaleCompare("identify",option+1) == 0)
5036 if (LocaleCompare("idft",option+1) == 0)
5038 if (LocaleCompare("implode",option+1) == 0)
5043 if (i == (ssize_t) argc)
5044 ThrowMogrifyException(OptionError,"MissingArgument",option);
5045 if (IsGeometry(argv[i]) == MagickFalse)
5046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5049 if (LocaleCompare("intensity",option+1) == 0)
5057 if (i == (ssize_t) argc)
5058 ThrowMogrifyException(OptionError,"MissingArgument",option);
5059 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5060 MagickFalse,argv[i]);
5062 ThrowMogrifyException(OptionError,
5063 "UnrecognizedPixelIntensityMethod",argv[i]);
5066 if (LocaleCompare("intent",option+1) == 0)
5074 if (i == (ssize_t) argc)
5075 ThrowMogrifyException(OptionError,"MissingArgument",option);
5076 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5078 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5082 if (LocaleCompare("interlace",option+1) == 0)
5090 if (i == (ssize_t) argc)
5091 ThrowMogrifyException(OptionError,"MissingArgument",option);
5092 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5095 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5099 if (LocaleCompare("interline-spacing",option+1) == 0)
5104 if (i == (ssize_t) argc)
5105 ThrowMogrifyException(OptionError,"MissingArgument",option);
5106 if (IsGeometry(argv[i]) == MagickFalse)
5107 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5110 if (LocaleCompare("interpolate",option+1) == 0)
5118 if (i == (ssize_t) argc)
5119 ThrowMogrifyException(OptionError,"MissingArgument",option);
5120 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5122 if (interpolate < 0)
5123 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5127 if (LocaleCompare("interword-spacing",option+1) == 0)
5132 if (i == (ssize_t) argc)
5133 ThrowMogrifyException(OptionError,"MissingArgument",option);
5134 if (IsGeometry(argv[i]) == MagickFalse)
5135 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5138 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5142 if (LocaleCompare("kerning",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("kuwahara",option+1) == 0)
5156 if (i == (ssize_t) argc)
5157 ThrowMogrifyException(OptionError,"MissingArgument",option);
5158 if (IsGeometry(argv[i]) == MagickFalse)
5159 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5162 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5166 if (LocaleCompare("label",option+1) == 0)
5171 if (i == (ssize_t) argc)
5172 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 if (LocaleCompare("lat",option+1) == 0)
5180 if (i == (ssize_t) argc)
5181 ThrowMogrifyException(OptionError,"MissingArgument",option);
5182 if (IsGeometry(argv[i]) == MagickFalse)
5183 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5185 if (LocaleCompare("layers",option+1) == 0)
5193 if (i == (ssize_t) argc)
5194 ThrowMogrifyException(OptionError,"MissingArgument",option);
5195 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5197 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5201 if (LocaleCompare("level",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,"MissingArgument",option);
5206 if (IsGeometry(argv[i]) == MagickFalse)
5207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5210 if (LocaleCompare("level-colors",option+1) == 0)
5213 if (i == (ssize_t) argc)
5214 ThrowMogrifyException(OptionError,"MissingArgument",option);
5217 if (LocaleCompare("limit",option+1) == 0)
5231 if (i == (ssize_t) argc)
5232 ThrowMogrifyException(OptionError,"MissingArgument",option);
5233 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5236 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5239 if (i == (ssize_t) argc)
5240 ThrowMogrifyException(OptionError,"MissingArgument",option);
5241 value=StringToDouble(argv[i],&p);
5243 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5244 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5247 if (LocaleCompare("liquid-rescale",option+1) == 0)
5250 if (i == (ssize_t) argc)
5251 ThrowMogrifyException(OptionError,"MissingArgument",option);
5252 if (IsGeometry(argv[i]) == MagickFalse)
5253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5256 if (LocaleCompare("list",option+1) == 0)
5264 if (i == (ssize_t) argc)
5265 ThrowMogrifyException(OptionError,"MissingArgument",option);
5266 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5268 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5269 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5271 return(status == 0 ? MagickTrue : MagickFalse);
5273 if (LocaleCompare("log",option+1) == 0)
5278 if ((i == (ssize_t) argc) ||
5279 (strchr(argv[i],'%') == (char *) NULL))
5280 ThrowMogrifyException(OptionError,"MissingArgument",option);
5283 if (LocaleCompare("loop",option+1) == 0)
5288 if (i == (ssize_t) argc)
5289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5290 if (IsGeometry(argv[i]) == MagickFalse)
5291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5294 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5298 if (LocaleCompare("map",option+1) == 0)
5300 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5304 if (i == (ssize_t) argc)
5305 ThrowMogrifyException(OptionError,"MissingArgument",option);
5308 if (LocaleCompare("mask",option+1) == 0)
5313 if (i == (ssize_t) argc)
5314 ThrowMogrifyException(OptionError,"MissingArgument",option);
5317 if (LocaleCompare("matte",option+1) == 0)
5319 if (LocaleCompare("mattecolor",option+1) == 0)
5324 if (i == (ssize_t) argc)
5325 ThrowMogrifyException(OptionError,"MissingArgument",option);
5328 if (LocaleCompare("maximum",option+1) == 0)
5330 if (LocaleCompare("mean-shift",option+1) == 0)
5335 if (i == (ssize_t) argc)
5336 ThrowMogrifyException(OptionError,"MissingArgument",option);
5337 if (IsGeometry(argv[i]) == MagickFalse)
5338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5341 if (LocaleCompare("median",option+1) == 0)
5346 if (i == (ssize_t) argc)
5347 ThrowMogrifyException(OptionError,"MissingArgument",option);
5348 if (IsGeometry(argv[i]) == MagickFalse)
5349 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5352 if (LocaleCompare("metric",option+1) == 0)
5360 if (i == (ssize_t) argc)
5361 ThrowMogrifyException(OptionError,"MissingArgument",option);
5362 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5364 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5368 if (LocaleCompare("minimum",option+1) == 0)
5370 if (LocaleCompare("modulate",option+1) == 0)
5375 if (i == (ssize_t) argc)
5376 ThrowMogrifyException(OptionError,"MissingArgument",option);
5377 if (IsGeometry(argv[i]) == MagickFalse)
5378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5381 if (LocaleCompare("mode",option+1) == 0)
5386 if (i == (ssize_t) argc)
5387 ThrowMogrifyException(OptionError,"MissingArgument",option);
5388 if (IsGeometry(argv[i]) == MagickFalse)
5389 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5392 if (LocaleCompare("monitor",option+1) == 0)
5394 if (LocaleCompare("monochrome",option+1) == 0)
5396 if (LocaleCompare("morph",option+1) == 0)
5401 if (i == (ssize_t) argc)
5402 ThrowMogrifyException(OptionError,"MissingArgument",option);
5403 if (IsGeometry(argv[i]) == MagickFalse)
5404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5407 if (LocaleCompare("morphology",option+1) == 0)
5410 token[MagickPathExtent];
5419 if (i == (ssize_t) argc)
5420 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 GetMagickToken(argv[i],NULL,token);
5422 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5424 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5427 if (i == (ssize_t) argc)
5428 ThrowMogrifyException(OptionError,"MissingArgument",option);
5429 kernel_info=AcquireKernelInfo(argv[i],exception);
5430 if (kernel_info == (KernelInfo *) NULL)
5431 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5432 kernel_info=DestroyKernelInfo(kernel_info);
5435 if (LocaleCompare("mosaic",option+1) == 0)
5437 if (LocaleCompare("motion-blur",option+1) == 0)
5442 if (i == (ssize_t) argc)
5443 ThrowMogrifyException(OptionError,"MissingArgument",option);
5444 if (IsGeometry(argv[i]) == MagickFalse)
5445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5448 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5452 if (LocaleCompare("negate",option+1) == 0)
5454 if (LocaleCompare("noise",option+1) == 0)
5457 if (i == (ssize_t) argc)
5458 ThrowMogrifyException(OptionError,"MissingArgument",option);
5464 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5466 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5470 if (IsGeometry(argv[i]) == MagickFalse)
5471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5474 if (LocaleCompare("noop",option+1) == 0)
5476 if (LocaleCompare("normalize",option+1) == 0)
5478 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5482 if (LocaleCompare("opaque",option+1) == 0)
5485 if (i == (ssize_t) argc)
5486 ThrowMogrifyException(OptionError,"MissingArgument",option);
5489 if (LocaleCompare("ordered-dither",option+1) == 0)
5494 if (i == (ssize_t) argc)
5495 ThrowMogrifyException(OptionError,"MissingArgument",option);
5498 if (LocaleCompare("orient",option+1) == 0)
5503 orientation=UndefinedOrientation;
5507 if (i == (ssize_t) argc)
5508 ThrowMogrifyException(OptionError,"MissingArgument",option);
5509 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5511 if (orientation < 0)
5512 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5516 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5520 if (LocaleCompare("page",option+1) == 0)
5525 if (i == (ssize_t) argc)
5526 ThrowMogrifyException(OptionError,"MissingArgument",option);
5529 if (LocaleCompare("paint",option+1) == 0)
5534 if (i == (ssize_t) argc)
5535 ThrowMogrifyException(OptionError,"MissingArgument",option);
5536 if (IsGeometry(argv[i]) == MagickFalse)
5537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5540 if (LocaleCompare("path",option+1) == 0)
5542 (void) CloneString(&path,(char *) NULL);
5546 if (i == (ssize_t) argc)
5547 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 (void) CloneString(&path,argv[i]);
5551 if (LocaleCompare("perceptible",option+1) == 0)
5556 if (i == (ssize_t) argc)
5557 ThrowMogrifyException(OptionError,"MissingArgument",option);
5558 if (IsGeometry(argv[i]) == MagickFalse)
5559 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5562 if (LocaleCompare("pointsize",option+1) == 0)
5567 if (i == (ssize_t) argc)
5568 ThrowMogrifyException(OptionError,"MissingArgument",option);
5569 if (IsGeometry(argv[i]) == MagickFalse)
5570 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5573 if (LocaleCompare("polaroid",option+1) == 0)
5578 if (i == (ssize_t) argc)
5579 ThrowMogrifyException(OptionError,"MissingArgument",option);
5580 if (IsGeometry(argv[i]) == MagickFalse)
5581 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5584 if (LocaleCompare("poly",option+1) == 0)
5589 if (i == (ssize_t) argc)
5590 ThrowMogrifyException(OptionError,"MissingArgument",option);
5591 if (IsGeometry(argv[i]) == MagickFalse)
5592 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5595 if (LocaleCompare("posterize",option+1) == 0)
5600 if (i == (ssize_t) argc)
5601 ThrowMogrifyException(OptionError,"MissingArgument",option);
5602 if (IsGeometry(argv[i]) == MagickFalse)
5603 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5606 if (LocaleCompare("precision",option+1) == 0)
5611 if (i == (ssize_t) argc)
5612 ThrowMogrifyException(OptionError,"MissingArgument",option);
5613 if (IsGeometry(argv[i]) == MagickFalse)
5614 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5617 if (LocaleCompare("print",option+1) == 0)
5622 if (i == (ssize_t) argc)
5623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5626 if (LocaleCompare("process",option+1) == 0)
5631 if (i == (ssize_t) argc)
5632 ThrowMogrifyException(OptionError,"MissingArgument",option);
5635 if (LocaleCompare("profile",option+1) == 0)
5638 if (i == (ssize_t) argc)
5639 ThrowMogrifyException(OptionError,"MissingArgument",option);
5642 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5646 if (LocaleCompare("quality",option+1) == 0)
5651 if (i == (ssize_t) argc)
5652 ThrowMogrifyException(OptionError,"MissingArgument",option);
5653 if (IsGeometry(argv[i]) == MagickFalse)
5654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5657 if (LocaleCompare("quantize",option+1) == 0)
5665 if (i == (ssize_t) argc)
5666 ThrowMogrifyException(OptionError,"MissingArgument",option);
5667 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5670 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5674 if (LocaleCompare("quiet",option+1) == 0)
5676 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5680 if (LocaleCompare("rotational-blur",option+1) == 0)
5683 if (i == (ssize_t) argc)
5684 ThrowMogrifyException(OptionError,"MissingArgument",option);
5685 if (IsGeometry(argv[i]) == MagickFalse)
5686 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5689 if (LocaleCompare("raise",option+1) == 0)
5692 if (i == (ssize_t) argc)
5693 ThrowMogrifyException(OptionError,"MissingArgument",option);
5694 if (IsGeometry(argv[i]) == MagickFalse)
5695 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5698 if (LocaleCompare("random-threshold",option+1) == 0)
5703 if (i == (ssize_t) argc)
5704 ThrowMogrifyException(OptionError,"MissingArgument",option);
5705 if (IsGeometry(argv[i]) == MagickFalse)
5706 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5709 if (LocaleCompare("read-mask",option+1) == 0)
5714 if (i == (ssize_t) argc)
5715 ThrowMogrifyException(OptionError,"MissingArgument",option);
5718 if (LocaleCompare("red-primary",option+1) == 0)
5723 if (i == (ssize_t) argc)
5724 ThrowMogrifyException(OptionError,"MissingArgument",option);
5725 if (IsGeometry(argv[i]) == MagickFalse)
5726 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5728 if (LocaleCompare("regard-warnings",option+1) == 0)
5730 if (LocaleCompare("region",option+1) == 0)
5735 if (i == (ssize_t) argc)
5736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 if (IsGeometry(argv[i]) == MagickFalse)
5738 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5741 if (LocaleCompare("remap",option+1) == 0)
5746 if (i == (ssize_t) argc)
5747 ThrowMogrifyException(OptionError,"MissingArgument",option);
5750 if (LocaleCompare("render",option+1) == 0)
5752 if (LocaleCompare("repage",option+1) == 0)
5757 if (i == (ssize_t) argc)
5758 ThrowMogrifyException(OptionError,"MissingArgument",option);
5759 if (IsGeometry(argv[i]) == MagickFalse)
5760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5763 if (LocaleCompare("resample",option+1) == 0)
5768 if (i == (ssize_t) argc)
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5770 if (IsGeometry(argv[i]) == MagickFalse)
5771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5774 if (LocaleCompare("resize",option+1) == 0)
5779 if (i == (ssize_t) argc)
5780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5781 if (IsGeometry(argv[i]) == MagickFalse)
5782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5785 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5787 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5790 if (LocaleCompare("reverse",option+1) == 0)
5792 if (LocaleCompare("roll",option+1) == 0)
5797 if (i == (ssize_t) argc)
5798 ThrowMogrifyException(OptionError,"MissingArgument",option);
5799 if (IsGeometry(argv[i]) == MagickFalse)
5800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5803 if (LocaleCompare("rotate",option+1) == 0)
5806 if (i == (ssize_t) argc)
5807 ThrowMogrifyException(OptionError,"MissingArgument",option);
5808 if (IsGeometry(argv[i]) == MagickFalse)
5809 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5812 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5816 if (LocaleCompare("sample",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5827 if (LocaleCompare("sampling-factor",option+1) == 0)
5832 if (i == (ssize_t) argc)
5833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 if (IsGeometry(argv[i]) == MagickFalse)
5835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5838 if (LocaleCompare("scale",option+1) == 0)
5843 if (i == (ssize_t) argc)
5844 ThrowMogrifyException(OptionError,"MissingArgument",option);
5845 if (IsGeometry(argv[i]) == MagickFalse)
5846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5849 if (LocaleCompare("scene",option+1) == 0)
5854 if (i == (ssize_t) argc)
5855 ThrowMogrifyException(OptionError,"MissingArgument",option);
5856 if (IsGeometry(argv[i]) == MagickFalse)
5857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5860 if (LocaleCompare("seed",option+1) == 0)
5865 if (i == (ssize_t) argc)
5866 ThrowMogrifyException(OptionError,"MissingArgument",option);
5867 if (IsGeometry(argv[i]) == MagickFalse)
5868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5871 if (LocaleCompare("segment",option+1) == 0)
5876 if (i == (ssize_t) argc)
5877 ThrowMogrifyException(OptionError,"MissingArgument",option);
5878 if (IsGeometry(argv[i]) == MagickFalse)
5879 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5882 if (LocaleCompare("selective-blur",option+1) == 0)
5885 if (i == (ssize_t) argc)
5886 ThrowMogrifyException(OptionError,"MissingArgument",option);
5887 if (IsGeometry(argv[i]) == MagickFalse)
5888 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5891 if (LocaleCompare("separate",option+1) == 0)
5893 if (LocaleCompare("sepia-tone",option+1) == 0)
5898 if (i == (ssize_t) argc)
5899 ThrowMogrifyException(OptionError,"MissingArgument",option);
5900 if (IsGeometry(argv[i]) == MagickFalse)
5901 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5904 if (LocaleCompare("set",option+1) == 0)
5907 if (i == (ssize_t) argc)
5908 ThrowMogrifyException(OptionError,"MissingArgument",option);
5912 if (i == (ssize_t) argc)
5913 ThrowMogrifyException(OptionError,"MissingArgument",option);
5916 if (LocaleCompare("shade",option+1) == 0)
5919 if (i == (ssize_t) argc)
5920 ThrowMogrifyException(OptionError,"MissingArgument",option);
5921 if (IsGeometry(argv[i]) == MagickFalse)
5922 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5925 if (LocaleCompare("shadow",option+1) == 0)
5930 if (i == (ssize_t) argc)
5931 ThrowMogrifyException(OptionError,"MissingArgument",option);
5932 if (IsGeometry(argv[i]) == MagickFalse)
5933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5936 if (LocaleCompare("sharpen",option+1) == 0)
5939 if (i == (ssize_t) argc)
5940 ThrowMogrifyException(OptionError,"MissingArgument",option);
5941 if (IsGeometry(argv[i]) == MagickFalse)
5942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5945 if (LocaleCompare("shave",option+1) == 0)
5950 if (i == (ssize_t) argc)
5951 ThrowMogrifyException(OptionError,"MissingArgument",option);
5952 if (IsGeometry(argv[i]) == MagickFalse)
5953 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5956 if (LocaleCompare("shear",option+1) == 0)
5959 if (i == (ssize_t) argc)
5960 ThrowMogrifyException(OptionError,"MissingArgument",option);
5961 if (IsGeometry(argv[i]) == MagickFalse)
5962 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5965 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5968 if (i == (ssize_t) argc)
5969 ThrowMogrifyException(OptionError,"MissingArgument",option);
5970 if (IsGeometry(argv[i]) == MagickFalse)
5971 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5974 if (LocaleCompare("size",option+1) == 0)
5979 if (i == (ssize_t) argc)
5980 ThrowMogrifyException(OptionError,"MissingArgument",option);
5981 if (IsGeometry(argv[i]) == MagickFalse)
5982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5985 if (LocaleCompare("sketch",option+1) == 0)
5990 if (i == (ssize_t) argc)
5991 ThrowMogrifyException(OptionError,"MissingArgument",option);
5992 if (IsGeometry(argv[i]) == MagickFalse)
5993 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5996 if (LocaleCompare("smush",option+1) == 0)
5999 if (i == (ssize_t) argc)
6000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6001 if (IsGeometry(argv[i]) == MagickFalse)
6002 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6006 if (LocaleCompare("solarize",option+1) == 0)
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6013 if (IsGeometry(argv[i]) == MagickFalse)
6014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6017 if (LocaleCompare("sparse-color",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6025 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6027 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6030 if (i == (ssize_t) argc)
6031 ThrowMogrifyException(OptionError,"MissingArgument",option);
6034 if (LocaleCompare("splice",option+1) == 0)
6039 if (i == (ssize_t) argc)
6040 ThrowMogrifyException(OptionError,"MissingArgument",option);
6041 if (IsGeometry(argv[i]) == MagickFalse)
6042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6045 if (LocaleCompare("spread",option+1) == 0)
6050 if (i == (ssize_t) argc)
6051 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6056 if (LocaleCompare("statistic",option+1) == 0)
6064 if (i == (ssize_t) argc)
6065 ThrowMogrifyException(OptionError,"MissingArgument",option);
6066 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6068 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6071 if (i == (ssize_t) argc)
6072 ThrowMogrifyException(OptionError,"MissingArgument",option);
6073 if (IsGeometry(argv[i]) == MagickFalse)
6074 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6077 if (LocaleCompare("stretch",option+1) == 0)
6085 if (i == (ssize_t) argc)
6086 ThrowMogrifyException(OptionError,"MissingArgument",option);
6087 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
6089 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6093 if (LocaleCompare("strip",option+1) == 0)
6095 if (LocaleCompare("stroke",option+1) == 0)
6100 if (i == (ssize_t) argc)
6101 ThrowMogrifyException(OptionError,"MissingArgument",option);
6104 if (LocaleCompare("strokewidth",option+1) == 0)
6109 if (i == (ssize_t) argc)
6110 ThrowMogrifyException(OptionError,"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6115 if (LocaleCompare("style",option+1) == 0)
6123 if (i == (ssize_t) argc)
6124 ThrowMogrifyException(OptionError,"MissingArgument",option);
6125 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6127 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6131 if (LocaleCompare("swap",option+1) == 0)
6136 if (i == (ssize_t) argc)
6137 ThrowMogrifyException(OptionError,"MissingArgument",option);
6138 if (IsGeometry(argv[i]) == MagickFalse)
6139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6142 if (LocaleCompare("swirl",option+1) == 0)
6147 if (i == (ssize_t) argc)
6148 ThrowMogrifyException(OptionError,"MissingArgument",option);
6149 if (IsGeometry(argv[i]) == MagickFalse)
6150 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6153 if (LocaleCompare("synchronize",option+1) == 0)
6155 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6159 if (LocaleCompare("taint",option+1) == 0)
6161 if (LocaleCompare("texture",option+1) == 0)
6166 if (i == (ssize_t) argc)
6167 ThrowMogrifyException(OptionError,"MissingArgument",option);
6170 if (LocaleCompare("tile",option+1) == 0)
6175 if (i == (ssize_t) argc)
6176 ThrowMogrifyException(OptionError,"MissingArgument",option);
6179 if (LocaleCompare("tile-offset",option+1) == 0)
6184 if (i == (ssize_t) argc)
6185 ThrowMogrifyException(OptionError,"MissingArgument",option);
6186 if (IsGeometry(argv[i]) == MagickFalse)
6187 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6190 if (LocaleCompare("tint",option+1) == 0)
6195 if (i == (ssize_t) argc)
6196 ThrowMogrifyException(OptionError,"MissingArgument",option);
6197 if (IsGeometry(argv[i]) == MagickFalse)
6198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6201 if (LocaleCompare("transform",option+1) == 0)
6203 if (LocaleCompare("transpose",option+1) == 0)
6205 if (LocaleCompare("transverse",option+1) == 0)
6207 if (LocaleCompare("threshold",option+1) == 0)
6212 if (i == (ssize_t) argc)
6213 ThrowMogrifyException(OptionError,"MissingArgument",option);
6214 if (IsGeometry(argv[i]) == MagickFalse)
6215 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6218 if (LocaleCompare("thumbnail",option+1) == 0)
6223 if (i == (ssize_t) argc)
6224 ThrowMogrifyException(OptionError,"MissingArgument",option);
6225 if (IsGeometry(argv[i]) == MagickFalse)
6226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6229 if (LocaleCompare("transparent",option+1) == 0)
6232 if (i == (ssize_t) argc)
6233 ThrowMogrifyException(OptionError,"MissingArgument",option);
6236 if (LocaleCompare("transparent-color",option+1) == 0)
6241 if (i == (ssize_t) argc)
6242 ThrowMogrifyException(OptionError,"MissingArgument",option);
6245 if (LocaleCompare("treedepth",option+1) == 0)
6250 if (i == (ssize_t) argc)
6251 ThrowMogrifyException(OptionError,"MissingArgument",option);
6252 if (IsGeometry(argv[i]) == MagickFalse)
6253 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6256 if (LocaleCompare("trim",option+1) == 0)
6258 if (LocaleCompare("type",option+1) == 0)
6266 if (i == (ssize_t) argc)
6267 ThrowMogrifyException(OptionError,"MissingArgument",option);
6268 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6270 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6274 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6278 if (LocaleCompare("undercolor",option+1) == 0)
6283 if (i == (ssize_t) argc)
6284 ThrowMogrifyException(OptionError,"MissingArgument",option);
6287 if (LocaleCompare("unique-colors",option+1) == 0)
6289 if (LocaleCompare("units",option+1) == 0)
6297 if (i == (ssize_t) argc)
6298 ThrowMogrifyException(OptionError,"MissingArgument",option);
6299 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6302 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6306 if (LocaleCompare("unsharp",option+1) == 0)
6309 if (i == (ssize_t) argc)
6310 ThrowMogrifyException(OptionError,"MissingArgument",option);
6311 if (IsGeometry(argv[i]) == MagickFalse)
6312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6315 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6319 if (LocaleCompare("verbose",option+1) == 0)
6321 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6324 if ((LocaleCompare("version",option+1) == 0) ||
6325 (LocaleCompare("-version",option+1) == 0))
6327 ListMagickVersion(stdout);
6330 if (LocaleCompare("vignette",option+1) == 0)
6335 if (i == (ssize_t) argc)
6336 ThrowMogrifyException(OptionError,"MissingArgument",option);
6337 if (IsGeometry(argv[i]) == MagickFalse)
6338 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6341 if (LocaleCompare("virtual-pixel",option+1) == 0)
6349 if (i == (ssize_t) argc)
6350 ThrowMogrifyException(OptionError,"MissingArgument",option);
6351 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6354 ThrowMogrifyException(OptionError,
6355 "UnrecognizedVirtualPixelMethod",argv[i]);
6358 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6362 if (LocaleCompare("wave",option+1) == 0)
6365 if (i == (ssize_t) argc)
6366 ThrowMogrifyException(OptionError,"MissingArgument",option);
6367 if (IsGeometry(argv[i]) == MagickFalse)
6368 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6371 if (LocaleCompare("weight",option+1) == 0)
6376 if (i == (ssize_t) argc)
6377 ThrowMogrifyException(OptionError,"MissingArgument",option);
6380 if (LocaleCompare("white-point",option+1) == 0)
6385 if (i == (ssize_t) argc)
6386 ThrowMogrifyException(OptionError,"MissingArgument",option);
6387 if (IsGeometry(argv[i]) == MagickFalse)
6388 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6391 if (LocaleCompare("white-threshold",option+1) == 0)
6396 if (i == (ssize_t) argc)
6397 ThrowMogrifyException(OptionError,"MissingArgument",option);
6398 if (IsGeometry(argv[i]) == MagickFalse)
6399 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6402 if (LocaleCompare("write",option+1) == 0)
6405 if (i == (ssize_t) argc)
6406 ThrowMogrifyException(OptionError,"MissingArgument",option);
6409 if (LocaleCompare("write-mask",option+1) == 0)
6414 if (i == (ssize_t) argc)
6415 ThrowMogrifyException(OptionError,"MissingArgument",option);
6418 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6423 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6425 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6426 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6427 if (fire != MagickFalse)
6428 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6431 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6432 if (i != (ssize_t) argc)
6433 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6435 return(status != 0 ? MagickTrue : MagickFalse);
6439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6443 + M o g r i f y I m a g e I n f o %
6447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6449 % MogrifyImageInfo() applies image processing settings to the image as
6450 % prescribed by command line options.
6452 % The format of the MogrifyImageInfo method is:
6454 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6455 % const char **argv,ExceptionInfo *exception)
6457 % A description of each parameter follows:
6459 % o image_info: the image info..
6461 % o argc: Specifies a pointer to an integer describing the number of
6462 % elements in the argument vector.
6464 % o argv: Specifies a pointer to a text array containing the command line
6467 % o exception: return any errors or warnings in this structure.
6470 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6471 const int argc,const char **argv,ExceptionInfo *exception)
6486 Initialize method variables.
6488 assert(image_info != (ImageInfo *) NULL);
6489 assert(image_info->signature == MagickCoreSignature);
6490 if (image_info->debug != MagickFalse)
6491 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6492 image_info->filename);
6496 Set the image settings.
6498 for (i=0; i < (ssize_t) argc; i++)
6501 if (IsCommandOption(option) == MagickFalse)
6503 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6504 count=MagickMax(count,0L);
6505 if ((i+count) >= (ssize_t) argc)
6507 switch (*(option+1))
6511 if (LocaleCompare("adjoin",option+1) == 0)
6513 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6516 if (LocaleCompare("antialias",option+1) == 0)
6518 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6521 if (LocaleCompare("authenticate",option+1) == 0)
6524 (void) DeleteImageOption(image_info,option+1);
6526 (void) SetImageOption(image_info,option+1,argv[i+1]);
6533 if (LocaleCompare("background",option+1) == 0)
6537 (void) DeleteImageOption(image_info,option+1);
6538 (void) QueryColorCompliance(MogrifyBackgroundColor,
6539 AllCompliance,&image_info->background_color,exception);
6542 (void) SetImageOption(image_info,option+1,argv[i+1]);
6543 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6544 &image_info->background_color,exception);
6547 if (LocaleCompare("bias",option+1) == 0)
6551 (void) SetImageOption(image_info,option+1,"0.0");
6554 (void) SetImageOption(image_info,option+1,argv[i+1]);
6557 if (LocaleCompare("black-point-compensation",option+1) == 0)
6561 (void) SetImageOption(image_info,option+1,"false");
6564 (void) SetImageOption(image_info,option+1,"true");
6567 if (LocaleCompare("blue-primary",option+1) == 0)
6571 (void) SetImageOption(image_info,option+1,"0.0");
6574 (void) SetImageOption(image_info,option+1,argv[i+1]);
6577 if (LocaleCompare("bordercolor",option+1) == 0)
6581 (void) DeleteImageOption(image_info,option+1);
6582 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6583 &image_info->border_color,exception);
6586 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6587 &image_info->border_color,exception);
6588 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 if (LocaleCompare("box",option+1) == 0)
6595 (void) SetImageOption(image_info,"undercolor","none");
6598 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6605 if (LocaleCompare("cache",option+1) == 0)
6610 limit=MagickResourceInfinity;
6611 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6612 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6614 (void) SetMagickResourceLimit(MemoryResource,limit);
6615 (void) SetMagickResourceLimit(MapResource,2*limit);
6618 if (LocaleCompare("caption",option+1) == 0)
6622 (void) DeleteImageOption(image_info,option+1);
6625 (void) SetImageOption(image_info,option+1,argv[i+1]);
6628 if (LocaleCompare("colorspace",option+1) == 0)
6632 image_info->colorspace=UndefinedColorspace;
6633 (void) SetImageOption(image_info,option+1,"undefined");
6636 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6637 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6638 (void) SetImageOption(image_info,option+1,argv[i+1]);
6641 if (LocaleCompare("comment",option+1) == 0)
6645 (void) DeleteImageOption(image_info,option+1);
6648 (void) SetImageOption(image_info,option+1,argv[i+1]);
6651 if (LocaleCompare("compose",option+1) == 0)
6655 (void) SetImageOption(image_info,option+1,"undefined");
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6661 if (LocaleCompare("compress",option+1) == 0)
6665 image_info->compression=UndefinedCompression;
6666 (void) SetImageOption(image_info,option+1,"undefined");
6669 image_info->compression=(CompressionType) ParseCommandOption(
6670 MagickCompressOptions,MagickFalse,argv[i+1]);
6671 (void) SetImageOption(image_info,option+1,argv[i+1]);
6678 if (LocaleCompare("debug",option+1) == 0)
6681 (void) SetLogEventMask("none");
6683 (void) SetLogEventMask(argv[i+1]);
6684 image_info->debug=IsEventLogging();
6687 if (LocaleCompare("define",option+1) == 0)
6691 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6692 (void) DeleteImageRegistry(argv[i+1]+9);
6694 (void) DeleteImageOption(image_info,argv[i+1]);
6697 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6699 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6703 (void) DefineImageOption(image_info,argv[i+1]);
6706 if (LocaleCompare("delay",option+1) == 0)
6710 (void) SetImageOption(image_info,option+1,"0");
6713 (void) SetImageOption(image_info,option+1,argv[i+1]);
6716 if (LocaleCompare("density",option+1) == 0)
6723 if (image_info->density != (char *) NULL)
6724 image_info->density=DestroyString(image_info->density);
6725 (void) SetImageOption(image_info,option+1,"72");
6728 (void) CloneString(&image_info->density,argv[i+1]);
6729 (void) SetImageOption(image_info,option+1,argv[i+1]);
6732 if (LocaleCompare("depth",option+1) == 0)
6736 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6739 image_info->depth=StringToUnsignedLong(argv[i+1]);
6742 if (LocaleCompare("direction",option+1) == 0)
6746 (void) SetImageOption(image_info,option+1,"undefined");
6749 (void) SetImageOption(image_info,option+1,argv[i+1]);
6752 if (LocaleCompare("display",option+1) == 0)
6756 if (image_info->server_name != (char *) NULL)
6757 image_info->server_name=DestroyString(
6758 image_info->server_name);
6761 (void) CloneString(&image_info->server_name,argv[i+1]);
6764 if (LocaleCompare("dispose",option+1) == 0)
6768 (void) SetImageOption(image_info,option+1,"undefined");
6771 (void) SetImageOption(image_info,option+1,argv[i+1]);
6774 if (LocaleCompare("dither",option+1) == 0)
6778 image_info->dither=MagickFalse;
6779 (void) SetImageOption(image_info,option+1,"none");
6782 (void) SetImageOption(image_info,option+1,argv[i+1]);
6783 image_info->dither=MagickTrue;
6790 if (LocaleCompare("encoding",option+1) == 0)
6794 (void) SetImageOption(image_info,option+1,"undefined");
6797 (void) SetImageOption(image_info,option+1,argv[i+1]);
6800 if (LocaleCompare("endian",option+1) == 0)
6804 image_info->endian=UndefinedEndian;
6805 (void) SetImageOption(image_info,option+1,"undefined");
6808 image_info->endian=(EndianType) ParseCommandOption(
6809 MagickEndianOptions,MagickFalse,argv[i+1]);
6810 (void) SetImageOption(image_info,option+1,argv[i+1]);
6813 if (LocaleCompare("extract",option+1) == 0)
6816 Set image extract geometry.
6820 if (image_info->extract != (char *) NULL)
6821 image_info->extract=DestroyString(image_info->extract);
6824 (void) CloneString(&image_info->extract,argv[i+1]);
6831 if (LocaleCompare("family",option+1) == 0)
6834 (void) SetImageOption(image_info,option+1,argv[i+1]);
6837 if (LocaleCompare("fill",option+1) == 0)
6841 (void) SetImageOption(image_info,option+1,"none");
6844 (void) SetImageOption(image_info,option+1,argv[i+1]);
6847 if (LocaleCompare("filter",option+1) == 0)
6851 (void) SetImageOption(image_info,option+1,"undefined");
6854 (void) SetImageOption(image_info,option+1,argv[i+1]);
6857 if (LocaleCompare("font",option+1) == 0)
6861 if (image_info->font != (char *) NULL)
6862 image_info->font=DestroyString(image_info->font);
6865 (void) CloneString(&image_info->font,argv[i+1]);
6868 if (LocaleCompare("format",option+1) == 0)
6873 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6874 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6875 image_info->ping=MagickFalse;
6876 (void) SetImageOption(image_info,option+1,argv[i+1]);
6879 if (LocaleCompare("fuzz",option+1) == 0)
6883 image_info->fuzz=0.0;
6884 (void) SetImageOption(image_info,option+1,"0");
6887 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6889 (void) SetImageOption(image_info,option+1,argv[i+1]);
6896 if (LocaleCompare("gravity",option+1) == 0)
6900 (void) SetImageOption(image_info,option+1,"undefined");
6903 (void) SetImageOption(image_info,option+1,argv[i+1]);
6906 if (LocaleCompare("green-primary",option+1) == 0)
6910 (void) SetImageOption(image_info,option+1,"0.0");
6913 (void) SetImageOption(image_info,option+1,argv[i+1]);
6920 if (LocaleCompare("intensity",option+1) == 0)
6924 (void) SetImageOption(image_info,option+1,"undefined");
6927 (void) SetImageOption(image_info,option+1,argv[i+1]);
6930 if (LocaleCompare("intent",option+1) == 0)
6934 (void) SetImageOption(image_info,option+1,"undefined");
6937 (void) SetImageOption(image_info,option+1,argv[i+1]);
6940 if (LocaleCompare("interlace",option+1) == 0)
6944 image_info->interlace=UndefinedInterlace;
6945 (void) SetImageOption(image_info,option+1,"undefined");
6948 image_info->interlace=(InterlaceType) ParseCommandOption(
6949 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6950 (void) SetImageOption(image_info,option+1,argv[i+1]);
6953 if (LocaleCompare("interline-spacing",option+1) == 0)
6957 (void) SetImageOption(image_info,option+1,"undefined");
6960 (void) SetImageOption(image_info,option+1,argv[i+1]);
6963 if (LocaleCompare("interpolate",option+1) == 0)
6967 (void) SetImageOption(image_info,option+1,"undefined");
6970 (void) SetImageOption(image_info,option+1,argv[i+1]);
6973 if (LocaleCompare("interword-spacing",option+1) == 0)
6977 (void) SetImageOption(image_info,option+1,"undefined");
6980 (void) SetImageOption(image_info,option+1,argv[i+1]);
6987 if (LocaleCompare("kerning",option+1) == 0)
6991 (void) SetImageOption(image_info,option+1,"undefined");
6994 (void) SetImageOption(image_info,option+1,argv[i+1]);
7001 if (LocaleCompare("label",option+1) == 0)
7005 (void) DeleteImageOption(image_info,option+1);
7008 (void) SetImageOption(image_info,option+1,argv[i+1]);
7011 if (LocaleCompare("limit",option+1) == 0)
7021 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7022 MagickFalse,argv[i+1]);
7023 limit=MagickResourceInfinity;
7024 if (LocaleCompare("unlimited",argv[i+2]) != 0)
7025 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7026 (void) SetMagickResourceLimit(type,limit);
7029 if (LocaleCompare("list",option+1) == 0)
7035 Display configuration list.
7037 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7040 case MagickCoderOptions:
7042 (void) ListCoderInfo((FILE *) NULL,exception);
7045 case MagickColorOptions:
7047 (void) ListColorInfo((FILE *) NULL,exception);
7050 case MagickConfigureOptions:
7052 (void) ListConfigureInfo((FILE *) NULL,exception);
7055 case MagickDelegateOptions:
7057 (void) ListDelegateInfo((FILE *) NULL,exception);
7060 case MagickFontOptions:
7062 (void) ListTypeInfo((FILE *) NULL,exception);
7065 case MagickFormatOptions:
7067 (void) ListMagickInfo((FILE *) NULL,exception);
7070 case MagickLocaleOptions:
7072 (void) ListLocaleInfo((FILE *) NULL,exception);
7075 case MagickLogOptions:
7077 (void) ListLogInfo((FILE *) NULL,exception);
7080 case MagickMagicOptions:
7082 (void) ListMagicInfo((FILE *) NULL,exception);
7085 case MagickMimeOptions:
7087 (void) ListMimeInfo((FILE *) NULL,exception);
7090 case MagickModuleOptions:
7092 (void) ListModuleInfo((FILE *) NULL,exception);
7095 case MagickPolicyOptions:
7097 (void) ListPolicyInfo((FILE *) NULL,exception);
7100 case MagickResourceOptions:
7102 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7105 case MagickThresholdOptions:
7107 (void) ListThresholdMaps((FILE *) NULL,exception);
7112 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7119 if (LocaleCompare("log",option+1) == 0)
7123 (void) SetLogFormat(argv[i+1]);
7126 if (LocaleCompare("loop",option+1) == 0)
7130 (void) SetImageOption(image_info,option+1,"0");
7133 (void) SetImageOption(image_info,option+1,argv[i+1]);
7140 if (LocaleCompare("matte",option+1) == 0)
7144 (void) SetImageOption(image_info,option+1,"false");
7147 (void) SetImageOption(image_info,option+1,"true");
7150 if (LocaleCompare("mattecolor",option+1) == 0)
7154 (void) SetImageOption(image_info,option+1,argv[i+1]);
7155 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
7156 &image_info->matte_color,exception);
7159 (void) SetImageOption(image_info,option+1,argv[i+1]);
7160 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7161 &image_info->matte_color,exception);
7164 if (LocaleCompare("metric",option+1) == 0)
7167 (void) DeleteImageOption(image_info,option+1);
7169 (void) SetImageOption(image_info,option+1,argv[i+1]);
7172 if (LocaleCompare("monitor",option+1) == 0)
7174 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7178 if (LocaleCompare("monochrome",option+1) == 0)
7180 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7187 if (LocaleCompare("orient",option+1) == 0)
7191 image_info->orientation=UndefinedOrientation;
7192 (void) SetImageOption(image_info,option+1,"undefined");
7195 image_info->orientation=(OrientationType) ParseCommandOption(
7196 MagickOrientationOptions,MagickFalse,argv[i+1]);
7197 (void) SetImageOption(image_info,option+1,argv[i+1]);
7203 if (LocaleCompare("page",option+1) == 0)
7207 page[MagickPathExtent];
7220 (void) DeleteImageOption(image_info,option+1);
7221 (void) CloneString(&image_info->page,(char *) NULL);
7224 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7225 image_option=GetImageOption(image_info,"page");
7226 if (image_option != (const char *) NULL)
7227 flags=ParseAbsoluteGeometry(image_option,&geometry);
7228 canonical_page=GetPageGeometry(argv[i+1]);
7229 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7230 canonical_page=DestroyString(canonical_page);
7231 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu",
7232 (unsigned long) geometry.width,(unsigned long) geometry.height);
7233 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7234 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld",
7235 (unsigned long) geometry.width,(unsigned long) geometry.height,
7236 (long) geometry.x,(long) geometry.y);
7237 (void) SetImageOption(image_info,option+1,page);
7238 (void) CloneString(&image_info->page,page);
7241 if (LocaleCompare("ping",option+1) == 0)
7243 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7246 if (LocaleCompare("pointsize",option+1) == 0)
7249 geometry_info.rho=0.0;
7251 (void) ParseGeometry(argv[i+1],&geometry_info);
7252 image_info->pointsize=geometry_info.rho;
7255 if (LocaleCompare("precision",option+1) == 0)
7257 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7260 if (LocaleCompare("preview",option+1) == 0)
7267 image_info->preview_type=UndefinedPreview;
7270 image_info->preview_type=(PreviewType) ParseCommandOption(
7271 MagickPreviewOptions,MagickFalse,argv[i+1]);
7278 if (LocaleCompare("quality",option+1) == 0)
7281 Set image compression quality.
7285 image_info->quality=UndefinedCompressionQuality;
7286 (void) SetImageOption(image_info,option+1,"0");
7289 image_info->quality=StringToUnsignedLong(argv[i+1]);
7290 (void) SetImageOption(image_info,option+1,argv[i+1]);
7293 if (LocaleCompare("quiet",option+1) == 0)
7295 static WarningHandler
7296 warning_handler = (WarningHandler) NULL;
7301 Restore error or warning messages.
7303 warning_handler=SetWarningHandler(warning_handler);
7307 Suppress error or warning messages.
7309 warning_handler=SetWarningHandler((WarningHandler) NULL);
7316 if (LocaleCompare("red-primary",option+1) == 0)
7320 (void) SetImageOption(image_info,option+1,"0.0");
7323 (void) SetImageOption(image_info,option+1,argv[i+1]);
7330 if (LocaleCompare("sampling-factor",option+1) == 0)
7333 Set image sampling factor.
7337 if (image_info->sampling_factor != (char *) NULL)
7338 image_info->sampling_factor=DestroyString(
7339 image_info->sampling_factor);
7342 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7345 if (LocaleCompare("scene",option+1) == 0)
7352 image_info->scene=0;
7353 (void) SetImageOption(image_info,option+1,"0");
7356 image_info->scene=StringToUnsignedLong(argv[i+1]);
7357 (void) SetImageOption(image_info,option+1,argv[i+1]);
7360 if (LocaleCompare("seed",option+1) == 0)
7367 seed=(unsigned long) time((time_t *) NULL);
7368 SetRandomSecretKey(seed);
7371 seed=StringToUnsignedLong(argv[i+1]);
7372 SetRandomSecretKey(seed);
7375 if (LocaleCompare("size",option+1) == 0)
7379 if (image_info->size != (char *) NULL)
7380 image_info->size=DestroyString(image_info->size);
7383 (void) CloneString(&image_info->size,argv[i+1]);
7386 if (LocaleCompare("stroke",option+1) == 0)
7390 (void) SetImageOption(image_info,option+1,"none");
7393 (void) SetImageOption(image_info,option+1,argv[i+1]);
7396 if (LocaleCompare("strokewidth",option+1) == 0)
7399 (void) SetImageOption(image_info,option+1,"0");
7401 (void) SetImageOption(image_info,option+1,argv[i+1]);
7404 if (LocaleCompare("style",option+1) == 0)
7408 (void) SetImageOption(image_info,option+1,"none");
7411 (void) SetImageOption(image_info,option+1,argv[i+1]);
7414 if (LocaleCompare("synchronize",option+1) == 0)
7418 image_info->synchronize=MagickFalse;
7421 image_info->synchronize=MagickTrue;
7428 if (LocaleCompare("taint",option+1) == 0)
7432 (void) SetImageOption(image_info,option+1,"false");
7435 (void) SetImageOption(image_info,option+1,"true");
7438 if (LocaleCompare("texture",option+1) == 0)
7442 if (image_info->texture != (char *) NULL)
7443 image_info->texture=DestroyString(image_info->texture);
7446 (void) CloneString(&image_info->texture,argv[i+1]);
7449 if (LocaleCompare("tile-offset",option+1) == 0)
7452 (void) SetImageOption(image_info,option+1,"0");
7454 (void) SetImageOption(image_info,option+1,argv[i+1]);
7457 if (LocaleCompare("transparent-color",option+1) == 0)
7461 (void) QueryColorCompliance("none",AllCompliance,
7462 &image_info->transparent_color,exception);
7463 (void) SetImageOption(image_info,option+1,"none");
7466 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7467 &image_info->transparent_color,exception);
7468 (void) SetImageOption(image_info,option+1,argv[i+1]);
7471 if (LocaleCompare("type",option+1) == 0)
7475 image_info->type=UndefinedType;
7476 (void) SetImageOption(image_info,option+1,"undefined");
7479 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7480 MagickFalse,argv[i+1]);
7481 (void) SetImageOption(image_info,option+1,argv[i+1]);
7488 if (LocaleCompare("undercolor",option+1) == 0)
7491 (void) DeleteImageOption(image_info,option+1);
7493 (void) SetImageOption(image_info,option+1,argv[i+1]);
7496 if (LocaleCompare("units",option+1) == 0)
7500 image_info->units=UndefinedResolution;
7501 (void) SetImageOption(image_info,option+1,"undefined");
7504 image_info->units=(ResolutionType) ParseCommandOption(
7505 MagickResolutionOptions,MagickFalse,argv[i+1]);
7506 (void) SetImageOption(image_info,option+1,argv[i+1]);
7513 if (LocaleCompare("verbose",option+1) == 0)
7517 image_info->verbose=MagickFalse;
7520 image_info->verbose=MagickTrue;
7521 image_info->ping=MagickFalse;
7524 if (LocaleCompare("virtual-pixel",option+1) == 0)
7527 (void) SetImageOption(image_info,option+1,"undefined");
7529 (void) SetImageOption(image_info,option+1,argv[i+1]);
7536 if (LocaleCompare("weight",option+1) == 0)
7539 (void) SetImageOption(image_info,option+1,"0");
7541 (void) SetImageOption(image_info,option+1,argv[i+1]);
7544 if (LocaleCompare("white-point",option+1) == 0)
7547 (void) SetImageOption(image_info,option+1,"0.0");
7549 (void) SetImageOption(image_info,option+1,argv[i+1]);
7563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7567 + M o g r i f y I m a g e L i s t %
7571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7573 % MogrifyImageList() applies any command line options that might affect the
7574 % entire image list (e.g. -append, -coalesce, etc.).
7576 % The format of the MogrifyImage method is:
7578 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7579 % const char **argv,Image **images,ExceptionInfo *exception)
7581 % A description of each parameter follows:
7583 % o image_info: the image info..
7585 % o argc: Specifies a pointer to an integer describing the number of
7586 % elements in the argument vector.
7588 % o argv: Specifies a pointer to a text array containing the command line
7591 % o images: pointer to pointer of the first image in image list.
7593 % o exception: return any errors or warnings in this structure.
7596 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7597 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7608 PixelInterpolateMethod
7622 Apply options to the image list.
7624 assert(image_info != (ImageInfo *) NULL);
7625 assert(image_info->signature == MagickCoreSignature);
7626 assert(images != (Image **) NULL);
7627 assert((*images)->previous == (Image *) NULL);
7628 assert((*images)->signature == MagickCoreSignature);
7629 if ((*images)->debug != MagickFalse)
7630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7631 (*images)->filename);
7632 if ((argc <= 0) || (*argv == (char *) NULL))
7634 interpolate_method=UndefinedInterpolatePixel;
7635 mogrify_info=CloneImageInfo(image_info);
7636 quantize_info=AcquireQuantizeInfo(mogrify_info);
7638 for (i=0; i < (ssize_t) argc; i++)
7640 if (*images == (Image *) NULL)
7643 if (IsCommandOption(option) == MagickFalse)
7645 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7646 count=MagickMax(count,0L);
7647 if ((i+count) >= (ssize_t) argc)
7649 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7650 switch (*(option+1))
7654 if (LocaleCompare("affinity",option+1) == 0)
7656 (void) SyncImagesSettings(mogrify_info,*images,exception);
7659 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7666 if (LocaleCompare("append",option+1) == 0)
7671 (void) SyncImagesSettings(mogrify_info,*images,exception);
7672 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7673 MagickFalse,exception);
7674 if (append_image == (Image *) NULL)
7679 *images=DestroyImageList(*images);
7680 *images=append_image;
7683 if (LocaleCompare("average",option+1) == 0)
7689 Average an image sequence (deprecated).
7691 (void) SyncImagesSettings(mogrify_info,*images,exception);
7692 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7694 if (average_image == (Image *) NULL)
7699 *images=DestroyImageList(*images);
7700 *images=average_image;
7707 if (LocaleCompare("channel-fx",option+1) == 0)
7712 (void) SyncImagesSettings(mogrify_info,*images,exception);
7713 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7714 if (channel_image == (Image *) NULL)
7719 *images=DestroyImageList(*images);
7720 *images=channel_image;
7723 if (LocaleCompare("clut",option+1) == 0)
7729 (void) SyncImagesSettings(mogrify_info,*images,exception);
7730 image=RemoveFirstImageFromList(images);
7731 clut_image=RemoveFirstImageFromList(images);
7732 if (clut_image == (Image *) NULL)
7737 (void) ClutImage(image,clut_image,interpolate_method,exception);
7738 clut_image=DestroyImage(clut_image);
7739 *images=DestroyImageList(*images);
7743 if (LocaleCompare("coalesce",option+1) == 0)
7748 (void) SyncImagesSettings(mogrify_info,*images,exception);
7749 coalesce_image=CoalesceImages(*images,exception);
7750 if (coalesce_image == (Image *) NULL)
7755 *images=DestroyImageList(*images);
7756 *images=coalesce_image;
7759 if (LocaleCompare("combine",option+1) == 0)
7767 (void) SyncImagesSettings(mogrify_info,*images,exception);
7768 colorspace=(*images)->colorspace;
7770 colorspace=(ColorspaceType) ParseCommandOption(
7771 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7772 combine_image=CombineImages(*images,colorspace,exception);
7773 if (combine_image == (Image *) NULL)
7778 *images=DestroyImageList(*images);
7779 *images=combine_image;
7782 if (LocaleCompare("compare",option+1) == 0)
7796 Mathematically and visually annotate the difference between an
7797 image and its reconstruction.
7799 (void) SyncImagesSettings(mogrify_info,*images,exception);
7800 image=RemoveFirstImageFromList(images);
7801 reconstruct_image=RemoveFirstImageFromList(images);
7802 if (reconstruct_image == (Image *) NULL)
7807 metric=UndefinedErrorMetric;
7808 option=GetImageOption(image_info,"metric");
7809 if (option != (const char *) NULL)
7810 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7811 MagickFalse,option);
7812 difference_image=CompareImages(image,reconstruct_image,metric,
7813 &distortion,exception);
7814 if (difference_image == (Image *) NULL)
7816 if (*images != (Image *) NULL)
7817 *images=DestroyImage(*images);
7818 *images=difference_image;
7821 if (LocaleCompare("complex",option+1) == 0)
7829 (void) SyncImageSettings(mogrify_info,*images,exception);
7830 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7831 MagickFalse,argv[i+1]);
7832 complex_images=ComplexImages(*images,op,exception);
7833 if (complex_images == (Image *) NULL)
7838 *images=DestroyImageList(*images);
7839 *images=complex_images;
7842 if (LocaleCompare("composite",option+1) == 0)
7858 (void) SyncImagesSettings(mogrify_info,*images,exception);
7859 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7860 if (value == (const char *) NULL)
7861 clip_to_self=MagickTrue;
7863 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7864 "compose:clip-to-self")); /* if this is true */
7865 if (clip_to_self == MagickFalse) /* or */
7866 clip_to_self=IsStringFalse(GetImageOption(mogrify_info,
7867 "compose:outside-overlay"));
7868 image=RemoveFirstImageFromList(images);
7869 composite_image=RemoveFirstImageFromList(images);
7870 if (composite_image == (Image *) NULL)
7875 (void) TransformImage(&composite_image,(char *) NULL,
7876 composite_image->geometry,exception);
7877 SetGeometry(composite_image,&geometry);
7878 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7879 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7881 mask_image=RemoveFirstImageFromList(images);
7882 if (mask_image == (Image *) NULL)
7883 (void) CompositeImage(image,composite_image,image->compose,
7884 clip_to_self,geometry.x,geometry.y,exception);
7887 if ((image->compose != DisplaceCompositeOp) &&
7888 (image->compose != DistortCompositeOp))
7890 status&=CompositeImage(composite_image,mask_image,
7891 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7892 (void) CompositeImage(image,composite_image,image->compose,
7893 clip_to_self,geometry.x,geometry.y,exception);
7900 clone_image=CloneImage(image,0,0,MagickTrue,exception);
7901 if (clone_image == (Image *) NULL)
7903 (void) CompositeImage(image,composite_image,image->compose,
7904 clip_to_self,geometry.x,geometry.y,exception);
7905 status&=CompositeImage(image,mask_image,
7906 CopyAlphaCompositeOp,MagickTrue,0,0,exception);
7907 status&=CompositeImage(clone_image,image,OverCompositeOp,
7908 clip_to_self,0,0,exception);
7909 image=DestroyImage(image);
7912 mask_image=DestroyImage(mask_image);
7914 composite_image=DestroyImage(composite_image);
7915 *images=DestroyImageList(*images);
7919 if (LocaleCompare("copy",option+1) == 0)
7933 (void) SyncImageSettings(mogrify_info,*images,exception);
7934 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
7935 offset.x=geometry.x;
7936 offset.y=geometry.y;
7937 source_image=(*images);
7938 if (source_image->next != (Image *) NULL)
7939 source_image=source_image->next;
7940 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
7942 status=CopyImagePixels(*images,source_image,&geometry,&offset,
7950 if (LocaleCompare("deconstruct",option+1) == 0)
7955 (void) SyncImagesSettings(mogrify_info,*images,exception);
7956 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7958 if (deconstruct_image == (Image *) NULL)
7963 *images=DestroyImageList(*images);
7964 *images=deconstruct_image;
7967 if (LocaleCompare("delete",option+1) == 0)
7970 DeleteImages(images,"-1",exception);
7972 DeleteImages(images,argv[i+1],exception);
7975 if (LocaleCompare("dither",option+1) == 0)
7979 quantize_info->dither_method=NoDitherMethod;
7982 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7983 MagickDitherOptions,MagickFalse,argv[i+1]);
7986 if (LocaleCompare("duplicate",option+1) == 0)
7992 duplicate_images=DuplicateImages(*images,1,"-1",exception);
8001 number_duplicates=(size_t) StringToLong(argv[i+1]);
8002 p=strchr(argv[i+1],',');
8003 if (p == (const char *) NULL)
8004 duplicate_images=DuplicateImages(*images,number_duplicates,
8007 duplicate_images=DuplicateImages(*images,number_duplicates,p,
8010 AppendImageToList(images, duplicate_images);
8011 (void) SyncImagesSettings(mogrify_info,*images,exception);
8018 if (LocaleCompare("evaluate-sequence",option+1) == 0)
8023 MagickEvaluateOperator
8026 (void) SyncImageSettings(mogrify_info,*images,exception);
8027 op=(MagickEvaluateOperator) ParseCommandOption(
8028 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8029 evaluate_image=EvaluateImages(*images,op,exception);
8030 if (evaluate_image == (Image *) NULL)
8035 *images=DestroyImageList(*images);
8036 *images=evaluate_image;
8043 if (LocaleCompare("fft",option+1) == 0)
8049 Implements the discrete Fourier transform (DFT).
8051 (void) SyncImageSettings(mogrify_info,*images,exception);
8052 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8053 MagickTrue : MagickFalse,exception);
8054 if (fourier_image == (Image *) NULL)
8056 *images=DestroyImage(*images);
8057 *images=fourier_image;
8060 if (LocaleCompare("flatten",option+1) == 0)
8065 (void) SyncImagesSettings(mogrify_info,*images,exception);
8066 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8067 if (flatten_image == (Image *) NULL)
8069 *images=DestroyImageList(*images);
8070 *images=flatten_image;
8073 if (LocaleCompare("fx",option+1) == 0)
8078 (void) SyncImagesSettings(mogrify_info,*images,exception);
8079 fx_image=FxImage(*images,argv[i+1],exception);
8080 if (fx_image == (Image *) NULL)
8085 *images=DestroyImageList(*images);
8093 if (LocaleCompare("hald-clut",option+1) == 0)
8099 (void) SyncImagesSettings(mogrify_info,*images,exception);
8100 image=RemoveFirstImageFromList(images);
8101 hald_image=RemoveFirstImageFromList(images);
8102 if (hald_image == (Image *) NULL)
8107 (void) HaldClutImage(image,hald_image,exception);
8108 hald_image=DestroyImage(hald_image);
8109 if (*images != (Image *) NULL)
8110 *images=DestroyImageList(*images);
8118 if (LocaleCompare("ift",option+1) == 0)
8126 Implements the inverse fourier discrete Fourier transform (DFT).
8128 (void) SyncImagesSettings(mogrify_info,*images,exception);
8129 magnitude_image=RemoveFirstImageFromList(images);
8130 phase_image=RemoveFirstImageFromList(images);
8131 if (phase_image == (Image *) NULL)
8136 fourier_image=InverseFourierTransformImage(magnitude_image,
8137 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
8138 if (fourier_image == (Image *) NULL)
8140 if (*images != (Image *) NULL)
8141 *images=DestroyImage(*images);
8142 *images=fourier_image;
8145 if (LocaleCompare("insert",option+1) == 0)
8153 index=(ssize_t) StringToLong(argv[i+1]);
8154 p=RemoveLastImageFromList(images);
8155 if (p == (Image *) NULL)
8157 (void) ThrowMagickException(exception,GetMagickModule(),
8158 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8164 PrependImageToList(images,q);
8166 if (index == (ssize_t) GetImageListLength(*images))
8167 AppendImageToList(images,q);
8170 q=GetImageFromList(*images,index-1);
8171 if (q == (Image *) NULL)
8173 (void) ThrowMagickException(exception,GetMagickModule(),
8174 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8178 InsertImageInList(&q,p);
8180 *images=GetFirstImageInList(q);
8183 if (LocaleCompare("interpolate",option+1) == 0)
8185 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8186 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8193 if (LocaleCompare("layers",option+1) == 0)
8201 (void) SyncImagesSettings(mogrify_info,*images,exception);
8202 layers=(Image *) NULL;
8203 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8204 MagickFalse,argv[i+1]);
8209 layers=CoalesceImages(*images,exception);
8212 case CompareAnyLayer:
8213 case CompareClearLayer:
8214 case CompareOverlayLayer:
8217 layers=CompareImagesLayers(*images,method,exception);
8223 case TrimBoundsLayer:
8225 layers=MergeImageLayers(*images,method,exception);
8230 layers=DisposeImages(*images,exception);
8233 case OptimizeImageLayer:
8235 layers=OptimizeImageLayers(*images,exception);
8238 case OptimizePlusLayer:
8240 layers=OptimizePlusImageLayers(*images,exception);
8243 case OptimizeTransLayer:
8245 OptimizeImageTransparency(*images,exception);
8248 case RemoveDupsLayer:
8250 RemoveDuplicateLayers(images,exception);
8253 case RemoveZeroLayer:
8255 RemoveZeroDelayLayers(images,exception);
8261 General Purpose, GIF Animation Optimizer.
8263 layers=CoalesceImages(*images,exception);
8264 if (layers == (Image *) NULL)
8269 *images=DestroyImageList(*images);
8271 layers=OptimizeImageLayers(*images,exception);
8272 if (layers == (Image *) NULL)
8277 *images=DestroyImageList(*images);
8279 layers=(Image *) NULL;
8280 OptimizeImageTransparency(*images,exception);
8281 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8285 case CompositeLayer:
8297 Split image sequence at the first 'NULL:' image.
8300 while (source != (Image *) NULL)
8302 source=GetNextImageInList(source);
8303 if ((source != (Image *) NULL) &&
8304 (LocaleCompare(source->magick,"NULL") == 0))
8307 if (source != (Image *) NULL)
8309 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8310 (GetNextImageInList(source) == (Image *) NULL))
8311 source=(Image *) NULL;
8315 Separate the two lists, junk the null: image.
8317 source=SplitImageList(source->previous);
8318 DeleteImageFromList(&source);
8321 if (source == (Image *) NULL)
8323 (void) ThrowMagickException(exception,GetMagickModule(),
8324 OptionError,"MissingNullSeparator","layers Composite");
8329 Adjust offset with gravity and virtual canvas.
8331 SetGeometry(*images,&geometry);
8332 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8333 geometry.width=source->page.width != 0 ?
8334 source->page.width : source->columns;
8335 geometry.height=source->page.height != 0 ?
8336 source->page.height : source->rows;
8337 GravityAdjustGeometry((*images)->page.width != 0 ?
8338 (*images)->page.width : (*images)->columns,
8339 (*images)->page.height != 0 ? (*images)->page.height :
8340 (*images)->rows,(*images)->gravity,&geometry);
8341 compose=OverCompositeOp;
8342 option=GetImageOption(mogrify_info,"compose");
8343 if (option != (const char *) NULL)
8344 compose=(CompositeOperator) ParseCommandOption(
8345 MagickComposeOptions,MagickFalse,option);
8346 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8348 source=DestroyImageList(source);
8352 if (layers == (Image *) NULL)
8354 *images=DestroyImageList(*images);
8362 if (LocaleCompare("map",option+1) == 0)
8364 (void) SyncImagesSettings(mogrify_info,*images,exception);
8367 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8374 if (LocaleCompare("maximum",option+1) == 0)
8380 Maximum image sequence (deprecated).
8382 (void) SyncImagesSettings(mogrify_info,*images,exception);
8383 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8384 if (maximum_image == (Image *) NULL)
8389 *images=DestroyImageList(*images);
8390 *images=maximum_image;
8393 if (LocaleCompare("minimum",option+1) == 0)
8399 Minimum image sequence (deprecated).
8401 (void) SyncImagesSettings(mogrify_info,*images,exception);
8402 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8403 if (minimum_image == (Image *) NULL)
8408 *images=DestroyImageList(*images);
8409 *images=minimum_image;
8412 if (LocaleCompare("morph",option+1) == 0)
8417 (void) SyncImagesSettings(mogrify_info,*images,exception);
8418 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8420 if (morph_image == (Image *) NULL)
8425 *images=DestroyImageList(*images);
8426 *images=morph_image;
8429 if (LocaleCompare("mosaic",option+1) == 0)
8434 (void) SyncImagesSettings(mogrify_info,*images,exception);
8435 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8436 if (mosaic_image == (Image *) NULL)
8441 *images=DestroyImageList(*images);
8442 *images=mosaic_image;
8449 if (LocaleCompare("poly",option+1) == 0)
8453 token[MagickPathExtent];
8473 (void) SyncImageSettings(mogrify_info,*images,exception);
8474 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8476 if (args == (char *) NULL)
8479 for (x=0; *p != '\0'; x++)
8481 GetMagickToken(p,&p,token);
8483 GetMagickToken(p,&p,token);
8485 number_arguments=(size_t) x;
8486 arguments=(double *) AcquireQuantumMemory(number_arguments,
8487 sizeof(*arguments));
8488 if (arguments == (double *) NULL)
8489 ThrowWandFatalException(ResourceLimitFatalError,
8490 "MemoryAllocationFailed",(*images)->filename);
8491 (void) ResetMagickMemory(arguments,0,number_arguments*
8492 sizeof(*arguments));
8494 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8496 GetMagickToken(p,&p,token);
8498 GetMagickToken(p,&p,token);
8499 arguments[x]=StringToDouble(token,(char **) NULL);
8501 args=DestroyString(args);
8502 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8503 arguments,exception);
8504 arguments=(double *) RelinquishMagickMemory(arguments);
8505 if (polynomial_image == (Image *) NULL)
8510 *images=DestroyImageList(*images);
8511 *images=polynomial_image;
8513 if (LocaleCompare("print",option+1) == 0)
8518 (void) SyncImagesSettings(mogrify_info,*images,exception);
8519 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8521 if (string == (char *) NULL)
8523 (void) FormatLocaleFile(stdout,"%s",string);
8524 string=DestroyString(string);
8526 if (LocaleCompare("process",option+1) == 0)
8535 (void) SyncImagesSettings(mogrify_info,*images,exception);
8536 arguments=StringToArgv(argv[i+1],&number_arguments);
8537 if (arguments == (char **) NULL)
8539 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8560 Support old style syntax, filter="-option arg".
8562 length=strlen(argv[i+1]);
8563 token=(char *) NULL;
8564 if (~length >= (MagickPathExtent-1))
8565 token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
8567 if (token == (char *) NULL)
8571 token_info=AcquireTokenInfo();
8572 token_status=Tokenizer(token_info,0,token,length,argument,"",
8573 "=","\"",'\0',&breaker,&next,"e);
8574 token_info=DestroyTokenInfo(token_info);
8575 if (token_status == 0)
8580 arg=(&(argument[next]));
8581 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8584 token=DestroyString(token);
8587 (void) SubstituteString(&arguments[1],"-","");
8588 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8589 number_arguments-2,(const char **) arguments+2,exception);
8590 for (j=0; j < number_arguments; j++)
8591 arguments[j]=DestroyString(arguments[j]);
8592 arguments=(char **) RelinquishMagickMemory(arguments);
8599 if (LocaleCompare("reverse",option+1) == 0)
8601 ReverseImageList(images);
8608 if (LocaleCompare("smush",option+1) == 0)
8616 (void) SyncImagesSettings(mogrify_info,*images,exception);
8617 offset=(ssize_t) StringToLong(argv[i+1]);
8618 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8619 MagickFalse,offset,exception);
8620 if (smush_image == (Image *) NULL)
8625 *images=DestroyImageList(*images);
8626 *images=smush_image;
8629 if (LocaleCompare("swap",option+1) == 0)
8650 flags=ParseGeometry(argv[i+1],&geometry_info);
8651 index=(ssize_t) geometry_info.rho;
8652 if ((flags & SigmaValue) != 0)
8653 swap_index=(ssize_t) geometry_info.sigma;
8655 p=GetImageFromList(*images,index);
8656 q=GetImageFromList(*images,swap_index);
8657 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8659 (void) ThrowMagickException(exception,GetMagickModule(),
8660 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8666 swap=CloneImage(p,0,0,MagickTrue,exception);
8667 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8668 ReplaceImageInList(&q,swap);
8669 *images=GetFirstImageInList(q);
8676 if (LocaleCompare("write",option+1) == 0)
8679 key[MagickPathExtent];
8687 (void) SyncImagesSettings(mogrify_info,*images,exception);
8688 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",argv[i+1]);
8689 (void) DeleteImageRegistry(key);
8690 write_images=(*images);
8692 write_images=CloneImageList(*images,exception);
8693 write_info=CloneImageInfo(mogrify_info);
8694 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8695 write_info=DestroyImageInfo(write_info);
8697 write_images=DestroyImageList(write_images);
8707 quantize_info=DestroyQuantizeInfo(quantize_info);
8708 mogrify_info=DestroyImageInfo(mogrify_info);
8709 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8710 return(status != 0 ? MagickTrue : MagickFalse);
8714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8718 + M o g r i f y I m a g e s %
8722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8724 % MogrifyImages() applies image processing options to a sequence of images as
8725 % prescribed by command line options.
8727 % The format of the MogrifyImage method is:
8729 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8730 % const MagickBooleanType post,const int argc,const char **argv,
8731 % Image **images,Exceptioninfo *exception)
8733 % A description of each parameter follows:
8735 % o image_info: the image info..
8737 % o post: If true, post process image list operators otherwise pre-process.
8739 % o argc: Specifies a pointer to an integer describing the number of
8740 % elements in the argument vector.
8742 % o argv: Specifies a pointer to a text array containing the command line
8745 % o images: pointer to a pointer of the first image in image list.
8747 % o exception: return any errors or warnings in this structure.
8750 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8751 const MagickBooleanType post,const int argc,const char **argv,
8752 Image **images,ExceptionInfo *exception)
8754 #define MogrifyImageTag "Mogrify/Image"
8768 assert(image_info != (ImageInfo *) NULL);
8769 assert(image_info->signature == MagickCoreSignature);
8770 if (images == (Image **) NULL)
8771 return(MogrifyImage(image_info,argc,argv,images,exception));
8772 assert((*images)->previous == (Image *) NULL);
8773 assert((*images)->signature == MagickCoreSignature);
8774 if ((*images)->debug != MagickFalse)
8775 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8776 (*images)->filename);
8777 if ((argc <= 0) || (*argv == (char *) NULL))
8779 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8783 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8787 Pre-process multi-image sequence operators
8789 if (post == MagickFalse)
8790 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8792 For each image, process simple single image operators
8795 n=GetImageListLength(*images);
8799 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8800 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8802 status&=MogrifyImage(image_info,argc,argv,images,exception);
8803 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8804 if (proceed == MagickFalse)
8806 if ( (*images)->next == (Image *) NULL )
8808 *images=(*images)->next;
8811 assert( *images != (Image *) NULL );
8813 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8814 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8817 Post-process, multi-image sequence operators
8819 *images=GetFirstImageInList(*images);
8820 if (post != MagickFalse)
8821 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8822 return(status != 0 ? MagickTrue : MagickFalse);