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-2012 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/string-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/utility-private.h"
62 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
69 #define UndefinedCompressionQuality 0UL
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % M a g i c k C o m m a n d G e n e s i s %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % MagickCommandGenesis() applies image processing options to an image as
83 % prescribed by command line options.
85 % The format of the MagickCommandGenesis method is:
87 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
88 % MagickCommand command,int argc,char **argv,char **metadata,
89 % ExceptionInfo *exception)
91 % A description of each parameter follows:
93 % o image_info: the image info.
95 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
96 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
97 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98 % DisplayImageCommand, or AnimateImageCommand.
100 % o argc: Specifies a pointer to an integer describing the number of
101 % elements in the argument vector.
103 % o argv: Specifies a pointer to a text array containing the command line
106 % o metadata: any metadata is returned here.
108 % o exception: return any errors or warnings in this structure.
111 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
139 concurrent=MagickFalse;
143 regard_warnings=MagickFalse;
144 for (i=1; i < (ssize_t) (argc-1); i++)
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
149 if (LocaleCompare("-bench",option) == 0)
150 iterations=StringToUnsignedLong(argv[++i]);
151 if (LocaleCompare("-concurrent",option) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("-debug",option) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("-duration",option) == 0)
156 duration=StringToDouble(argv[++i],(char **) NULL);
157 if (LocaleCompare("-regard-warnings",option) == 0)
158 regard_warnings=MagickTrue;
162 status=command(image_info,argc,argv,metadata,exception);
163 if (exception->severity != UndefinedException)
165 if ((exception->severity > ErrorException) ||
166 (regard_warnings != MagickFalse))
168 CatchException(exception);
170 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
172 (void) fputs(*metadata,stdout);
173 (void) fputc('\n',stdout);
174 *metadata=DestroyString(*metadata);
178 number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
180 for (n=1; n <= (ssize_t) number_threads; n++)
190 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
191 timer=AcquireTimerInfo();
192 if (concurrent == MagickFalse)
194 for (i=0; i < (ssize_t) iterations; i++)
196 if (status != MagickFalse)
200 if (GetElapsedTime(timer) > duration)
202 (void) ContinueTimer(timer);
204 status=command(image_info,argc,argv,metadata,exception);
205 if (exception->severity != UndefinedException)
207 if ((exception->severity > ErrorException) ||
208 (regard_warnings != MagickFalse))
210 CatchException(exception);
212 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
214 (void) fputs(*metadata,stdout);
215 (void) fputc('\n',stdout);
216 *metadata=DestroyString(*metadata);
223 #if defined(MAGICKCORE_OPENMP_SUPPORT)
224 # pragma omp parallel for shared(status)
226 for (i=0; i < (ssize_t) iterations; i++)
228 if (status != MagickFalse)
232 if (GetElapsedTime(timer) > duration)
234 (void) ContinueTimer(timer);
236 status=command(image_info,argc,argv,metadata,exception);
237 #if defined(MAGICKCORE_OPENMP_SUPPORT)
238 # pragma omp critical (MagickCore_CommandGenesis)
241 if (exception->severity != UndefinedException)
243 if ((exception->severity > ErrorException) ||
244 (regard_warnings != MagickFalse))
246 CatchException(exception);
248 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
250 (void) fputs(*metadata,stdout);
251 (void) fputc('\n',stdout);
252 *metadata=DestroyString(*metadata);
257 user_time=GetUserTime(timer);
258 parallel=GetElapsedTime(timer);
263 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
264 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
265 (void) FormatLocaleFile(stderr,
266 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
267 (double) n,(double) iterations,(double) iterations/parallel,e,
268 user_time,(unsigned long) (parallel/60.0),(unsigned long)
269 floor(fmod(parallel,60.0)),(unsigned long)
270 (1000.0*(parallel-floor(parallel))+0.5));
271 timer=DestroyTimerInfo(timer);
277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281 + M o g r i f y I m a g e %
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 % MogrifyImage() applies simple single image processing options to a single
288 % image that may be part of a large list, but also handles any 'region'
291 % The image in the list may be modified in three different ways...
293 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
294 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
295 % * replace by a list of images (only the -separate option!)
297 % In each case the result is returned into the list, and a pointer to the
298 % modified image (last image added if replaced by a list of images) is
301 % ASIDE: The -crop is present but restricted to non-tile single image crops
303 % This means if all the images are being processed (such as by
304 % MogrifyImages(), next image to be processed will be as per the pointer
305 % (*image)->next. Also the image list may grow as a result of some specific
306 % operations but as images are never merged or deleted, it will never shrink
307 % in length. Typically the list will remain the same length.
309 % WARNING: As the image pointed to may be replaced, the first image in the
310 % list may also change. GetFirstImageInList() should be used by caller if
311 % they wish return the Image pointer to the first image in list.
314 % The format of the MogrifyImage method is:
316 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
317 % const char **argv,Image **image)
319 % A description of each parameter follows:
321 % o image_info: the image info..
323 % o argc: Specifies a pointer to an integer describing the number of
324 % elements in the argument vector.
326 % o argv: Specifies a pointer to a text array containing the command line
329 % o image: the image.
331 % o exception: return any errors or warnings in this structure.
335 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
336 ExceptionInfo *exception)
351 Read an image into a image cache (for repeated usage) if not already in
352 cache. Then return the image that is in the cache.
354 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
355 sans_exception=AcquireExceptionInfo();
356 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
357 sans_exception=DestroyExceptionInfo(sans_exception);
358 if (image != (Image *) NULL)
360 read_info=CloneImageInfo(image_info);
361 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
362 image=ReadImage(read_info,exception);
363 read_info=DestroyImageInfo(read_info);
364 if (image != (Image *) NULL)
365 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
369 static MagickBooleanType IsPathWritable(const char *path)
371 if (IsPathAccessible(path) == MagickFalse)
373 if (access_utf8(path,W_OK) != 0)
378 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
385 static MagickBooleanType MonitorProgress(const char *text,
386 const MagickOffsetType offset,const MagickSizeType extent,
387 void *wand_unused(client_data))
390 message[MaxTextExtent],
401 (void) CopyMagickMemory(tag,text,MaxTextExtent);
403 if (p != (char *) NULL)
405 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
406 locale_message=GetLocaleMessage(message);
407 if (locale_message == message)
409 if (p == (char *) NULL)
410 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
411 locale_message,(long) offset,(unsigned long) extent,(long)
412 (100L*offset/(extent-1)));
414 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
415 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
416 (100L*offset/(extent-1)));
417 if (offset == (MagickOffsetType) (extent-1))
418 (void) FormatLocaleFile(stderr,"\n");
419 (void) fflush(stderr);
423 static Image *SparseColorOption(const Image *image,
424 const SparseColorMethod method,const char *arguments,
425 const MagickBooleanType color_from_image,ExceptionInfo *exception)
428 token[MaxTextExtent];
453 SparseColorOption() parses the complex -sparse-color argument into an an
454 array of floating point values then calls SparseColorImage(). Argument is
455 a complex mix of floating-point pixel coodinates, and color specifications
456 (or direct floating point numbers). The number of floats needed to
457 represent a color varies depending on the current channel setting.
459 assert(image != (Image *) NULL);
460 assert(image->signature == MagickSignature);
461 if (image->debug != MagickFalse)
462 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
463 assert(exception != (ExceptionInfo *) NULL);
464 assert(exception->signature == MagickSignature);
466 Limit channels according to image - and add up number of color channel.
469 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
471 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
473 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
475 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
476 (image->colorspace == CMYKColorspace))
478 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
479 (image->matte != MagickFalse))
483 Read string, to determine number of arguments needed,
489 GetMagickToken(p,&p,token);
490 if ( token[0] == ',' ) continue;
491 if ( isalpha((int) token[0]) || token[0] == '#' ) {
492 if ( color_from_image ) {
493 (void) ThrowMagickException(exception,GetMagickModule(),
494 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
495 "Color arg given, when colors are coming from image");
496 return( (Image *)NULL);
498 x += number_colors; /* color argument */
501 x++; /* floating point argument */
505 if ( color_from_image ) {
506 /* just the control points are being given */
507 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
508 number_arguments=(x/2)*(2+number_colors);
511 /* control points and color values */
512 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
516 (void) ThrowMagickException(exception,GetMagickModule(),
517 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
518 "Invalid number of Arguments");
519 return( (Image *)NULL);
522 /* Allocate and fill in the floating point arguments */
523 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
524 sizeof(*sparse_arguments));
525 if (sparse_arguments == (double *) NULL) {
526 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
527 "MemoryAllocationFailed","%s","SparseColorOption");
528 return( (Image *)NULL);
530 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
531 sizeof(*sparse_arguments));
534 while( *p != '\0' && x < number_arguments ) {
536 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
537 if ( token[0] == '\0' ) break;
538 if ( isalpha((int) token[0]) || token[0] == '#' ) {
539 (void) ThrowMagickException(exception,GetMagickModule(),
540 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
541 "Color found, instead of X-coord");
545 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
547 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
548 if ( token[0] == '\0' ) break;
549 if ( isalpha((int) token[0]) || token[0] == '#' ) {
550 (void) ThrowMagickException(exception,GetMagickModule(),
551 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
552 "Color found, instead of Y-coord");
556 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
557 /* color values for this control point */
559 if ( (color_from_image ) {
560 /* get color from image */
566 /* color name or function given in string argument */
567 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
568 if ( token[0] == '\0' ) break;
569 if ( isalpha((int) token[0]) || token[0] == '#' ) {
570 /* Color string given */
571 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
572 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
573 sparse_arguments[x++] = QuantumScale*color.red;
574 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
575 sparse_arguments[x++] = QuantumScale*color.green;
576 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
577 sparse_arguments[x++] = QuantumScale*color.blue;
578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
579 (image->colorspace == CMYKColorspace))
580 sparse_arguments[x++] = QuantumScale*color.black;
581 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
582 (image->matte != MagickFalse))
583 sparse_arguments[x++] = QuantumScale*color.alpha;
586 /* Colors given as a set of floating point values - experimental */
587 /* NB: token contains the first floating point value to use! */
588 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
593 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
594 token[0] = ','; /* used this token - get another */
596 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
598 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
599 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
601 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
602 token[0] = ','; /* used this token - get another */
604 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
606 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
607 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
609 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
610 token[0] = ','; /* used this token - get another */
612 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
613 (image->colorspace == CMYKColorspace))
615 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
616 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
618 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
619 token[0] = ','; /* used this token - get another */
621 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
622 (image->matte != MagickFalse))
624 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
625 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
627 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
628 token[0] = ','; /* used this token - get another */
633 if ( number_arguments != x && !error ) {
634 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
635 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
636 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
637 return( (Image *)NULL);
640 return( (Image *)NULL);
642 /* Call the Interpolation function with the parsed arguments */
643 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
645 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
646 return( sparse_image );
649 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
650 const char **argv,Image **image,ExceptionInfo *exception)
683 PixelInterpolateMethod
697 Initialize method variables.
699 assert(image_info != (const ImageInfo *) NULL);
700 assert(image_info->signature == MagickSignature);
701 assert(image != (Image **) NULL);
702 assert((*image)->signature == MagickSignature);
703 if ((*image)->debug != MagickFalse)
704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
707 mogrify_info=CloneImageInfo(image_info);
708 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
709 quantize_info=AcquireQuantizeInfo(mogrify_info);
710 SetGeometryInfo(&geometry_info);
711 GetPixelInfo(*image,&fill);
712 fill=(*image)->background_color;
714 compose=(*image)->compose;
715 interpolate_method=UndefinedInterpolatePixel;
716 format=GetImageOption(mogrify_info,"format");
717 SetGeometry(*image,®ion_geometry);
718 region_image=NewImageList();
720 Transmogrify the image.
722 for (i=0; i < (ssize_t) argc; i++)
731 if (IsCommandOption(option) == MagickFalse)
733 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
735 if ((i+count) >= (ssize_t) argc)
737 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
738 mogrify_image=(Image *)NULL;
743 if (LocaleCompare("adaptive-blur",option+1) == 0)
748 (void) SyncImageSettings(mogrify_info,*image,exception);
749 flags=ParseGeometry(argv[i+1],&geometry_info);
750 if ((flags & SigmaValue) == 0)
751 geometry_info.sigma=1.0;
752 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
753 geometry_info.sigma,exception);
756 if (LocaleCompare("adaptive-resize",option+1) == 0)
759 Adaptive resize image.
761 (void) SyncImageSettings(mogrify_info,*image,exception);
762 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
763 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
764 geometry.height,exception);
767 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
770 Adaptive sharpen image.
772 (void) SyncImageSettings(mogrify_info,*image,exception);
773 flags=ParseGeometry(argv[i+1],&geometry_info);
774 if ((flags & SigmaValue) == 0)
775 geometry_info.sigma=1.0;
776 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
777 geometry_info.sigma,exception);
780 if (LocaleCompare("affine",option+1) == 0)
787 GetAffineMatrix(&draw_info->affine);
790 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
793 if (LocaleCompare("alpha",option+1) == 0)
798 (void) SyncImageSettings(mogrify_info,*image,exception);
799 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
800 MagickFalse,argv[i+1]);
801 (void) SetImageAlphaChannel(*image,alpha_type,exception);
804 if (LocaleCompare("annotate",option+1) == 0)
808 geometry[MaxTextExtent];
813 (void) SyncImageSettings(mogrify_info,*image,exception);
814 SetGeometryInfo(&geometry_info);
815 flags=ParseGeometry(argv[i+1],&geometry_info);
816 if ((flags & SigmaValue) == 0)
817 geometry_info.sigma=geometry_info.rho;
818 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
820 if (text == (char *) NULL)
822 (void) CloneString(&draw_info->text,text);
823 text=DestroyString(text);
824 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
825 geometry_info.xi,geometry_info.psi);
826 (void) CloneString(&draw_info->geometry,geometry);
827 draw_info->affine.sx=cos(DegreesToRadians(
828 fmod(geometry_info.rho,360.0)));
829 draw_info->affine.rx=sin(DegreesToRadians(
830 fmod(geometry_info.rho,360.0)));
831 draw_info->affine.ry=(-sin(DegreesToRadians(
832 fmod(geometry_info.sigma,360.0))));
833 draw_info->affine.sy=cos(DegreesToRadians(
834 fmod(geometry_info.sigma,360.0)));
835 (void) AnnotateImage(*image,draw_info,exception);
838 if (LocaleCompare("antialias",option+1) == 0)
840 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
842 draw_info->text_antialias=(*option == '-') ? MagickTrue :
846 if (LocaleCompare("attenuate",option+1) == 0)
853 attenuate=StringToDouble(argv[i+1],(char **) NULL);
856 if (LocaleCompare("auto-gamma",option+1) == 0)
859 Auto Adjust Gamma of image based on its mean
861 (void) SyncImageSettings(mogrify_info,*image,exception);
862 (void) AutoGammaImage(*image,exception);
865 if (LocaleCompare("auto-level",option+1) == 0)
868 Perfectly Normalize (max/min stretch) the image
870 (void) SyncImageSettings(mogrify_info,*image,exception);
871 (void) AutoLevelImage(*image,exception);
874 if (LocaleCompare("auto-orient",option+1) == 0)
876 (void) SyncImageSettings(mogrify_info,*image,exception);
877 switch ((*image)->orientation)
879 case TopRightOrientation:
881 mogrify_image=FlopImage(*image,exception);
884 case BottomRightOrientation:
886 mogrify_image=RotateImage(*image,180.0,exception);
889 case BottomLeftOrientation:
891 mogrify_image=FlipImage(*image,exception);
894 case LeftTopOrientation:
896 mogrify_image=TransposeImage(*image,exception);
899 case RightTopOrientation:
901 mogrify_image=RotateImage(*image,90.0,exception);
904 case RightBottomOrientation:
906 mogrify_image=TransverseImage(*image,exception);
909 case LeftBottomOrientation:
911 mogrify_image=RotateImage(*image,270.0,exception);
917 if (mogrify_image != (Image *) NULL)
918 mogrify_image->orientation=TopLeftOrientation;
925 if (LocaleCompare("black-threshold",option+1) == 0)
928 Black threshold image.
930 (void) SyncImageSettings(mogrify_info,*image,exception);
931 (void) BlackThresholdImage(*image,argv[i+1],exception);
934 if (LocaleCompare("blue-shift",option+1) == 0)
939 (void) SyncImageSettings(mogrify_info,*image,exception);
940 geometry_info.rho=1.5;
942 flags=ParseGeometry(argv[i+1],&geometry_info);
943 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
946 if (LocaleCompare("blur",option+1) == 0)
951 (void) SyncImageSettings(mogrify_info,*image,exception);
952 flags=ParseGeometry(argv[i+1],&geometry_info);
953 if ((flags & SigmaValue) == 0)
954 geometry_info.sigma=1.0;
955 if ((flags & XiValue) == 0)
956 geometry_info.xi=0.0;
957 mogrify_image=BlurImage(*image,geometry_info.rho,
958 geometry_info.sigma,exception);
961 if (LocaleCompare("border",option+1) == 0)
964 Surround image with a border of solid color.
966 (void) SyncImageSettings(mogrify_info,*image,exception);
967 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
968 if ((flags & SigmaValue) == 0)
969 geometry.height=geometry.width;
970 mogrify_image=BorderImage(*image,&geometry,compose,exception);
973 if (LocaleCompare("bordercolor",option+1) == 0)
977 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
978 &draw_info->border_color,exception);
981 (void) QueryColorCompliance(argv[i+1],AllCompliance,
982 &draw_info->border_color,exception);
985 if (LocaleCompare("box",option+1) == 0)
987 (void) QueryColorCompliance(argv[i+1],AllCompliance,
988 &draw_info->undercolor,exception);
991 if (LocaleCompare("brightness-contrast",option+1) == 0)
1004 Brightness / contrast image.
1006 (void) SyncImageSettings(mogrify_info,*image,exception);
1007 flags=ParseGeometry(argv[i+1],&geometry_info);
1008 brightness=geometry_info.rho;
1010 if ((flags & SigmaValue) != 0)
1011 contrast=geometry_info.sigma;
1012 (void) BrightnessContrastImage(*image,brightness,contrast,
1020 if (LocaleCompare("cdl",option+1) == 0)
1023 *color_correction_collection;
1026 Color correct with a color decision list.
1028 (void) SyncImageSettings(mogrify_info,*image,exception);
1029 color_correction_collection=FileToString(argv[i+1],~0,exception);
1030 if (color_correction_collection == (char *) NULL)
1032 (void) ColorDecisionListImage(*image,color_correction_collection,
1036 if (LocaleCompare("charcoal",option+1) == 0)
1041 (void) SyncImageSettings(mogrify_info,*image,exception);
1042 flags=ParseGeometry(argv[i+1],&geometry_info);
1043 if ((flags & SigmaValue) == 0)
1044 geometry_info.sigma=1.0;
1045 if ((flags & XiValue) == 0)
1046 geometry_info.xi=1.0;
1047 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1048 geometry_info.sigma,exception);
1051 if (LocaleCompare("chop",option+1) == 0)
1056 (void) SyncImageSettings(mogrify_info,*image,exception);
1057 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1058 mogrify_image=ChopImage(*image,&geometry,exception);
1061 if (LocaleCompare("clamp",option+1) == 0)
1066 (void) SyncImageSettings(mogrify_info,*image,exception);
1067 (void) ClampImage(*image,exception);
1070 if (LocaleCompare("clip",option+1) == 0)
1072 (void) SyncImageSettings(mogrify_info,*image,exception);
1075 (void) SetImageMask(*image,(Image *) NULL,exception);
1078 (void) ClipImage(*image,exception);
1081 if (LocaleCompare("clip-mask",option+1) == 0)
1098 (void) SyncImageSettings(mogrify_info,*image,exception);
1104 (void) SetImageMask(*image,(Image *) NULL,exception);
1109 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1111 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1112 if (mask_image == (Image *) NULL)
1114 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1115 return(MagickFalse);
1116 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1117 for (y=0; y < (ssize_t) mask_image->rows; y++)
1119 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1121 if (q == (Quantum *) NULL)
1123 for (x=0; x < (ssize_t) mask_image->columns; x++)
1125 if (mask_image->matte == MagickFalse)
1126 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1127 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1128 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1129 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1130 q+=GetPixelChannels(mask_image);
1132 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1135 mask_view=DestroyCacheView(mask_view);
1136 mask_image->matte=MagickTrue;
1137 (void) SetImageMask(*image,mask_image,exception);
1140 if (LocaleCompare("clip-path",option+1) == 0)
1142 (void) SyncImageSettings(mogrify_info,*image,exception);
1143 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1144 MagickFalse,exception);
1147 if (LocaleCompare("colorize",option+1) == 0)
1152 (void) SyncImageSettings(mogrify_info,*image,exception);
1153 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1156 if (LocaleCompare("color-matrix",option+1) == 0)
1161 (void) SyncImageSettings(mogrify_info,*image,exception);
1162 kernel=AcquireKernelInfo(argv[i+1]);
1163 if (kernel == (KernelInfo *) NULL)
1165 /* FUTURE: check on size of the matrix */
1166 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1167 kernel=DestroyKernelInfo(kernel);
1170 if (LocaleCompare("colors",option+1) == 0)
1173 Reduce the number of colors in the image.
1175 (void) SyncImageSettings(mogrify_info,*image,exception);
1176 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1177 if (quantize_info->number_colors == 0)
1179 if (((*image)->storage_class == DirectClass) ||
1180 (*image)->colors > quantize_info->number_colors)
1181 (void) QuantizeImage(quantize_info,*image,exception);
1183 (void) CompressImageColormap(*image,exception);
1186 if (LocaleCompare("colorspace",option+1) == 0)
1191 (void) SyncImageSettings(mogrify_info,*image,exception);
1194 (void) TransformImageColorspace(*image,sRGBColorspace,
1198 colorspace=(ColorspaceType) ParseCommandOption(
1199 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1200 (void) TransformImageColorspace(*image,colorspace,exception);
1203 if (LocaleCompare("compose",option+1) == 0)
1205 (void) SyncImageSettings(mogrify_info,*image,exception);
1206 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1207 MagickFalse,argv[i+1]);
1210 if (LocaleCompare("contrast",option+1) == 0)
1212 (void) SyncImageSettings(mogrify_info,*image,exception);
1213 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1214 MagickFalse,exception);
1217 if (LocaleCompare("contrast-stretch",option+1) == 0)
1227 Contrast stretch image.
1229 (void) SyncImageSettings(mogrify_info,*image,exception);
1230 flags=ParseGeometry(argv[i+1],&geometry_info);
1231 black_point=geometry_info.rho;
1232 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1234 if ((flags & PercentValue) != 0)
1236 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1237 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1239 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1241 (void) ContrastStretchImage(*image,black_point,white_point,
1245 if (LocaleCompare("convolve",option+1) == 0)
1250 (void) SyncImageSettings(mogrify_info,*image,exception);
1251 kernel_info=AcquireKernelInfo(argv[i+1]);
1252 if (kernel_info == (KernelInfo *) NULL)
1254 /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */
1255 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1256 kernel_info,exception);
1257 kernel_info=DestroyKernelInfo(kernel_info);
1260 if (LocaleCompare("crop",option+1) == 0)
1263 Crop a image to a smaller size
1265 (void) SyncImageSettings(mogrify_info,*image,exception);
1266 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1269 if (LocaleCompare("cycle",option+1) == 0)
1272 Cycle an image colormap.
1274 (void) SyncImageSettings(mogrify_info,*image,exception);
1275 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1283 if (LocaleCompare("decipher",option+1) == 0)
1291 (void) SyncImageSettings(mogrify_info,*image,exception);
1292 passkey=FileToStringInfo(argv[i+1],~0,exception);
1293 if (passkey != (StringInfo *) NULL)
1295 (void) PasskeyDecipherImage(*image,passkey,exception);
1296 passkey=DestroyStringInfo(passkey);
1300 if (LocaleCompare("density",option+1) == 0)
1305 (void) CloneString(&draw_info->density,argv[i+1]);
1308 if (LocaleCompare("depth",option+1) == 0)
1310 (void) SyncImageSettings(mogrify_info,*image,exception);
1313 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1316 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1320 if (LocaleCompare("deskew",option+1) == 0)
1326 Straighten the image.
1328 (void) SyncImageSettings(mogrify_info,*image,exception);
1330 threshold=40.0*QuantumRange/100.0;
1332 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1334 mogrify_image=DeskewImage(*image,threshold,exception);
1337 if (LocaleCompare("despeckle",option+1) == 0)
1340 Reduce the speckles within an image.
1342 (void) SyncImageSettings(mogrify_info,*image,exception);
1343 mogrify_image=DespeckleImage(*image,exception);
1346 if (LocaleCompare("display",option+1) == 0)
1348 (void) CloneString(&draw_info->server_name,argv[i+1]);
1351 if (LocaleCompare("distort",option+1) == 0)
1355 token[MaxTextExtent];
1375 (void) SyncImageSettings(mogrify_info,*image,exception);
1376 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1377 MagickFalse,argv[i+1]);
1378 if (method == ResizeDistortion)
1384 Special Case - Argument is actually a resize geometry!
1385 Convert that to an appropriate distortion argument array.
1387 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1389 resize_args[0]=(double) geometry.width;
1390 resize_args[1]=(double) geometry.height;
1391 mogrify_image=DistortImage(*image,method,(size_t)2,
1392 resize_args,MagickTrue,exception);
1395 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1397 if (args == (char *) NULL)
1400 for (x=0; *p != '\0'; x++)
1402 GetMagickToken(p,&p,token);
1404 GetMagickToken(p,&p,token);
1406 number_arguments=(size_t) x;
1407 arguments=(double *) AcquireQuantumMemory(number_arguments,
1408 sizeof(*arguments));
1409 if (arguments == (double *) NULL)
1410 ThrowWandFatalException(ResourceLimitFatalError,
1411 "MemoryAllocationFailed",(*image)->filename);
1412 (void) ResetMagickMemory(arguments,0,number_arguments*
1413 sizeof(*arguments));
1415 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1417 GetMagickToken(p,&p,token);
1419 GetMagickToken(p,&p,token);
1420 arguments[x]=StringToDouble(token,(char **) NULL);
1422 args=DestroyString(args);
1423 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1424 (*option == '+') ? MagickTrue : MagickFalse,exception);
1425 arguments=(double *) RelinquishMagickMemory(arguments);
1428 if (LocaleCompare("dither",option+1) == 0)
1432 quantize_info->dither=MagickFalse;
1435 quantize_info->dither=MagickTrue;
1436 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1437 MagickDitherOptions,MagickFalse,argv[i+1]);
1438 if (quantize_info->dither_method == NoDitherMethod)
1439 quantize_info->dither=MagickFalse;
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 if ((flags & SigmaValue) == 0)
1464 geometry_info.sigma=1.0;
1465 mogrify_image=EdgeImage(*image,geometry_info.rho,
1466 geometry_info.sigma,exception);
1469 if (LocaleCompare("emboss",option+1) == 0)
1474 (void) SyncImageSettings(mogrify_info,*image,exception);
1475 flags=ParseGeometry(argv[i+1],&geometry_info);
1476 if ((flags & SigmaValue) == 0)
1477 geometry_info.sigma=1.0;
1478 mogrify_image=EmbossImage(*image,geometry_info.rho,
1479 geometry_info.sigma,exception);
1482 if (LocaleCompare("encipher",option+1) == 0)
1490 (void) SyncImageSettings(mogrify_info,*image,exception);
1491 passkey=FileToStringInfo(argv[i+1],~0,exception);
1492 if (passkey != (StringInfo *) NULL)
1494 (void) PasskeyEncipherImage(*image,passkey,exception);
1495 passkey=DestroyStringInfo(passkey);
1499 if (LocaleCompare("encoding",option+1) == 0)
1501 (void) CloneString(&draw_info->encoding,argv[i+1]);
1504 if (LocaleCompare("enhance",option+1) == 0)
1509 (void) SyncImageSettings(mogrify_info,*image,exception);
1510 mogrify_image=EnhanceImage(*image,exception);
1513 if (LocaleCompare("equalize",option+1) == 0)
1518 (void) SyncImageSettings(mogrify_info,*image,exception);
1519 (void) EqualizeImage(*image,exception);
1522 if (LocaleCompare("evaluate",option+1) == 0)
1527 MagickEvaluateOperator
1530 (void) SyncImageSettings(mogrify_info,*image,exception);
1531 op=(MagickEvaluateOperator) ParseCommandOption(
1532 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1533 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1535 (void) EvaluateImage(*image,op,constant,exception);
1538 if (LocaleCompare("extent",option+1) == 0)
1541 Set the image extent.
1543 (void) SyncImageSettings(mogrify_info,*image,exception);
1544 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1545 if (geometry.width == 0)
1546 geometry.width=(*image)->columns;
1547 if (geometry.height == 0)
1548 geometry.height=(*image)->rows;
1549 mogrify_image=ExtentImage(*image,&geometry,exception);
1556 if (LocaleCompare("family",option+1) == 0)
1560 if (draw_info->family != (char *) NULL)
1561 draw_info->family=DestroyString(draw_info->family);
1564 (void) CloneString(&draw_info->family,argv[i+1]);
1567 if (LocaleCompare("features",option+1) == 0)
1571 (void) DeleteImageArtifact(*image,"identify:features");
1574 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1577 if (LocaleCompare("fill",option+1) == 0)
1585 GetPixelInfo(*image,&fill);
1588 (void) QueryColorCompliance("none",AllCompliance,&fill,
1590 draw_info->fill=fill;
1591 if (draw_info->fill_pattern != (Image *) NULL)
1592 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1595 sans=AcquireExceptionInfo();
1596 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1597 sans=DestroyExceptionInfo(sans);
1598 if (status == MagickFalse)
1599 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1602 draw_info->fill=fill=color;
1605 if (LocaleCompare("flip",option+1) == 0)
1608 Flip image scanlines.
1610 (void) SyncImageSettings(mogrify_info,*image,exception);
1611 mogrify_image=FlipImage(*image,exception);
1614 if (LocaleCompare("floodfill",option+1) == 0)
1622 (void) SyncImageSettings(mogrify_info,*image,exception);
1623 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1624 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1626 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1627 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1630 if (LocaleCompare("flop",option+1) == 0)
1633 Flop image scanlines.
1635 (void) SyncImageSettings(mogrify_info,*image,exception);
1636 mogrify_image=FlopImage(*image,exception);
1639 if (LocaleCompare("font",option+1) == 0)
1643 if (draw_info->font != (char *) NULL)
1644 draw_info->font=DestroyString(draw_info->font);
1647 (void) CloneString(&draw_info->font,argv[i+1]);
1650 if (LocaleCompare("format",option+1) == 0)
1655 if (LocaleCompare("frame",option+1) == 0)
1661 Surround image with an ornamental border.
1663 (void) SyncImageSettings(mogrify_info,*image,exception);
1664 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1665 frame_info.width=geometry.width;
1666 frame_info.height=geometry.height;
1667 if ((flags & HeightValue) == 0)
1668 frame_info.height=geometry.width;
1669 frame_info.outer_bevel=geometry.x;
1670 frame_info.inner_bevel=geometry.y;
1671 frame_info.x=(ssize_t) frame_info.width;
1672 frame_info.y=(ssize_t) frame_info.height;
1673 frame_info.width=(*image)->columns+2*frame_info.width;
1674 frame_info.height=(*image)->rows+2*frame_info.height;
1675 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1678 if (LocaleCompare("function",option+1) == 0)
1682 token[MaxTextExtent];
1700 Function Modify Image Values
1702 (void) SyncImageSettings(mogrify_info,*image,exception);
1703 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1704 MagickFalse,argv[i+1]);
1705 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1707 if (arguments == (char *) NULL)
1709 p=(char *) arguments;
1710 for (x=0; *p != '\0'; x++)
1712 GetMagickToken(p,&p,token);
1714 GetMagickToken(p,&p,token);
1716 number_parameters=(size_t) x;
1717 parameters=(double *) AcquireQuantumMemory(number_parameters,
1718 sizeof(*parameters));
1719 if (parameters == (double *) NULL)
1720 ThrowWandFatalException(ResourceLimitFatalError,
1721 "MemoryAllocationFailed",(*image)->filename);
1722 (void) ResetMagickMemory(parameters,0,number_parameters*
1723 sizeof(*parameters));
1724 p=(char *) arguments;
1725 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1727 GetMagickToken(p,&p,token);
1729 GetMagickToken(p,&p,token);
1730 parameters[x]=StringToDouble(token,(char **) NULL);
1732 arguments=DestroyString(arguments);
1733 (void) FunctionImage(*image,function,number_parameters,parameters,
1735 parameters=(double *) RelinquishMagickMemory(parameters);
1742 if (LocaleCompare("gamma",option+1) == 0)
1747 (void) SyncImageSettings(mogrify_info,*image,exception);
1749 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1751 (void) GammaImage(*image,StringToDouble(argv[i+1],
1752 (char **) NULL),exception);
1755 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1756 (LocaleCompare("gaussian",option+1) == 0))
1759 Gaussian blur image.
1761 (void) SyncImageSettings(mogrify_info,*image,exception);
1762 flags=ParseGeometry(argv[i+1],&geometry_info);
1763 if ((flags & SigmaValue) == 0)
1764 geometry_info.sigma=1.0;
1765 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1766 geometry_info.sigma,exception);
1769 if (LocaleCompare("geometry",option+1) == 0)
1772 Record Image offset, Resize last image.
1774 (void) SyncImageSettings(mogrify_info,*image,exception);
1777 if ((*image)->geometry != (char *) NULL)
1778 (*image)->geometry=DestroyString((*image)->geometry);
1781 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1782 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1783 (void) CloneString(&(*image)->geometry,argv[i+1]);
1785 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1786 (*image)->filter,exception);
1789 if (LocaleCompare("gravity",option+1) == 0)
1793 draw_info->gravity=UndefinedGravity;
1796 draw_info->gravity=(GravityType) ParseCommandOption(
1797 MagickGravityOptions,MagickFalse,argv[i+1]);
1804 if (LocaleCompare("highlight-color",option+1) == 0)
1806 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1813 if (LocaleCompare("identify",option+1) == 0)
1818 (void) SyncImageSettings(mogrify_info,*image,exception);
1819 if (format == (char *) NULL)
1821 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1825 text=InterpretImageProperties(mogrify_info,*image,format,
1827 if (text == (char *) NULL)
1829 (void) fputs(text,stdout);
1830 (void) fputc('\n',stdout);
1831 text=DestroyString(text);
1834 if (LocaleCompare("implode",option+1) == 0)
1839 (void) SyncImageSettings(mogrify_info,*image,exception);
1840 (void) ParseGeometry(argv[i+1],&geometry_info);
1841 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1842 interpolate_method,exception);
1845 if (LocaleCompare("interline-spacing",option+1) == 0)
1848 (void) ParseGeometry("0",&geometry_info);
1850 (void) ParseGeometry(argv[i+1],&geometry_info);
1851 draw_info->interline_spacing=geometry_info.rho;
1854 if (LocaleCompare("interpolate",option+1) == 0)
1856 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1857 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1860 if (LocaleCompare("interword-spacing",option+1) == 0)
1863 (void) ParseGeometry("0",&geometry_info);
1865 (void) ParseGeometry(argv[i+1],&geometry_info);
1866 draw_info->interword_spacing=geometry_info.rho;
1869 if (LocaleCompare("interpolative-resize",option+1) == 0)
1872 Interpolative resize image.
1874 (void) SyncImageSettings(mogrify_info,*image,exception);
1875 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1876 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1877 geometry.height,interpolate_method,exception);
1884 if (LocaleCompare("kerning",option+1) == 0)
1887 (void) ParseGeometry("0",&geometry_info);
1889 (void) ParseGeometry(argv[i+1],&geometry_info);
1890 draw_info->kerning=geometry_info.rho;
1897 if (LocaleCompare("lat",option+1) == 0)
1900 Local adaptive threshold image.
1902 (void) SyncImageSettings(mogrify_info,*image,exception);
1903 flags=ParseGeometry(argv[i+1],&geometry_info);
1904 if ((flags & PercentValue) != 0)
1905 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1906 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1907 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1908 geometry_info.xi,exception);
1911 if (LocaleCompare("level",option+1) == 0)
1924 (void) SyncImageSettings(mogrify_info,*image,exception);
1925 flags=ParseGeometry(argv[i+1],&geometry_info);
1926 black_point=geometry_info.rho;
1927 white_point=(MagickRealType) QuantumRange;
1928 if ((flags & SigmaValue) != 0)
1929 white_point=geometry_info.sigma;
1931 if ((flags & XiValue) != 0)
1932 gamma=geometry_info.xi;
1933 if ((flags & PercentValue) != 0)
1935 black_point*=(MagickRealType) (QuantumRange/100.0);
1936 white_point*=(MagickRealType) (QuantumRange/100.0);
1938 if ((flags & SigmaValue) == 0)
1939 white_point=(MagickRealType) QuantumRange-black_point;
1940 if ((*option == '+') || ((flags & AspectValue) != 0))
1941 (void) LevelizeImage(*image,black_point,white_point,gamma,
1944 (void) LevelImage(*image,black_point,white_point,gamma,
1948 if (LocaleCompare("level-colors",option+1) == 0)
1951 token[MaxTextExtent];
1960 p=(const char *) argv[i+1];
1961 GetMagickToken(p,&p,token); /* get black point color */
1962 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1963 (void) QueryColorCompliance(token,AllCompliance,
1964 &black_point,exception);
1966 (void) QueryColorCompliance("#000000",AllCompliance,
1967 &black_point,exception);
1968 if (isalpha((int) token[0]) || (token[0] == '#'))
1969 GetMagickToken(p,&p,token);
1971 white_point=black_point; /* set everything to that color */
1974 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1975 GetMagickToken(p,&p,token); /* Get white point color. */
1976 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1977 (void) QueryColorCompliance(token,AllCompliance,
1978 &white_point,exception);
1980 (void) QueryColorCompliance("#ffffff",AllCompliance,
1981 &white_point,exception);
1983 (void) LevelImageColors(*image,&black_point,&white_point,
1984 *option == '+' ? MagickTrue : MagickFalse,exception);
1987 if (LocaleCompare("linear-stretch",option+1) == 0)
1996 (void) SyncImageSettings(mogrify_info,*image,exception);
1997 flags=ParseGeometry(argv[i+1],&geometry_info);
1998 black_point=geometry_info.rho;
1999 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2000 if ((flags & SigmaValue) != 0)
2001 white_point=geometry_info.sigma;
2002 if ((flags & PercentValue) != 0)
2004 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2005 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2007 if ((flags & SigmaValue) == 0)
2008 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2010 (void) LinearStretchImage(*image,black_point,white_point,exception);
2013 if (LocaleCompare("liquid-rescale",option+1) == 0)
2016 Liquid rescale image.
2018 (void) SyncImageSettings(mogrify_info,*image,exception);
2019 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2020 if ((flags & XValue) == 0)
2022 if ((flags & YValue) == 0)
2024 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2025 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2028 if (LocaleCompare("lowlight-color",option+1) == 0)
2030 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2037 if (LocaleCompare("map",option+1) == 0)
2043 Transform image colors to match this set of colors.
2045 (void) SyncImageSettings(mogrify_info,*image,exception);
2048 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2049 if (remap_image == (Image *) NULL)
2051 (void) RemapImage(quantize_info,*image,remap_image,exception);
2052 remap_image=DestroyImage(remap_image);
2055 if (LocaleCompare("mask",option+1) == 0)
2060 (void) SyncImageSettings(mogrify_info,*image,exception);
2066 (void) SetImageMask(*image,(Image *) NULL,exception);
2072 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2073 if (mask == (Image *) NULL)
2075 (void) SetImageMask(*image,mask,exception);
2076 mask=DestroyImage(mask);
2079 if (LocaleCompare("matte",option+1) == 0)
2081 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2082 SetAlphaChannel : DeactivateAlphaChannel,exception);
2085 if (LocaleCompare("median",option+1) == 0)
2088 Median filter image.
2090 (void) SyncImageSettings(mogrify_info,*image,exception);
2091 flags=ParseGeometry(argv[i+1],&geometry_info);
2092 if ((flags & SigmaValue) == 0)
2093 geometry_info.sigma=geometry_info.rho;
2094 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2095 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2098 if (LocaleCompare("mode",option+1) == 0)
2103 (void) SyncImageSettings(mogrify_info,*image,exception);
2104 flags=ParseGeometry(argv[i+1],&geometry_info);
2105 if ((flags & SigmaValue) == 0)
2106 geometry_info.sigma=geometry_info.rho;
2107 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2108 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2111 if (LocaleCompare("modulate",option+1) == 0)
2113 (void) SyncImageSettings(mogrify_info,*image,exception);
2114 (void) ModulateImage(*image,argv[i+1],exception);
2117 if (LocaleCompare("monitor",option+1) == 0)
2121 (void) SetImageProgressMonitor(*image,
2122 (MagickProgressMonitor) NULL,(void *) NULL);
2125 (void) SetImageProgressMonitor(*image,MonitorProgress,
2129 if (LocaleCompare("monochrome",option+1) == 0)
2131 (void) SyncImageSettings(mogrify_info,*image,exception);
2132 (void) SetImageType(*image,BilevelType,exception);
2135 if (LocaleCompare("morphology",option+1) == 0)
2138 token[MaxTextExtent];
2153 Morphological Image Operation
2155 (void) SyncImageSettings(mogrify_info,*image,exception);
2157 GetMagickToken(p,&p,token);
2158 method=(MorphologyMethod) ParseCommandOption(
2159 MagickMorphologyOptions,MagickFalse,token);
2161 GetMagickToken(p,&p,token);
2162 if ((*p == ':') || (*p == ','))
2163 GetMagickToken(p,&p,token);
2165 iterations=(ssize_t) StringToLong(p);
2166 kernel=AcquireKernelInfo(argv[i+2]);
2167 if (kernel == (KernelInfo *) NULL)
2169 (void) ThrowMagickException(exception,GetMagickModule(),
2170 OptionError,"UnabletoParseKernel","morphology");
2174 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2176 kernel=DestroyKernelInfo(kernel);
2179 if (LocaleCompare("motion-blur",option+1) == 0)
2184 (void) SyncImageSettings(mogrify_info,*image,exception);
2185 flags=ParseGeometry(argv[i+1],&geometry_info);
2186 if ((flags & SigmaValue) == 0)
2187 geometry_info.sigma=1.0;
2188 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2189 geometry_info.sigma,geometry_info.xi,exception);
2196 if (LocaleCompare("negate",option+1) == 0)
2198 (void) SyncImageSettings(mogrify_info,*image,exception);
2199 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2200 MagickFalse,exception);
2203 if (LocaleCompare("noise",option+1) == 0)
2205 (void) SyncImageSettings(mogrify_info,*image,exception);
2208 flags=ParseGeometry(argv[i+1],&geometry_info);
2209 if ((flags & SigmaValue) == 0)
2210 geometry_info.sigma=geometry_info.rho;
2211 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2212 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2219 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2220 MagickFalse,argv[i+1]);
2221 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2225 if (LocaleCompare("normalize",option+1) == 0)
2227 (void) SyncImageSettings(mogrify_info,*image,exception);
2228 (void) NormalizeImage(*image,exception);
2235 if (LocaleCompare("opaque",option+1) == 0)
2240 (void) SyncImageSettings(mogrify_info,*image,exception);
2241 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2243 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2244 MagickFalse : MagickTrue,exception);
2247 if (LocaleCompare("ordered-dither",option+1) == 0)
2249 (void) SyncImageSettings(mogrify_info,*image,exception);
2250 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2257 if (LocaleCompare("paint",option+1) == 0)
2259 (void) SyncImageSettings(mogrify_info,*image,exception);
2260 (void) ParseGeometry(argv[i+1],&geometry_info);
2261 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2262 geometry_info.sigma,exception);
2265 if (LocaleCompare("pointsize",option+1) == 0)
2268 (void) ParseGeometry("12",&geometry_info);
2270 (void) ParseGeometry(argv[i+1],&geometry_info);
2271 draw_info->pointsize=geometry_info.rho;
2274 if (LocaleCompare("polaroid",option+1) == 0)
2286 Simulate a Polaroid picture.
2288 (void) SyncImageSettings(mogrify_info,*image,exception);
2289 random_info=AcquireRandomInfo();
2290 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2291 random_info=DestroyRandomInfo(random_info);
2294 SetGeometryInfo(&geometry_info);
2295 flags=ParseGeometry(argv[i+1],&geometry_info);
2296 angle=geometry_info.rho;
2298 caption=GetImageProperty(*image,"caption",exception);
2299 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2300 interpolate_method,exception);
2303 if (LocaleCompare("posterize",option+1) == 0)
2308 (void) SyncImageSettings(mogrify_info,*image,exception);
2309 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2310 quantize_info->dither,exception);
2313 if (LocaleCompare("preview",option+1) == 0)
2321 (void) SyncImageSettings(mogrify_info,*image,exception);
2323 preview_type=UndefinedPreview;
2325 preview_type=(PreviewType) ParseCommandOption(
2326 MagickPreviewOptions,MagickFalse,argv[i+1]);
2327 mogrify_image=PreviewImage(*image,preview_type,exception);
2330 if (LocaleCompare("profile",option+1) == 0)
2344 (void) SyncImageSettings(mogrify_info,*image,exception);
2348 Remove a profile from the image.
2350 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2355 Associate a profile with the image.
2357 profile_info=CloneImageInfo(mogrify_info);
2358 profile=GetImageProfile(*image,"iptc");
2359 if (profile != (StringInfo *) NULL)
2360 profile_info->profile=(void *) CloneStringInfo(profile);
2361 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2362 profile_info=DestroyImageInfo(profile_info);
2363 if (profile_image == (Image *) NULL)
2368 profile_info=CloneImageInfo(mogrify_info);
2369 (void) CopyMagickString(profile_info->filename,argv[i+1],
2371 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2372 if (profile != (StringInfo *) NULL)
2374 (void) ProfileImage(*image,profile_info->magick,
2375 GetStringInfoDatum(profile),(size_t)
2376 GetStringInfoLength(profile),exception);
2377 profile=DestroyStringInfo(profile);
2379 profile_info=DestroyImageInfo(profile_info);
2382 ResetImageProfileIterator(profile_image);
2383 name=GetNextImageProfile(profile_image);
2384 while (name != (const char *) NULL)
2386 profile=GetImageProfile(profile_image,name);
2387 if (profile != (StringInfo *) NULL)
2388 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2389 (size_t) GetStringInfoLength(profile),exception);
2390 name=GetNextImageProfile(profile_image);
2392 profile_image=DestroyImage(profile_image);
2399 if (LocaleCompare("quantize",option+1) == 0)
2403 quantize_info->colorspace=UndefinedColorspace;
2406 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2407 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2414 if (LocaleCompare("radial-blur",option+1) == 0)
2419 (void) SyncImageSettings(mogrify_info,*image,exception);
2420 flags=ParseGeometry(argv[i+1],&geometry_info);
2421 mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception);
2424 if (LocaleCompare("raise",option+1) == 0)
2427 Surround image with a raise of solid color.
2429 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2430 if ((flags & SigmaValue) == 0)
2431 geometry.height=geometry.width;
2432 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2433 MagickFalse,exception);
2436 if (LocaleCompare("random-threshold",option+1) == 0)
2441 (void) SyncImageSettings(mogrify_info,*image,exception);
2442 (void) RandomThresholdImage(*image,argv[i+1],exception);
2445 if (LocaleCompare("region",option+1) == 0)
2447 (void) SyncImageSettings(mogrify_info,*image,exception);
2448 if (region_image != (Image *) NULL)
2453 (void) CompositeImage(region_image,*image,region_image->matte !=
2454 MagickFalse ? CopyCompositeOp : OverCompositeOp,MagickTrue,
2455 region_geometry.x,region_geometry.y,exception);
2456 *image=DestroyImage(*image);
2457 *image=region_image;
2458 region_image = (Image *) NULL;
2463 Apply transformations to a selected region of the image.
2465 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2467 mogrify_image=CropImage(*image,®ion_geometry,exception);
2468 if (mogrify_image == (Image *) NULL)
2470 region_image=(*image);
2471 *image=mogrify_image;
2472 mogrify_image=(Image *) NULL;
2475 if (LocaleCompare("render",option+1) == 0)
2477 (void) SyncImageSettings(mogrify_info,*image,exception);
2478 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2481 if (LocaleCompare("remap",option+1) == 0)
2487 Transform image colors to match this set of colors.
2489 (void) SyncImageSettings(mogrify_info,*image,exception);
2492 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2493 if (remap_image == (Image *) NULL)
2495 (void) RemapImage(quantize_info,*image,remap_image,exception);
2496 remap_image=DestroyImage(remap_image);
2499 if (LocaleCompare("repage",option+1) == 0)
2503 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2506 (void) ResetImagePage(*image,argv[i+1]);
2509 if (LocaleCompare("resample",option+1) == 0)
2514 (void) SyncImageSettings(mogrify_info,*image,exception);
2515 flags=ParseGeometry(argv[i+1],&geometry_info);
2516 if ((flags & SigmaValue) == 0)
2517 geometry_info.sigma=geometry_info.rho;
2518 mogrify_image=ResampleImage(*image,geometry_info.rho,
2519 geometry_info.sigma,(*image)->filter,exception);
2522 if (LocaleCompare("resize",option+1) == 0)
2527 (void) SyncImageSettings(mogrify_info,*image,exception);
2528 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2529 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2530 (*image)->filter,exception);
2533 if (LocaleCompare("roll",option+1) == 0)
2538 (void) SyncImageSettings(mogrify_info,*image,exception);
2539 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2540 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2543 if (LocaleCompare("rotate",option+1) == 0)
2549 Check for conditional image rotation.
2551 (void) SyncImageSettings(mogrify_info,*image,exception);
2552 if (strchr(argv[i+1],'>') != (char *) NULL)
2553 if ((*image)->columns <= (*image)->rows)
2555 if (strchr(argv[i+1],'<') != (char *) NULL)
2556 if ((*image)->columns >= (*image)->rows)
2561 geometry=ConstantString(argv[i+1]);
2562 (void) SubstituteString(&geometry,">","");
2563 (void) SubstituteString(&geometry,"<","");
2564 (void) ParseGeometry(geometry,&geometry_info);
2565 geometry=DestroyString(geometry);
2566 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2573 if (LocaleCompare("sample",option+1) == 0)
2576 Sample image with pixel replication.
2578 (void) SyncImageSettings(mogrify_info,*image,exception);
2579 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2580 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2584 if (LocaleCompare("scale",option+1) == 0)
2589 (void) SyncImageSettings(mogrify_info,*image,exception);
2590 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2591 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2595 if (LocaleCompare("selective-blur",option+1) == 0)
2598 Selectively blur pixels within a contrast threshold.
2600 (void) SyncImageSettings(mogrify_info,*image,exception);
2601 flags=ParseGeometry(argv[i+1],&geometry_info);
2602 if ((flags & PercentValue) != 0)
2603 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2604 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2605 geometry_info.sigma,geometry_info.xi,exception);
2608 if (LocaleCompare("separate",option+1) == 0)
2611 Break channels into separate images.
2613 (void) SyncImageSettings(mogrify_info,*image,exception);
2614 mogrify_image=SeparateImages(*image,exception);
2617 if (LocaleCompare("sepia-tone",option+1) == 0)
2625 (void) SyncImageSettings(mogrify_info,*image,exception);
2626 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2628 mogrify_image=SepiaToneImage(*image,threshold,exception);
2631 if (LocaleCompare("segment",option+1) == 0)
2636 (void) SyncImageSettings(mogrify_info,*image,exception);
2637 flags=ParseGeometry(argv[i+1],&geometry_info);
2638 if ((flags & SigmaValue) == 0)
2639 geometry_info.sigma=1.0;
2640 (void) SegmentImage(*image,(*image)->colorspace,
2641 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2645 if (LocaleCompare("set",option+1) == 0)
2655 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2656 (void) DeleteImageRegistry(argv[i+1]+9);
2658 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2660 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2661 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2664 (void) DeleteImageProperty(*image,argv[i+1]);
2667 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2669 if (value == (char *) NULL)
2671 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2672 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2675 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2677 (void) SetImageOption(image_info,argv[i+1]+7,value);
2678 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2679 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2682 (void) SetImageProperty(*image,argv[i+1],value,exception);
2683 value=DestroyString(value);
2686 if (LocaleCompare("shade",option+1) == 0)
2691 (void) SyncImageSettings(mogrify_info,*image,exception);
2692 flags=ParseGeometry(argv[i+1],&geometry_info);
2693 if ((flags & SigmaValue) == 0)
2694 geometry_info.sigma=1.0;
2695 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2696 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2699 if (LocaleCompare("shadow",option+1) == 0)
2704 (void) SyncImageSettings(mogrify_info,*image,exception);
2705 flags=ParseGeometry(argv[i+1],&geometry_info);
2706 if ((flags & SigmaValue) == 0)
2707 geometry_info.sigma=1.0;
2708 if ((flags & XiValue) == 0)
2709 geometry_info.xi=4.0;
2710 if ((flags & PsiValue) == 0)
2711 geometry_info.psi=4.0;
2712 mogrify_image=ShadowImage(*image,geometry_info.rho,
2713 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2714 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2717 if (LocaleCompare("sharpen",option+1) == 0)
2722 (void) SyncImageSettings(mogrify_info,*image,exception);
2723 flags=ParseGeometry(argv[i+1],&geometry_info);
2724 if ((flags & SigmaValue) == 0)
2725 geometry_info.sigma=1.0;
2726 if ((flags & XiValue) == 0)
2727 geometry_info.xi=0.0;
2728 mogrify_image=SharpenImage(*image,geometry_info.rho,
2729 geometry_info.sigma,exception);
2732 if (LocaleCompare("shave",option+1) == 0)
2735 Shave the image edges.
2737 (void) SyncImageSettings(mogrify_info,*image,exception);
2738 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2739 mogrify_image=ShaveImage(*image,&geometry,exception);
2742 if (LocaleCompare("shear",option+1) == 0)
2747 (void) SyncImageSettings(mogrify_info,*image,exception);
2748 flags=ParseGeometry(argv[i+1],&geometry_info);
2749 if ((flags & SigmaValue) == 0)
2750 geometry_info.sigma=geometry_info.rho;
2751 mogrify_image=ShearImage(*image,geometry_info.rho,
2752 geometry_info.sigma,exception);
2755 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2758 Sigmoidal non-linearity contrast control.
2760 (void) SyncImageSettings(mogrify_info,*image,exception);
2761 flags=ParseGeometry(argv[i+1],&geometry_info);
2762 if ((flags & SigmaValue) == 0)
2763 geometry_info.sigma=(double) QuantumRange/2.0;
2764 if ((flags & PercentValue) != 0)
2765 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2767 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2768 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2772 if (LocaleCompare("sketch",option+1) == 0)
2777 (void) SyncImageSettings(mogrify_info,*image,exception);
2778 flags=ParseGeometry(argv[i+1],&geometry_info);
2779 if ((flags & SigmaValue) == 0)
2780 geometry_info.sigma=1.0;
2781 mogrify_image=SketchImage(*image,geometry_info.rho,
2782 geometry_info.sigma,geometry_info.xi,exception);
2785 if (LocaleCompare("solarize",option+1) == 0)
2790 (void) SyncImageSettings(mogrify_info,*image,exception);
2791 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2793 (void) SolarizeImage(*image,threshold,exception);
2796 if (LocaleCompare("sparse-color",option+1) == 0)
2805 Sparse Color Interpolated Gradient
2807 (void) SyncImageSettings(mogrify_info,*image,exception);
2808 method=(SparseColorMethod) ParseCommandOption(
2809 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2810 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2812 if (arguments == (char *) NULL)
2814 mogrify_image=SparseColorOption(*image,method,arguments,
2815 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2816 arguments=DestroyString(arguments);
2819 if (LocaleCompare("splice",option+1) == 0)
2822 Splice a solid color into the image.
2824 (void) SyncImageSettings(mogrify_info,*image,exception);
2825 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2826 mogrify_image=SpliceImage(*image,&geometry,exception);
2829 if (LocaleCompare("spread",option+1) == 0)
2834 (void) SyncImageSettings(mogrify_info,*image,exception);
2835 (void) ParseGeometry(argv[i+1],&geometry_info);
2836 mogrify_image=SpreadImage(*image,geometry_info.rho,
2837 interpolate_method,exception);
2840 if (LocaleCompare("statistic",option+1) == 0)
2845 (void) SyncImageSettings(mogrify_info,*image,exception);
2846 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2847 MagickFalse,argv[i+1]);
2848 (void) ParseGeometry(argv[i+2],&geometry_info);
2849 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2850 (size_t) geometry_info.sigma,exception);
2853 if (LocaleCompare("stretch",option+1) == 0)
2857 draw_info->stretch=UndefinedStretch;
2860 draw_info->stretch=(StretchType) ParseCommandOption(
2861 MagickStretchOptions,MagickFalse,argv[i+1]);
2864 if (LocaleCompare("strip",option+1) == 0)
2867 Strip image of profiles and comments.
2869 (void) SyncImageSettings(mogrify_info,*image,exception);
2870 (void) StripImage(*image,exception);
2873 if (LocaleCompare("stroke",option+1) == 0)
2883 (void) QueryColorCompliance("none",AllCompliance,
2884 &draw_info->stroke,exception);
2885 if (draw_info->stroke_pattern != (Image *) NULL)
2886 draw_info->stroke_pattern=DestroyImage(
2887 draw_info->stroke_pattern);
2890 sans=AcquireExceptionInfo();
2891 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2892 sans=DestroyExceptionInfo(sans);
2893 if (status == MagickFalse)
2894 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2897 draw_info->stroke=color;
2900 if (LocaleCompare("strokewidth",option+1) == 0)
2902 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2905 if (LocaleCompare("style",option+1) == 0)
2909 draw_info->style=UndefinedStyle;
2912 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2913 MagickFalse,argv[i+1]);
2916 if (LocaleCompare("swirl",option+1) == 0)
2921 (void) SyncImageSettings(mogrify_info,*image,exception);
2922 (void) ParseGeometry(argv[i+1],&geometry_info);
2923 mogrify_image=SwirlImage(*image,geometry_info.rho,
2924 interpolate_method,exception);
2931 if (LocaleCompare("threshold",option+1) == 0)
2939 (void) SyncImageSettings(mogrify_info,*image,exception);
2941 threshold=(double) QuantumRange/2;
2943 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2945 (void) BilevelImage(*image,threshold,exception);
2948 if (LocaleCompare("thumbnail",option+1) == 0)
2953 (void) SyncImageSettings(mogrify_info,*image,exception);
2954 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2955 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2959 if (LocaleCompare("tile",option+1) == 0)
2963 if (draw_info->fill_pattern != (Image *) NULL)
2964 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2967 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2971 if (LocaleCompare("tint",option+1) == 0)
2976 (void) SyncImageSettings(mogrify_info,*image,exception);
2977 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
2980 if (LocaleCompare("transform",option+1) == 0)
2983 Affine transform image.
2985 (void) SyncImageSettings(mogrify_info,*image,exception);
2986 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2990 if (LocaleCompare("transparent",option+1) == 0)
2995 (void) SyncImageSettings(mogrify_info,*image,exception);
2996 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2998 (void) TransparentPaintImage(*image,&target,(Quantum)
2999 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3003 if (LocaleCompare("transpose",option+1) == 0)
3006 Transpose image scanlines.
3008 (void) SyncImageSettings(mogrify_info,*image,exception);
3009 mogrify_image=TransposeImage(*image,exception);
3012 if (LocaleCompare("transverse",option+1) == 0)
3015 Transverse image scanlines.
3017 (void) SyncImageSettings(mogrify_info,*image,exception);
3018 mogrify_image=TransverseImage(*image,exception);
3021 if (LocaleCompare("treedepth",option+1) == 0)
3023 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3026 if (LocaleCompare("trim",option+1) == 0)
3031 (void) SyncImageSettings(mogrify_info,*image,exception);
3032 mogrify_image=TrimImage(*image,exception);
3035 if (LocaleCompare("type",option+1) == 0)
3040 (void) SyncImageSettings(mogrify_info,*image,exception);
3044 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3046 (*image)->type=UndefinedType;
3047 (void) SetImageType(*image,type,exception);
3054 if (LocaleCompare("undercolor",option+1) == 0)
3056 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3057 &draw_info->undercolor,exception);
3060 if (LocaleCompare("unique",option+1) == 0)
3064 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3067 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3068 (void) SetImageArtifact(*image,"verbose","true");
3071 if (LocaleCompare("unique-colors",option+1) == 0)
3074 Unique image colors.
3076 (void) SyncImageSettings(mogrify_info,*image,exception);
3077 mogrify_image=UniqueImageColors(*image,exception);
3080 if (LocaleCompare("unsharp",option+1) == 0)
3085 (void) SyncImageSettings(mogrify_info,*image,exception);
3086 flags=ParseGeometry(argv[i+1],&geometry_info);
3087 if ((flags & SigmaValue) == 0)
3088 geometry_info.sigma=1.0;
3089 if ((flags & XiValue) == 0)
3090 geometry_info.xi=1.0;
3091 if ((flags & PsiValue) == 0)
3092 geometry_info.psi=0.05;
3093 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3094 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3101 if (LocaleCompare("verbose",option+1) == 0)
3103 (void) SetImageArtifact(*image,option+1,
3104 *option == '+' ? "false" : "true");
3107 if (LocaleCompare("vignette",option+1) == 0)
3112 (void) SyncImageSettings(mogrify_info,*image,exception);
3113 flags=ParseGeometry(argv[i+1],&geometry_info);
3114 if ((flags & SigmaValue) == 0)
3115 geometry_info.sigma=1.0;
3116 if ((flags & XiValue) == 0)
3117 geometry_info.xi=0.1*(*image)->columns;
3118 if ((flags & PsiValue) == 0)
3119 geometry_info.psi=0.1*(*image)->rows;
3120 mogrify_image=VignetteImage(*image,geometry_info.rho,
3121 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3122 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3125 if (LocaleCompare("virtual-pixel",option+1) == 0)
3129 (void) SetImageVirtualPixelMethod(*image,
3130 UndefinedVirtualPixelMethod,exception);
3133 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3134 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3135 argv[i+1]),exception);
3142 if (LocaleCompare("wave",option+1) == 0)
3147 (void) SyncImageSettings(mogrify_info,*image,exception);
3148 flags=ParseGeometry(argv[i+1],&geometry_info);
3149 if ((flags & SigmaValue) == 0)
3150 geometry_info.sigma=1.0;
3151 mogrify_image=WaveImage(*image,geometry_info.rho,
3152 geometry_info.sigma,interpolate_method,exception);
3155 if (LocaleCompare("weight",option+1) == 0)
3157 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3158 if (LocaleCompare(argv[i+1],"all") == 0)
3159 draw_info->weight=0;
3160 if (LocaleCompare(argv[i+1],"bold") == 0)
3161 draw_info->weight=700;
3162 if (LocaleCompare(argv[i+1],"bolder") == 0)
3163 if (draw_info->weight <= 800)
3164 draw_info->weight+=100;
3165 if (LocaleCompare(argv[i+1],"lighter") == 0)
3166 if (draw_info->weight >= 100)
3167 draw_info->weight-=100;
3168 if (LocaleCompare(argv[i+1],"normal") == 0)
3169 draw_info->weight=400;
3172 if (LocaleCompare("white-threshold",option+1) == 0)
3175 White threshold image.
3177 (void) SyncImageSettings(mogrify_info,*image,exception);
3178 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3187 Replace current image with any image that was generated
3189 if (mogrify_image != (Image *) NULL)
3190 ReplaceImageInListReturnLast(image,mogrify_image);
3193 if (region_image != (Image *) NULL)
3196 Composite transformed region onto image.
3198 (void) SyncImageSettings(mogrify_info,*image,exception);
3199 (void) CompositeImage(region_image,*image,region_image->matte !=
3200 MagickFalse ? CopyCompositeOp : OverCompositeOp,MagickTrue,
3201 region_geometry.x,region_geometry.y,exception);
3202 *image=DestroyImage(*image);
3203 *image=region_image;
3204 region_image = (Image *) NULL;
3209 quantize_info=DestroyQuantizeInfo(quantize_info);
3210 draw_info=DestroyDrawInfo(draw_info);
3211 mogrify_info=DestroyImageInfo(mogrify_info);
3212 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3213 return(status == 0 ? MagickFalse : MagickTrue);
3217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3221 + M o g r i f y I m a g e C o m m a n d %
3225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3227 % MogrifyImageCommand() transforms an image or a sequence of images. These
3228 % transforms include image scaling, image rotation, color reduction, and
3229 % others. The transmogrified image overwrites the original image.
3231 % The format of the MogrifyImageCommand method is:
3233 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3234 % const char **argv,char **metadata,ExceptionInfo *exception)
3236 % A description of each parameter follows:
3238 % o image_info: the image info.
3240 % o argc: the number of elements in the argument vector.
3242 % o argv: A text array containing the command line arguments.
3244 % o metadata: any metadata is returned here.
3246 % o exception: return any errors or warnings in this structure.
3250 static MagickBooleanType MogrifyUsage(void)
3253 *channel_operators[]=
3255 "-channel-fx expression",
3256 " exchange, extract, or transfer one or more image channels",
3257 "-separate separate an image channel into a grayscale image",
3262 "-debug events display copious debugging information",
3263 "-help print program options",
3264 "-list type print a list of supported option arguments",
3265 "-log format format of debugging information",
3266 "-version print version information",
3271 "-adaptive-blur geometry",
3272 " adaptively blur pixels; decrease effect near edges",
3273 "-adaptive-resize geometry",
3274 " adaptively resize image using 'mesh' interpolation",
3275 "-adaptive-sharpen geometry",
3276 " adaptively sharpen pixels; increase effect near edges",
3277 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3278 " transparent, extract, background, or shape",
3279 "-annotate geometry text",
3280 " annotate the image with text",
3281 "-auto-gamma automagically adjust gamma level of image",
3282 "-auto-level automagically adjust color levels of image",
3283 "-auto-orient automagically orient (rotate) image",
3284 "-bench iterations measure performance",
3285 "-black-threshold value",
3286 " force all pixels below the threshold into black",
3287 "-blue-shift simulate a scene at nighttime in the moonlight",
3288 "-blur geometry reduce image noise and reduce detail levels",
3289 "-border geometry surround image with a border of color",
3290 "-bordercolor color border color",
3291 "-brightness-contrast geometry",
3292 " improve brightness / contrast of the image",
3293 "-cdl filename color correct with a color decision list",
3294 "-charcoal geometry simulate a charcoal drawing",
3295 "-chop geometry remove pixels from the image interior",
3296 "-clamp restrict pixel range from 0 to the quantum depth",
3297 "-clip clip along the first path from the 8BIM profile",
3298 "-clip-mask filename associate a clip mask with the image",
3299 "-clip-path id clip along a named path from the 8BIM profile",
3300 "-colorize value colorize the image with the fill color",
3301 "-color-matrix matrix apply color correction to the image",
3302 "-contrast enhance or reduce the image contrast",
3303 "-contrast-stretch geometry",
3304 " improve contrast by 'stretching' the intensity range",
3305 "-convolve coefficients",
3306 " apply a convolution kernel to the image",
3307 "-cycle amount cycle the image colormap",
3308 "-decipher filename convert cipher pixels to plain pixels",
3309 "-deskew threshold straighten an image",
3310 "-despeckle reduce the speckles within an image",
3311 "-distort method args",
3312 " distort images according to given method ad args",
3313 "-draw string annotate the image with a graphic primitive",
3314 "-edge radius apply a filter to detect edges in the image",
3315 "-encipher filename convert plain pixels to cipher pixels",
3316 "-emboss radius emboss an image",
3317 "-enhance apply a digital filter to enhance a noisy image",
3318 "-equalize perform histogram equalization to an image",
3319 "-evaluate operator value",
3320 " evaluate an arithmetic, relational, or logical expression",
3321 "-extent geometry set the image size",
3322 "-extract geometry extract area from image",
3323 "-fft implements the discrete Fourier transform (DFT)",
3324 "-flip flip image vertically",
3325 "-floodfill geometry color",
3326 " floodfill the image with color",
3327 "-flop flop image horizontally",
3328 "-frame geometry surround image with an ornamental border",
3329 "-function name parameters",
3330 " apply function over image values",
3331 "-gamma value level of gamma correction",
3332 "-gaussian-blur geometry",
3333 " reduce image noise and reduce detail levels",
3334 "-geometry geometry preferred size or location of the image",
3335 "-identify identify the format and characteristics of the image",
3336 "-ift implements the inverse discrete Fourier transform (DFT)",
3337 "-implode amount implode image pixels about the center",
3338 "-interpolative-resize geometry",
3339 " resize image using interpolation",
3340 "-lat geometry local adaptive thresholding",
3341 "-layers method optimize, merge, or compare image layers",
3342 "-level value adjust the level of image contrast",
3343 "-level-colors color,color",
3344 " level image with the given colors",
3345 "-linear-stretch geometry",
3346 " improve contrast by 'stretching with saturation'",
3347 "-liquid-rescale geometry",
3348 " rescale image with seam-carving",
3349 "-median geometry apply a median filter to the image",
3350 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3351 "-modulate value vary the brightness, saturation, and hue",
3352 "-monochrome transform image to black and white",
3353 "-morphology method kernel",
3354 " apply a morphology method to the image",
3355 "-motion-blur geometry",
3356 " simulate motion blur",
3357 "-negate replace every pixel with its complementary color ",
3358 "-noise geometry add or reduce noise in an image",
3359 "-normalize transform image to span the full range of colors",
3360 "-opaque color change this color to the fill color",
3361 "-ordered-dither NxN",
3362 " add a noise pattern to the image with specific",
3364 "-paint radius simulate an oil painting",
3365 "-polaroid angle simulate a Polaroid picture",
3366 "-posterize levels reduce the image to a limited number of color levels",
3367 "-profile filename add, delete, or apply an image profile",
3368 "-quantize colorspace reduce colors in this colorspace",
3369 "-radial-blur angle radial blur the image",
3370 "-raise value lighten/darken image edges to create a 3-D effect",
3371 "-random-threshold low,high",
3372 " random threshold the image",
3373 "-region geometry apply options to a portion of the image",
3374 "-render render vector graphics",
3375 "-repage geometry size and location of an image canvas",
3376 "-resample geometry change the resolution of an image",
3377 "-resize geometry resize the image",
3378 "-roll geometry roll an image vertically or horizontally",
3379 "-rotate degrees apply Paeth rotation to the image",
3380 "-sample geometry scale image with pixel sampling",
3381 "-scale geometry scale the image",
3382 "-segment values segment an image",
3383 "-selective-blur geometry",
3384 " selectively blur pixels within a contrast threshold",
3385 "-sepia-tone threshold",
3386 " simulate a sepia-toned photo",
3387 "-set property value set an image property",
3388 "-shade degrees shade the image using a distant light source",
3389 "-shadow geometry simulate an image shadow",
3390 "-sharpen geometry sharpen the image",
3391 "-shave geometry shave pixels from the image edges",
3392 "-shear geometry slide one edge of the image along the X or Y axis",
3393 "-sigmoidal-contrast geometry",
3394 " increase the contrast without saturating highlights or shadows",
3395 "-sketch geometry simulate a pencil sketch",
3396 "-solarize threshold negate all pixels above the threshold level",
3397 "-sparse-color method args",
3398 " fill in a image based on a few color points",
3399 "-splice geometry splice the background color into the image",
3400 "-spread radius displace image pixels by a random amount",
3401 "-statistic type radius",
3402 " replace each pixel with corresponding statistic from the neighborhood",
3403 "-strip strip image of all profiles and comments",
3404 "-swirl degrees swirl image pixels about the center",
3405 "-threshold value threshold the image",
3406 "-thumbnail geometry create a thumbnail of the image",
3407 "-tile filename tile image when filling a graphic primitive",
3408 "-tint value tint the image with the fill color",
3409 "-transform affine transform image",
3410 "-transparent color make this color transparent within the image",
3411 "-transpose flip image vertically and rotate 90 degrees",
3412 "-transverse flop image horizontally and rotate 270 degrees",
3413 "-trim trim image edges",
3414 "-type type image type",
3415 "-unique-colors discard all but one of any pixel color",
3416 "-unsharp geometry sharpen the image",
3417 "-vignette geometry soften the edges of the image in vignette style",
3418 "-wave geometry alter an image along a sine wave",
3419 "-white-threshold value",
3420 " force all pixels above the threshold into white",
3423 *sequence_operators[]=
3425 "-append append an image sequence",
3426 "-clut apply a color lookup table to the image",
3427 "-coalesce merge a sequence of images",
3428 "-combine combine a sequence of images",
3429 "-composite composite image",
3430 "-crop geometry cut out a rectangular region of the image",
3431 "-deconstruct break down an image sequence into constituent parts",
3432 "-evaluate-sequence operator",
3433 " evaluate an arithmetic, relational, or logical expression",
3434 "-flatten flatten a sequence of images",
3435 "-fx expression apply mathematical expression to an image channel(s)",
3436 "-hald-clut apply a Hald color lookup table to the image",
3437 "-morph value morph an image sequence",
3438 "-mosaic create a mosaic from an image sequence",
3439 "-print string interpret string and print to console",
3440 "-process arguments process the image with a custom image filter",
3441 "-smush geometry smush an image sequence together",
3442 "-write filename write images to this file",
3447 "-adjoin join images into a single multi-image file",
3448 "-affine matrix affine transform matrix",
3449 "-alpha option activate, deactivate, reset, or set the alpha channel",
3450 "-antialias remove pixel-aliasing",
3451 "-authenticate password",
3452 " decipher image with this password",
3453 "-attenuate value lessen (or intensify) when adding noise to an image",
3454 "-background color background color",
3455 "-bias value add bias when convolving an image",
3456 "-black-point-compensation",
3457 " use black point compensation",
3458 "-blue-primary point chromaticity blue primary point",
3459 "-bordercolor color border color",
3460 "-caption string assign a caption to an image",
3461 "-channel type apply option to select image channels",
3462 "-colors value preferred number of colors in the image",
3463 "-colorspace type alternate image colorspace",
3464 "-comment string annotate image with comment",
3465 "-compose operator set image composite operator",
3466 "-compress type type of pixel compression when writing the image",
3467 "-define format:option=value",
3468 " define one or more image format options",
3469 "-delay value display the next image after pausing",
3470 "-density geometry horizontal and vertical density of the image",
3471 "-depth value image depth",
3472 "-direction type render text right-to-left or left-to-right",
3473 "-display server get image or font from this X server",
3474 "-dispose method layer disposal method",
3475 "-dither method apply error diffusion to image",
3476 "-encoding type text encoding type",
3477 "-endian type endianness (MSB or LSB) of the image",
3478 "-family name render text with this font family",
3479 "-fill color color to use when filling a graphic primitive",
3480 "-filter type use this filter when resizing an image",
3481 "-font name render text with this font",
3482 "-format \"string\" output formatted image characteristics",
3483 "-fuzz distance colors within this distance are considered equal",
3484 "-gravity type horizontal and vertical text placement",
3485 "-green-primary point chromaticity green primary point",
3486 "-intent type type of rendering intent when managing the image color",
3487 "-interlace type type of image interlacing scheme",
3488 "-interline-spacing value",
3489 " set the space between two text lines",
3490 "-interpolate method pixel color interpolation method",
3491 "-interword-spacing value",
3492 " set the space between two words",
3493 "-kerning value set the space between two letters",
3494 "-label string assign a label to an image",
3495 "-limit type value pixel cache resource limit",
3496 "-loop iterations add Netscape loop extension to your GIF animation",
3497 "-mask filename associate a mask with the image",
3498 "-mattecolor color frame color",
3499 "-monitor monitor progress",
3500 "-orient type image orientation",
3501 "-page geometry size and location of an image canvas (setting)",
3502 "-ping efficiently determine image attributes",
3503 "-pointsize value font point size",
3504 "-precision value maximum number of significant digits to print",
3505 "-preview type image preview type",
3506 "-quality value JPEG/MIFF/PNG compression level",
3507 "-quiet suppress all warning messages",
3508 "-red-primary point chromaticity red primary point",
3509 "-regard-warnings pay attention to warning messages",
3510 "-remap filename transform image colors to match this set of colors",
3511 "-respect-parentheses settings remain in effect until parenthesis boundary",
3512 "-sampling-factor geometry",
3513 " horizontal and vertical sampling factor",
3514 "-scene value image scene number",
3515 "-seed value seed a new sequence of pseudo-random numbers",
3516 "-size geometry width and height of image",
3517 "-stretch type render text with this font stretch",
3518 "-stroke color graphic primitive stroke color",
3519 "-strokewidth value graphic primitive stroke width",
3520 "-style type render text with this font style",
3521 "-synchronize synchronize image to storage device",
3522 "-taint declare the image as modified",
3523 "-texture filename name of texture to tile onto the image background",
3524 "-tile-offset geometry",
3526 "-treedepth value color tree depth",
3527 "-transparent-color color",
3528 " transparent color",
3529 "-undercolor color annotation bounding box color",
3530 "-units type the units of image resolution",
3531 "-verbose print detailed information about the image",
3532 "-view FlashPix viewing transforms",
3533 "-virtual-pixel method",
3534 " virtual pixel access method",
3535 "-weight type render text with this font weight",
3536 "-white-point point chromaticity white point",
3541 "-delete indexes delete the image from the image sequence",
3542 "-duplicate count,indexes",
3543 " duplicate an image one or more times",
3544 "-insert index insert last image into the image sequence",
3545 "-reverse reverse image sequence",
3546 "-swap indexes swap two images in the image sequence",
3553 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3554 (void) printf("Copyright: %s\n",GetMagickCopyright());
3555 (void) printf("Features: %s\n\n",GetMagickFeatures());
3556 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3558 (void) printf("\nImage Settings:\n");
3559 for (p=settings; *p != (char *) NULL; p++)
3560 (void) printf(" %s\n",*p);
3561 (void) printf("\nImage Operators:\n");
3562 for (p=operators; *p != (char *) NULL; p++)
3563 (void) printf(" %s\n",*p);
3564 (void) printf("\nImage Channel Operators:\n");
3565 for (p=channel_operators; *p != (char *) NULL; p++)
3566 (void) printf(" %s\n",*p);
3567 (void) printf("\nImage Sequence Operators:\n");
3568 for (p=sequence_operators; *p != (char *) NULL; p++)
3569 (void) printf(" %s\n",*p);
3570 (void) printf("\nImage Stack Operators:\n");
3571 for (p=stack_operators; *p != (char *) NULL; p++)
3572 (void) printf(" %s\n",*p);
3573 (void) printf("\nMiscellaneous Options:\n");
3574 for (p=miscellaneous; *p != (char *) NULL; p++)
3575 (void) printf(" %s\n",*p);
3577 "\nBy default, the image format of 'file' is determined by its magic\n");
3579 "number. To specify a particular image format, precede the filename\n");
3581 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3583 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3584 (void) printf("'-' for standard input or output.\n");
3585 return(MagickFalse);
3588 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3589 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3591 #define DestroyMogrify() \
3593 if (format != (char *) NULL) \
3594 format=DestroyString(format); \
3595 if (path != (char *) NULL) \
3596 path=DestroyString(path); \
3597 DestroyImageStack(); \
3598 for (i=0; i < (ssize_t) argc; i++) \
3599 argv[i]=DestroyString(argv[i]); \
3600 argv=(char **) RelinquishMagickMemory(argv); \
3602 #define ThrowMogrifyException(asperity,tag,option) \
3604 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
3607 return(MagickFalse); \
3609 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3611 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3612 "InvalidArgument","'%s': %s",argument,option); \
3614 return(MagickFalse); \
3626 image_stack[MaxImageStackDepth+1];
3634 respect_parenthesis;
3649 assert(image_info != (ImageInfo *) NULL);
3650 assert(image_info->signature == MagickSignature);
3651 if (image_info->debug != MagickFalse)
3652 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3653 assert(exception != (ExceptionInfo *) NULL);
3657 if ((LocaleCompare("version",option+1) == 0) ||
3658 (LocaleCompare("-version",option+1) == 0))
3660 (void) FormatLocaleFile(stdout,"Version: %s\n",
3661 GetMagickVersion((size_t *) NULL));
3662 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3663 GetMagickCopyright());
3664 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3665 GetMagickFeatures());
3666 return(MagickFalse);
3670 return(MogrifyUsage());
3671 format=(char *) NULL;
3673 global_colormap=MagickFalse;
3677 option=(char *) NULL;
3679 respect_parenthesis=MagickFalse;
3684 ReadCommandlLine(argc,&argv);
3685 status=ExpandFilenames(&argc,&argv);
3686 if (status == MagickFalse)
3687 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3688 GetExceptionMessage(errno));
3689 for (i=1; i < (ssize_t) argc; i++)
3692 if (LocaleCompare(option,"(") == 0)
3694 FireImageStack(MagickFalse,MagickTrue,pend);
3695 if (k == MaxImageStackDepth)
3696 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3701 if (LocaleCompare(option,")") == 0)
3703 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3705 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3709 if (IsCommandOption(option) == MagickFalse)
3712 backup_filename[MaxTextExtent],
3719 Option is a file name: begin by reading image from specified file.
3721 FireImageStack(MagickFalse,MagickFalse,pend);
3723 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3725 images=ReadImages(image_info,filename,exception);
3726 status&=(images != (Image *) NULL) &&
3727 (exception->severity < ErrorException);
3728 if (images == (Image *) NULL)
3730 if (format != (char *) NULL)
3731 (void) CopyMagickString(images->filename,images->magick_filename,
3733 if (path != (char *) NULL)
3735 GetPathComponent(option,TailPath,filename);
3736 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3737 path,*DirectorySeparator,filename);
3739 if (format != (char *) NULL)
3740 AppendImageFormat(format,images->filename);
3741 AppendImageStack(images);
3742 FinalizeImageSettings(image_info,image,MagickFalse);
3743 if (global_colormap != MagickFalse)
3748 quantize_info=AcquireQuantizeInfo(image_info);
3749 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3750 quantize_info=DestroyQuantizeInfo(quantize_info);
3752 *backup_filename='\0';
3753 if ((LocaleCompare(image->filename,"-") != 0) &&
3754 (IsPathWritable(image->filename) != MagickFalse))
3760 Rename image file as backup.
3762 (void) CopyMagickString(backup_filename,image->filename,
3764 for (i=0; i < 6; i++)
3766 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3767 if (IsPathAccessible(backup_filename) == MagickFalse)
3770 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3771 (rename_utf8(image->filename,backup_filename) != 0))
3772 *backup_filename='\0';
3775 Write transmogrified image to disk.
3777 image_info->synchronize=MagickTrue;
3778 status&=WriteImages(image_info,image,image->filename,exception);
3779 if ((status == MagickFalse) && (*backup_filename != '\0'))
3780 (void) remove_utf8(backup_filename);
3781 RemoveAllImageStack();
3784 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3785 switch (*(option+1))
3789 if (LocaleCompare("adaptive-blur",option+1) == 0)
3792 if (i == (ssize_t) argc)
3793 ThrowMogrifyException(OptionError,"MissingArgument",option);
3794 if (IsGeometry(argv[i]) == MagickFalse)
3795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3798 if (LocaleCompare("adaptive-resize",option+1) == 0)
3801 if (i == (ssize_t) argc)
3802 ThrowMogrifyException(OptionError,"MissingArgument",option);
3803 if (IsGeometry(argv[i]) == MagickFalse)
3804 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3807 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3810 if (i == (ssize_t) argc)
3811 ThrowMogrifyException(OptionError,"MissingArgument",option);
3812 if (IsGeometry(argv[i]) == MagickFalse)
3813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3816 if (LocaleCompare("affine",option+1) == 0)
3821 if (i == (ssize_t) argc)
3822 ThrowMogrifyException(OptionError,"MissingArgument",option);
3825 if (LocaleCompare("alpha",option+1) == 0)
3833 if (i == (ssize_t) argc)
3834 ThrowMogrifyException(OptionError,"MissingArgument",option);
3835 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3837 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3841 if (LocaleCompare("annotate",option+1) == 0)
3846 if (i == (ssize_t) argc)
3847 ThrowMogrifyException(OptionError,"MissingArgument",option);
3848 if (IsGeometry(argv[i]) == MagickFalse)
3849 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3850 if (i == (ssize_t) argc)
3851 ThrowMogrifyException(OptionError,"MissingArgument",option);
3855 if (LocaleCompare("antialias",option+1) == 0)
3857 if (LocaleCompare("append",option+1) == 0)
3859 if (LocaleCompare("attenuate",option+1) == 0)
3864 if (i == (ssize_t) (argc-1))
3865 ThrowMogrifyException(OptionError,"MissingArgument",option);
3866 if (IsGeometry(argv[i]) == MagickFalse)
3867 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3870 if (LocaleCompare("authenticate",option+1) == 0)
3875 if (i == (ssize_t) argc)
3876 ThrowMogrifyException(OptionError,"MissingArgument",option);
3879 if (LocaleCompare("auto-gamma",option+1) == 0)
3881 if (LocaleCompare("auto-level",option+1) == 0)
3883 if (LocaleCompare("auto-orient",option+1) == 0)
3885 if (LocaleCompare("average",option+1) == 0)
3887 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3891 if (LocaleCompare("background",option+1) == 0)
3896 if (i == (ssize_t) argc)
3897 ThrowMogrifyException(OptionError,"MissingArgument",option);
3900 if (LocaleCompare("bias",option+1) == 0)
3905 if (i == (ssize_t) (argc-1))
3906 ThrowMogrifyException(OptionError,"MissingArgument",option);
3907 if (IsGeometry(argv[i]) == MagickFalse)
3908 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3911 if (LocaleCompare("black-point-compensation",option+1) == 0)
3913 if (LocaleCompare("black-threshold",option+1) == 0)
3918 if (i == (ssize_t) argc)
3919 ThrowMogrifyException(OptionError,"MissingArgument",option);
3920 if (IsGeometry(argv[i]) == MagickFalse)
3921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3924 if (LocaleCompare("blue-primary",option+1) == 0)
3929 if (i == (ssize_t) argc)
3930 ThrowMogrifyException(OptionError,"MissingArgument",option);
3931 if (IsGeometry(argv[i]) == MagickFalse)
3932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3935 if (LocaleCompare("blue-shift",option+1) == 0)
3938 if (i == (ssize_t) argc)
3939 ThrowMogrifyException(OptionError,"MissingArgument",option);
3940 if (IsGeometry(argv[i]) == MagickFalse)
3941 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3944 if (LocaleCompare("blur",option+1) == 0)
3947 if (i == (ssize_t) argc)
3948 ThrowMogrifyException(OptionError,"MissingArgument",option);
3949 if (IsGeometry(argv[i]) == MagickFalse)
3950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 if (LocaleCompare("border",option+1) == 0)
3958 if (i == (ssize_t) argc)
3959 ThrowMogrifyException(OptionError,"MissingArgument",option);
3960 if (IsGeometry(argv[i]) == MagickFalse)
3961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3964 if (LocaleCompare("bordercolor",option+1) == 0)
3969 if (i == (ssize_t) argc)
3970 ThrowMogrifyException(OptionError,"MissingArgument",option);
3973 if (LocaleCompare("box",option+1) == 0)
3978 if (i == (ssize_t) argc)
3979 ThrowMogrifyException(OptionError,"MissingArgument",option);
3982 if (LocaleCompare("brightness-contrast",option+1) == 0)
3985 if (i == (ssize_t) argc)
3986 ThrowMogrifyException(OptionError,"MissingArgument",option);
3987 if (IsGeometry(argv[i]) == MagickFalse)
3988 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3991 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3995 if (LocaleCompare("cache",option+1) == 0)
4000 if (i == (ssize_t) argc)
4001 ThrowMogrifyException(OptionError,"MissingArgument",option);
4002 if (IsGeometry(argv[i]) == MagickFalse)
4003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4006 if (LocaleCompare("caption",option+1) == 0)
4011 if (i == (ssize_t) argc)
4012 ThrowMogrifyException(OptionError,"MissingArgument",option);
4015 if (LocaleCompare("channel",option+1) == 0)
4023 if (i == (ssize_t) (argc-1))
4024 ThrowMogrifyException(OptionError,"MissingArgument",option);
4025 channel=ParseChannelOption(argv[i]);
4027 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4031 if (LocaleCompare("channel-fx",option+1) == 0)
4039 if (i == (ssize_t) (argc-1))
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4041 channel=ParsePixelChannelOption(argv[i]);
4043 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4047 if (LocaleCompare("cdl",option+1) == 0)
4052 if (i == (ssize_t) (argc-1))
4053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4056 if (LocaleCompare("charcoal",option+1) == 0)
4061 if (i == (ssize_t) argc)
4062 ThrowMogrifyException(OptionError,"MissingArgument",option);
4063 if (IsGeometry(argv[i]) == MagickFalse)
4064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4067 if (LocaleCompare("chop",option+1) == 0)
4072 if (i == (ssize_t) argc)
4073 ThrowMogrifyException(OptionError,"MissingArgument",option);
4074 if (IsGeometry(argv[i]) == MagickFalse)
4075 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4078 if (LocaleCompare("clamp",option+1) == 0)
4080 if (LocaleCompare("clip",option+1) == 0)
4082 if (LocaleCompare("clip-mask",option+1) == 0)
4087 if (i == (ssize_t) argc)
4088 ThrowMogrifyException(OptionError,"MissingArgument",option);
4091 if (LocaleCompare("clut",option+1) == 0)
4093 if (LocaleCompare("coalesce",option+1) == 0)
4095 if (LocaleCompare("colorize",option+1) == 0)
4100 if (i == (ssize_t) argc)
4101 ThrowMogrifyException(OptionError,"MissingArgument",option);
4102 if (IsGeometry(argv[i]) == MagickFalse)
4103 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4106 if (LocaleCompare("color-matrix",option+1) == 0)
4114 if (i == (ssize_t) (argc-1))
4115 ThrowMogrifyException(OptionError,"MissingArgument",option);
4116 kernel_info=AcquireKernelInfo(argv[i]);
4117 if (kernel_info == (KernelInfo *) NULL)
4118 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4119 kernel_info=DestroyKernelInfo(kernel_info);
4122 if (LocaleCompare("colors",option+1) == 0)
4127 if (i == (ssize_t) argc)
4128 ThrowMogrifyException(OptionError,"MissingArgument",option);
4129 if (IsGeometry(argv[i]) == MagickFalse)
4130 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4133 if (LocaleCompare("colorspace",option+1) == 0)
4141 if (i == (ssize_t) argc)
4142 ThrowMogrifyException(OptionError,"MissingArgument",option);
4143 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4146 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4150 if (LocaleCompare("combine",option+1) == 0)
4152 if (LocaleCompare("comment",option+1) == 0)
4157 if (i == (ssize_t) argc)
4158 ThrowMogrifyException(OptionError,"MissingArgument",option);
4161 if (LocaleCompare("composite",option+1) == 0)
4163 if (LocaleCompare("compress",option+1) == 0)
4171 if (i == (ssize_t) argc)
4172 ThrowMogrifyException(OptionError,"MissingArgument",option);
4173 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4176 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4180 if (LocaleCompare("concurrent",option+1) == 0)
4182 if (LocaleCompare("contrast",option+1) == 0)
4184 if (LocaleCompare("contrast-stretch",option+1) == 0)
4187 if (i == (ssize_t) argc)
4188 ThrowMogrifyException(OptionError,"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4193 if (LocaleCompare("convolve",option+1) == 0)
4201 if (i == (ssize_t) argc)
4202 ThrowMogrifyException(OptionError,"MissingArgument",option);
4203 kernel_info=AcquireKernelInfo(argv[i]);
4204 if (kernel_info == (KernelInfo *) NULL)
4205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4206 kernel_info=DestroyKernelInfo(kernel_info);
4209 if (LocaleCompare("crop",option+1) == 0)
4214 if (i == (ssize_t) argc)
4215 ThrowMogrifyException(OptionError,"MissingArgument",option);
4216 if (IsGeometry(argv[i]) == MagickFalse)
4217 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4220 if (LocaleCompare("cycle",option+1) == 0)
4225 if (i == (ssize_t) argc)
4226 ThrowMogrifyException(OptionError,"MissingArgument",option);
4227 if (IsGeometry(argv[i]) == MagickFalse)
4228 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4231 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4235 if (LocaleCompare("decipher",option+1) == 0)
4240 if (i == (ssize_t) (argc-1))
4241 ThrowMogrifyException(OptionError,"MissingArgument",option);
4244 if (LocaleCompare("deconstruct",option+1) == 0)
4246 if (LocaleCompare("debug",option+1) == 0)
4254 if (i == (ssize_t) argc)
4255 ThrowMogrifyException(OptionError,"MissingArgument",option);
4256 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4258 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4260 (void) SetLogEventMask(argv[i]);
4263 if (LocaleCompare("define",option+1) == 0)
4266 if (i == (ssize_t) argc)
4267 ThrowMogrifyException(OptionError,"MissingArgument",option);
4273 define=GetImageOption(image_info,argv[i]);
4274 if (define == (const char *) NULL)
4275 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4280 if (LocaleCompare("delay",option+1) == 0)
4285 if (i == (ssize_t) argc)
4286 ThrowMogrifyException(OptionError,"MissingArgument",option);
4287 if (IsGeometry(argv[i]) == MagickFalse)
4288 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4291 if (LocaleCompare("delete",option+1) == 0)
4296 if (i == (ssize_t) (argc-1))
4297 ThrowMogrifyException(OptionError,"MissingArgument",option);
4298 if (IsGeometry(argv[i]) == MagickFalse)
4299 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4302 if (LocaleCompare("density",option+1) == 0)
4307 if (i == (ssize_t) argc)
4308 ThrowMogrifyException(OptionError,"MissingArgument",option);
4309 if (IsGeometry(argv[i]) == MagickFalse)
4310 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4313 if (LocaleCompare("depth",option+1) == 0)
4318 if (i == (ssize_t) argc)
4319 ThrowMogrifyException(OptionError,"MissingArgument",option);
4320 if (IsGeometry(argv[i]) == MagickFalse)
4321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4324 if (LocaleCompare("deskew",option+1) == 0)
4329 if (i == (ssize_t) argc)
4330 ThrowMogrifyException(OptionError,"MissingArgument",option);
4331 if (IsGeometry(argv[i]) == MagickFalse)
4332 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4335 if (LocaleCompare("despeckle",option+1) == 0)
4337 if (LocaleCompare("dft",option+1) == 0)
4339 if (LocaleCompare("direction",option+1) == 0)
4347 if (i == (ssize_t) argc)
4348 ThrowMogrifyException(OptionError,"MissingArgument",option);
4349 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4352 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4356 if (LocaleCompare("display",option+1) == 0)
4361 if (i == (ssize_t) argc)
4362 ThrowMogrifyException(OptionError,"MissingArgument",option);
4365 if (LocaleCompare("dispose",option+1) == 0)
4373 if (i == (ssize_t) argc)
4374 ThrowMogrifyException(OptionError,"MissingArgument",option);
4375 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4377 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4381 if (LocaleCompare("distort",option+1) == 0)
4387 if (i == (ssize_t) argc)
4388 ThrowMogrifyException(OptionError,"MissingArgument",option);
4389 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4391 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4394 if (i == (ssize_t) (argc-1))
4395 ThrowMogrifyException(OptionError,"MissingArgument",option);
4398 if (LocaleCompare("dither",option+1) == 0)
4406 if (i == (ssize_t) argc)
4407 ThrowMogrifyException(OptionError,"MissingArgument",option);
4408 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4410 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4414 if (LocaleCompare("draw",option+1) == 0)
4419 if (i == (ssize_t) argc)
4420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4423 if (LocaleCompare("duplicate",option+1) == 0)
4428 if (i == (ssize_t) (argc-1))
4429 ThrowMogrifyException(OptionError,"MissingArgument",option);
4430 if (IsGeometry(argv[i]) == MagickFalse)
4431 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4434 if (LocaleCompare("duration",option+1) == 0)
4439 if (i == (ssize_t) (argc-1))
4440 ThrowMogrifyException(OptionError,"MissingArgument",option);
4441 if (IsGeometry(argv[i]) == MagickFalse)
4442 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4445 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4449 if (LocaleCompare("edge",option+1) == 0)
4454 if (i == (ssize_t) argc)
4455 ThrowMogrifyException(OptionError,"MissingArgument",option);
4456 if (IsGeometry(argv[i]) == MagickFalse)
4457 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4460 if (LocaleCompare("emboss",option+1) == 0)
4465 if (i == (ssize_t) argc)
4466 ThrowMogrifyException(OptionError,"MissingArgument",option);
4467 if (IsGeometry(argv[i]) == MagickFalse)
4468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4471 if (LocaleCompare("encipher",option+1) == 0)
4476 if (i == (ssize_t) argc)
4477 ThrowMogrifyException(OptionError,"MissingArgument",option);
4480 if (LocaleCompare("encoding",option+1) == 0)
4485 if (i == (ssize_t) argc)
4486 ThrowMogrifyException(OptionError,"MissingArgument",option);
4489 if (LocaleCompare("endian",option+1) == 0)
4497 if (i == (ssize_t) argc)
4498 ThrowMogrifyException(OptionError,"MissingArgument",option);
4499 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4501 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4505 if (LocaleCompare("enhance",option+1) == 0)
4507 if (LocaleCompare("equalize",option+1) == 0)
4509 if (LocaleCompare("evaluate",option+1) == 0)
4517 if (i == (ssize_t) argc)
4518 ThrowMogrifyException(OptionError,"MissingArgument",option);
4519 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4521 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4524 if (i == (ssize_t) (argc-1))
4525 ThrowMogrifyException(OptionError,"MissingArgument",option);
4526 if (IsGeometry(argv[i]) == MagickFalse)
4527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4530 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4538 if (i == (ssize_t) argc)
4539 ThrowMogrifyException(OptionError,"MissingArgument",option);
4540 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4542 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4546 if (LocaleCompare("extent",option+1) == 0)
4551 if (i == (ssize_t) argc)
4552 ThrowMogrifyException(OptionError,"MissingArgument",option);
4553 if (IsGeometry(argv[i]) == MagickFalse)
4554 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4557 if (LocaleCompare("extract",option+1) == 0)
4562 if (i == (ssize_t) argc)
4563 ThrowMogrifyException(OptionError,"MissingArgument",option);
4564 if (IsGeometry(argv[i]) == MagickFalse)
4565 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4568 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4572 if (LocaleCompare("family",option+1) == 0)
4577 if (i == (ssize_t) (argc-1))
4578 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (LocaleCompare("fill",option+1) == 0)
4586 if (i == (ssize_t) argc)
4587 ThrowMogrifyException(OptionError,"MissingArgument",option);
4590 if (LocaleCompare("filter",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4602 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4606 if (LocaleCompare("flatten",option+1) == 0)
4608 if (LocaleCompare("flip",option+1) == 0)
4610 if (LocaleCompare("flop",option+1) == 0)
4612 if (LocaleCompare("floodfill",option+1) == 0)
4617 if (i == (ssize_t) argc)
4618 ThrowMogrifyException(OptionError,"MissingArgument",option);
4619 if (IsGeometry(argv[i]) == MagickFalse)
4620 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4622 if (i == (ssize_t) argc)
4623 ThrowMogrifyException(OptionError,"MissingArgument",option);
4626 if (LocaleCompare("font",option+1) == 0)
4631 if (i == (ssize_t) argc)
4632 ThrowMogrifyException(OptionError,"MissingArgument",option);
4635 if (LocaleCompare("format",option+1) == 0)
4637 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4638 (void) CloneString(&format,(char *) NULL);
4642 if (i == (ssize_t) argc)
4643 ThrowMogrifyException(OptionError,"MissingArgument",option);
4644 (void) CloneString(&format,argv[i]);
4645 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4646 (void) ConcatenateMagickString(image_info->filename,":",
4648 (void) SetImageInfo(image_info,0,exception);
4649 if (*image_info->magick == '\0')
4650 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4654 if (LocaleCompare("frame",option+1) == 0)
4659 if (i == (ssize_t) argc)
4660 ThrowMogrifyException(OptionError,"MissingArgument",option);
4661 if (IsGeometry(argv[i]) == MagickFalse)
4662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4665 if (LocaleCompare("function",option+1) == 0)
4673 if (i == (ssize_t) argc)
4674 ThrowMogrifyException(OptionError,"MissingArgument",option);
4675 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4677 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4679 if (i == (ssize_t) (argc-1))
4680 ThrowMogrifyException(OptionError,"MissingArgument",option);
4683 if (LocaleCompare("fuzz",option+1) == 0)
4688 if (i == (ssize_t) argc)
4689 ThrowMogrifyException(OptionError,"MissingArgument",option);
4690 if (IsGeometry(argv[i]) == MagickFalse)
4691 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4694 if (LocaleCompare("fx",option+1) == 0)
4699 if (i == (ssize_t) (argc-1))
4700 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4707 if (LocaleCompare("gamma",option+1) == 0)
4710 if (i == (ssize_t) argc)
4711 ThrowMogrifyException(OptionError,"MissingArgument",option);
4712 if (IsGeometry(argv[i]) == MagickFalse)
4713 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4716 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4717 (LocaleCompare("gaussian",option+1) == 0))
4720 if (i == (ssize_t) argc)
4721 ThrowMogrifyException(OptionError,"MissingArgument",option);
4722 if (IsGeometry(argv[i]) == MagickFalse)
4723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4726 if (LocaleCompare("geometry",option+1) == 0)
4731 if (i == (ssize_t) argc)
4732 ThrowMogrifyException(OptionError,"MissingArgument",option);
4733 if (IsGeometry(argv[i]) == MagickFalse)
4734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4737 if (LocaleCompare("gravity",option+1) == 0)
4745 if (i == (ssize_t) argc)
4746 ThrowMogrifyException(OptionError,"MissingArgument",option);
4747 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4749 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4753 if (LocaleCompare("green-primary",option+1) == 0)
4758 if (i == (ssize_t) argc)
4759 ThrowMogrifyException(OptionError,"MissingArgument",option);
4760 if (IsGeometry(argv[i]) == MagickFalse)
4761 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4764 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4768 if (LocaleCompare("hald-clut",option+1) == 0)
4770 if ((LocaleCompare("help",option+1) == 0) ||
4771 (LocaleCompare("-help",option+1) == 0))
4772 return(MogrifyUsage());
4773 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4777 if (LocaleCompare("identify",option+1) == 0)
4779 if (LocaleCompare("idft",option+1) == 0)
4781 if (LocaleCompare("implode",option+1) == 0)
4786 if (i == (ssize_t) argc)
4787 ThrowMogrifyException(OptionError,"MissingArgument",option);
4788 if (IsGeometry(argv[i]) == MagickFalse)
4789 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4792 if (LocaleCompare("intent",option+1) == 0)
4800 if (i == (ssize_t) (argc-1))
4801 ThrowMogrifyException(OptionError,"MissingArgument",option);
4802 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4804 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4808 if (LocaleCompare("interlace",option+1) == 0)
4816 if (i == (ssize_t) argc)
4817 ThrowMogrifyException(OptionError,"MissingArgument",option);
4818 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4821 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4825 if (LocaleCompare("interline-spacing",option+1) == 0)
4830 if (i == (ssize_t) (argc-1))
4831 ThrowMogrifyException(OptionError,"MissingArgument",option);
4832 if (IsGeometry(argv[i]) == MagickFalse)
4833 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4836 if (LocaleCompare("interpolate",option+1) == 0)
4844 if (i == (ssize_t) argc)
4845 ThrowMogrifyException(OptionError,"MissingArgument",option);
4846 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4848 if (interpolate < 0)
4849 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4853 if (LocaleCompare("interword-spacing",option+1) == 0)
4858 if (i == (ssize_t) (argc-1))
4859 ThrowMogrifyException(OptionError,"MissingArgument",option);
4860 if (IsGeometry(argv[i]) == MagickFalse)
4861 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4864 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4868 if (LocaleCompare("kerning",option+1) == 0)
4873 if (i == (ssize_t) (argc-1))
4874 ThrowMogrifyException(OptionError,"MissingArgument",option);
4875 if (IsGeometry(argv[i]) == MagickFalse)
4876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4879 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4883 if (LocaleCompare("label",option+1) == 0)
4888 if (i == (ssize_t) argc)
4889 ThrowMogrifyException(OptionError,"MissingArgument",option);
4892 if (LocaleCompare("lat",option+1) == 0)
4897 if (i == (ssize_t) argc)
4898 ThrowMogrifyException(OptionError,"MissingArgument",option);
4899 if (IsGeometry(argv[i]) == MagickFalse)
4900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4902 if (LocaleCompare("layers",option+1) == 0)
4910 if (i == (ssize_t) (argc-1))
4911 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4914 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4918 if (LocaleCompare("level",option+1) == 0)
4921 if (i == (ssize_t) argc)
4922 ThrowMogrifyException(OptionError,"MissingArgument",option);
4923 if (IsGeometry(argv[i]) == MagickFalse)
4924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4927 if (LocaleCompare("level-colors",option+1) == 0)
4930 if (i == (ssize_t) argc)
4931 ThrowMogrifyException(OptionError,"MissingArgument",option);
4934 if (LocaleCompare("limit",option+1) == 0)
4948 if (i == (ssize_t) argc)
4949 ThrowMogrifyException(OptionError,"MissingArgument",option);
4950 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4953 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4956 if (i == (ssize_t) argc)
4957 ThrowMogrifyException(OptionError,"MissingArgument",option);
4958 value=StringToDouble(argv[i],&p);
4960 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4964 if (LocaleCompare("liquid-rescale",option+1) == 0)
4967 if (i == (ssize_t) argc)
4968 ThrowMogrifyException(OptionError,"MissingArgument",option);
4969 if (IsGeometry(argv[i]) == MagickFalse)
4970 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4973 if (LocaleCompare("list",option+1) == 0)
4981 if (i == (ssize_t) argc)
4982 ThrowMogrifyException(OptionError,"MissingArgument",option);
4983 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4985 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4986 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4988 return(status != 0 ? MagickFalse : MagickTrue);
4990 if (LocaleCompare("log",option+1) == 0)
4995 if ((i == (ssize_t) argc) ||
4996 (strchr(argv[i],'%') == (char *) NULL))
4997 ThrowMogrifyException(OptionError,"MissingArgument",option);
5000 if (LocaleCompare("loop",option+1) == 0)
5005 if (i == (ssize_t) argc)
5006 ThrowMogrifyException(OptionError,"MissingArgument",option);
5007 if (IsGeometry(argv[i]) == MagickFalse)
5008 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5011 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5015 if (LocaleCompare("map",option+1) == 0)
5017 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5021 if (i == (ssize_t) argc)
5022 ThrowMogrifyException(OptionError,"MissingArgument",option);
5025 if (LocaleCompare("mask",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,"MissingArgument",option);
5034 if (LocaleCompare("matte",option+1) == 0)
5036 if (LocaleCompare("mattecolor",option+1) == 0)
5041 if (i == (ssize_t) argc)
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5045 if (LocaleCompare("maximum",option+1) == 0)
5047 if (LocaleCompare("minimum",option+1) == 0)
5049 if (LocaleCompare("modulate",option+1) == 0)
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 if (LocaleCompare("median",option+1) == 0)
5065 if (i == (ssize_t) argc)
5066 ThrowMogrifyException(OptionError,"MissingArgument",option);
5067 if (IsGeometry(argv[i]) == MagickFalse)
5068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5071 if (LocaleCompare("mode",option+1) == 0)
5076 if (i == (ssize_t) argc)
5077 ThrowMogrifyException(OptionError,"MissingArgument",option);
5078 if (IsGeometry(argv[i]) == MagickFalse)
5079 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5082 if (LocaleCompare("monitor",option+1) == 0)
5084 if (LocaleCompare("monochrome",option+1) == 0)
5086 if (LocaleCompare("morph",option+1) == 0)
5091 if (i == (ssize_t) (argc-1))
5092 ThrowMogrifyException(OptionError,"MissingArgument",option);
5093 if (IsGeometry(argv[i]) == MagickFalse)
5094 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5097 if (LocaleCompare("morphology",option+1) == 0)
5100 token[MaxTextExtent];
5109 if (i == (ssize_t) argc)
5110 ThrowMogrifyException(OptionError,"MissingArgument",option);
5111 GetMagickToken(argv[i],NULL,token);
5112 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5114 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5117 if (i == (ssize_t) (argc-1))
5118 ThrowMogrifyException(OptionError,"MissingArgument",option);
5119 kernel_info=AcquireKernelInfo(argv[i]);
5120 if (kernel_info == (KernelInfo *) NULL)
5121 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5122 kernel_info=DestroyKernelInfo(kernel_info);
5125 if (LocaleCompare("mosaic",option+1) == 0)
5127 if (LocaleCompare("motion-blur",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("negate",option+1) == 0)
5144 if (LocaleCompare("noise",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5154 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5156 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5160 if (IsGeometry(argv[i]) == MagickFalse)
5161 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5164 if (LocaleCompare("noop",option+1) == 0)
5166 if (LocaleCompare("normalize",option+1) == 0)
5168 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5172 if (LocaleCompare("opaque",option+1) == 0)
5175 if (i == (ssize_t) argc)
5176 ThrowMogrifyException(OptionError,"MissingArgument",option);
5179 if (LocaleCompare("ordered-dither",option+1) == 0)
5184 if (i == (ssize_t) argc)
5185 ThrowMogrifyException(OptionError,"MissingArgument",option);
5188 if (LocaleCompare("orient",option+1) == 0)
5193 orientation=UndefinedOrientation;
5197 if (i == (ssize_t) (argc-1))
5198 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5201 if (orientation < 0)
5202 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5206 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5210 if (LocaleCompare("page",option+1) == 0)
5215 if (i == (ssize_t) argc)
5216 ThrowMogrifyException(OptionError,"MissingArgument",option);
5219 if (LocaleCompare("paint",option+1) == 0)
5224 if (i == (ssize_t) argc)
5225 ThrowMogrifyException(OptionError,"MissingArgument",option);
5226 if (IsGeometry(argv[i]) == MagickFalse)
5227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5230 if (LocaleCompare("path",option+1) == 0)
5232 (void) CloneString(&path,(char *) NULL);
5236 if (i == (ssize_t) argc)
5237 ThrowMogrifyException(OptionError,"MissingArgument",option);
5238 (void) CloneString(&path,argv[i]);
5241 if (LocaleCompare("pointsize",option+1) == 0)
5246 if (i == (ssize_t) argc)
5247 ThrowMogrifyException(OptionError,"MissingArgument",option);
5248 if (IsGeometry(argv[i]) == MagickFalse)
5249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5252 if (LocaleCompare("polaroid",option+1) == 0)
5257 if (i == (ssize_t) argc)
5258 ThrowMogrifyException(OptionError,"MissingArgument",option);
5259 if (IsGeometry(argv[i]) == MagickFalse)
5260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5263 if (LocaleCompare("posterize",option+1) == 0)
5268 if (i == (ssize_t) argc)
5269 ThrowMogrifyException(OptionError,"MissingArgument",option);
5270 if (IsGeometry(argv[i]) == MagickFalse)
5271 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5274 if (LocaleCompare("precision",option+1) == 0)
5279 if (i == (ssize_t) argc)
5280 ThrowMogrifyException(OptionError,"MissingArgument",option);
5281 if (IsGeometry(argv[i]) == MagickFalse)
5282 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5285 if (LocaleCompare("print",option+1) == 0)
5290 if (i == (ssize_t) argc)
5291 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 if (LocaleCompare("process",option+1) == 0)
5299 if (i == (ssize_t) (argc-1))
5300 ThrowMogrifyException(OptionError,"MissingArgument",option);
5303 if (LocaleCompare("profile",option+1) == 0)
5306 if (i == (ssize_t) argc)
5307 ThrowMogrifyException(OptionError,"MissingArgument",option);
5310 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5314 if (LocaleCompare("quality",option+1) == 0)
5319 if (i == (ssize_t) argc)
5320 ThrowMogrifyException(OptionError,"MissingArgument",option);
5321 if (IsGeometry(argv[i]) == MagickFalse)
5322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5325 if (LocaleCompare("quantize",option+1) == 0)
5333 if (i == (ssize_t) (argc-1))
5334 ThrowMogrifyException(OptionError,"MissingArgument",option);
5335 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5338 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5342 if (LocaleCompare("quiet",option+1) == 0)
5344 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5348 if (LocaleCompare("radial-blur",option+1) == 0)
5351 if (i == (ssize_t) argc)
5352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5353 if (IsGeometry(argv[i]) == MagickFalse)
5354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5357 if (LocaleCompare("raise",option+1) == 0)
5360 if (i == (ssize_t) argc)
5361 ThrowMogrifyException(OptionError,"MissingArgument",option);
5362 if (IsGeometry(argv[i]) == MagickFalse)
5363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5366 if (LocaleCompare("random-threshold",option+1) == 0)
5371 if (i == (ssize_t) argc)
5372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5377 if (LocaleCompare("red-primary",option+1) == 0)
5382 if (i == (ssize_t) argc)
5383 ThrowMogrifyException(OptionError,"MissingArgument",option);
5384 if (IsGeometry(argv[i]) == MagickFalse)
5385 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5387 if (LocaleCompare("regard-warnings",option+1) == 0)
5389 if (LocaleCompare("region",option+1) == 0)
5394 if (i == (ssize_t) argc)
5395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 if (IsGeometry(argv[i]) == MagickFalse)
5397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5400 if (LocaleCompare("remap",option+1) == 0)
5405 if (i == (ssize_t) (argc-1))
5406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5409 if (LocaleCompare("render",option+1) == 0)
5411 if (LocaleCompare("repage",option+1) == 0)
5416 if (i == (ssize_t) argc)
5417 ThrowMogrifyException(OptionError,"MissingArgument",option);
5418 if (IsGeometry(argv[i]) == MagickFalse)
5419 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5422 if (LocaleCompare("resample",option+1) == 0)
5427 if (i == (ssize_t) argc)
5428 ThrowMogrifyException(OptionError,"MissingArgument",option);
5429 if (IsGeometry(argv[i]) == MagickFalse)
5430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5433 if (LocaleCompare("resize",option+1) == 0)
5438 if (i == (ssize_t) argc)
5439 ThrowMogrifyException(OptionError,"MissingArgument",option);
5440 if (IsGeometry(argv[i]) == MagickFalse)
5441 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5444 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5446 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5449 if (LocaleCompare("reverse",option+1) == 0)
5451 if (LocaleCompare("roll",option+1) == 0)
5456 if (i == (ssize_t) argc)
5457 ThrowMogrifyException(OptionError,"MissingArgument",option);
5458 if (IsGeometry(argv[i]) == MagickFalse)
5459 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5462 if (LocaleCompare("rotate",option+1) == 0)
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,"MissingArgument",option);
5467 if (IsGeometry(argv[i]) == MagickFalse)
5468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5471 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5475 if (LocaleCompare("sample",option+1) == 0)
5480 if (i == (ssize_t) argc)
5481 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (IsGeometry(argv[i]) == MagickFalse)
5483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5486 if (LocaleCompare("sampling-factor",option+1) == 0)
5491 if (i == (ssize_t) argc)
5492 ThrowMogrifyException(OptionError,"MissingArgument",option);
5493 if (IsGeometry(argv[i]) == MagickFalse)
5494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5497 if (LocaleCompare("scale",option+1) == 0)
5502 if (i == (ssize_t) argc)
5503 ThrowMogrifyException(OptionError,"MissingArgument",option);
5504 if (IsGeometry(argv[i]) == MagickFalse)
5505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5508 if (LocaleCompare("scene",option+1) == 0)
5513 if (i == (ssize_t) argc)
5514 ThrowMogrifyException(OptionError,"MissingArgument",option);
5515 if (IsGeometry(argv[i]) == MagickFalse)
5516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5519 if (LocaleCompare("seed",option+1) == 0)
5524 if (i == (ssize_t) argc)
5525 ThrowMogrifyException(OptionError,"MissingArgument",option);
5526 if (IsGeometry(argv[i]) == MagickFalse)
5527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5530 if (LocaleCompare("segment",option+1) == 0)
5535 if (i == (ssize_t) argc)
5536 ThrowMogrifyException(OptionError,"MissingArgument",option);
5537 if (IsGeometry(argv[i]) == MagickFalse)
5538 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5541 if (LocaleCompare("selective-blur",option+1) == 0)
5544 if (i == (ssize_t) argc)
5545 ThrowMogrifyException(OptionError,"MissingArgument",option);
5546 if (IsGeometry(argv[i]) == MagickFalse)
5547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5550 if (LocaleCompare("separate",option+1) == 0)
5552 if (LocaleCompare("sepia-tone",option+1) == 0)
5557 if (i == (ssize_t) argc)
5558 ThrowMogrifyException(OptionError,"MissingArgument",option);
5559 if (IsGeometry(argv[i]) == MagickFalse)
5560 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5563 if (LocaleCompare("set",option+1) == 0)
5566 if (i == (ssize_t) argc)
5567 ThrowMogrifyException(OptionError,"MissingArgument",option);
5571 if (i == (ssize_t) argc)
5572 ThrowMogrifyException(OptionError,"MissingArgument",option);
5575 if (LocaleCompare("shade",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("shadow",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("sharpen",option+1) == 0)
5598 if (i == (ssize_t) argc)
5599 ThrowMogrifyException(OptionError,"MissingArgument",option);
5600 if (IsGeometry(argv[i]) == MagickFalse)
5601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5604 if (LocaleCompare("shave",option+1) == 0)
5609 if (i == (ssize_t) argc)
5610 ThrowMogrifyException(OptionError,"MissingArgument",option);
5611 if (IsGeometry(argv[i]) == MagickFalse)
5612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5615 if (LocaleCompare("shear",option+1) == 0)
5618 if (i == (ssize_t) argc)
5619 ThrowMogrifyException(OptionError,"MissingArgument",option);
5620 if (IsGeometry(argv[i]) == MagickFalse)
5621 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5624 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5627 if (i == (ssize_t) (argc-1))
5628 ThrowMogrifyException(OptionError,"MissingArgument",option);
5629 if (IsGeometry(argv[i]) == MagickFalse)
5630 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5633 if (LocaleCompare("size",option+1) == 0)
5638 if (i == (ssize_t) argc)
5639 ThrowMogrifyException(OptionError,"MissingArgument",option);
5640 if (IsGeometry(argv[i]) == MagickFalse)
5641 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644 if (LocaleCompare("sketch",option+1) == 0)
5649 if (i == (ssize_t) argc)
5650 ThrowMogrifyException(OptionError,"MissingArgument",option);
5651 if (IsGeometry(argv[i]) == MagickFalse)
5652 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5655 if (LocaleCompare("smush",option+1) == 0)
5658 if (i == (ssize_t) argc)
5659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 if (IsGeometry(argv[i]) == MagickFalse)
5661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5665 if (LocaleCompare("solarize",option+1) == 0)
5670 if (i == (ssize_t) argc)
5671 ThrowMogrifyException(OptionError,"MissingArgument",option);
5672 if (IsGeometry(argv[i]) == MagickFalse)
5673 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5676 if (LocaleCompare("sparse-color",option+1) == 0)
5682 if (i == (ssize_t) argc)
5683 ThrowMogrifyException(OptionError,"MissingArgument",option);
5684 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5686 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5689 if (i == (ssize_t) (argc-1))
5690 ThrowMogrifyException(OptionError,"MissingArgument",option);
5693 if (LocaleCompare("spread",option+1) == 0)
5698 if (i == (ssize_t) argc)
5699 ThrowMogrifyException(OptionError,"MissingArgument",option);
5700 if (IsGeometry(argv[i]) == MagickFalse)
5701 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5704 if (LocaleCompare("statistic",option+1) == 0)
5712 if (i == (ssize_t) argc)
5713 ThrowMogrifyException(OptionError,"MissingArgument",option);
5714 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5716 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5719 if (i == (ssize_t) (argc-1))
5720 ThrowMogrifyException(OptionError,"MissingArgument",option);
5721 if (IsGeometry(argv[i]) == MagickFalse)
5722 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5725 if (LocaleCompare("stretch",option+1) == 0)
5733 if (i == (ssize_t) (argc-1))
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5735 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5737 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5741 if (LocaleCompare("strip",option+1) == 0)
5743 if (LocaleCompare("stroke",option+1) == 0)
5748 if (i == (ssize_t) argc)
5749 ThrowMogrifyException(OptionError,"MissingArgument",option);
5752 if (LocaleCompare("strokewidth",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("style",option+1) == 0)
5771 if (i == (ssize_t) (argc-1))
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5775 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5779 if (LocaleCompare("swap",option+1) == 0)
5784 if (i == (ssize_t) (argc-1))
5785 ThrowMogrifyException(OptionError,"MissingArgument",option);
5786 if (IsGeometry(argv[i]) == MagickFalse)
5787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5790 if (LocaleCompare("swirl",option+1) == 0)
5795 if (i == (ssize_t) argc)
5796 ThrowMogrifyException(OptionError,"MissingArgument",option);
5797 if (IsGeometry(argv[i]) == MagickFalse)
5798 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5801 if (LocaleCompare("synchronize",option+1) == 0)
5803 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5807 if (LocaleCompare("taint",option+1) == 0)
5809 if (LocaleCompare("texture",option+1) == 0)
5814 if (i == (ssize_t) argc)
5815 ThrowMogrifyException(OptionError,"MissingArgument",option);
5818 if (LocaleCompare("tile",option+1) == 0)
5823 if (i == (ssize_t) (argc-1))
5824 ThrowMogrifyException(OptionError,"MissingArgument",option);
5827 if (LocaleCompare("tile-offset",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("tint",option+1) == 0)
5843 if (i == (ssize_t) (argc-1))
5844 ThrowMogrifyException(OptionError,"MissingArgument",option);
5845 if (IsGeometry(argv[i]) == MagickFalse)
5846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5849 if (LocaleCompare("transform",option+1) == 0)
5851 if (LocaleCompare("transpose",option+1) == 0)
5853 if (LocaleCompare("transverse",option+1) == 0)
5855 if (LocaleCompare("threshold",option+1) == 0)
5860 if (i == (ssize_t) argc)
5861 ThrowMogrifyException(OptionError,"MissingArgument",option);
5862 if (IsGeometry(argv[i]) == MagickFalse)
5863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5866 if (LocaleCompare("thumbnail",option+1) == 0)
5871 if (i == (ssize_t) argc)
5872 ThrowMogrifyException(OptionError,"MissingArgument",option);
5873 if (IsGeometry(argv[i]) == MagickFalse)
5874 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5877 if (LocaleCompare("transparent",option+1) == 0)
5880 if (i == (ssize_t) argc)
5881 ThrowMogrifyException(OptionError,"MissingArgument",option);
5884 if (LocaleCompare("transparent-color",option+1) == 0)
5889 if (i == (ssize_t) (argc-1))
5890 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 if (LocaleCompare("treedepth",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("trim",option+1) == 0)
5906 if (LocaleCompare("type",option+1) == 0)
5914 if (i == (ssize_t) argc)
5915 ThrowMogrifyException(OptionError,"MissingArgument",option);
5916 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5918 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5922 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5926 if (LocaleCompare("undercolor",option+1) == 0)
5931 if (i == (ssize_t) argc)
5932 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 if (LocaleCompare("unique-colors",option+1) == 0)
5937 if (LocaleCompare("units",option+1) == 0)
5945 if (i == (ssize_t) argc)
5946 ThrowMogrifyException(OptionError,"MissingArgument",option);
5947 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5950 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5954 if (LocaleCompare("unsharp",option+1) == 0)
5957 if (i == (ssize_t) argc)
5958 ThrowMogrifyException(OptionError,"MissingArgument",option);
5959 if (IsGeometry(argv[i]) == MagickFalse)
5960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5963 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5967 if (LocaleCompare("verbose",option+1) == 0)
5969 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5972 if ((LocaleCompare("version",option+1) == 0) ||
5973 (LocaleCompare("-version",option+1) == 0))
5975 (void) FormatLocaleFile(stdout,"Version: %s\n",
5976 GetMagickVersion((size_t *) NULL));
5977 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5978 GetMagickCopyright());
5979 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5980 GetMagickFeatures());
5983 if (LocaleCompare("view",option+1) == 0)
5988 if (i == (ssize_t) argc)
5989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5992 if (LocaleCompare("vignette",option+1) == 0)
5997 if (i == (ssize_t) argc)
5998 ThrowMogrifyException(OptionError,"MissingArgument",option);
5999 if (IsGeometry(argv[i]) == MagickFalse)
6000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003 if (LocaleCompare("virtual-pixel",option+1) == 0)
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6013 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6016 ThrowMogrifyException(OptionError,
6017 "UnrecognizedVirtualPixelMethod",argv[i]);
6020 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6024 if (LocaleCompare("wave",option+1) == 0)
6027 if (i == (ssize_t) argc)
6028 ThrowMogrifyException(OptionError,"MissingArgument",option);
6029 if (IsGeometry(argv[i]) == MagickFalse)
6030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6033 if (LocaleCompare("weight",option+1) == 0)
6038 if (i == (ssize_t) (argc-1))
6039 ThrowMogrifyException(OptionError,"MissingArgument",option);
6042 if (LocaleCompare("white-point",option+1) == 0)
6047 if (i == (ssize_t) argc)
6048 ThrowMogrifyException(OptionError,"MissingArgument",option);
6049 if (IsGeometry(argv[i]) == MagickFalse)
6050 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 if (LocaleCompare("white-threshold",option+1) == 0)
6058 if (i == (ssize_t) argc)
6059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 if (IsGeometry(argv[i]) == MagickFalse)
6061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 if (LocaleCompare("write",option+1) == 0)
6067 if (i == (ssize_t) (argc-1))
6068 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6076 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6078 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6079 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6080 if (fire != MagickFalse)
6081 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6084 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6085 if (i != (ssize_t) argc)
6086 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6088 return(status != 0 ? MagickTrue : MagickFalse);
6092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6096 + M o g r i f y I m a g e I n f o %
6100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6102 % MogrifyImageInfo() applies image processing settings to the image as
6103 % prescribed by command line options.
6105 % The format of the MogrifyImageInfo method is:
6107 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6108 % const char **argv,ExceptionInfo *exception)
6110 % A description of each parameter follows:
6112 % o image_info: the image info..
6114 % o argc: Specifies a pointer to an integer describing the number of
6115 % elements in the argument vector.
6117 % o argv: Specifies a pointer to a text array containing the command line
6120 % o exception: return any errors or warnings in this structure.
6123 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6124 const int argc,const char **argv,ExceptionInfo *exception)
6139 Initialize method variables.
6141 assert(image_info != (ImageInfo *) NULL);
6142 assert(image_info->signature == MagickSignature);
6143 if (image_info->debug != MagickFalse)
6144 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6145 image_info->filename);
6149 Set the image settings.
6151 for (i=0; i < (ssize_t) argc; i++)
6154 if (IsCommandOption(option) == MagickFalse)
6156 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6157 count=MagickMax(count,0L);
6158 if ((i+count) >= (ssize_t) argc)
6160 switch (*(option+1))
6164 if (LocaleCompare("adjoin",option+1) == 0)
6166 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6169 if (LocaleCompare("antialias",option+1) == 0)
6171 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6174 if (LocaleCompare("authenticate",option+1) == 0)
6177 (void) DeleteImageOption(image_info,option+1);
6179 (void) SetImageOption(image_info,option+1,argv[i+1]);
6186 if (LocaleCompare("background",option+1) == 0)
6190 (void) DeleteImageOption(image_info,option+1);
6191 (void) QueryColorCompliance(MogrifyBackgroundColor,
6192 AllCompliance,&image_info->background_color,exception);
6195 (void) SetImageOption(image_info,option+1,argv[i+1]);
6196 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6197 &image_info->background_color,exception);
6200 if (LocaleCompare("bias",option+1) == 0)
6204 (void) SetImageOption(image_info,option+1,"0.0");
6207 (void) SetImageOption(image_info,option+1,argv[i+1]);
6210 if (LocaleCompare("black-point-compensation",option+1) == 0)
6214 (void) SetImageOption(image_info,option+1,"false");
6217 (void) SetImageOption(image_info,option+1,"true");
6220 if (LocaleCompare("blue-primary",option+1) == 0)
6224 (void) SetImageOption(image_info,option+1,"0.0");
6227 (void) SetImageOption(image_info,option+1,argv[i+1]);
6230 if (LocaleCompare("bordercolor",option+1) == 0)
6234 (void) DeleteImageOption(image_info,option+1);
6235 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6236 &image_info->border_color,exception);
6239 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6240 &image_info->border_color,exception);
6241 (void) SetImageOption(image_info,option+1,argv[i+1]);
6244 if (LocaleCompare("box",option+1) == 0)
6248 (void) SetImageOption(image_info,"undercolor","none");
6251 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6258 if (LocaleCompare("cache",option+1) == 0)
6263 limit=MagickResourceInfinity;
6264 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6265 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6267 (void) SetMagickResourceLimit(MemoryResource,limit);
6268 (void) SetMagickResourceLimit(MapResource,2*limit);
6271 if (LocaleCompare("caption",option+1) == 0)
6275 (void) DeleteImageOption(image_info,option+1);
6278 (void) SetImageOption(image_info,option+1,argv[i+1]);
6281 if (LocaleCompare("channel",option+1) == 0)
6285 image_info->channel=DefaultChannels;
6286 (void) SetImageOption(image_info,option+1,"default");
6289 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6290 (void) SetImageOption(image_info,option+1,argv[i+1]);
6293 if (LocaleCompare("colorspace",option+1) == 0)
6297 image_info->colorspace=UndefinedColorspace;
6298 (void) SetImageOption(image_info,option+1,"undefined");
6301 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6302 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6303 (void) SetImageOption(image_info,option+1,argv[i+1]);
6306 if (LocaleCompare("comment",option+1) == 0)
6310 (void) DeleteImageOption(image_info,option+1);
6313 (void) SetImageOption(image_info,option+1,argv[i+1]);
6316 if (LocaleCompare("compose",option+1) == 0)
6320 (void) SetImageOption(image_info,option+1,"undefined");
6323 (void) SetImageOption(image_info,option+1,argv[i+1]);
6326 if (LocaleCompare("compress",option+1) == 0)
6330 image_info->compression=UndefinedCompression;
6331 (void) SetImageOption(image_info,option+1,"undefined");
6334 image_info->compression=(CompressionType) ParseCommandOption(
6335 MagickCompressOptions,MagickFalse,argv[i+1]);
6336 (void) SetImageOption(image_info,option+1,argv[i+1]);
6343 if (LocaleCompare("debug",option+1) == 0)
6346 (void) SetLogEventMask("none");
6348 (void) SetLogEventMask(argv[i+1]);
6349 image_info->debug=IsEventLogging();
6352 if (LocaleCompare("define",option+1) == 0)
6356 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6357 (void) DeleteImageRegistry(argv[i+1]+9);
6359 (void) DeleteImageOption(image_info,argv[i+1]);
6362 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6364 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6368 (void) DefineImageOption(image_info,argv[i+1]);
6371 if (LocaleCompare("delay",option+1) == 0)
6375 (void) SetImageOption(image_info,option+1,"0");
6378 (void) SetImageOption(image_info,option+1,argv[i+1]);
6381 if (LocaleCompare("density",option+1) == 0)
6388 if (image_info->density != (char *) NULL)
6389 image_info->density=DestroyString(image_info->density);
6390 (void) SetImageOption(image_info,option+1,"72");
6393 (void) CloneString(&image_info->density,argv[i+1]);
6394 (void) SetImageOption(image_info,option+1,argv[i+1]);
6397 if (LocaleCompare("depth",option+1) == 0)
6401 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6404 image_info->depth=StringToUnsignedLong(argv[i+1]);
6407 if (LocaleCompare("direction",option+1) == 0)
6411 (void) SetImageOption(image_info,option+1,"undefined");
6414 (void) SetImageOption(image_info,option+1,argv[i+1]);
6417 if (LocaleCompare("display",option+1) == 0)
6421 if (image_info->server_name != (char *) NULL)
6422 image_info->server_name=DestroyString(
6423 image_info->server_name);
6426 (void) CloneString(&image_info->server_name,argv[i+1]);
6429 if (LocaleCompare("dispose",option+1) == 0)
6433 (void) SetImageOption(image_info,option+1,"undefined");
6436 (void) SetImageOption(image_info,option+1,argv[i+1]);
6439 if (LocaleCompare("dither",option+1) == 0)
6443 image_info->dither=MagickFalse;
6444 (void) SetImageOption(image_info,option+1,"none");
6447 (void) SetImageOption(image_info,option+1,argv[i+1]);
6448 image_info->dither=MagickTrue;
6455 if (LocaleCompare("encoding",option+1) == 0)
6459 (void) SetImageOption(image_info,option+1,"undefined");
6462 (void) SetImageOption(image_info,option+1,argv[i+1]);
6465 if (LocaleCompare("endian",option+1) == 0)
6469 image_info->endian=UndefinedEndian;
6470 (void) SetImageOption(image_info,option+1,"undefined");
6473 image_info->endian=(EndianType) ParseCommandOption(
6474 MagickEndianOptions,MagickFalse,argv[i+1]);
6475 (void) SetImageOption(image_info,option+1,argv[i+1]);
6478 if (LocaleCompare("extract",option+1) == 0)
6481 Set image extract geometry.
6485 if (image_info->extract != (char *) NULL)
6486 image_info->extract=DestroyString(image_info->extract);
6489 (void) CloneString(&image_info->extract,argv[i+1]);
6496 if (LocaleCompare("fill",option+1) == 0)
6500 (void) SetImageOption(image_info,option+1,"none");
6503 (void) SetImageOption(image_info,option+1,argv[i+1]);
6506 if (LocaleCompare("filter",option+1) == 0)
6510 (void) SetImageOption(image_info,option+1,"undefined");
6513 (void) SetImageOption(image_info,option+1,argv[i+1]);
6516 if (LocaleCompare("font",option+1) == 0)
6520 if (image_info->font != (char *) NULL)
6521 image_info->font=DestroyString(image_info->font);
6524 (void) CloneString(&image_info->font,argv[i+1]);
6527 if (LocaleCompare("format",option+1) == 0)
6532 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6533 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6534 image_info->ping=MagickFalse;
6535 (void) SetImageOption(image_info,option+1,argv[i+1]);
6538 if (LocaleCompare("fuzz",option+1) == 0)
6542 image_info->fuzz=0.0;
6543 (void) SetImageOption(image_info,option+1,"0");
6546 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6548 (void) SetImageOption(image_info,option+1,argv[i+1]);
6555 if (LocaleCompare("gravity",option+1) == 0)
6559 (void) SetImageOption(image_info,option+1,"undefined");
6562 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 if (LocaleCompare("green-primary",option+1) == 0)
6569 (void) SetImageOption(image_info,option+1,"0.0");
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6579 if (LocaleCompare("intent",option+1) == 0)
6583 (void) SetImageOption(image_info,option+1,"undefined");
6586 (void) SetImageOption(image_info,option+1,argv[i+1]);
6589 if (LocaleCompare("interlace",option+1) == 0)
6593 image_info->interlace=UndefinedInterlace;
6594 (void) SetImageOption(image_info,option+1,"undefined");
6597 image_info->interlace=(InterlaceType) ParseCommandOption(
6598 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6599 (void) SetImageOption(image_info,option+1,argv[i+1]);
6602 if (LocaleCompare("interline-spacing",option+1) == 0)
6606 (void) SetImageOption(image_info,option+1,"undefined");
6609 (void) SetImageOption(image_info,option+1,argv[i+1]);
6612 if (LocaleCompare("interpolate",option+1) == 0)
6616 (void) SetImageOption(image_info,option+1,"undefined");
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6622 if (LocaleCompare("interword-spacing",option+1) == 0)
6626 (void) SetImageOption(image_info,option+1,"undefined");
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6636 if (LocaleCompare("kerning",option+1) == 0)
6640 (void) SetImageOption(image_info,option+1,"undefined");
6643 (void) SetImageOption(image_info,option+1,argv[i+1]);
6650 if (LocaleCompare("label",option+1) == 0)
6654 (void) DeleteImageOption(image_info,option+1);
6657 (void) SetImageOption(image_info,option+1,argv[i+1]);
6660 if (LocaleCompare("limit",option+1) == 0)
6670 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6671 MagickFalse,argv[i+1]);
6672 limit=MagickResourceInfinity;
6673 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6674 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6675 (void) SetMagickResourceLimit(type,limit);
6678 if (LocaleCompare("list",option+1) == 0)
6684 Display configuration list.
6686 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6689 case MagickCoderOptions:
6691 (void) ListCoderInfo((FILE *) NULL,exception);
6694 case MagickColorOptions:
6696 (void) ListColorInfo((FILE *) NULL,exception);
6699 case MagickConfigureOptions:
6701 (void) ListConfigureInfo((FILE *) NULL,exception);
6704 case MagickDelegateOptions:
6706 (void) ListDelegateInfo((FILE *) NULL,exception);
6709 case MagickFontOptions:
6711 (void) ListTypeInfo((FILE *) NULL,exception);
6714 case MagickFormatOptions:
6716 (void) ListMagickInfo((FILE *) NULL,exception);
6719 case MagickLocaleOptions:
6721 (void) ListLocaleInfo((FILE *) NULL,exception);
6724 case MagickLogOptions:
6726 (void) ListLogInfo((FILE *) NULL,exception);
6729 case MagickMagicOptions:
6731 (void) ListMagicInfo((FILE *) NULL,exception);
6734 case MagickMimeOptions:
6736 (void) ListMimeInfo((FILE *) NULL,exception);
6739 case MagickModuleOptions:
6741 (void) ListModuleInfo((FILE *) NULL,exception);
6744 case MagickPolicyOptions:
6746 (void) ListPolicyInfo((FILE *) NULL,exception);
6749 case MagickResourceOptions:
6751 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6754 case MagickThresholdOptions:
6756 (void) ListThresholdMaps((FILE *) NULL,exception);
6761 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6768 if (LocaleCompare("log",option+1) == 0)
6772 (void) SetLogFormat(argv[i+1]);
6775 if (LocaleCompare("loop",option+1) == 0)
6779 (void) SetImageOption(image_info,option+1,"0");
6782 (void) SetImageOption(image_info,option+1,argv[i+1]);
6789 if (LocaleCompare("matte",option+1) == 0)
6793 (void) SetImageOption(image_info,option+1,"false");
6796 (void) SetImageOption(image_info,option+1,"true");
6799 if (LocaleCompare("mattecolor",option+1) == 0)
6803 (void) SetImageOption(image_info,option+1,argv[i+1]);
6804 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6805 &image_info->matte_color,exception);
6808 (void) SetImageOption(image_info,option+1,argv[i+1]);
6809 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6810 &image_info->matte_color,exception);
6813 if (LocaleCompare("monitor",option+1) == 0)
6815 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6819 if (LocaleCompare("monochrome",option+1) == 0)
6821 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6828 if (LocaleCompare("orient",option+1) == 0)
6832 image_info->orientation=UndefinedOrientation;
6833 (void) SetImageOption(image_info,option+1,"undefined");
6836 image_info->orientation=(OrientationType) ParseCommandOption(
6837 MagickOrientationOptions,MagickFalse,argv[i+1]);
6838 (void) SetImageOption(image_info,option+1,argv[i+1]);
6844 if (LocaleCompare("page",option+1) == 0)
6848 page[MaxTextExtent];
6861 (void) DeleteImageOption(image_info,option+1);
6862 (void) CloneString(&image_info->page,(char *) NULL);
6865 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6866 image_option=GetImageOption(image_info,"page");
6867 if (image_option != (const char *) NULL)
6868 flags=ParseAbsoluteGeometry(image_option,&geometry);
6869 canonical_page=GetPageGeometry(argv[i+1]);
6870 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6871 canonical_page=DestroyString(canonical_page);
6872 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6873 (unsigned long) geometry.width,(unsigned long) geometry.height);
6874 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6875 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6876 (unsigned long) geometry.width,(unsigned long) geometry.height,
6877 (long) geometry.x,(long) geometry.y);
6878 (void) SetImageOption(image_info,option+1,page);
6879 (void) CloneString(&image_info->page,page);
6882 if (LocaleCompare("ping",option+1) == 0)
6884 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6887 if (LocaleCompare("pointsize",option+1) == 0)
6890 geometry_info.rho=0.0;
6892 (void) ParseGeometry(argv[i+1],&geometry_info);
6893 image_info->pointsize=geometry_info.rho;
6896 if (LocaleCompare("precision",option+1) == 0)
6898 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6901 if (LocaleCompare("preview",option+1) == 0)
6908 image_info->preview_type=UndefinedPreview;
6911 image_info->preview_type=(PreviewType) ParseCommandOption(
6912 MagickPreviewOptions,MagickFalse,argv[i+1]);
6919 if (LocaleCompare("quality",option+1) == 0)
6922 Set image compression quality.
6926 image_info->quality=UndefinedCompressionQuality;
6927 (void) SetImageOption(image_info,option+1,"0");
6930 image_info->quality=StringToUnsignedLong(argv[i+1]);
6931 (void) SetImageOption(image_info,option+1,argv[i+1]);
6934 if (LocaleCompare("quiet",option+1) == 0)
6936 static WarningHandler
6937 warning_handler = (WarningHandler) NULL;
6942 Restore error or warning messages.
6944 warning_handler=SetWarningHandler(warning_handler);
6948 Suppress error or warning messages.
6950 warning_handler=SetWarningHandler((WarningHandler) NULL);
6957 if (LocaleCompare("red-primary",option+1) == 0)
6961 (void) SetImageOption(image_info,option+1,"0.0");
6964 (void) SetImageOption(image_info,option+1,argv[i+1]);
6971 if (LocaleCompare("sampling-factor",option+1) == 0)
6974 Set image sampling factor.
6978 if (image_info->sampling_factor != (char *) NULL)
6979 image_info->sampling_factor=DestroyString(
6980 image_info->sampling_factor);
6983 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6986 if (LocaleCompare("scene",option+1) == 0)
6993 image_info->scene=0;
6994 (void) SetImageOption(image_info,option+1,"0");
6997 image_info->scene=StringToUnsignedLong(argv[i+1]);
6998 (void) SetImageOption(image_info,option+1,argv[i+1]);
7001 if (LocaleCompare("seed",option+1) == 0)
7008 seed=(size_t) time((time_t *) NULL);
7009 SetRandomSecretKey(seed);
7012 seed=StringToUnsignedLong(argv[i+1]);
7013 SetRandomSecretKey(seed);
7016 if (LocaleCompare("size",option+1) == 0)
7020 if (image_info->size != (char *) NULL)
7021 image_info->size=DestroyString(image_info->size);
7024 (void) CloneString(&image_info->size,argv[i+1]);
7027 if (LocaleCompare("stroke",option+1) == 0)
7031 (void) SetImageOption(image_info,option+1,"none");
7034 (void) SetImageOption(image_info,option+1,argv[i+1]);
7037 if (LocaleCompare("strokewidth",option+1) == 0)
7041 (void) SetImageOption(image_info,option+1,"0");
7044 (void) SetImageOption(image_info,option+1,argv[i+1]);
7047 if (LocaleCompare("synchronize",option+1) == 0)
7051 image_info->synchronize=MagickFalse;
7054 image_info->synchronize=MagickTrue;
7061 if (LocaleCompare("taint",option+1) == 0)
7065 (void) SetImageOption(image_info,option+1,"false");
7068 (void) SetImageOption(image_info,option+1,"true");
7071 if (LocaleCompare("texture",option+1) == 0)
7075 if (image_info->texture != (char *) NULL)
7076 image_info->texture=DestroyString(image_info->texture);
7079 (void) CloneString(&image_info->texture,argv[i+1]);
7082 if (LocaleCompare("tile-offset",option+1) == 0)
7085 (void) SetImageOption(image_info,option+1,"0");
7087 (void) SetImageOption(image_info,option+1,argv[i+1]);
7090 if (LocaleCompare("transparent-color",option+1) == 0)
7094 (void) QueryColorCompliance("none",AllCompliance,
7095 &image_info->transparent_color,exception);
7096 (void) SetImageOption(image_info,option+1,"none");
7099 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7100 &image_info->transparent_color,exception);
7101 (void) SetImageOption(image_info,option+1,argv[i+1]);
7104 if (LocaleCompare("type",option+1) == 0)
7108 image_info->type=UndefinedType;
7109 (void) SetImageOption(image_info,option+1,"undefined");
7112 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7113 MagickFalse,argv[i+1]);
7114 (void) SetImageOption(image_info,option+1,argv[i+1]);
7121 if (LocaleCompare("undercolor",option+1) == 0)
7124 (void) DeleteImageOption(image_info,option+1);
7126 (void) SetImageOption(image_info,option+1,argv[i+1]);
7129 if (LocaleCompare("units",option+1) == 0)
7133 image_info->units=UndefinedResolution;
7134 (void) SetImageOption(image_info,option+1,"undefined");
7137 image_info->units=(ResolutionType) ParseCommandOption(
7138 MagickResolutionOptions,MagickFalse,argv[i+1]);
7139 (void) SetImageOption(image_info,option+1,argv[i+1]);
7146 if (LocaleCompare("verbose",option+1) == 0)
7150 image_info->verbose=MagickFalse;
7153 image_info->verbose=MagickTrue;
7154 image_info->ping=MagickFalse;
7157 if (LocaleCompare("view",option+1) == 0)
7161 if (image_info->view != (char *) NULL)
7162 image_info->view=DestroyString(image_info->view);
7165 (void) CloneString(&image_info->view,argv[i+1]);
7168 if (LocaleCompare("virtual-pixel",option+1) == 0)
7171 (void) SetImageOption(image_info,option+1,"undefined");
7173 (void) SetImageOption(image_info,option+1,argv[i+1]);
7180 if (LocaleCompare("white-point",option+1) == 0)
7183 (void) SetImageOption(image_info,option+1,"0.0");
7185 (void) SetImageOption(image_info,option+1,argv[i+1]);
7199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7203 + M o g r i f y I m a g e L i s t %
7207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7209 % MogrifyImageList() applies any command line options that might affect the
7210 % entire image list (e.g. -append, -coalesce, etc.).
7212 % The format of the MogrifyImage method is:
7214 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7215 % const char **argv,Image **images,ExceptionInfo *exception)
7217 % A description of each parameter follows:
7219 % o image_info: the image info..
7221 % o argc: Specifies a pointer to an integer describing the number of
7222 % elements in the argument vector.
7224 % o argv: Specifies a pointer to a text array containing the command line
7227 % o images: pointer to pointer of the first image in image list.
7229 % o exception: return any errors or warnings in this structure.
7232 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7233 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7244 PixelInterpolateMethod
7258 Apply options to the image list.
7260 assert(image_info != (ImageInfo *) NULL);
7261 assert(image_info->signature == MagickSignature);
7262 assert(images != (Image **) NULL);
7263 assert((*images)->previous == (Image *) NULL);
7264 assert((*images)->signature == MagickSignature);
7265 if ((*images)->debug != MagickFalse)
7266 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7267 (*images)->filename);
7268 if ((argc <= 0) || (*argv == (char *) NULL))
7270 interpolate_method=UndefinedInterpolatePixel;
7271 mogrify_info=CloneImageInfo(image_info);
7272 quantize_info=AcquireQuantizeInfo(mogrify_info);
7274 for (i=0; i < (ssize_t) argc; i++)
7276 if (*images == (Image *) NULL)
7279 if (IsCommandOption(option) == MagickFalse)
7281 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7282 count=MagickMax(count,0L);
7283 if ((i+count) >= (ssize_t) argc)
7285 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7286 switch (*(option+1))
7290 if (LocaleCompare("affinity",option+1) == 0)
7292 (void) SyncImagesSettings(mogrify_info,*images,exception);
7295 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7302 if (LocaleCompare("append",option+1) == 0)
7307 (void) SyncImagesSettings(mogrify_info,*images,exception);
7308 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7309 MagickFalse,exception);
7310 if (append_image == (Image *) NULL)
7315 *images=DestroyImageList(*images);
7316 *images=append_image;
7319 if (LocaleCompare("average",option+1) == 0)
7325 Average an image sequence (deprecated).
7327 (void) SyncImagesSettings(mogrify_info,*images,exception);
7328 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7330 if (average_image == (Image *) NULL)
7335 *images=DestroyImageList(*images);
7336 *images=average_image;
7343 if (LocaleCompare("channel-fx",option+1) == 0)
7348 (void) SyncImagesSettings(mogrify_info,*images,exception);
7349 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7350 if (channel_image == (Image *) NULL)
7355 *images=DestroyImageList(*images);
7356 *images=channel_image;
7359 if (LocaleCompare("clut",option+1) == 0)
7365 (void) SyncImagesSettings(mogrify_info,*images,exception);
7366 image=RemoveFirstImageFromList(images);
7367 clut_image=RemoveFirstImageFromList(images);
7368 if (clut_image == (Image *) NULL)
7373 (void) ClutImage(image,clut_image,interpolate_method,exception);
7374 clut_image=DestroyImage(clut_image);
7375 *images=DestroyImageList(*images);
7379 if (LocaleCompare("coalesce",option+1) == 0)
7384 (void) SyncImagesSettings(mogrify_info,*images,exception);
7385 coalesce_image=CoalesceImages(*images,exception);
7386 if (coalesce_image == (Image *) NULL)
7391 *images=DestroyImageList(*images);
7392 *images=coalesce_image;
7395 if (LocaleCompare("combine",option+1) == 0)
7400 (void) SyncImagesSettings(mogrify_info,*images,exception);
7401 combine_image=CombineImages(*images,exception);
7402 if (combine_image == (Image *) NULL)
7407 *images=DestroyImageList(*images);
7408 *images=combine_image;
7411 if (LocaleCompare("composite",option+1) == 0)
7427 (void) SyncImagesSettings(mogrify_info,*images,exception);
7428 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7429 if (value == (const char *) NULL)
7430 clip_to_self=MagickTrue;
7432 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7433 "compose:clip-to-self")); /* if this is true */
7434 if (IsMagickFalse(clip_to_self)) /* or */
7435 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption(
7436 mogrify_info,"compose:outside-overlay"))); /* this false */
7437 image=RemoveFirstImageFromList(images);
7438 composite_image=RemoveFirstImageFromList(images);
7439 if (composite_image == (Image *) NULL)
7444 (void) TransformImage(&composite_image,(char *) NULL,
7445 composite_image->geometry,exception);
7446 SetGeometry(composite_image,&geometry);
7447 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7448 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7450 mask_image=RemoveFirstImageFromList(images);
7451 if (mask_image != (Image *) NULL)
7453 if ((image->compose == DisplaceCompositeOp) ||
7454 (image->compose == DistortCompositeOp))
7457 Merge Y displacement into X displacement image.
7459 (void) CompositeImage(composite_image,mask_image,
7460 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7461 mask_image=DestroyImage(mask_image);
7466 Set a blending mask for the composition.
7468 (void) NegateImage(mask_image,MagickFalse,exception);
7469 (void) SetImageMask(image,mask_image,exception);
7470 mask_image=DestroyImage(mask_image);
7473 (void) CompositeImage(image,composite_image,image->compose,
7474 clip_to_self,geometry.x,geometry.y,exception);
7475 (void) SetImageMask(image,(Image *) NULL,exception);
7476 composite_image=DestroyImage(composite_image);
7477 *images=DestroyImageList(*images);
7485 if (LocaleCompare("deconstruct",option+1) == 0)
7490 (void) SyncImagesSettings(mogrify_info,*images,exception);
7491 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7493 if (deconstruct_image == (Image *) NULL)
7498 *images=DestroyImageList(*images);
7499 *images=deconstruct_image;
7502 if (LocaleCompare("delete",option+1) == 0)
7505 DeleteImages(images,"-1",exception);
7507 DeleteImages(images,argv[i+1],exception);
7510 if (LocaleCompare("dither",option+1) == 0)
7514 quantize_info->dither=MagickFalse;
7517 quantize_info->dither=MagickTrue;
7518 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7519 MagickDitherOptions,MagickFalse,argv[i+1]);
7522 if (LocaleCompare("duplicate",option+1) == 0)
7528 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7537 number_duplicates=(size_t) StringToLong(argv[i+1]);
7538 p=strchr(argv[i+1],',');
7539 if (p == (const char *) NULL)
7540 duplicate_images=DuplicateImages(*images,number_duplicates,
7543 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7546 AppendImageToList(images, duplicate_images);
7547 (void) SyncImagesSettings(mogrify_info,*images,exception);
7554 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7559 MagickEvaluateOperator
7562 (void) SyncImageSettings(mogrify_info,*images,exception);
7563 op=(MagickEvaluateOperator) ParseCommandOption(
7564 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7565 evaluate_image=EvaluateImages(*images,op,exception);
7566 if (evaluate_image == (Image *) NULL)
7571 *images=DestroyImageList(*images);
7572 *images=evaluate_image;
7579 if (LocaleCompare("fft",option+1) == 0)
7585 Implements the discrete Fourier transform (DFT).
7587 (void) SyncImageSettings(mogrify_info,*images,exception);
7588 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7589 MagickTrue : MagickFalse,exception);
7590 if (fourier_image == (Image *) NULL)
7592 *images=DestroyImage(*images);
7593 *images=fourier_image;
7596 if (LocaleCompare("flatten",option+1) == 0)
7601 (void) SyncImagesSettings(mogrify_info,*images,exception);
7602 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7603 if (flatten_image == (Image *) NULL)
7605 *images=DestroyImageList(*images);
7606 *images=flatten_image;
7609 if (LocaleCompare("fx",option+1) == 0)
7614 (void) SyncImagesSettings(mogrify_info,*images,exception);
7615 fx_image=FxImage(*images,argv[i+1],exception);
7616 if (fx_image == (Image *) NULL)
7621 *images=DestroyImageList(*images);
7629 if (LocaleCompare("hald-clut",option+1) == 0)
7635 (void) SyncImagesSettings(mogrify_info,*images,exception);
7636 image=RemoveFirstImageFromList(images);
7637 hald_image=RemoveFirstImageFromList(images);
7638 if (hald_image == (Image *) NULL)
7643 (void) HaldClutImage(image,hald_image,exception);
7644 hald_image=DestroyImage(hald_image);
7645 if (*images != (Image *) NULL)
7646 *images=DestroyImageList(*images);
7654 if (LocaleCompare("ift",option+1) == 0)
7662 Implements the inverse fourier discrete Fourier transform (DFT).
7664 (void) SyncImagesSettings(mogrify_info,*images,exception);
7665 magnitude_image=RemoveFirstImageFromList(images);
7666 phase_image=RemoveFirstImageFromList(images);
7667 if (phase_image == (Image *) NULL)
7672 fourier_image=InverseFourierTransformImage(magnitude_image,
7673 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7674 if (fourier_image == (Image *) NULL)
7676 if (*images != (Image *) NULL)
7677 *images=DestroyImage(*images);
7678 *images=fourier_image;
7681 if (LocaleCompare("insert",option+1) == 0)
7689 index=(ssize_t) StringToLong(argv[i+1]);
7690 p=RemoveLastImageFromList(images);
7691 if (p == (Image *) NULL)
7693 (void) ThrowMagickException(exception,GetMagickModule(),
7694 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7700 PrependImageToList(images,q);
7702 if (index == (ssize_t) GetImageListLength(*images))
7703 AppendImageToList(images,q);
7706 q=GetImageFromList(*images,index-1);
7707 if (q == (Image *) NULL)
7709 (void) ThrowMagickException(exception,GetMagickModule(),
7710 OptionError,"NoSuchImage","'%s'",argv[i+1]);
7714 InsertImageInList(&q,p);
7716 *images=GetFirstImageInList(q);
7719 if (LocaleCompare("interpolate",option+1) == 0)
7721 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7722 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7729 if (LocaleCompare("layers",option+1) == 0)
7737 (void) SyncImagesSettings(mogrify_info,*images,exception);
7738 layers=(Image *) NULL;
7739 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7740 MagickFalse,argv[i+1]);
7745 layers=CoalesceImages(*images,exception);
7748 case CompareAnyLayer:
7749 case CompareClearLayer:
7750 case CompareOverlayLayer:
7753 layers=CompareImagesLayers(*images,method,exception);
7759 case TrimBoundsLayer:
7761 layers=MergeImageLayers(*images,method,exception);
7766 layers=DisposeImages(*images,exception);
7769 case OptimizeImageLayer:
7771 layers=OptimizeImageLayers(*images,exception);
7774 case OptimizePlusLayer:
7776 layers=OptimizePlusImageLayers(*images,exception);
7779 case OptimizeTransLayer:
7781 OptimizeImageTransparency(*images,exception);
7784 case RemoveDupsLayer:
7786 RemoveDuplicateLayers(images,exception);
7789 case RemoveZeroLayer:
7791 RemoveZeroDelayLayers(images,exception);
7797 General Purpose, GIF Animation Optimizer.
7799 layers=CoalesceImages(*images,exception);
7800 if (layers == (Image *) NULL)
7805 *images=DestroyImageList(*images);
7807 layers=OptimizeImageLayers(*images,exception);
7808 if (layers == (Image *) NULL)
7813 *images=DestroyImageList(*images);
7815 layers=(Image *) NULL;
7816 OptimizeImageTransparency(*images,exception);
7817 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7821 case CompositeLayer:
7833 Split image sequence at the first 'NULL:' image.
7836 while (source != (Image *) NULL)
7838 source=GetNextImageInList(source);
7839 if ((source != (Image *) NULL) &&
7840 (LocaleCompare(source->magick,"NULL") == 0))
7843 if (source != (Image *) NULL)
7845 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7846 (GetNextImageInList(source) == (Image *) NULL))
7847 source=(Image *) NULL;
7851 Separate the two lists, junk the null: image.
7853 source=SplitImageList(source->previous);
7854 DeleteImageFromList(&source);
7857 if (source == (Image *) NULL)
7859 (void) ThrowMagickException(exception,GetMagickModule(),
7860 OptionError,"MissingNullSeparator","layers Composite");
7865 Adjust offset with gravity and virtual canvas.
7867 SetGeometry(*images,&geometry);
7868 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7869 geometry.width=source->page.width != 0 ?
7870 source->page.width : source->columns;
7871 geometry.height=source->page.height != 0 ?
7872 source->page.height : source->rows;
7873 GravityAdjustGeometry((*images)->page.width != 0 ?
7874 (*images)->page.width : (*images)->columns,
7875 (*images)->page.height != 0 ? (*images)->page.height :
7876 (*images)->rows,(*images)->gravity,&geometry);
7877 compose=OverCompositeOp;
7878 option=GetImageOption(mogrify_info,"compose");
7879 if (option != (const char *) NULL)
7880 compose=(CompositeOperator) ParseCommandOption(
7881 MagickComposeOptions,MagickFalse,option);
7882 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7884 source=DestroyImageList(source);
7888 if (layers == (Image *) NULL)
7890 *images=DestroyImageList(*images);
7898 if (LocaleCompare("map",option+1) == 0)
7900 (void) SyncImagesSettings(mogrify_info,*images,exception);
7903 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7910 if (LocaleCompare("maximum",option+1) == 0)
7916 Maximum image sequence (deprecated).
7918 (void) SyncImagesSettings(mogrify_info,*images,exception);
7919 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7920 if (maximum_image == (Image *) NULL)
7925 *images=DestroyImageList(*images);
7926 *images=maximum_image;
7929 if (LocaleCompare("minimum",option+1) == 0)
7935 Minimum image sequence (deprecated).
7937 (void) SyncImagesSettings(mogrify_info,*images,exception);
7938 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7939 if (minimum_image == (Image *) NULL)
7944 *images=DestroyImageList(*images);
7945 *images=minimum_image;
7948 if (LocaleCompare("morph",option+1) == 0)
7953 (void) SyncImagesSettings(mogrify_info,*images,exception);
7954 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7956 if (morph_image == (Image *) NULL)
7961 *images=DestroyImageList(*images);
7962 *images=morph_image;
7965 if (LocaleCompare("mosaic",option+1) == 0)
7970 (void) SyncImagesSettings(mogrify_info,*images,exception);
7971 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7972 if (mosaic_image == (Image *) NULL)
7977 *images=DestroyImageList(*images);
7978 *images=mosaic_image;
7985 if (LocaleCompare("print",option+1) == 0)
7990 (void) SyncImagesSettings(mogrify_info,*images,exception);
7991 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7993 if (string == (char *) NULL)
7995 (void) FormatLocaleFile(stdout,"%s",string);
7996 string=DestroyString(string);
7998 if (LocaleCompare("process",option+1) == 0)
8007 (void) SyncImagesSettings(mogrify_info,*images,exception);
8008 arguments=StringToArgv(argv[i+1],&number_arguments);
8009 if (arguments == (char **) NULL)
8011 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8032 Support old style syntax, filter="-option arg".
8034 length=strlen(argv[i+1]);
8035 token=(char *) NULL;
8036 if (~length >= (MaxTextExtent-1))
8037 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8039 if (token == (char *) NULL)
8042 arguments=argv[i+1];
8043 token_info=AcquireTokenInfo();
8044 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8045 "\"",'\0',&breaker,&next,"e);
8046 token_info=DestroyTokenInfo(token_info);
8052 argv=(&(arguments[next]));
8053 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8056 token=DestroyString(token);
8059 (void) SubstituteString(&arguments[1],"-","");
8060 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8061 number_arguments-2,(const char **) arguments+2,exception);
8062 for (j=0; j < number_arguments; j++)
8063 arguments[j]=DestroyString(arguments[j]);
8064 arguments=(char **) RelinquishMagickMemory(arguments);
8071 if (LocaleCompare("reverse",option+1) == 0)
8073 ReverseImageList(images);
8080 if (LocaleCompare("smush",option+1) == 0)
8088 (void) SyncImagesSettings(mogrify_info,*images,exception);
8089 offset=(ssize_t) StringToLong(argv[i+1]);
8090 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8091 MagickFalse,offset,exception);
8092 if (smush_image == (Image *) NULL)
8097 *images=DestroyImageList(*images);
8098 *images=smush_image;
8101 if (LocaleCompare("swap",option+1) == 0)
8122 flags=ParseGeometry(argv[i+1],&geometry_info);
8123 index=(ssize_t) geometry_info.rho;
8124 if ((flags & SigmaValue) != 0)
8125 swap_index=(ssize_t) geometry_info.sigma;
8127 p=GetImageFromList(*images,index);
8128 q=GetImageFromList(*images,swap_index);
8129 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8131 (void) ThrowMagickException(exception,GetMagickModule(),
8132 OptionError,"NoSuchImage","'%s'",(*images)->filename);
8138 swap=CloneImage(p,0,0,MagickTrue,exception);
8139 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8140 ReplaceImageInList(&q,swap);
8141 *images=GetFirstImageInList(q);
8148 if (LocaleCompare("write",option+1) == 0)
8159 (void) SyncImagesSettings(mogrify_info,*images,exception);
8160 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8161 (void) DeleteImageRegistry(key);
8162 write_images=(*images);
8164 write_images=CloneImageList(*images,exception);
8165 write_info=CloneImageInfo(mogrify_info);
8166 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8167 write_info=DestroyImageInfo(write_info);
8169 write_images=DestroyImageList(write_images);
8179 quantize_info=DestroyQuantizeInfo(quantize_info);
8180 mogrify_info=DestroyImageInfo(mogrify_info);
8181 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8182 return(status != 0 ? MagickTrue : MagickFalse);
8186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8190 + M o g r i f y I m a g e s %
8194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8196 % MogrifyImages() applies image processing options to a sequence of images as
8197 % prescribed by command line options.
8199 % The format of the MogrifyImage method is:
8201 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8202 % const MagickBooleanType post,const int argc,const char **argv,
8203 % Image **images,Exceptioninfo *exception)
8205 % A description of each parameter follows:
8207 % o image_info: the image info..
8209 % o post: If true, post process image list operators otherwise pre-process.
8211 % o argc: Specifies a pointer to an integer describing the number of
8212 % elements in the argument vector.
8214 % o argv: Specifies a pointer to a text array containing the command line
8217 % o images: pointer to a pointer of the first image in image list.
8219 % o exception: return any errors or warnings in this structure.
8222 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8223 const MagickBooleanType post,const int argc,const char **argv,
8224 Image **images,ExceptionInfo *exception)
8226 #define MogrifyImageTag "Mogrify/Image"
8240 assert(image_info != (ImageInfo *) NULL);
8241 assert(image_info->signature == MagickSignature);
8242 if (images == (Image **) NULL)
8243 return(MogrifyImage(image_info,argc,argv,images,exception));
8244 assert((*images)->previous == (Image *) NULL);
8245 assert((*images)->signature == MagickSignature);
8246 if ((*images)->debug != MagickFalse)
8247 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8248 (*images)->filename);
8249 if ((argc <= 0) || (*argv == (char *) NULL))
8251 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8256 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8261 Pre-process multi-image sequence operators
8263 if (post == MagickFalse)
8264 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8266 For each image, process simple single image operators
8269 n=GetImageListLength(*images);
8273 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8274 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8276 status&=MogrifyImage(image_info,argc,argv,images,exception);
8277 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8278 if (proceed == MagickFalse)
8280 if ( (*images)->next == (Image *) NULL )
8282 *images=(*images)->next;
8285 assert( *images != (Image *) NULL );
8287 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8288 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8292 Post-process, multi-image sequence operators
8294 *images=GetFirstImageInList(*images);
8295 if (post != MagickFalse)
8296 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8297 return(status != 0 ? MagickTrue : MagickFalse);