2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % OOO PPPP EEEE RRRR AA TTTTTT III OOO N N %
7 % O O P P E R R A A TT I O O NN N %
8 % O O PPPP EEE RRRR AAAA TT I O O N N N %
9 % O O P E R R A A TT I O O N NN %
10 % OOO P EEEE R RR A A TT III OOO N N %
13 % MagickWand Module Methods %
20 % Copyright 1999-2011 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 % Apply the given options (settings, and simple, or sequence operations) to
37 % the given image(s) according to the current "image_info" and "draw_info"
40 % The final goal is to allow the execution in a strict one option at a time
41 % manner that is needed for 'pipelining and file scripting' of options in
44 % Anthony Thyssen, Sept 2011
51 #include "MagickWand/studio.h"
52 #include "MagickWand/MagickWand.h"
53 #include "MagickWand/mogrify-private.h"
54 #include "MagickCore/monitor-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/string-private.h"
61 #define UndefinedCompressionQuality 0UL
63 Constant declaration. (temporary exports)
66 BackgroundColor[] = "#fff", /* white */
67 BorderColor[] = "#dfdfdf", /* gray */
68 MatteColor[] = "#bdbdbd"; /* gray */
71 ** Function to report on the progress of image operations
73 static MagickBooleanType MonitorProgress(const char *text,
74 const MagickOffsetType offset,const MagickSizeType extent,
75 void *wand_unused(client_data))
78 message[MaxTextExtent],
89 (void) CopyMagickMemory(tag,text,MaxTextExtent);
91 if (p != (char *) NULL)
93 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
94 locale_message=GetLocaleMessage(message);
95 if (locale_message == message)
97 if (p == (char *) NULL)
98 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
99 locale_message,(long) offset,(unsigned long) extent,(long)
100 (100L*offset/(extent-1)));
102 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
103 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
104 (100L*offset/(extent-1)));
105 if (offset == (MagickOffsetType) (extent-1))
106 (void) FormatLocaleFile(stderr,"\n");
107 (void) fflush(stderr);
112 ** GetImageCache() will read an image into a image cache if not already
113 ** present then return the image that is in the cache under that filename.
115 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
116 ExceptionInfo *exception)
130 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
131 sans_exception=AcquireExceptionInfo();
132 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
133 sans_exception=DestroyExceptionInfo(sans_exception);
134 if (image != (Image *) NULL)
136 read_info=CloneImageInfo(image_info);
137 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
138 image=ReadImage(read_info,exception);
139 read_info=DestroyImageInfo(read_info);
140 if (image != (Image *) NULL)
141 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
146 ** SparseColorOption() parse the complex -sparse-color argument into an
147 ** an array of floating point values than call SparseColorImage().
148 ** Argument is a complex mix of floating-point pixel coodinates, and color
149 ** specifications (or direct floating point numbers). The number of floats
150 ** needed to represent a color varies depending on teh current channel
153 static Image *SparseColorOption(const Image *image,
154 const SparseColorMethod method,const char *arguments,
155 const MagickBooleanType color_from_image,ExceptionInfo *exception)
158 token[MaxTextExtent];
182 assert(image != (Image *) NULL);
183 assert(image->signature == MagickSignature);
184 if (image->debug != MagickFalse)
185 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
186 assert(exception != (ExceptionInfo *) NULL);
187 assert(exception->signature == MagickSignature);
189 Limit channels according to image - and add up number of color channel.
192 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
194 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
196 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
198 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
199 (image->colorspace == CMYKColorspace))
201 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
202 (image->matte != MagickFalse))
206 Read string, to determine number of arguments needed,
212 GetMagickToken(p,&p,token);
213 if ( token[0] == ',' ) continue;
214 if ( isalpha((int) token[0]) || token[0] == '#' ) {
215 if ( color_from_image ) {
216 (void) ThrowMagickException(exception,GetMagickModule(),
217 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
218 "Color arg given, when colors are coming from image");
219 return( (Image *)NULL);
221 x += number_colors; /* color argument */
224 x++; /* floating point argument */
228 if ( color_from_image ) {
229 /* just the control points are being given */
230 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
231 number_arguments=(x/2)*(2+number_colors);
234 /* control points and color values */
235 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
239 (void) ThrowMagickException(exception,GetMagickModule(),
240 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
241 "Invalid number of Arguments");
242 return( (Image *)NULL);
245 /* Allocate and fill in the floating point arguments */
246 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
247 sizeof(*sparse_arguments));
248 if (sparse_arguments == (double *) NULL) {
249 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
250 "MemoryAllocationFailed","%s","SparseColorOption");
251 return( (Image *)NULL);
253 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
254 sizeof(*sparse_arguments));
257 while( *p != '\0' && x < number_arguments ) {
259 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
260 if ( token[0] == '\0' ) break;
261 if ( isalpha((int) token[0]) || token[0] == '#' ) {
262 (void) ThrowMagickException(exception,GetMagickModule(),
263 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
264 "Color found, instead of X-coord");
268 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
270 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
271 if ( token[0] == '\0' ) break;
272 if ( isalpha((int) token[0]) || token[0] == '#' ) {
273 (void) ThrowMagickException(exception,GetMagickModule(),
274 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
275 "Color found, instead of Y-coord");
279 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
280 /* color values for this control point */
282 if ( (color_from_image ) {
283 /* get color from image */
289 /* color name or function given in string argument */
290 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
291 if ( token[0] == '\0' ) break;
292 if ( isalpha((int) token[0]) || token[0] == '#' ) {
293 /* Color string given */
294 (void) QueryMagickColorCompliance(token,&color,exception);
295 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
296 sparse_arguments[x++] = QuantumScale*color.red;
297 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
298 sparse_arguments[x++] = QuantumScale*color.green;
299 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
300 sparse_arguments[x++] = QuantumScale*color.blue;
301 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
302 (image->colorspace == CMYKColorspace))
303 sparse_arguments[x++] = QuantumScale*color.black;
304 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
305 (image->matte != MagickFalse))
306 sparse_arguments[x++] = QuantumScale*color.alpha;
309 /* Colors given as a set of floating point values - experimental */
310 /* NB: token contains the first floating point value to use! */
311 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
313 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
314 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
316 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
317 token[0] = ','; /* used this token - get another */
319 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
321 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
322 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
324 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
325 token[0] = ','; /* used this token - get another */
327 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
329 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
330 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
332 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
333 token[0] = ','; /* used this token - get another */
335 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
336 (image->colorspace == CMYKColorspace))
338 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
339 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
341 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
342 token[0] = ','; /* used this token - get another */
344 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
345 (image->matte != MagickFalse))
347 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
348 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
350 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
351 token[0] = ','; /* used this token - get another */
356 if ( number_arguments != x && !error ) {
357 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
358 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
359 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
360 return( (Image *)NULL);
363 return( (Image *)NULL);
365 /* Call the Interpolation function with the parsed arguments */
366 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
368 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
369 return( sparse_image );
373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 + S e t t i n g s O p t i o n I n f o %
381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 % SettingsOptionInfo() saves the given single settings argv[0] into a
384 % ImageInfo structure for later use by various image processing operations.
386 % The format of the SettingsOptionInfo method is:
388 % MagickBooleanType SettingsOptionInfo(ImageInfo *image_info,
389 % const int argc, const char **argv,ExceptionInfo *exception)
391 % A description of each parameter follows:
393 % o image_info: the image info..
395 % o argc: Specifies a pointer to an integer describing the number of
396 % elements in the argument vector.
398 % o argv: Specifies a pointer to a text array containing the command line
401 % o exception: return any errors or warnings in this structure.
404 WandExport MagickBooleanType SettingsOptionInfo(ImageInfo *image_info,
405 const int argc,const char **argv,ExceptionInfo *exception)
411 Initialize method variables.
413 assert(image_info != (ImageInfo *) NULL);
414 assert(image_info->signature == MagickSignature);
415 if (image_info->debug != MagickFalse)
416 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
417 image_info->filename);
421 Set the image settings for one image.
423 switch (*(argv[0]+1))
427 if (LocaleCompare("adjoin",argv[0]+1) == 0)
429 image_info->adjoin=(*argv[0] == '-') ? MagickTrue : MagickFalse;
432 if (LocaleCompare("antialias",argv[0]+1) == 0)
434 image_info->antialias=(*argv[0] == '-') ? MagickTrue : MagickFalse;
437 if (LocaleCompare("attenuate",argv[0]+1) == 0)
441 (void) DeleteImageOption(image_info,argv[0]+1);
444 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
447 if (LocaleCompare("authenticate",argv[0]+1) == 0)
450 (void) CloneString(&image_info->authenticate,(char *) NULL);
452 (void) CloneString(&image_info->authenticate,argv[1]);
459 if (LocaleCompare("background",argv[0]+1) == 0)
463 (void) DeleteImageOption(image_info,argv[0]+1);
464 (void) QueryColorCompliance(BackgroundColor,
465 &image_info->background_color,exception);
468 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
469 (void) QueryColorCompliance(argv[1],&image_info->background_color,
473 if (LocaleCompare("bias",argv[0]+1) == 0)
477 (void) SetImageOption(image_info,argv[0]+1,"0.0");
480 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
483 if (LocaleCompare("black-point-compensation",argv[0]+1) == 0)
487 (void) SetImageOption(image_info,argv[0]+1,"false");
490 (void) SetImageOption(image_info,argv[0]+1,"true");
493 if (LocaleCompare("blue-primary",argv[0]+1) == 0)
497 (void) SetImageOption(image_info,argv[0]+1,"0.0");
500 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
503 if (LocaleCompare("bordercolor",argv[0]+1) == 0)
507 (void) DeleteImageOption(image_info,argv[0]+1);
508 (void) QueryColorCompliance(BorderColor,&image_info->border_color,
512 (void) QueryColorCompliance(argv[1],&image_info->border_color,
514 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
517 if (LocaleCompare("box",argv[0]+1) == 0)
521 (void) SetImageOption(image_info,"undercolor","none");
524 (void) SetImageOption(image_info,"undercolor",argv[1]);
531 if (LocaleCompare("cache",argv[0]+1) == 0)
536 limit=MagickResourceInfinity;
537 if (LocaleCompare("unlimited",argv[1]) != 0)
538 limit=(MagickSizeType) SiPrefixToDouble(argv[1],100.0);
539 (void) SetMagickResourceLimit(MemoryResource,limit);
540 (void) SetMagickResourceLimit(MapResource,2*limit);
543 if (LocaleCompare("caption",argv[0]+1) == 0)
547 (void) DeleteImageOption(image_info,argv[0]+1);
550 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
553 if (LocaleCompare("channel",argv[0]+1) == 0)
557 image_info->channel=DefaultChannels;
560 image_info->channel=(ChannelType) ParseChannelOption(argv[1]);
563 if (LocaleCompare("colors",argv[0]+1) == 0)
565 image_info->colors=StringToUnsignedLong(argv[1]);
568 if (LocaleCompare("colorspace",argv[0]+1) == 0)
572 image_info->colorspace=UndefinedColorspace;
573 (void) SetImageOption(image_info,argv[0]+1,"undefined");
576 image_info->colorspace=(ColorspaceType) ParseCommandOption(
577 MagickColorspaceOptions,MagickFalse,argv[1]);
578 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
581 if (LocaleCompare("comment",argv[0]+1) == 0)
585 (void) DeleteImageOption(image_info,argv[0]+1);
588 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
591 if (LocaleCompare("compose",argv[0]+1) == 0)
595 (void) SetImageOption(image_info,argv[0]+1,"undefined");
598 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
601 if (LocaleCompare("compress",argv[0]+1) == 0)
605 image_info->compression=UndefinedCompression;
606 (void) SetImageOption(image_info,argv[0]+1,"undefined");
609 image_info->compression=(CompressionType) ParseCommandOption(
610 MagickCompressOptions,MagickFalse,argv[1]);
611 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
618 if (LocaleCompare("debug",argv[0]+1) == 0)
621 (void) SetLogEventMask("none");
623 (void) SetLogEventMask(argv[1]);
624 image_info->debug=IsEventLogging();
627 if (LocaleCompare("define",argv[0]+1) == 0)
631 if (LocaleNCompare(argv[1],"registry:",9) == 0)
632 (void) DeleteImageRegistry(argv[1]+9);
634 (void) DeleteImageOption(image_info,argv[1]);
637 if (LocaleNCompare(argv[1],"registry:",9) == 0)
639 (void) DefineImageRegistry(StringRegistryType,argv[1]+9,
643 (void) DefineImageOption(image_info,argv[1]);
646 if (LocaleCompare("delay",argv[0]+1) == 0)
650 (void) SetImageOption(image_info,argv[0]+1,"0");
653 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
656 if (LocaleCompare("density",argv[0]+1) == 0)
663 if (image_info->density != (char *) NULL)
664 image_info->density=DestroyString(image_info->density);
665 (void) SetImageOption(image_info,argv[0]+1,"72");
668 (void) CloneString(&image_info->density,argv[1]);
669 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
672 if (LocaleCompare("depth",argv[0]+1) == 0)
676 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
679 image_info->depth=StringToUnsignedLong(argv[1]);
682 if (LocaleCompare("direction",argv[0]+1) == 0)
686 (void) SetImageOption(image_info,argv[0]+1,"undefined");
689 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
692 if (LocaleCompare("display",argv[0]+1) == 0)
696 if (image_info->server_name != (char *) NULL)
697 image_info->server_name=DestroyString(
698 image_info->server_name);
701 (void) CloneString(&image_info->server_name,argv[1]);
704 if (LocaleCompare("dispose",argv[0]+1) == 0)
708 (void) SetImageOption(image_info,argv[0]+1,"undefined");
711 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
714 if (LocaleCompare("dither",argv[0]+1) == 0)
718 image_info->dither=MagickFalse;
719 (void) SetImageOption(image_info,argv[0]+1,"none");
722 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
723 image_info->dither=MagickTrue;
730 if (LocaleCompare("encoding",argv[0]+1) == 0)
734 (void) SetImageOption(image_info,argv[0]+1,"undefined");
737 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
740 if (LocaleCompare("endian",argv[0]+1) == 0)
744 image_info->endian=UndefinedEndian;
745 (void) SetImageOption(image_info,argv[0]+1,"undefined");
748 image_info->endian=(EndianType) ParseCommandOption(
749 MagickEndianOptions,MagickFalse,argv[1]);
750 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
753 if (LocaleCompare("extract",argv[0]+1) == 0)
756 Set image extract geometry.
760 if (image_info->extract != (char *) NULL)
761 image_info->extract=DestroyString(image_info->extract);
764 (void) CloneString(&image_info->extract,argv[1]);
771 if (LocaleCompare("fill",argv[0]+1) == 0)
775 (void) SetImageOption(image_info,argv[0]+1,"none");
778 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
781 if (LocaleCompare("filter",argv[0]+1) == 0)
785 (void) SetImageOption(image_info,argv[0]+1,"undefined");
788 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
791 if (LocaleCompare("font",argv[0]+1) == 0)
795 if (image_info->font != (char *) NULL)
796 image_info->font=DestroyString(image_info->font);
799 (void) CloneString(&image_info->font,argv[1]);
802 if (LocaleCompare("format",argv[0]+1) == 0)
807 for (q=strchr(argv[1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
808 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
809 image_info->ping=MagickFalse;
810 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
813 if (LocaleCompare("fuzz",argv[0]+1) == 0)
817 image_info->fuzz=0.0;
818 (void) SetImageOption(image_info,argv[0]+1,"0");
821 image_info->fuzz=SiPrefixToDouble(argv[1],(double) QuantumRange+
823 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
830 if (LocaleCompare("gravity",argv[0]+1) == 0)
834 (void) SetImageOption(image_info,argv[0]+1,"undefined");
837 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
840 if (LocaleCompare("green-primary",argv[0]+1) == 0)
844 (void) SetImageOption(image_info,argv[0]+1,"0.0");
847 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
854 if (LocaleCompare("intent",argv[0]+1) == 0)
858 (void) SetImageOption(image_info,argv[0]+1,"undefined");
861 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
864 if (LocaleCompare("interlace",argv[0]+1) == 0)
868 image_info->interlace=UndefinedInterlace;
869 (void) SetImageOption(image_info,argv[0]+1,"undefined");
872 image_info->interlace=(InterlaceType) ParseCommandOption(
873 MagickInterlaceOptions,MagickFalse,argv[1]);
874 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
877 if (LocaleCompare("interline-spacing",argv[0]+1) == 0)
881 (void) SetImageOption(image_info,argv[0]+1,"undefined");
884 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
887 if (LocaleCompare("interpolate",argv[0]+1) == 0)
891 (void) SetImageOption(image_info,argv[0]+1,"undefined");
894 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
897 if (LocaleCompare("interword-spacing",argv[0]+1) == 0)
901 (void) SetImageOption(image_info,argv[0]+1,"undefined");
904 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
911 if (LocaleCompare("kerning",argv[0]+1) == 0)
915 (void) SetImageOption(image_info,argv[0]+1,"undefined");
918 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
925 if (LocaleCompare("label",argv[0]+1) == 0)
929 (void) DeleteImageOption(image_info,argv[0]+1);
932 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
935 if (LocaleCompare("limit",argv[0]+1) == 0)
945 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
946 MagickFalse,argv[1]);
947 limit=MagickResourceInfinity;
948 if (LocaleCompare("unlimited",argv[2]) != 0)
949 limit=(MagickSizeType) SiPrefixToDouble(argv[2],100.0);
950 (void) SetMagickResourceLimit(type,limit);
953 if (LocaleCompare("list",argv[0]+1) == 0)
959 Display configuration list.
961 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[1]);
964 case MagickCoderOptions:
966 (void) ListCoderInfo((FILE *) NULL,exception);
969 case MagickColorOptions:
971 (void) ListColorInfo((FILE *) NULL,exception);
974 case MagickConfigureOptions:
976 (void) ListConfigureInfo((FILE *) NULL,exception);
979 case MagickDelegateOptions:
981 (void) ListDelegateInfo((FILE *) NULL,exception);
984 case MagickFontOptions:
986 (void) ListTypeInfo((FILE *) NULL,exception);
989 case MagickFormatOptions:
991 (void) ListMagickInfo((FILE *) NULL,exception);
994 case MagickLocaleOptions:
996 (void) ListLocaleInfo((FILE *) NULL,exception);
999 case MagickLogOptions:
1001 (void) ListLogInfo((FILE *) NULL,exception);
1004 case MagickMagicOptions:
1006 (void) ListMagicInfo((FILE *) NULL,exception);
1009 case MagickMimeOptions:
1011 (void) ListMimeInfo((FILE *) NULL,exception);
1014 case MagickModuleOptions:
1016 (void) ListModuleInfo((FILE *) NULL,exception);
1019 case MagickPolicyOptions:
1021 (void) ListPolicyInfo((FILE *) NULL,exception);
1024 case MagickResourceOptions:
1026 (void) ListMagickResourceInfo((FILE *) NULL,exception);
1029 case MagickThresholdOptions:
1031 (void) ListThresholdMaps((FILE *) NULL,exception);
1036 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
1043 if (LocaleCompare("log",argv[0]+1) == 0)
1045 if (*argv[0] == '+')
1047 (void) SetLogFormat(argv[1]);
1050 if (LocaleCompare("loop",argv[0]+1) == 0)
1052 if (*argv[0] == '+')
1054 (void) SetImageOption(image_info,argv[0]+1,"0");
1057 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1064 if (LocaleCompare("matte",argv[0]+1) == 0)
1066 if (*argv[0] == '+')
1068 (void) SetImageOption(image_info,argv[0]+1,"false");
1071 (void) SetImageOption(image_info,argv[0]+1,"true");
1074 if (LocaleCompare("mattecolor",argv[0]+1) == 0)
1076 if (*argv[0] == '+')
1078 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1079 (void) QueryColorCompliance(MatteColor,&image_info->matte_color,
1083 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1084 (void) QueryColorCompliance(argv[1],&image_info->matte_color,
1088 if (LocaleCompare("monitor",argv[0]+1) == 0)
1090 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
1094 if (LocaleCompare("monochrome",argv[0]+1) == 0)
1096 image_info->monochrome=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1103 if (LocaleCompare("orient",argv[0]+1) == 0)
1105 if (*argv[0] == '+')
1107 image_info->orientation=UndefinedOrientation;
1108 (void) SetImageOption(image_info,argv[0]+1,"undefined");
1111 image_info->orientation=(OrientationType) ParseCommandOption(
1112 MagickOrientationOptions,MagickFalse,argv[1]);
1113 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1119 if (LocaleCompare("page",argv[0]+1) == 0)
1123 page[MaxTextExtent];
1134 if (*argv[0] == '+')
1136 (void) DeleteImageOption(image_info,argv[0]+1);
1137 (void) CloneString(&image_info->page,(char *) NULL);
1140 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
1141 image_option=GetImageOption(image_info,"page");
1142 if (image_option != (const char *) NULL)
1143 flags=ParseAbsoluteGeometry(image_option,&geometry);
1144 canonical_page=GetPageGeometry(argv[1]);
1145 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
1146 canonical_page=DestroyString(canonical_page);
1147 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
1148 (unsigned long) geometry.width,(unsigned long) geometry.height);
1149 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1150 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
1151 (unsigned long) geometry.width,(unsigned long) geometry.height,
1152 (long) geometry.x,(long) geometry.y);
1153 (void) SetImageOption(image_info,argv[0]+1,page);
1154 (void) CloneString(&image_info->page,page);
1157 if (LocaleCompare("pen",argv[0]+1) == 0)
1159 if (*argv[0] == '+')
1161 (void) SetImageOption(image_info,argv[0]+1,"none");
1164 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1167 if (LocaleCompare("ping",argv[0]+1) == 0)
1169 image_info->ping=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1172 if (LocaleCompare("pointsize",argv[0]+1) == 0)
1174 if (*argv[0] == '+')
1175 geometry_info.rho=0.0;
1177 (void) ParseGeometry(argv[1],&geometry_info);
1178 image_info->pointsize=geometry_info.rho;
1181 if (LocaleCompare("precision",argv[0]+1) == 0)
1183 (void) SetMagickPrecision(StringToInteger(argv[1]));
1186 if (LocaleCompare("preview",argv[0]+1) == 0)
1191 if (*argv[0] == '+')
1193 image_info->preview_type=UndefinedPreview;
1196 image_info->preview_type=(PreviewType) ParseCommandOption(
1197 MagickPreviewOptions,MagickFalse,argv[1]);
1204 if (LocaleCompare("quality",argv[0]+1) == 0)
1207 Set image compression quality.
1209 if (*argv[0] == '+')
1211 image_info->quality=UndefinedCompressionQuality;
1212 (void) SetImageOption(image_info,argv[0]+1,"0");
1215 image_info->quality=StringToUnsignedLong(argv[1]);
1216 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1219 if (LocaleCompare("quiet",argv[0]+1) == 0)
1221 static WarningHandler
1222 warning_handler = (WarningHandler) NULL;
1224 if (*argv[0] == '+')
1227 Restore error or warning messages.
1229 warning_handler=SetWarningHandler(warning_handler);
1233 Suppress error or warning messages.
1235 warning_handler=SetWarningHandler((WarningHandler) NULL);
1242 if (LocaleCompare("red-primary",argv[0]+1) == 0)
1244 if (*argv[0] == '+')
1246 (void) SetImageOption(image_info,argv[0]+1,"0.0");
1249 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1256 if (LocaleCompare("sampling-factor",argv[0]+1) == 0)
1259 Set image sampling factor.
1261 if (*argv[0] == '+')
1263 if (image_info->sampling_factor != (char *) NULL)
1264 image_info->sampling_factor=DestroyString(
1265 image_info->sampling_factor);
1268 (void) CloneString(&image_info->sampling_factor,argv[1]);
1271 if (LocaleCompare("scene",argv[0]+1) == 0)
1276 if (*argv[0] == '+')
1278 image_info->scene=0;
1279 (void) SetImageOption(image_info,argv[0]+1,"0");
1282 image_info->scene=StringToUnsignedLong(argv[1]);
1283 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1286 if (LocaleCompare("seed",argv[0]+1) == 0)
1291 if (*argv[0] == '+')
1293 seed=(size_t) time((time_t *) NULL);
1294 SeedPseudoRandomGenerator(seed);
1297 seed=StringToUnsignedLong(argv[1]);
1298 SeedPseudoRandomGenerator(seed);
1301 if (LocaleCompare("size",argv[0]+1) == 0)
1303 if (*argv[0] == '+')
1305 if (image_info->size != (char *) NULL)
1306 image_info->size=DestroyString(image_info->size);
1309 (void) CloneString(&image_info->size,argv[1]);
1312 if (LocaleCompare("stroke",argv[0]+1) == 0)
1314 if (*argv[0] == '+')
1316 (void) SetImageOption(image_info,argv[0]+1,"none");
1319 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1322 if (LocaleCompare("strokewidth",argv[0]+1) == 0)
1324 if (*argv[0] == '+')
1326 (void) SetImageOption(image_info,argv[0]+1,"0");
1329 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1332 if (LocaleCompare("synchronize",argv[0]+1) == 0)
1334 if (*argv[0] == '+')
1336 image_info->synchronize=MagickFalse;
1339 image_info->synchronize=MagickTrue;
1346 if (LocaleCompare("taint",argv[0]+1) == 0)
1348 if (*argv[0] == '+')
1350 (void) SetImageOption(image_info,argv[0]+1,"false");
1353 (void) SetImageOption(image_info,argv[0]+1,"true");
1356 if (LocaleCompare("texture",argv[0]+1) == 0)
1358 if (*argv[0] == '+')
1360 if (image_info->texture != (char *) NULL)
1361 image_info->texture=DestroyString(image_info->texture);
1364 (void) CloneString(&image_info->texture,argv[1]);
1367 if (LocaleCompare("tile-offset",argv[0]+1) == 0)
1369 if (*argv[0] == '+')
1371 (void) SetImageOption(image_info,argv[0]+1,"0");
1374 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1377 if (LocaleCompare("transparent-color",argv[0]+1) == 0)
1379 if (*argv[0] == '+')
1381 (void) QueryColorCompliance("none",&image_info->transparent_color, exception);
1382 (void) SetImageOption(image_info,argv[0]+1,"none");
1385 (void) QueryColorCompliance(argv[1],&image_info->transparent_color,
1387 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1390 if (LocaleCompare("type",argv[0]+1) == 0)
1392 if (*argv[0] == '+')
1394 image_info->type=UndefinedType;
1395 (void) SetImageOption(image_info,argv[0]+1,"undefined");
1398 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1399 MagickFalse,argv[1]);
1400 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1407 if (LocaleCompare("undercolor",argv[0]+1) == 0)
1409 if (*argv[0] == '+')
1411 (void) DeleteImageOption(image_info,argv[0]+1);
1414 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1417 if (LocaleCompare("units",argv[0]+1) == 0)
1419 if (*argv[0] == '+')
1421 image_info->units=UndefinedResolution;
1422 (void) SetImageOption(image_info,argv[0]+1,"undefined");
1425 image_info->units=(ResolutionType) ParseCommandOption(
1426 MagickResolutionOptions,MagickFalse,argv[1]);
1427 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1434 if (LocaleCompare("verbose",argv[0]+1) == 0)
1436 if (*argv[0] == '+')
1438 image_info->verbose=MagickFalse;
1441 image_info->verbose=MagickTrue;
1442 image_info->ping=MagickFalse;
1445 if (LocaleCompare("view",argv[0]+1) == 0)
1447 if (*argv[0] == '+')
1449 if (image_info->view != (char *) NULL)
1450 image_info->view=DestroyString(image_info->view);
1453 (void) CloneString(&image_info->view,argv[1]);
1456 if (LocaleCompare("virtual-pixel",argv[0]+1) == 0)
1458 if (*argv[0] == '+')
1460 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
1461 (void) SetImageOption(image_info,argv[0]+1,"undefined");
1464 image_info->virtual_pixel_method=(VirtualPixelMethod)
1465 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,argv[1]);
1466 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1473 if (LocaleCompare("white-point",argv[0]+1) == 0)
1475 if (*argv[0] == '+')
1477 (void) SetImageOption(image_info,argv[0]+1,"0.0");
1480 (void) SetImageOption(image_info,argv[0]+1,argv[1]);
1492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1496 + S i m p l e O p e r a t i o n I m a g e %
1500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1502 % SimpleOperationImage() apply one simple operation on one image.
1503 % The image however may be part of a longer list of images.
1505 % The image in the list may be modified in three different ways...
1507 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
1508 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
1509 % * replace by a list of images (-separate and -crop only!)
1511 % In each case the result is returned into the list, and the pointer to the
1512 % modified image (last image added if replaced by a list of images) is
1513 % returned. As the image pointed to may be replaced, the first image in the
1514 % list may also change. GetFirstImageInList() should be used by caller if
1515 % they wish return the Image pointer to the first image in list.
1517 % The format of the SimpleOperationImage method is:
1519 % MagickBooleanType SimpleOperationImage(ImageInfo *image_info,
1520 % const int argc,const char **argv,Image **image)
1522 % A description of each parameter follows:
1524 % o image_info: the image info..
1526 % o argc: Specifies a pointer to an integer describing the number of
1527 % elements in the argument vector.
1529 % o argv: Specifies a pointer to a text array containing the command line
1532 % o image: the image.
1534 % o exception: return any errors or warnings in this structure.
1537 MagickExport MagickBooleanType SimpleOperationImage(ImageInfo *image_info,
1538 const int wand_unused(argc), const char **argv,Image **image,
1539 ExceptionInfo *exception)
1571 assert(image_info != (const ImageInfo *) NULL);
1572 assert(image_info->signature == MagickSignature);
1573 assert(image != (Image **) NULL);
1574 assert((*image)->signature == MagickSignature);
1575 if ((*image)->debug != MagickFalse)
1576 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1578 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
1579 quantize_info=AcquireQuantizeInfo(image_info);
1580 SetGeometryInfo(&geometry_info);
1581 GetPixelInfo(*image,&fill);
1582 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
1583 channel=image_info->channel;
1584 format=GetImageOption(image_info,"format");
1586 new_image = (Image *)NULL;
1588 switch (*(argv[0]+1))
1592 if (LocaleCompare("adaptive-blur",argv[0]+1) == 0)
1595 Adaptive blur image.
1597 (void) SyncImageSettings(image_info,*image);
1598 flags=ParseGeometry(argv[1],&geometry_info);
1599 if ((flags & SigmaValue) == 0)
1600 geometry_info.sigma=1.0;
1601 if ((flags & XiValue) == 0)
1602 geometry_info.xi=0.0;
1603 new_image=AdaptiveBlurImage(*image,geometry_info.rho,
1604 geometry_info.sigma,geometry_info.xi,exception);
1607 if (LocaleCompare("adaptive-resize",argv[0]+1) == 0)
1610 Adaptive resize image.
1612 (void) SyncImageSettings(image_info,*image);
1613 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
1614 new_image=AdaptiveResizeImage(*image,geometry.width,
1615 geometry.height,exception);
1618 if (LocaleCompare("adaptive-sharpen",argv[0]+1) == 0)
1621 Adaptive sharpen image.
1623 (void) SyncImageSettings(image_info,*image);
1624 flags=ParseGeometry(argv[1],&geometry_info);
1625 if ((flags & SigmaValue) == 0)
1626 geometry_info.sigma=1.0;
1627 if ((flags & XiValue) == 0)
1628 geometry_info.xi=0.0;
1629 new_image=AdaptiveSharpenImage(*image,geometry_info.rho,
1630 geometry_info.sigma,geometry_info.xi,exception);
1633 if (LocaleCompare("affine",argv[0]+1) == 0)
1638 if (*argv[0] == '+')
1640 GetAffineMatrix(&draw_info->affine);
1643 (void) ParseAffineGeometry(argv[1],&draw_info->affine,exception);
1646 if (LocaleCompare("alpha",argv[0]+1) == 0)
1651 (void) SyncImageSettings(image_info,*image);
1652 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
1653 MagickFalse,argv[1]);
1654 (void) SetImageAlphaChannel(*image,alpha_type,exception);
1657 if (LocaleCompare("annotate",argv[0]+1) == 0)
1661 geometry[MaxTextExtent];
1666 (void) SyncImageSettings(image_info,*image);
1667 SetGeometryInfo(&geometry_info);
1668 flags=ParseGeometry(argv[1],&geometry_info);
1669 if ((flags & SigmaValue) == 0)
1670 geometry_info.sigma=geometry_info.rho;
1671 text=InterpretImageProperties(image_info,*image,argv[2],
1673 if (text == (char *) NULL)
1675 (void) CloneString(&draw_info->text,text);
1676 text=DestroyString(text);
1677 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
1678 geometry_info.xi,geometry_info.psi);
1679 (void) CloneString(&draw_info->geometry,geometry);
1680 draw_info->affine.sx=cos(DegreesToRadians(
1681 fmod(geometry_info.rho,360.0)));
1682 draw_info->affine.rx=sin(DegreesToRadians(
1683 fmod(geometry_info.rho,360.0)));
1684 draw_info->affine.ry=(-sin(DegreesToRadians(
1685 fmod(geometry_info.sigma,360.0))));
1686 draw_info->affine.sy=cos(DegreesToRadians(
1687 fmod(geometry_info.sigma,360.0)));
1688 (void) AnnotateImage(*image,draw_info,exception);
1691 if (LocaleCompare("antialias",argv[0]+1) == 0)
1693 draw_info->stroke_antialias=(*argv[0] == '-') ? MagickTrue :
1695 draw_info->text_antialias=(*argv[0] == '-') ? MagickTrue :
1699 if (LocaleCompare("auto-gamma",argv[0]+1) == 0)
1702 Auto Adjust Gamma of image based on its mean
1704 (void) SyncImageSettings(image_info,*image);
1705 (void) AutoGammaImage(*image,exception);
1708 if (LocaleCompare("auto-level",argv[0]+1) == 0)
1711 Perfectly Normalize (max/min stretch) the image
1713 (void) SyncImageSettings(image_info,*image);
1714 (void) AutoLevelImage(*image,exception);
1717 if (LocaleCompare("auto-orient",argv[0]+1) == 0)
1719 (void) SyncImageSettings(image_info,*image);
1720 switch ((*image)->orientation)
1722 case TopRightOrientation:
1724 new_image=FlopImage(*image,exception);
1727 case BottomRightOrientation:
1729 new_image=RotateImage(*image,180.0,exception);
1732 case BottomLeftOrientation:
1734 new_image=FlipImage(*image,exception);
1737 case LeftTopOrientation:
1739 new_image=TransposeImage(*image,exception);
1742 case RightTopOrientation:
1744 new_image=RotateImage(*image,90.0,exception);
1747 case RightBottomOrientation:
1749 new_image=TransverseImage(*image,exception);
1752 case LeftBottomOrientation:
1754 new_image=RotateImage(*image,270.0,exception);
1760 if (new_image != (Image *) NULL)
1761 new_image->orientation=TopLeftOrientation;
1768 if (LocaleCompare("black-threshold",argv[0]+1) == 0)
1771 Black threshold image.
1773 (void) SyncImageSettings(image_info,*image);
1774 (void) BlackThresholdImage(*image,argv[1],exception);
1775 InheritException(exception,&(*image)->exception);
1778 if (LocaleCompare("blue-shift",argv[0]+1) == 0)
1783 (void) SyncImageSettings(image_info,*image);
1784 geometry_info.rho=1.5;
1785 if (*argv[0] == '-')
1786 flags=ParseGeometry(argv[1],&geometry_info);
1787 new_image=BlueShiftImage(*image,geometry_info.rho,exception);
1790 if (LocaleCompare("blur",argv[0]+1) == 0)
1793 Two pass gaussian blur of image.
1795 (void) SyncImageSettings(image_info,*image);
1796 flags=ParseGeometry(argv[1],&geometry_info);
1797 if ((flags & SigmaValue) == 0)
1798 geometry_info.sigma=1.0;
1799 if ((flags & XiValue) == 0)
1800 geometry_info.xi=0.0;
1801 new_image=BlurImage(*image,geometry_info.rho,
1802 geometry_info.sigma,geometry_info.xi,exception);
1805 if (LocaleCompare("border",argv[0]+1) == 0)
1808 Surround image with a border of solid color.
1810 (void) SyncImageSettings(image_info,*image);
1811 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
1812 if ((flags & SigmaValue) == 0)
1813 geometry.height=geometry.width;
1814 new_image=BorderImage(*image,&geometry,exception);
1817 if (LocaleCompare("bordercolor",argv[0]+1) == 0)
1819 if (*argv[0] == '+')
1821 (void) QueryColorCompliance(BorderColor,&draw_info->border_color,
1825 (void) QueryColorCompliance(argv[1],&draw_info->border_color,
1829 if (LocaleCompare("box",argv[0]+1) == 0)
1831 (void) QueryColorCompliance(argv[1],&draw_info->undercolor,
1835 if (LocaleCompare("brightness-contrast",argv[0]+1) == 0)
1848 Brightness / contrast image.
1850 (void) SyncImageSettings(image_info,*image);
1851 flags=ParseGeometry(argv[1],&geometry_info);
1852 brightness=geometry_info.rho;
1854 if ((flags & SigmaValue) != 0)
1855 contrast=geometry_info.sigma;
1856 (void) BrightnessContrastImage(*image,brightness,contrast,
1858 InheritException(exception,&(*image)->exception);
1865 if (LocaleCompare("cdl",argv[0]+1) == 0)
1868 *color_correction_collection;
1871 Color correct with a color decision list.
1873 (void) SyncImageSettings(image_info,*image);
1874 color_correction_collection=FileToString(argv[1],~0,exception);
1875 if (color_correction_collection == (char *) NULL)
1877 (void) ColorDecisionListImage(*image,color_correction_collection,
1879 InheritException(exception,&(*image)->exception);
1882 if (LocaleCompare("channel",argv[0]+1) == 0)
1884 if (*argv[0] == '+')
1885 channel=DefaultChannels;
1887 channel=(ChannelType) ParseChannelOption(argv[1]);
1888 SetPixelChannelMap(*image,channel);
1891 if (LocaleCompare("charcoal",argv[0]+1) == 0)
1896 (void) SyncImageSettings(image_info,*image);
1897 flags=ParseGeometry(argv[1],&geometry_info);
1898 if ((flags & SigmaValue) == 0)
1899 geometry_info.sigma=1.0;
1900 if ((flags & XiValue) == 0)
1901 geometry_info.xi=1.0;
1902 new_image=CharcoalImage(*image,geometry_info.rho,
1903 geometry_info.sigma,geometry_info.xi,exception);
1906 if (LocaleCompare("chop",argv[0]+1) == 0)
1911 (void) SyncImageSettings(image_info,*image);
1912 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
1913 new_image=ChopImage(*image,&geometry,exception);
1916 if (LocaleCompare("clamp",argv[0]+1) == 0)
1921 (void) SyncImageSettings(image_info,*image);
1922 (void) ClampImage(*image);
1923 InheritException(exception,&(*image)->exception);
1926 if (LocaleCompare("clip",argv[0]+1) == 0)
1928 (void) SyncImageSettings(image_info,*image);
1929 if (*argv[0] == '+')
1931 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1934 (void) ClipImage(*image,exception);
1937 if (LocaleCompare("clip-mask",argv[0]+1) == 0)
1954 (void) SyncImageSettings(image_info,*image);
1955 if (*argv[0] == '+')
1960 (void) SetImageMask(*image,(Image *) NULL,exception);
1963 mask_image=GetImageCache(image_info,argv[1],exception);
1964 if (mask_image == (Image *) NULL)
1966 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1967 return(MagickFalse);
1968 mask_view=AcquireCacheView(mask_image);
1969 for (y=0; y < (ssize_t) mask_image->rows; y++)
1971 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1973 if (q == (Quantum *) NULL)
1975 for (x=0; x < (ssize_t) mask_image->columns; x++)
1977 if (mask_image->matte == MagickFalse)
1978 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1979 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1980 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1981 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1982 q+=GetPixelChannels(mask_image);
1984 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1987 mask_view=DestroyCacheView(mask_view);
1988 mask_image->matte=MagickTrue;
1989 (void) SetImageClipMask(*image,mask_image);
1990 mask_image=DestroyImage(mask_image);
1991 InheritException(exception,&(*image)->exception);
1994 if (LocaleCompare("clip-path",argv[0]+1) == 0)
1996 (void) SyncImageSettings(image_info,*image);
1997 (void) ClipImagePath(*image,argv[1],*argv[0] == '-' ? MagickTrue :
1998 MagickFalse,exception);
2001 if (LocaleCompare("colorize",argv[0]+1) == 0)
2006 (void) SyncImageSettings(image_info,*image);
2007 new_image=ColorizeImage(*image,argv[1],draw_info->fill,
2011 if (LocaleCompare("color-matrix",argv[0]+1) == 0)
2016 (void) SyncImageSettings(image_info,*image);
2017 kernel=AcquireKernelInfo(argv[1]);
2018 if (kernel == (KernelInfo *) NULL)
2020 new_image=ColorMatrixImage(*image,kernel,exception);
2021 kernel=DestroyKernelInfo(kernel);
2024 if (LocaleCompare("colors",argv[0]+1) == 0)
2027 Reduce the number of colors in the image.
2029 (void) SyncImageSettings(image_info,*image);
2030 quantize_info->number_colors=StringToUnsignedLong(argv[1]);
2031 if (quantize_info->number_colors == 0)
2033 if (((*image)->storage_class == DirectClass) ||
2034 (*image)->colors > quantize_info->number_colors)
2035 (void) QuantizeImage(quantize_info,*image,exception);
2037 (void) CompressImageColormap(*image,exception);
2040 if (LocaleCompare("colorspace",argv[0]+1) == 0)
2045 (void) SyncImageSettings(image_info,*image);
2046 if (*argv[0] == '+')
2048 (void) TransformImageColorspace(*image,RGBColorspace);
2049 InheritException(exception,&(*image)->exception);
2052 colorspace=(ColorspaceType) ParseCommandOption(
2053 MagickColorspaceOptions,MagickFalse,argv[1]);
2054 (void) TransformImageColorspace(*image,colorspace);
2055 InheritException(exception,&(*image)->exception);
2058 if (LocaleCompare("contrast",argv[0]+1) == 0)
2060 (void) SyncImageSettings(image_info,*image);
2061 (void) ContrastImage(*image,(*argv[0] == '-') ? MagickTrue :
2062 MagickFalse,exception);
2065 if (LocaleCompare("contrast-stretch",argv[0]+1) == 0)
2075 Contrast stretch image.
2077 (void) SyncImageSettings(image_info,*image);
2078 flags=ParseGeometry(argv[1],&geometry_info);
2079 black_point=geometry_info.rho;
2080 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2082 if ((flags & PercentValue) != 0)
2084 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2085 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2087 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2089 (void) ContrastStretchImage(*image,black_point,white_point,
2091 InheritException(exception,&(*image)->exception);
2094 if (LocaleCompare("convolve",argv[0]+1) == 0)
2099 (void) SyncImageSettings(image_info,*image);
2100 kernel_info=AcquireKernelInfo(argv[1]);
2101 if (kernel_info == (KernelInfo *) NULL)
2103 kernel_info->bias=(*image)->bias;
2104 new_image=ConvolveImage(*image,kernel_info,exception);
2105 kernel_info=DestroyKernelInfo(kernel_info);
2108 if (LocaleCompare("crop",argv[0]+1) == 0)
2111 Crop a image to a smaller size
2113 (void) SyncImageSettings(image_info,*image);
2114 new_image=CropImageToTiles(*image,argv[1],exception);
2117 if (LocaleCompare("cycle",argv[0]+1) == 0)
2120 Cycle an image colormap.
2122 (void) SyncImageSettings(image_info,*image);
2123 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[1]),
2131 if (LocaleCompare("decipher",argv[0]+1) == 0)
2139 (void) SyncImageSettings(image_info,*image);
2140 passkey=FileToStringInfo(argv[1],~0,exception);
2141 if (passkey != (StringInfo *) NULL)
2143 (void) PasskeyDecipherImage(*image,passkey,exception);
2144 passkey=DestroyStringInfo(passkey);
2148 if (LocaleCompare("density",argv[0]+1) == 0)
2153 (void) CloneString(&draw_info->density,argv[1]);
2156 if (LocaleCompare("depth",argv[0]+1) == 0)
2158 (void) SyncImageSettings(image_info,*image);
2159 if (*argv[0] == '+')
2161 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
2164 (void) SetImageDepth(*image,StringToUnsignedLong(argv[1]));
2167 if (LocaleCompare("deskew",argv[0]+1) == 0)
2173 Straighten the image.
2175 (void) SyncImageSettings(image_info,*image);
2176 if (*argv[0] == '+')
2177 threshold=40.0*QuantumRange/100.0;
2179 threshold=SiPrefixToDouble(argv[1],QuantumRange);
2180 new_image=DeskewImage(*image,threshold,exception);
2183 if (LocaleCompare("despeckle",argv[0]+1) == 0)
2186 Reduce the speckles within an image.
2188 (void) SyncImageSettings(image_info,*image);
2189 new_image=DespeckleImage(*image,exception);
2192 if (LocaleCompare("display",argv[0]+1) == 0)
2194 (void) CloneString(&draw_info->server_name,argv[1]);
2197 if (LocaleCompare("distort",argv[0]+1) == 0)
2201 token[MaxTextExtent];
2221 (void) SyncImageSettings(image_info,*image);
2222 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
2223 MagickFalse,argv[1]);
2224 if ( method == ResizeDistortion )
2226 /* Special Case - Argument is actually a resize geometry!
2227 ** Convert that to an appropriate distortion argument array.
2231 (void) ParseRegionGeometry(*image,argv[2],&geometry,
2233 resize_args[0]=(double)geometry.width;
2234 resize_args[1]=(double)geometry.height;
2235 new_image=DistortImage(*image,method,(size_t)2,
2236 resize_args,MagickTrue,exception);
2239 args=InterpretImageProperties(image_info,*image,argv[2],
2241 if (args == (char *) NULL)
2244 for (x=0; *p != '\0'; x++)
2246 GetMagickToken(p,&p,token);
2248 GetMagickToken(p,&p,token);
2250 number_arguments=(size_t) x;
2251 arguments=(double *) AcquireQuantumMemory(number_arguments,
2252 sizeof(*arguments));
2253 if (arguments == (double *) NULL)
2254 ThrowWandFatalException(ResourceLimitFatalError,
2255 "MemoryAllocationFailed",(*image)->filename);
2256 (void) ResetMagickMemory(arguments,0,number_arguments*
2257 sizeof(*arguments));
2259 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
2261 GetMagickToken(p,&p,token);
2263 GetMagickToken(p,&p,token);
2264 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
2266 args=DestroyString(args);
2267 new_image=DistortImage(*image,method,number_arguments,arguments,
2268 (*argv[0] == '+') ? MagickTrue : MagickFalse,exception);
2269 arguments=(double *) RelinquishMagickMemory(arguments);
2272 if (LocaleCompare("dither",argv[0]+1) == 0)
2274 if (*argv[0] == '+')
2276 quantize_info->dither=MagickFalse;
2279 quantize_info->dither=MagickTrue;
2280 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
2281 MagickDitherOptions,MagickFalse,argv[1]);
2282 if (quantize_info->dither_method == NoDitherMethod)
2283 quantize_info->dither=MagickFalse;
2286 if (LocaleCompare("draw",argv[0]+1) == 0)
2291 (void) SyncImageSettings(image_info,*image);
2292 (void) CloneString(&draw_info->primitive,argv[1]);
2293 (void) DrawImage(*image,draw_info,exception);
2300 if (LocaleCompare("edge",argv[0]+1) == 0)
2303 Enhance edges in the image.
2305 (void) SyncImageSettings(image_info,*image);
2306 flags=ParseGeometry(argv[1],&geometry_info);
2307 if ((flags & SigmaValue) == 0)
2308 geometry_info.sigma=1.0;
2309 new_image=EdgeImage(*image,geometry_info.rho,
2310 geometry_info.sigma,exception);
2313 if (LocaleCompare("emboss",argv[0]+1) == 0)
2316 Gaussian embossen image.
2318 (void) SyncImageSettings(image_info,*image);
2319 flags=ParseGeometry(argv[1],&geometry_info);
2320 if ((flags & SigmaValue) == 0)
2321 geometry_info.sigma=1.0;
2322 new_image=EmbossImage(*image,geometry_info.rho,
2323 geometry_info.sigma,exception);
2326 if (LocaleCompare("encipher",argv[0]+1) == 0)
2334 (void) SyncImageSettings(image_info,*image);
2335 passkey=FileToStringInfo(argv[1],~0,exception);
2336 if (passkey != (StringInfo *) NULL)
2338 (void) PasskeyEncipherImage(*image,passkey,exception);
2339 passkey=DestroyStringInfo(passkey);
2343 if (LocaleCompare("encoding",argv[0]+1) == 0)
2345 (void) CloneString(&draw_info->encoding,argv[1]);
2348 if (LocaleCompare("enhance",argv[0]+1) == 0)
2353 (void) SyncImageSettings(image_info,*image);
2354 new_image=EnhanceImage(*image,exception);
2357 if (LocaleCompare("equalize",argv[0]+1) == 0)
2362 (void) SyncImageSettings(image_info,*image);
2363 (void) EqualizeImage(*image,exception);
2366 if (LocaleCompare("evaluate",argv[0]+1) == 0)
2371 MagickEvaluateOperator
2374 (void) SyncImageSettings(image_info,*image);
2375 op=(MagickEvaluateOperator) ParseCommandOption(
2376 MagickEvaluateOptions,MagickFalse,argv[1]);
2377 constant=SiPrefixToDouble(argv[2],QuantumRange);
2378 (void) EvaluateImage(*image,op,constant,exception);
2381 if (LocaleCompare("extent",argv[0]+1) == 0)
2384 Set the image extent.
2386 (void) SyncImageSettings(image_info,*image);
2387 flags=ParseGravityGeometry(*image,argv[1],&geometry,exception);
2388 if (geometry.width == 0)
2389 geometry.width=(*image)->columns;
2390 if (geometry.height == 0)
2391 geometry.height=(*image)->rows;
2392 new_image=ExtentImage(*image,&geometry,exception);
2399 if (LocaleCompare("family",argv[0]+1) == 0)
2401 if (*argv[0] == '+')
2403 if (draw_info->family != (char *) NULL)
2404 draw_info->family=DestroyString(draw_info->family);
2407 (void) CloneString(&draw_info->family,argv[1]);
2410 if (LocaleCompare("features",argv[0]+1) == 0)
2412 if (*argv[0] == '+')
2414 (void) DeleteImageArtifact(*image,"identify:features");
2417 (void) SetImageArtifact(*image,"identify:features",argv[1]);
2420 if (LocaleCompare("fill",argv[0]+1) == 0)
2425 GetPixelInfo(*image,&fill);
2426 if (*argv[0] == '+')
2428 (void) QueryMagickColorCompliance("none",&fill,exception);
2429 (void) QueryColorCompliance("none",&draw_info->fill,exception);
2430 if (draw_info->fill_pattern != (Image *) NULL)
2431 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2434 sans=AcquireExceptionInfo();
2435 (void) QueryMagickColorCompliance(argv[1],&fill,sans);
2436 status=QueryColorCompliance(argv[1],&draw_info->fill,sans);
2437 sans=DestroyExceptionInfo(sans);
2438 if (status == MagickFalse)
2439 draw_info->fill_pattern=GetImageCache(image_info,argv[1],
2443 if (LocaleCompare("flip",argv[0]+1) == 0)
2446 Flip image scanlines.
2448 (void) SyncImageSettings(image_info,*image);
2449 new_image=FlipImage(*image,exception);
2452 if (LocaleCompare("flop",argv[0]+1) == 0)
2455 Flop image scanlines.
2457 (void) SyncImageSettings(image_info,*image);
2458 new_image=FlopImage(*image,exception);
2461 if (LocaleCompare("floodfill",argv[0]+1) == 0)
2469 (void) SyncImageSettings(image_info,*image);
2470 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
2471 (void) QueryMagickColorCompliance(argv[2],&target,exception);
2472 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
2473 geometry.y,*argv[0] == '-' ? MagickFalse : MagickTrue,exception);
2476 if (LocaleCompare("font",argv[0]+1) == 0)
2478 if (*argv[0] == '+')
2480 if (draw_info->font != (char *) NULL)
2481 draw_info->font=DestroyString(draw_info->font);
2484 (void) CloneString(&draw_info->font,argv[1]);
2487 if (LocaleCompare("format",argv[0]+1) == 0)
2492 if (LocaleCompare("frame",argv[0]+1) == 0)
2498 Surround image with an ornamental border.
2500 (void) SyncImageSettings(image_info,*image);
2501 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
2502 frame_info.width=geometry.width;
2503 frame_info.height=geometry.height;
2504 if ((flags & HeightValue) == 0)
2505 frame_info.height=geometry.width;
2506 frame_info.outer_bevel=geometry.x;
2507 frame_info.inner_bevel=geometry.y;
2508 frame_info.x=(ssize_t) frame_info.width;
2509 frame_info.y=(ssize_t) frame_info.height;
2510 frame_info.width=(*image)->columns+2*frame_info.width;
2511 frame_info.height=(*image)->rows+2*frame_info.height;
2512 new_image=FrameImage(*image,&frame_info,exception);
2515 if (LocaleCompare("function",argv[0]+1) == 0)
2519 token[MaxTextExtent];
2537 Function Modify Image Values
2539 (void) SyncImageSettings(image_info,*image);
2540 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
2541 MagickFalse,argv[1]);
2542 arguments=InterpretImageProperties(image_info,*image,argv[2],
2544 if (arguments == (char *) NULL)
2546 p=(char *) arguments;
2547 for (x=0; *p != '\0'; x++)
2549 GetMagickToken(p,&p,token);
2551 GetMagickToken(p,&p,token);
2553 number_parameters=(size_t) x;
2554 parameters=(double *) AcquireQuantumMemory(number_parameters,
2555 sizeof(*parameters));
2556 if (parameters == (double *) NULL)
2557 ThrowWandFatalException(ResourceLimitFatalError,
2558 "MemoryAllocationFailed",(*image)->filename);
2559 (void) ResetMagickMemory(parameters,0,number_parameters*
2560 sizeof(*parameters));
2561 p=(char *) arguments;
2562 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
2564 GetMagickToken(p,&p,token);
2566 GetMagickToken(p,&p,token);
2567 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
2569 arguments=DestroyString(arguments);
2570 (void) FunctionImage(*image,function,number_parameters,parameters,
2572 parameters=(double *) RelinquishMagickMemory(parameters);
2579 if (LocaleCompare("gamma",argv[0]+1) == 0)
2584 (void) SyncImageSettings(image_info,*image);
2585 if (*argv[0] == '+')
2586 (*image)->gamma=InterpretLocaleValue(argv[1],(char **) NULL);
2588 (void) GammaImage(*image,InterpretLocaleValue(argv[1],
2589 (char **) NULL),exception);
2592 if ((LocaleCompare("gaussian-blur",argv[0]+1) == 0) ||
2593 (LocaleCompare("gaussian",argv[0]+1) == 0))
2596 Gaussian blur image.
2598 (void) SyncImageSettings(image_info,*image);
2599 flags=ParseGeometry(argv[1],&geometry_info);
2600 if ((flags & SigmaValue) == 0)
2601 geometry_info.sigma=1.0;
2602 if ((flags & XiValue) == 0)
2603 geometry_info.xi=0.0;
2604 new_image=GaussianBlurImage(*image,geometry_info.rho,
2605 geometry_info.sigma,geometry_info.xi,exception);
2608 if (LocaleCompare("geometry",argv[0]+1) == 0)
2611 Record Image offset, Resize last image.
2613 (void) SyncImageSettings(image_info,*image);
2614 if (*argv[0] == '+')
2616 if ((*image)->geometry != (char *) NULL)
2617 (*image)->geometry=DestroyString((*image)->geometry);
2620 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2621 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2622 (void) CloneString(&(*image)->geometry,argv[1]);
2624 new_image=ResizeImage(*image,geometry.width,geometry.height,
2625 (*image)->filter,(*image)->blur,exception);
2628 if (LocaleCompare("gravity",argv[0]+1) == 0)
2630 if (*argv[0] == '+')
2632 draw_info->gravity=UndefinedGravity;
2635 draw_info->gravity=(GravityType) ParseCommandOption(
2636 MagickGravityOptions,MagickFalse,argv[1]);
2643 if (LocaleCompare("highlight-color",argv[0]+1) == 0)
2645 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2652 if (LocaleCompare("identify",argv[0]+1) == 0)
2657 (void) SyncImageSettings(image_info,*image);
2658 if (format == (char *) NULL)
2660 (void) IdentifyImage(*image,stdout,image_info->verbose,
2664 text=InterpretImageProperties(image_info,*image,format,
2666 if (text == (char *) NULL)
2668 (void) fputs(text,stdout);
2669 (void) fputc('\n',stdout);
2670 text=DestroyString(text);
2673 if (LocaleCompare("implode",argv[0]+1) == 0)
2678 (void) SyncImageSettings(image_info,*image);
2679 (void) ParseGeometry(argv[1],&geometry_info);
2680 new_image=ImplodeImage(*image,geometry_info.rho,exception);
2683 if (LocaleCompare("interline-spacing",argv[0]+1) == 0)
2685 if (*argv[0] == '+')
2686 (void) ParseGeometry("0",&geometry_info);
2688 (void) ParseGeometry(argv[1],&geometry_info);
2689 draw_info->interline_spacing=geometry_info.rho;
2692 if (LocaleCompare("interword-spacing",argv[0]+1) == 0)
2694 if (*argv[0] == '+')
2695 (void) ParseGeometry("0",&geometry_info);
2697 (void) ParseGeometry(argv[1],&geometry_info);
2698 draw_info->interword_spacing=geometry_info.rho;
2705 if (LocaleCompare("kerning",argv[0]+1) == 0)
2707 if (*argv[0] == '+')
2708 (void) ParseGeometry("0",&geometry_info);
2710 (void) ParseGeometry(argv[1],&geometry_info);
2711 draw_info->kerning=geometry_info.rho;
2718 if (LocaleCompare("lat",argv[0]+1) == 0)
2721 Local adaptive threshold image.
2723 (void) SyncImageSettings(image_info,*image);
2724 flags=ParseGeometry(argv[1],&geometry_info);
2725 if ((flags & PercentValue) != 0)
2726 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2727 new_image=AdaptiveThresholdImage(*image,(size_t)
2728 geometry_info.rho,(size_t) geometry_info.sigma,(double)
2729 geometry_info.xi,exception);
2732 if (LocaleCompare("level",argv[0]+1) == 0)
2745 (void) SyncImageSettings(image_info,*image);
2746 flags=ParseGeometry(argv[1],&geometry_info);
2747 black_point=geometry_info.rho;
2748 white_point=(MagickRealType) QuantumRange;
2749 if ((flags & SigmaValue) != 0)
2750 white_point=geometry_info.sigma;
2752 if ((flags & XiValue) != 0)
2753 gamma=geometry_info.xi;
2754 if ((flags & PercentValue) != 0)
2756 black_point*=(MagickRealType) (QuantumRange/100.0);
2757 white_point*=(MagickRealType) (QuantumRange/100.0);
2759 if ((flags & SigmaValue) == 0)
2760 white_point=(MagickRealType) QuantumRange-black_point;
2761 if ((*argv[0] == '+') || ((flags & AspectValue) != 0))
2762 (void) LevelizeImage(*image,black_point,white_point,gamma,
2765 (void) LevelImage(*image,black_point,white_point,gamma,
2767 InheritException(exception,&(*image)->exception);
2770 if (LocaleCompare("level-colors",argv[0]+1) == 0)
2773 token[MaxTextExtent];
2782 p=(const char *) argv[1];
2783 GetMagickToken(p,&p,token); /* get black point color */
2784 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2785 (void) QueryMagickColorCompliance(token,&black_point,exception);
2787 (void) QueryMagickColorCompliance("#000000",&black_point,exception);
2788 if (isalpha((int) token[0]) || (token[0] == '#'))
2789 GetMagickToken(p,&p,token);
2791 white_point=black_point; /* set everything to that color */
2794 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2795 GetMagickToken(p,&p,token); /* Get white point color. */
2796 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2797 (void) QueryMagickColorCompliance(token,&white_point,exception);
2799 (void) QueryMagickColorCompliance("#ffffff",&white_point,exception);
2801 (void) LevelImageColors(*image,&black_point,&white_point,
2802 *argv[0] == '+' ? MagickTrue : MagickFalse,exception);
2805 if (LocaleCompare("linear-stretch",argv[0]+1) == 0)
2814 (void) SyncImageSettings(image_info,*image);
2815 flags=ParseGeometry(argv[1],&geometry_info);
2816 black_point=geometry_info.rho;
2817 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2818 if ((flags & SigmaValue) != 0)
2819 white_point=geometry_info.sigma;
2820 if ((flags & PercentValue) != 0)
2822 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2823 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2825 if ((flags & SigmaValue) == 0)
2826 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2828 (void) LinearStretchImage(*image,black_point,white_point,exception);
2829 InheritException(exception,&(*image)->exception);
2832 if (LocaleCompare("linewidth",argv[0]+1) == 0)
2834 draw_info->stroke_width=InterpretLocaleValue(argv[1],
2838 if (LocaleCompare("liquid-rescale",argv[0]+1) == 0)
2841 Liquid rescale image.
2843 (void) SyncImageSettings(image_info,*image);
2844 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2845 if ((flags & XValue) == 0)
2847 if ((flags & YValue) == 0)
2849 new_image=LiquidRescaleImage(*image,geometry.width,
2850 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2853 if (LocaleCompare("lowlight-color",argv[0]+1) == 0)
2855 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2862 if (LocaleCompare("map",argv[0]+1) == 0)
2868 Transform image colors to match this set of colors.
2870 (void) SyncImageSettings(image_info,*image);
2871 if (*argv[0] == '+')
2873 remap_image=GetImageCache(image_info,argv[1],exception);
2874 if (remap_image == (Image *) NULL)
2876 (void) RemapImage(quantize_info,*image,remap_image,exception);
2877 remap_image=DestroyImage(remap_image);
2880 if (LocaleCompare("mask",argv[0]+1) == 0)
2885 (void) SyncImageSettings(image_info,*image);
2886 if (*argv[0] == '+')
2891 (void) SetImageMask(*image,(Image *) NULL,exception);
2897 mask=GetImageCache(image_info,argv[1],exception);
2898 if (mask == (Image *) NULL)
2900 (void) SetImageMask(*image,mask,exception);
2901 mask=DestroyImage(mask);
2904 if (LocaleCompare("matte",argv[0]+1) == 0)
2906 (void) SetImageAlphaChannel(*image,(*argv[0] == '-') ?
2907 SetAlphaChannel : DeactivateAlphaChannel,exception);
2910 if (LocaleCompare("median",argv[0]+1) == 0)
2913 Median filter image.
2915 (void) SyncImageSettings(image_info,*image);
2916 flags=ParseGeometry(argv[1],&geometry_info);
2917 if ((flags & SigmaValue) == 0)
2918 geometry_info.sigma=geometry_info.rho;
2919 new_image=StatisticImage(*image,MedianStatistic,(size_t)
2920 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2923 if (LocaleCompare("mode",argv[0]+1) == 0)
2928 (void) SyncImageSettings(image_info,*image);
2929 flags=ParseGeometry(argv[1],&geometry_info);
2930 if ((flags & SigmaValue) == 0)
2931 geometry_info.sigma=geometry_info.rho;
2932 new_image=StatisticImage(*image,ModeStatistic,(size_t)
2933 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2936 if (LocaleCompare("modulate",argv[0]+1) == 0)
2938 (void) SyncImageSettings(image_info,*image);
2939 (void) ModulateImage(*image,argv[1],exception);
2942 if (LocaleCompare("monitor",argv[0]+1) == 0)
2944 if (*argv[0] == '+')
2946 (void) SetImageProgressMonitor(*image,
2947 (MagickProgressMonitor) NULL,(void *) NULL);
2950 (void) SetImageProgressMonitor(*image,MonitorProgress,
2954 if (LocaleCompare("monochrome",argv[0]+1) == 0)
2956 (void) SyncImageSettings(image_info,*image);
2957 (void) SetImageType(*image,BilevelType,exception);
2960 if (LocaleCompare("morphology",argv[0]+1) == 0)
2963 token[MaxTextExtent];
2978 Morphological Image Operation
2980 (void) SyncImageSettings(image_info,*image);
2982 GetMagickToken(p,&p,token);
2983 method=(MorphologyMethod) ParseCommandOption(
2984 MagickMorphologyOptions,MagickFalse,token);
2986 GetMagickToken(p,&p,token);
2987 if ((*p == ':') || (*p == ','))
2988 GetMagickToken(p,&p,token);
2990 iterations=(ssize_t) StringToLong(p);
2991 kernel=AcquireKernelInfo(argv[2]);
2992 if (kernel == (KernelInfo *) NULL)
2994 (void) ThrowMagickException(exception,GetMagickModule(),
2995 OptionError,"UnabletoParseKernel","morphology");
2999 new_image=MorphologyImage(*image,method,iterations,kernel,
3001 kernel=DestroyKernelInfo(kernel);
3004 if (LocaleCompare("motion-blur",argv[0]+1) == 0)
3009 (void) SyncImageSettings(image_info,*image);
3010 flags=ParseGeometry(argv[1],&geometry_info);
3011 if ((flags & SigmaValue) == 0)
3012 geometry_info.sigma=1.0;
3013 new_image=MotionBlurImage(*image,geometry_info.rho,
3014 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3022 if (LocaleCompare("negate",argv[0]+1) == 0)
3024 (void) SyncImageSettings(image_info,*image);
3025 (void) NegateImage(*image,*argv[0] == '+' ? MagickTrue :
3026 MagickFalse,exception);
3029 if (LocaleCompare("noise",argv[0]+1) == 0)
3031 (void) SyncImageSettings(image_info,*image);
3032 if (*argv[0] == '-')
3034 flags=ParseGeometry(argv[1],&geometry_info);
3035 if ((flags & SigmaValue) == 0)
3036 geometry_info.sigma=geometry_info.rho;
3037 new_image=StatisticImage(*image,NonpeakStatistic,(size_t)
3038 geometry_info.rho,(size_t) geometry_info.sigma,exception);
3045 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
3046 MagickFalse,argv[1]);
3047 new_image=AddNoiseImage(*image,noise,exception);
3051 if (LocaleCompare("normalize",argv[0]+1) == 0)
3053 (void) SyncImageSettings(image_info,*image);
3054 (void) NormalizeImage(*image,exception);
3061 if (LocaleCompare("opaque",argv[0]+1) == 0)
3066 (void) SyncImageSettings(image_info,*image);
3067 (void) QueryMagickColorCompliance(argv[1],&target,exception);
3068 (void) OpaquePaintImage(*image,&target,&fill,*argv[0] == '-' ?
3069 MagickFalse : MagickTrue,exception);
3072 if (LocaleCompare("ordered-dither",argv[0]+1) == 0)
3074 (void) SyncImageSettings(image_info,*image);
3075 (void) OrderedPosterizeImage(*image,argv[1],exception);
3082 if (LocaleCompare("paint",argv[0]+1) == 0)
3084 (void) SyncImageSettings(image_info,*image);
3085 (void) ParseGeometry(argv[1],&geometry_info);
3086 new_image=OilPaintImage(*image,geometry_info.rho,
3087 geometry_info.sigma,exception);
3090 if (LocaleCompare("pen",argv[0]+1) == 0)
3092 if (*argv[0] == '+')
3094 (void) QueryColorCompliance("none",&draw_info->fill,exception);
3097 (void) QueryColorCompliance(argv[1],&draw_info->fill,exception);
3100 if (LocaleCompare("pointsize",argv[0]+1) == 0)
3102 if (*argv[0] == '+')
3103 (void) ParseGeometry("12",&geometry_info);
3105 (void) ParseGeometry(argv[1],&geometry_info);
3106 draw_info->pointsize=geometry_info.rho;
3109 if (LocaleCompare("polaroid",argv[0]+1) == 0)
3118 Simulate a Polaroid picture.
3120 (void) SyncImageSettings(image_info,*image);
3121 random_info=AcquireRandomInfo();
3122 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
3123 random_info=DestroyRandomInfo(random_info);
3124 if (*argv[0] == '-')
3126 SetGeometryInfo(&geometry_info);
3127 flags=ParseGeometry(argv[1],&geometry_info);
3128 angle=geometry_info.rho;
3130 new_image=PolaroidImage(*image,draw_info,angle,
3131 interpolate_method,exception);
3134 if (LocaleCompare("posterize",argv[0]+1) == 0)
3139 (void) SyncImageSettings(image_info,*image);
3140 (void) PosterizeImage(*image,StringToUnsignedLong(argv[1]),
3141 quantize_info->dither,exception);
3144 if (LocaleCompare("preview",argv[0]+1) == 0)
3152 (void) SyncImageSettings(image_info,*image);
3153 if (*argv[0] == '+')
3154 preview_type=UndefinedPreview;
3156 preview_type=(PreviewType) ParseCommandOption(
3157 MagickPreviewOptions,MagickFalse,argv[1]);
3158 new_image=PreviewImage(*image,preview_type,exception);
3161 if (LocaleCompare("profile",argv[0]+1) == 0)
3175 (void) SyncImageSettings(image_info,*image);
3176 if (*argv[0] == '+')
3179 Remove a profile from the image.
3181 (void) ProfileImage(*image,argv[1],(const unsigned char *)
3183 InheritException(exception,&(*image)->exception);
3187 Associate a profile with the image.
3189 profile_info=CloneImageInfo(image_info);
3190 profile=GetImageProfile(*image,"iptc");
3191 if (profile != (StringInfo *) NULL)
3192 profile_info->profile=(void *) CloneStringInfo(profile);
3193 profile_image=GetImageCache(profile_info,argv[1],exception);
3194 profile_info=DestroyImageInfo(profile_info);
3195 if (profile_image == (Image *) NULL)
3200 profile_info=CloneImageInfo(image_info);
3201 (void) CopyMagickString(profile_info->filename,argv[1],
3203 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
3204 if (profile != (StringInfo *) NULL)
3206 (void) ProfileImage(*image,profile_info->magick,
3207 GetStringInfoDatum(profile),(size_t)
3208 GetStringInfoLength(profile),MagickFalse);
3209 profile=DestroyStringInfo(profile);
3211 profile_info=DestroyImageInfo(profile_info);
3214 ResetImageProfileIterator(profile_image);
3215 name=GetNextImageProfile(profile_image);
3216 while (name != (const char *) NULL)
3218 profile=GetImageProfile(profile_image,name);
3219 if (profile != (StringInfo *) NULL)
3220 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
3221 (size_t) GetStringInfoLength(profile),MagickFalse);
3222 name=GetNextImageProfile(profile_image);
3224 profile_image=DestroyImage(profile_image);
3231 if (LocaleCompare("quantize",argv[0]+1) == 0)
3233 if (*argv[0] == '+')
3235 quantize_info->colorspace=UndefinedColorspace;
3238 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
3239 MagickColorspaceOptions,MagickFalse,argv[1]);
3246 if (LocaleCompare("radial-blur",argv[0]+1) == 0)
3251 (void) SyncImageSettings(image_info,*image);
3252 flags=ParseGeometry(argv[1],&geometry_info);
3253 new_image=RadialBlurImage(*image,geometry_info.rho,
3254 geometry_info.sigma,exception);
3257 if (LocaleCompare("raise",argv[0]+1) == 0)
3260 Surround image with a raise of solid color.
3262 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3263 if ((flags & SigmaValue) == 0)
3264 geometry.height=geometry.width;
3265 (void) RaiseImage(*image,&geometry,*argv[0] == '-' ? MagickTrue :
3266 MagickFalse,exception);
3269 if (LocaleCompare("random-threshold",argv[0]+1) == 0)
3274 (void) SyncImageSettings(image_info,*image);
3275 (void) RandomThresholdImage(*image,argv[1],exception);
3278 if (LocaleCompare("recolor",argv[0]+1) == 0)
3283 (void) SyncImageSettings(image_info,*image);
3284 kernel=AcquireKernelInfo(argv[1]);
3285 if (kernel == (KernelInfo *) NULL)
3287 new_image=ColorMatrixImage(*image,kernel,exception);
3288 kernel=DestroyKernelInfo(kernel);
3291 if (LocaleCompare("render",argv[0]+1) == 0)
3293 (void) SyncImageSettings(image_info,*image);
3294 draw_info->render=(*argv[0] == '+') ? MagickTrue : MagickFalse;
3297 if (LocaleCompare("remap",argv[0]+1) == 0)
3303 Transform image colors to match this set of colors.
3305 (void) SyncImageSettings(image_info,*image);
3306 if (*argv[0] == '+')
3308 remap_image=GetImageCache(image_info,argv[1],exception);
3309 if (remap_image == (Image *) NULL)
3311 (void) RemapImage(quantize_info,*image,remap_image,exception);
3312 remap_image=DestroyImage(remap_image);
3315 if (LocaleCompare("repage",argv[0]+1) == 0)
3317 if (*argv[0] == '+')
3319 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
3322 (void) ResetImagePage(*image,argv[1]);
3323 InheritException(exception,&(*image)->exception);
3326 if (LocaleCompare("resample",argv[0]+1) == 0)
3331 (void) SyncImageSettings(image_info,*image);
3332 flags=ParseGeometry(argv[1],&geometry_info);
3333 if ((flags & SigmaValue) == 0)
3334 geometry_info.sigma=geometry_info.rho;
3335 new_image=ResampleImage(*image,geometry_info.rho,
3336 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
3339 if (LocaleCompare("resize",argv[0]+1) == 0)
3344 (void) SyncImageSettings(image_info,*image);
3345 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3346 new_image=ResizeImage(*image,geometry.width,geometry.height,
3347 (*image)->filter,(*image)->blur,exception);
3350 if (LocaleCompare("roll",argv[0]+1) == 0)
3355 (void) SyncImageSettings(image_info,*image);
3356 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
3357 new_image=RollImage(*image,geometry.x,geometry.y,exception);
3360 if (LocaleCompare("rotate",argv[0]+1) == 0)
3366 Check for conditional image rotation.
3368 (void) SyncImageSettings(image_info,*image);
3369 if (strchr(argv[1],'>') != (char *) NULL)
3370 if ((*image)->columns <= (*image)->rows)
3372 if (strchr(argv[1],'<') != (char *) NULL)
3373 if ((*image)->columns >= (*image)->rows)
3378 geometry=ConstantString(argv[1]);
3379 (void) SubstituteString(&geometry,">","");
3380 (void) SubstituteString(&geometry,"<","");
3381 (void) ParseGeometry(geometry,&geometry_info);
3382 geometry=DestroyString(geometry);
3383 new_image=RotateImage(*image,geometry_info.rho,exception);
3390 if (LocaleCompare("sample",argv[0]+1) == 0)
3393 Sample image with pixel replication.
3395 (void) SyncImageSettings(image_info,*image);
3396 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3397 new_image=SampleImage(*image,geometry.width,geometry.height,
3401 if (LocaleCompare("scale",argv[0]+1) == 0)
3406 (void) SyncImageSettings(image_info,*image);
3407 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3408 new_image=ScaleImage(*image,geometry.width,geometry.height,
3412 if (LocaleCompare("selective-blur",argv[0]+1) == 0)
3415 Selectively blur pixels within a contrast threshold.
3417 (void) SyncImageSettings(image_info,*image);
3418 flags=ParseGeometry(argv[1],&geometry_info);
3419 if ((flags & PercentValue) != 0)
3420 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3421 new_image=SelectiveBlurImage(*image,geometry_info.rho,
3422 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3425 if (LocaleCompare("separate",argv[0]+1) == 0)
3428 Break channels into separate images.
3429 WARNING: This can generate multiple images!
3431 (void) SyncImageSettings(image_info,*image);
3432 new_image=SeparateImages(*image,exception);
3435 if (LocaleCompare("sepia-tone",argv[0]+1) == 0)
3443 (void) SyncImageSettings(image_info,*image);
3444 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3445 new_image=SepiaToneImage(*image,threshold,exception);
3448 if (LocaleCompare("segment",argv[0]+1) == 0)
3453 (void) SyncImageSettings(image_info,*image);
3454 flags=ParseGeometry(argv[1],&geometry_info);
3455 if ((flags & SigmaValue) == 0)
3456 geometry_info.sigma=1.0;
3457 (void) SegmentImage(*image,(*image)->colorspace,
3458 image_info->verbose,geometry_info.rho,geometry_info.sigma,
3462 if (LocaleCompare("set",argv[0]+1) == 0)
3470 if (*argv[0] == '+')
3472 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3473 (void) DeleteImageRegistry(argv[1]+9);
3475 if (LocaleNCompare(argv[1],"argv[0]:",7) == 0)
3477 (void) DeleteImageOption(image_info,argv[1]+7);
3478 (void) DeleteImageArtifact(*image,argv[1]+7);
3481 (void) DeleteImageProperty(*image,argv[1]);
3484 value=InterpretImageProperties(image_info,*image,argv[2],
3486 if (value == (char *) NULL)
3488 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3489 (void) SetImageRegistry(StringRegistryType,argv[1]+9,value,
3492 if (LocaleNCompare(argv[1],"argv[0]:",7) == 0)
3494 (void) SetImageOption(image_info,argv[1]+7,value);
3495 (void) SetImageOption(image_info,argv[1]+7,value);
3496 (void) SetImageArtifact(*image,argv[1]+7,value);
3499 (void) SetImageProperty(*image,argv[1],value);
3500 value=DestroyString(value);
3503 if (LocaleCompare("shade",argv[0]+1) == 0)
3508 (void) SyncImageSettings(image_info,*image);
3509 flags=ParseGeometry(argv[1],&geometry_info);
3510 if ((flags & SigmaValue) == 0)
3511 geometry_info.sigma=1.0;
3512 new_image=ShadeImage(*image,(*argv[0] == '-') ? MagickTrue :
3513 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
3516 if (LocaleCompare("shadow",argv[0]+1) == 0)
3521 (void) SyncImageSettings(image_info,*image);
3522 flags=ParseGeometry(argv[1],&geometry_info);
3523 if ((flags & SigmaValue) == 0)
3524 geometry_info.sigma=1.0;
3525 if ((flags & XiValue) == 0)
3526 geometry_info.xi=4.0;
3527 if ((flags & PsiValue) == 0)
3528 geometry_info.psi=4.0;
3529 new_image=ShadowImage(*image,geometry_info.rho,
3530 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3531 ceil(geometry_info.psi-0.5),exception);
3534 if (LocaleCompare("sharpen",argv[0]+1) == 0)
3539 (void) SyncImageSettings(image_info,*image);
3540 flags=ParseGeometry(argv[1],&geometry_info);
3541 if ((flags & SigmaValue) == 0)
3542 geometry_info.sigma=1.0;
3543 if ((flags & XiValue) == 0)
3544 geometry_info.xi=0.0;
3545 new_image=SharpenImage(*image,geometry_info.rho,
3546 geometry_info.sigma,geometry_info.xi,exception);
3549 if (LocaleCompare("shave",argv[0]+1) == 0)
3552 Shave the image edges.
3554 (void) SyncImageSettings(image_info,*image);
3555 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3556 new_image=ShaveImage(*image,&geometry,exception);
3559 if (LocaleCompare("shear",argv[0]+1) == 0)
3564 (void) SyncImageSettings(image_info,*image);
3565 flags=ParseGeometry(argv[1],&geometry_info);
3566 if ((flags & SigmaValue) == 0)
3567 geometry_info.sigma=geometry_info.rho;
3568 new_image=ShearImage(*image,geometry_info.rho,
3569 geometry_info.sigma,exception);
3572 if (LocaleCompare("sigmoidal-contrast",argv[0]+1) == 0)
3575 Sigmoidal non-linearity contrast control.
3577 (void) SyncImageSettings(image_info,*image);
3578 flags=ParseGeometry(argv[1],&geometry_info);
3579 if ((flags & SigmaValue) == 0)
3580 geometry_info.sigma=(double) QuantumRange/2.0;
3581 if ((flags & PercentValue) != 0)
3582 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3584 (void) SigmoidalContrastImage(*image,(*argv[0] == '-') ?
3585 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
3589 if (LocaleCompare("sketch",argv[0]+1) == 0)
3594 (void) SyncImageSettings(image_info,*image);
3595 flags=ParseGeometry(argv[1],&geometry_info);
3596 if ((flags & SigmaValue) == 0)
3597 geometry_info.sigma=1.0;
3598 new_image=SketchImage(*image,geometry_info.rho,
3599 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3602 if (LocaleCompare("solarize",argv[0]+1) == 0)
3607 (void) SyncImageSettings(image_info,*image);
3608 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3609 (void) SolarizeImage(*image,threshold,exception);
3612 if (LocaleCompare("sparse-color",argv[0]+1) == 0)
3621 Sparse Color Interpolated Gradient
3623 (void) SyncImageSettings(image_info,*image);
3624 method=(SparseColorMethod) ParseCommandOption(
3625 MagickSparseColorOptions,MagickFalse,argv[1]);
3626 arguments=InterpretImageProperties(image_info,*image,argv[2],
3628 if (arguments == (char *) NULL)
3630 new_image=SparseColorOption(*image,method,arguments,
3631 argv[0][0] == '+' ? MagickTrue : MagickFalse,exception);
3632 arguments=DestroyString(arguments);
3635 if (LocaleCompare("splice",argv[0]+1) == 0)
3638 Splice a solid color into the image.
3640 (void) SyncImageSettings(image_info,*image);
3641 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
3642 new_image=SpliceImage(*image,&geometry,exception);
3645 if (LocaleCompare("spread",argv[0]+1) == 0)
3650 (void) SyncImageSettings(image_info,*image);
3651 (void) ParseGeometry(argv[1],&geometry_info);
3652 new_image=SpreadImage(*image,geometry_info.rho,
3653 interpolate_method,exception);
3656 if (LocaleCompare("statistic",argv[0]+1) == 0)
3661 (void) SyncImageSettings(image_info,*image);
3662 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3663 MagickFalse,argv[1]);
3664 (void) ParseGeometry(argv[2],&geometry_info);
3665 new_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
3666 (size_t) geometry_info.sigma,exception);
3669 if (LocaleCompare("stretch",argv[0]+1) == 0)
3671 if (*argv[0] == '+')
3673 draw_info->stretch=UndefinedStretch;
3676 draw_info->stretch=(StretchType) ParseCommandOption(
3677 MagickStretchOptions,MagickFalse,argv[1]);
3680 if (LocaleCompare("strip",argv[0]+1) == 0)
3683 Strip image of profiles and comments.
3685 (void) SyncImageSettings(image_info,*image);
3686 (void) StripImage(*image);
3687 InheritException(exception,&(*image)->exception);
3690 if (LocaleCompare("stroke",argv[0]+1) == 0)
3695 if (*argv[0] == '+')
3697 (void) QueryColorCompliance("none",&draw_info->stroke,exception);
3698 if (draw_info->stroke_pattern != (Image *) NULL)
3699 draw_info->stroke_pattern=DestroyImage(
3700 draw_info->stroke_pattern);
3703 sans=AcquireExceptionInfo();
3704 status=QueryColorCompliance(argv[1],&draw_info->stroke,sans);
3705 sans=DestroyExceptionInfo(sans);
3706 if (status == MagickFalse)
3707 draw_info->stroke_pattern=GetImageCache(image_info,argv[1],
3711 if (LocaleCompare("strokewidth",argv[0]+1) == 0)
3713 draw_info->stroke_width=InterpretLocaleValue(argv[1],
3717 if (LocaleCompare("style",argv[0]+1) == 0)
3719 if (*argv[0] == '+')
3721 draw_info->style=UndefinedStyle;
3724 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3725 MagickFalse,argv[1]);
3728 if (LocaleCompare("swirl",argv[0]+1) == 0)
3733 (void) SyncImageSettings(image_info,*image);
3734 (void) ParseGeometry(argv[1],&geometry_info);
3735 new_image=SwirlImage(*image,geometry_info.rho,
3736 interpolate_method,exception);
3743 if (LocaleCompare("threshold",argv[0]+1) == 0)
3751 (void) SyncImageSettings(image_info,*image);
3752 if (*argv[0] == '+')
3753 threshold=(double) QuantumRange/2;
3755 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3756 (void) BilevelImage(*image,threshold);
3757 InheritException(exception,&(*image)->exception);
3760 if (LocaleCompare("thumbnail",argv[0]+1) == 0)
3765 (void) SyncImageSettings(image_info,*image);
3766 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3767 new_image=ThumbnailImage(*image,geometry.width,geometry.height,
3771 if (LocaleCompare("tile",argv[0]+1) == 0)
3773 if (*argv[0] == '+')
3775 if (draw_info->fill_pattern != (Image *) NULL)
3776 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3779 draw_info->fill_pattern=GetImageCache(image_info,argv[1],
3783 if (LocaleCompare("tint",argv[0]+1) == 0)
3788 (void) SyncImageSettings(image_info,*image);
3789 new_image=TintImage(*image,argv[1],&fill,exception);
3792 if (LocaleCompare("transform",argv[0]+1) == 0)
3795 Affine transform image.
3797 (void) SyncImageSettings(image_info,*image);
3798 new_image=AffineTransformImage(*image,&draw_info->affine,
3802 if (LocaleCompare("transparent",argv[0]+1) == 0)
3807 (void) SyncImageSettings(image_info,*image);
3808 (void) QueryMagickColorCompliance(argv[1],&target,exception);
3809 (void) TransparentPaintImage(*image,&target,(Quantum)
3810 TransparentAlpha,*argv[0] == '-' ? MagickFalse : MagickTrue,
3811 &(*image)->exception);
3814 if (LocaleCompare("transpose",argv[0]+1) == 0)
3817 Transpose image scanlines.
3819 (void) SyncImageSettings(image_info,*image);
3820 new_image=TransposeImage(*image,exception);
3823 if (LocaleCompare("transverse",argv[0]+1) == 0)
3826 Transverse image scanlines.
3828 (void) SyncImageSettings(image_info,*image);
3829 new_image=TransverseImage(*image,exception);
3832 if (LocaleCompare("treedepth",argv[0]+1) == 0)
3834 quantize_info->tree_depth=StringToUnsignedLong(argv[1]);
3837 if (LocaleCompare("trim",argv[0]+1) == 0)
3842 (void) SyncImageSettings(image_info,*image);
3843 new_image=TrimImage(*image,exception);
3846 if (LocaleCompare("type",argv[0]+1) == 0)
3851 (void) SyncImageSettings(image_info,*image);
3852 if (*argv[0] == '+')
3855 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3857 (*image)->type=UndefinedType;
3858 (void) SetImageType(*image,type,exception);
3865 if (LocaleCompare("undercolor",argv[0]+1) == 0)
3867 (void) QueryColorCompliance(argv[1],&draw_info->undercolor,
3871 if (LocaleCompare("unique",argv[0]+1) == 0)
3873 if (*argv[0] == '+')
3875 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3878 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3879 (void) SetImageArtifact(*image,"verbose","true");
3882 if (LocaleCompare("unique-colors",argv[0]+1) == 0)
3885 Unique image colors.
3887 (void) SyncImageSettings(image_info,*image);
3888 new_image=UniqueImageColors(*image,exception);
3891 if (LocaleCompare("unsharp",argv[0]+1) == 0)
3896 (void) SyncImageSettings(image_info,*image);
3897 flags=ParseGeometry(argv[1],&geometry_info);
3898 if ((flags & SigmaValue) == 0)
3899 geometry_info.sigma=1.0;
3900 if ((flags & XiValue) == 0)
3901 geometry_info.xi=1.0;
3902 if ((flags & PsiValue) == 0)
3903 geometry_info.psi=0.05;
3904 new_image=UnsharpMaskImage(*image,geometry_info.rho,
3905 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3912 if (LocaleCompare("verbose",argv[0]+1) == 0)
3914 (void) SetImageArtifact(*image,argv[0]+1,
3915 *argv[0] == '+' ? "false" : "true");
3918 if (LocaleCompare("vignette",argv[0]+1) == 0)
3923 (void) SyncImageSettings(image_info,*image);
3924 flags=ParseGeometry(argv[1],&geometry_info);
3925 if ((flags & SigmaValue) == 0)
3926 geometry_info.sigma=1.0;
3927 if ((flags & XiValue) == 0)
3928 geometry_info.xi=0.1*(*image)->columns;
3929 if ((flags & PsiValue) == 0)
3930 geometry_info.psi=0.1*(*image)->rows;
3931 new_image=VignetteImage(*image,geometry_info.rho,
3932 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3933 ceil(geometry_info.psi-0.5),exception);
3936 if (LocaleCompare("virtual-pixel",argv[0]+1) == 0)
3938 if (*argv[0] == '+')
3940 (void) SetImageVirtualPixelMethod(*image,
3941 UndefinedVirtualPixelMethod);
3944 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3945 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3953 if (LocaleCompare("wave",argv[0]+1) == 0)
3958 (void) SyncImageSettings(image_info,*image);
3959 flags=ParseGeometry(argv[1],&geometry_info);
3960 if ((flags & SigmaValue) == 0)
3961 geometry_info.sigma=1.0;
3962 new_image=WaveImage(*image,geometry_info.rho,
3963 geometry_info.sigma,exception);
3966 if (LocaleCompare("weight",argv[0]+1) == 0)
3968 draw_info->weight=StringToUnsignedLong(argv[1]);
3969 if (LocaleCompare(argv[1],"all") == 0)
3970 draw_info->weight=0;
3971 if (LocaleCompare(argv[1],"bold") == 0)
3972 draw_info->weight=700;
3973 if (LocaleCompare(argv[1],"bolder") == 0)
3974 if (draw_info->weight <= 800)
3975 draw_info->weight+=100;
3976 if (LocaleCompare(argv[1],"lighter") == 0)
3977 if (draw_info->weight >= 100)
3978 draw_info->weight-=100;
3979 if (LocaleCompare(argv[1],"normal") == 0)
3980 draw_info->weight=400;
3983 if (LocaleCompare("white-threshold",argv[0]+1) == 0)
3986 White threshold image.
3988 (void) SyncImageSettings(image_info,*image);
3989 (void) WhiteThresholdImage(*image,argv[1],exception);
3990 InheritException(exception,&(*image)->exception);
3999 Replace current image with any image that was generated
4001 if (new_image != (Image *) NULL)
4002 ReplaceImageInListReturnLast(image,new_image);
4007 quantize_info=DestroyQuantizeInfo(quantize_info);
4008 draw_info=DestroyDrawInfo(draw_info);
4009 status=(*image)->exception.severity == UndefinedException ? 1 : 0;
4015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4019 + S e q u e n c e O p e r a t i o n I m a g e s %
4023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4025 % SequenceOperationImages() applies a single operation that apply to the
4026 % entire image list (e.g. -append, -layers, -coalesce, etc.).
4028 % The format of the MogrifyImage method is:
4030 % MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
4031 % const int argc, const char **argv,Image **images,
4032 % ExceptionInfo *exception)
4034 % A description of each parameter follows:
4036 % o image_info: the image info..
4038 % o argc: Specifies a pointer to an integer describing the number of
4039 % elements in the argument vector.
4041 % o argv: Specifies a pointer to a text array containing the command line
4044 % o images: pointer to pointer of the first image in image list.
4046 % o exception: return any errors or warnings in this structure.
4049 WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
4050 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
4059 assert(image_info != (ImageInfo *) NULL);
4060 assert(image_info->signature == MagickSignature);
4061 assert(images != (Image **) NULL);
4062 assert((*images)->previous == (Image *) NULL);
4063 assert((*images)->signature == MagickSignature);
4064 if ((*images)->debug != MagickFalse)
4065 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
4066 (*images)->filename);
4068 quantize_info=AcquireQuantizeInfo(image_info);
4069 channel=image_info->channel;
4073 switch (*(argv[0]+1))
4077 if (LocaleCompare("affinity",argv[0]+1) == 0)
4079 (void) SyncImagesSettings(image_info,*images);
4080 if (*argv[0] == '+')
4082 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4088 if (LocaleCompare("append",argv[0]+1) == 0)
4093 (void) SyncImagesSettings(image_info,*images);
4094 append_image=AppendImages(*images,*argv[0] == '-' ? MagickTrue :
4095 MagickFalse,exception);
4096 if (append_image == (Image *) NULL)
4101 *images=DestroyImageList(*images);
4102 *images=append_image;
4105 if (LocaleCompare("average",argv[0]+1) == 0)
4111 Average an image sequence (deprecated).
4113 (void) SyncImagesSettings(image_info,*images);
4114 average_image=EvaluateImages(*images,MeanEvaluateOperator,
4116 if (average_image == (Image *) NULL)
4121 *images=DestroyImageList(*images);
4122 *images=average_image;
4129 if (LocaleCompare("channel",argv[0]+1) == 0)
4134 if (*argv[0] == '+')
4136 channel=DefaultChannels;
4139 channel=(ChannelType) ParseChannelOption(argv[1]);
4140 SetPixelChannelMap(*images,channel);
4143 if (LocaleCompare("clut",argv[0]+1) == 0)
4149 (void) SyncImagesSettings(image_info,*images);
4150 image=RemoveFirstImageFromList(images);
4151 clut_image=RemoveFirstImageFromList(images);
4152 if (clut_image == (Image *) NULL)
4157 (void) ClutImageChannel(image,channel,clut_image);
4158 clut_image=DestroyImage(clut_image);
4159 *images=DestroyImageList(*images);
4163 if (LocaleCompare("coalesce",argv[0]+1) == 0)
4168 (void) SyncImagesSettings(image_info,*images);
4169 coalesce_image=CoalesceImages(*images,exception);
4170 if (coalesce_image == (Image *) NULL)
4175 *images=DestroyImageList(*images);
4176 *images=coalesce_image;
4179 if (LocaleCompare("combine",argv[0]+1) == 0)
4184 (void) SyncImagesSettings(image_info,*images);
4185 combine_image=CombineImages(*images,exception);
4186 if (combine_image == (Image *) NULL)
4191 *images=DestroyImageList(*images);
4192 *images=combine_image;
4195 if (LocaleCompare("composite",argv[0]+1) == 0)
4205 (void) SyncImagesSettings(image_info,*images);
4206 image=RemoveFirstImageFromList(images);
4207 composite_image=RemoveFirstImageFromList(images);
4208 if (composite_image == (Image *) NULL)
4213 (void) TransformImage(&composite_image,(char *) NULL,
4214 composite_image->geometry);
4215 SetGeometry(composite_image,&geometry);
4216 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
4217 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
4219 mask_image=RemoveFirstImageFromList(images);
4220 if (mask_image != (Image *) NULL)
4222 if ((image->compose == DisplaceCompositeOp) ||
4223 (image->compose == DistortCompositeOp))
4226 Merge Y displacement into X displacement image.
4228 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
4230 mask_image=DestroyImage(mask_image);
4235 Set a blending mask for the composition.
4236 Posible error, what if image->mask already set.
4238 image->mask=mask_image;
4239 (void) NegateImage(image->mask,MagickFalse,exception);
4242 (void) CompositeImage(image,image->compose,composite_image,
4243 geometry.x,geometry.y);
4244 if (mask_image != (Image *) NULL)
4245 mask_image=image->mask=DestroyImage(image->mask);
4246 composite_image=DestroyImage(composite_image);
4247 InheritException(exception,&image->exception);
4248 *images=DestroyImageList(*images);
4256 if (LocaleCompare("deconstruct",argv[0]+1) == 0)
4261 (void) SyncImagesSettings(image_info,*images);
4262 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
4264 if (deconstruct_image == (Image *) NULL)
4269 *images=DestroyImageList(*images);
4270 *images=deconstruct_image;
4273 if (LocaleCompare("delete",argv[0]+1) == 0)
4275 if (*argv[0] == '+')
4276 DeleteImages(images,"-1",exception);
4278 DeleteImages(images,argv[1],exception);
4281 if (LocaleCompare("dither",argv[0]+1) == 0)
4283 if (*argv[0] == '+')
4285 quantize_info->dither=MagickFalse;
4288 quantize_info->dither=MagickTrue;
4289 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
4290 MagickDitherOptions,MagickFalse,argv[1]);
4293 if (LocaleCompare("duplicate",argv[0]+1) == 0)
4298 if (*argv[0] == '+')
4299 duplicate_images=DuplicateImages(*images,1,"-1",exception);
4308 number_duplicates=(size_t) StringToLong(argv[1]);
4309 p=strchr(argv[1],',');
4310 if (p == (const char *) NULL)
4311 duplicate_images=DuplicateImages(*images,number_duplicates,
4314 duplicate_images=DuplicateImages(*images,number_duplicates,p,
4317 AppendImageToList(images, duplicate_images);
4318 (void) SyncImagesSettings(image_info,*images);
4325 if (LocaleCompare("evaluate-sequence",argv[0]+1) == 0)
4330 MagickEvaluateOperator
4333 (void) SyncImageSettings(image_info,*images);
4334 op=(MagickEvaluateOperator) ParseCommandOption(
4335 MagickEvaluateOptions,MagickFalse,argv[1]);
4336 evaluate_image=EvaluateImages(*images,op,exception);
4337 if (evaluate_image == (Image *) NULL)
4342 *images=DestroyImageList(*images);
4343 *images=evaluate_image;
4350 if (LocaleCompare("fft",argv[0]+1) == 0)
4356 Implements the discrete Fourier transform (DFT).
4358 (void) SyncImageSettings(image_info,*images);
4359 fourier_image=ForwardFourierTransformImage(*images,*argv[0] == '-' ?
4360 MagickTrue : MagickFalse,exception);
4361 if (fourier_image == (Image *) NULL)
4363 *images=DestroyImage(*images);
4364 *images=fourier_image;
4367 if (LocaleCompare("flatten",argv[0]+1) == 0)
4372 (void) SyncImagesSettings(image_info,*images);
4373 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
4374 if (flatten_image == (Image *) NULL)
4376 *images=DestroyImageList(*images);
4377 *images=flatten_image;
4380 if (LocaleCompare("fx",argv[0]+1) == 0)
4385 (void) SyncImagesSettings(image_info,*images);
4386 fx_image=FxImage(*images,argv[1],exception);
4387 if (fx_image == (Image *) NULL)
4392 *images=DestroyImageList(*images);
4400 if (LocaleCompare("hald-clut",argv[0]+1) == 0)
4406 (void) SyncImagesSettings(image_info,*images);
4407 image=RemoveFirstImageFromList(images);
4408 hald_image=RemoveFirstImageFromList(images);
4409 if (hald_image == (Image *) NULL)
4414 (void) HaldClutImage(image,hald_image,exception);
4415 hald_image=DestroyImage(hald_image);
4416 if (*images != (Image *) NULL)
4417 *images=DestroyImageList(*images);
4425 if (LocaleCompare("ift",argv[0]+1) == 0)
4433 Implements the inverse fourier discrete Fourier transform (DFT).
4435 (void) SyncImagesSettings(image_info,*images);
4436 magnitude_image=RemoveFirstImageFromList(images);
4437 phase_image=RemoveFirstImageFromList(images);
4438 if (phase_image == (Image *) NULL)
4443 fourier_image=InverseFourierTransformImage(magnitude_image,
4444 phase_image,*argv[0] == '-' ? MagickTrue : MagickFalse,exception);
4445 if (fourier_image == (Image *) NULL)
4447 if (*images != (Image *) NULL)
4448 *images=DestroyImage(*images);
4449 *images=fourier_image;
4452 if (LocaleCompare("insert",argv[0]+1) == 0)
4459 if (*argv[0] != '+')
4460 index=(ssize_t) StringToLong(argv[1]);
4461 p=RemoveLastImageFromList(images);
4462 if (p == (Image *) NULL)
4464 (void) ThrowMagickException(exception,GetMagickModule(),
4465 OptionError,"NoSuchImage","`%s'",argv[1]);
4471 PrependImageToList(images,q);
4473 if (index == (ssize_t) GetImageListLength(*images))
4474 AppendImageToList(images,q);
4477 q=GetImageFromList(*images,index-1);
4478 if (q == (Image *) NULL)
4480 (void) ThrowMagickException(exception,GetMagickModule(),
4481 OptionError,"NoSuchImage","`%s'",argv[1]);
4485 InsertImageInList(&q,p);
4487 *images=GetFirstImageInList(q);
4490 if (LocaleCompare("interpolate",argv[0]+1) == 0)
4492 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
4493 MagickInterpolateOptions,MagickFalse,argv[1]);
4500 if (LocaleCompare("layers",argv[0]+1) == 0)
4508 (void) SyncImagesSettings(image_info,*images);
4509 layers=(Image *) NULL;
4510 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
4511 MagickFalse,argv[1]);
4516 layers=CoalesceImages(*images,exception);
4519 case CompareAnyLayer:
4520 case CompareClearLayer:
4521 case CompareOverlayLayer:
4524 layers=CompareImagesLayers(*images,method,exception);
4530 case TrimBoundsLayer:
4532 layers=MergeImageLayers(*images,method,exception);
4537 layers=DisposeImages(*images,exception);
4540 case OptimizeImageLayer:
4542 layers=OptimizeImageLayers(*images,exception);
4545 case OptimizePlusLayer:
4547 layers=OptimizePlusImageLayers(*images,exception);
4550 case OptimizeTransLayer:
4552 OptimizeImageTransparency(*images,exception);
4555 case RemoveDupsLayer:
4557 RemoveDuplicateLayers(images,exception);
4560 case RemoveZeroLayer:
4562 RemoveZeroDelayLayers(images,exception);
4568 General Purpose, GIF Animation Optimizer.
4570 layers=CoalesceImages(*images,exception);
4571 if (layers == (Image *) NULL)
4576 *images=DestroyImageList(*images);
4578 layers=OptimizeImageLayers(*images,exception);
4579 if (layers == (Image *) NULL)
4584 *images=DestroyImageList(*images);
4586 layers=(Image *) NULL;
4587 OptimizeImageTransparency(*images,exception);
4588 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4592 case CompositeLayer:
4604 Split image sequence at the first 'NULL:' image.
4607 while (source != (Image *) NULL)
4609 source=GetNextImageInList(source);
4610 if ((source != (Image *) NULL) &&
4611 (LocaleCompare(source->magick,"NULL") == 0))
4614 if (source != (Image *) NULL)
4616 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4617 (GetNextImageInList(source) == (Image *) NULL))
4618 source=(Image *) NULL;
4622 Separate the two lists, junk the null: image.
4624 source=SplitImageList(source->previous);
4625 DeleteImageFromList(&source);
4628 if (source == (Image *) NULL)
4630 (void) ThrowMagickException(exception,GetMagickModule(),
4631 OptionError,"MissingNullSeparator","layers Composite");
4636 Adjust offset with gravity and virtual canvas.
4638 SetGeometry(*images,&geometry);
4639 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
4640 geometry.width=source->page.width != 0 ?
4641 source->page.width : source->columns;
4642 geometry.height=source->page.height != 0 ?
4643 source->page.height : source->rows;
4644 GravityAdjustGeometry((*images)->page.width != 0 ?
4645 (*images)->page.width : (*images)->columns,
4646 (*images)->page.height != 0 ? (*images)->page.height :
4647 (*images)->rows,(*images)->gravity,&geometry);
4648 compose=OverCompositeOp;
4649 argv[0]=GetImageOption(image_info,"compose");
4650 if (argv[0] != (const char *) NULL)
4651 compose=(CompositeOperator) ParseCommandOption(
4652 MagickComposeOptions,MagickFalse,argv[0]);
4653 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
4655 source=DestroyImageList(source);
4659 if (layers == (Image *) NULL)
4661 InheritException(exception,&layers->exception);
4662 *images=DestroyImageList(*images);
4670 if (LocaleCompare("map",argv[0]+1) == 0)
4672 (void) SyncImagesSettings(image_info,*images);
4673 if (*argv[0] == '+')
4675 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4681 if (LocaleCompare("maximum",argv[0]+1) == 0)
4687 Maximum image sequence (deprecated).
4689 (void) SyncImagesSettings(image_info,*images);
4690 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
4691 if (maximum_image == (Image *) NULL)
4696 *images=DestroyImageList(*images);
4697 *images=maximum_image;
4700 if (LocaleCompare("minimum",argv[0]+1) == 0)
4706 Minimum image sequence (deprecated).
4708 (void) SyncImagesSettings(image_info,*images);
4709 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
4710 if (minimum_image == (Image *) NULL)
4715 *images=DestroyImageList(*images);
4716 *images=minimum_image;
4719 if (LocaleCompare("morph",argv[0]+1) == 0)
4724 (void) SyncImagesSettings(image_info,*images);
4725 morph_image=MorphImages(*images,StringToUnsignedLong(argv[1]),
4727 if (morph_image == (Image *) NULL)
4732 *images=DestroyImageList(*images);
4733 *images=morph_image;
4736 if (LocaleCompare("mosaic",argv[0]+1) == 0)
4741 (void) SyncImagesSettings(image_info,*images);
4742 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
4743 if (mosaic_image == (Image *) NULL)
4748 *images=DestroyImageList(*images);
4749 *images=mosaic_image;
4756 if (LocaleCompare("print",argv[0]+1) == 0)
4761 (void) SyncImagesSettings(image_info,*images);
4762 string=InterpretImageProperties(image_info,*images,argv[1],
4764 if (string == (char *) NULL)
4766 (void) FormatLocaleFile(stdout,"%s",string);
4767 string=DestroyString(string);
4769 if (LocaleCompare("process",argv[0]+1) == 0)
4778 (void) SyncImagesSettings(image_info,*images);
4779 arguments=StringToArgv(argv[1],&number_arguments);
4780 if (arguments == (char **) NULL)
4782 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
4803 Support old style syntax, filter="-option arg".
4805 length=strlen(argv[1]);
4806 token=(char *) NULL;
4807 if (~length >= (MaxTextExtent-1))
4808 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
4810 if (token == (char *) NULL)
4814 token_info=AcquireTokenInfo();
4815 status=Tokenizer(token_info,0,token,length,arguments,"","=",
4816 "\"",'\0',&breaker,&next,"e);
4817 token_info=DestroyTokenInfo(token_info);
4823 argv=(&(arguments[next]));
4824 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
4827 token=DestroyString(token);
4830 (void) SubstituteString(&arguments[1],"-","");
4831 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
4832 number_arguments-2,(const char **) arguments+2,exception);
4833 for (j=0; j < number_arguments; j++)
4834 arguments[j]=DestroyString(arguments[j]);
4835 arguments=(char **) RelinquishMagickMemory(arguments);
4842 if (LocaleCompare("reverse",argv[0]+1) == 0)
4844 ReverseImageList(images);
4845 InheritException(exception,&(*images)->exception);
4852 if (LocaleCompare("smush",argv[0]+1) == 0)
4860 (void) SyncImagesSettings(image_info,*images);
4861 offset=(ssize_t) StringToLong(argv[1]);
4862 smush_image=SmushImages(*images,*argv[0] == '-' ? MagickTrue :
4863 MagickFalse,offset,exception);
4864 if (smush_image == (Image *) NULL)
4869 *images=DestroyImageList(*images);
4870 *images=smush_image;
4873 if (LocaleCompare("swap",argv[0]+1) == 0)
4885 if (*argv[0] != '+')
4894 flags=ParseGeometry(argv[1],&geometry_info);
4895 index=(ssize_t) geometry_info.rho;
4896 if ((flags & SigmaValue) != 0)
4897 swap_index=(ssize_t) geometry_info.sigma;
4899 p=GetImageFromList(*images,index);
4900 q=GetImageFromList(*images,swap_index);
4901 if ((p == (Image *) NULL) || (q == (Image *) NULL))
4903 (void) ThrowMagickException(exception,GetMagickModule(),
4904 OptionError,"NoSuchImage","`%s'",(*images)->filename);
4910 swap=CloneImage(p,0,0,MagickTrue,exception);
4911 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
4912 ReplaceImageInList(&q,swap);
4913 *images=GetFirstImageInList(q);
4920 if (LocaleCompare("write",argv[0]+1) == 0)
4931 (void) SyncImagesSettings(image_info,*images);
4932 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[1]);
4933 (void) DeleteImageRegistry(key);
4934 write_images=(*images);
4935 if (*argv[0] == '+')
4936 write_images=CloneImageList(*images,exception);
4937 write_info=CloneImageInfo(image_info);
4938 status&=WriteImages(write_info,write_images,argv[1],exception);
4939 write_info=DestroyImageInfo(write_info);
4940 if (*argv[0] == '+')
4941 write_images=DestroyImageList(write_images);
4949 quantize_info=DestroyQuantizeInfo(quantize_info);
4951 return(status != 0 ? MagickTrue : MagickFalse);