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-2012 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % 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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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++]=StringToDouble(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() applies a single settings option into a CLI wand
385 % holding the image_info, draw_info, quantize_info structures that will be
386 % later used when processing images.
388 % These options require no images to be present in the wand for them to be
389 % able to be set. That is they may be used before the first image is read.
391 % The format of the ApplySettingOption method is:
393 % MagickBooleanType ApplySettingOption(MagickWand *wand,
394 % const char *option, const MagickBooleanType set_option, const char
395 % **args, ExceptionInfo *exception)
397 % A description of each parameter follows:
399 % o wand: structure holding settings to be applied
401 % o option: The option string to be set
403 % o set_option: is the option being set, or reset to some default
405 % o arg: the single argument (if needed) to set this option.
407 % o exception: return any errors or warnings in this structure.
410 % Example usage (FUTURE)
415 % count=ParseCommandOption(MagickCommandOptions,MagickFalse,argv[i]);
416 % flags=GetCommandOptionFlags(MagickCommandOptions,MagickFalse,argv[i]);
417 % if ( flags == MagickCommandOptions )
418 % ApplySettingsOption(wand, argv[i]+1,
419 % (*argv[i])=='-' ? MagickTrue : MagickFalse,
420 % (count>0)? argv[i+1]:(char *)NULL,
425 WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand,
426 const char *option, const MagickBooleanType set_option, const char *arg,
427 ExceptionInfo *exception)
429 assert(wand != (MagickWand *) NULL);
430 assert(wand->signature == WandSignature);
431 assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */
432 if (wand->debug != MagickFalse)
433 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
435 #define image_info (wand->image_info)
436 #define draw_info (wand->draw_info)
437 #define quantize_info (wand->quantize_info)
438 #define IfSetOption (set_option != MagickFalse)
439 #define IfArgOption (IfSetOption?arg:(char *)NULL)
445 if (LocaleCompare("adjoin",option) == 0)
447 image_info->adjoin = set_option;
450 if (LocaleCompare("affine",option) == 0)
452 /* draw_info setting only */
454 (void) ParseAffineGeometry(arg,draw_info->affine,exception);
456 GetAffineMatrix(draw_info->affine);
459 if (LocaleCompare("antialias",option) == 0)
461 image_info->antialias =
462 draw_info->stroke_antialias =
463 draw_info->text_antialias = set_option;
466 if (LocaleCompare("authenticate",option) == 0)
468 (void) SetImageOption(image_info,option,IfArgOption);
475 if (LocaleCompare("background",option) == 0)
477 /* FUTURE: both image_info attribute & ImageOption in use!
478 image_info only used for generating new images.
479 Note that +background, means fall-back to image
480 attribute so ImageOption is deleted, not set to a default.
484 (void) SetImageOption(image_info,option,arg);
485 (void) QueryColorCompliance(arg,AllCompliance,
486 image_info->background_color,exception);
489 (void) DeleteImageOption(image_info,option);
490 (void) QueryColorCompliance("none",AllCompliance,
491 image_info->background_color,exception);
494 if (LocaleCompare("bias",option) == 0)
496 /* FUTURE: bias OBSOLETED, replaced by "convolve:bias"
497 as it is actually rarely used except in direct convolve
498 Usage outside direct convolve is actally non-sensible!
500 (void) SetImageOption(image_info,option,
501 IfSetOption ? arg : "0");
504 if (LocaleCompare("black-point-compensation",option) == 0)
506 /* Used as a image chromaticity setting */
507 (void) SetImageOption(image_info,option,
508 IfSetOption ? "true" : "false" );
511 if (LocaleCompare("blue-primary",option) == 0)
513 /* Image chromaticity X,Y NB: Y=X if Y not defined
514 Used by many coders including PNG
516 (void) SetImageOption(image_info,option,
517 IfSetOption ? arg : "0" );
520 if (LocaleCompare("bordercolor",option) == 0)
522 /* FUTURE: both image_info attribute & ImageOption in use! */
525 (void) SetImageOption(image_info,option,arg);
526 (void) QueryColorCompliance(arg,AllCompliece,
527 &image_info->border_color,exception);
528 (void) QueryColorCompliance(arg,AllCompliance,
529 &draw_info->border_color,exception);
532 (void) DeleteImageOption(image_info,option);
533 (void) QueryColorCompliance(BorderColor,AllCompliance,
534 &image_info->border_color,exception);
535 (void) QueryColorCompliance(BorderColor,AllCompliance,
536 &draw_info->border_color,exception);
539 if (LocaleCompare("box",option) == 0)
541 /* Only used to set draw_info for text drawing */
543 *value = IfSetOption ? arg : "none";
544 (void) SetImageOption(image_info,option,value);
545 (void) QueryColorCompliance(value,AllCompliance,
546 &draw_info->undercolor,exception);
553 if (LocaleCompare("cache",option) == 0)
558 limit=MagickResourceInfinity;
559 if (LocaleCompare("unlimited",arg) != 0)
560 limit=(MagickSizeType) SiPrefixToDoubleInterval(arg,100.0);
561 (void) SetMagickResourceLimit(MemoryResource,limit);
562 (void) SetMagickResourceLimit(MapResource,2*limit);
565 if (LocaleCompare("caption",option) == 0)
567 (void) SetImageOption(image_info,option,IfSetOption ? arg :
571 if (LocaleCompare("channel",option) == 0)
573 /* FUTURE: This is also a SimpleImageOperator!!! */
574 image_info->channel=(ChannelType) (
575 IfSetOption ? ParseChannelOption(arg) : DefaultChannels );
576 /* This is also a SimpleImageOperator */
579 if (LocaleCompare("colorspace",option) == 0)
581 /* Setting used for new images via AquireImage()
582 But also used as a SimpleImageOperator
583 Undefined colorspace means don't modify images on
584 read or as a operation */
585 image_info->colorspace=UndefinedColorspace;
587 image_info->colorspace=(ColorspaceType) ParseCommandOption(
588 MagickColorspaceOptions,MagickFalse,arg)
591 if (LocaleCompare("comment",option) == 0)
593 (void) SetImageOption(image_info,option,
594 IfSetOption ? arg : (const char*)NULL);
597 if (LocaleCompare("compose",option) == 0)
599 /* FUTURE: image_info should be used, but Option kept escapes
600 This setting should NOT be used to set image 'compose'
601 which is used by "-layer" operators is image_info is undefined
603 (void) SetImageOption(image_info,option,
604 IfSetOption ? arg : (const char*)NULL);
605 image_info->compose=(CompositeOperator) ParseCommandOption(
606 MagickComposeOptions,MagickFalse,
607 IfSetOption ? arg : "undefined");
610 if (LocaleCompare("compress",option) == 0)
612 /* FUTURE: What should be used? image_info or ImageOption ???
613 The former is more efficent, but Crisy prefers the latter!
615 The coders appears to use image_info, not Image_Option
616 however the image attribute (for save) is set from the
621 image_info->compression=(CompressionType) ParseCommandOption(
622 MagickCompressOptions,MagickFalse,arg);
623 (void) SetImageOption(image_info,option,arg);
626 image_info->compression=UndefinedCompression;
627 (void) SetImageOption(image_info,option,"undefined");
634 if (LocaleCompare("debug",option) == 0)
637 (void) SetLogEventMask(IfSetOption?arg:"none");
638 image_info->debug=IsEventLogging(); /* extract logging*/
639 wand->debug=IsEventLogging();
642 if (LocaleCompare("define",option) == 0)
644 /* FUTURE both -set and -define sets ImageOption
645 But differs in that -set tries to set image properity (attributes)
647 if (LocaleNCompare(arg,"registry:",9) == 0)
650 (void) DefineImageRegistry(StringRegistryType,arg+9,
653 (void) DefineImageOption(image_info,arg,exception);
657 (void) DefineImageOption(image_info,arg,exception);
659 (void) DeleteImageOption(image_info,arg,exception);
662 if (LocaleCompare("delay",option) == 0)
664 /* Only used for new images via AcquireImage()
665 FUTURE: Option should also be used for "-morph" (color morphing)
667 (void) SetImageOption(image_info,option,
668 IfSetOption ? arg : "0");
671 if (LocaleCompare("density",option) == 0)
673 /* FUTURE: string in image_info - moved into Option ??? */
674 /* Used by both draw_info and in images via SyncImageSettings() */
677 (void) CloneString(&image_info->density,arg);
678 (void) CloneString(&draw_info->density,arg);
679 (void) SetImageOption(image_info,option,arg);
682 if (image_info->density != (char *) NULL)
683 image_info->density=DestroyString(image_info->density);
684 if (draw_info->density != (char *) NULL)
685 draw_info->density=DestroyString(draw_info->density);
686 (void) SetImageOption(image_info,option,"72");
689 if (LocaleCompare("depth",option) == 0)
691 /* This is also a SimpleImageOperator! to set depth across images */
692 image_info->depth=IfSetOption?StringToUnsignedLong(arg)
693 :MAGICKCORE_QUANTUM_DEPTH;
696 if (LocaleCompare("direction",option) == 0)
698 /* Image Option is only used to set draw_info */
699 (void) SetImageOption(image_info,option,
700 IfSetOption ? arg : "undefined");
701 draw_info->direction=(DirectionType) ParseCommandOption(
702 MagickDirectionOptions,MagickFalse,
703 IfSetOption ? arg : "undefined");
706 if (LocaleCompare("display",option) == 0)
708 /* FUTURE: string in image_info - moved into Option ??? */
709 (void) CloneString(&image_info->server_name,
710 IfSetOption ? arg :(char *) NULL);
713 if (LocaleCompare("dispose",option) == 0)
715 (void) SetImageOption(image_info,option,
716 IfSetOption ? arg : "undefined");
719 if (LocaleCompare("dither",option) == 0)
721 /* FUTURE: merge all options to just Option and quantize_info! */
722 (void) SetImageOption(image_info,option,
723 IfSetOption ? arg : "none");
724 image_info->dither = quantize_info->dither =
725 IfSetOption ? MagickTrue : MagickFalse;
726 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
727 MagickDitherOptions,MagickFalse,
728 IfSetOption ? arg : "none");
729 if (quantize_info->dither_method == NoDitherMethod)
730 image_info->dither = quantize_info->dither = MagickFalse;
737 if (LocaleCompare("encoding",option) == 0)
739 (void) CloneString(&draw_info->encoding,
740 IfSetOption ? arg : "undefined");
741 (void) SetImageOption(image_info,option,&draw_info->encoding);
744 if (LocaleCompare("endian",option) == 0)
749 value=IfSetOption?arg:"undefined";
750 (void) SetImageOption(image_info,option,value);
751 image_info->endian=(EndianType) ParseCommandOption(
752 MagickEndianOptions,MagickFalse,value);
755 if (LocaleCompare("extract",option) == 0)
757 (void) CloneString(&image_info->extract,
758 IfSetOption?arg:(const char *) NULL);
765 if (LocaleCompare("family",argv[0]+1) == 0)
767 (void) CloneString(&draw_info->family,
768 IfSetOption ? arg : (const char *) NULL);
771 if (LocaleCompare("fill",option) == 0)
773 /* set fill OR a fill-pattern
774 color is only used by draw_info
775 but draw_info is only initialsed using the color not the pattern
783 value = IfSetOption ? arg : "none";
784 (void) SetImageOption(image_info,option,value);
786 sans=AcquireExceptionInfo();
787 status=QueryColorCompliance(value,AllCompliance,&draw_info->fill,sans);
788 sans=DestroyExceptionInfo(sans);
790 if (draw_info->fill_pattern != (Image *) NULL)
791 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
792 if (status == MagickFalse)
793 draw_info->fill_pattern=GetImageCache(image_info,value,
797 if (LocaleCompare("filter",option) == 0)
799 (void) SetImageOption(image_info,option,
800 IfSetOption ? arg : "undefined");
803 if (LocaleCompare("font",option) == 0)
805 (void) CloneString(&draw_info->font,
806 IfSetOption ? arg : (const char *) NULL);
807 (void) CloneString(&image_info->font,draw_info->font);
810 if (LocaleCompare("format",option) == 0)
812 /* FUTURE: why the ping test, you could set ping after this! */
817 for (q=strchr(arg,'%'); q != (char *) NULL; q=strchr(q+1,'%'))
818 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
819 image_info->ping=MagickFalse;
821 (void) SetImageOption(image_info,option,
822 IfSetOption ? arg : (const char *) NULL);
825 if (LocaleCompare("fuzz",option) == 0)
827 /* FUTURE: image_info and ImageOption!
828 Option used to set image fuzz! unless blank canvas (from color)
829 Image attribute used for color compare operations
830 image->fuzz is being set by SyncImageSettings()
831 Can't find anything using image_info->fuzz (except cloning)!
835 image_info->fuzz=StringToDoubleInterval(arg,(double) QuantumRange+
837 (void) SetImageOption(image_info,option,arg);
840 image_info->fuzz=0.0;
841 (void) SetImageOption(image_info,option,"0");
848 if (LocaleCompare("gravity",option) == 0)
850 /* FUTURE gravity also set in image via SyncImageSettings() */
854 value = IfSetOption ? arg : "none";
855 (void) SetImageOption(image_info,option,value);
856 draw_info->gravity=(GravityType) ParseCommandOption(
857 MagickGravityOptions,MagickFalse,value);
860 if (LocaleCompare("green-primary",option) == 0)
862 /* Image chromaticity X,Y NB: Y=X if Y not defined
865 (void) SetImageOption(image_info,option,
866 IfSetOption ? arg : "0.0");
873 if (LocaleCompare("intent",option) == 0)
875 /* FUTURE: sets image->rendering_intent in SyncImagesSettings
876 Which is only used by coders: MIFF, MPC, BMP, PNG
877 and for image profile call to AcquireTransformThreadSet()
879 (void) SetImageOption(image_info,option,
880 IfSetOption ? arg : "undefined");
883 if (LocaleCompare("interlace",option) == 0)
885 /* sets image attibute interlace via SyncImageSettings()
886 Also image_info is directly used by coders
891 value = IfSetOption ? arg : "undefined";
892 (void) SetImageOption(image_info,option, value);
893 image_info->interlace=(InterlaceType) ParseCommandOption(
894 MagickInterlaceOptions,MagickFalse,arg);
895 (void) SetImageOption(image_info,option,arg);
898 if (LocaleCompare("interline-spacing",option) == 0)
903 value = IfSetOption ? arg : "0"; /* undefined? */
904 (void) SetImageOption(image_info,option, value);
905 draw_info->interline_spacing=StringToDouble(value,(char **) NULL);
908 if (LocaleCompare("interpolate",option) == 0)
910 /* FUTURE: sets image interpolate value via SyncImageSettings()
911 It is NOT used by coders, only in image processing,
912 so shoud really be a image_info attribute.
914 (void) SetImageOption(image_info,option,
915 IfSetOption ? arg : "undefined");
918 if (LocaleCompare("interword-spacing",option) == 0)
923 value = IfSetOption ? arg : "0"; /* undefined? */
924 (void) SetImageOption(image_info,option, value);
925 draw_info->interword_spacing=StringToDouble(value,(char **) NULL);
932 if (LocaleCompare("kerning",option) == 0)
937 value = IfSetOption ? arg : "0"; /* undefined? */
938 (void) SetImageOption(image_info,option, value);
939 draw_info->kerning=StringToDouble(value,(char **) NULL);
946 if (LocaleCompare("label",option) == 0)
948 /* only used for new images */
949 (void) SetImageOption(image_info,option,
950 IfSetOption ? arg : (char *)NULL);
953 if (LocaleCompare("limit",option) == 0)
963 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
965 limit=MagickResourceInfinity;
966 if (LocaleCompare("unlimited",argv[2]) != 0)
967 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[2],
969 (void) SetMagickResourceLimit(type,limit);
972 if (LocaleCompare("list",option) == 0)
977 list=ParseCommandOption(MagickListOptions,MagickFalse,arg);
980 case MagickCoderOptions:
982 (void) ListCoderInfo((FILE *) NULL,exception);
985 case MagickColorOptions:
987 (void) ListColorInfo((FILE *) NULL,exception);
990 case MagickConfigureOptions:
992 (void) ListConfigureInfo((FILE *) NULL,exception);
995 case MagickDelegateOptions:
997 (void) ListDelegateInfo((FILE *) NULL,exception);
1000 case MagickFontOptions:
1002 (void) ListTypeInfo((FILE *) NULL,exception);
1005 case MagickFormatOptions:
1007 (void) ListMagickInfo((FILE *) NULL,exception);
1010 case MagickLocaleOptions:
1012 (void) ListLocaleInfo((FILE *) NULL,exception);
1015 case MagickLogOptions:
1017 (void) ListLogInfo((FILE *) NULL,exception);
1020 case MagickMagicOptions:
1022 (void) ListMagicInfo((FILE *) NULL,exception);
1025 case MagickMimeOptions:
1027 (void) ListMimeInfo((FILE *) NULL,exception);
1030 case MagickModuleOptions:
1032 (void) ListModuleInfo((FILE *) NULL,exception);
1035 case MagickPolicyOptions:
1037 (void) ListPolicyInfo((FILE *) NULL,exception);
1040 case MagickResourceOptions:
1042 (void) ListMagickResourceInfo((FILE *) NULL,exception);
1045 case MagickThresholdOptions:
1047 (void) ListThresholdMaps((FILE *) NULL,exception);
1052 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
1059 if (LocaleCompare("log",option) == 0)
1062 (void) SetLogFormat(arg);
1065 if (LocaleCompare("loop",option) == 0)
1067 /* Sets image attibutes iterations via SyncImageSettings() */
1068 (void) SetImageOption(image_info,option,
1069 IfSetOption ? arg : "0");
1076 if (LocaleCompare("matte",option) == 0)
1078 if (*argv[0] == '+')
1080 (void) SetImageOption(image_info,option,"false");
1083 (void) SetImageOption(image_info,option,"true");
1086 if (LocaleCompare("mattecolor",option) == 0)
1088 if (*argv[0] == '+')
1090 (void) SetImageOption(image_info,option,arg);
1091 (void) QueryColorCompliance(MatteColor,AllCompliance,
1092 &image_info->matte_color,exception);
1095 (void) SetImageOption(image_info,option,arg);
1096 (void) QueryColorCompliance(arg,AllCompliance,&image_info->matte_color,
1100 if (LocaleCompare("monitor",option) == 0)
1102 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
1106 if (LocaleCompare("monochrome",option) == 0)
1108 /* Setting (for input coders) and a 'type' operation */
1109 image_info->monochrome=IfSetOption ? MagickTrue : MagickFalse;
1116 if (LocaleCompare("orient",option) == 0)
1118 /* Sets image attribute orientation via SyncImageSettings()
1119 Is not used when defining for new images.
1120 This makes it more of a 'operation' than a setting
1125 value = IfSetOption ? arg : "undefined";
1126 (void) SetImageOption(image_info,option, value);
1127 image_info->orientation=(InterlaceType) ParseCommandOption(
1128 MagickOrientationOptions,MagickFalse,value);
1134 if (LocaleCompare("page",option) == 0)
1136 /* Only used for new images and image generators */
1139 page[MaxTextExtent];
1152 (void) DeleteImageOption(image_info,option);
1153 (void) CloneString(&image_info->page,(char *) NULL);
1156 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
1157 image_option=GetImageOption(image_info,"page");
1158 if (image_option != (const char *) NULL)
1159 flags=ParseAbsoluteGeometry(image_option,&geometry);
1160 canonical_page=GetPageGeometry(arg);
1161 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
1162 canonical_page=DestroyString(canonical_page);
1163 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
1164 (unsigned long) geometry.width,(unsigned long) geometry.height);
1165 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1166 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
1167 (unsigned long) geometry.width,(unsigned long) geometry.height,
1168 (long) geometry.x,(long) geometry.y);
1169 (void) SetImageOption(image_info,option,page);
1170 (void) CloneString(&image_info->page,page);
1173 if (LocaleCompare("ping",option) == 0)
1175 image_info->ping= IfSetOption ? MagickTrue : MagickFalse;
1178 if (LocaleCompare("pointsize",option) == 0)
1184 StringToDouble(arg,(char **) NULL);
1185 image_info->pointsize=draw_info->pointsize=value;
1188 if (LocaleCompare("precision",option) == 0)
1190 (void) SetMagickPrecision(StringToInteger(arg));
1193 /* FUTURE: Only the 'preview' coder appears to use this
1194 * Depreciate the coder? Leaving only the 'preview' operator.
1195 if (LocaleCompare("preview",option) == 0)
1197 image_info->preview_type=UndefinedPreview;
1199 image_info->preview_type=(PreviewType) ParseCommandOption(
1200 MagickPreviewOptions,MagickFalse,arg);
1208 if (LocaleCompare("quality",option) == 0)
1212 image_info->quality=StringToUnsignedLong(arg);
1213 (void) SetImageOption(image_info,option,arg);
1216 image_info->quality=UndefinedCompressionQuality;
1217 (void) SetImageOption(image_info,option,"0");
1220 if (LocaleCompare("quantize",option) == 0)
1222 /* no image_info setting! Only set direct in quantize_info */
1223 quantize_info->colorspace=UndefinedColorspace;
1225 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
1226 MagickColorspaceOptions,MagickFalse,arg);
1229 if (LocaleCompare("quiet",option) == 0)
1231 /* FUTURE: if two -quiet is performed you can not do +quiet! */
1232 static WarningHandler
1233 warning_handler = (WarningHandler) NULL;
1235 tmp = SetWarningHandler((WarningHandler) NULL);
1237 if ( tmp != (WarningHandler) NULL)
1238 warning_handler = tmp; /* remember the old handler */
1239 if (!IfSetOption) /* set the old handler */
1240 warning_handler=SetWarningHandler(warning_handler);
1247 if (LocaleCompare("red-primary",option) == 0)
1249 /* Image chromaticity X,Y NB: Y=X if Y not defined
1252 (void) SetImageOption(image_info,option,
1253 IfSetOption ? arg : "0" );
1256 if (LocaleCompare("render",option) == 0)
1258 /* draw_info only setting */
1259 draw_info->render= IfSetOption ? MagickFalse : MagickTrue;
1266 if (LocaleCompare("sampling-factor",option) == 0)
1268 /* FUTURE: should be converted to jpeg:sampling_factor */
1269 (void) CloneString(&image_info->sampling_factor,
1270 IfSetOption ? arg : (char *) NULL);
1273 if (LocaleCompare("scene",option) == 0)
1276 *value = IfSetOption ? arg : "0";
1278 (void) SetImageOption(image_info,option,value);
1279 image_info->scene=StringToUnsignedLong(value);
1282 if (LocaleCompare("seed",option) == 0)
1284 SeedPseudoRandomGenerator(
1285 IfSetOption ? (size_t) StringToUnsignedLong(arg)
1286 : (size_t) time((time_t *) NULL) );
1289 if (LocaleCompare("size",option) == 0)
1291 /* FUTURE: string in image_info -- convert to Option ???
1292 Look at the special handling for "size" in SetImageOption()
1294 (void) CloneString(&image_info->size,
1295 IfSetOption ? arg : (char *) NULL);
1298 if (LocaleCompare("stretch",option) == 0)
1300 draw_info->stretch=UndefinedStretch;
1302 draw_info->stretch=(StretchType) ParseCommandOption(
1303 MagickStretchOptions,MagickFalse,arg);
1306 if (LocaleCompare("stroke",option) == 0)
1308 /* set stroke color OR stroke-pattern
1309 color is only used by draw_info
1310 but draw_info is only initialsed using the color not the pattern
1313 *value = IfSetOption ? arg : "none";
1318 (void) SetImageOption(image_info,option,value);
1320 sans=AcquireExceptionInfo();
1321 status=QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
1323 sans=DestroyExceptionInfo(sans);
1325 if (draw_info->stroke_pattern != (Image *) NULL)
1326 draw_info->stroke_pattern=DestroyImage(draw_info->stroke_pattern);
1327 if (status == MagickFalse)
1328 draw_info->stroke_pattern=GetImageCache(image_info,value,
1332 if (LocaleCompare("strokewidth",option) == 0)
1335 *value = IfSetOption ? arg : "1.0";
1336 (void) SetImageOption(image_info,option,value);
1337 draw_info->stroke_width=StringToDouble(value,(char **) NULL);
1340 if (LocaleCompare("style",option) == 0)
1342 draw_info->style=UndefinedStyle;
1344 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
1348 if (LocaleCompare("synchronize",option) == 0)
1350 image_info->synchronize=IfSetOption ? MagickTrue : MagickFalse;
1357 if (LocaleCompare("taint",option) == 0)
1359 (void) SetImageOption(image_info,option,
1360 IfSetOption ? "true" : "false");
1363 if (LocaleCompare("texture",option) == 0)
1365 /* FUTURE: move image_info string to option splay-tree */
1366 (void) CloneString(&image_info->texture,
1367 IfSetOption ? arg : (char *) NULL);
1370 if (LocaleCompare("tile",option) == 0)
1372 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1374 draw_info->fill_pattern=GetImageCache(image_info,arg,exception);
1377 if (LocaleCompare("tile-offset",option) == 0)
1379 (void) SetImageOption(image_info,option,
1380 IfSetOption ? arg : "0");
1383 if (LocaleCompare("transparent-color",option) == 0)
1385 /* FUTURE: both image_info attribute & ImageOption in use!
1386 image_info only used for generating new images.
1387 Note that +transparent-color, means fall-back to image
1388 attribute so ImageOption is deleted, not set to a default.
1392 (void) SetImageOption(image_info,option,arg);
1393 (void) QueryColorCompliance(arg,AllCompliance,
1394 image_info->transparent_color,exception);
1397 (void) DeleteImageOption(image_info,option);
1398 (void) QueryColorCompliance("none",AllCompliance,
1399 image_info->transparent_color,exception);
1402 if (LocaleCompare("type",option) == 0)
1404 (void) SetImageOption(image_info,option,
1405 IfSetOption ? arg : (char) NULL);
1406 image_info->type=UndefinedType;
1408 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1416 if (LocaleCompare("undercolor",option) == 0)
1418 (void) SetImageOption(image_info,option,
1419 IfSetOption ? arg : (char) NULL);
1420 (void) QueryColorCompliance(arg,AllCompliance,
1421 draw_info->undercolor,exception);
1424 if (LocaleCompare("units",option) == 0)
1426 /* Set in images via SyncImageSettings() */
1427 /* Should this effect draw_info X and Y resolution? */
1428 /* FUTURE: this probably should be part of the density setting */
1429 (void) SetImageOption(image_info,option,
1430 IfSetOption ? arg : (char) NULL);
1431 image_info->units=UndefinedResolution;
1433 image_info->units=(ResolutionType) ParseCommandOption(
1434 MagickResolutionOptions,MagickFalse,arg);
1441 if (LocaleCompare("verbose",option) == 0)
1443 /* FUTURE: Also an image artifact, set in Simple Operators.
1444 But artifact is only used in verbose output.
1446 image_info->verbose= IfSetOption ? MagickTrue : MagickFalse;
1447 image_info->ping=MagickFalse; /* verbose can't be a ping */
1450 if (LocaleCompare("view",option) == 0)
1452 /* FUTURE: Convert from image_info to Option
1453 Only used by coder FPX
1455 (void) CloneString(&image_info->view,
1456 IfSetOption ? arg : (char) NULL);
1459 if (LocaleCompare("virtual-pixel",option) == 0)
1461 /* Also used as a 'image' option deep in image structure */
1463 *value = IfSetOption ? arg : "undefined";
1465 (void) SetImageOption(image_info,option,value);
1466 image_info->virtual_pixel_method=(VirtualPixelMethod)
1467 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,value);
1474 if (LocaleCompare("weight",option) == 0)
1476 /* FUTURE: relative weights not sensical due to first assignment!
1477 Also just what is actually using font 'weight' ???
1478 There is no "-list weight" output (reference manual says there is)
1480 draw_info->weight=StringToUnsignedLong(arg);
1481 if (LocaleCompare(arg,"all") == 0)
1482 draw_info->weight=0;
1483 if (LocaleCompare(arg,"bold") == 0)
1484 draw_info->weight=700;
1485 if (LocaleCompare(arg,"bolder") == 0)
1486 if (draw_info->weight <= 800)
1487 draw_info->weight+=100;
1488 if (LocaleCompare(arg,"lighter") == 0)
1489 if (draw_info->weight >= 100)
1490 draw_info->weight-=100;
1491 if (LocaleCompare(arg,"normal") == 0)
1492 draw_info->weight=400;
1495 if (LocaleCompare("white-point",option) == 0)
1497 /* Used as a image chromaticity setting */
1498 (void) SetImageOption(image_info,option,
1499 IfSetOption ? arg : "0.0" );
1511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1515 + A p p l y I m a g e O p e r a t o r %
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 % ApplyImageOperator() apply one simple image operation to the current
1522 % image pointed to by the CLI wand, with the settings that are saved in the
1525 % The image in the list may be modified in three different ways...
1527 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
1528 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
1529 % * replace by a list of images (-separate and -crop only!)
1531 % In each case the result replaces the original image in the list, as well as
1532 % the pointer to the modified image (last image added if replaced by a list
1533 % of images) is returned. As the image pointed to may be replaced, the first
1534 % image in the list may also change. GetFirstImageInList() should be used by
1535 % caller if they wish return the Image pointer to the first image in list.
1537 % It is assumed that any per-image settings are up-to-date with respect to
1538 % extra settings that have been saved in the wand.
1540 % The format of the ApplyImageOperator method is:
1542 % MagickBooleanType ApplyImageOperator(MagickWand *wand,
1543 % const char *option, const MagickBooleanType set_option, const char
1544 % **args, ExceptionInfo *exception)
1546 % A description of each parameter follows:
1548 % o wand: structure holding settings to be applied
1550 % o option: The option string to be set
1552 % o set_option: is the option being set, or reset to some default
1554 % o arg: the single argument (if needed) to set this option.
1556 % o exception: return any errors or warnings in this structure.
1559 % Example usage (FUTURE)
1564 % count=ParseCommandOption(MagickCommandOptions,MagickFalse,argv[i]);
1565 % flags=GetCommandOptionFlags(MagickCommandOptions,MagickFalse,argv[i]);
1566 % if ( flags == MagickCommandOptions )
1567 % ApplySettingsOption(wand, argv[i]+1,
1568 % (*argv[i])=='-' ? MagickTrue : MagickFalse,
1569 % argv+i+1, exception);
1573 WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand,
1574 const char *option, const MagickBooleanType set_option, const char **args,
1575 ExceptionInfo *exception)
1592 assert(image_info != (const ImageInfo *) NULL);
1593 assert(image_info->signature == MagickSignature);
1594 assert(wand->draw_info != (DrawInfo *) NULL); /* ensure it is a CLI wand */
1595 assert(image != (Image **) NULL); /* there is an image */
1596 assert((*image)->signature == MagickSignature);
1598 if (wand->debug != MagickFalse)
1599 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1601 SetGeometryInfo(&geometry_info);
1603 new_image = (Image *)NULL; /* the replacement image, if not null at end */
1605 /* We need somthing more optimized than this! */
1606 (void) SyncImageSettings(image_info,*image,exception);
1612 if (LocaleCompare("adaptive-blur",option) == 0)
1614 flags=ParseGeometry(args[0],&geometry_info);
1615 if ((flags & SigmaValue) == 0)
1616 geometry_info.sigma=1.0;
1617 if ((flags & XiValue) == 0)
1618 geometry_info.xi=0.0;
1619 new_image=AdaptiveBlurImage(*image,geometry_info.rho,
1620 geometry_info.sigma,geometry_info.xi,exception);
1623 if (LocaleCompare("adaptive-resize",option) == 0)
1625 /* FUTURE: this is really a "interpolate-resize" operator
1626 "adaptive-resize" uses a fixed "Mesh" interpolation
1628 (void) ParseRegionGeometry(*image,args[0],&geometry,exception);
1629 new_image=AdaptiveResizeImage(*image,geometry.width,
1630 geometry.height,interpolate_method,exception);
1633 if (LocaleCompare("adaptive-sharpen",option) == 0)
1636 Adaptive sharpen image.
1638 (void) SyncImageSettings(image_info,*image,exception);
1639 flags=ParseGeometry(args[0],&geometry_info);
1640 if ((flags & SigmaValue) == 0)
1641 geometry_info.sigma=1.0;
1642 if ((flags & XiValue) == 0)
1643 geometry_info.xi=0.0;
1644 new_image=AdaptiveSharpenImage(*image,geometry_info.rho,
1645 geometry_info.sigma,geometry_info.xi,exception);
1648 if (LocaleCompare("alpha",option) == 0)
1653 (void) SyncImageSettings(image_info,*image,exception);
1654 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
1655 MagickFalse,args[0]);
1656 (void) SetImageAlphaChannel(*image,alpha_type,exception);
1659 if (LocaleCompare("annotate",option) == 0)
1663 geometry[MaxTextExtent];
1665 (void) SyncImageSettings(image_info,*image,exception);
1666 SetGeometryInfo(&geometry_info);
1667 flags=ParseGeometry(args[0],&geometry_info);
1668 if ((flags & SigmaValue) == 0)
1669 geometry_info.sigma=geometry_info.rho;
1670 text=InterpretImageProperties(image_info,*image,argv[2],
1672 if (text == (char *) NULL)
1674 (void) CloneString(&draw_info->text,text);
1675 text=DestroyString(text);
1676 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
1677 geometry_info.xi,geometry_info.psi);
1678 (void) CloneString(&draw_info->geometry,geometry);
1679 draw_info->affine.sx=cos(DegreesToRadians(
1680 fmod(geometry_info.rho,360.0)));
1681 draw_info->affine.rx=sin(DegreesToRadians(
1682 fmod(geometry_info.rho,360.0)));
1683 draw_info->affine.ry=(-sin(DegreesToRadians(
1684 fmod(geometry_info.sigma,360.0))));
1685 draw_info->affine.sy=cos(DegreesToRadians(
1686 fmod(geometry_info.sigma,360.0)));
1687 (void) AnnotateImage(*image,draw_info,exception);
1690 if (LocaleCompare("auto-gamma",option) == 0)
1693 Auto Adjust Gamma of image based on its mean
1695 (void) SyncImageSettings(image_info,*image,exception);
1696 (void) AutoGammaImage(*image,exception);
1699 if (LocaleCompare("auto-level",option) == 0)
1702 Perfectly Normalize (max/min stretch) the image
1704 (void) SyncImageSettings(image_info,*image,exception);
1705 (void) AutoLevelImage(*image,exception);
1708 if (LocaleCompare("auto-orient",option) == 0)
1710 (void) SyncImageSettings(image_info,*image,exception);
1711 switch ((*image)->orientation)
1713 case TopRightOrientation:
1715 new_image=FlopImage(*image,exception);
1718 case BottomRightOrientation:
1720 new_image=RotateImage(*image,180.0,exception);
1723 case BottomLeftOrientation:
1725 new_image=FlipImage(*image,exception);
1728 case LeftTopOrientation:
1730 new_image=TransposeImage(*image,exception);
1733 case RightTopOrientation:
1735 new_image=RotateImage(*image,90.0,exception);
1738 case RightBottomOrientation:
1740 new_image=TransverseImage(*image,exception);
1743 case LeftBottomOrientation:
1745 new_image=RotateImage(*image,270.0,exception);
1751 if (new_image != (Image *) NULL)
1752 new_image->orientation=TopLeftOrientation;
1759 if (LocaleCompare("black-threshold",option) == 0)
1761 (void) SyncImageSettings(image_info,*image,exception);
1762 (void) BlackThresholdImage(*image,args[0],exception);
1765 if (LocaleCompare("blue-shift",option) == 0)
1767 (void) SyncImageSettings(image_info,*image,exception);
1768 geometry_info.rho=1.5;
1769 if (*argv[0] == '-')
1770 flags=ParseGeometry(args[0],&geometry_info);
1771 new_image=BlueShiftImage(*image,geometry_info.rho,exception);
1774 if (LocaleCompare("blur",option) == 0)
1776 /* FUTURE: use of "bias" in a blur is non-sensible */
1777 (void) SyncImageSettings(image_info,*image,exception);
1778 flags=ParseGeometry(args[0],&geometry_info);
1779 if ((flags & SigmaValue) == 0)
1780 geometry_info.sigma=1.0;
1781 if ((flags & XiValue) == 0)
1782 geometry_info.xi=0.0;
1783 new_image=BlurImage(*image,geometry_info.rho,
1784 geometry_info.sigma,geometry_info.xi,exception);
1787 if (LocaleCompare("border",option) == 0)
1796 value=GetImageOption(image_info,"compose");
1797 if (value != (const char *) NULL)
1798 compose=(CompositeOperator) ParseCommandOption(
1799 MagickComposeOptions,MagickFalse,value);
1801 compose=OverCompositeOp; /* use Over not image->compose */
1803 (void) SyncImageSettings(image_info,*image,exception);
1804 flags=ParsePageGeometry(*image,args[0],&geometry,exception);
1805 if ((flags & SigmaValue) == 0)
1806 geometry.height=geometry.width;
1807 new_image=BorderImage(*image,&geometry,compose,exception);
1810 if (LocaleCompare("brightness-contrast",option) == 0)
1822 (void) SyncImageSettings(image_info,*image,exception);
1823 flags=ParseGeometry(args[0],&geometry_info);
1824 brightness=geometry_info.rho;
1826 if ((flags & SigmaValue) != 0)
1827 contrast=geometry_info.sigma;
1828 (void) BrightnessContrastImage(*image,brightness,contrast,
1836 if (LocaleCompare("cdl",option) == 0)
1839 *color_correction_collection;
1842 Color correct with a color decision list.
1844 (void) SyncImageSettings(image_info,*image,exception);
1845 color_correction_collection=FileToString(args[0],~0,exception);
1846 if (color_correction_collection == (char *) NULL)
1848 (void) ColorDecisionListImage(*image,color_correction_collection,
1852 if (LocaleCompare("channel",option) == 0)
1854 /* The "channel" setting has already been set */
1855 SetPixelChannelMap(*image,image_info->channel);
1858 if (LocaleCompare("charcoal",option) == 0)
1860 (void) SyncImageSettings(image_info,*image,exception);
1861 flags=ParseGeometry(args[0],&geometry_info);
1862 if ((flags & SigmaValue) == 0)
1863 geometry_info.sigma=1.0;
1864 if ((flags & XiValue) == 0)
1865 geometry_info.xi=1.0;
1866 new_image=CharcoalImage(*image,geometry_info.rho,
1867 geometry_info.sigma,geometry_info.xi,exception);
1870 if (LocaleCompare("chop",option) == 0)
1872 (void) SyncImageSettings(image_info,*image,exception);
1873 (void) ParseGravityGeometry(*image,args[0],&geometry,exception);
1874 new_image=ChopImage(*image,&geometry,exception);
1877 if (LocaleCompare("clamp",option) == 0)
1879 (void) SyncImageSettings(image_info,*image,exception);
1880 (void) ClampImage(*image,exception);
1883 if (LocaleCompare("clip",option) == 0)
1885 (void) SyncImageSettings(image_info,*image,exception);
1886 if (*argv[0] == '+')
1888 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1891 (void) ClipImage(*image,exception);
1894 if (LocaleCompare("clip-mask",option) == 0)
1911 (void) SyncImageSettings(image_info,*image,exception);
1912 if (*argv[0] == '+')
1914 /* Remove the write mask */
1915 (void) SetImageMask(*image,(Image *) NULL,exception);
1918 mask_image=GetImageCache(image_info,args[0],exception);
1919 if (mask_image == (Image *) NULL)
1921 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1922 return(MagickFalse);
1923 /* create a write mask from clip-mask image */
1924 /* FUTURE: use Alpha operations instead */
1925 mask_view=AcquireCacheView(mask_image);
1926 for (y=0; y < (ssize_t) mask_image->rows; y++)
1928 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1930 if (q == (Quantum *) NULL)
1932 for (x=0; x < (ssize_t) mask_image->columns; x++)
1934 if (mask_image->matte == MagickFalse)
1935 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1936 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1937 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1938 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1939 q+=GetPixelChannels(mask_image);
1941 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1944 /* set the write mask */
1945 mask_view=DestroyCacheView(mask_view);
1946 mask_image->matte=MagickTrue;
1947 (void) SetImageClipMask(*image,mask_image,exception);
1948 mask_image=DestroyImage(mask_image);
1951 if (LocaleCompare("clip-path",option) == 0)
1953 (void) SyncImageSettings(image_info,*image,exception);
1954 (void) ClipImagePath(*image,args[0],*argv[0] == '-' ? MagickTrue :
1955 MagickFalse,exception);
1958 if (LocaleCompare("colorize",option) == 0)
1960 (void) SyncImageSettings(image_info,*image,exception);
1961 new_image=ColorizeImage(*image,args[0],draw_info->fill,
1965 if (LocaleCompare("color-matrix",option) == 0)
1970 (void) SyncImageSettings(image_info,*image,exception);
1971 kernel=AcquireKernelInfo(args[0]);
1972 if (kernel == (KernelInfo *) NULL)
1974 new_image=ColorMatrixImage(*image,kernel,exception);
1975 kernel=DestroyKernelInfo(kernel);
1978 if (LocaleCompare("colors",option) == 0)
1980 /* Reduce the number of colors in the image. */
1981 (void) SyncImageSettings(image_info,*image,exception);
1982 quantize_info->number_colors=StringToUnsignedLong(args[0]);
1983 if (quantize_info->number_colors == 0)
1985 if (((*image)->storage_class == DirectClass) ||
1986 (*image)->colors > quantize_info->number_colors)
1987 (void) QuantizeImage(quantize_info,*image,exception);
1989 (void) CompressImageColormap(*image,exception);
1992 if (LocaleCompare("colorspace",option) == 0)
1994 /* This is a Image Setting, which should already been set */
1995 /* FUTURE: default colorspace should be sRGB!
1996 Unless some type of 'linear colorspace' mode is set.
1997 Note that +colorspace sets "undefined" or no effect on
1998 new images, but forces images already in memory back to RGB!
2000 (void) SyncImageSettings(image_info,*image,exception);
2001 (void) TransformImageColorspace(*image,
2002 IfSetOption ? image_info->colorspace : RGBColorspace,
2006 if (LocaleCompare("contrast",option) == 0)
2008 (void) SyncImageSettings(image_info,*image,exception);
2009 (void) ContrastImage(*image,(*argv[0] == '-') ? MagickTrue :
2010 MagickFalse,exception);
2013 if (LocaleCompare("contrast-stretch",option) == 0)
2023 Contrast stretch image.
2025 (void) SyncImageSettings(image_info,*image,exception);
2026 flags=ParseGeometry(args[0],&geometry_info);
2027 black_point=geometry_info.rho;
2028 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2030 if ((flags & PercentValue) != 0)
2032 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2033 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2035 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2037 (void) ContrastStretchImage(*image,black_point,white_point,
2041 if (LocaleCompare("convolve",option) == 0)
2046 (void) SyncImageSettings(image_info,*image,exception);
2047 kernel_info=AcquireKernelInfo(args[0]);
2048 if (kernel_info == (KernelInfo *) NULL)
2050 kernel_info->bias=(*image)->bias;
2051 new_image=ConvolveImage(*image,kernel_info,exception);
2052 kernel_info=DestroyKernelInfo(kernel_info);
2055 if (LocaleCompare("crop",option) == 0)
2058 Crop a image to a smaller size
2060 (void) SyncImageSettings(image_info,*image,exception);
2061 new_image=CropImageToTiles(*image,args[0],exception);
2064 if (LocaleCompare("cycle",option) == 0)
2067 Cycle an image colormap.
2069 (void) SyncImageSettings(image_info,*image,exception);
2070 (void) CycleColormapImage(*image,(ssize_t) StringToLong(args[0]),
2078 if (LocaleCompare("decipher",option) == 0)
2086 (void) SyncImageSettings(image_info,*image,exception);
2087 passkey=FileToStringInfo(args[0],~0,exception);
2088 if (passkey != (StringInfo *) NULL)
2090 (void) PasskeyDecipherImage(*image,passkey,exception);
2091 passkey=DestroyStringInfo(passkey);
2095 if (LocaleCompare("depth",option) == 0)
2097 /* The image_info->depth setting has already been set
2098 We just need to apply it to all images in current sequence
2099 WARNING: Depth from 8 to 16 causes 'quantum rounding to images!
2100 That is it really is an operation, not a setting! Arrgghhh
2102 (void) SyncImageSettings(image_info,*image,exception);
2103 (void) SetImageDepth(*image,image_info->depth);
2106 if (LocaleCompare("deskew",option) == 0)
2112 Straighten the image.
2114 (void) SyncImageSettings(image_info,*image,exception);
2115 if (*argv[0] == '+')
2116 threshold=40.0*QuantumRange/100.0;
2118 threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0);
2119 new_image=DeskewImage(*image,threshold,exception);
2122 if (LocaleCompare("despeckle",option) == 0)
2125 Reduce the speckles within an image.
2127 (void) SyncImageSettings(image_info,*image,exception);
2128 new_image=DespeckleImage(*image,exception);
2131 if (LocaleCompare("display",option) == 0)
2133 (void) CloneString(&draw_info->server_name,args[0]);
2136 if (LocaleCompare("distort",option) == 0)
2140 token[MaxTextExtent];
2160 (void) SyncImageSettings(image_info,*image,exception);
2161 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
2162 MagickFalse,args[0]);
2163 if ( method == ResizeDistortion )
2165 /* Special Case - Argument is actually a resize geometry!
2166 ** Convert that to an appropriate distortion argument array.
2170 (void) ParseRegionGeometry(*image,argv[2],&geometry,
2172 resize_args[0]=(double)geometry.width;
2173 resize_args[1]=(double)geometry.height;
2174 new_image=DistortImage(*image,method,(size_t)2,
2175 resize_args,MagickTrue,exception);
2178 args=InterpretImageProperties(image_info,*image,argv[2],
2180 if (args == (char *) NULL)
2183 for (x=0; *p != '\0'; x++)
2185 GetMagickToken(p,&p,token);
2187 GetMagickToken(p,&p,token);
2189 number_arguments=(size_t) x;
2190 arguments=(double *) AcquireQuantumMemory(number_arguments,
2191 sizeof(*arguments));
2192 if (arguments == (double *) NULL)
2193 ThrowWandFatalException(ResourceLimitFatalError,
2194 "MemoryAllocationFailed",(*image)->filename);
2195 (void) ResetMagickMemory(arguments,0,number_arguments*
2196 sizeof(*arguments));
2198 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
2200 GetMagickToken(p,&p,token);
2202 GetMagickToken(p,&p,token);
2203 arguments[x]=StringToDouble(token,(char **) NULL);
2205 args=DestroyString(args);
2206 new_image=DistortImage(*image,method,number_arguments,arguments,
2207 (*argv[0] == '+') ? MagickTrue : MagickFalse,exception);
2208 arguments=(double *) RelinquishMagickMemory(arguments);
2211 if (LocaleCompare("draw",option) == 0)
2213 (void) SyncImageSettings(image_info,*image,exception);
2214 (void) CloneString(&draw_info->primitive,args[0]);
2215 (void) DrawImage(*image,draw_info,exception);
2222 if (LocaleCompare("edge",option) == 0)
2224 (void) SyncImageSettings(image_info,*image,exception);
2225 flags=ParseGeometry(args[0],&geometry_info);
2226 if ((flags & SigmaValue) == 0)
2227 geometry_info.sigma=1.0;
2228 new_image=EdgeImage(*image,geometry_info.rho,
2229 geometry_info.sigma,exception);
2232 if (LocaleCompare("emboss",option) == 0)
2234 (void) SyncImageSettings(image_info,*image,exception);
2235 flags=ParseGeometry(args[0],&geometry_info);
2236 if ((flags & SigmaValue) == 0)
2237 geometry_info.sigma=1.0;
2238 new_image=EmbossImage(*image,geometry_info.rho,
2239 geometry_info.sigma,exception);
2242 if (LocaleCompare("encipher",option) == 0)
2247 (void) SyncImageSettings(image_info,*image,exception);
2248 passkey=FileToStringInfo(args[0],~0,exception);
2249 if (passkey != (StringInfo *) NULL)
2251 (void) PasskeyEncipherImage(*image,passkey,exception);
2252 passkey=DestroyStringInfo(passkey);
2256 if (LocaleCompare("enhance",option) == 0)
2258 (void) SyncImageSettings(image_info,*image,exception);
2259 new_image=EnhanceImage(*image,exception);
2262 if (LocaleCompare("equalize",option) == 0)
2264 (void) SyncImageSettings(image_info,*image,exception);
2265 (void) EqualizeImage(*image,exception);
2268 if (LocaleCompare("evaluate",option) == 0)
2273 MagickEvaluateOperator
2276 (void) SyncImageSettings(image_info,*image,exception);
2277 op=(MagickEvaluateOperator) ParseCommandOption(
2278 MagickEvaluateOptions,MagickFalse,args[0]);
2279 constant=StringToDoubleInterval(argv[2],(double) QuantumRange+1.0);
2280 (void) EvaluateImage(*image,op,constant,exception);
2283 if (LocaleCompare("extent",option) == 0)
2285 (void) SyncImageSettings(image_info,*image,exception);
2286 flags=ParseGravityGeometry(*image,args[0],&geometry,exception);
2287 if (geometry.width == 0)
2288 geometry.width=(*image)->columns;
2289 if (geometry.height == 0)
2290 geometry.height=(*image)->rows;
2291 new_image=ExtentImage(*image,&geometry,exception);
2298 if (LocaleCompare("features",option) == 0)
2300 /* FUTURE: Assign Artifact to all images -- per image setting */
2301 (void) SetImageArtifact(*image,"identify:features",
2302 IfSetOption ? args[0] : (const char *) NULL);
2305 if (LocaleCompare("flip",option) == 0)
2308 Flip image scanlines.
2310 (void) SyncImageSettings(image_info,*image,exception);
2311 new_image=FlipImage(*image,exception);
2314 if (LocaleCompare("flop",option) == 0)
2317 Flop image scanlines.
2319 (void) SyncImageSettings(image_info,*image,exception);
2320 new_image=FlopImage(*image,exception);
2323 if (LocaleCompare("floodfill",option) == 0)
2331 (void) SyncImageSettings(image_info,*image,exception);
2332 (void) ParsePageGeometry(*image,args[0],&geometry,exception);
2333 (void) QueryColorCompliance(argv[2],AllCompliance,&target,
2335 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
2336 geometry.y,*argv[0] == '-' ? MagickFalse : MagickTrue,exception);
2339 /* FUTURE: should be from ImageOption "format"
2340 if (LocaleCompare("format",option) == 0)
2346 if (LocaleCompare("frame",option) == 0)
2352 Surround image with an ornamental border.
2354 (void) SyncImageSettings(image_info,*image,exception);
2355 flags=ParsePageGeometry(*image,args[0],&geometry,exception);
2356 frame_info.width=geometry.width;
2357 frame_info.height=geometry.height;
2358 if ((flags & HeightValue) == 0)
2359 frame_info.height=geometry.width;
2360 frame_info.outer_bevel=geometry.x;
2361 frame_info.inner_bevel=geometry.y;
2362 frame_info.x=(ssize_t) frame_info.width;
2363 frame_info.y=(ssize_t) frame_info.height;
2364 frame_info.width=(*image)->columns+2*frame_info.width;
2365 frame_info.height=(*image)->rows+2*frame_info.height;
2366 new_image=FrameImage(*image,&frame_info,COMPOSE,exception);
2369 if (LocaleCompare("function",option) == 0)
2373 token[MaxTextExtent];
2391 Function Modify Image Values
2393 (void) SyncImageSettings(image_info,*image,exception);
2394 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
2395 MagickFalse,args[0]);
2396 arguments=InterpretImageProperties(image_info,*image,argv[2],
2398 if (arguments == (char *) NULL)
2400 p=(char *) arguments;
2401 for (x=0; *p != '\0'; x++)
2403 GetMagickToken(p,&p,token);
2405 GetMagickToken(p,&p,token);
2407 number_parameters=(size_t) x;
2408 parameters=(double *) AcquireQuantumMemory(number_parameters,
2409 sizeof(*parameters));
2410 if (parameters == (double *) NULL)
2411 ThrowWandFatalException(ResourceLimitFatalError,
2412 "MemoryAllocationFailed",(*image)->filename);
2413 (void) ResetMagickMemory(parameters,0,number_parameters*
2414 sizeof(*parameters));
2415 p=(char *) arguments;
2416 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
2418 GetMagickToken(p,&p,token);
2420 GetMagickToken(p,&p,token);
2421 parameters[x]=StringToDouble(token,(char **) NULL);
2423 arguments=DestroyString(arguments);
2424 (void) FunctionImage(*image,function,number_parameters,parameters,
2426 parameters=(double *) RelinquishMagickMemory(parameters);
2433 if (LocaleCompare("gamma",option) == 0)
2435 (void) SyncImageSettings(image_info,*image,exception);
2436 if (*argv[0] == '+')
2437 (*image)->gamma=StringToDouble(args[0],(char **) NULL);
2439 (void) GammaImage(*image,StringToDouble(args[0],
2440 (char **) NULL),exception);
2443 if ((LocaleCompare("gaussian-blur",option) == 0) ||
2444 (LocaleCompare("gaussian",option) == 0))
2446 (void) SyncImageSettings(image_info,*image,exception);
2447 flags=ParseGeometry(args[0],&geometry_info);
2448 if ((flags & SigmaValue) == 0)
2449 geometry_info.sigma=1.0;
2450 if ((flags & XiValue) == 0)
2451 geometry_info.xi=0.0;
2452 new_image=GaussianBlurImage(*image,geometry_info.rho,
2453 geometry_info.sigma,geometry_info.xi,exception);
2456 if (LocaleCompare("geometry",option) == 0)
2459 Record Image offset for composition,
2460 Resize last image. -- FUTURE depreciate this aspect
2462 (void) SyncImageSettings(image_info,*image,exception);
2463 if (*argv[0] == '+')
2465 if ((*image)->geometry != (char *) NULL)
2466 (*image)->geometry=DestroyString((*image)->geometry);
2469 flags=ParseRegionGeometry(*image,args[0],&geometry,exception);
2470 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2471 (void) CloneString(&(*image)->geometry,args[0]);
2473 new_image=ResizeImage(*image,geometry.width,geometry.height,
2474 (*image)->filter,(*image)->blur,exception);
2481 if (LocaleCompare("highlight-color",option) == 0)
2483 (void) SetImageArtifact(*image,option,args[0]);
2490 if (LocaleCompare("identify",option) == 0)
2495 (void) SyncImageSettings(image_info,*image,exception);
2496 if (format == (char *) NULL)
2498 (void) IdentifyImage(*image,stdout,image_info->verbose,
2502 text=InterpretImageProperties(image_info,*image,format,
2504 if (text == (char *) NULL)
2506 (void) fputs(text,stdout);
2507 (void) fputc('\n',stdout);
2508 text=DestroyString(text);
2511 if (LocaleCompare("implode",option) == 0)
2516 (void) SyncImageSettings(image_info,*image,exception);
2517 (void) ParseGeometry(args[0],&geometry_info);
2518 new_image=ImplodeImage(*image,geometry_info.rho,
2519 interpolate_method,exception);
2522 if (LocaleCompare("interline-spacing",option) == 0)
2524 if (*argv[0] == '+')
2525 (void) ParseGeometry("0",&geometry_info);
2527 (void) ParseGeometry(args[0],&geometry_info);
2528 draw_info->interline_spacing=geometry_info.rho;
2531 if (LocaleCompare("interpolate",option) == 0)
2533 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
2534 MagickInterpolateOptions,MagickFalse,args[0]);
2537 if (LocaleCompare("interword-spacing",option) == 0)
2539 if (*argv[0] == '+')
2540 (void) ParseGeometry("0",&geometry_info);
2542 (void) ParseGeometry(args[0],&geometry_info);
2543 draw_info->interword_spacing=geometry_info.rho;
2550 if (LocaleCompare("kerning",option) == 0)
2552 if (*argv[0] == '+')
2553 (void) ParseGeometry("0",&geometry_info);
2555 (void) ParseGeometry(args[0],&geometry_info);
2556 draw_info->kerning=geometry_info.rho;
2563 if (LocaleCompare("lat",option) == 0)
2566 Local adaptive threshold image.
2568 (void) SyncImageSettings(image_info,*image,exception);
2569 flags=ParseGeometry(args[0],&geometry_info);
2570 if ((flags & PercentValue) != 0)
2571 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2572 new_image=AdaptiveThresholdImage(*image,(size_t)
2573 geometry_info.rho,(size_t) geometry_info.sigma,(double)
2574 geometry_info.xi,exception);
2577 if (LocaleCompare("level",option) == 0)
2590 (void) SyncImageSettings(image_info,*image,exception);
2591 flags=ParseGeometry(args[0],&geometry_info);
2592 black_point=geometry_info.rho;
2593 white_point=(MagickRealType) QuantumRange;
2594 if ((flags & SigmaValue) != 0)
2595 white_point=geometry_info.sigma;
2597 if ((flags & XiValue) != 0)
2598 gamma=geometry_info.xi;
2599 if ((flags & PercentValue) != 0)
2601 black_point*=(MagickRealType) (QuantumRange/100.0);
2602 white_point*=(MagickRealType) (QuantumRange/100.0);
2604 if ((flags & SigmaValue) == 0)
2605 white_point=(MagickRealType) QuantumRange-black_point;
2606 if ((*argv[0] == '+') || ((flags & AspectValue) != 0))
2607 (void) LevelizeImage(*image,black_point,white_point,gamma,
2610 (void) LevelImage(*image,black_point,white_point,gamma,
2614 if (LocaleCompare("level-colors",option) == 0)
2617 token[MaxTextExtent];
2626 p=(const char *) args[0];
2627 GetMagickToken(p,&p,token); /* get black point color */
2628 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2629 (void) QueryColorCompliance(token,AllCompliance,
2630 &black_point,exception);
2632 (void) QueryColorCompliance("#000000",AllCompliance,
2633 &black_point,exception);
2634 if (isalpha((int) token[0]) || (token[0] == '#'))
2635 GetMagickToken(p,&p,token);
2637 white_point=black_point; /* set everything to that color */
2640 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2641 GetMagickToken(p,&p,token); /* Get white point color. */
2642 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2643 (void) QueryColorCompliance(token,AllCompliance,
2644 &white_point,exception);
2646 (void) QueryColorCompliance("#ffffff",AllCompliance,
2647 &white_point,exception);
2649 (void) LevelImageColors(*image,&black_point,&white_point,
2650 *argv[0] == '+' ? MagickTrue : MagickFalse,exception);
2653 if (LocaleCompare("linear-stretch",option) == 0)
2662 (void) SyncImageSettings(image_info,*image,exception);
2663 flags=ParseGeometry(args[0],&geometry_info);
2664 black_point=geometry_info.rho;
2665 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2666 if ((flags & SigmaValue) != 0)
2667 white_point=geometry_info.sigma;
2668 if ((flags & PercentValue) != 0)
2670 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2671 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2673 if ((flags & SigmaValue) == 0)
2674 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2676 (void) LinearStretchImage(*image,black_point,white_point,exception);
2679 if (LocaleCompare("linewidth",option) == 0)
2681 draw_info->stroke_width=StringToDouble(args[0],
2685 if (LocaleCompare("liquid-rescale",option) == 0)
2688 Liquid rescale image.
2690 (void) SyncImageSettings(image_info,*image,exception);
2691 flags=ParseRegionGeometry(*image,args[0],&geometry,exception);
2692 if ((flags & XValue) == 0)
2694 if ((flags & YValue) == 0)
2696 new_image=LiquidRescaleImage(*image,geometry.width,
2697 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2700 if (LocaleCompare("lowlight-color",option) == 0)
2702 (void) SetImageArtifact(*image,option,args[0]);
2709 if (LocaleCompare("map",option) == 0)
2715 Transform image colors to match this set of colors.
2717 (void) SyncImageSettings(image_info,*image,exception);
2718 if (*argv[0] == '+')
2720 remap_image=GetImageCache(image_info,args[0],exception);
2721 if (remap_image == (Image *) NULL)
2723 (void) RemapImage(quantize_info,*image,remap_image,exception);
2724 remap_image=DestroyImage(remap_image);
2727 if (LocaleCompare("mask",option) == 0)
2732 (void) SyncImageSettings(image_info,*image,exception);
2733 if (*argv[0] == '+')
2738 (void) SetImageMask(*image,(Image *) NULL,exception);
2744 mask=GetImageCache(image_info,args[0],exception);
2745 if (mask == (Image *) NULL)
2747 (void) SetImageMask(*image,mask,exception);
2748 mask=DestroyImage(mask);
2751 if (LocaleCompare("matte",option) == 0)
2753 (void) SetImageAlphaChannel(*image,(*argv[0] == '-') ?
2754 SetAlphaChannel : DeactivateAlphaChannel,exception);
2757 if (LocaleCompare("median",option) == 0)
2760 Median filter image.
2762 (void) SyncImageSettings(image_info,*image,exception);
2763 flags=ParseGeometry(args[0],&geometry_info);
2764 if ((flags & SigmaValue) == 0)
2765 geometry_info.sigma=geometry_info.rho;
2766 new_image=StatisticImage(*image,MedianStatistic,(size_t)
2767 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2770 if (LocaleCompare("mode",option) == 0)
2775 (void) SyncImageSettings(image_info,*image,exception);
2776 flags=ParseGeometry(args[0],&geometry_info);
2777 if ((flags & SigmaValue) == 0)
2778 geometry_info.sigma=geometry_info.rho;
2779 new_image=StatisticImage(*image,ModeStatistic,(size_t)
2780 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2783 if (LocaleCompare("modulate",option) == 0)
2785 (void) SyncImageSettings(image_info,*image,exception);
2786 (void) ModulateImage(*image,args[0],exception);
2789 if (LocaleCompare("monitor",option) == 0)
2791 /* FUTURE: Why is this a per-image setting? */
2792 if (*argv[0] == '+')
2794 (void) SetImageProgressMonitor(*image,
2795 (MagickProgressMonitor) NULL,(void *) NULL);
2798 (void) SetImageProgressMonitor(*image,MonitorProgress,
2802 if (LocaleCompare("monochrome",option) == 0)
2804 (void) SyncImageSettings(image_info,*image,exception);
2805 (void) SetImageType(*image,BilevelType,exception);
2808 if (LocaleCompare("morphology",option) == 0)
2811 token[MaxTextExtent];
2825 (void) SyncImageSettings(image_info,*image,exception);
2827 GetMagickToken(p,&p,token);
2828 method=(MorphologyMethod) ParseCommandOption(
2829 MagickMorphologyOptions,MagickFalse,token);
2831 GetMagickToken(p,&p,token);
2832 if ((*p == ':') || (*p == ','))
2833 GetMagickToken(p,&p,token);
2835 iterations=(ssize_t) StringToLong(p);
2836 kernel=AcquireKernelInfo(argv[2]);
2837 if (kernel == (KernelInfo *) NULL)
2839 (void) ThrowMagickException(exception,GetMagickModule(),
2840 OptionError,"UnabletoParseKernel","morphology");
2844 new_image=MorphologyImage(*image,method,iterations,kernel,
2846 kernel=DestroyKernelInfo(kernel);
2849 if (LocaleCompare("motion-blur",option) == 0)
2854 (void) SyncImageSettings(image_info,*image,exception);
2855 flags=ParseGeometry(args[0],&geometry_info);
2856 if ((flags & SigmaValue) == 0)
2857 geometry_info.sigma=1.0;
2858 new_image=MotionBlurImage(*image,geometry_info.rho,
2859 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2867 if (LocaleCompare("negate",option) == 0)
2869 (void) SyncImageSettings(image_info,*image,exception);
2870 (void) NegateImage(*image,*argv[0] == '+' ? MagickTrue :
2871 MagickFalse,exception);
2874 if (LocaleCompare("noise",option) == 0)
2876 (void) SyncImageSettings(image_info,*image,exception);
2877 if (*argv[0] == '-')
2879 flags=ParseGeometry(args[0],&geometry_info);
2880 if ((flags & SigmaValue) == 0)
2881 geometry_info.sigma=geometry_info.rho;
2882 new_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2883 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2890 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2891 MagickFalse,args[0]);
2892 new_image=AddNoiseImage(*image,noise,exception);
2896 if (LocaleCompare("normalize",option) == 0)
2898 (void) SyncImageSettings(image_info,*image,exception);
2899 (void) NormalizeImage(*image,exception);
2906 if (LocaleCompare("opaque",option) == 0)
2911 (void) SyncImageSettings(image_info,*image,exception);
2912 (void) QueryColorCompliance(args[0],AllCompliance,&target,
2914 (void) OpaquePaintImage(*image,&target,&fill,*argv[0] == '-' ?
2915 MagickFalse : MagickTrue,exception);
2918 if (LocaleCompare("ordered-dither",option) == 0)
2920 (void) SyncImageSettings(image_info,*image,exception);
2921 (void) OrderedPosterizeImage(*image,args[0],exception);
2928 if (LocaleCompare("paint",option) == 0)
2930 (void) SyncImageSettings(image_info,*image,exception);
2931 (void) ParseGeometry(args[0],&geometry_info);
2932 new_image=OilPaintImage(*image,geometry_info.rho,
2933 geometry_info.sigma,exception);
2936 if (LocaleCompare("polaroid",option) == 0)
2948 Simulate a Polaroid picture.
2950 (void) SyncImageSettings(image_info,*image,exception);
2951 random_info=AcquireRandomInfo();
2952 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2953 random_info=DestroyRandomInfo(random_info);
2954 if (*argv[0] == '-')
2956 SetGeometryInfo(&geometry_info);
2957 flags=ParseGeometry(args[0],&geometry_info);
2958 angle=geometry_info.rho;
2960 caption=GetImageProperty(*image,"caption",exception);
2961 new_image=PolaroidImage(*image,draw_info,caption,angle,
2962 interpolate_method,exception);
2965 if (LocaleCompare("posterize",option) == 0)
2970 (void) SyncImageSettings(image_info,*image,exception);
2971 (void) PosterizeImage(*image,StringToUnsignedLong(args[0]),
2972 quantize_info->dither,exception);
2975 if (LocaleCompare("preview",option) == 0)
2983 (void) SyncImageSettings(image_info,*image,exception);
2984 if (*argv[0] == '+')
2985 preview_type=UndefinedPreview;
2987 preview_type=(PreviewType) ParseCommandOption(
2988 MagickPreviewOptions,MagickFalse,args[0]);
2989 new_image=PreviewImage(*image,preview_type,exception);
2992 if (LocaleCompare("profile",option) == 0)
3006 (void) SyncImageSettings(image_info,*image,exception);
3007 if (*argv[0] == '+')
3010 Remove a profile from the image.
3012 (void) ProfileImage(*image,args[0],(const unsigned char *)
3017 Associate a profile with the image.
3019 profile_info=CloneImageInfo(image_info);
3020 profile=GetImageProfile(*image,"iptc");
3021 if (profile != (StringInfo *) NULL)
3022 profile_info->profile=(void *) CloneStringInfo(profile);
3023 profile_image=GetImageCache(profile_info,args[0],exception);
3024 profile_info=DestroyImageInfo(profile_info);
3025 if (profile_image == (Image *) NULL)
3030 profile_info=CloneImageInfo(image_info);
3031 (void) CopyMagickString(profile_info->filename,args[0],
3033 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
3034 if (profile != (StringInfo *) NULL)
3036 (void) ProfileImage(*image,profile_info->magick,
3037 GetStringInfoDatum(profile),(size_t)
3038 GetStringInfoLength(profile),exception);
3039 profile=DestroyStringInfo(profile);
3041 profile_info=DestroyImageInfo(profile_info);
3044 ResetImageProfileIterator(profile_image);
3045 name=GetNextImageProfile(profile_image);
3046 while (name != (const char *) NULL)
3048 profile=GetImageProfile(profile_image,name);
3049 if (profile != (StringInfo *) NULL)
3050 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
3051 (size_t) GetStringInfoLength(profile),exception);
3052 name=GetNextImageProfile(profile_image);
3054 profile_image=DestroyImage(profile_image);
3061 if (LocaleCompare("quantize",option) == 0)
3063 if (*argv[0] == '+')
3065 quantize_info->colorspace=UndefinedColorspace;
3068 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
3069 MagickColorspaceOptions,MagickFalse,args[0]);
3076 if (LocaleCompare("radial-blur",option) == 0)
3078 (void) SyncImageSettings(image_info,*image,exception);
3079 flags=ParseGeometry(args[0],&geometry_info);
3080 new_image=RadialBlurImage(*image,geometry_info.rho,
3081 geometry_info.sigma,exception);
3084 if (LocaleCompare("raise",option) == 0)
3086 flags=ParsePageGeometry(*image,args[0],&geometry,exception);
3087 if ((flags & SigmaValue) == 0)
3088 geometry.height=geometry.width;
3089 (void) RaiseImage(*image,&geometry,*argv[0] == '-' ? MagickTrue :
3090 MagickFalse,exception);
3093 if (LocaleCompare("random-threshold",option) == 0)
3095 (void) SyncImageSettings(image_info,*image,exception);
3096 (void) RandomThresholdImage(*image,args[0],exception);
3099 if (LocaleCompare("recolor",option) == 0)
3104 (void) SyncImageSettings(image_info,*image,exception);
3105 kernel=AcquireKernelInfo(args[0]);
3106 if (kernel == (KernelInfo *) NULL)
3108 new_image=ColorMatrixImage(*image,kernel,exception);
3109 kernel=DestroyKernelInfo(kernel);
3112 if (LocaleCompare("remap",option) == 0)
3117 (void) SyncImageSettings(image_info,*image,exception);
3118 if (*argv[0] == '+')
3120 remap_image=GetImageCache(image_info,args[0],exception);
3121 if (remap_image == (Image *) NULL)
3123 (void) RemapImage(quantize_info,*image,remap_image,exception);
3124 remap_image=DestroyImage(remap_image);
3127 if (LocaleCompare("repage",option) == 0)
3129 if (*argv[0] == '+')
3131 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
3134 (void) ResetImagePage(*image,args[0]);
3137 if (LocaleCompare("resample",option) == 0)
3139 /* FUTURE: remove blur - no longer used */
3140 (void) SyncImageSettings(image_info,*image,exception);
3141 flags=ParseGeometry(args[0],&geometry_info);
3142 if ((flags & SigmaValue) == 0)
3143 geometry_info.sigma=geometry_info.rho;
3144 new_image=ResampleImage(*image,geometry_info.rho,
3145 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
3148 if (LocaleCompare("resize",option) == 0)
3150 /* FUTURE: remove blur argument - no longer used */
3151 (void) SyncImageSettings(image_info,*image,exception);
3152 (void) ParseRegionGeometry(*image,args[0],&geometry,exception);
3153 new_image=ResizeImage(*image,geometry.width,geometry.height,
3154 (*image)->filter,(*image)->blur,exception);
3157 if (LocaleCompare("roll",option) == 0)
3159 (void) SyncImageSettings(image_info,*image,exception);
3160 (void) ParsePageGeometry(*image,args[0],&geometry,exception);
3161 new_image=RollImage(*image,geometry.x,geometry.y,exception);
3164 if (LocaleCompare("rotate",option) == 0)
3166 /* special case rotation flags */
3167 (void) SyncImageSettings(image_info,*image,exception);
3168 if (strchr(args[0],'>') != (char *) NULL)
3169 if ((*image)->columns <= (*image)->rows)
3171 if (strchr(args[0],'<') != (char *) NULL)
3172 if ((*image)->columns >= (*image)->rows)
3175 (void) ParseGeometry(args[0],&geometry_info);
3176 new_image=RotateImage(*image,geometry_info.rho,exception);
3183 if (LocaleCompare("sample",option) == 0)
3185 (void) SyncImageSettings(image_info,*image,exception);
3186 (void) ParseRegionGeometry(*image,args[0],&geometry,exception);
3187 new_image=SampleImage(*image,geometry.width,geometry.height,
3191 if (LocaleCompare("scale",option) == 0)
3193 (void) SyncImageSettings(image_info,*image,exception);
3194 (void) ParseRegionGeometry(*image,args[0],&geometry,exception);
3195 new_image=ScaleImage(*image,geometry.width,geometry.height,
3199 if (LocaleCompare("selective-blur",option) == 0)
3201 (void) SyncImageSettings(image_info,*image,exception);
3202 flags=ParseGeometry(args[0],&geometry_info);
3203 if ((flags & PercentValue) != 0)
3204 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3205 new_image=SelectiveBlurImage(*image,geometry_info.rho,
3206 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3209 if (LocaleCompare("separate",option) == 0)
3212 Break channels into separate images.
3213 WARNING: This can generate multiple images!
3215 (void) SyncImageSettings(image_info,*image,exception);
3216 new_image=SeparateImages(*image,exception);
3219 if (LocaleCompare("sepia-tone",option) == 0)
3224 (void) SyncImageSettings(image_info,*image,exception);
3225 threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0);
3226 new_image=SepiaToneImage(*image,threshold,exception);
3229 if (LocaleCompare("segment",option) == 0)
3231 (void) SyncImageSettings(image_info,*image,exception);
3232 flags=ParseGeometry(args[0],&geometry_info);
3233 if ((flags & SigmaValue) == 0)
3234 geometry_info.sigma=1.0;
3235 (void) SegmentImage(*image,(*image)->colorspace,
3236 image_info->verbose,geometry_info.rho,geometry_info.sigma,
3240 if (LocaleCompare("set",option) == 0)
3245 if (*argv[0] == '+')
3247 if (LocaleNCompare(args[0],"registry:",9) == 0)
3248 (void) DeleteImageRegistry(args[0]+9);
3250 if (LocaleNCompare(args[0],"argv[0]:",7) == 0)
3252 (void) DeleteImageOption(image_info,args[0]+7);
3253 (void) DeleteImageArtifact(*image,args[0]+7);
3256 (void) DeleteImageProperty(*image,args[0]);
3259 value=InterpretImageProperties(image_info,*image,argv[2],
3261 if (value == (char *) NULL)
3263 if (LocaleNCompare(args[0],"registry:",9) == 0)
3264 (void) SetImageRegistry(StringRegistryType,args[0]+9,value,
3267 if (LocaleNCompare(args[0],"option:",7) == 0)
3269 (void) SetImageOption(image_info,args[0]+7,value);
3270 (void) SetImageArtifact(*image,args[0]+7,value);
3273 (void) SetImageProperty(*image,args[0],value,exception);
3274 value=DestroyString(value);
3277 if (LocaleCompare("shade",option) == 0)
3279 (void) SyncImageSettings(image_info,*image,exception);
3280 flags=ParseGeometry(args[0],&geometry_info);
3281 if ((flags & SigmaValue) == 0)
3282 geometry_info.sigma=1.0;
3283 new_image=ShadeImage(*image,(*argv[0] == '-') ? MagickTrue :
3284 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
3287 if (LocaleCompare("shadow",option) == 0)
3289 (void) SyncImageSettings(image_info,*image,exception);
3290 flags=ParseGeometry(args[0],&geometry_info);
3291 if ((flags & SigmaValue) == 0)
3292 geometry_info.sigma=1.0;
3293 if ((flags & XiValue) == 0)
3294 geometry_info.xi=4.0;
3295 if ((flags & PsiValue) == 0)
3296 geometry_info.psi=4.0;
3297 new_image=ShadowImage(*image,geometry_info.rho,
3298 geometry_info.sigma,(*image)->bias,(ssize_t)
3299 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3303 if (LocaleCompare("sharpen",option) == 0)
3305 (void) SyncImageSettings(image_info,*image,exception);
3306 flags=ParseGeometry(args[0],&geometry_info);
3307 if ((flags & SigmaValue) == 0)
3308 geometry_info.sigma=1.0;
3309 if ((flags & XiValue) == 0)
3310 geometry_info.xi=0.0;
3311 new_image=SharpenImage(*image,geometry_info.rho,
3312 geometry_info.sigma,geometry_info.xi,exception);
3315 if (LocaleCompare("shave",option) == 0)
3317 (void) SyncImageSettings(image_info,*image,exception);
3318 flags=ParsePageGeometry(*image,args[0],&geometry,exception);
3319 new_image=ShaveImage(*image,&geometry,exception);
3322 if (LocaleCompare("shear",option) == 0)
3324 (void) SyncImageSettings(image_info,*image,exception);
3325 flags=ParseGeometry(args[0],&geometry_info);
3326 if ((flags & SigmaValue) == 0)
3327 geometry_info.sigma=geometry_info.rho;
3328 new_image=ShearImage(*image,geometry_info.rho,
3329 geometry_info.sigma,exception);
3332 if (LocaleCompare("sigmoidal-contrast",option) == 0)
3334 (void) SyncImageSettings(image_info,*image,exception);
3335 flags=ParseGeometry(args[0],&geometry_info);
3336 if ((flags & SigmaValue) == 0)
3337 geometry_info.sigma=(double) QuantumRange/2.0;
3338 if ((flags & PercentValue) != 0)
3339 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3341 (void) SigmoidalContrastImage(*image,(*argv[0] == '-') ?
3342 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
3346 if (LocaleCompare("sketch",option) == 0)
3348 (void) SyncImageSettings(image_info,*image,exception);
3349 flags=ParseGeometry(args[0],&geometry_info);
3350 if ((flags & SigmaValue) == 0)
3351 geometry_info.sigma=1.0;
3352 new_image=SketchImage(*image,geometry_info.rho,
3353 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3356 if (LocaleCompare("solarize",option) == 0)
3361 (void) SyncImageSettings(image_info,*image,exception);
3362 threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0);
3363 (void) SolarizeImage(*image,threshold,exception);
3366 if (LocaleCompare("sparse-color",option) == 0)
3374 (void) SyncImageSettings(image_info,*image,exception);
3375 method=(SparseColorMethod) ParseCommandOption(
3376 MagickSparseColorOptions,MagickFalse,args[0]);
3377 arguments=InterpretImageProperties(image_info,*image,argv[2],
3379 if (arguments == (char *) NULL)
3381 new_image=SparseColorOption(*image,method,arguments,
3382 argv[0][0] == '+' ? MagickTrue : MagickFalse,exception);
3383 arguments=DestroyString(arguments);
3386 if (LocaleCompare("splice",option) == 0)
3388 (void) SyncImageSettings(image_info,*image,exception);
3389 (void) ParseGravityGeometry(*image,args[0],&geometry,exception);
3390 new_image=SpliceImage(*image,&geometry,exception);
3393 if (LocaleCompare("spread",option) == 0)
3395 (void) SyncImageSettings(image_info,*image,exception);
3396 (void) ParseGeometry(args[0],&geometry_info);
3397 new_image=SpreadImage(*image,geometry_info.rho,
3398 interpolate_method,exception);
3401 if (LocaleCompare("statistic",option) == 0)
3406 (void) SyncImageSettings(image_info,*image,exception);
3407 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
3408 MagickFalse,args[0]);
3409 (void) ParseGeometry(argv[2],&geometry_info);
3410 new_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
3411 (size_t) geometry_info.sigma,exception);
3414 if (LocaleCompare("strip",option) == 0)
3416 (void) SyncImageSettings(image_info,*image,exception);
3417 (void) StripImage(*image,exception);
3420 if (LocaleCompare("swirl",option) == 0)
3422 (void) SyncImageSettings(image_info,*image,exception);
3423 (void) ParseGeometry(args[0],&geometry_info);
3424 new_image=SwirlImage(*image,geometry_info.rho,
3425 interpolate_method,exception);
3432 if (LocaleCompare("threshold",option) == 0)
3437 (void) SyncImageSettings(image_info,*image,exception);
3438 if (*argv[0] == '+')
3439 threshold=(double) QuantumRange/2;
3441 threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0);
3442 (void) BilevelImage(*image,threshold,exception);
3445 if (LocaleCompare("thumbnail",option) == 0)
3450 (void) SyncImageSettings(image_info,*image,exception);
3451 (void) ParseRegionGeometry(*image,args[0],&geometry,exception);
3452 new_image=ThumbnailImage(*image,geometry.width,geometry.height,
3456 if (LocaleCompare("tint",option) == 0)
3458 (void) SyncImageSettings(image_info,*image,exception);
3459 new_image=TintImage(*image,args[0],&fill,exception);
3462 if (LocaleCompare("transform",option) == 0)
3464 (void) SyncImageSettings(image_info,*image,exception);
3465 new_image=AffineTransformImage(*image,&draw_info->affine,
3469 if (LocaleCompare("transparent",option) == 0)
3474 (void) SyncImageSettings(image_info,*image,exception);
3475 (void) QueryColorCompliance(args[0],AllCompliance,&target,
3477 (void) TransparentPaintImage(*image,&target,(Quantum)
3478 TransparentAlpha,*argv[0] == '-' ? MagickFalse : MagickTrue,
3482 if (LocaleCompare("transpose",option) == 0)
3484 (void) SyncImageSettings(image_info,*image,exception);
3485 new_image=TransposeImage(*image,exception);
3488 if (LocaleCompare("transverse",option) == 0)
3490 (void) SyncImageSettings(image_info,*image,exception);
3491 new_image=TransverseImage(*image,exception);
3494 if (LocaleCompare("treedepth",option) == 0)
3496 quantize_info->tree_depth=StringToUnsignedLong(args[0]);
3499 if (LocaleCompare("trim",option) == 0)
3501 (void) SyncImageSettings(image_info,*image,exception);
3502 new_image=TrimImage(*image,exception);
3505 if (LocaleCompare("type",option) == 0)
3507 /* Note that "type" setting should have already been defined */
3508 (void) SyncImageSettings(image_info,*image,exception);
3509 (void) SetImageType(*image,type,exception);
3516 if (LocaleCompare("unique",option) == 0)
3518 if (*argv[0] == '+')
3520 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3523 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3524 (void) SetImageArtifact(*image,"verbose","true");
3527 if (LocaleCompare("unique-colors",option) == 0)
3529 (void) SyncImageSettings(image_info,*image,exception);
3530 new_image=UniqueImageColors(*image,exception);
3533 if (LocaleCompare("unsharp",option) == 0)
3535 (void) SyncImageSettings(image_info,*image,exception);
3536 flags=ParseGeometry(args[0],&geometry_info);
3537 if ((flags & SigmaValue) == 0)
3538 geometry_info.sigma=1.0;
3539 if ((flags & XiValue) == 0)
3540 geometry_info.xi=1.0;
3541 if ((flags & PsiValue) == 0)
3542 geometry_info.psi=0.05;
3543 new_image=UnsharpMaskImage(*image,geometry_info.rho,
3544 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3551 if (LocaleCompare("verbose",option) == 0)
3553 (void) SetImageArtifact(*image,option,
3554 *argv[0] == '+' ? "false" : "true");
3557 if (LocaleCompare("vignette",option) == 0)
3562 (void) SyncImageSettings(image_info,*image,exception);
3563 flags=ParseGeometry(args[0],&geometry_info);
3564 if ((flags & SigmaValue) == 0)
3565 geometry_info.sigma=1.0;
3566 if ((flags & XiValue) == 0)
3567 geometry_info.xi=0.1*(*image)->columns;
3568 if ((flags & PsiValue) == 0)
3569 geometry_info.psi=0.1*(*image)->rows;
3570 new_image=VignetteImage(*image,geometry_info.rho,
3571 geometry_info.sigma,(*image)->bias,(ssize_t)
3572 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3576 if (LocaleCompare("virtual-pixel",option) == 0)
3578 /* setting already defined in image_info structure */
3579 SetImageVirtualPixelMethod(*image, image_info->virtual_pixel_method);
3586 if (LocaleCompare("wave",option) == 0)
3588 (void) SyncImageSettings(image_info,*image,exception);
3589 flags=ParseGeometry(args[0],&geometry_info);
3590 if ((flags & SigmaValue) == 0)
3591 geometry_info.sigma=1.0;
3592 new_image=WaveImage(*image,geometry_info.rho,
3593 geometry_info.sigma,interpolate_method,exception);
3596 if (LocaleCompare("white-threshold",option) == 0)
3598 (void) SyncImageSettings(image_info,*image,exception);
3599 (void) WhiteThresholdImage(*image,args[0],exception);
3608 Replace current image with any image that was generated
3610 if (new_image != (Image *) NULL)
3611 ReplaceImageInListReturnLast(image,new_image);
3616 quantize_info=DestroyQuantizeInfo(quantize_info);
3617 draw_info=DestroyDrawInfo(draw_info);
3618 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3619 return(status == 0 ? MagickFalse : MagickTrue);
3623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3627 + S e q u e n c e O p e r a t i o n I m a g e s %
3631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3633 % SequenceOperationImages() applies a single operation that apply to the
3634 % entire image list (e.g. -append, -layers, -coalesce, etc.).
3636 % The format of the MogrifyImage method is:
3638 % MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3639 % const int argc, const char **argv,Image **images,
3640 % ExceptionInfo *exception)
3642 % A description of each parameter follows:
3644 % o image_info: the image info..
3646 % o argc: Specifies a pointer to an integer describing the number of
3647 % elements in the argument vector.
3649 % o argv: Specifies a pointer to a text array containing the command line
3652 % o images: pointer to pointer of the first image in image list.
3654 % o exception: return any errors or warnings in this structure.
3657 WandExport MagickBooleanType SequenceOperationImages(ImageInfo *image_info,
3658 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
3667 assert(image_info != (ImageInfo *) NULL);
3668 assert(image_info->signature == MagickSignature);
3669 assert(images != (Image **) NULL);
3670 assert((*images)->previous == (Image *) NULL);
3671 assert((*images)->signature == MagickSignature);
3672 if ((*images)->debug != MagickFalse)
3673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3674 (*images)->filename);
3675 if ((argc <= 0) || (*argv == (char *) NULL))
3679 switch (*(argv[0]+1))
3683 if (LocaleCompare("affinity",argv[0]+1) == 0)
3685 (void) SyncImagesSettings(image_info,*images,exception);
3686 if (*argv[0] == '+')
3688 (void) RemapImages(quantize_info,*images,(Image *) NULL,
3694 if (LocaleCompare("append",argv[0]+1) == 0)
3699 (void) SyncImagesSettings(image_info,*images,exception);
3700 append_image=AppendImages(*images,*argv[0] == '-' ? MagickTrue :
3701 MagickFalse,exception);
3702 if (append_image == (Image *) NULL)
3707 *images=DestroyImageList(*images);
3708 *images=append_image;
3711 if (LocaleCompare("average",argv[0]+1) == 0)
3717 Average an image sequence (deprecated).
3719 (void) SyncImagesSettings(image_info,*images,exception);
3720 average_image=EvaluateImages(*images,MeanEvaluateOperator,
3722 if (average_image == (Image *) NULL)
3727 *images=DestroyImageList(*images);
3728 *images=average_image;
3735 if (LocaleCompare("channel",argv[0]+1) == 0)
3740 if (*argv[0] == '+')
3742 channel=DefaultChannels;
3745 channel=(ChannelType) ParseChannelOption(argv[1]);
3746 SetPixelChannelMap(*images,channel);
3749 if (LocaleCompare("clut",argv[0]+1) == 0)
3755 (void) SyncImagesSettings(image_info,*images,exception);
3756 image=RemoveFirstImageFromList(images);
3757 clut_image=RemoveFirstImageFromList(images);
3758 if (clut_image == (Image *) NULL)
3763 (void) ClutImage(image,clut_image,interpolate_method,exception);
3764 clut_image=DestroyImage(clut_image);
3765 *images=DestroyImageList(*images);
3769 if (LocaleCompare("coalesce",argv[0]+1) == 0)
3774 (void) SyncImagesSettings(image_info,*images,exception);
3775 coalesce_image=CoalesceImages(*images,exception);
3776 if (coalesce_image == (Image *) NULL)
3781 *images=DestroyImageList(*images);
3782 *images=coalesce_image;
3785 if (LocaleCompare("combine",argv[0]+1) == 0)
3790 (void) SyncImagesSettings(image_info,*images,exception);
3791 combine_image=CombineImages(*images,exception);
3792 if (combine_image == (Image *) NULL)
3797 *images=DestroyImageList(*images);
3798 *images=combine_image;
3801 if (LocaleCompare("composite",argv[0]+1) == 0)
3817 value=GetImageOption(image_info,"compose");
3818 if (value != (const char *) NULL)
3819 compose=(CompositeOperator) ParseCommandOption(
3820 MagickComposeOptions,MagickFalse,value);
3822 compose=OverCompositeOp; /* use Over not image->compose */
3825 value=GetImageOption(image_info,"compose");
3827 if (value != (const char *) NULL)
3828 compose=(CompositeOperator) ParseCommandOption(
3829 MagickComposeOptions,MagickFalse,value);
3831 compose=OverCompositeOp; /* use Over not image->compose */
3834 (void) SyncImagesSettings(image_info,*images,exception);
3835 image=RemoveFirstImageFromList(images);
3836 composite_image=RemoveFirstImageFromList(images);
3837 if (composite_image == (Image *) NULL)
3842 (void) TransformImage(&composite_image,(char *) NULL,
3843 composite_image->geometry,exception);
3844 SetGeometry(composite_image,&geometry);
3845 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
3846 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
3848 mask_image=RemoveFirstImageFromList(images);
3849 if (mask_image != (Image *) NULL)
3851 if ((compose == DisplaceCompositeOp) ||
3852 (compose == DistortCompositeOp))
3855 Merge Y displacement into X displacement image.
3857 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
3858 mask_image,0,0,exception);
3859 mask_image=DestroyImage(mask_image);
3864 Set a blending mask for the composition.
3865 Posible error, what if image->mask already set.
3867 image->mask=mask_image;
3868 (void) NegateImage(image->mask,MagickFalse,exception);
3871 (void) CompositeImage(image,compose,composite_image,
3872 geometry.x,geometry.y,exception);
3873 if (mask_image != (Image *) NULL)
3874 mask_image=image->mask=DestroyImage(image->mask);
3875 composite_image=DestroyImage(composite_image);
3876 *images=DestroyImageList(*images);
3884 if (LocaleCompare("deconstruct",argv[0]+1) == 0)
3889 (void) SyncImagesSettings(image_info,*images,exception);
3890 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
3892 if (deconstruct_image == (Image *) NULL)
3897 *images=DestroyImageList(*images);
3898 *images=deconstruct_image;
3901 if (LocaleCompare("delete",argv[0]+1) == 0)
3903 if (*argv[0] == '+')
3904 DeleteImages(images,"-1",exception);
3906 DeleteImages(images,argv[1],exception);
3909 if (LocaleCompare("dither",argv[0]+1) == 0)
3911 if (*argv[0] == '+')
3913 quantize_info->dither=MagickFalse;
3916 quantize_info->dither=MagickTrue;
3917 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
3918 MagickDitherOptions,MagickFalse,argv[1]);
3921 if (LocaleCompare("duplicate",argv[0]+1) == 0)
3926 if (*argv[0] == '+')
3927 duplicate_images=DuplicateImages(*images,1,"-1",exception);
3936 number_duplicates=(size_t) StringToLong(argv[1]);
3937 p=strchr(argv[1],',');
3938 if (p == (const char *) NULL)
3939 duplicate_images=DuplicateImages(*images,number_duplicates,
3942 duplicate_images=DuplicateImages(*images,number_duplicates,p,
3945 AppendImageToList(images, duplicate_images);
3946 (void) SyncImagesSettings(image_info,*images,exception);
3953 if (LocaleCompare("evaluate-sequence",argv[0]+1) == 0)
3958 MagickEvaluateOperator
3961 (void) SyncImageSettings(image_info,*images);
3962 op=(MagickEvaluateOperator) ParseCommandOption(
3963 MagickEvaluateOptions,MagickFalse,argv[1]);
3964 evaluate_image=EvaluateImages(*images,op,exception);
3965 if (evaluate_image == (Image *) NULL)
3970 *images=DestroyImageList(*images);
3971 *images=evaluate_image;
3978 if (LocaleCompare("fft",argv[0]+1) == 0)
3984 Implements the discrete Fourier transform (DFT).
3986 (void) SyncImageSettings(image_info,*images);
3987 fourier_image=ForwardFourierTransformImage(*images,*argv[0] == '-' ?
3988 MagickTrue : MagickFalse,exception);
3989 if (fourier_image == (Image *) NULL)
3991 *images=DestroyImage(*images);
3992 *images=fourier_image;
3995 if (LocaleCompare("flatten",argv[0]+1) == 0)
4000 (void) SyncImagesSettings(image_info,*images,exception);
4001 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
4002 if (flatten_image == (Image *) NULL)
4004 *images=DestroyImageList(*images);
4005 *images=flatten_image;
4008 if (LocaleCompare("fx",argv[0]+1) == 0)
4013 (void) SyncImagesSettings(image_info,*images,exception);
4014 fx_image=FxImage(*images,argv[1],exception);
4015 if (fx_image == (Image *) NULL)
4020 *images=DestroyImageList(*images);
4028 if (LocaleCompare("hald-clut",argv[0]+1) == 0)
4034 (void) SyncImagesSettings(image_info,*images,exception);
4035 image=RemoveFirstImageFromList(images);
4036 hald_image=RemoveFirstImageFromList(images);
4037 if (hald_image == (Image *) NULL)
4042 (void) HaldClutImage(image,hald_image,exception);
4043 hald_image=DestroyImage(hald_image);
4044 if (*images != (Image *) NULL)
4045 *images=DestroyImageList(*images);
4053 if (LocaleCompare("ift",argv[0]+1) == 0)
4061 Implements the inverse fourier discrete Fourier transform (DFT).
4063 (void) SyncImagesSettings(image_info,*images,exception);
4064 magnitude_image=RemoveFirstImageFromList(images);
4065 phase_image=RemoveFirstImageFromList(images);
4066 if (phase_image == (Image *) NULL)
4071 fourier_image=InverseFourierTransformImage(magnitude_image,
4072 phase_image,*argv[0] == '-' ? MagickTrue : MagickFalse,exception);
4073 if (fourier_image == (Image *) NULL)
4075 if (*images != (Image *) NULL)
4076 *images=DestroyImage(*images);
4077 *images=fourier_image;
4080 if (LocaleCompare("insert",argv[0]+1) == 0)
4087 if (*argv[0] != '+')
4088 index=(ssize_t) StringToLong(argv[1]);
4089 p=RemoveLastImageFromList(images);
4090 if (p == (Image *) NULL)
4092 (void) ThrowMagickException(exception,GetMagickModule(),
4093 OptionError,"NoSuchImage","`%s'",argv[1]);
4099 PrependImageToList(images,q);
4101 if (index == (ssize_t) GetImageListLength(*images))
4102 AppendImageToList(images,q);
4105 q=GetImageFromList(*images,index-1);
4106 if (q == (Image *) NULL)
4108 (void) ThrowMagickException(exception,GetMagickModule(),
4109 OptionError,"NoSuchImage","`%s'",argv[1]);
4113 InsertImageInList(&q,p);
4115 *images=GetFirstImageInList(q);
4118 if (LocaleCompare("interpolate",argv[0]+1) == 0)
4120 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
4121 MagickInterpolateOptions,MagickFalse,argv[1]);
4128 if (LocaleCompare("layers",argv[0]+1) == 0)
4136 (void) SyncImagesSettings(image_info,*images,exception);
4137 layers=(Image *) NULL;
4138 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
4139 MagickFalse,argv[1]);
4144 layers=CoalesceImages(*images,exception);
4147 case CompareAnyLayer:
4148 case CompareClearLayer:
4149 case CompareOverlayLayer:
4152 layers=CompareImagesLayers(*images,method,exception);
4158 case TrimBoundsLayer:
4160 layers=MergeImageLayers(*images,method,exception);
4165 layers=DisposeImages(*images,exception);
4168 case OptimizeImageLayer:
4170 layers=OptimizeImageLayers(*images,exception);
4173 case OptimizePlusLayer:
4175 layers=OptimizePlusImageLayers(*images,exception);
4178 case OptimizeTransLayer:
4180 OptimizeImageTransparency(*images,exception);
4183 case RemoveDupsLayer:
4185 RemoveDuplicateLayers(images,exception);
4188 case RemoveZeroLayer:
4190 RemoveZeroDelayLayers(images,exception);
4196 General Purpose, GIF Animation Optimizer.
4198 layers=CoalesceImages(*images,exception);
4199 if (layers == (Image *) NULL)
4204 *images=DestroyImageList(*images);
4206 layers=OptimizeImageLayers(*images,exception);
4207 if (layers == (Image *) NULL)
4212 *images=DestroyImageList(*images);
4214 layers=(Image *) NULL;
4215 OptimizeImageTransparency(*images,exception);
4216 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4220 case CompositeLayer:
4234 value=GetImageOption(image_info,"compose");
4235 if (value != (const char *) NULL)
4236 compose=(CompositeOperator) ParseCommandOption(
4237 MagickComposeOptions,MagickFalse,value);
4239 compose=OverCompositeOp; /* use Over not image->compose */
4242 Split image sequence at the first 'NULL:' image.
4245 while (source != (Image *) NULL)
4247 source=GetNextImageInList(source);
4248 if ((source != (Image *) NULL) &&
4249 (LocaleCompare(source->magick,"NULL") == 0))
4252 if (source != (Image *) NULL)
4254 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4255 (GetNextImageInList(source) == (Image *) NULL))
4256 source=(Image *) NULL;
4260 Separate the two lists, junk the null: image.
4262 source=SplitImageList(source->previous);
4263 DeleteImageFromList(&source);
4266 if (source == (Image *) NULL)
4268 (void) ThrowMagickException(exception,GetMagickModule(),
4269 OptionError,"MissingNullSeparator","layers Composite");
4274 Adjust offset with gravity and virtual canvas.
4276 SetGeometry(*images,&geometry);
4277 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
4278 geometry.width=source->page.width != 0 ?
4279 source->page.width : source->columns;
4280 geometry.height=source->page.height != 0 ?
4281 source->page.height : source->rows;
4282 GravityAdjustGeometry((*images)->page.width != 0 ?
4283 (*images)->page.width : (*images)->columns,
4284 (*images)->page.height != 0 ? (*images)->page.height :
4285 (*images)->rows,(*images)->gravity,&geometry);
4288 Compose the two image sequences together
4290 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
4292 source=DestroyImageList(source);
4296 if (layers == (Image *) NULL)
4298 *images=DestroyImageList(*images);
4306 if (LocaleCompare("map",argv[0]+1) == 0)
4308 (void) SyncImagesSettings(image_info,*images,exception);
4309 if (*argv[0] == '+')
4311 (void) RemapImages(quantize_info,*images,(Image *) NULL,
4317 if (LocaleCompare("maximum",argv[0]+1) == 0)
4323 Maximum image sequence (deprecated).
4325 (void) SyncImagesSettings(image_info,*images,exception);
4326 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
4327 if (maximum_image == (Image *) NULL)
4332 *images=DestroyImageList(*images);
4333 *images=maximum_image;
4336 if (LocaleCompare("minimum",argv[0]+1) == 0)
4342 Minimum image sequence (deprecated).
4344 (void) SyncImagesSettings(image_info,*images,exception);
4345 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
4346 if (minimum_image == (Image *) NULL)
4351 *images=DestroyImageList(*images);
4352 *images=minimum_image;
4355 if (LocaleCompare("morph",argv[0]+1) == 0)
4360 (void) SyncImagesSettings(image_info,*images,exception);
4361 morph_image=MorphImages(*images,StringToUnsignedLong(argv[1]),
4363 if (morph_image == (Image *) NULL)
4368 *images=DestroyImageList(*images);
4369 *images=morph_image;
4372 if (LocaleCompare("mosaic",argv[0]+1) == 0)
4377 (void) SyncImagesSettings(image_info,*images,exception);
4378 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
4379 if (mosaic_image == (Image *) NULL)
4384 *images=DestroyImageList(*images);
4385 *images=mosaic_image;
4392 if (LocaleCompare("print",argv[0]+1) == 0)
4397 (void) SyncImagesSettings(image_info,*images,exception);
4398 string=InterpretImageProperties(image_info,*images,argv[1],
4400 if (string == (char *) NULL)
4402 (void) FormatLocaleFile(stdout,"%s",string);
4403 string=DestroyString(string);
4405 if (LocaleCompare("process",argv[0]+1) == 0)
4414 (void) SyncImagesSettings(image_info,*images,exception);
4415 arguments=StringToArgv(argv[1],&number_arguments);
4416 if (arguments == (char **) NULL)
4418 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
4439 Support old style syntax, filter="-option arg".
4441 length=strlen(argv[1]);
4442 token=(char *) NULL;
4443 if (~length >= (MaxTextExtent-1))
4444 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
4446 if (token == (char *) NULL)
4450 token_info=AcquireTokenInfo();
4451 status=Tokenizer(token_info,0,token,length,arguments,"","=",
4452 "\"",'\0',&breaker,&next,"e);
4453 token_info=DestroyTokenInfo(token_info);
4459 argv=(&(arguments[next]));
4460 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
4463 token=DestroyString(token);
4466 (void) SubstituteString(&arguments[1],"-","");
4467 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
4468 number_arguments-2,(const char **) arguments+2,exception);
4469 for (j=0; j < number_arguments; j++)
4470 arguments[j]=DestroyString(arguments[j]);
4471 arguments=(char **) RelinquishMagickMemory(arguments);
4478 if (LocaleCompare("reverse",argv[0]+1) == 0)
4480 ReverseImageList(images);
4487 if (LocaleCompare("smush",argv[0]+1) == 0)
4495 (void) SyncImagesSettings(image_info,*images,exception);
4496 offset=(ssize_t) StringToLong(argv[1]);
4497 smush_image=SmushImages(*images,*argv[0] == '-' ? MagickTrue :
4498 MagickFalse,offset,exception);
4499 if (smush_image == (Image *) NULL)
4504 *images=DestroyImageList(*images);
4505 *images=smush_image;
4508 if (LocaleCompare("swap",argv[0]+1) == 0)
4520 if (*argv[0] != '+')
4529 flags=ParseGeometry(argv[1],&geometry_info);
4530 index=(ssize_t) geometry_info.rho;
4531 if ((flags & SigmaValue) != 0)
4532 swap_index=(ssize_t) geometry_info.sigma;
4534 p=GetImageFromList(*images,index);
4535 q=GetImageFromList(*images,swap_index);
4536 if ((p == (Image *) NULL) || (q == (Image *) NULL))
4538 (void) ThrowMagickException(exception,GetMagickModule(),
4539 OptionError,"NoSuchImage","`%s'",(*images)->filename);
4545 swap=CloneImage(p,0,0,MagickTrue,exception);
4546 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
4547 ReplaceImageInList(&q,swap);
4548 *images=GetFirstImageInList(q);
4555 if (LocaleCompare("write",argv[0]+1) == 0)
4566 (void) SyncImagesSettings(image_info,*images,exception);
4567 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[1]);
4568 (void) DeleteImageRegistry(key);
4569 write_images=(*images);
4570 if (*argv[0] == '+')
4571 write_images=CloneImageList(*images,exception);
4572 write_info=CloneImageInfo(image_info);
4573 status&=WriteImages(write_info,write_images,argv[1],exception);
4574 write_info=DestroyImageInfo(write_info);
4575 if (*argv[0] == '+')
4576 write_images=DestroyImageList(write_images);
4584 quantize_info=DestroyQuantizeInfo(quantize_info);
4586 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
4587 return(status != 0 ? MagickTrue : MagickFalse);