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) QueryColorCompliance(token,AllCompliance,&color,
296 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
297 sparse_arguments[x++] = QuantumScale*color.red;
298 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
299 sparse_arguments[x++] = QuantumScale*color.green;
300 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
301 sparse_arguments[x++] = QuantumScale*color.blue;
302 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
303 (image->colorspace == CMYKColorspace))
304 sparse_arguments[x++] = QuantumScale*color.black;
305 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
306 (image->matte != MagickFalse))
307 sparse_arguments[x++] = QuantumScale*color.alpha;
310 /* Colors given as a set of floating point values - experimental */
311 /* NB: token contains the first floating point value to use! */
312 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
314 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
315 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
317 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
318 token[0] = ','; /* used this token - get another */
320 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
322 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
323 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
325 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
326 token[0] = ','; /* used this token - get another */
328 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
330 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
331 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
333 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
334 token[0] = ','; /* used this token - get another */
336 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
337 (image->colorspace == CMYKColorspace))
339 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
340 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
342 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
343 token[0] = ','; /* used this token - get another */
345 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
346 (image->matte != MagickFalse))
348 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
349 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
351 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
352 token[0] = ','; /* used this token - get another */
357 if ( number_arguments != x && !error ) {
358 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
359 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
360 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
361 return( (Image *)NULL);
364 return( (Image *)NULL);
366 /* Call the Interpolation function with the parsed arguments */
367 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
369 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
370 return( sparse_image );
374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378 + A p p l y S e t t i n g O p t i o n %
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384 % ApplySettingOption() saves the given single settings option into a CLI wand
385 % holding the image_info, draw_info, quantize_info structures that is later
386 % used for reading, processing, and writing images.
388 % No image in the wand is actually modified (setting options only)
390 % The format of the ApplySettingOption method is:
392 % MagickBooleanType ApplySettingOption(MagickWand *wand,
393 % const int argc, const char **argv,ExceptionInfo *exception)
395 % A description of each parameter follows:
397 % o wand: structure holding settings to be applied
399 % o argc: Specifies a pointer to an integer describing the number of
400 % elements in the argument vector.
402 % o argv: Specifies a pointer to a text array containing the command line
405 % o exception: return any errors or warnings in this structure.
408 WandExport MagickBooleanType ApplySettingsOption(ImageInfo *image_info,
409 const int argc,const char **argv,ExceptionInfo *exception)
423 assert(wand != (MagickWand *) NULL);
424 assert(wand->signature == WandSignature);
425 assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */
426 assert(wand->quantize_info == (QuantizeInfo *) NULL);
427 if (wand->debug != MagickFalse)
428 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
433 image_info=wand->image_info;
434 draw_info=wand->_info;
436 #define IfSetOption ((*argv[0])=='-')
442 if (LocaleCompare("adjoin",option) == 0)
444 image_info->adjoin = IfSetOption ? MagickTrue : MagickFalse;
447 if (LocaleCompare("affine",option) == 0)
450 (void) ParseAffineGeometry(argv[1],draw_info->affine,
453 GetAffineMatrix(draw_info->affine);
456 if (LocaleCompare("antialias",option) == 0)
458 image_info->antialias =
459 draw_info->stroke_antialias =
460 draw_info->text_antialias =
461 IfSetOption ? MagickTrue : MagickFalse;
464 if (LocaleCompare("authenticate",option) == 0)
466 (void) SetImageOption(image_info,option,
467 IfSetOption ? argv[1] : (const char*)NULL);
474 if (LocaleCompare("background",option) == 0)
476 /* FUTURE: both image_info attribute & ImageOption in use!
477 Note that +background, means fall-back to image attribute
478 so ImageOption is deleted, not set to a default.
482 (void) DeleteImageOption(image_info,option);
483 (void) QueryColorCompliance(BackgroundColor,AllCompliance,
484 image_info->background_color,exception);
487 (void) SetImageOption(image_info,option,argv[1]);
488 (void) QueryColorCompliance(argv[1],AllCompliance,
489 image_info->background_color,exception);
492 if (LocaleCompare("bias",option) == 0)
494 /* FUTURE: bias OBSOLETED, replaced by "convolve:bias"
495 as it is actually rarely used except in direct convolve
496 Usage outside direct convolve is actally non-sensible!
498 (void) SetImageOption(image_info,option,
499 IfSetOption ? argv[1] : "0");
502 if (LocaleCompare("black-point-compensation",option) == 0)
504 (void) SetImageOption(image_info,option,
505 IfSetOption ? "true" : "false" );
508 if (LocaleCompare("blue-primary",option) == 0)
510 (void) SetImageOption(image_info,option,
511 IfSetOption ? argv[1] : "0" );
514 if (LocaleCompare("bordercolor",option) == 0)
516 /* FUTURE: both image_info attribute & ImageOption in use! */
519 (void) SetImageOption(image_info,option,argv[1]);
520 (void) QueryColorCompliance(argv[1],AllCompliece,
521 &image_info->border_color,exception);
522 (void) QueryColorCompliance(argv[1],AllCompliance,
523 &draw_info->border_color,exception);
526 (void) DeleteImageOption(image_info,option);
527 (void) QueryColorCompliance(BorderColor,AllCompliance,
528 &image_info->border_color,exception);
529 (void) QueryColorCompliance(BorderColor,AllCompliance,
530 &draw_info->border_color,exception);
533 if (LocaleCompare("box",option) == 0)
536 *value = IfSetOption ? argv[1] : "none";
537 (void) SetImageOption(image_info,option,value);
538 (void) QueryColorCompliance(value,AllCompliance,
539 &draw_info->undercolor,exception);
546 if (LocaleCompare("cache",option) == 0)
551 limit=MagickResourceInfinity;
552 if (LocaleCompare("unlimited",argv[1]) != 0)
553 limit=(MagickSizeType) SiPrefixToDouble(argv[1],100.0);
554 (void) SetMagickResourceLimit(MemoryResource,limit);
555 (void) SetMagickResourceLimit(MapResource,2*limit);
558 if (LocaleCompare("caption",option) == 0)
560 (void) SetImageOption(image_info,option,
561 IfSetOption ? argv[1] : (const char*)NULL);
564 if (LocaleCompare("channel",option) == 0)
566 image_info->channel=(ChannelType) (
567 IfSetOption ? ParseChannelOption(argv[1]) : DefaultChannels );
568 /* This is also a SimpleImageOperator */
571 if (LocaleCompare("colorspace",option) == 0)
573 /* This is also a SimpleImageOperator */
574 /* Undefined colorspace means don't modify images */
575 image_info->colorspace=UndefinedColorspace;
577 image_info->colorspace=(ColorspaceType) ParseCommandOption(
578 MagickColorspaceOptions,MagickFalse,argv[1])
581 if (LocaleCompare("comment",option) == 0)
583 (void) SetImageOption(image_info,option,
584 IfSetOption ? argv[1] : (const char*)NULL);
587 if (LocaleCompare("compose",option) == 0)
589 /* FUTURE: What should be used? image_info or ImageOption ???
590 The former is more efficent, but Crisy prefers the latter!
592 (void) SetImageOption(image_info,option,
593 IfSetOption ? argv[1] : (const char*)NULL);
594 image_info->compose=(CompositeOperator) ParseCommandOption(
595 MagickComposeOptions,MagickFalse,
596 IfSetOption ? argv[1] : "undefined");
599 if (LocaleCompare("compress",option) == 0)
601 /* FUTURE: What should be used? image_info or ImageOption ???
602 The former is more efficent, but Crisy prefers the latter!
604 The coders appears to use image_info, not Image_Option
605 however the image attribute (for save) is set from the
610 image_info->compression=(CompressionType) ParseCommandOption(
611 MagickCompressOptions,MagickFalse,argv[1]);
612 (void) SetImageOption(image_info,option,argv[1]);
615 image_info->compression=UndefinedCompression;
616 (void) SetImageOption(image_info,option,"undefined");
623 if (LocaleCompare("debug",option) == 0)
626 (void) SetLogEventMask(IfSetOption?argv[1]:"none");
627 image_info->debug=IsEventLogging(); /* extract logging*/
628 wand->debug=IsEventLogging();
631 if (LocaleCompare("define",option) == 0)
633 /* FUTURE both -set and -define sets ImageOption
634 But differs in that -set tried to set image properity (attribute)
636 if (LocaleNCompare(argv[1],"registry:",9) == 0)
639 (void) DefineImageRegistry(StringRegistryType,argv[1]+9,
642 (void) DefineImageOption(image_info,argv[1],exception);
646 (void) DefineImageOption(image_info,argv[1],exception);
648 (void) DeleteImageOption(image_info,argv[1],exception);
651 if (LocaleCompare("delay",option) == 0)
653 /* transfered to new images only via AcquireImage()
654 -set delay must be used to set attributes directly.
656 (void) SetImageOption(image_info,option,
657 IfSetOption ? argv[1] : "0");
660 if (LocaleCompare("density",option) == 0)
662 /* FUTURE: At this time everyone is using image_info string
663 The Image Option is not being used.
667 (void) CloneString(&image_info->density,argv[1]);
668 (void) CloneString(&draw_info->density,argv[1]);
669 (void) SetImageOption(image_info,option,argv[1]);
672 if (image_info->density != (char *) NULL)
673 image_info->density=DestroyString(image_info->density);
674 if (draw_info->density != (char *) NULL)
675 draw_info->density=DestroyString(draw_info->density);
676 (void) SetImageOption(image_info,option,"72");
679 if (LocaleCompare("depth",option) == 0)
681 /* This is also a SimpleImageOperator! */
682 image_info->depth=IsSetOption?StringToUnsignedLong(argv[1])
683 :MAGICKCORE_QUANTUM_DEPTH;
686 if (LocaleCompare("direction",option) == 0)
688 /* Image Option is only used to set draw_info */
689 (void) SetImageOption(image_info,option,
690 IfSetOption ? argv[1] : "undefined");
691 draw_info->direction=(DirectionType) ParseCommandOption(
692 MagickDirectionOptions,MagickFalse,
693 IfSetOption ? argv[1] : "undefined");
696 if (LocaleCompare("display",option) == 0)
699 (void) CloneString(&image_info->server_name,argv[1]);
701 if (image_info->server_name != (char *) NULL)
702 image_info->server_name=DestroyString(image_info->server_name);
705 if (LocaleCompare("dispose",option) == 0)
707 (void) SetImageOption(image_info,option,
708 IfSetOption ? argv[1] : "undefined");
711 if (LocaleCompare("dither",option) == 0)
713 /* FUTURE: Merge boolean image_info->dither with Dither type */
714 (void) SetImageOption(image_info,option,
715 IfSetOption ? argv[1] : "none");
716 image_info->dither = quantize_info->dither =
717 IfSetOption ? MagickTrue : MagickFalse;
718 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
719 MagickDitherOptions,MagickFalse,
720 IfSetOption ? argv[1] : "none");
721 if (quantize_info->dither_method == NoDitherMethod)
722 image_info->dither = quantize_info->dither = MagickFalse;
729 if (LocaleCompare("encoding",option) == 0)
731 (void) CloneString(&draw_info->encoding,
732 IfSetOption ? argv[1] : "undefined");
733 (void) SetImageOption(image_info,option,&draw_info->encoding);
736 if (LocaleCompare("endian",option) == 0)
741 value=IfSetOption?argv[1]:"undefined";
742 (void) SetImageOption(image_info,option,value);
743 image_info->endian=(EndianType) ParseCommandOption(
744 MagickEndianOptions,MagickFalse,value);
747 if (LocaleCompare("extract",option) == 0)
749 (void) CloneString(&image_info->extract,
750 IfSetOption?argv[1]:(const char *) NULL);
757 if (LocaleCompare("family",argv[0]+1) == 0)
759 (void) CloneString(&draw_info->family,
760 IfSetOption ? argv[1] : (const char *) NULL);
763 if (LocaleCompare("fill",option) == 0)
771 value = IfSetOption ? argv[1] : "none";
772 (void) SetImageOption(image_info,option,value);
774 sans=AcquireExceptionInfo();
775 status=QueryColorCompliance(value,AllCompliance,&draw_info->fill,sans);
776 sans=DestroyExceptionInfo(sans);
778 if (draw_info->fill_pattern != (Image *) NULL)
779 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
780 if (status == MagickFalse)
781 draw_info->fill_pattern=GetImageCache(image_info,value,
785 if (LocaleCompare("filter",option) == 0)
787 (void) SetImageOption(image_info,option,
788 IfSetOption ? argv[1] : "undefined");
791 if (LocaleCompare("font",argv[0]+1) == 0)
793 (void) CloneString(&draw_info->font,
794 IfSetOption ? argv[1] : (const char *) NULL);
795 (void) CloneString(&image_info->font,draw_info->font);
798 if (LocaleCompare("format",option) == 0)
800 /* FUTURE: why the ping test, the user could set ping after this! */
804 for (q=strchr(argv[1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
805 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
806 image_info->ping=MagickFalse;
807 (void) SetImageOption(image_info,option,argv[1]);
810 if (LocaleCompare("fuzz",option) == 0)
812 /* FUTURE: image_info and ImageOption!
813 Option used to set image fuzz! unless blank canvas (from color)
814 image attribute used for color compare operations
815 Can't find anything using image_info->fuzz (except cloning)!
819 image_info->fuzz=SiPrefixToDouble(argv[1],(double) QuantumRange+1.0);
820 (void) SetImageOption(image_info,option,argv[1]);
823 image_info->fuzz=0.0;
824 (void) SetImageOption(image_info,option,"0");
831 if (LocaleCompare("gravity",option) == 0)
835 (void) SetImageOption(image_info,option,"undefined");
836 draw_info->gravity=UndefinedGravity;
839 (void) SetImageOption(image_info,option,argv[1]);
840 draw_info->gravity=(GravityType) ParseCommandOption(
841 MagickGravityOptions,MagickFalse,argv[1]);
844 if (LocaleCompare("green-primary",option) == 0)
848 (void) SetImageOption(image_info,option,"0.0");
851 (void) SetImageOption(image_info,option,argv[1]);
858 if (LocaleCompare("intent",option) == 0)
862 (void) SetImageOption(image_info,option,"undefined");
865 (void) SetImageOption(image_info,option,argv[1]);
868 if (LocaleCompare("interlace",option) == 0)
872 image_info->interlace=UndefinedInterlace;
873 (void) SetImageOption(image_info,option,"undefined");
876 image_info->interlace=(InterlaceType) ParseCommandOption(
877 MagickInterlaceOptions,MagickFalse,argv[1]);
878 (void) SetImageOption(image_info,option,argv[1]);
881 if (LocaleCompare("interline-spacing",option) == 0)
885 (void) SetImageOption(image_info,option,"undefined");
888 (void) SetImageOption(image_info,option,argv[1]);
891 if (LocaleCompare("interpolate",option) == 0)
895 (void) SetImageOption(image_info,option,"undefined");
898 (void) SetImageOption(image_info,option,argv[1]);
901 if (LocaleCompare("interword-spacing",option) == 0)
905 (void) SetImageOption(image_info,option,"undefined");
908 (void) SetImageOption(image_info,option,argv[1]);
915 if (LocaleCompare("kerning",option) == 0)
919 (void) SetImageOption(image_info,option,"undefined");
922 (void) SetImageOption(image_info,option,argv[1]);
929 if (LocaleCompare("label",option) == 0)
933 (void) DeleteImageOption(image_info,option);
936 (void) SetImageOption(image_info,option,argv[1]);
939 if (LocaleCompare("limit",option) == 0)
949 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
950 MagickFalse,argv[1]);
951 limit=MagickResourceInfinity;
952 if (LocaleCompare("unlimited",argv[2]) != 0)
953 limit=(MagickSizeType) SiPrefixToDouble(argv[2],100.0);
954 (void) SetMagickResourceLimit(type,limit);
957 if (LocaleCompare("list",option) == 0)
963 Display configuration list.
965 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[1]);
968 case MagickCoderOptions:
970 (void) ListCoderInfo((FILE *) NULL,exception);
973 case MagickColorOptions:
975 (void) ListColorInfo((FILE *) NULL,exception);
978 case MagickConfigureOptions:
980 (void) ListConfigureInfo((FILE *) NULL,exception);
983 case MagickDelegateOptions:
985 (void) ListDelegateInfo((FILE *) NULL,exception);
988 case MagickFontOptions:
990 (void) ListTypeInfo((FILE *) NULL,exception);
993 case MagickFormatOptions:
995 (void) ListMagickInfo((FILE *) NULL,exception);
998 case MagickLocaleOptions:
1000 (void) ListLocaleInfo((FILE *) NULL,exception);
1003 case MagickLogOptions:
1005 (void) ListLogInfo((FILE *) NULL,exception);
1008 case MagickMagicOptions:
1010 (void) ListMagicInfo((FILE *) NULL,exception);
1013 case MagickMimeOptions:
1015 (void) ListMimeInfo((FILE *) NULL,exception);
1018 case MagickModuleOptions:
1020 (void) ListModuleInfo((FILE *) NULL,exception);
1023 case MagickPolicyOptions:
1025 (void) ListPolicyInfo((FILE *) NULL,exception);
1028 case MagickResourceOptions:
1030 (void) ListMagickResourceInfo((FILE *) NULL,exception);
1033 case MagickThresholdOptions:
1035 (void) ListThresholdMaps((FILE *) NULL,exception);
1040 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
1047 if (LocaleCompare("log",option) == 0)
1049 if (*argv[0] == '+')
1051 (void) SetLogFormat(argv[1]);
1054 if (LocaleCompare("loop",option) == 0)
1056 if (*argv[0] == '+')
1058 (void) SetImageOption(image_info,option,"0");
1061 (void) SetImageOption(image_info,option,argv[1]);
1068 if (LocaleCompare("matte",option) == 0)
1070 if (*argv[0] == '+')
1072 (void) SetImageOption(image_info,option,"false");
1075 (void) SetImageOption(image_info,option,"true");
1078 if (LocaleCompare("mattecolor",option) == 0)
1080 if (*argv[0] == '+')
1082 (void) SetImageOption(image_info,option,argv[1]);
1083 (void) QueryColorCompliance(MatteColor,AllCompliance,
1084 &image_info->matte_color,exception);
1087 (void) SetImageOption(image_info,option,argv[1]);
1088 (void) QueryColorCompliance(argv[1],AllCompliance,&image_info->matte_color,
1092 if (LocaleCompare("monitor",option) == 0)
1094 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
1098 if (LocaleCompare("monochrome",option) == 0)
1100 image_info->monochrome=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1107 if (LocaleCompare("orient",option) == 0)
1109 if (*argv[0] == '+')
1111 image_info->orientation=UndefinedOrientation;
1112 (void) SetImageOption(image_info,option,"undefined");
1115 image_info->orientation=(OrientationType) ParseCommandOption(
1116 MagickOrientationOptions,MagickFalse,argv[1]);
1117 (void) SetImageOption(image_info,option,argv[1]);
1123 if (LocaleCompare("page",option) == 0)
1127 page[MaxTextExtent];
1138 if (*argv[0] == '+')
1140 (void) DeleteImageOption(image_info,option);
1141 (void) CloneString(&image_info->page,(char *) NULL);
1144 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
1145 image_option=GetImageOption(image_info,"page");
1146 if (image_option != (const char *) NULL)
1147 flags=ParseAbsoluteGeometry(image_option,&geometry);
1148 canonical_page=GetPageGeometry(argv[1]);
1149 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
1150 canonical_page=DestroyString(canonical_page);
1151 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
1152 (unsigned long) geometry.width,(unsigned long) geometry.height);
1153 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1154 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
1155 (unsigned long) geometry.width,(unsigned long) geometry.height,
1156 (long) geometry.x,(long) geometry.y);
1157 (void) SetImageOption(image_info,option,page);
1158 (void) CloneString(&image_info->page,page);
1161 if (LocaleCompare("pen",option) == 0)
1163 if (*argv[0] == '+')
1165 (void) SetImageOption(image_info,option,"none");
1168 (void) SetImageOption(image_info,option,argv[1]);
1171 if (LocaleCompare("ping",option) == 0)
1173 image_info->ping=(*argv[0] == '-') ? MagickTrue : MagickFalse;
1176 if (LocaleCompare("pointsize",option) == 0)
1178 if (*argv[0] == '+')
1179 geometry_info.rho=0.0;
1181 (void) ParseGeometry(argv[1],&geometry_info);
1182 image_info->pointsize=geometry_info.rho;
1185 if (LocaleCompare("precision",option) == 0)
1187 (void) SetMagickPrecision(StringToInteger(argv[1]));
1190 if (LocaleCompare("preview",option) == 0)
1195 if (*argv[0] == '+')
1197 image_info->preview_type=UndefinedPreview;
1200 image_info->preview_type=(PreviewType) ParseCommandOption(
1201 MagickPreviewOptions,MagickFalse,argv[1]);
1208 if (LocaleCompare("quality",option) == 0)
1211 Set image compression quality.
1213 if (*argv[0] == '+')
1215 image_info->quality=UndefinedCompressionQuality;
1216 (void) SetImageOption(image_info,option,"0");
1219 image_info->quality=StringToUnsignedLong(argv[1]);
1220 (void) SetImageOption(image_info,option,argv[1]);
1223 if (LocaleCompare("quiet",option) == 0)
1225 static WarningHandler
1226 warning_handler = (WarningHandler) NULL;
1228 if (*argv[0] == '+')
1231 Restore error or warning messages.
1233 warning_handler=SetWarningHandler(warning_handler);
1237 Suppress error or warning messages.
1239 warning_handler=SetWarningHandler((WarningHandler) NULL);
1246 if (LocaleCompare("red-primary",option) == 0)
1248 if (*argv[0] == '+')
1250 (void) SetImageOption(image_info,option,"0.0");
1253 (void) SetImageOption(image_info,option,argv[1]);
1260 if (LocaleCompare("sampling-factor",option) == 0)
1263 Set image sampling factor.
1265 if (*argv[0] == '+')
1267 if (image_info->sampling_factor != (char *) NULL)
1268 image_info->sampling_factor=DestroyString(
1269 image_info->sampling_factor);
1272 (void) CloneString(&image_info->sampling_factor,argv[1]);
1275 if (LocaleCompare("scene",option) == 0)
1280 if (*argv[0] == '+')
1282 image_info->scene=0;
1283 (void) SetImageOption(image_info,option,"0");
1286 image_info->scene=StringToUnsignedLong(argv[1]);
1287 (void) SetImageOption(image_info,option,argv[1]);
1290 if (LocaleCompare("seed",option) == 0)
1295 if (*argv[0] == '+')
1297 seed=(size_t) time((time_t *) NULL);
1298 SeedPseudoRandomGenerator(seed);
1301 seed=StringToUnsignedLong(argv[1]);
1302 SeedPseudoRandomGenerator(seed);
1305 if (LocaleCompare("size",option) == 0)
1307 /* FUTURE: convert to ImageOption
1308 Look at special handling for "size" in SetImageOption()
1310 if (*argv[0] == '+')
1312 if (image_info->size != (char *) NULL)
1313 image_info->size=DestroyString(image_info->size);
1316 (void) CloneString(&image_info->size,argv[1]);
1319 if (LocaleCompare("stroke",option) == 0)
1321 if (*argv[0] == '+')
1323 (void) SetImageOption(image_info,option,"none");
1326 (void) SetImageOption(image_info,option,argv[1]);
1329 if (LocaleCompare("strokewidth",option) == 0)
1331 if (*argv[0] == '+')
1333 (void) SetImageOption(image_info,option,"0");
1336 (void) SetImageOption(image_info,option,argv[1]);
1339 if (LocaleCompare("synchronize",option) == 0)
1341 if (*argv[0] == '+')
1343 image_info->synchronize=MagickFalse;
1346 image_info->synchronize=MagickTrue;
1353 if (LocaleCompare("taint",option) == 0)
1355 if (*argv[0] == '+')
1357 (void) SetImageOption(image_info,option,"false");
1360 (void) SetImageOption(image_info,option,"true");
1363 if (LocaleCompare("texture",option) == 0)
1365 if (*argv[0] == '+')
1367 if (image_info->texture != (char *) NULL)
1368 image_info->texture=DestroyString(image_info->texture);
1371 (void) CloneString(&image_info->texture,argv[1]);
1374 if (LocaleCompare("tile-offset",option) == 0)
1376 if (*argv[0] == '+')
1378 (void) SetImageOption(image_info,option,"0");
1381 (void) SetImageOption(image_info,option,argv[1]);
1384 if (LocaleCompare("transparent-color",option) == 0)
1386 if (*argv[0] == '+')
1388 (void) QueryColorCompliance("none",AllCompliance,
1389 &image_info->transparent_color,exception);
1390 (void) SetImageOption(image_info,option,"none");
1393 (void) QueryColorCompliance("none",AllCompliance,
1394 &image_info->transparent_color,exception);
1395 (void) SetImageOption(image_info,option,argv[1]);
1398 if (LocaleCompare("type",option) == 0)
1400 if (*argv[0] == '+')
1402 image_info->type=UndefinedType;
1403 (void) SetImageOption(image_info,option,"undefined");
1406 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1407 MagickFalse,argv[1]);
1408 (void) SetImageOption(image_info,option,argv[1]);
1415 if (LocaleCompare("undercolor",option) == 0)
1417 if (*argv[0] == '+')
1419 (void) DeleteImageOption(image_info,option);
1422 (void) SetImageOption(image_info,option,argv[1]);
1425 if (LocaleCompare("units",option) == 0)
1427 if (*argv[0] == '+')
1429 image_info->units=UndefinedResolution;
1430 (void) SetImageOption(image_info,option,"undefined");
1433 image_info->units=(ResolutionType) ParseCommandOption(
1434 MagickResolutionOptions,MagickFalse,argv[1]);
1435 (void) SetImageOption(image_info,option,argv[1]);
1442 if (LocaleCompare("verbose",option) == 0)
1444 if (*argv[0] == '+')
1446 image_info->verbose=MagickFalse;
1449 image_info->verbose=MagickTrue;
1450 image_info->ping=MagickFalse;
1453 if (LocaleCompare("view",option) == 0)
1455 if (*argv[0] == '+')
1457 if (image_info->view != (char *) NULL)
1458 image_info->view=DestroyString(image_info->view);
1461 (void) CloneString(&image_info->view,argv[1]);
1464 if (LocaleCompare("virtual-pixel",option) == 0)
1466 if (*argv[0] == '+')
1468 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
1469 (void) SetImageOption(image_info,option,"undefined");
1472 image_info->virtual_pixel_method=(VirtualPixelMethod)
1473 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,argv[1]);
1474 (void) SetImageOption(image_info,option,argv[1]);
1481 if (LocaleCompare("white-point",option) == 0)
1483 if (*argv[0] == '+')
1485 (void) SetImageOption(image_info,option,"0.0");
1488 (void) SetImageOption(image_info,option,argv[1]);
1500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1504 + A p p l y I m a g e O p e r a t o r %
1508 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1510 % ApplyImageOperator() apply one simple image operation to just the current
1513 % The image in the list may be modified in three different ways...
1515 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
1516 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
1517 % * replace by a list of images (-separate and -crop only!)
1519 % In each case the result is returned into the list, and the pointer to the
1520 % modified image (last image added if replaced by a list of images) is
1521 % returned. As the image pointed to may be replaced, the first image in the
1522 % list may also change. GetFirstImageInList() should be used by caller if
1523 % they wish return the Image pointer to the first image in list.
1525 % The format of the ApplyImageOperator method is:
1527 % MagickBooleanType ApplyImageOperator(MagickWand *wand,
1528 % const int argc,const char **argv)
1530 % A description of each parameter follows:
1532 % o wand: The CLI wand holding all the settings and pointer to image
1534 % o argc: Specifies a pointer to an integer describing the number of
1535 % elements in the argument vector.
1537 % o argv: Specifies a pointer to a text array containing the command line
1540 % o exception: return any errors or warnings in this structure.
1543 MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
1544 const int wand_unused(argc), const char **argv, ExceptionInfo *exception)
1579 assert(image_info != (const ImageInfo *) NULL);
1580 assert(image_info->signature == MagickSignature);
1581 assert(image != (Image **) NULL);
1582 assert((*image)->signature == MagickSignature);
1583 if ((*image)->debug != MagickFalse)
1584 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1587 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
1588 quantize_info=AcquireQuantizeInfo(image_info);
1589 SetGeometryInfo(&geometry_info);
1590 GetPixelInfo(*image,&fill);
1591 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
1592 channel=image_info->channel;
1593 format=GetImageOption(image_info,"format");
1595 new_image = (Image *)NULL;
1597 switch (*(argv[0]+1))
1601 if (LocaleCompare("adaptive-blur",argv[0]+1) == 0)
1603 (void) SyncImageSettings(image_info,*image,exception);
1604 flags=ParseGeometry(argv[1],&geometry_info);
1605 if ((flags & SigmaValue) == 0)
1606 geometry_info.sigma=1.0;
1607 if ((flags & XiValue) == 0)
1608 geometry_info.xi=0.0;
1609 new_image=AdaptiveBlurImage(*image,geometry_info.rho,
1610 geometry_info.sigma,geometry_info.xi,exception);
1613 if (LocaleCompare("adaptive-resize",argv[0]+1) == 0)
1615 /* FUTURE: this is really a "interpolate-resize" operator
1616 "adaptive-resize" uses a fixed "Mesh" interpolation
1618 (void) SyncImageSettings(image_info,*image,exception);
1619 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
1620 new_image=AdaptiveResizeImage(*image,geometry.width,
1621 geometry.height,interpolate_method,exception);
1624 if (LocaleCompare("adaptive-sharpen",argv[0]+1) == 0)
1627 Adaptive sharpen image.
1629 (void) SyncImageSettings(image_info,*image,exception);
1630 flags=ParseGeometry(argv[1],&geometry_info);
1631 if ((flags & SigmaValue) == 0)
1632 geometry_info.sigma=1.0;
1633 if ((flags & XiValue) == 0)
1634 geometry_info.xi=0.0;
1635 new_image=AdaptiveSharpenImage(*image,geometry_info.rho,
1636 geometry_info.sigma,geometry_info.xi,exception);
1639 if (LocaleCompare("alpha",argv[0]+1) == 0)
1644 (void) SyncImageSettings(image_info,*image,exception);
1645 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
1646 MagickFalse,argv[1]);
1647 (void) SetImageAlphaChannel(*image,alpha_type,exception);
1650 if (LocaleCompare("annotate",argv[0]+1) == 0)
1654 geometry[MaxTextExtent];
1656 (void) SyncImageSettings(image_info,*image,exception);
1657 SetGeometryInfo(&geometry_info);
1658 flags=ParseGeometry(argv[1],&geometry_info);
1659 if ((flags & SigmaValue) == 0)
1660 geometry_info.sigma=geometry_info.rho;
1661 text=InterpretImageProperties(image_info,*image,argv[2],
1663 if (text == (char *) NULL)
1665 (void) CloneString(&draw_info->text,text);
1666 text=DestroyString(text);
1667 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
1668 geometry_info.xi,geometry_info.psi);
1669 (void) CloneString(&draw_info->geometry,geometry);
1670 draw_info->affine.sx=cos(DegreesToRadians(
1671 fmod(geometry_info.rho,360.0)));
1672 draw_info->affine.rx=sin(DegreesToRadians(
1673 fmod(geometry_info.rho,360.0)));
1674 draw_info->affine.ry=(-sin(DegreesToRadians(
1675 fmod(geometry_info.sigma,360.0))));
1676 draw_info->affine.sy=cos(DegreesToRadians(
1677 fmod(geometry_info.sigma,360.0)));
1678 (void) AnnotateImage(*image,draw_info,exception);
1681 if (LocaleCompare("auto-gamma",argv[0]+1) == 0)
1684 Auto Adjust Gamma of image based on its mean
1686 (void) SyncImageSettings(image_info,*image,exception);
1687 (void) AutoGammaImage(*image,exception);
1690 if (LocaleCompare("auto-level",argv[0]+1) == 0)
1693 Perfectly Normalize (max/min stretch) the image
1695 (void) SyncImageSettings(image_info,*image,exception);
1696 (void) AutoLevelImage(*image,exception);
1699 if (LocaleCompare("auto-orient",argv[0]+1) == 0)
1701 (void) SyncImageSettings(image_info,*image,exception);
1702 switch ((*image)->orientation)
1704 case TopRightOrientation:
1706 new_image=FlopImage(*image,exception);
1709 case BottomRightOrientation:
1711 new_image=RotateImage(*image,180.0,exception);
1714 case BottomLeftOrientation:
1716 new_image=FlipImage(*image,exception);
1719 case LeftTopOrientation:
1721 new_image=TransposeImage(*image,exception);
1724 case RightTopOrientation:
1726 new_image=RotateImage(*image,90.0,exception);
1729 case RightBottomOrientation:
1731 new_image=TransverseImage(*image,exception);
1734 case LeftBottomOrientation:
1736 new_image=RotateImage(*image,270.0,exception);
1742 if (new_image != (Image *) NULL)
1743 new_image->orientation=TopLeftOrientation;
1750 if (LocaleCompare("black-threshold",argv[0]+1) == 0)
1752 (void) SyncImageSettings(image_info,*image,exception);
1753 (void) BlackThresholdImage(*image,argv[1],exception);
1756 if (LocaleCompare("blue-shift",argv[0]+1) == 0)
1758 (void) SyncImageSettings(image_info,*image,exception);
1759 geometry_info.rho=1.5;
1760 if (*argv[0] == '-')
1761 flags=ParseGeometry(argv[1],&geometry_info);
1762 new_image=BlueShiftImage(*image,geometry_info.rho,exception);
1765 if (LocaleCompare("blur",argv[0]+1) == 0)
1767 /* FUTURE: use of "bias" in a blur is non-sensible */
1768 (void) SyncImageSettings(image_info,*image,exception);
1769 flags=ParseGeometry(argv[1],&geometry_info);
1770 if ((flags & SigmaValue) == 0)
1771 geometry_info.sigma=1.0;
1772 if ((flags & XiValue) == 0)
1773 geometry_info.xi=0.0;
1774 new_image=BlurImage(*image,geometry_info.rho,
1775 geometry_info.sigma,geometry_info.xi,exception);
1778 if (LocaleCompare("border",argv[0]+1) == 0)
1787 value=GetImageOption(image_info,"compose");
1788 if (value != (const char *) NULL)
1789 compose=(CompositeOperator) ParseCommandOption(
1790 MagickComposeOptions,MagickFalse,value);
1792 compose=OverCompositeOp; /* use Over not image->compose */
1794 (void) SyncImageSettings(image_info,*image,exception);
1795 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
1796 if ((flags & SigmaValue) == 0)
1797 geometry.height=geometry.width;
1798 new_image=BorderImage(*image,&geometry,compose,exception);
1801 if (LocaleCompare("brightness-contrast",argv[0]+1) == 0)
1813 (void) SyncImageSettings(image_info,*image,exception);
1814 flags=ParseGeometry(argv[1],&geometry_info);
1815 brightness=geometry_info.rho;
1817 if ((flags & SigmaValue) != 0)
1818 contrast=geometry_info.sigma;
1819 (void) BrightnessContrastImage(*image,brightness,contrast,
1827 if (LocaleCompare("cdl",argv[0]+1) == 0)
1830 *color_correction_collection;
1833 Color correct with a color decision list.
1835 (void) SyncImageSettings(image_info,*image,exception);
1836 color_correction_collection=FileToString(argv[1],~0,exception);
1837 if (color_correction_collection == (char *) NULL)
1839 (void) ColorDecisionListImage(*image,color_correction_collection,
1843 if (LocaleCompare("channel",argv[0]+1) == 0)
1845 /* The "channel" setting has already been set */
1846 SetPixelChannelMap(*image,image_info->channel);
1849 if (LocaleCompare("charcoal",argv[0]+1) == 0)
1851 (void) SyncImageSettings(image_info,*image,exception);
1852 flags=ParseGeometry(argv[1],&geometry_info);
1853 if ((flags & SigmaValue) == 0)
1854 geometry_info.sigma=1.0;
1855 if ((flags & XiValue) == 0)
1856 geometry_info.xi=1.0;
1857 new_image=CharcoalImage(*image,geometry_info.rho,
1858 geometry_info.sigma,geometry_info.xi,exception);
1861 if (LocaleCompare("chop",argv[0]+1) == 0)
1863 (void) SyncImageSettings(image_info,*image,exception);
1864 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
1865 new_image=ChopImage(*image,&geometry,exception);
1868 if (LocaleCompare("clamp",argv[0]+1) == 0)
1870 (void) SyncImageSettings(image_info,*image,exception);
1871 (void) ClampImage(*image,exception);
1874 if (LocaleCompare("clip",argv[0]+1) == 0)
1876 (void) SyncImageSettings(image_info,*image,exception);
1877 if (*argv[0] == '+')
1879 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1882 (void) ClipImage(*image,exception);
1885 if (LocaleCompare("clip-mask",argv[0]+1) == 0)
1902 (void) SyncImageSettings(image_info,*image,exception);
1903 if (*argv[0] == '+')
1905 /* Remove the write mask */
1906 (void) SetImageMask(*image,(Image *) NULL,exception);
1909 mask_image=GetImageCache(image_info,argv[1],exception);
1910 if (mask_image == (Image *) NULL)
1912 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1913 return(MagickFalse);
1914 /* create a write mask from clip-mask image */
1915 /* FUTURE: use Alpha operations instead */
1916 mask_view=AcquireCacheView(mask_image);
1917 for (y=0; y < (ssize_t) mask_image->rows; y++)
1919 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1921 if (q == (Quantum *) NULL)
1923 for (x=0; x < (ssize_t) mask_image->columns; x++)
1925 if (mask_image->matte == MagickFalse)
1926 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1927 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1928 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1929 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1930 q+=GetPixelChannels(mask_image);
1932 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1935 /* set the write mask */
1936 mask_view=DestroyCacheView(mask_view);
1937 mask_image->matte=MagickTrue;
1938 (void) SetImageClipMask(*image,mask_image,exception);
1939 mask_image=DestroyImage(mask_image);
1942 if (LocaleCompare("clip-path",argv[0]+1) == 0)
1944 (void) SyncImageSettings(image_info,*image,exception);
1945 (void) ClipImagePath(*image,argv[1],*argv[0] == '-' ? MagickTrue :
1946 MagickFalse,exception);
1949 if (LocaleCompare("colorize",argv[0]+1) == 0)
1951 (void) SyncImageSettings(image_info,*image,exception);
1952 new_image=ColorizeImage(*image,argv[1],draw_info->fill,
1956 if (LocaleCompare("color-matrix",argv[0]+1) == 0)
1961 (void) SyncImageSettings(image_info,*image,exception);
1962 kernel=AcquireKernelInfo(argv[1]);
1963 if (kernel == (KernelInfo *) NULL)
1965 new_image=ColorMatrixImage(*image,kernel,exception);
1966 kernel=DestroyKernelInfo(kernel);
1969 if (LocaleCompare("colors",argv[0]+1) == 0)
1971 /* Reduce the number of colors in the image. */
1972 (void) SyncImageSettings(image_info,*image,exception);
1973 quantize_info->number_colors=StringToUnsignedLong(argv[1]);
1974 if (quantize_info->number_colors == 0)
1976 if (((*image)->storage_class == DirectClass) ||
1977 (*image)->colors > quantize_info->number_colors)
1978 (void) QuantizeImage(quantize_info,*image,exception);
1980 (void) CompressImageColormap(*image,exception);
1983 if (LocaleCompare("colorspace",argv[0]+1) == 0)
1985 /* This is a Image Setting, which should already been set */
1986 /* FUTURE: default colorspace should be sRGB!
1987 Unless some type of 'linear colorspace' mode is set.
1988 Note that +colorspace sets "undefined" or no effect on
1989 new images, but forces images already in memory back to RGB!
1991 (void) SyncImageSettings(image_info,*image,exception);
1992 (void) TransformImageColorspace(*image,
1993 IfSetOption ? image_info->colorspace : RGBColorspace,
1997 if (LocaleCompare("contrast",argv[0]+1) == 0)
1999 (void) SyncImageSettings(image_info,*image,exception);
2000 (void) ContrastImage(*image,(*argv[0] == '-') ? MagickTrue :
2001 MagickFalse,exception);
2004 if (LocaleCompare("contrast-stretch",argv[0]+1) == 0)
2014 Contrast stretch image.
2016 (void) SyncImageSettings(image_info,*image,exception);
2017 flags=ParseGeometry(argv[1],&geometry_info);
2018 black_point=geometry_info.rho;
2019 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2021 if ((flags & PercentValue) != 0)
2023 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2024 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2026 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2028 (void) ContrastStretchImage(*image,black_point,white_point,
2032 if (LocaleCompare("convolve",argv[0]+1) == 0)
2037 (void) SyncImageSettings(image_info,*image,exception);
2038 kernel_info=AcquireKernelInfo(argv[1]);
2039 if (kernel_info == (KernelInfo *) NULL)
2041 kernel_info->bias=(*image)->bias;
2042 new_image=ConvolveImage(*image,kernel_info,exception);
2043 kernel_info=DestroyKernelInfo(kernel_info);
2046 if (LocaleCompare("crop",argv[0]+1) == 0)
2049 Crop a image to a smaller size
2051 (void) SyncImageSettings(image_info,*image,exception);
2052 new_image=CropImageToTiles(*image,argv[1],exception);
2055 if (LocaleCompare("cycle",argv[0]+1) == 0)
2058 Cycle an image colormap.
2060 (void) SyncImageSettings(image_info,*image,exception);
2061 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[1]),
2069 if (LocaleCompare("decipher",argv[0]+1) == 0)
2077 (void) SyncImageSettings(image_info,*image,exception);
2078 passkey=FileToStringInfo(argv[1],~0,exception);
2079 if (passkey != (StringInfo *) NULL)
2081 (void) PasskeyDecipherImage(*image,passkey,exception);
2082 passkey=DestroyStringInfo(passkey);
2086 if (LocaleCompare("depth",argv[0]+1) == 0)
2088 /* the image_info->depth setting has already bee set
2089 * We just need to apply it to all images in current sequence */
2090 (void) SyncImageSettings(image_info,*image,exception);
2091 (void) SetImageDepth(*image,image_info->depth);
2094 if (LocaleCompare("deskew",argv[0]+1) == 0)
2100 Straighten the image.
2102 (void) SyncImageSettings(image_info,*image,exception);
2103 if (*argv[0] == '+')
2104 threshold=40.0*QuantumRange/100.0;
2106 threshold=SiPrefixToDouble(argv[1],QuantumRange);
2107 new_image=DeskewImage(*image,threshold,exception);
2110 if (LocaleCompare("despeckle",argv[0]+1) == 0)
2113 Reduce the speckles within an image.
2115 (void) SyncImageSettings(image_info,*image,exception);
2116 new_image=DespeckleImage(*image,exception);
2119 if (LocaleCompare("display",argv[0]+1) == 0)
2121 (void) CloneString(&draw_info->server_name,argv[1]);
2124 if (LocaleCompare("distort",argv[0]+1) == 0)
2128 token[MaxTextExtent];
2148 (void) SyncImageSettings(image_info,*image,exception);
2149 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
2150 MagickFalse,argv[1]);
2151 if ( method == ResizeDistortion )
2153 /* Special Case - Argument is actually a resize geometry!
2154 ** Convert that to an appropriate distortion argument array.
2158 (void) ParseRegionGeometry(*image,argv[2],&geometry,
2160 resize_args[0]=(double)geometry.width;
2161 resize_args[1]=(double)geometry.height;
2162 new_image=DistortImage(*image,method,(size_t)2,
2163 resize_args,MagickTrue,exception);
2166 args=InterpretImageProperties(image_info,*image,argv[2],
2168 if (args == (char *) NULL)
2171 for (x=0; *p != '\0'; x++)
2173 GetMagickToken(p,&p,token);
2175 GetMagickToken(p,&p,token);
2177 number_arguments=(size_t) x;
2178 arguments=(double *) AcquireQuantumMemory(number_arguments,
2179 sizeof(*arguments));
2180 if (arguments == (double *) NULL)
2181 ThrowWandFatalException(ResourceLimitFatalError,
2182 "MemoryAllocationFailed",(*image)->filename);
2183 (void) ResetMagickMemory(arguments,0,number_arguments*
2184 sizeof(*arguments));
2186 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
2188 GetMagickToken(p,&p,token);
2190 GetMagickToken(p,&p,token);
2191 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
2193 args=DestroyString(args);
2194 new_image=DistortImage(*image,method,number_arguments,arguments,
2195 (*argv[0] == '+') ? MagickTrue : MagickFalse,exception);
2196 arguments=(double *) RelinquishMagickMemory(arguments);
2199 if (LocaleCompare("draw",argv[0]+1) == 0)
2201 (void) SyncImageSettings(image_info,*image,exception);
2202 (void) CloneString(&draw_info->primitive,argv[1]);
2203 (void) DrawImage(*image,draw_info,exception);
2210 if (LocaleCompare("edge",argv[0]+1) == 0)
2212 (void) SyncImageSettings(image_info,*image,exception);
2213 flags=ParseGeometry(argv[1],&geometry_info);
2214 if ((flags & SigmaValue) == 0)
2215 geometry_info.sigma=1.0;
2216 new_image=EdgeImage(*image,geometry_info.rho,
2217 geometry_info.sigma,exception);
2220 if (LocaleCompare("emboss",argv[0]+1) == 0)
2222 (void) SyncImageSettings(image_info,*image,exception);
2223 flags=ParseGeometry(argv[1],&geometry_info);
2224 if ((flags & SigmaValue) == 0)
2225 geometry_info.sigma=1.0;
2226 new_image=EmbossImage(*image,geometry_info.rho,
2227 geometry_info.sigma,exception);
2230 if (LocaleCompare("encipher",argv[0]+1) == 0)
2235 (void) SyncImageSettings(image_info,*image,exception);
2236 passkey=FileToStringInfo(argv[1],~0,exception);
2237 if (passkey != (StringInfo *) NULL)
2239 (void) PasskeyEncipherImage(*image,passkey,exception);
2240 passkey=DestroyStringInfo(passkey);
2244 if (LocaleCompare("enhance",argv[0]+1) == 0)
2246 (void) SyncImageSettings(image_info,*image,exception);
2247 new_image=EnhanceImage(*image,exception);
2250 if (LocaleCompare("equalize",argv[0]+1) == 0)
2252 (void) SyncImageSettings(image_info,*image,exception);
2253 (void) EqualizeImage(*image,exception);
2256 if (LocaleCompare("evaluate",argv[0]+1) == 0)
2261 MagickEvaluateOperator
2264 (void) SyncImageSettings(image_info,*image,exception);
2265 op=(MagickEvaluateOperator) ParseCommandOption(
2266 MagickEvaluateOptions,MagickFalse,argv[1]);
2267 constant=SiPrefixToDouble(argv[2],QuantumRange);
2268 (void) EvaluateImage(*image,op,constant,exception);
2271 if (LocaleCompare("extent",argv[0]+1) == 0)
2273 (void) SyncImageSettings(image_info,*image,exception);
2274 flags=ParseGravityGeometry(*image,argv[1],&geometry,exception);
2275 if (geometry.width == 0)
2276 geometry.width=(*image)->columns;
2277 if (geometry.height == 0)
2278 geometry.height=(*image)->rows;
2279 new_image=ExtentImage(*image,&geometry,exception);
2286 if (LocaleCompare("features",argv[0]+1) == 0)
2288 /* FUTURE: Assign Artifact all images */
2289 (void) SetImageArtifact(*image,"identify:features",
2290 IfSetOption ? argv[1] : (const char *) NULL);
2293 if (LocaleCompare("flip",argv[0]+1) == 0)
2296 Flip image scanlines.
2298 (void) SyncImageSettings(image_info,*image,exception);
2299 new_image=FlipImage(*image,exception);
2302 if (LocaleCompare("flop",argv[0]+1) == 0)
2305 Flop image scanlines.
2307 (void) SyncImageSettings(image_info,*image,exception);
2308 new_image=FlopImage(*image,exception);
2311 if (LocaleCompare("floodfill",argv[0]+1) == 0)
2319 (void) SyncImageSettings(image_info,*image,exception);
2320 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
2321 (void) QueryColorCompliance(argv[2],AllCompliance,&target,
2323 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
2324 geometry.y,*argv[0] == '-' ? MagickFalse : MagickTrue,exception);
2327 /* FUTURE: should be from ImageOption "format"
2328 if (LocaleCompare("format",argv[0]+1) == 0)
2334 if (LocaleCompare("frame",argv[0]+1) == 0)
2340 Surround image with an ornamental border.
2342 (void) SyncImageSettings(image_info,*image,exception);
2343 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
2344 frame_info.width=geometry.width;
2345 frame_info.height=geometry.height;
2346 if ((flags & HeightValue) == 0)
2347 frame_info.height=geometry.width;
2348 frame_info.outer_bevel=geometry.x;
2349 frame_info.inner_bevel=geometry.y;
2350 frame_info.x=(ssize_t) frame_info.width;
2351 frame_info.y=(ssize_t) frame_info.height;
2352 frame_info.width=(*image)->columns+2*frame_info.width;
2353 frame_info.height=(*image)->rows+2*frame_info.height;
2354 new_image=FrameImage(*image,&frame_info,COMPOSE,exception);
2357 if (LocaleCompare("function",argv[0]+1) == 0)
2361 token[MaxTextExtent];
2379 Function Modify Image Values
2381 (void) SyncImageSettings(image_info,*image,exception);
2382 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
2383 MagickFalse,argv[1]);
2384 arguments=InterpretImageProperties(image_info,*image,argv[2],
2386 if (arguments == (char *) NULL)
2388 p=(char *) arguments;
2389 for (x=0; *p != '\0'; x++)
2391 GetMagickToken(p,&p,token);
2393 GetMagickToken(p,&p,token);
2395 number_parameters=(size_t) x;
2396 parameters=(double *) AcquireQuantumMemory(number_parameters,
2397 sizeof(*parameters));
2398 if (parameters == (double *) NULL)
2399 ThrowWandFatalException(ResourceLimitFatalError,
2400 "MemoryAllocationFailed",(*image)->filename);
2401 (void) ResetMagickMemory(parameters,0,number_parameters*
2402 sizeof(*parameters));
2403 p=(char *) arguments;
2404 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
2406 GetMagickToken(p,&p,token);
2408 GetMagickToken(p,&p,token);
2409 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
2411 arguments=DestroyString(arguments);
2412 (void) FunctionImage(*image,function,number_parameters,parameters,
2414 parameters=(double *) RelinquishMagickMemory(parameters);
2421 if (LocaleCompare("gamma",argv[0]+1) == 0)
2423 (void) SyncImageSettings(image_info,*image,exception);
2424 if (*argv[0] == '+')
2425 (*image)->gamma=InterpretLocaleValue(argv[1],(char **) NULL);
2427 (void) GammaImage(*image,InterpretLocaleValue(argv[1],
2428 (char **) NULL),exception);
2431 if ((LocaleCompare("gaussian-blur",argv[0]+1) == 0) ||
2432 (LocaleCompare("gaussian",argv[0]+1) == 0))
2434 (void) SyncImageSettings(image_info,*image,exception);
2435 flags=ParseGeometry(argv[1],&geometry_info);
2436 if ((flags & SigmaValue) == 0)
2437 geometry_info.sigma=1.0;
2438 if ((flags & XiValue) == 0)
2439 geometry_info.xi=0.0;
2440 new_image=GaussianBlurImage(*image,geometry_info.rho,
2441 geometry_info.sigma,geometry_info.xi,exception);
2444 if (LocaleCompare("geometry",argv[0]+1) == 0)
2447 Record Image offset for composition,
2448 Resize last image. -- FUTURE depreciate this aspect
2450 (void) SyncImageSettings(image_info,*image,exception);
2451 if (*argv[0] == '+')
2453 if ((*image)->geometry != (char *) NULL)
2454 (*image)->geometry=DestroyString((*image)->geometry);
2457 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2458 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2459 (void) CloneString(&(*image)->geometry,argv[1]);
2461 new_image=ResizeImage(*image,geometry.width,geometry.height,
2462 (*image)->filter,(*image)->blur,exception);
2469 if (LocaleCompare("highlight-color",argv[0]+1) == 0)
2471 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2478 if (LocaleCompare("identify",argv[0]+1) == 0)
2483 (void) SyncImageSettings(image_info,*image,exception);
2484 if (format == (char *) NULL)
2486 (void) IdentifyImage(*image,stdout,image_info->verbose,
2490 text=InterpretImageProperties(image_info,*image,format,
2492 if (text == (char *) NULL)
2494 (void) fputs(text,stdout);
2495 (void) fputc('\n',stdout);
2496 text=DestroyString(text);
2499 if (LocaleCompare("implode",argv[0]+1) == 0)
2504 (void) SyncImageSettings(image_info,*image,exception);
2505 (void) ParseGeometry(argv[1],&geometry_info);
2506 new_image=ImplodeImage(*image,geometry_info.rho,
2507 interpolate_method,exception);
2510 if (LocaleCompare("interline-spacing",argv[0]+1) == 0)
2512 if (*argv[0] == '+')
2513 (void) ParseGeometry("0",&geometry_info);
2515 (void) ParseGeometry(argv[1],&geometry_info);
2516 draw_info->interline_spacing=geometry_info.rho;
2519 if (LocaleCompare("interpolate",argv[0]+1) == 0)
2521 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
2522 MagickInterpolateOptions,MagickFalse,argv[1]);
2525 if (LocaleCompare("interword-spacing",argv[0]+1) == 0)
2527 if (*argv[0] == '+')
2528 (void) ParseGeometry("0",&geometry_info);
2530 (void) ParseGeometry(argv[1],&geometry_info);
2531 draw_info->interword_spacing=geometry_info.rho;
2538 if (LocaleCompare("kerning",argv[0]+1) == 0)
2540 if (*argv[0] == '+')
2541 (void) ParseGeometry("0",&geometry_info);
2543 (void) ParseGeometry(argv[1],&geometry_info);
2544 draw_info->kerning=geometry_info.rho;
2551 if (LocaleCompare("lat",argv[0]+1) == 0)
2554 Local adaptive threshold image.
2556 (void) SyncImageSettings(image_info,*image,exception);
2557 flags=ParseGeometry(argv[1],&geometry_info);
2558 if ((flags & PercentValue) != 0)
2559 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2560 new_image=AdaptiveThresholdImage(*image,(size_t)
2561 geometry_info.rho,(size_t) geometry_info.sigma,(double)
2562 geometry_info.xi,exception);
2565 if (LocaleCompare("level",argv[0]+1) == 0)
2578 (void) SyncImageSettings(image_info,*image,exception);
2579 flags=ParseGeometry(argv[1],&geometry_info);
2580 black_point=geometry_info.rho;
2581 white_point=(MagickRealType) QuantumRange;
2582 if ((flags & SigmaValue) != 0)
2583 white_point=geometry_info.sigma;
2585 if ((flags & XiValue) != 0)
2586 gamma=geometry_info.xi;
2587 if ((flags & PercentValue) != 0)
2589 black_point*=(MagickRealType) (QuantumRange/100.0);
2590 white_point*=(MagickRealType) (QuantumRange/100.0);
2592 if ((flags & SigmaValue) == 0)
2593 white_point=(MagickRealType) QuantumRange-black_point;
2594 if ((*argv[0] == '+') || ((flags & AspectValue) != 0))
2595 (void) LevelizeImage(*image,black_point,white_point,gamma,
2598 (void) LevelImage(*image,black_point,white_point,gamma,
2602 if (LocaleCompare("level-colors",argv[0]+1) == 0)
2605 token[MaxTextExtent];
2614 p=(const char *) argv[1];
2615 GetMagickToken(p,&p,token); /* get black point color */
2616 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2617 (void) QueryColorCompliance(token,AllCompliance,
2618 &black_point,exception);
2620 (void) QueryColorCompliance("#000000",AllCompliance,
2621 &black_point,exception);
2622 if (isalpha((int) token[0]) || (token[0] == '#'))
2623 GetMagickToken(p,&p,token);
2625 white_point=black_point; /* set everything to that color */
2628 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2629 GetMagickToken(p,&p,token); /* Get white point color. */
2630 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2631 (void) QueryColorCompliance(token,AllCompliance,
2632 &white_point,exception);
2634 (void) QueryColorCompliance("#ffffff",AllCompliance,
2635 &white_point,exception);
2637 (void) LevelImageColors(*image,&black_point,&white_point,
2638 *argv[0] == '+' ? MagickTrue : MagickFalse,exception);
2641 if (LocaleCompare("linear-stretch",argv[0]+1) == 0)
2650 (void) SyncImageSettings(image_info,*image,exception);
2651 flags=ParseGeometry(argv[1],&geometry_info);
2652 black_point=geometry_info.rho;
2653 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2654 if ((flags & SigmaValue) != 0)
2655 white_point=geometry_info.sigma;
2656 if ((flags & PercentValue) != 0)
2658 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2659 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2661 if ((flags & SigmaValue) == 0)
2662 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2664 (void) LinearStretchImage(*image,black_point,white_point,exception);
2667 if (LocaleCompare("linewidth",argv[0]+1) == 0)
2669 draw_info->stroke_width=InterpretLocaleValue(argv[1],
2673 if (LocaleCompare("liquid-rescale",argv[0]+1) == 0)
2676 Liquid rescale image.
2678 (void) SyncImageSettings(image_info,*image,exception);
2679 flags=ParseRegionGeometry(*image,argv[1],&geometry,exception);
2680 if ((flags & XValue) == 0)
2682 if ((flags & YValue) == 0)
2684 new_image=LiquidRescaleImage(*image,geometry.width,
2685 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2688 if (LocaleCompare("lowlight-color",argv[0]+1) == 0)
2690 (void) SetImageArtifact(*image,argv[0]+1,argv[1]);
2697 if (LocaleCompare("map",argv[0]+1) == 0)
2703 Transform image colors to match this set of colors.
2705 (void) SyncImageSettings(image_info,*image,exception);
2706 if (*argv[0] == '+')
2708 remap_image=GetImageCache(image_info,argv[1],exception);
2709 if (remap_image == (Image *) NULL)
2711 (void) RemapImage(quantize_info,*image,remap_image,exception);
2712 remap_image=DestroyImage(remap_image);
2715 if (LocaleCompare("mask",argv[0]+1) == 0)
2720 (void) SyncImageSettings(image_info,*image,exception);
2721 if (*argv[0] == '+')
2726 (void) SetImageMask(*image,(Image *) NULL,exception);
2732 mask=GetImageCache(image_info,argv[1],exception);
2733 if (mask == (Image *) NULL)
2735 (void) SetImageMask(*image,mask,exception);
2736 mask=DestroyImage(mask);
2739 if (LocaleCompare("matte",argv[0]+1) == 0)
2741 (void) SetImageAlphaChannel(*image,(*argv[0] == '-') ?
2742 SetAlphaChannel : DeactivateAlphaChannel,exception);
2745 if (LocaleCompare("median",argv[0]+1) == 0)
2748 Median filter image.
2750 (void) SyncImageSettings(image_info,*image,exception);
2751 flags=ParseGeometry(argv[1],&geometry_info);
2752 if ((flags & SigmaValue) == 0)
2753 geometry_info.sigma=geometry_info.rho;
2754 new_image=StatisticImage(*image,MedianStatistic,(size_t)
2755 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2758 if (LocaleCompare("mode",argv[0]+1) == 0)
2763 (void) SyncImageSettings(image_info,*image,exception);
2764 flags=ParseGeometry(argv[1],&geometry_info);
2765 if ((flags & SigmaValue) == 0)
2766 geometry_info.sigma=geometry_info.rho;
2767 new_image=StatisticImage(*image,ModeStatistic,(size_t)
2768 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2771 if (LocaleCompare("modulate",argv[0]+1) == 0)
2773 (void) SyncImageSettings(image_info,*image,exception);
2774 (void) ModulateImage(*image,argv[1],exception);
2777 if (LocaleCompare("monitor",argv[0]+1) == 0)
2779 if (*argv[0] == '+')
2781 (void) SetImageProgressMonitor(*image,
2782 (MagickProgressMonitor) NULL,(void *) NULL);
2785 (void) SetImageProgressMonitor(*image,MonitorProgress,
2789 if (LocaleCompare("monochrome",argv[0]+1) == 0)
2791 (void) SyncImageSettings(image_info,*image,exception);
2792 (void) SetImageType(*image,BilevelType,exception);
2795 if (LocaleCompare("morphology",argv[0]+1) == 0)
2798 token[MaxTextExtent];
2813 Morphological Image Operation
2815 (void) SyncImageSettings(image_info,*image,exception);
2817 GetMagickToken(p,&p,token);
2818 method=(MorphologyMethod) ParseCommandOption(
2819 MagickMorphologyOptions,MagickFalse,token);
2821 GetMagickToken(p,&p,token);
2822 if ((*p == ':') || (*p == ','))
2823 GetMagickToken(p,&p,token);
2825 iterations=(ssize_t) StringToLong(p);
2826 kernel=AcquireKernelInfo(argv[2]);
2827 if (kernel == (KernelInfo *) NULL)
2829 (void) ThrowMagickException(exception,GetMagickModule(),
2830 OptionError,"UnabletoParseKernel","morphology");
2834 new_image=MorphologyImage(*image,method,iterations,kernel,
2836 kernel=DestroyKernelInfo(kernel);
2839 if (LocaleCompare("motion-blur",argv[0]+1) == 0)
2844 (void) SyncImageSettings(image_info,*image,exception);
2845 flags=ParseGeometry(argv[1],&geometry_info);
2846 if ((flags & SigmaValue) == 0)
2847 geometry_info.sigma=1.0;
2848 new_image=MotionBlurImage(*image,geometry_info.rho,
2849 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2857 if (LocaleCompare("negate",argv[0]+1) == 0)
2859 (void) SyncImageSettings(image_info,*image,exception);
2860 (void) NegateImage(*image,*argv[0] == '+' ? MagickTrue :
2861 MagickFalse,exception);
2864 if (LocaleCompare("noise",argv[0]+1) == 0)
2866 (void) SyncImageSettings(image_info,*image,exception);
2867 if (*argv[0] == '-')
2869 flags=ParseGeometry(argv[1],&geometry_info);
2870 if ((flags & SigmaValue) == 0)
2871 geometry_info.sigma=geometry_info.rho;
2872 new_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2873 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2880 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2881 MagickFalse,argv[1]);
2882 new_image=AddNoiseImage(*image,noise,exception);
2886 if (LocaleCompare("normalize",argv[0]+1) == 0)
2888 (void) SyncImageSettings(image_info,*image,exception);
2889 (void) NormalizeImage(*image,exception);
2896 if (LocaleCompare("opaque",argv[0]+1) == 0)
2901 (void) SyncImageSettings(image_info,*image,exception);
2902 (void) QueryColorCompliance(argv[1],AllCompliance,&target,
2904 (void) OpaquePaintImage(*image,&target,&fill,*argv[0] == '-' ?
2905 MagickFalse : MagickTrue,exception);
2908 if (LocaleCompare("ordered-dither",argv[0]+1) == 0)
2910 (void) SyncImageSettings(image_info,*image,exception);
2911 (void) OrderedPosterizeImage(*image,argv[1],exception);
2918 if (LocaleCompare("paint",argv[0]+1) == 0)
2920 (void) SyncImageSettings(image_info,*image,exception);
2921 (void) ParseGeometry(argv[1],&geometry_info);
2922 new_image=OilPaintImage(*image,geometry_info.rho,
2923 geometry_info.sigma,exception);
2926 if (LocaleCompare("pen",argv[0]+1) == 0)
2928 if (*argv[0] == '+')
2930 (void) QueryColorCompliance("none",AllCompliance,&draw_info->fill,
2934 (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->fill,
2938 if (LocaleCompare("pointsize",argv[0]+1) == 0)
2940 if (*argv[0] == '+')
2941 (void) ParseGeometry("12",&geometry_info);
2943 (void) ParseGeometry(argv[1],&geometry_info);
2944 draw_info->pointsize=geometry_info.rho;
2947 if (LocaleCompare("polaroid",argv[0]+1) == 0)
2956 Simulate a Polaroid picture.
2958 (void) SyncImageSettings(image_info,*image,exception);
2959 random_info=AcquireRandomInfo();
2960 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2961 random_info=DestroyRandomInfo(random_info);
2962 if (*argv[0] == '-')
2964 SetGeometryInfo(&geometry_info);
2965 flags=ParseGeometry(argv[1],&geometry_info);
2966 angle=geometry_info.rho;
2968 new_image=PolaroidImage(*image,draw_info,angle,
2969 interpolate_method,exception);
2972 if (LocaleCompare("posterize",argv[0]+1) == 0)
2977 (void) SyncImageSettings(image_info,*image,exception);
2978 (void) PosterizeImage(*image,StringToUnsignedLong(argv[1]),
2979 quantize_info->dither,exception);
2982 if (LocaleCompare("preview",argv[0]+1) == 0)
2990 (void) SyncImageSettings(image_info,*image,exception);
2991 if (*argv[0] == '+')
2992 preview_type=UndefinedPreview;
2994 preview_type=(PreviewType) ParseCommandOption(
2995 MagickPreviewOptions,MagickFalse,argv[1]);
2996 new_image=PreviewImage(*image,preview_type,exception);
2999 if (LocaleCompare("profile",argv[0]+1) == 0)
3013 (void) SyncImageSettings(image_info,*image,exception);
3014 if (*argv[0] == '+')
3017 Remove a profile from the image.
3019 (void) ProfileImage(*image,argv[1],(const unsigned char *)
3024 Associate a profile with the image.
3026 profile_info=CloneImageInfo(image_info);
3027 profile=GetImageProfile(*image,"iptc");
3028 if (profile != (StringInfo *) NULL)
3029 profile_info->profile=(void *) CloneStringInfo(profile);
3030 profile_image=GetImageCache(profile_info,argv[1],exception);
3031 profile_info=DestroyImageInfo(profile_info);
3032 if (profile_image == (Image *) NULL)
3037 profile_info=CloneImageInfo(image_info);
3038 (void) CopyMagickString(profile_info->filename,argv[1],
3040 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
3041 if (profile != (StringInfo *) NULL)
3043 (void) ProfileImage(*image,profile_info->magick,
3044 GetStringInfoDatum(profile),(size_t)
3045 GetStringInfoLength(profile),exception);
3046 profile=DestroyStringInfo(profile);
3048 profile_info=DestroyImageInfo(profile_info);
3051 ResetImageProfileIterator(profile_image);
3052 name=GetNextImageProfile(profile_image);
3053 while (name != (const char *) NULL)
3055 profile=GetImageProfile(profile_image,name);
3056 if (profile != (StringInfo *) NULL)
3057 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
3058 (size_t) GetStringInfoLength(profile),exception);
3059 name=GetNextImageProfile(profile_image);
3061 profile_image=DestroyImage(profile_image);
3068 if (LocaleCompare("quantize",argv[0]+1) == 0)
3070 if (*argv[0] == '+')
3072 quantize_info->colorspace=UndefinedColorspace;
3075 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
3076 MagickColorspaceOptions,MagickFalse,argv[1]);
3083 if (LocaleCompare("radial-blur",argv[0]+1) == 0)
3088 (void) SyncImageSettings(image_info,*image,exception);
3089 flags=ParseGeometry(argv[1],&geometry_info);
3090 new_image=RadialBlurImage(*image,geometry_info.rho,
3091 geometry_info.sigma,exception);
3094 if (LocaleCompare("raise",argv[0]+1) == 0)
3097 Surround image with a raise of solid color.
3099 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3100 if ((flags & SigmaValue) == 0)
3101 geometry.height=geometry.width;
3102 (void) RaiseImage(*image,&geometry,*argv[0] == '-' ? MagickTrue :
3103 MagickFalse,exception);
3106 if (LocaleCompare("random-threshold",argv[0]+1) == 0)
3111 (void) SyncImageSettings(image_info,*image,exception);
3112 (void) RandomThresholdImage(*image,argv[1],exception);
3115 if (LocaleCompare("recolor",argv[0]+1) == 0)
3120 (void) SyncImageSettings(image_info,*image,exception);
3121 kernel=AcquireKernelInfo(argv[1]);
3122 if (kernel == (KernelInfo *) NULL)
3124 new_image=ColorMatrixImage(*image,kernel,exception);
3125 kernel=DestroyKernelInfo(kernel);
3128 if (LocaleCompare("render",argv[0]+1) == 0)
3130 (void) SyncImageSettings(image_info,*image,exception);
3131 draw_info->render=(*argv[0] == '+') ? MagickTrue : MagickFalse;
3134 if (LocaleCompare("remap",argv[0]+1) == 0)
3140 Transform image colors to match this set of colors.
3142 (void) SyncImageSettings(image_info,*image,exception);
3143 if (*argv[0] == '+')
3145 remap_image=GetImageCache(image_info,argv[1],exception);
3146 if (remap_image == (Image *) NULL)
3148 (void) RemapImage(quantize_info,*image,remap_image,exception);
3149 remap_image=DestroyImage(remap_image);
3152 if (LocaleCompare("repage",argv[0]+1) == 0)
3154 if (*argv[0] == '+')
3156 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
3159 (void) ResetImagePage(*image,argv[1]);
3162 if (LocaleCompare("resample",argv[0]+1) == 0)
3167 (void) SyncImageSettings(image_info,*image,exception);
3168 flags=ParseGeometry(argv[1],&geometry_info);
3169 if ((flags & SigmaValue) == 0)
3170 geometry_info.sigma=geometry_info.rho;
3171 new_image=ResampleImage(*image,geometry_info.rho,
3172 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
3175 if (LocaleCompare("resize",argv[0]+1) == 0)
3180 (void) SyncImageSettings(image_info,*image,exception);
3181 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3182 new_image=ResizeImage(*image,geometry.width,geometry.height,
3183 (*image)->filter,(*image)->blur,exception);
3186 if (LocaleCompare("roll",argv[0]+1) == 0)
3191 (void) SyncImageSettings(image_info,*image,exception);
3192 (void) ParsePageGeometry(*image,argv[1],&geometry,exception);
3193 new_image=RollImage(*image,geometry.x,geometry.y,exception);
3196 if (LocaleCompare("rotate",argv[0]+1) == 0)
3202 Check for conditional image rotation.
3204 (void) SyncImageSettings(image_info,*image,exception);
3205 if (strchr(argv[1],'>') != (char *) NULL)
3206 if ((*image)->columns <= (*image)->rows)
3208 if (strchr(argv[1],'<') != (char *) NULL)
3209 if ((*image)->columns >= (*image)->rows)
3214 geometry=ConstantString(argv[1]);
3215 (void) SubstituteString(&geometry,">","");
3216 (void) SubstituteString(&geometry,"<","");
3217 (void) ParseGeometry(geometry,&geometry_info);
3218 geometry=DestroyString(geometry);
3219 new_image=RotateImage(*image,geometry_info.rho,exception);
3226 if (LocaleCompare("sample",argv[0]+1) == 0)
3229 Sample image with pixel replication.
3231 (void) SyncImageSettings(image_info,*image,exception);
3232 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3233 new_image=SampleImage(*image,geometry.width,geometry.height,
3237 if (LocaleCompare("scale",argv[0]+1) == 0)
3242 (void) SyncImageSettings(image_info,*image,exception);
3243 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3244 new_image=ScaleImage(*image,geometry.width,geometry.height,
3248 if (LocaleCompare("selective-blur",argv[0]+1) == 0)
3251 Selectively blur pixels within a contrast threshold.
3253 (void) SyncImageSettings(image_info,*image,exception);
3254 flags=ParseGeometry(argv[1],&geometry_info);
3255 if ((flags & PercentValue) != 0)
3256 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3257 new_image=SelectiveBlurImage(*image,geometry_info.rho,
3258 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3261 if (LocaleCompare("separate",argv[0]+1) == 0)
3264 Break channels into separate images.
3265 WARNING: This can generate multiple images!
3267 (void) SyncImageSettings(image_info,*image,exception);
3268 new_image=SeparateImages(*image,exception);
3271 if (LocaleCompare("sepia-tone",argv[0]+1) == 0)
3279 (void) SyncImageSettings(image_info,*image,exception);
3280 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3281 new_image=SepiaToneImage(*image,threshold,exception);
3284 if (LocaleCompare("segment",argv[0]+1) == 0)
3289 (void) SyncImageSettings(image_info,*image,exception);
3290 flags=ParseGeometry(argv[1],&geometry_info);
3291 if ((flags & SigmaValue) == 0)
3292 geometry_info.sigma=1.0;
3293 (void) SegmentImage(*image,(*image)->colorspace,
3294 image_info->verbose,geometry_info.rho,geometry_info.sigma,
3298 if (LocaleCompare("set",argv[0]+1) == 0)
3303 if (*argv[0] == '+')
3305 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3306 (void) DeleteImageRegistry(argv[1]+9);
3308 if (LocaleNCompare(argv[1],"argv[0]:",7) == 0)
3310 (void) DeleteImageOption(image_info,argv[1]+7);
3311 (void) DeleteImageArtifact(*image,argv[1]+7);
3314 (void) DeleteImageProperty(*image,argv[1]);
3317 value=InterpretImageProperties(image_info,*image,argv[2],
3319 if (value == (char *) NULL)
3321 if (LocaleNCompare(argv[1],"registry:",9) == 0)
3322 (void) SetImageRegistry(StringRegistryType,argv[1]+9,value,
3325 if (LocaleNCompare(argv[1],"option:",7) == 0)
3327 (void) SetImageOption(image_info,argv[1]+7,value);
3328 (void) SetImageArtifact(*image,argv[1]+7,value);
3331 (void) SetImageProperty(*image,argv[1],value,exception);
3332 value=DestroyString(value);
3335 if (LocaleCompare("shade",argv[0]+1) == 0)
3340 (void) SyncImageSettings(image_info,*image,exception);
3341 flags=ParseGeometry(argv[1],&geometry_info);
3342 if ((flags & SigmaValue) == 0)
3343 geometry_info.sigma=1.0;
3344 new_image=ShadeImage(*image,(*argv[0] == '-') ? MagickTrue :
3345 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
3348 if (LocaleCompare("shadow",argv[0]+1) == 0)
3353 (void) SyncImageSettings(image_info,*image,exception);
3354 flags=ParseGeometry(argv[1],&geometry_info);
3355 if ((flags & SigmaValue) == 0)
3356 geometry_info.sigma=1.0;
3357 if ((flags & XiValue) == 0)
3358 geometry_info.xi=4.0;
3359 if ((flags & PsiValue) == 0)
3360 geometry_info.psi=4.0;
3361 new_image=ShadowImage(*image,geometry_info.rho,
3362 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3363 ceil(geometry_info.psi-0.5),exception);
3366 if (LocaleCompare("sharpen",argv[0]+1) == 0)
3371 (void) SyncImageSettings(image_info,*image,exception);
3372 flags=ParseGeometry(argv[1],&geometry_info);
3373 if ((flags & SigmaValue) == 0)
3374 geometry_info.sigma=1.0;
3375 if ((flags & XiValue) == 0)
3376 geometry_info.xi=0.0;
3377 new_image=SharpenImage(*image,geometry_info.rho,
3378 geometry_info.sigma,geometry_info.xi,exception);
3381 if (LocaleCompare("shave",argv[0]+1) == 0)
3384 Shave the image edges.
3386 (void) SyncImageSettings(image_info,*image,exception);
3387 flags=ParsePageGeometry(*image,argv[1],&geometry,exception);
3388 new_image=ShaveImage(*image,&geometry,exception);
3391 if (LocaleCompare("shear",argv[0]+1) == 0)
3396 (void) SyncImageSettings(image_info,*image,exception);
3397 flags=ParseGeometry(argv[1],&geometry_info);
3398 if ((flags & SigmaValue) == 0)
3399 geometry_info.sigma=geometry_info.rho;
3400 new_image=ShearImage(*image,geometry_info.rho,
3401 geometry_info.sigma,exception);
3404 if (LocaleCompare("sigmoidal-contrast",argv[0]+1) == 0)
3407 Sigmoidal non-linearity contrast control.
3409 (void) SyncImageSettings(image_info,*image,exception);
3410 flags=ParseGeometry(argv[1],&geometry_info);
3411 if ((flags & SigmaValue) == 0)
3412 geometry_info.sigma=(double) QuantumRange/2.0;
3413 if ((flags & PercentValue) != 0)
3414 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3416 (void) SigmoidalContrastImage(*image,(*argv[0] == '-') ?
3417 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
3421 if (LocaleCompare("sketch",argv[0]+1) == 0)
3426 (void) SyncImageSettings(image_info,*image,exception);
3427 flags=ParseGeometry(argv[1],&geometry_info);
3428 if ((flags & SigmaValue) == 0)
3429 geometry_info.sigma=1.0;
3430 new_image=SketchImage(*image,geometry_info.rho,
3431 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3434 if (LocaleCompare("solarize",argv[0]+1) == 0)
3439 (void) SyncImageSettings(image_info,*image,exception);
3440 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3441 (void) SolarizeImage(*image,threshold,exception);
3444 if (LocaleCompare("sparse-color",argv[0]+1) == 0)
3453 Sparse Color Interpolated Gradient
3455 (void) SyncImageSettings(image_info,*image,exception);
3456 method=(SparseColorMethod) ParseCommandOption(
3457 MagickSparseColorOptions,MagickFalse,argv[1]);
3458 arguments=InterpretImageProperties(image_info,*image,argv[2],
3460 if (arguments == (char *) NULL)
3462 new_image=SparseColorOption(*image,method,arguments,
3463 argv[0][0] == '+' ? MagickTrue : MagickFalse,exception);
3464 arguments=DestroyString(arguments);
3467 if (LocaleCompare("splice",argv[0]+1) == 0)
3470 Splice a solid color into the image.
3472 (void) SyncImageSettings(image_info,*image,exception);
3473 (void) ParseGravityGeometry(*image,argv[1],&geometry,exception);
3474 new_image=SpliceImage(*image,&geometry,exception);
3477 if (LocaleCompare("spread",argv[0]+1) == 0)
3482 (void) SyncImageSettings(image_info,*image,exception);
3483 (void) ParseGeometry(argv[1],&geometry_info);
3484 new_image=SpreadImage(*image,geometry_info.rho,
3485 interpolate_method,exception);
3488 if (LocaleCompare("statistic",argv[0]+1) == 0)
3493 (void) SyncImageSettings(image_info,*image,exception);
3494 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3495 MagickFalse,argv[1]);
3496 (void) ParseGeometry(argv[2],&geometry_info);
3497 new_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
3498 (size_t) geometry_info.sigma,exception);
3501 if (LocaleCompare("stretch",argv[0]+1) == 0)
3503 if (*argv[0] == '+')
3505 draw_info->stretch=UndefinedStretch;
3508 draw_info->stretch=(StretchType) ParseCommandOption(
3509 MagickStretchOptions,MagickFalse,argv[1]);
3512 if (LocaleCompare("strip",argv[0]+1) == 0)
3515 Strip image of profiles and comments.
3517 (void) SyncImageSettings(image_info,*image,exception);
3518 (void) StripImage(*image,exception);
3521 if (LocaleCompare("stroke",argv[0]+1) == 0)
3526 if (*argv[0] == '+')
3528 (void) QueryColorCompliance("none",AllCompliance,&draw_info->stroke,
3530 if (draw_info->stroke_pattern != (Image *) NULL)
3531 draw_info->stroke_pattern=DestroyImage(
3532 draw_info->stroke_pattern);
3535 sans=AcquireExceptionInfo();
3536 status=QueryColorCompliance(argv[1],AllCompliance,&draw_info->stroke,sans);
3537 sans=DestroyExceptionInfo(sans);
3538 if (status == MagickFalse)
3539 draw_info->stroke_pattern=GetImageCache(image_info,argv[1],
3543 if (LocaleCompare("strokewidth",argv[0]+1) == 0)
3545 draw_info->stroke_width=InterpretLocaleValue(argv[1],
3549 if (LocaleCompare("style",argv[0]+1) == 0)
3551 if (*argv[0] == '+')
3553 draw_info->style=UndefinedStyle;
3556 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3557 MagickFalse,argv[1]);
3560 if (LocaleCompare("swirl",argv[0]+1) == 0)
3565 (void) SyncImageSettings(image_info,*image,exception);
3566 (void) ParseGeometry(argv[1],&geometry_info);
3567 new_image=SwirlImage(*image,geometry_info.rho,
3568 interpolate_method,exception);
3575 if (LocaleCompare("threshold",argv[0]+1) == 0)
3583 (void) SyncImageSettings(image_info,*image,exception);
3584 if (*argv[0] == '+')
3585 threshold=(double) QuantumRange/2;
3587 threshold=SiPrefixToDouble(argv[1],QuantumRange);
3588 (void) BilevelImage(*image,threshold,exception);
3591 if (LocaleCompare("thumbnail",argv[0]+1) == 0)
3596 (void) SyncImageSettings(image_info,*image,exception);
3597 (void) ParseRegionGeometry(*image,argv[1],&geometry,exception);
3598 new_image=ThumbnailImage(*image,geometry.width,geometry.height,
3602 if (LocaleCompare("tile",argv[0]+1) == 0)
3604 if (*argv[0] == '+')
3606 if (draw_info->fill_pattern != (Image *) NULL)
3607 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3610 draw_info->fill_pattern=GetImageCache(image_info,argv[1],
3614 if (LocaleCompare("tint",argv[0]+1) == 0)
3619 (void) SyncImageSettings(image_info,*image,exception);
3620 new_image=TintImage(*image,argv[1],&fill,exception);
3623 if (LocaleCompare("transform",argv[0]+1) == 0)
3626 Affine transform image.
3628 (void) SyncImageSettings(image_info,*image,exception);
3629 new_image=AffineTransformImage(*image,&draw_info->affine,
3633 if (LocaleCompare("transparent",argv[0]+1) == 0)
3638 (void) SyncImageSettings(image_info,*image,exception);
3639 (void) QueryColorCompliance(argv[1],AllCompliance,&target,
3641 (void) TransparentPaintImage(*image,&target,(Quantum)
3642 TransparentAlpha,*argv[0] == '-' ? MagickFalse : MagickTrue,
3646 if (LocaleCompare("transpose",argv[0]+1) == 0)
3649 Transpose image scanlines.
3651 (void) SyncImageSettings(image_info,*image,exception);
3652 new_image=TransposeImage(*image,exception);
3655 if (LocaleCompare("transverse",argv[0]+1) == 0)
3658 Transverse image scanlines.
3660 (void) SyncImageSettings(image_info,*image,exception);
3661 new_image=TransverseImage(*image,exception);
3664 if (LocaleCompare("treedepth",argv[0]+1) == 0)
3666 quantize_info->tree_depth=StringToUnsignedLong(argv[1]);
3669 if (LocaleCompare("trim",argv[0]+1) == 0)
3674 (void) SyncImageSettings(image_info,*image,exception);
3675 new_image=TrimImage(*image,exception);
3678 if (LocaleCompare("type",argv[0]+1) == 0)
3683 (void) SyncImageSettings(image_info,*image,exception);
3684 if (*argv[0] == '+')
3687 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3689 (*image)->type=UndefinedType;
3690 (void) SetImageType(*image,type,exception);
3697 if (LocaleCompare("undercolor",argv[0]+1) == 0)
3699 (void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->undercolor,
3703 if (LocaleCompare("unique",argv[0]+1) == 0)
3705 if (*argv[0] == '+')
3707 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3710 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3711 (void) SetImageArtifact(*image,"verbose","true");
3714 if (LocaleCompare("unique-colors",argv[0]+1) == 0)
3717 Unique image colors.
3719 (void) SyncImageSettings(image_info,*image,exception);
3720 new_image=UniqueImageColors(*image,exception);
3723 if (LocaleCompare("unsharp",argv[0]+1) == 0)
3728 (void) SyncImageSettings(image_info,*image,exception);
3729 flags=ParseGeometry(argv[1],&geometry_info);
3730 if ((flags & SigmaValue) == 0)
3731 geometry_info.sigma=1.0;
3732 if ((flags & XiValue) == 0)
3733 geometry_info.xi=1.0;
3734 if ((flags & PsiValue) == 0)
3735 geometry_info.psi=0.05;
3736 new_image=UnsharpMaskImage(*image,geometry_info.rho,
3737 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3744 if (LocaleCompare("verbose",argv[0]+1) == 0)
3746 (void) SetImageArtifact(*image,argv[0]+1,
3747 *argv[0] == '+' ? "false" : "true");
3750 if (LocaleCompare("vignette",argv[0]+1) == 0)
3755 (void) SyncImageSettings(image_info,*image,exception);
3756 flags=ParseGeometry(argv[1],&geometry_info);
3757 if ((flags & SigmaValue) == 0)
3758 geometry_info.sigma=1.0;
3759 if ((flags & XiValue) == 0)
3760 geometry_info.xi=0.1*(*image)->columns;
3761 if ((flags & PsiValue) == 0)
3762 geometry_info.psi=0.1*(*image)->rows;
3763 new_image=VignetteImage(*image,geometry_info.rho,
3764 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3765 ceil(geometry_info.psi-0.5),exception);
3768 if (LocaleCompare("virtual-pixel",argv[0]+1) == 0)
3770 if (*argv[0] == '+')
3772 (void) SetImageVirtualPixelMethod(*image,
3773 UndefinedVirtualPixelMethod);
3776 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3777 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3785 if (LocaleCompare("wave",argv[0]+1) == 0)
3790 (void) SyncImageSettings(image_info,*image,exception);
3791 flags=ParseGeometry(argv[1],&geometry_info);
3792 if ((flags & SigmaValue) == 0)
3793 geometry_info.sigma=1.0;
3794 new_image=WaveImage(*image,geometry_info.rho,
3795 geometry_info.sigma,interpolate_method,exception);
3798 if (LocaleCompare("weight",argv[0]+1) == 0)
3800 draw_info->weight=StringToUnsignedLong(argv[1]);
3801 if (LocaleCompare(argv[1],"all") == 0)
3802 draw_info->weight=0;
3803 if (LocaleCompare(argv[1],"bold") == 0)
3804 draw_info->weight=700;
3805 if (LocaleCompare(argv[1],"bolder") == 0)
3806 if (draw_info->weight <= 800)
3807 draw_info->weight+=100;
3808 if (LocaleCompare(argv[1],"lighter") == 0)
3809 if (draw_info->weight >= 100)
3810 draw_info->weight-=100;
3811 if (LocaleCompare(argv[1],"normal") == 0)
3812 draw_info->weight=400;
3815 if (LocaleCompare("white-threshold",argv[0]+1) == 0)
3818 White threshold image.
3820 (void) SyncImageSettings(image_info,*image,exception);
3821 (void) WhiteThresholdImage(*image,argv[1],exception);
3830 Replace current image with any image that was generated
3832 if (new_image != (Image *) NULL)
3833 ReplaceImageInListReturnLast(image,new_image);
3838 quantize_info=DestroyQuantizeInfo(quantize_info);
3839 draw_info=DestroyDrawInfo(draw_info);
3840 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3841 return(status == 0 ? MagickFalse : MagickTrue);
3845 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3849 + S e q u e n c e O p e r a t i o n I m a g e s %
3853 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3855 % SequenceOperationImages() applies a single operation that apply to the
3856 % entire image list (e.g. -append, -layers, -coalesce, etc.).
3858 % The format of the MogrifyImage method is:
3860 % MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3861 % const int argc, const char **argv,Image **images,
3862 % ExceptionInfo *exception)
3864 % A description of each parameter follows:
3866 % o image_info: the image info..
3868 % o argc: Specifies a pointer to an integer describing the number of
3869 % elements in the argument vector.
3871 % o argv: Specifies a pointer to a text array containing the command line
3874 % o images: pointer to pointer of the first image in image list.
3876 % o exception: return any errors or warnings in this structure.
3879 WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3880 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
3889 assert(image_info != (ImageInfo *) NULL);
3890 assert(image_info->signature == MagickSignature);
3891 assert(images != (Image **) NULL);
3892 assert((*images)->previous == (Image *) NULL);
3893 assert((*images)->signature == MagickSignature);
3894 if ((*images)->debug != MagickFalse)
3895 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3896 (*images)->filename);
3897 if ((argc <= 0) || (*argv == (char *) NULL))
3901 switch (*(argv[0]+1))
3905 if (LocaleCompare("affinity",argv[0]+1) == 0)
3907 (void) SyncImagesSettings(image_info,*images,exception);
3908 if (*argv[0] == '+')
3910 (void) RemapImages(quantize_info,*images,(Image *) NULL,
3916 if (LocaleCompare("append",argv[0]+1) == 0)
3921 (void) SyncImagesSettings(image_info,*images,exception);
3922 append_image=AppendImages(*images,*argv[0] == '-' ? MagickTrue :
3923 MagickFalse,exception);
3924 if (append_image == (Image *) NULL)
3929 *images=DestroyImageList(*images);
3930 *images=append_image;
3933 if (LocaleCompare("average",argv[0]+1) == 0)
3939 Average an image sequence (deprecated).
3941 (void) SyncImagesSettings(image_info,*images,exception);
3942 average_image=EvaluateImages(*images,MeanEvaluateOperator,
3944 if (average_image == (Image *) NULL)
3949 *images=DestroyImageList(*images);
3950 *images=average_image;
3957 if (LocaleCompare("channel",argv[0]+1) == 0)
3962 if (*argv[0] == '+')
3964 channel=DefaultChannels;
3967 channel=(ChannelType) ParseChannelOption(argv[1]);
3968 SetPixelChannelMap(*images,channel);
3971 if (LocaleCompare("clut",argv[0]+1) == 0)
3977 (void) SyncImagesSettings(image_info,*images,exception);
3978 image=RemoveFirstImageFromList(images);
3979 clut_image=RemoveFirstImageFromList(images);
3980 if (clut_image == (Image *) NULL)
3985 (void) ClutImage(image,clut_image,interpolate_method,exception);
3986 clut_image=DestroyImage(clut_image);
3987 *images=DestroyImageList(*images);
3991 if (LocaleCompare("coalesce",argv[0]+1) == 0)
3996 (void) SyncImagesSettings(image_info,*images,exception);
3997 coalesce_image=CoalesceImages(*images,exception);
3998 if (coalesce_image == (Image *) NULL)
4003 *images=DestroyImageList(*images);
4004 *images=coalesce_image;
4007 if (LocaleCompare("combine",argv[0]+1) == 0)
4012 (void) SyncImagesSettings(image_info,*images,exception);
4013 combine_image=CombineImages(*images,exception);
4014 if (combine_image == (Image *) NULL)
4019 *images=DestroyImageList(*images);
4020 *images=combine_image;
4023 if (LocaleCompare("composite",argv[0]+1) == 0)
4039 value=GetImageOption(image_info,"compose");
4040 if (value != (const char *) NULL)
4041 compose=(CompositeOperator) ParseCommandOption(
4042 MagickComposeOptions,MagickFalse,value);
4044 compose=OverCompositeOp; /* use Over not image->compose */
4047 value=GetImageOption(image_info,"compose");
4049 if (value != (const char *) NULL)
4050 compose=(CompositeOperator) ParseCommandOption(
4051 MagickComposeOptions,MagickFalse,value);
4053 compose=OverCompositeOp; /* use Over not image->compose */
4056 (void) SyncImagesSettings(image_info,*images,exception);
4057 image=RemoveFirstImageFromList(images);
4058 composite_image=RemoveFirstImageFromList(images);
4059 if (composite_image == (Image *) NULL)
4064 (void) TransformImage(&composite_image,(char *) NULL,
4065 composite_image->geometry,exception);
4066 SetGeometry(composite_image,&geometry);
4067 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
4068 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
4070 mask_image=RemoveFirstImageFromList(images);
4071 if (mask_image != (Image *) NULL)
4073 if ((compose == DisplaceCompositeOp) ||
4074 (compose == DistortCompositeOp))
4077 Merge Y displacement into X displacement image.
4079 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
4080 mask_image,0,0,exception);
4081 mask_image=DestroyImage(mask_image);
4086 Set a blending mask for the composition.
4087 Posible error, what if image->mask already set.
4089 image->mask=mask_image;
4090 (void) NegateImage(image->mask,MagickFalse,exception);
4093 (void) CompositeImage(image,compose,composite_image,
4094 geometry.x,geometry.y,exception);
4095 if (mask_image != (Image *) NULL)
4096 mask_image=image->mask=DestroyImage(image->mask);
4097 composite_image=DestroyImage(composite_image);
4098 *images=DestroyImageList(*images);
4106 if (LocaleCompare("deconstruct",argv[0]+1) == 0)
4111 (void) SyncImagesSettings(image_info,*images,exception);
4112 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
4114 if (deconstruct_image == (Image *) NULL)
4119 *images=DestroyImageList(*images);
4120 *images=deconstruct_image;
4123 if (LocaleCompare("delete",argv[0]+1) == 0)
4125 if (*argv[0] == '+')
4126 DeleteImages(images,"-1",exception);
4128 DeleteImages(images,argv[1],exception);
4131 if (LocaleCompare("dither",argv[0]+1) == 0)
4133 if (*argv[0] == '+')
4135 quantize_info->dither=MagickFalse;
4138 quantize_info->dither=MagickTrue;
4139 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
4140 MagickDitherOptions,MagickFalse,argv[1]);
4143 if (LocaleCompare("duplicate",argv[0]+1) == 0)
4148 if (*argv[0] == '+')
4149 duplicate_images=DuplicateImages(*images,1,"-1",exception);
4158 number_duplicates=(size_t) StringToLong(argv[1]);
4159 p=strchr(argv[1],',');
4160 if (p == (const char *) NULL)
4161 duplicate_images=DuplicateImages(*images,number_duplicates,
4164 duplicate_images=DuplicateImages(*images,number_duplicates,p,
4167 AppendImageToList(images, duplicate_images);
4168 (void) SyncImagesSettings(image_info,*images,exception);
4175 if (LocaleCompare("evaluate-sequence",argv[0]+1) == 0)
4180 MagickEvaluateOperator
4183 (void) SyncImageSettings(image_info,*images);
4184 op=(MagickEvaluateOperator) ParseCommandOption(
4185 MagickEvaluateOptions,MagickFalse,argv[1]);
4186 evaluate_image=EvaluateImages(*images,op,exception);
4187 if (evaluate_image == (Image *) NULL)
4192 *images=DestroyImageList(*images);
4193 *images=evaluate_image;
4200 if (LocaleCompare("fft",argv[0]+1) == 0)
4206 Implements the discrete Fourier transform (DFT).
4208 (void) SyncImageSettings(image_info,*images);
4209 fourier_image=ForwardFourierTransformImage(*images,*argv[0] == '-' ?
4210 MagickTrue : MagickFalse,exception);
4211 if (fourier_image == (Image *) NULL)
4213 *images=DestroyImage(*images);
4214 *images=fourier_image;
4217 if (LocaleCompare("flatten",argv[0]+1) == 0)
4222 (void) SyncImagesSettings(image_info,*images,exception);
4223 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
4224 if (flatten_image == (Image *) NULL)
4226 *images=DestroyImageList(*images);
4227 *images=flatten_image;
4230 if (LocaleCompare("fx",argv[0]+1) == 0)
4235 (void) SyncImagesSettings(image_info,*images,exception);
4236 fx_image=FxImage(*images,argv[1],exception);
4237 if (fx_image == (Image *) NULL)
4242 *images=DestroyImageList(*images);
4250 if (LocaleCompare("hald-clut",argv[0]+1) == 0)
4256 (void) SyncImagesSettings(image_info,*images,exception);
4257 image=RemoveFirstImageFromList(images);
4258 hald_image=RemoveFirstImageFromList(images);
4259 if (hald_image == (Image *) NULL)
4264 (void) HaldClutImage(image,hald_image,exception);
4265 hald_image=DestroyImage(hald_image);
4266 if (*images != (Image *) NULL)
4267 *images=DestroyImageList(*images);
4275 if (LocaleCompare("ift",argv[0]+1) == 0)
4283 Implements the inverse fourier discrete Fourier transform (DFT).
4285 (void) SyncImagesSettings(image_info,*images,exception);
4286 magnitude_image=RemoveFirstImageFromList(images);
4287 phase_image=RemoveFirstImageFromList(images);
4288 if (phase_image == (Image *) NULL)
4293 fourier_image=InverseFourierTransformImage(magnitude_image,
4294 phase_image,*argv[0] == '-' ? MagickTrue : MagickFalse,exception);
4295 if (fourier_image == (Image *) NULL)
4297 if (*images != (Image *) NULL)
4298 *images=DestroyImage(*images);
4299 *images=fourier_image;
4302 if (LocaleCompare("insert",argv[0]+1) == 0)
4309 if (*argv[0] != '+')
4310 index=(ssize_t) StringToLong(argv[1]);
4311 p=RemoveLastImageFromList(images);
4312 if (p == (Image *) NULL)
4314 (void) ThrowMagickException(exception,GetMagickModule(),
4315 OptionError,"NoSuchImage","`%s'",argv[1]);
4321 PrependImageToList(images,q);
4323 if (index == (ssize_t) GetImageListLength(*images))
4324 AppendImageToList(images,q);
4327 q=GetImageFromList(*images,index-1);
4328 if (q == (Image *) NULL)
4330 (void) ThrowMagickException(exception,GetMagickModule(),
4331 OptionError,"NoSuchImage","`%s'",argv[1]);
4335 InsertImageInList(&q,p);
4337 *images=GetFirstImageInList(q);
4340 if (LocaleCompare("interpolate",argv[0]+1) == 0)
4342 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
4343 MagickInterpolateOptions,MagickFalse,argv[1]);
4350 if (LocaleCompare("layers",argv[0]+1) == 0)
4358 (void) SyncImagesSettings(image_info,*images,exception);
4359 layers=(Image *) NULL;
4360 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
4361 MagickFalse,argv[1]);
4366 layers=CoalesceImages(*images,exception);
4369 case CompareAnyLayer:
4370 case CompareClearLayer:
4371 case CompareOverlayLayer:
4374 layers=CompareImagesLayers(*images,method,exception);
4380 case TrimBoundsLayer:
4382 layers=MergeImageLayers(*images,method,exception);
4387 layers=DisposeImages(*images,exception);
4390 case OptimizeImageLayer:
4392 layers=OptimizeImageLayers(*images,exception);
4395 case OptimizePlusLayer:
4397 layers=OptimizePlusImageLayers(*images,exception);
4400 case OptimizeTransLayer:
4402 OptimizeImageTransparency(*images,exception);
4405 case RemoveDupsLayer:
4407 RemoveDuplicateLayers(images,exception);
4410 case RemoveZeroLayer:
4412 RemoveZeroDelayLayers(images,exception);
4418 General Purpose, GIF Animation Optimizer.
4420 layers=CoalesceImages(*images,exception);
4421 if (layers == (Image *) NULL)
4426 *images=DestroyImageList(*images);
4428 layers=OptimizeImageLayers(*images,exception);
4429 if (layers == (Image *) NULL)
4434 *images=DestroyImageList(*images);
4436 layers=(Image *) NULL;
4437 OptimizeImageTransparency(*images,exception);
4438 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4442 case CompositeLayer:
4456 value=GetImageOption(image_info,"compose");
4457 if (value != (const char *) NULL)
4458 compose=(CompositeOperator) ParseCommandOption(
4459 MagickComposeOptions,MagickFalse,value);
4461 compose=OverCompositeOp; /* use Over not image->compose */
4464 Split image sequence at the first 'NULL:' image.
4467 while (source != (Image *) NULL)
4469 source=GetNextImageInList(source);
4470 if ((source != (Image *) NULL) &&
4471 (LocaleCompare(source->magick,"NULL") == 0))
4474 if (source != (Image *) NULL)
4476 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4477 (GetNextImageInList(source) == (Image *) NULL))
4478 source=(Image *) NULL;
4482 Separate the two lists, junk the null: image.
4484 source=SplitImageList(source->previous);
4485 DeleteImageFromList(&source);
4488 if (source == (Image *) NULL)
4490 (void) ThrowMagickException(exception,GetMagickModule(),
4491 OptionError,"MissingNullSeparator","layers Composite");
4496 Adjust offset with gravity and virtual canvas.
4498 SetGeometry(*images,&geometry);
4499 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
4500 geometry.width=source->page.width != 0 ?
4501 source->page.width : source->columns;
4502 geometry.height=source->page.height != 0 ?
4503 source->page.height : source->rows;
4504 GravityAdjustGeometry((*images)->page.width != 0 ?
4505 (*images)->page.width : (*images)->columns,
4506 (*images)->page.height != 0 ? (*images)->page.height :
4507 (*images)->rows,(*images)->gravity,&geometry);
4510 Compose the two image sequences together
4512 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
4514 source=DestroyImageList(source);
4518 if (layers == (Image *) NULL)
4520 *images=DestroyImageList(*images);
4528 if (LocaleCompare("map",argv[0]+1) == 0)
4530 (void) SyncImagesSettings(image_info,*images,exception);
4531 if (*argv[0] == '+')
4533 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4539 if (LocaleCompare("maximum",argv[0]+1) == 0)
4545 Maximum image sequence (deprecated).
4547 (void) SyncImagesSettings(image_info,*images,exception);
4548 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
4549 if (maximum_image == (Image *) NULL)
4554 *images=DestroyImageList(*images);
4555 *images=maximum_image;
4558 if (LocaleCompare("minimum",argv[0]+1) == 0)
4564 Minimum image sequence (deprecated).
4566 (void) SyncImagesSettings(image_info,*images,exception);
4567 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
4568 if (minimum_image == (Image *) NULL)
4573 *images=DestroyImageList(*images);
4574 *images=minimum_image;
4577 if (LocaleCompare("morph",argv[0]+1) == 0)
4582 (void) SyncImagesSettings(image_info,*images,exception);
4583 morph_image=MorphImages(*images,StringToUnsignedLong(argv[1]),
4585 if (morph_image == (Image *) NULL)
4590 *images=DestroyImageList(*images);
4591 *images=morph_image;
4594 if (LocaleCompare("mosaic",argv[0]+1) == 0)
4599 (void) SyncImagesSettings(image_info,*images,exception);
4600 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
4601 if (mosaic_image == (Image *) NULL)
4606 *images=DestroyImageList(*images);
4607 *images=mosaic_image;
4614 if (LocaleCompare("print",argv[0]+1) == 0)
4619 (void) SyncImagesSettings(image_info,*images,exception);
4620 string=InterpretImageProperties(image_info,*images,argv[1],
4622 if (string == (char *) NULL)
4624 (void) FormatLocaleFile(stdout,"%s",string);
4625 string=DestroyString(string);
4627 if (LocaleCompare("process",argv[0]+1) == 0)
4636 (void) SyncImagesSettings(image_info,*images,exception);
4637 arguments=StringToArgv(argv[1],&number_arguments);
4638 if (arguments == (char **) NULL)
4640 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
4661 Support old style syntax, filter="-option arg".
4663 length=strlen(argv[1]);
4664 token=(char *) NULL;
4665 if (~length >= (MaxTextExtent-1))
4666 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
4668 if (token == (char *) NULL)
4672 token_info=AcquireTokenInfo();
4673 status=Tokenizer(token_info,0,token,length,arguments,"","=",
4674 "\"",'\0',&breaker,&next,"e);
4675 token_info=DestroyTokenInfo(token_info);
4681 argv=(&(arguments[next]));
4682 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
4685 token=DestroyString(token);
4688 (void) SubstituteString(&arguments[1],"-","");
4689 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
4690 number_arguments-2,(const char **) arguments+2,exception);
4691 for (j=0; j < number_arguments; j++)
4692 arguments[j]=DestroyString(arguments[j]);
4693 arguments=(char **) RelinquishMagickMemory(arguments);
4700 if (LocaleCompare("reverse",argv[0]+1) == 0)
4702 ReverseImageList(images);
4709 if (LocaleCompare("smush",argv[0]+1) == 0)
4717 (void) SyncImagesSettings(image_info,*images,exception);
4718 offset=(ssize_t) StringToLong(argv[1]);
4719 smush_image=SmushImages(*images,*argv[0] == '-' ? MagickTrue :
4720 MagickFalse,offset,exception);
4721 if (smush_image == (Image *) NULL)
4726 *images=DestroyImageList(*images);
4727 *images=smush_image;
4730 if (LocaleCompare("swap",argv[0]+1) == 0)
4742 if (*argv[0] != '+')
4751 flags=ParseGeometry(argv[1],&geometry_info);
4752 index=(ssize_t) geometry_info.rho;
4753 if ((flags & SigmaValue) != 0)
4754 swap_index=(ssize_t) geometry_info.sigma;
4756 p=GetImageFromList(*images,index);
4757 q=GetImageFromList(*images,swap_index);
4758 if ((p == (Image *) NULL) || (q == (Image *) NULL))
4760 (void) ThrowMagickException(exception,GetMagickModule(),
4761 OptionError,"NoSuchImage","`%s'",(*images)->filename);
4767 swap=CloneImage(p,0,0,MagickTrue,exception);
4768 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
4769 ReplaceImageInList(&q,swap);
4770 *images=GetFirstImageInList(q);
4777 if (LocaleCompare("write",argv[0]+1) == 0)
4788 (void) SyncImagesSettings(image_info,*images,exception);
4789 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[1]);
4790 (void) DeleteImageRegistry(key);
4791 write_images=(*images);
4792 if (*argv[0] == '+')
4793 write_images=CloneImageList(*images,exception);
4794 write_info=CloneImageInfo(image_info);
4795 status&=WriteImages(write_info,write_images,argv[1],exception);
4796 write_info=DestroyImageInfo(write_info);
4797 if (*argv[0] == '+')
4798 write_images=DestroyImageList(write_images);
4806 quantize_info=DestroyQuantizeInfo(quantize_info);
4808 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
4809 return(status != 0 ? MagickTrue : MagickFalse);