2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/colormap.h"
53 #include "MagickCore/color-private.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/enhance.h"
61 #include "MagickCore/exception.h"
62 #include "MagickCore/exception-private.h"
63 #include "MagickCore/fx.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/image.h"
66 #include "MagickCore/image-private.h"
67 #include "MagickCore/list.h"
68 #include "MagickCore/log.h"
69 #include "MagickCore/magick.h"
70 #include "MagickCore/memory_.h"
71 #include "MagickCore/module.h"
72 #include "MagickCore/option.h"
73 #include "MagickCore/paint.h"
74 #include "MagickCore/pixel-accessor.h"
75 #include "MagickCore/profile.h"
76 #include "MagickCore/property.h"
77 #include "MagickCore/quantize.h"
78 #include "MagickCore/quantum-private.h"
79 #include "MagickCore/registry.h"
80 #include "MagickCore/resize.h"
81 #include "MagickCore/resource_.h"
82 #include "MagickCore/segment.h"
83 #include "MagickCore/shear.h"
84 #include "MagickCore/signature.h"
85 #include "MagickCore/static.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/string-private.h"
88 #include "MagickCore/transform.h"
89 #include "MagickCore/threshold.h"
90 #include "MagickCore/utility.h"
91 #if defined(MAGICKCORE_XML_DELEGATE)
92 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
93 # if defined(__MINGW32__)
96 # include <win32config.h>
99 # include <libxml/parser.h>
100 # include <libxml/xmlmemory.h>
101 # include <libxml/parserInternals.h>
102 # include <libxml/xmlerror.h>
108 #define ThrowMSLException(severity,tag,reason) \
109 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
113 Typedef declaractions.
115 typedef struct _MSLGroupInfo
118 numImages; /* how many images are in this group */
121 typedef struct _MSLInfo
146 #if defined(MAGICKCORE_XML_DELEGATE)
156 Forward declarations.
158 #if defined(MAGICKCORE_XML_DELEGATE)
159 static MagickBooleanType
160 WriteMSLImage(const ImageInfo *,Image *);
162 static MagickBooleanType
163 SetMSLAttributes(MSLInfo *,const char *,const char *);
166 #if defined(MAGICKCORE_XML_DELEGATE)
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % R e a d M S L I m a g e %
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
180 % It allocates the memory necessary for the new Image structure and returns a
181 % pointer to the new image.
183 % The format of the ReadMSLImage method is:
185 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
187 % A description of each parameter follows:
189 % o image_info: the image info.
191 % o exception: return any errors or warnings in this structure.
195 #if defined(__cplusplus) || defined(c_plusplus)
199 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
200 ExceptionInfo *exception)
214 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
215 sans_exception=AcquireExceptionInfo();
216 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
217 sans_exception=DestroyExceptionInfo(sans_exception);
218 if (image != (Image *) NULL)
220 read_info=CloneImageInfo(image_info);
221 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
222 image=ReadImage(read_info,exception);
223 read_info=DestroyImageInfo(read_info);
224 if (image != (Image *) NULL)
225 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
229 static int IsPathDirectory(const char *path)
237 if ((path == (const char *) NULL) || (*path == '\0'))
239 status=GetPathAttributes(path,&attributes);
240 if (status == MagickFalse)
242 if (S_ISDIR(attributes.st_mode) == 0)
247 static int MSLIsStandalone(void *context)
253 Is this document tagged standalone?
255 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
256 msl_info=(MSLInfo *) context;
257 return(msl_info->document->standalone == 1);
260 static int MSLHasInternalSubset(void *context)
266 Does this document has an internal subset?
268 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
269 " SAX.MSLHasInternalSubset()");
270 msl_info=(MSLInfo *) context;
271 return(msl_info->document->intSubset != NULL);
274 static int MSLHasExternalSubset(void *context)
280 Does this document has an external subset?
282 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
283 " SAX.MSLHasExternalSubset()");
284 msl_info=(MSLInfo *) context;
285 return(msl_info->document->extSubset != NULL);
288 static void MSLInternalSubset(void *context,const xmlChar *name,
289 const xmlChar *external_id,const xmlChar *system_id)
295 Does this document has an internal subset?
297 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
298 " SAX.internalSubset(%s %s %s)",name,
299 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
300 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
301 msl_info=(MSLInfo *) context;
302 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
305 static xmlParserInputPtr MSLResolveEntity(void *context,
306 const xmlChar *public_id,const xmlChar *system_id)
315 Special entity resolver, better left to the parser, it has more
316 context than the application layer. The default behaviour is to
317 not resolve the entities, in that case the ENTITY_REF nodes are
318 built in the structure (and the parameter values).
320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
321 " SAX.resolveEntity(%s, %s)",
322 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
323 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
324 msl_info=(MSLInfo *) context;
325 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
326 public_id,msl_info->parser);
330 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
336 Get an entity by name.
338 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
339 " SAX.MSLGetEntity(%s)",(const char *) name);
340 msl_info=(MSLInfo *) context;
341 return(xmlGetDocEntity(msl_info->document,name));
344 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
350 Get a parameter entity by name.
352 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
353 " SAX.getParameterEntity(%s)",(const char *) name);
354 msl_info=(MSLInfo *) context;
355 return(xmlGetParameterEntity(msl_info->document,name));
358 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
359 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
365 An entity definition has been parsed.
367 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
368 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
369 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
370 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
372 msl_info=(MSLInfo *) context;
373 if (msl_info->parser->inSubset == 1)
374 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
377 if (msl_info->parser->inSubset == 2)
378 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
382 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
383 const xmlChar *name,int type,int value,const xmlChar *default_value,
384 xmlEnumerationPtr tree)
397 An attribute definition has been parsed.
399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
400 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
402 msl_info=(MSLInfo *) context;
403 fullname=(xmlChar *) NULL;
404 prefix=(xmlChar *) NULL;
405 parser=msl_info->parser;
406 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
407 if (parser->inSubset == 1)
408 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
409 element,fullname,prefix,(xmlAttributeType) type,
410 (xmlAttributeDefault) value,default_value,tree);
412 if (parser->inSubset == 2)
413 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
414 element,fullname,prefix,(xmlAttributeType) type,
415 (xmlAttributeDefault) value,default_value,tree);
416 if (prefix != (xmlChar *) NULL)
418 if (fullname != (xmlChar *) NULL)
422 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
423 xmlElementContentPtr content)
432 An element definition has been parsed.
434 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
435 " SAX.elementDecl(%s, %d, ...)",name,type);
436 msl_info=(MSLInfo *) context;
437 parser=msl_info->parser;
438 if (parser->inSubset == 1)
439 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
440 name,(xmlElementTypeVal) type,content);
442 if (parser->inSubset == 2)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
444 name,(xmlElementTypeVal) type,content);
447 static void MSLNotationDeclaration(void *context,const xmlChar *name,
448 const xmlChar *public_id,const xmlChar *system_id)
457 What to do when a notation declaration has been parsed.
459 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
460 " SAX.notationDecl(%s, %s, %s)",name,
461 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
462 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
463 msl_info=(MSLInfo *) context;
464 parser=msl_info->parser;
465 if (parser->inSubset == 1)
466 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
467 name,public_id,system_id);
469 if (parser->inSubset == 2)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
474 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
475 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
481 What to do when an unparsed entity declaration is parsed.
483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
484 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
485 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
486 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
488 msl_info=(MSLInfo *) context;
489 (void) xmlAddDocEntity(msl_info->document,name,
490 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
494 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
500 Receive the document locator at startup, actually xmlDefaultSAXLocator.
502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
503 " SAX.setDocumentLocator()\n");
505 msl_info=(MSLInfo *) context;
509 static void MSLStartDocument(void *context)
518 Called when the document start being processed.
520 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521 " SAX.startDocument()");
522 msl_info=(MSLInfo *) context;
523 parser=msl_info->parser;
524 msl_info->document=xmlNewDoc(parser->version);
525 if (msl_info->document == (xmlDocPtr) NULL)
527 if (parser->encoding == NULL)
528 msl_info->document->encoding=NULL;
530 msl_info->document->encoding=xmlStrdup(parser->encoding);
531 msl_info->document->standalone=parser->standalone;
534 static void MSLEndDocument(void *context)
540 Called when the document end has been detected.
542 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
543 msl_info=(MSLInfo *) context;
544 if (msl_info->content != (char *) NULL)
545 msl_info->content=DestroyString(msl_info->content);
548 static void MSLPushImage(MSLInfo *msl_info,Image *image)
553 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
554 assert(msl_info != (MSLInfo *) NULL);
557 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
558 (n+1),sizeof(*msl_info->image_info));
559 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
560 (n+1),sizeof(*msl_info->draw_info));
561 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
562 (n+1),sizeof(*msl_info->attributes));
563 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
564 sizeof(*msl_info->image));
565 if ((msl_info->image_info == (ImageInfo **) NULL) ||
566 (msl_info->draw_info == (DrawInfo **) NULL) ||
567 (msl_info->attributes == (Image **) NULL) ||
568 (msl_info->image == (Image **) NULL))
569 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
570 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
571 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
572 msl_info->draw_info[n-1]);
573 if (image == (Image *) NULL)
574 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
576 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
577 msl_info->image[n]=(Image *) image;
578 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
579 (msl_info->attributes[n] == (Image *) NULL))
580 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
581 if (msl_info->number_groups != 0)
582 msl_info->group_info[msl_info->number_groups-1].numImages++;
585 static void MSLPopImage(MSLInfo *msl_info)
587 if (msl_info->number_groups != 0)
589 if (msl_info->image[msl_info->n] != (Image *) NULL)
590 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
591 msl_info->attributes[msl_info->n]=DestroyImage(
592 msl_info->attributes[msl_info->n]);
593 msl_info->image_info[msl_info->n]=DestroyImageInfo(
594 msl_info->image_info[msl_info->n]);
598 static void MSLStartElement(void *context,const xmlChar *tag,
599 const xmlChar **attributes)
655 Called when an opening tag has been processed.
657 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
658 " SAX.startElement(%s",tag);
659 GetExceptionInfo(&exception);
660 msl_info=(MSLInfo *) context;
662 keyword=(const char *) NULL;
664 SetGeometryInfo(&geometry_info);
665 channel=DefaultChannels;
671 if (LocaleCompare((const char *) tag,"add-noise") == 0)
682 if (msl_info->image[n] == (Image *) NULL)
684 ThrowMSLException(OptionError,"NoImagesDefined",
689 if (attributes != (const xmlChar **) NULL)
690 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
692 keyword=(const char *) attributes[i++];
693 attribute=InterpretImageProperties(msl_info->image_info[n],
694 msl_info->attributes[n],(const char *) attributes[i]);
695 CloneString(&value,attribute);
701 if (LocaleCompare(keyword,"channel") == 0)
703 option=ParseChannelOption(value);
705 ThrowMSLException(OptionError,"UnrecognizedChannelType",
707 channel=(ChannelType) option;
710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
717 if (LocaleCompare(keyword,"noise") == 0)
719 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
722 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
724 noise=(NoiseType) option;
727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
739 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
740 &msl_info->image[n]->exception);
741 if (noise_image == (Image *) NULL)
743 msl_info->image[n]=DestroyImage(msl_info->image[n]);
744 msl_info->image[n]=noise_image;
747 if (LocaleCompare((const char *) tag,"annotate") == 0)
755 if (msl_info->image[n] == (Image *) NULL)
757 ThrowMSLException(OptionError,"NoImagesDefined",
761 draw_info=CloneDrawInfo(msl_info->image_info[n],
762 msl_info->draw_info[n]);
764 current=draw_info->affine;
765 GetAffineMatrix(&affine);
766 if (attributes != (const xmlChar **) NULL)
767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
769 keyword=(const char *) attributes[i++];
770 attribute=InterpretImageProperties(msl_info->image_info[n],
771 msl_info->attributes[n],(const char *) attributes[i]);
772 CloneString(&value,attribute);
778 if (LocaleCompare(keyword,"affine") == 0)
784 draw_info->affine.sx=InterpretLocaleValue(p,&p);
787 draw_info->affine.rx=InterpretLocaleValue(p,&p);
790 draw_info->affine.ry=InterpretLocaleValue(p,&p);
793 draw_info->affine.sy=InterpretLocaleValue(p,&p);
796 draw_info->affine.tx=InterpretLocaleValue(p,&p);
799 draw_info->affine.ty=InterpretLocaleValue(p,&p);
802 if (LocaleCompare(keyword,"align") == 0)
804 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
807 ThrowMSLException(OptionError,"UnrecognizedAlignType",
809 draw_info->align=(AlignType) option;
812 if (LocaleCompare(keyword,"antialias") == 0)
814 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
817 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
819 draw_info->stroke_antialias=(MagickBooleanType) option;
820 draw_info->text_antialias=(MagickBooleanType) option;
823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
830 if (LocaleCompare(keyword,"density") == 0)
832 CloneString(&draw_info->density,value);
835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
842 if (LocaleCompare(keyword,"encoding") == 0)
844 CloneString(&draw_info->encoding,value);
847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
854 if (LocaleCompare(keyword, "fill") == 0)
856 (void) QueryColorDatabase(value,&draw_info->fill,
860 if (LocaleCompare(keyword,"family") == 0)
862 CloneString(&draw_info->family,value);
865 if (LocaleCompare(keyword,"font") == 0)
867 CloneString(&draw_info->font,value);
870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
877 if (LocaleCompare(keyword,"geometry") == 0)
879 flags=ParsePageGeometry(msl_info->image[n],value,
880 &geometry,&exception);
881 if ((flags & HeightValue) == 0)
882 geometry.height=geometry.width;
885 if (LocaleCompare(keyword,"gravity") == 0)
887 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
890 ThrowMSLException(OptionError,"UnrecognizedGravityType",
892 draw_info->gravity=(GravityType) option;
895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
902 if (LocaleCompare(keyword,"pointsize") == 0)
904 draw_info->pointsize=InterpretLocaleValue(value,
908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
915 if (LocaleCompare(keyword,"rotate") == 0)
917 angle=InterpretLocaleValue(value,(char **) NULL);
918 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
919 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
920 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
921 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
931 if (LocaleCompare(keyword,"scale") == 0)
933 flags=ParseGeometry(value,&geometry_info);
934 if ((flags & SigmaValue) == 0)
935 geometry_info.sigma=1.0;
936 affine.sx=geometry_info.rho;
937 affine.sy=geometry_info.sigma;
940 if (LocaleCompare(keyword,"skewX") == 0)
942 angle=InterpretLocaleValue(value,(char **) NULL);
943 affine.ry=tan(DegreesToRadians(fmod((double) angle,
947 if (LocaleCompare(keyword,"skewY") == 0)
949 angle=InterpretLocaleValue(value,(char **) NULL);
950 affine.rx=tan(DegreesToRadians(fmod((double) angle,
954 if (LocaleCompare(keyword,"stretch") == 0)
956 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
959 ThrowMSLException(OptionError,"UnrecognizedStretchType",
961 draw_info->stretch=(StretchType) option;
964 if (LocaleCompare(keyword, "stroke") == 0)
966 (void) QueryColorDatabase(value,&draw_info->stroke,
970 if (LocaleCompare(keyword,"strokewidth") == 0)
972 draw_info->stroke_width=StringToLong(value);
975 if (LocaleCompare(keyword,"style") == 0)
977 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
980 ThrowMSLException(OptionError,"UnrecognizedStyleType",
982 draw_info->style=(StyleType) option;
985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
992 if (LocaleCompare(keyword,"text") == 0)
994 CloneString(&draw_info->text,value);
997 if (LocaleCompare(keyword,"translate") == 0)
999 flags=ParseGeometry(value,&geometry_info);
1000 if ((flags & SigmaValue) == 0)
1001 geometry_info.sigma=1.0;
1002 affine.tx=geometry_info.rho;
1003 affine.ty=geometry_info.sigma;
1006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1013 if (LocaleCompare(keyword, "undercolor") == 0)
1015 (void) QueryColorDatabase(value,&draw_info->undercolor,
1019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1026 if (LocaleCompare(keyword,"weight") == 0)
1028 draw_info->weight=StringToLong(value);
1031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1038 if (LocaleCompare(keyword,"x") == 0)
1040 geometry.x=StringToLong(value);
1043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1050 if (LocaleCompare(keyword,"y") == 0)
1052 geometry.y=StringToLong(value);
1055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1067 (void) FormatLocaleString(text,MaxTextExtent,
1068 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1069 geometry.height,(double) geometry.x,(double) geometry.y);
1070 CloneString(&draw_info->geometry,text);
1071 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1072 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1073 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1074 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1075 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1077 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1079 (void) AnnotateImage(msl_info->image[n],draw_info);
1080 draw_info=DestroyDrawInfo(draw_info);
1083 if (LocaleCompare((const char *) tag,"append") == 0)
1091 if (msl_info->image[n] == (Image *) NULL)
1093 ThrowMSLException(OptionError,"NoImagesDefined",
1094 (const char *) tag);
1098 if (attributes != (const xmlChar **) NULL)
1099 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1101 keyword=(const char *) attributes[i++];
1102 attribute=InterpretImageProperties(msl_info->image_info[n],
1103 msl_info->attributes[n],(const char *) attributes[i]);
1104 CloneString(&value,attribute);
1110 if (LocaleCompare(keyword,"stack") == 0)
1112 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1115 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1117 stack=(MagickBooleanType) option;
1120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1132 append_image=AppendImages(msl_info->image[n],stack,
1133 &msl_info->image[n]->exception);
1134 if (append_image == (Image *) NULL)
1136 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1137 msl_info->image[n]=append_image;
1140 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1146 if (LocaleCompare((const char *) tag,"blur") == 0)
1154 if (msl_info->image[n] == (Image *) NULL)
1156 ThrowMSLException(OptionError,"NoImagesDefined",
1157 (const char *) tag);
1160 if (attributes != (const xmlChar **) NULL)
1161 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1163 keyword=(const char *) attributes[i++];
1164 attribute=InterpretImageProperties(msl_info->image_info[n],
1165 msl_info->attributes[n],(const char *) attributes[i]);
1166 CloneString(&value,attribute);
1172 if (LocaleCompare(keyword,"channel") == 0)
1174 option=ParseChannelOption(value);
1176 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1178 channel=(ChannelType) option;
1181 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1188 if (LocaleCompare(keyword,"geometry") == 0)
1190 flags=ParseGeometry(value,&geometry_info);
1191 if ((flags & SigmaValue) == 0)
1192 geometry_info.sigma=1.0;
1195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1202 if (LocaleCompare(keyword,"radius") == 0)
1204 geometry_info.rho=InterpretLocaleValue(value,
1208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1215 if (LocaleCompare(keyword,"sigma") == 0)
1217 geometry_info.sigma=StringToLong(value);
1220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1232 blur_image=BlurImageChannel(msl_info->image[n],channel,
1233 geometry_info.rho,geometry_info.sigma,
1234 &msl_info->image[n]->exception);
1235 if (blur_image == (Image *) NULL)
1237 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1238 msl_info->image[n]=blur_image;
1241 if (LocaleCompare((const char *) tag,"border") == 0)
1249 if (msl_info->image[n] == (Image *) NULL)
1251 ThrowMSLException(OptionError,"NoImagesDefined",
1252 (const char *) tag);
1255 SetGeometry(msl_info->image[n],&geometry);
1256 if (attributes != (const xmlChar **) NULL)
1257 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1259 keyword=(const char *) attributes[i++];
1260 attribute=InterpretImageProperties(msl_info->image_info[n],
1261 msl_info->attributes[n],(const char *) attributes[i]);
1262 CloneString(&value,attribute);
1268 if (LocaleCompare(keyword,"compose") == 0)
1270 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1273 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1275 msl_info->image[n]->compose=(CompositeOperator) option;
1278 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1285 if (LocaleCompare(keyword, "fill") == 0)
1287 (void) QueryColorDatabase(value,
1288 &msl_info->image[n]->border_color,&exception);
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword,"geometry") == 0)
1300 flags=ParsePageGeometry(msl_info->image[n],value,
1301 &geometry,&exception);
1302 if ((flags & HeightValue) == 0)
1303 geometry.height=geometry.width;
1306 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1313 if (LocaleCompare(keyword,"height") == 0)
1315 geometry.height=StringToLong(value);
1318 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1325 if (LocaleCompare(keyword,"width") == 0)
1327 geometry.width=StringToLong(value);
1330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1336 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1342 border_image=BorderImage(msl_info->image[n],&geometry,
1343 &msl_info->image[n]->exception);
1344 if (border_image == (Image *) NULL)
1346 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1347 msl_info->image[n]=border_image;
1350 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1355 if (LocaleCompare((const char *) tag,"colorize") == 0)
1358 opacity[MaxTextExtent];
1369 if (msl_info->image[n] == (Image *) NULL)
1371 ThrowMSLException(OptionError,"NoImagesDefined",
1372 (const char *) tag);
1375 target=msl_info->image[n]->background_color;
1376 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1377 if (attributes != (const xmlChar **) NULL)
1378 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1380 keyword=(const char *) attributes[i++];
1381 attribute=InterpretImageProperties(msl_info->image_info[n],
1382 msl_info->attributes[n],(const char *) attributes[i]);
1383 CloneString(&value,attribute);
1389 if (LocaleCompare(keyword,"fill") == 0)
1391 (void) QueryColorDatabase(value,&target,
1392 &msl_info->image[n]->exception);
1395 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1402 if (LocaleCompare(keyword,"opacity") == 0)
1404 (void) CopyMagickString(opacity,value,MaxTextExtent);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1419 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1420 &msl_info->image[n]->exception);
1421 if (colorize_image == (Image *) NULL)
1423 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1424 msl_info->image[n]=colorize_image;
1427 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1429 double radius = 0.0,
1432 if (msl_info->image[n] == (Image *) NULL)
1434 ThrowMSLException(OptionError,"NoImagesDefined",
1435 (const char *) tag);
1439 NOTE: charcoal can have no attributes, since we use all the defaults!
1441 if (attributes != (const xmlChar **) NULL)
1443 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1445 keyword=(const char *) attributes[i++];
1446 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1447 msl_info->attributes[n],(const char *) attributes[i]));
1453 if (LocaleCompare(keyword, "radius") == 0)
1455 radius = InterpretLocaleValue(value,(char **) NULL);
1458 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1464 if (LocaleCompare(keyword,"sigma") == 0)
1466 sigma = StringToLong( value );
1469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1474 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1488 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1489 &msl_info->image[n]->exception);
1490 if (newImage == (Image *) NULL)
1492 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1493 msl_info->image[n]=newImage;
1497 if (LocaleCompare((const char *) tag,"chop") == 0)
1505 if (msl_info->image[n] == (Image *) NULL)
1507 ThrowMSLException(OptionError,"NoImagesDefined",
1508 (const char *) tag);
1511 SetGeometry(msl_info->image[n],&geometry);
1512 if (attributes != (const xmlChar **) NULL)
1513 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1515 keyword=(const char *) attributes[i++];
1516 attribute=InterpretImageProperties(msl_info->image_info[n],
1517 msl_info->attributes[n],(const char *) attributes[i]);
1518 CloneString(&value,attribute);
1524 if (LocaleCompare(keyword,"geometry") == 0)
1526 flags=ParsePageGeometry(msl_info->image[n],value,
1527 &geometry,&exception);
1528 if ((flags & HeightValue) == 0)
1529 geometry.height=geometry.width;
1532 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1539 if (LocaleCompare(keyword,"height") == 0)
1541 geometry.height=StringToLong(value);
1544 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1551 if (LocaleCompare(keyword,"width") == 0)
1553 geometry.width=StringToLong(value);
1556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1563 if (LocaleCompare(keyword,"x") == 0)
1565 geometry.x=StringToLong(value);
1568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1575 if (LocaleCompare(keyword,"y") == 0)
1577 geometry.y=StringToLong(value);
1580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1592 chop_image=ChopImage(msl_info->image[n],&geometry,
1593 &msl_info->image[n]->exception);
1594 if (chop_image == (Image *) NULL)
1596 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1597 msl_info->image[n]=chop_image;
1600 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1609 Color floodfill image.
1611 if (msl_info->image[n] == (Image *) NULL)
1613 ThrowMSLException(OptionError,"NoImagesDefined",
1614 (const char *) tag);
1617 draw_info=CloneDrawInfo(msl_info->image_info[n],
1618 msl_info->draw_info[n]);
1619 SetGeometry(msl_info->image[n],&geometry);
1620 paint_method=FloodfillMethod;
1621 if (attributes != (const xmlChar **) NULL)
1622 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1624 keyword=(const char *) attributes[i++];
1625 attribute=InterpretImageProperties(msl_info->image_info[n],
1626 msl_info->attributes[n],(const char *) attributes[i]);
1627 CloneString(&value,attribute);
1633 if (LocaleCompare(keyword,"bordercolor") == 0)
1635 (void) QueryMagickColor(value,&target,&exception);
1636 paint_method=FillToBorderMethod;
1639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1646 if (LocaleCompare(keyword,"fill") == 0)
1648 (void) QueryColorDatabase(value,&draw_info->fill,
1652 if (LocaleCompare(keyword,"fuzz") == 0)
1654 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1665 if (LocaleCompare(keyword,"geometry") == 0)
1667 flags=ParsePageGeometry(msl_info->image[n],value,
1668 &geometry,&exception);
1669 if ((flags & HeightValue) == 0)
1670 geometry.height=geometry.width;
1671 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1672 geometry.x,geometry.y,&target,&exception);
1675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1682 if (LocaleCompare(keyword,"x") == 0)
1684 geometry.x=StringToLong(value);
1685 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1686 geometry.x,geometry.y,&target,&exception);
1689 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1696 if (LocaleCompare(keyword,"y") == 0)
1698 geometry.y=StringToLong(value);
1699 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1700 geometry.x,geometry.y,&target,&exception);
1703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1715 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1716 draw_info,&target,geometry.x,geometry.y,
1717 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1718 draw_info=DestroyDrawInfo(draw_info);
1721 if (LocaleCompare((const char *) tag,"comment") == 0)
1723 if (LocaleCompare((const char *) tag,"composite") == 0)
1726 composite_geometry[MaxTextExtent];
1741 if (msl_info->image[n] == (Image *) NULL)
1743 ThrowMSLException(OptionError,"NoImagesDefined",
1744 (const char *) tag);
1747 composite_image=NewImageList();
1748 compose=OverCompositeOp;
1749 if (attributes != (const xmlChar **) NULL)
1750 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1752 keyword=(const char *) attributes[i++];
1753 attribute=InterpretImageProperties(msl_info->image_info[n],
1754 msl_info->attributes[n],(const char *) attributes[i]);
1755 CloneString(&value,attribute);
1761 if (LocaleCompare(keyword,"compose") == 0)
1763 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1766 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1768 compose=(CompositeOperator) option;
1776 if (LocaleCompare(keyword,"image") == 0)
1777 for (j=0; j < msl_info->n; j++)
1782 attribute=GetImageProperty(msl_info->attributes[j],"id");
1783 if ((attribute != (const char *) NULL) &&
1784 (LocaleCompare(attribute,value) == 0))
1786 composite_image=CloneImage(msl_info->image[j],0,0,
1787 MagickFalse,&exception);
1797 if (composite_image == (Image *) NULL)
1799 rotate_image=NewImageList();
1800 SetGeometry(msl_info->image[n],&geometry);
1801 if (attributes != (const xmlChar **) NULL)
1802 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1804 keyword=(const char *) attributes[i++];
1805 attribute=InterpretImageProperties(msl_info->image_info[n],
1806 msl_info->attributes[n],(const char *) attributes[i]);
1807 CloneString(&value,attribute);
1813 if (LocaleCompare(keyword,"blend") == 0)
1815 (void) SetImageArtifact(composite_image,
1816 "compose:args",value);
1819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1826 if (LocaleCompare(keyword,"channel") == 0)
1828 option=ParseChannelOption(value);
1830 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1832 channel=(ChannelType) option;
1835 if (LocaleCompare(keyword, "color") == 0)
1837 (void) QueryColorDatabase(value,
1838 &composite_image->background_color,&exception);
1841 if (LocaleCompare(keyword,"compose") == 0)
1843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1850 if (LocaleCompare(keyword,"geometry") == 0)
1852 flags=ParsePageGeometry(msl_info->image[n],value,
1853 &geometry,&exception);
1854 if ((flags & HeightValue) == 0)
1855 geometry.height=geometry.width;
1856 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1857 geometry.y,&target,&exception);
1860 if (LocaleCompare(keyword,"gravity") == 0)
1862 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1865 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1867 msl_info->image[n]->gravity=(GravityType) option;
1870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1877 if (LocaleCompare(keyword,"image") == 0)
1879 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1886 if (LocaleCompare(keyword,"mask") == 0)
1887 for (j=0; j < msl_info->n; j++)
1892 attribute=GetImageProperty(msl_info->attributes[j],"id");
1893 if ((attribute != (const char *) NULL) &&
1894 (LocaleCompare(value,value) == 0))
1896 SetImageType(composite_image,TrueColorMatteType);
1897 (void) CompositeImage(composite_image,
1898 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1909 if (LocaleCompare(keyword,"opacity") == 0)
1924 opacity=StringToLong(value);
1925 if (compose != DissolveCompositeOp)
1927 (void) SetImageOpacity(composite_image,(Quantum)
1931 (void) SetImageArtifact(msl_info->image[n],
1932 "compose:args",value);
1933 if (composite_image->matte != MagickTrue)
1934 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1935 composite_view=AcquireCacheView(composite_image);
1936 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1938 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1939 (ssize_t) composite_image->columns,1,&exception);
1940 for (x=0; x < (ssize_t) composite_image->columns; x++)
1942 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1943 SetPixelAlpha(composite_image,
1944 ClampToQuantum(opacity),q);
1945 q+=GetPixelChannels(composite_image);
1947 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1950 composite_view=DestroyCacheView(composite_view);
1953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1960 if (LocaleCompare(keyword,"rotate") == 0)
1962 rotate_image=RotateImage(composite_image,
1963 InterpretLocaleValue(value,(char **) NULL),&exception);
1966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1973 if (LocaleCompare(keyword,"tile") == 0)
1978 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1981 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1983 tile=(MagickBooleanType) option;
1985 if (rotate_image != (Image *) NULL)
1986 (void) SetImageArtifact(rotate_image,
1987 "compose:outside-overlay","false");
1989 (void) SetImageArtifact(composite_image,
1990 "compose:outside-overlay","false");
1991 image=msl_info->image[n];
1992 height=composite_image->rows;
1993 width=composite_image->columns;
1994 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1995 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1997 if (rotate_image != (Image *) NULL)
1998 (void) CompositeImage(image,compose,rotate_image,
2001 (void) CompositeImage(image,compose,
2002 composite_image,x,y);
2004 if (rotate_image != (Image *) NULL)
2005 rotate_image=DestroyImage(rotate_image);
2008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2015 if (LocaleCompare(keyword,"x") == 0)
2017 geometry.x=StringToLong(value);
2018 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2019 geometry.y,&target,&exception);
2022 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2029 if (LocaleCompare(keyword,"y") == 0)
2031 geometry.y=StringToLong(value);
2032 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2033 geometry.y,&target,&exception);
2036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2048 image=msl_info->image[n];
2049 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2050 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2051 (double) composite_image->rows,(double) geometry.x,(double)
2053 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2055 if (rotate_image == (Image *) NULL)
2056 CompositeImageChannel(image,channel,compose,composite_image,
2057 geometry.x,geometry.y);
2063 geometry.x-=(ssize_t) (rotate_image->columns-
2064 composite_image->columns)/2;
2065 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2066 CompositeImageChannel(image,channel,compose,rotate_image,
2067 geometry.x,geometry.y);
2068 rotate_image=DestroyImage(rotate_image);
2070 composite_image=DestroyImage(composite_image);
2073 if (LocaleCompare((const char *) tag,"contrast") == 0)
2081 if (msl_info->image[n] == (Image *) NULL)
2083 ThrowMSLException(OptionError,"NoImagesDefined",
2084 (const char *) tag);
2087 sharpen=MagickFalse;
2088 if (attributes != (const xmlChar **) NULL)
2089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2091 keyword=(const char *) attributes[i++];
2092 attribute=InterpretImageProperties(msl_info->image_info[n],
2093 msl_info->attributes[n],(const char *) attributes[i]);
2094 CloneString(&value,attribute);
2100 if (LocaleCompare(keyword,"sharpen") == 0)
2102 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2105 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2107 sharpen=(MagickBooleanType) option;
2110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2122 (void) ContrastImage(msl_info->image[n],sharpen);
2125 if (LocaleCompare((const char *) tag,"crop") == 0)
2133 if (msl_info->image[n] == (Image *) NULL)
2135 ThrowMSLException(OptionError,"NoImagesDefined",
2136 (const char *) tag);
2139 SetGeometry(msl_info->image[n],&geometry);
2140 if (attributes != (const xmlChar **) NULL)
2141 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2143 keyword=(const char *) attributes[i++];
2144 attribute=InterpretImageProperties(msl_info->image_info[n],
2145 msl_info->attributes[n],(const char *) attributes[i]);
2146 CloneString(&value,attribute);
2152 if (LocaleCompare(keyword,"geometry") == 0)
2154 flags=ParsePageGeometry(msl_info->image[n],value,
2155 &geometry,&exception);
2156 if ((flags & HeightValue) == 0)
2157 geometry.height=geometry.width;
2160 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2167 if (LocaleCompare(keyword,"height") == 0)
2169 geometry.height=StringToLong(value);
2172 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2179 if (LocaleCompare(keyword,"width") == 0)
2181 geometry.width=StringToLong(value);
2184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2191 if (LocaleCompare(keyword,"x") == 0)
2193 geometry.x=StringToLong(value);
2196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 if (LocaleCompare(keyword,"y") == 0)
2205 geometry.y=StringToLong(value);
2208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2220 crop_image=CropImage(msl_info->image[n],&geometry,
2221 &msl_info->image[n]->exception);
2222 if (crop_image == (Image *) NULL)
2224 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2225 msl_info->image[n]=crop_image;
2228 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2234 Cycle-colormap image.
2236 if (msl_info->image[n] == (Image *) NULL)
2238 ThrowMSLException(OptionError,"NoImagesDefined",
2239 (const char *) tag);
2243 if (attributes != (const xmlChar **) NULL)
2244 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2246 keyword=(const char *) attributes[i++];
2247 attribute=InterpretImageProperties(msl_info->image_info[n],
2248 msl_info->attributes[n],(const char *) attributes[i]);
2249 CloneString(&value,attribute);
2255 if (LocaleCompare(keyword,"display") == 0)
2257 display=StringToLong(value);
2260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2272 (void) CycleColormapImage(msl_info->image[n],display);
2275 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2280 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2288 if (msl_info->image[n] == (Image *) NULL)
2290 ThrowMSLException(OptionError,"NoImagesDefined",
2291 (const char *) tag);
2294 if (attributes != (const xmlChar **) NULL)
2295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2297 keyword=(const char *) attributes[i++];
2298 attribute=InterpretImageProperties(msl_info->image_info[n],
2299 msl_info->attributes[n],(const char *) attributes[i]);
2300 CloneString(&value,attribute);
2301 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2303 despeckle_image=DespeckleImage(msl_info->image[n],
2304 &msl_info->image[n]->exception);
2305 if (despeckle_image == (Image *) NULL)
2307 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2308 msl_info->image[n]=despeckle_image;
2311 if (LocaleCompare((const char *) tag,"display") == 0)
2313 if (msl_info->image[n] == (Image *) NULL)
2315 ThrowMSLException(OptionError,"NoImagesDefined",
2316 (const char *) tag);
2319 if (attributes != (const xmlChar **) NULL)
2320 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2322 keyword=(const char *) attributes[i++];
2323 attribute=InterpretImageProperties(msl_info->image_info[n],
2324 msl_info->attributes[n],(const char *) attributes[i]);
2325 CloneString(&value,attribute);
2330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2336 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2339 if (LocaleCompare((const char *) tag,"draw") == 0)
2342 text[MaxTextExtent];
2347 if (msl_info->image[n] == (Image *) NULL)
2349 ThrowMSLException(OptionError,"NoImagesDefined",
2350 (const char *) tag);
2353 draw_info=CloneDrawInfo(msl_info->image_info[n],
2354 msl_info->draw_info[n]);
2356 current=draw_info->affine;
2357 GetAffineMatrix(&affine);
2358 if (attributes != (const xmlChar **) NULL)
2359 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2361 keyword=(const char *) attributes[i++];
2362 attribute=InterpretImageProperties(msl_info->image_info[n],
2363 msl_info->attributes[n],(const char *) attributes[i]);
2364 CloneString(&value,attribute);
2370 if (LocaleCompare(keyword,"affine") == 0)
2376 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2379 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2382 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2385 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2388 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2391 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2394 if (LocaleCompare(keyword,"align") == 0)
2396 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2399 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2401 draw_info->align=(AlignType) option;
2404 if (LocaleCompare(keyword,"antialias") == 0)
2406 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2409 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2411 draw_info->stroke_antialias=(MagickBooleanType) option;
2412 draw_info->text_antialias=(MagickBooleanType) option;
2415 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2422 if (LocaleCompare(keyword,"density") == 0)
2424 CloneString(&draw_info->density,value);
2427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2434 if (LocaleCompare(keyword,"encoding") == 0)
2436 CloneString(&draw_info->encoding,value);
2439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2446 if (LocaleCompare(keyword, "fill") == 0)
2448 (void) QueryColorDatabase(value,&draw_info->fill,
2452 if (LocaleCompare(keyword,"family") == 0)
2454 CloneString(&draw_info->family,value);
2457 if (LocaleCompare(keyword,"font") == 0)
2459 CloneString(&draw_info->font,value);
2462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2469 if (LocaleCompare(keyword,"geometry") == 0)
2471 flags=ParsePageGeometry(msl_info->image[n],value,
2472 &geometry,&exception);
2473 if ((flags & HeightValue) == 0)
2474 geometry.height=geometry.width;
2477 if (LocaleCompare(keyword,"gravity") == 0)
2479 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2482 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2484 draw_info->gravity=(GravityType) option;
2487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2494 if (LocaleCompare(keyword,"primitive") == 0)
2496 CloneString(&draw_info->primitive,value);
2499 if (LocaleCompare(keyword,"pointsize") == 0)
2501 draw_info->pointsize=InterpretLocaleValue(value,
2505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2512 if (LocaleCompare(keyword,"rotate") == 0)
2514 angle=InterpretLocaleValue(value,(char **) NULL);
2515 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2516 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2517 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2518 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2521 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2528 if (LocaleCompare(keyword,"scale") == 0)
2530 flags=ParseGeometry(value,&geometry_info);
2531 if ((flags & SigmaValue) == 0)
2532 geometry_info.sigma=1.0;
2533 affine.sx=geometry_info.rho;
2534 affine.sy=geometry_info.sigma;
2537 if (LocaleCompare(keyword,"skewX") == 0)
2539 angle=InterpretLocaleValue(value,(char **) NULL);
2540 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2543 if (LocaleCompare(keyword,"skewY") == 0)
2545 angle=InterpretLocaleValue(value,(char **) NULL);
2546 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2549 if (LocaleCompare(keyword,"stretch") == 0)
2551 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2554 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2556 draw_info->stretch=(StretchType) option;
2559 if (LocaleCompare(keyword, "stroke") == 0)
2561 (void) QueryColorDatabase(value,&draw_info->stroke,
2565 if (LocaleCompare(keyword,"strokewidth") == 0)
2567 draw_info->stroke_width=StringToLong(value);
2570 if (LocaleCompare(keyword,"style") == 0)
2572 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2575 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2577 draw_info->style=(StyleType) option;
2580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2587 if (LocaleCompare(keyword,"text") == 0)
2589 CloneString(&draw_info->text,value);
2592 if (LocaleCompare(keyword,"translate") == 0)
2594 flags=ParseGeometry(value,&geometry_info);
2595 if ((flags & SigmaValue) == 0)
2596 geometry_info.sigma=1.0;
2597 affine.tx=geometry_info.rho;
2598 affine.ty=geometry_info.sigma;
2601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2608 if (LocaleCompare(keyword, "undercolor") == 0)
2610 (void) QueryColorDatabase(value,&draw_info->undercolor,
2614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2621 if (LocaleCompare(keyword,"weight") == 0)
2623 draw_info->weight=StringToLong(value);
2626 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2633 if (LocaleCompare(keyword,"x") == 0)
2635 geometry.x=StringToLong(value);
2638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2645 if (LocaleCompare(keyword,"y") == 0)
2647 geometry.y=StringToLong(value);
2650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2662 (void) FormatLocaleString(text,MaxTextExtent,
2663 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2664 geometry.height,(double) geometry.x,(double) geometry.y);
2665 CloneString(&draw_info->geometry,text);
2666 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2667 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2668 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2669 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2670 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2672 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2674 (void) DrawImage(msl_info->image[n],draw_info);
2675 draw_info=DestroyDrawInfo(draw_info);
2678 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2683 if (LocaleCompare((const char *) tag,"edge") == 0)
2691 if (msl_info->image[n] == (Image *) NULL)
2693 ThrowMSLException(OptionError,"NoImagesDefined",
2694 (const char *) tag);
2697 if (attributes != (const xmlChar **) NULL)
2698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2700 keyword=(const char *) attributes[i++];
2701 attribute=InterpretImageProperties(msl_info->image_info[n],
2702 msl_info->attributes[n],(const char *) attributes[i]);
2703 CloneString(&value,attribute);
2709 if (LocaleCompare(keyword,"geometry") == 0)
2711 flags=ParseGeometry(value,&geometry_info);
2712 if ((flags & SigmaValue) == 0)
2713 geometry_info.sigma=1.0;
2716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2723 if (LocaleCompare(keyword,"radius") == 0)
2725 geometry_info.rho=InterpretLocaleValue(value,
2729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2741 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2742 &msl_info->image[n]->exception);
2743 if (edge_image == (Image *) NULL)
2745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2746 msl_info->image[n]=edge_image;
2749 if (LocaleCompare((const char *) tag,"emboss") == 0)
2757 if (msl_info->image[n] == (Image *) NULL)
2759 ThrowMSLException(OptionError,"NoImagesDefined",
2760 (const char *) tag);
2763 if (attributes != (const xmlChar **) NULL)
2764 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2766 keyword=(const char *) attributes[i++];
2767 attribute=InterpretImageProperties(msl_info->image_info[n],
2768 msl_info->attributes[n],(const char *) attributes[i]);
2769 CloneString(&value,attribute);
2775 if (LocaleCompare(keyword,"geometry") == 0)
2777 flags=ParseGeometry(value,&geometry_info);
2778 if ((flags & SigmaValue) == 0)
2779 geometry_info.sigma=1.0;
2782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2789 if (LocaleCompare(keyword,"radius") == 0)
2791 geometry_info.rho=InterpretLocaleValue(value,
2795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2802 if (LocaleCompare(keyword,"sigma") == 0)
2804 geometry_info.sigma=StringToLong(value);
2807 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2819 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2820 geometry_info.sigma,&msl_info->image[n]->exception);
2821 if (emboss_image == (Image *) NULL)
2823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2824 msl_info->image[n]=emboss_image;
2827 if (LocaleCompare((const char *) tag,"enhance") == 0)
2835 if (msl_info->image[n] == (Image *) NULL)
2837 ThrowMSLException(OptionError,"NoImagesDefined",
2838 (const char *) tag);
2841 if (attributes != (const xmlChar **) NULL)
2842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2844 keyword=(const char *) attributes[i++];
2845 attribute=InterpretImageProperties(msl_info->image_info[n],
2846 msl_info->attributes[n],(const char *) attributes[i]);
2847 CloneString(&value,attribute);
2848 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2850 enhance_image=EnhanceImage(msl_info->image[n],
2851 &msl_info->image[n]->exception);
2852 if (enhance_image == (Image *) NULL)
2854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2855 msl_info->image[n]=enhance_image;
2858 if (LocaleCompare((const char *) tag,"equalize") == 0)
2863 if (msl_info->image[n] == (Image *) NULL)
2865 ThrowMSLException(OptionError,"NoImagesDefined",
2866 (const char *) tag);
2869 if (attributes != (const xmlChar **) NULL)
2870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2872 keyword=(const char *) attributes[i++];
2873 attribute=InterpretImageProperties(msl_info->image_info[n],
2874 msl_info->attributes[n],(const char *) attributes[i]);
2875 CloneString(&value,attribute);
2880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2886 (void) EqualizeImage(msl_info->image[n]);
2889 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2894 if (LocaleCompare((const char *) tag, "flatten") == 0)
2896 if (msl_info->image[n] == (Image *) NULL)
2898 ThrowMSLException(OptionError,"NoImagesDefined",
2899 (const char *) tag);
2903 /* no attributes here */
2905 /* process the image */
2910 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2911 &msl_info->image[n]->exception);
2912 if (newImage == (Image *) NULL)
2914 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2915 msl_info->image[n]=newImage;
2919 if (LocaleCompare((const char *) tag,"flip") == 0)
2927 if (msl_info->image[n] == (Image *) NULL)
2929 ThrowMSLException(OptionError,"NoImagesDefined",
2930 (const char *) tag);
2933 if (attributes != (const xmlChar **) NULL)
2934 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2936 keyword=(const char *) attributes[i++];
2937 attribute=InterpretImageProperties(msl_info->image_info[n],
2938 msl_info->attributes[n],(const char *) attributes[i]);
2939 CloneString(&value,attribute);
2940 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2942 flip_image=FlipImage(msl_info->image[n],
2943 &msl_info->image[n]->exception);
2944 if (flip_image == (Image *) NULL)
2946 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2947 msl_info->image[n]=flip_image;
2950 if (LocaleCompare((const char *) tag,"flop") == 0)
2958 if (msl_info->image[n] == (Image *) NULL)
2960 ThrowMSLException(OptionError,"NoImagesDefined",
2961 (const char *) tag);
2964 if (attributes != (const xmlChar **) NULL)
2965 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2967 keyword=(const char *) attributes[i++];
2968 attribute=InterpretImageProperties(msl_info->image_info[n],
2969 msl_info->attributes[n],(const char *) attributes[i]);
2970 CloneString(&value,attribute);
2971 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2973 flop_image=FlopImage(msl_info->image[n],
2974 &msl_info->image[n]->exception);
2975 if (flop_image == (Image *) NULL)
2977 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2978 msl_info->image[n]=flop_image;
2981 if (LocaleCompare((const char *) tag,"frame") == 0)
2992 if (msl_info->image[n] == (Image *) NULL)
2994 ThrowMSLException(OptionError,"NoImagesDefined",
2995 (const char *) tag);
2998 SetGeometry(msl_info->image[n],&geometry);
2999 if (attributes != (const xmlChar **) NULL)
3000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3002 keyword=(const char *) attributes[i++];
3003 attribute=InterpretImageProperties(msl_info->image_info[n],
3004 msl_info->attributes[n],(const char *) attributes[i]);
3005 CloneString(&value,attribute);
3011 if (LocaleCompare(keyword,"compose") == 0)
3013 option=ParseCommandOption(MagickComposeOptions,
3016 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3018 msl_info->image[n]->compose=(CompositeOperator) option;
3021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3028 if (LocaleCompare(keyword, "fill") == 0)
3030 (void) QueryColorDatabase(value,
3031 &msl_info->image[n]->matte_color,&exception);
3034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3041 if (LocaleCompare(keyword,"geometry") == 0)
3043 flags=ParsePageGeometry(msl_info->image[n],value,
3044 &geometry,&exception);
3045 if ((flags & HeightValue) == 0)
3046 geometry.height=geometry.width;
3047 frame_info.width=geometry.width;
3048 frame_info.height=geometry.height;
3049 frame_info.outer_bevel=geometry.x;
3050 frame_info.inner_bevel=geometry.y;
3053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3060 if (LocaleCompare(keyword,"height") == 0)
3062 frame_info.height=StringToLong(value);
3065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3072 if (LocaleCompare(keyword,"inner") == 0)
3074 frame_info.inner_bevel=StringToLong(value);
3077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3084 if (LocaleCompare(keyword,"outer") == 0)
3086 frame_info.outer_bevel=StringToLong(value);
3089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3096 if (LocaleCompare(keyword,"width") == 0)
3098 frame_info.width=StringToLong(value);
3101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3113 frame_info.x=(ssize_t) frame_info.width;
3114 frame_info.y=(ssize_t) frame_info.height;
3115 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3116 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3117 frame_image=FrameImage(msl_info->image[n],&frame_info,
3118 &msl_info->image[n]->exception);
3119 if (frame_image == (Image *) NULL)
3121 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3122 msl_info->image[n]=frame_image;
3125 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3130 if (LocaleCompare((const char *) tag,"gamma") == 0)
3133 gamma[MaxTextExtent];
3141 if (msl_info->image[n] == (Image *) NULL)
3143 ThrowMSLException(OptionError,"NoImagesDefined",
3144 (const char *) tag);
3147 channel=UndefinedChannel;
3152 if (attributes != (const xmlChar **) NULL)
3153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3155 keyword=(const char *) attributes[i++];
3156 attribute=InterpretImageProperties(msl_info->image_info[n],
3157 msl_info->attributes[n],(const char *) attributes[i]);
3158 CloneString(&value,attribute);
3164 if (LocaleCompare(keyword,"blue") == 0)
3166 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3169 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3176 if (LocaleCompare(keyword,"channel") == 0)
3178 option=ParseChannelOption(value);
3180 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3182 channel=(ChannelType) option;
3185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3192 if (LocaleCompare(keyword,"gamma") == 0)
3194 (void) CopyMagickString(gamma,value,MaxTextExtent);
3197 if (LocaleCompare(keyword,"green") == 0)
3199 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3209 if (LocaleCompare(keyword,"red") == 0)
3211 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3227 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3228 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3233 (void) GammaImage(msl_info->image[n],gamma);
3238 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3243 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3249 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3256 else if (LocaleCompare((const char *) tag,"get") == 0)
3258 if (msl_info->image[n] == (Image *) NULL)
3260 ThrowMSLException(OptionError,"NoImagesDefined",
3261 (const char *) tag);
3264 if (attributes == (const xmlChar **) NULL)
3266 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3268 keyword=(const char *) attributes[i++];
3269 CloneString(&value,(const char *) attributes[i]);
3270 (void) CopyMagickString(key,value,MaxTextExtent);
3276 if (LocaleCompare(keyword,"height") == 0)
3278 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3279 (double) msl_info->image[n]->rows);
3280 (void) SetImageProperty(msl_info->attributes[n],key,value);
3283 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3288 if (LocaleCompare(keyword,"width") == 0)
3290 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3291 (double) msl_info->image[n]->columns);
3292 (void) SetImageProperty(msl_info->attributes[n],key,value);
3295 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3299 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3306 else if (LocaleCompare((const char *) tag, "group") == 0)
3308 msl_info->number_groups++;
3309 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3310 msl_info->group_info,msl_info->number_groups+1UL,
3311 sizeof(*msl_info->group_info));
3314 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3319 if (LocaleCompare((const char *) tag,"image") == 0)
3321 MSLPushImage(msl_info,(Image *) NULL);
3322 if (attributes == (const xmlChar **) NULL)
3324 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3326 keyword=(const char *) attributes[i++];
3327 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3328 msl_info->attributes[n],(const char *) attributes[i]));
3334 if (LocaleCompare(keyword,"color") == 0)
3339 (void) CopyMagickString(msl_info->image_info[n]->filename,
3340 "xc:",MaxTextExtent);
3341 (void) ConcatenateMagickString(msl_info->image_info[n]->
3342 filename,value,MaxTextExtent);
3343 next_image=ReadImage(msl_info->image_info[n],&exception);
3344 CatchException(&exception);
3345 if (next_image == (Image *) NULL)
3347 if (msl_info->image[n] == (Image *) NULL)
3348 msl_info->image[n]=next_image;
3355 Link image into image list.
3357 p=msl_info->image[n];
3358 while (p->next != (Image *) NULL)
3359 p=GetNextImageInList(p);
3360 next_image->previous=p;
3365 (void) SetMSLAttributes(msl_info,keyword,value);
3370 (void) SetMSLAttributes(msl_info,keyword,value);
3377 if (LocaleCompare((const char *) tag,"implode") == 0)
3385 if (msl_info->image[n] == (Image *) NULL)
3387 ThrowMSLException(OptionError,"NoImagesDefined",
3388 (const char *) tag);
3391 if (attributes != (const xmlChar **) NULL)
3392 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3394 keyword=(const char *) attributes[i++];
3395 attribute=InterpretImageProperties(msl_info->image_info[n],
3396 msl_info->attributes[n],(const char *) attributes[i]);
3397 CloneString(&value,attribute);
3403 if (LocaleCompare(keyword,"amount") == 0)
3405 geometry_info.rho=InterpretLocaleValue(value,
3409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3416 if (LocaleCompare(keyword,"geometry") == 0)
3418 flags=ParseGeometry(value,&geometry_info);
3419 if ((flags & SigmaValue) == 0)
3420 geometry_info.sigma=1.0;
3423 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3429 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3435 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3436 &msl_info->image[n]->exception);
3437 if (implode_image == (Image *) NULL)
3439 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3440 msl_info->image[n]=implode_image;
3443 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3448 if (LocaleCompare((const char *) tag,"label") == 0)
3450 if (LocaleCompare((const char *) tag, "level") == 0)
3453 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3455 if (msl_info->image[n] == (Image *) NULL)
3457 ThrowMSLException(OptionError,"NoImagesDefined",
3458 (const char *) tag);
3461 if (attributes == (const xmlChar **) NULL)
3463 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3465 keyword=(const char *) attributes[i++];
3466 CloneString(&value,(const char *) attributes[i]);
3467 (void) CopyMagickString(key,value,MaxTextExtent);
3473 if (LocaleCompare(keyword,"black") == 0)
3475 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3484 if (LocaleCompare(keyword,"gamma") == 0)
3486 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3495 if (LocaleCompare(keyword,"white") == 0)
3497 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3500 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3505 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3512 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma);
3519 if (LocaleCompare((const char *) tag,"magnify") == 0)
3527 if (msl_info->image[n] == (Image *) NULL)
3529 ThrowMSLException(OptionError,"NoImagesDefined",
3530 (const char *) tag);
3533 if (attributes != (const xmlChar **) NULL)
3534 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3536 keyword=(const char *) attributes[i++];
3537 attribute=InterpretImageProperties(msl_info->image_info[n],
3538 msl_info->attributes[n],(const char *) attributes[i]);
3539 CloneString(&value,attribute);
3540 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3542 magnify_image=MagnifyImage(msl_info->image[n],
3543 &msl_info->image[n]->exception);
3544 if (magnify_image == (Image *) NULL)
3546 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3547 msl_info->image[n]=magnify_image;
3550 if (LocaleCompare((const char *) tag,"map") == 0)
3564 if (msl_info->image[n] == (Image *) NULL)
3566 ThrowMSLException(OptionError,"NoImagesDefined",
3567 (const char *) tag);
3570 affinity_image=NewImageList();
3572 if (attributes != (const xmlChar **) NULL)
3573 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3575 keyword=(const char *) attributes[i++];
3576 attribute=InterpretImageProperties(msl_info->image_info[n],
3577 msl_info->attributes[n],(const char *) attributes[i]);
3578 CloneString(&value,attribute);
3584 if (LocaleCompare(keyword,"dither") == 0)
3586 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3589 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3591 dither=(MagickBooleanType) option;
3594 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3601 if (LocaleCompare(keyword,"image") == 0)
3602 for (j=0; j < msl_info->n; j++)
3607 attribute=GetImageProperty(msl_info->attributes[j],"id");
3608 if ((attribute != (const char *) NULL) &&
3609 (LocaleCompare(attribute,value) == 0))
3611 affinity_image=CloneImage(msl_info->image[j],0,0,
3612 MagickFalse,&exception);
3620 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3626 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3627 quantize_info->dither=dither;
3628 (void) RemapImages(quantize_info,msl_info->image[n],
3630 quantize_info=DestroyQuantizeInfo(quantize_info);
3631 affinity_image=DestroyImage(affinity_image);
3634 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3646 Matte floodfill image.
3649 if (msl_info->image[n] == (Image *) NULL)
3651 ThrowMSLException(OptionError,"NoImagesDefined",
3652 (const char *) tag);
3655 SetGeometry(msl_info->image[n],&geometry);
3656 paint_method=FloodfillMethod;
3657 if (attributes != (const xmlChar **) NULL)
3658 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3660 keyword=(const char *) attributes[i++];
3661 attribute=InterpretImageProperties(msl_info->image_info[n],
3662 msl_info->attributes[n],(const char *) attributes[i]);
3663 CloneString(&value,attribute);
3669 if (LocaleCompare(keyword,"bordercolor") == 0)
3671 (void) QueryMagickColor(value,&target,&exception);
3672 paint_method=FillToBorderMethod;
3675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3682 if (LocaleCompare(keyword,"fuzz") == 0)
3684 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3688 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3695 if (LocaleCompare(keyword,"geometry") == 0)
3697 flags=ParsePageGeometry(msl_info->image[n],value,
3698 &geometry,&exception);
3699 if ((flags & HeightValue) == 0)
3700 geometry.height=geometry.width;
3701 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3702 geometry.x,geometry.y,&target,&exception);
3705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3712 if (LocaleCompare(keyword,"opacity") == 0)
3714 opacity=InterpretLocaleValue(value,(char **) NULL);
3717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3724 if (LocaleCompare(keyword,"x") == 0)
3726 geometry.x=StringToLong(value);
3727 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3728 geometry.x,geometry.y,&target,&exception);
3731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3738 if (LocaleCompare(keyword,"y") == 0)
3740 geometry.y=StringToLong(value);
3741 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3742 geometry.x,geometry.y,&target,&exception);
3745 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3757 draw_info=CloneDrawInfo(msl_info->image_info[n],
3758 msl_info->draw_info[n]);
3759 draw_info->fill.alpha=ClampToQuantum(opacity);
3760 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3761 draw_info,&target,geometry.x,geometry.y,
3762 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3763 draw_info=DestroyDrawInfo(draw_info);
3766 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3772 Median-filter image.
3774 if (msl_info->image[n] == (Image *) NULL)
3776 ThrowMSLException(OptionError,"NoImagesDefined",
3777 (const char *) tag);
3780 if (attributes != (const xmlChar **) NULL)
3781 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3783 keyword=(const char *) attributes[i++];
3784 attribute=InterpretImageProperties(msl_info->image_info[n],
3785 msl_info->attributes[n],(const char *) attributes[i]);
3786 CloneString(&value,attribute);
3792 if (LocaleCompare(keyword,"geometry") == 0)
3794 flags=ParseGeometry(value,&geometry_info);
3795 if ((flags & SigmaValue) == 0)
3796 geometry_info.sigma=1.0;
3799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3806 if (LocaleCompare(keyword,"radius") == 0)
3808 geometry_info.rho=InterpretLocaleValue(value,
3812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3818 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3824 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3825 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3826 &msl_info->image[n]->exception);
3827 if (median_image == (Image *) NULL)
3829 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3830 msl_info->image[n]=median_image;
3833 if (LocaleCompare((const char *) tag,"minify") == 0)
3841 if (msl_info->image[n] == (Image *) NULL)
3843 ThrowMSLException(OptionError,"NoImagesDefined",
3844 (const char *) tag);
3847 if (attributes != (const xmlChar **) NULL)
3848 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3850 keyword=(const char *) attributes[i++];
3851 attribute=InterpretImageProperties(msl_info->image_info[n],
3852 msl_info->attributes[n],(const char *) attributes[i]);
3853 CloneString(&value,attribute);
3854 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3856 minify_image=MinifyImage(msl_info->image[n],
3857 &msl_info->image[n]->exception);
3858 if (minify_image == (Image *) NULL)
3860 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3861 msl_info->image[n]=minify_image;
3864 if (LocaleCompare((const char *) tag,"msl") == 0 )
3866 if (LocaleCompare((const char *) tag,"modulate") == 0)
3869 modulate[MaxTextExtent];
3874 if (msl_info->image[n] == (Image *) NULL)
3876 ThrowMSLException(OptionError,"NoImagesDefined",
3877 (const char *) tag);
3880 geometry_info.rho=100.0;
3881 geometry_info.sigma=100.0;
3882 geometry_info.xi=100.0;
3883 if (attributes != (const xmlChar **) NULL)
3884 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3886 keyword=(const char *) attributes[i++];
3887 attribute=InterpretImageProperties(msl_info->image_info[n],
3888 msl_info->attributes[n],(const char *) attributes[i]);
3889 CloneString(&value,attribute);
3895 if (LocaleCompare(keyword,"blackness") == 0)
3897 geometry_info.rho=InterpretLocaleValue(value,
3901 if (LocaleCompare(keyword,"brightness") == 0)
3903 geometry_info.rho=InterpretLocaleValue(value,
3907 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3914 if (LocaleCompare(keyword,"factor") == 0)
3916 flags=ParseGeometry(value,&geometry_info);
3919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3926 if (LocaleCompare(keyword,"hue") == 0)
3928 geometry_info.xi=InterpretLocaleValue(value,
3932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3939 if (LocaleCompare(keyword,"lightness") == 0)
3941 geometry_info.rho=InterpretLocaleValue(value,
3945 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3952 if (LocaleCompare(keyword,"saturation") == 0)
3954 geometry_info.sigma=InterpretLocaleValue(value,
3958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 if (LocaleCompare(keyword,"whiteness") == 0)
3967 geometry_info.sigma=InterpretLocaleValue(value,
3971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3983 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3984 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3985 (void) ModulateImage(msl_info->image[n],modulate);
3988 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3993 if (LocaleCompare((const char *) tag,"negate") == 0)
4001 if (msl_info->image[n] == (Image *) NULL)
4003 ThrowMSLException(OptionError,"NoImagesDefined",
4004 (const char *) tag);
4008 if (attributes != (const xmlChar **) NULL)
4009 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4011 keyword=(const char *) attributes[i++];
4012 attribute=InterpretImageProperties(msl_info->image_info[n],
4013 msl_info->attributes[n],(const char *) attributes[i]);
4014 CloneString(&value,attribute);
4020 if (LocaleCompare(keyword,"channel") == 0)
4022 option=ParseChannelOption(value);
4024 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4026 channel=(ChannelType) option;
4029 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4036 if (LocaleCompare(keyword,"gray") == 0)
4038 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4041 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4043 gray=(MagickBooleanType) option;
4046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4058 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4061 if (LocaleCompare((const char *) tag,"normalize") == 0)
4066 if (msl_info->image[n] == (Image *) NULL)
4068 ThrowMSLException(OptionError,"NoImagesDefined",
4069 (const char *) tag);
4072 if (attributes != (const xmlChar **) NULL)
4073 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4075 keyword=(const char *) attributes[i++];
4076 attribute=InterpretImageProperties(msl_info->image_info[n],
4077 msl_info->attributes[n],(const char *) attributes[i]);
4078 CloneString(&value,attribute);
4084 if (LocaleCompare(keyword,"channel") == 0)
4086 option=ParseChannelOption(value);
4088 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4090 channel=(ChannelType) option;
4093 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4105 (void) NormalizeImageChannel(msl_info->image[n],channel);
4108 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4113 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4121 if (msl_info->image[n] == (Image *) NULL)
4123 ThrowMSLException(OptionError,"NoImagesDefined",
4124 (const char *) tag);
4127 if (attributes != (const xmlChar **) NULL)
4128 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4130 keyword=(const char *) attributes[i++];
4131 attribute=InterpretImageProperties(msl_info->image_info[n],
4132 msl_info->attributes[n],(const char *) attributes[i]);
4133 CloneString(&value,attribute);
4139 if (LocaleCompare(keyword,"geometry") == 0)
4141 flags=ParseGeometry(value,&geometry_info);
4142 if ((flags & SigmaValue) == 0)
4143 geometry_info.sigma=1.0;
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4153 if (LocaleCompare(keyword,"radius") == 0)
4155 geometry_info.rho=InterpretLocaleValue(value,
4159 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4165 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4171 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4172 &msl_info->image[n]->exception);
4173 if (paint_image == (Image *) NULL)
4175 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4176 msl_info->image[n]=paint_image;
4179 if (LocaleCompare((const char *) tag,"opaque") == 0)
4188 if (msl_info->image[n] == (Image *) NULL)
4190 ThrowMSLException(OptionError,"NoImagesDefined",
4191 (const char *) tag);
4194 (void) QueryMagickColor("none",&target,&exception);
4195 (void) QueryMagickColor("none",&fill_color,&exception);
4196 if (attributes != (const xmlChar **) NULL)
4197 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4199 keyword=(const char *) attributes[i++];
4200 attribute=InterpretImageProperties(msl_info->image_info[n],
4201 msl_info->attributes[n],(const char *) attributes[i]);
4202 CloneString(&value,attribute);
4208 if (LocaleCompare(keyword,"channel") == 0)
4210 option=ParseChannelOption(value);
4212 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4214 channel=(ChannelType) option;
4217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4224 if (LocaleCompare(keyword,"fill") == 0)
4226 (void) QueryMagickColor(value,&fill_color,&exception);
4229 if (LocaleCompare(keyword,"fuzz") == 0)
4231 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4235 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4241 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4247 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4248 &target,&fill_color,MagickFalse);
4251 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4256 if (LocaleCompare((const char *) tag,"print") == 0)
4258 if (attributes == (const xmlChar **) NULL)
4260 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4262 keyword=(const char *) attributes[i++];
4263 attribute=InterpretImageProperties(msl_info->image_info[n],
4264 msl_info->attributes[n],(const char *) attributes[i]);
4265 CloneString(&value,attribute);
4271 if (LocaleCompare(keyword,"output") == 0)
4273 (void) FormatLocaleFile(stdout,"%s",value);
4276 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4281 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4288 if (LocaleCompare((const char *) tag, "profile") == 0)
4290 if (msl_info->image[n] == (Image *) NULL)
4292 ThrowMSLException(OptionError,"NoImagesDefined",
4293 (const char *) tag);
4296 if (attributes == (const xmlChar **) NULL)
4298 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4312 keyword=(const char *) attributes[i++];
4313 attribute=InterpretImageProperties(msl_info->image_info[n],
4314 msl_info->attributes[n],(const char *) attributes[i]);
4315 CloneString(&value,attribute);
4316 if (*keyword == '+')
4319 Remove a profile from the image.
4321 (void) ProfileImage(msl_info->image[n],keyword,
4322 (const unsigned char *) NULL,0,MagickTrue);
4326 Associate a profile with the image.
4328 profile_info=CloneImageInfo(msl_info->image_info[n]);
4329 profile=GetImageProfile(msl_info->image[n],"iptc");
4330 if (profile != (StringInfo *) NULL)
4331 profile_info->profile=(void *) CloneStringInfo(profile);
4332 profile_image=GetImageCache(profile_info,keyword,&exception);
4333 profile_info=DestroyImageInfo(profile_info);
4334 if (profile_image == (Image *) NULL)
4337 name[MaxTextExtent],
4338 filename[MaxTextExtent];
4346 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4347 (void) CopyMagickString(name,keyword,MaxTextExtent);
4348 for (p=filename; *p != '\0'; p++)
4349 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4350 (IsPathAccessible(keyword) == MagickFalse))
4356 Look for profile name (e.g. name:profile).
4358 (void) CopyMagickString(name,filename,(size_t)
4360 for (q=filename; *q != '\0'; q++)
4364 profile=FileToStringInfo(filename,~0UL,&exception);
4365 if (profile != (StringInfo *) NULL)
4367 (void) ProfileImage(msl_info->image[n],name,
4368 GetStringInfoDatum(profile),(size_t)
4369 GetStringInfoLength(profile),MagickFalse);
4370 profile=DestroyStringInfo(profile);
4374 ResetImageProfileIterator(profile_image);
4375 name=GetNextImageProfile(profile_image);
4376 while (name != (const char *) NULL)
4378 profile=GetImageProfile(profile_image,name);
4379 if (profile != (StringInfo *) NULL)
4380 (void) ProfileImage(msl_info->image[n],name,
4381 GetStringInfoDatum(profile),(size_t)
4382 GetStringInfoLength(profile),MagickFalse);
4383 name=GetNextImageProfile(profile_image);
4385 profile_image=DestroyImage(profile_image);
4389 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4394 if (LocaleCompare((const char *) tag,"quantize") == 0)
4402 if (msl_info->image[n] == (Image *) NULL)
4404 ThrowMSLException(OptionError,"NoImagesDefined",
4405 (const char *) tag);
4408 GetQuantizeInfo(&quantize_info);
4409 if (attributes != (const xmlChar **) NULL)
4410 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4412 keyword=(const char *) attributes[i++];
4413 attribute=InterpretImageProperties(msl_info->image_info[n],
4414 msl_info->attributes[n],(const char *) attributes[i]);
4415 CloneString(&value,attribute);
4421 if (LocaleCompare(keyword,"colors") == 0)
4423 quantize_info.number_colors=StringToLong(value);
4426 if (LocaleCompare(keyword,"colorspace") == 0)
4428 option=ParseCommandOption(MagickColorspaceOptions,
4431 ThrowMSLException(OptionError,
4432 "UnrecognizedColorspaceType",value);
4433 quantize_info.colorspace=(ColorspaceType) option;
4436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4443 if (LocaleCompare(keyword,"dither") == 0)
4445 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4448 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4450 quantize_info.dither=(MagickBooleanType) option;
4453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4460 if (LocaleCompare(keyword,"measure") == 0)
4462 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4465 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4467 quantize_info.measure_error=(MagickBooleanType) option;
4470 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4477 if (LocaleCompare(keyword,"treedepth") == 0)
4479 quantize_info.tree_depth=StringToLong(value);
4482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4488 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4494 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4497 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4500 text[MaxTextExtent];
4511 draw_info=CloneDrawInfo(msl_info->image_info[n],
4512 msl_info->draw_info[n]);
4514 current=draw_info->affine;
4515 GetAffineMatrix(&affine);
4516 if (attributes != (const xmlChar **) NULL)
4517 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4519 keyword=(const char *) attributes[i++];
4520 attribute=InterpretImageProperties(msl_info->image_info[n],
4521 msl_info->attributes[n],(const char *) attributes[i]);
4522 CloneString(&value,attribute);
4528 if (LocaleCompare(keyword,"affine") == 0)
4534 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4537 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4540 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4543 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4546 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4549 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4552 if (LocaleCompare(keyword,"align") == 0)
4554 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4557 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4559 draw_info->align=(AlignType) option;
4562 if (LocaleCompare(keyword,"antialias") == 0)
4564 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4567 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4569 draw_info->stroke_antialias=(MagickBooleanType) option;
4570 draw_info->text_antialias=(MagickBooleanType) option;
4573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4580 if (LocaleCompare(keyword,"density") == 0)
4582 CloneString(&draw_info->density,value);
4585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4592 if (LocaleCompare(keyword,"encoding") == 0)
4594 CloneString(&draw_info->encoding,value);
4597 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4604 if (LocaleCompare(keyword, "fill") == 0)
4606 (void) QueryColorDatabase(value,&draw_info->fill,
4610 if (LocaleCompare(keyword,"family") == 0)
4612 CloneString(&draw_info->family,value);
4615 if (LocaleCompare(keyword,"font") == 0)
4617 CloneString(&draw_info->font,value);
4620 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4627 if (LocaleCompare(keyword,"geometry") == 0)
4629 flags=ParsePageGeometry(msl_info->image[n],value,
4630 &geometry,&exception);
4631 if ((flags & HeightValue) == 0)
4632 geometry.height=geometry.width;
4635 if (LocaleCompare(keyword,"gravity") == 0)
4637 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4640 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4642 draw_info->gravity=(GravityType) option;
4645 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4652 if (LocaleCompare(keyword,"pointsize") == 0)
4654 draw_info->pointsize=InterpretLocaleValue(value,
4658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4665 if (LocaleCompare(keyword,"rotate") == 0)
4667 angle=InterpretLocaleValue(value,(char **) NULL);
4668 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4669 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4670 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4671 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4674 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4681 if (LocaleCompare(keyword,"scale") == 0)
4683 flags=ParseGeometry(value,&geometry_info);
4684 if ((flags & SigmaValue) == 0)
4685 geometry_info.sigma=1.0;
4686 affine.sx=geometry_info.rho;
4687 affine.sy=geometry_info.sigma;
4690 if (LocaleCompare(keyword,"skewX") == 0)
4692 angle=InterpretLocaleValue(value,(char **) NULL);
4693 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4696 if (LocaleCompare(keyword,"skewY") == 0)
4698 angle=InterpretLocaleValue(value,(char **) NULL);
4699 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4702 if (LocaleCompare(keyword,"stretch") == 0)
4704 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4707 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4709 draw_info->stretch=(StretchType) option;
4712 if (LocaleCompare(keyword, "stroke") == 0)
4714 (void) QueryColorDatabase(value,&draw_info->stroke,
4718 if (LocaleCompare(keyword,"strokewidth") == 0)
4720 draw_info->stroke_width=StringToLong(value);
4723 if (LocaleCompare(keyword,"style") == 0)
4725 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4728 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4730 draw_info->style=(StyleType) option;
4733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4740 if (LocaleCompare(keyword,"text") == 0)
4742 CloneString(&draw_info->text,value);
4745 if (LocaleCompare(keyword,"translate") == 0)
4747 flags=ParseGeometry(value,&geometry_info);
4748 if ((flags & SigmaValue) == 0)
4749 geometry_info.sigma=1.0;
4750 affine.tx=geometry_info.rho;
4751 affine.ty=geometry_info.sigma;
4754 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4761 if (LocaleCompare(keyword, "undercolor") == 0)
4763 (void) QueryColorDatabase(value,&draw_info->undercolor,
4767 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4774 if (LocaleCompare(keyword,"weight") == 0)
4776 draw_info->weight=StringToLong(value);
4779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4786 if (LocaleCompare(keyword,"x") == 0)
4788 geometry.x=StringToLong(value);
4791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4798 if (LocaleCompare(keyword,"y") == 0)
4800 geometry.y=StringToLong(value);
4803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4815 (void) FormatLocaleString(text,MaxTextExtent,
4816 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4817 geometry.height,(double) geometry.x,(double) geometry.y);
4818 CloneString(&draw_info->geometry,text);
4819 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4820 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4821 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4822 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4823 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4825 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4827 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4828 if (status != MagickFalse)
4833 image=msl_info->attributes[n];
4834 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4835 "%g",metrics.pixels_per_em.x);
4836 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4837 "%g",metrics.pixels_per_em.y);
4838 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4840 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4842 FormatImageProperty(image,"msl:font-metrics.width","%g",
4844 FormatImageProperty(image,"msl:font-metrics.height","%g",
4846 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4847 metrics.max_advance);
4848 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4850 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4852 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4854 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4856 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4858 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4861 draw_info=DestroyDrawInfo(draw_info);
4864 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4869 if (LocaleCompare((const char *) tag,"raise") == 0)
4877 if (msl_info->image[n] == (Image *) NULL)
4879 ThrowMSLException(OptionError,"NoImagesDefined",
4880 (const char *) tag);
4884 SetGeometry(msl_info->image[n],&geometry);
4885 if (attributes != (const xmlChar **) NULL)
4886 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4888 keyword=(const char *) attributes[i++];
4889 attribute=InterpretImageProperties(msl_info->image_info[n],
4890 msl_info->attributes[n],(const char *) attributes[i]);
4891 CloneString(&value,attribute);
4897 if (LocaleCompare(keyword,"geometry") == 0)
4899 flags=ParsePageGeometry(msl_info->image[n],value,
4900 &geometry,&exception);
4901 if ((flags & HeightValue) == 0)
4902 geometry.height=geometry.width;
4905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4912 if (LocaleCompare(keyword,"height") == 0)
4914 geometry.height=StringToLong(value);
4917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4924 if (LocaleCompare(keyword,"raise") == 0)
4926 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4929 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4931 raise=(MagickBooleanType) option;
4934 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4941 if (LocaleCompare(keyword,"width") == 0)
4943 geometry.width=StringToLong(value);
4946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4952 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4958 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4961 if (LocaleCompare((const char *) tag,"read") == 0)
4963 if (attributes == (const xmlChar **) NULL)
4965 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4967 keyword=(const char *) attributes[i++];
4968 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4969 msl_info->attributes[n],(const char *) attributes[i]));
4975 if (LocaleCompare(keyword,"filename") == 0)
4980 (void) CopyMagickString(msl_info->image_info[n]->filename,
4981 value,MaxTextExtent);
4982 image=ReadImage(msl_info->image_info[n],&exception);
4983 CatchException(&exception);
4984 if (image == (Image *) NULL)
4986 AppendImageToList(&msl_info->image[n],image);
4989 (void) SetMSLAttributes(msl_info,keyword,value);
4994 (void) SetMSLAttributes(msl_info,keyword,value);
5001 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5009 if (msl_info->image[n] == (Image *) NULL)
5011 ThrowMSLException(OptionError,"NoImagesDefined",
5012 (const char *) tag);
5015 if (attributes != (const xmlChar **) NULL)
5016 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5018 keyword=(const char *) attributes[i++];
5019 attribute=InterpretImageProperties(msl_info->image_info[n],
5020 msl_info->attributes[n],(const char *) attributes[i]);
5021 CloneString(&value,attribute);
5027 if (LocaleCompare(keyword,"geometry") == 0)
5029 flags=ParseGeometry(value,&geometry_info);
5030 if ((flags & SigmaValue) == 0)
5031 geometry_info.sigma=1.0;
5034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5041 if (LocaleCompare(keyword,"radius") == 0)
5043 geometry_info.rho=InterpretLocaleValue(value,
5047 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5059 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5060 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5061 &msl_info->image[n]->exception);
5062 if (paint_image == (Image *) NULL)
5064 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5065 msl_info->image[n]=paint_image;
5068 else if (LocaleCompare((const char *) tag,"repage") == 0)
5070 /* init the values */
5071 width=msl_info->image[n]->page.width;
5072 height=msl_info->image[n]->page.height;
5073 x=msl_info->image[n]->page.x;
5074 y=msl_info->image[n]->page.y;
5076 if (msl_info->image[n] == (Image *) NULL)
5078 ThrowMSLException(OptionError,"NoImagesDefined",
5079 (const char *) tag);
5082 if (attributes == (const xmlChar **) NULL)
5084 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5086 keyword=(const char *) attributes[i++];
5087 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5088 msl_info->attributes[n],(const char *) attributes[i]));
5094 if (LocaleCompare(keyword,"geometry") == 0)
5102 flags=ParseAbsoluteGeometry(value,&geometry);
5103 if ((flags & WidthValue) != 0)
5105 if ((flags & HeightValue) == 0)
5106 geometry.height=geometry.width;
5107 width=geometry.width;
5108 height=geometry.height;
5110 if ((flags & AspectValue) != 0)
5112 if ((flags & XValue) != 0)
5114 if ((flags & YValue) != 0)
5119 if ((flags & XValue) != 0)
5122 if ((width == 0) && (geometry.x > 0))
5123 width=msl_info->image[n]->columns+geometry.x;
5125 if ((flags & YValue) != 0)
5128 if ((height == 0) && (geometry.y > 0))
5129 height=msl_info->image[n]->rows+geometry.y;
5134 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5140 if (LocaleCompare(keyword,"height") == 0)
5142 height = StringToLong( value );
5145 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5151 if (LocaleCompare(keyword,"width") == 0)
5153 width = StringToLong( value );
5156 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5162 if (LocaleCompare(keyword,"x") == 0)
5164 x = StringToLong( value );
5167 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5173 if (LocaleCompare(keyword,"y") == 0)
5175 y = StringToLong( value );
5178 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5183 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5189 msl_info->image[n]->page.width=width;
5190 msl_info->image[n]->page.height=height;
5191 msl_info->image[n]->page.x=x;
5192 msl_info->image[n]->page.y=y;
5195 else if (LocaleCompare((const char *) tag,"resample") == 0)
5201 if (msl_info->image[n] == (Image *) NULL)
5203 ThrowMSLException(OptionError,"NoImagesDefined",
5204 (const char *) tag);
5207 if (attributes == (const xmlChar **) NULL)
5209 x_resolution=DefaultResolution;
5210 y_resolution=DefaultResolution;
5211 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5213 keyword=(const char *) attributes[i++];
5214 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5215 msl_info->attributes[n],(const char *) attributes[i]));
5220 if (LocaleCompare(keyword,"blur") == 0)
5222 msl_info->image[n]->blur=InterpretLocaleValue(value,
5226 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5232 if (LocaleCompare(keyword,"geometry") == 0)
5237 flags=ParseGeometry(value,&geometry_info);
5238 if ((flags & SigmaValue) == 0)
5239 geometry_info.sigma*=geometry_info.rho;
5240 x_resolution=geometry_info.rho;
5241 y_resolution=geometry_info.sigma;
5244 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5250 if (LocaleCompare(keyword,"x-resolution") == 0)
5252 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5255 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5261 if (LocaleCompare(keyword,"y-resolution") == 0)
5263 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5266 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5271 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5287 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5289 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5290 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5291 msl_info->image[n]->x_resolution))+0.5);
5292 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5293 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5294 msl_info->image[n]->y_resolution))+0.5);
5295 resample_image=ResizeImage(msl_info->image[n],width,height,
5296 msl_info->image[n]->filter,msl_info->image[n]->blur,
5297 &msl_info->image[n]->exception);
5298 if (resample_image == (Image *) NULL)
5300 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5301 msl_info->image[n]=resample_image;
5305 if (LocaleCompare((const char *) tag,"resize") == 0)
5319 if (msl_info->image[n] == (Image *) NULL)
5321 ThrowMSLException(OptionError,"NoImagesDefined",
5322 (const char *) tag);
5325 filter=UndefinedFilter;
5327 if (attributes != (const xmlChar **) NULL)
5328 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5330 keyword=(const char *) attributes[i++];
5331 attribute=InterpretImageProperties(msl_info->image_info[n],
5332 msl_info->attributes[n],(const char *) attributes[i]);
5333 CloneString(&value,attribute);
5339 if (LocaleCompare(keyword,"filter") == 0)
5341 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5344 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5346 filter=(FilterTypes) option;
5349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5356 if (LocaleCompare(keyword,"geometry") == 0)
5358 flags=ParseRegionGeometry(msl_info->image[n],value,
5359 &geometry,&exception);
5362 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5369 if (LocaleCompare(keyword,"height") == 0)
5371 geometry.height=StringToUnsignedLong(value);
5374 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5381 if (LocaleCompare(keyword,"support") == 0)
5383 blur=InterpretLocaleValue(value,(char **) NULL);
5386 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5393 if (LocaleCompare(keyword,"width") == 0)
5395 geometry.width=StringToLong(value);
5398 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5404 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5410 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5411 geometry.height,filter,blur,&msl_info->image[n]->exception);
5412 if (resize_image == (Image *) NULL)
5414 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5415 msl_info->image[n]=resize_image;
5418 if (LocaleCompare((const char *) tag,"roll") == 0)
5426 if (msl_info->image[n] == (Image *) NULL)
5428 ThrowMSLException(OptionError,"NoImagesDefined",
5429 (const char *) tag);
5432 SetGeometry(msl_info->image[n],&geometry);
5433 if (attributes != (const xmlChar **) NULL)
5434 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5436 keyword=(const char *) attributes[i++];
5437 attribute=InterpretImageProperties(msl_info->image_info[n],
5438 msl_info->attributes[n],(const char *) attributes[i]);
5439 CloneString(&value,attribute);
5445 if (LocaleCompare(keyword,"geometry") == 0)
5447 flags=ParsePageGeometry(msl_info->image[n],value,
5448 &geometry,&exception);
5449 if ((flags & HeightValue) == 0)
5450 geometry.height=geometry.width;
5453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5460 if (LocaleCompare(keyword,"x") == 0)
5462 geometry.x=StringToLong(value);
5465 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5472 if (LocaleCompare(keyword,"y") == 0)
5474 geometry.y=StringToLong(value);
5477 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5483 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5489 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5490 &msl_info->image[n]->exception);
5491 if (roll_image == (Image *) NULL)
5493 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5494 msl_info->image[n]=roll_image;
5497 else if (LocaleCompare((const char *) tag,"roll") == 0)
5499 /* init the values */
5500 width=msl_info->image[n]->columns;
5501 height=msl_info->image[n]->rows;
5504 if (msl_info->image[n] == (Image *) NULL)
5506 ThrowMSLException(OptionError,"NoImagesDefined",
5507 (const char *) tag);
5510 if (attributes == (const xmlChar **) NULL)
5512 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5514 keyword=(const char *) attributes[i++];
5515 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5516 msl_info->attributes[n],(const char *) attributes[i]));
5522 if (LocaleCompare(keyword,"geometry") == 0)
5524 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5527 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5533 if (LocaleCompare(keyword,"x") == 0)
5535 x = StringToLong( value );
5538 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5544 if (LocaleCompare(keyword,"y") == 0)
5546 y = StringToLong( value );
5549 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5554 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5567 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5568 if (newImage == (Image *) NULL)
5570 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5571 msl_info->image[n]=newImage;
5576 if (LocaleCompare((const char *) tag,"rotate") == 0)
5584 if (msl_info->image[n] == (Image *) NULL)
5586 ThrowMSLException(OptionError,"NoImagesDefined",
5587 (const char *) tag);
5590 if (attributes != (const xmlChar **) NULL)
5591 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5593 keyword=(const char *) attributes[i++];
5594 attribute=InterpretImageProperties(msl_info->image_info[n],
5595 msl_info->attributes[n],(const char *) attributes[i]);
5596 CloneString(&value,attribute);
5602 if (LocaleCompare(keyword,"degrees") == 0)
5604 geometry_info.rho=InterpretLocaleValue(value,
5608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5615 if (LocaleCompare(keyword,"geometry") == 0)
5617 flags=ParseGeometry(value,&geometry_info);
5618 if ((flags & SigmaValue) == 0)
5619 geometry_info.sigma=1.0;
5622 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5634 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5635 &msl_info->image[n]->exception);
5636 if (rotate_image == (Image *) NULL)
5638 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5639 msl_info->image[n]=rotate_image;
5642 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5644 /* init the values */
5647 if (msl_info->image[n] == (Image *) NULL)
5649 ThrowMSLException(OptionError,"NoImagesDefined",
5650 (const char *) tag);
5653 if (attributes == (const xmlChar **) NULL)
5655 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5657 keyword=(const char *) attributes[i++];
5658 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5659 msl_info->attributes[n],(const char *) attributes[i]));
5665 if (LocaleCompare(keyword,"degrees") == 0)
5667 degrees = InterpretLocaleValue(value,(char **) NULL);
5670 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5675 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5688 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5689 if (newImage == (Image *) NULL)
5691 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5692 msl_info->image[n]=newImage;
5697 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5702 if (LocaleCompare((const char *) tag,"sample") == 0)
5710 if (msl_info->image[n] == (Image *) NULL)
5712 ThrowMSLException(OptionError,"NoImagesDefined",
5713 (const char *) tag);
5716 if (attributes != (const xmlChar **) NULL)
5717 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5719 keyword=(const char *) attributes[i++];
5720 attribute=InterpretImageProperties(msl_info->image_info[n],
5721 msl_info->attributes[n],(const char *) attributes[i]);
5722 CloneString(&value,attribute);
5728 if (LocaleCompare(keyword,"geometry") == 0)
5730 flags=ParseRegionGeometry(msl_info->image[n],value,
5731 &geometry,&exception);
5734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5741 if (LocaleCompare(keyword,"height") == 0)
5743 geometry.height=StringToUnsignedLong(value);
5746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5753 if (LocaleCompare(keyword,"width") == 0)
5755 geometry.width=StringToLong(value);
5758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5770 sample_image=SampleImage(msl_info->image[n],geometry.width,
5771 geometry.height,&msl_info->image[n]->exception);
5772 if (sample_image == (Image *) NULL)
5774 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5775 msl_info->image[n]=sample_image;
5778 if (LocaleCompare((const char *) tag,"scale") == 0)
5786 if (msl_info->image[n] == (Image *) NULL)
5788 ThrowMSLException(OptionError,"NoImagesDefined",
5789 (const char *) tag);
5792 if (attributes != (const xmlChar **) NULL)
5793 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5795 keyword=(const char *) attributes[i++];
5796 attribute=InterpretImageProperties(msl_info->image_info[n],
5797 msl_info->attributes[n],(const char *) attributes[i]);
5798 CloneString(&value,attribute);
5804 if (LocaleCompare(keyword,"geometry") == 0)
5806 flags=ParseRegionGeometry(msl_info->image[n],value,
5807 &geometry,&exception);
5810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5817 if (LocaleCompare(keyword,"height") == 0)
5819 geometry.height=StringToUnsignedLong(value);
5822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5829 if (LocaleCompare(keyword,"width") == 0)
5831 geometry.width=StringToLong(value);
5834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5846 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5847 geometry.height,&msl_info->image[n]->exception);
5848 if (scale_image == (Image *) NULL)
5850 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5851 msl_info->image[n]=scale_image;
5854 if (LocaleCompare((const char *) tag,"segment") == 0)
5865 if (msl_info->image[n] == (Image *) NULL)
5867 ThrowMSLException(OptionError,"NoImagesDefined",
5868 (const char *) tag);
5871 geometry_info.rho=1.0;
5872 geometry_info.sigma=1.5;
5873 colorspace=RGBColorspace;
5874 verbose=MagickFalse;
5875 if (attributes != (const xmlChar **) NULL)
5876 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5878 keyword=(const char *) attributes[i++];
5879 attribute=InterpretImageProperties(msl_info->image_info[n],
5880 msl_info->attributes[n],(const char *) attributes[i]);
5881 CloneString(&value,attribute);
5887 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5889 geometry_info.rho=InterpretLocaleValue(value,
5893 if (LocaleCompare(keyword,"colorspace") == 0)
5895 option=ParseCommandOption(MagickColorspaceOptions,
5898 ThrowMSLException(OptionError,
5899 "UnrecognizedColorspaceType",value);
5900 colorspace=(ColorspaceType) option;
5903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5910 if (LocaleCompare(keyword,"geometry") == 0)
5912 flags=ParseGeometry(value,&geometry_info);
5913 if ((flags & SigmaValue) == 0)
5914 geometry_info.sigma=1.5;
5917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5924 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5926 geometry_info.sigma=InterpretLocaleValue(value,
5930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5942 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5943 geometry_info.rho,geometry_info.sigma);
5946 else if (LocaleCompare((const char *) tag, "set") == 0)
5948 if (msl_info->image[n] == (Image *) NULL)
5950 ThrowMSLException(OptionError,"NoImagesDefined",
5951 (const char *) tag);
5955 if (attributes == (const xmlChar **) NULL)
5957 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5959 keyword=(const char *) attributes[i++];
5960 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5961 msl_info->attributes[n],(const char *) attributes[i]));
5967 if (LocaleCompare(keyword,"clip-mask") == 0)
5969 for (j=0; j < msl_info->n; j++)
5974 property=GetImageProperty(msl_info->attributes[j],"id");
5975 if (LocaleCompare(property,value) == 0)
5977 SetImageMask(msl_info->image[n],msl_info->image[j]);
5983 if (LocaleCompare(keyword,"clip-path") == 0)
5985 for (j=0; j < msl_info->n; j++)
5990 property=GetImageProperty(msl_info->attributes[j],"id");
5991 if (LocaleCompare(property,value) == 0)
5993 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5999 if (LocaleCompare(keyword,"colorspace") == 0)
6004 colorspace=(ColorspaceType) ParseCommandOption(
6005 MagickColorspaceOptions,MagickFalse,value);
6007 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6009 (void) TransformImageColorspace(msl_info->image[n],
6010 (ColorspaceType) colorspace);
6013 (void) SetMSLAttributes(msl_info,keyword,value);
6019 if (LocaleCompare(keyword,"density") == 0)
6021 flags=ParseGeometry(value,&geometry_info);
6022 msl_info->image[n]->x_resolution=geometry_info.rho;
6023 msl_info->image[n]->y_resolution=geometry_info.sigma;
6024 if ((flags & SigmaValue) == 0)
6025 msl_info->image[n]->y_resolution=
6026 msl_info->image[n]->x_resolution;
6029 (void) SetMSLAttributes(msl_info,keyword,value);
6035 if (LocaleCompare(keyword, "opacity") == 0)
6037 ssize_t opac = OpaqueAlpha,
6038 len = (ssize_t) strlen( value );
6040 if (value[len-1] == '%') {
6042 (void) CopyMagickString(tmp,value,len);
6043 opac = StringToLong( tmp );
6044 opac = (int)(QuantumRange * ((float)opac/100));
6046 opac = StringToLong( value );
6047 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6050 (void) SetMSLAttributes(msl_info,keyword,value);
6056 if (LocaleCompare(keyword, "page") == 0)
6059 page[MaxTextExtent];
6070 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6071 image_option=GetImageOption(msl_info->image_info[n],"page");
6072 if (image_option != (const char *) NULL)
6073 flags=ParseAbsoluteGeometry(image_option,&geometry);
6074 flags=ParseAbsoluteGeometry(value,&geometry);
6075 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6076 (double) geometry.width,(double) geometry.height);
6077 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6078 (void) FormatLocaleString(page,MaxTextExtent,
6079 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6080 (double) geometry.height,(double) geometry.x,(double)
6082 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6083 msl_info->image_info[n]->page=GetPageGeometry(page);
6086 (void) SetMSLAttributes(msl_info,keyword,value);
6091 (void) SetMSLAttributes(msl_info,keyword,value);
6098 if (LocaleCompare((const char *) tag,"shade") == 0)
6109 if (msl_info->image[n] == (Image *) NULL)
6111 ThrowMSLException(OptionError,"NoImagesDefined",
6112 (const char *) tag);
6116 if (attributes != (const xmlChar **) NULL)
6117 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6119 keyword=(const char *) attributes[i++];
6120 attribute=InterpretImageProperties(msl_info->image_info[n],
6121 msl_info->attributes[n],(const char *) attributes[i]);
6122 CloneString(&value,attribute);
6128 if (LocaleCompare(keyword,"azimuth") == 0)
6130 geometry_info.rho=InterpretLocaleValue(value,
6134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(keyword,"elevation") == 0)
6143 geometry_info.sigma=InterpretLocaleValue(value,
6147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6154 if (LocaleCompare(keyword,"geometry") == 0)
6156 flags=ParseGeometry(value,&geometry_info);
6157 if ((flags & SigmaValue) == 0)
6158 geometry_info.sigma=1.0;
6161 if (LocaleCompare(keyword,"gray") == 0)
6163 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6166 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6168 gray=(MagickBooleanType) option;
6171 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6177 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6183 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6184 geometry_info.sigma,&msl_info->image[n]->exception);
6185 if (shade_image == (Image *) NULL)
6187 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6188 msl_info->image[n]=shade_image;
6191 if (LocaleCompare((const char *) tag,"shadow") == 0)
6199 if (msl_info->image[n] == (Image *) NULL)
6201 ThrowMSLException(OptionError,"NoImagesDefined",
6202 (const char *) tag);
6205 if (attributes != (const xmlChar **) NULL)
6206 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6208 keyword=(const char *) attributes[i++];
6209 attribute=InterpretImageProperties(msl_info->image_info[n],
6210 msl_info->attributes[n],(const char *) attributes[i]);
6211 CloneString(&value,attribute);
6217 if (LocaleCompare(keyword,"geometry") == 0)
6219 flags=ParseGeometry(value,&geometry_info);
6220 if ((flags & SigmaValue) == 0)
6221 geometry_info.sigma=1.0;
6224 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6231 if (LocaleCompare(keyword,"opacity") == 0)
6233 geometry_info.rho=StringToLong(value);
6236 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6243 if (LocaleCompare(keyword,"sigma") == 0)
6245 geometry_info.sigma=StringToLong(value);
6253 if (LocaleCompare(keyword,"x") == 0)
6255 geometry_info.xi=InterpretLocaleValue(value,
6259 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6266 if (LocaleCompare(keyword,"y") == 0)
6268 geometry_info.psi=StringToLong(value);
6271 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6277 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6283 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6284 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6285 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6286 if (shadow_image == (Image *) NULL)
6288 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6289 msl_info->image[n]=shadow_image;
6292 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6294 double radius = 0.0,
6297 if (msl_info->image[n] == (Image *) NULL)
6299 ThrowMSLException(OptionError,"NoImagesDefined",
6300 (const char *) tag);
6304 NOTE: sharpen can have no attributes, since we use all the defaults!
6306 if (attributes != (const xmlChar **) NULL)
6308 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6310 keyword=(const char *) attributes[i++];
6311 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6312 msl_info->attributes[n],(const char *) attributes[i]));
6318 if (LocaleCompare(keyword, "radius") == 0)
6320 radius = InterpretLocaleValue(value,(char **) NULL);
6323 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6329 if (LocaleCompare(keyword,"sigma") == 0)
6331 sigma = StringToLong( value );
6334 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6339 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6353 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6354 if (newImage == (Image *) NULL)
6356 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6357 msl_info->image[n]=newImage;
6361 else if (LocaleCompare((const char *) tag,"shave") == 0)
6363 /* init the values */
6367 if (msl_info->image[n] == (Image *) NULL)
6369 ThrowMSLException(OptionError,"NoImagesDefined",
6370 (const char *) tag);
6373 if (attributes == (const xmlChar **) NULL)
6375 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6377 keyword=(const char *) attributes[i++];
6378 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6379 msl_info->attributes[n],(const char *) attributes[i]));
6385 if (LocaleCompare(keyword,"geometry") == 0)
6387 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6390 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6396 if (LocaleCompare(keyword,"height") == 0)
6398 height = StringToLong( value );
6401 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6407 if (LocaleCompare(keyword,"width") == 0)
6409 width = StringToLong( value );
6412 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6417 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6432 rectInfo.height = height;
6433 rectInfo.width = width;
6438 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6439 &msl_info->image[n]->exception);
6440 if (newImage == (Image *) NULL)
6442 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6443 msl_info->image[n]=newImage;
6448 if (LocaleCompare((const char *) tag,"shear") == 0)
6456 if (msl_info->image[n] == (Image *) NULL)
6458 ThrowMSLException(OptionError,"NoImagesDefined",
6459 (const char *) tag);
6462 if (attributes != (const xmlChar **) NULL)
6463 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6465 keyword=(const char *) attributes[i++];
6466 attribute=InterpretImageProperties(msl_info->image_info[n],
6467 msl_info->attributes[n],(const char *) attributes[i]);
6468 CloneString(&value,attribute);
6474 if (LocaleCompare(keyword, "fill") == 0)
6476 (void) QueryColorDatabase(value,
6477 &msl_info->image[n]->background_color,&exception);
6480 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6487 if (LocaleCompare(keyword,"geometry") == 0)
6489 flags=ParseGeometry(value,&geometry_info);
6490 if ((flags & SigmaValue) == 0)
6491 geometry_info.sigma=1.0;
6494 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6501 if (LocaleCompare(keyword,"x") == 0)
6503 geometry_info.rho=InterpretLocaleValue(value,
6507 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6514 if (LocaleCompare(keyword,"y") == 0)
6516 geometry_info.sigma=StringToLong(value);
6519 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6531 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6532 geometry_info.sigma,&msl_info->image[n]->exception);
6533 if (shear_image == (Image *) NULL)
6535 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6536 msl_info->image[n]=shear_image;
6539 if (LocaleCompare((const char *) tag,"signature") == 0)
6544 if (msl_info->image[n] == (Image *) NULL)
6546 ThrowMSLException(OptionError,"NoImagesDefined",
6547 (const char *) tag);
6550 if (attributes != (const xmlChar **) NULL)
6551 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6553 keyword=(const char *) attributes[i++];
6554 attribute=InterpretImageProperties(msl_info->image_info[n],
6555 msl_info->attributes[n],(const char *) attributes[i]);
6556 CloneString(&value,attribute);
6561 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6567 (void) SignatureImage(msl_info->image[n]);
6570 if (LocaleCompare((const char *) tag,"solarize") == 0)
6575 if (msl_info->image[n] == (Image *) NULL)
6577 ThrowMSLException(OptionError,"NoImagesDefined",
6578 (const char *) tag);
6581 geometry_info.rho=QuantumRange/2.0;
6582 if (attributes != (const xmlChar **) NULL)
6583 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6585 keyword=(const char *) attributes[i++];
6586 attribute=InterpretImageProperties(msl_info->image_info[n],
6587 msl_info->attributes[n],(const char *) attributes[i]);
6588 CloneString(&value,attribute);
6594 if (LocaleCompare(keyword,"geometry") == 0)
6596 flags=ParseGeometry(value,&geometry_info);
6599 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6606 if (LocaleCompare(keyword,"threshold") == 0)
6608 geometry_info.rho=InterpretLocaleValue(value,
6612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6618 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6624 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6627 if (LocaleCompare((const char *) tag,"spread") == 0)
6635 if (msl_info->image[n] == (Image *) NULL)
6637 ThrowMSLException(OptionError,"NoImagesDefined",
6638 (const char *) tag);
6641 if (attributes != (const xmlChar **) NULL)
6642 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6644 keyword=(const char *) attributes[i++];
6645 attribute=InterpretImageProperties(msl_info->image_info[n],
6646 msl_info->attributes[n],(const char *) attributes[i]);
6647 CloneString(&value,attribute);
6653 if (LocaleCompare(keyword,"geometry") == 0)
6655 flags=ParseGeometry(value,&geometry_info);
6656 if ((flags & SigmaValue) == 0)
6657 geometry_info.sigma=1.0;
6660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6667 if (LocaleCompare(keyword,"radius") == 0)
6669 geometry_info.rho=InterpretLocaleValue(value,
6673 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6685 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6686 &msl_info->image[n]->exception);
6687 if (spread_image == (Image *) NULL)
6689 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6690 msl_info->image[n]=spread_image;
6693 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6696 watermark = (Image*)NULL;
6698 if (msl_info->image[n] == (Image *) NULL)
6700 ThrowMSLException(OptionError,"NoImagesDefined",
6701 (const char *) tag);
6704 if (attributes == (const xmlChar **) NULL)
6706 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6708 keyword=(const char *) attributes[i++];
6709 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6710 msl_info->attributes[n],(const char *) attributes[i]));
6716 if (LocaleCompare(keyword,"image") == 0)
6718 for (j=0; j<msl_info->n;j++)
6721 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6722 if (theAttr && LocaleCompare(theAttr, value) == 0)
6724 watermark = msl_info->image[j];
6730 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6735 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6744 if ( watermark != (Image*) NULL )
6749 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6750 if (newImage == (Image *) NULL)
6752 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6753 msl_info->image[n]=newImage;
6756 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6758 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6761 stereoImage = (Image*)NULL;
6763 if (msl_info->image[n] == (Image *) NULL)
6765 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6768 if (attributes == (const xmlChar **) NULL)
6770 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6772 keyword=(const char *) attributes[i++];
6773 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6774 msl_info->attributes[n],(const char *) attributes[i]));
6780 if (LocaleCompare(keyword,"image") == 0)
6782 for (j=0; j<msl_info->n;j++)
6785 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6786 if (theAttr && LocaleCompare(theAttr, value) == 0)
6788 stereoImage = msl_info->image[j];
6794 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6799 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6808 if ( stereoImage != (Image*) NULL )
6813 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6814 if (newImage == (Image *) NULL)
6816 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6817 msl_info->image[n]=newImage;
6820 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6822 if (LocaleCompare((const char *) tag,"swap") == 0)
6833 if (msl_info->image[n] == (Image *) NULL)
6835 ThrowMSLException(OptionError,"NoImagesDefined",
6836 (const char *) tag);
6841 if (attributes != (const xmlChar **) NULL)
6842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6844 keyword=(const char *) attributes[i++];
6845 attribute=InterpretImageProperties(msl_info->image_info[n],
6846 msl_info->attributes[n],(const char *) attributes[i]);
6847 CloneString(&value,attribute);
6853 if (LocaleCompare(keyword,"indexes") == 0)
6855 flags=ParseGeometry(value,&geometry_info);
6856 index=(ssize_t) geometry_info.rho;
6857 if ((flags & SigmaValue) == 0)
6858 swap_index=(ssize_t) geometry_info.sigma;
6861 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6867 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6876 p=GetImageFromList(msl_info->image[n],index);
6877 q=GetImageFromList(msl_info->image[n],swap_index);
6878 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6880 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6883 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6884 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6885 ReplaceImageInList(&q,swap);
6886 msl_info->image[n]=GetFirstImageInList(q);
6889 if (LocaleCompare((const char *) tag,"swirl") == 0)
6897 if (msl_info->image[n] == (Image *) NULL)
6899 ThrowMSLException(OptionError,"NoImagesDefined",
6900 (const char *) tag);
6903 if (attributes != (const xmlChar **) NULL)
6904 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6906 keyword=(const char *) attributes[i++];
6907 attribute=InterpretImageProperties(msl_info->image_info[n],
6908 msl_info->attributes[n],(const char *) attributes[i]);
6909 CloneString(&value,attribute);
6915 if (LocaleCompare(keyword,"degrees") == 0)
6917 geometry_info.rho=InterpretLocaleValue(value,
6921 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6928 if (LocaleCompare(keyword,"geometry") == 0)
6930 flags=ParseGeometry(value,&geometry_info);
6931 if ((flags & SigmaValue) == 0)
6932 geometry_info.sigma=1.0;
6935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6941 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6947 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6948 &msl_info->image[n]->exception);
6949 if (swirl_image == (Image *) NULL)
6951 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6952 msl_info->image[n]=swirl_image;
6955 if (LocaleCompare((const char *) tag,"sync") == 0)
6960 if (msl_info->image[n] == (Image *) NULL)
6962 ThrowMSLException(OptionError,"NoImagesDefined",
6963 (const char *) tag);
6966 if (attributes != (const xmlChar **) NULL)
6967 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6969 keyword=(const char *) attributes[i++];
6970 attribute=InterpretImageProperties(msl_info->image_info[n],
6971 msl_info->attributes[n],(const char *) attributes[i]);
6972 CloneString(&value,attribute);
6977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6983 (void) SyncImage(msl_info->image[n]);
6986 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6991 if (LocaleCompare((const char *) tag,"map") == 0)
6999 if (msl_info->image[n] == (Image *) NULL)
7001 ThrowMSLException(OptionError,"NoImagesDefined",
7002 (const char *) tag);
7005 texture_image=NewImageList();
7006 if (attributes != (const xmlChar **) NULL)
7007 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7009 keyword=(const char *) attributes[i++];
7010 attribute=InterpretImageProperties(msl_info->image_info[n],
7011 msl_info->attributes[n],(const char *) attributes[i]);
7012 CloneString(&value,attribute);
7018 if (LocaleCompare(keyword,"image") == 0)
7019 for (j=0; j < msl_info->n; j++)
7024 attribute=GetImageProperty(msl_info->attributes[j],"id");
7025 if ((attribute != (const char *) NULL) &&
7026 (LocaleCompare(attribute,value) == 0))
7028 texture_image=CloneImage(msl_info->image[j],0,0,
7029 MagickFalse,&exception);
7037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7043 (void) TextureImage(msl_info->image[n],texture_image);
7044 texture_image=DestroyImage(texture_image);
7047 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7049 /* init the values */
7050 double threshold = 0;
7052 if (msl_info->image[n] == (Image *) NULL)
7054 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7057 if (attributes == (const xmlChar **) NULL)
7059 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7061 keyword=(const char *) attributes[i++];
7062 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7063 msl_info->attributes[n],(const char *) attributes[i]));
7069 if (LocaleCompare(keyword,"threshold") == 0)
7071 threshold = InterpretLocaleValue(value,(char **) NULL);
7074 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7079 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7089 BilevelImageChannel(msl_info->image[n],
7090 (ChannelType) ((ssize_t) (CompositeChannels &~ (ssize_t) OpacityChannel)),
7095 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7097 if (msl_info->image[n] == (Image *) NULL)
7099 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7102 if (attributes == (const xmlChar **) NULL)
7104 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7106 keyword=(const char *) attributes[i++];
7107 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7108 msl_info->attributes[n],(const char *) attributes[i]));
7114 if (LocaleCompare(keyword,"color") == 0)
7119 (void) QueryMagickColor(value,&target,&exception);
7120 (void) TransparentPaintImage(msl_info->image[n],&target,
7121 TransparentAlpha,MagickFalse);
7124 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7129 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7136 else if (LocaleCompare((const char *) tag, "trim") == 0)
7138 if (msl_info->image[n] == (Image *) NULL)
7140 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7144 /* no attributes here */
7146 /* process the image */
7153 /* all zeros on a crop == trim edges! */
7154 rectInfo.height = rectInfo.width = 0;
7155 rectInfo.x = rectInfo.y = 0;
7157 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7158 if (newImage == (Image *) NULL)
7160 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7161 msl_info->image[n]=newImage;
7165 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7170 if (LocaleCompare((const char *) tag,"write") == 0)
7172 if (msl_info->image[n] == (Image *) NULL)
7174 ThrowMSLException(OptionError,"NoImagesDefined",
7175 (const char *) tag);
7178 if (attributes == (const xmlChar **) NULL)
7180 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7182 keyword=(const char *) attributes[i++];
7183 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7184 msl_info->attributes[n],(const char *) attributes[i]));
7190 if (LocaleCompare(keyword,"filename") == 0)
7192 (void) CopyMagickString(msl_info->image[n]->filename,value,
7196 (void) SetMSLAttributes(msl_info,keyword,value);
7200 (void) SetMSLAttributes(msl_info,keyword,value);
7208 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7212 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7216 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7220 if ( value != NULL )
7221 value=DestroyString(value);
7222 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7225 static void MSLEndElement(void *context,const xmlChar *tag)
7234 Called when the end of an element has been detected.
7236 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7238 msl_info=(MSLInfo *) context;
7245 if (LocaleCompare((const char *) tag,"comment") == 0 )
7247 (void) DeleteImageProperty(msl_info->image[n],"comment");
7248 if (msl_info->content == (char *) NULL)
7250 StripString(msl_info->content);
7251 (void) SetImageProperty(msl_info->image[n],"comment",
7260 if (LocaleCompare((const char *) tag, "group") == 0 )
7262 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7264 ssize_t i = (ssize_t)
7265 (msl_info->group_info[msl_info->number_groups-1].numImages);
7268 if (msl_info->image[msl_info->n] != (Image *) NULL)
7269 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7270 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7271 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7275 msl_info->number_groups--;
7282 if (LocaleCompare((const char *) tag, "image") == 0)
7283 MSLPopImage(msl_info);
7289 if (LocaleCompare((const char *) tag,"label") == 0 )
7291 (void) DeleteImageProperty(msl_info->image[n],"label");
7292 if (msl_info->content == (char *) NULL)
7294 StripString(msl_info->content);
7295 (void) SetImageProperty(msl_info->image[n],"label",
7304 if (LocaleCompare((const char *) tag, "msl") == 0 )
7307 This our base element.
7308 at the moment we don't do anything special
7309 but someday we might!
7317 if (msl_info->content != (char *) NULL)
7318 msl_info->content=DestroyString(msl_info->content);
7321 static void MSLCharacters(void *context,const xmlChar *c,int length)
7333 Receiving some characters from the parser.
7335 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7336 " SAX.characters(%s,%d)",c,length);
7337 msl_info=(MSLInfo *) context;
7338 if (msl_info->content != (char *) NULL)
7339 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7340 strlen(msl_info->content)+length+MaxTextExtent,
7341 sizeof(*msl_info->content));
7344 msl_info->content=(char *) NULL;
7345 if (~length >= (MaxTextExtent-1))
7346 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7347 sizeof(*msl_info->content));
7348 if (msl_info->content != (char *) NULL)
7349 *msl_info->content='\0';
7351 if (msl_info->content == (char *) NULL)
7353 p=msl_info->content+strlen(msl_info->content);
7354 for (i=0; i < length; i++)
7359 static void MSLReference(void *context,const xmlChar *name)
7368 Called when an entity reference is detected.
7370 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7371 " SAX.reference(%s)",name);
7372 msl_info=(MSLInfo *) context;
7373 parser=msl_info->parser;
7375 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7377 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7380 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7386 Receiving some ignorable whitespaces from the parser.
7388 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7389 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7390 msl_info=(MSLInfo *) context;
7394 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7395 const xmlChar *data)
7401 A processing instruction has been parsed.
7403 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7404 " SAX.processingInstruction(%s, %s)",
7406 msl_info=(MSLInfo *) context;
7410 static void MSLComment(void *context,const xmlChar *value)
7416 A comment has been parsed.
7418 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7419 " SAX.comment(%s)",value);
7420 msl_info=(MSLInfo *) context;
7424 static void MSLWarning(void *context,const char *format,...)
7428 reason[MaxTextExtent];
7437 Display and format a warning messages, gives file, line, position and
7440 va_start(operands,format);
7441 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7442 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7443 msl_info=(MSLInfo *) context;
7445 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7446 (void) vsprintf(reason,format,operands);
7448 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7450 message=GetExceptionMessage(errno);
7451 ThrowMSLException(CoderError,reason,message);
7452 message=DestroyString(message);
7456 static void MSLError(void *context,const char *format,...)
7459 reason[MaxTextExtent];
7468 Display and format a error formats, gives file, line, position and
7471 va_start(operands,format);
7472 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7473 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7474 msl_info=(MSLInfo *) context;
7476 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7477 (void) vsprintf(reason,format,operands);
7479 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7481 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7485 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7497 Called when a pcdata block has been parsed.
7499 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7500 " SAX.pcdata(%s, %d)",value,length);
7501 msl_info=(MSLInfo *) context;
7503 parser=msl_info->parser;
7504 child=xmlGetLastChild(parser->node);
7505 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7507 xmlTextConcat(child,value,length);
7510 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7513 static void MSLExternalSubset(void *context,const xmlChar *name,
7514 const xmlChar *external_id,const xmlChar *system_id)
7529 Does this document has an external subset?
7531 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7532 " SAX.externalSubset(%s %s %s)",name,
7533 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7534 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7535 msl_info=(MSLInfo *) context;
7537 parser=msl_info->parser;
7538 if (((external_id == NULL) && (system_id == NULL)) ||
7539 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7540 (msl_info->document == 0)))
7542 input=MSLResolveEntity(context,external_id,system_id);
7545 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7546 parser_context=(*parser);
7547 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7548 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7550 parser->errNo=XML_ERR_NO_MEMORY;
7551 parser->input=parser_context.input;
7552 parser->inputNr=parser_context.inputNr;
7553 parser->inputMax=parser_context.inputMax;
7554 parser->inputTab=parser_context.inputTab;
7560 xmlPushInput(parser,input);
7561 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7562 if (input->filename == (char *) NULL)
7563 input->filename=(char *) xmlStrdup(system_id);
7566 input->base=parser->input->cur;
7567 input->cur=parser->input->cur;
7569 xmlParseExternalSubset(parser,external_id,system_id);
7570 while (parser->inputNr > 1)
7571 (void) xmlPopInput(parser);
7572 xmlFreeInputStream(parser->input);
7573 xmlFree(parser->inputTab);
7574 parser->input=parser_context.input;
7575 parser->inputNr=parser_context.inputNr;
7576 parser->inputMax=parser_context.inputMax;
7577 parser->inputTab=parser_context.inputTab;
7580 #if defined(__cplusplus) || defined(c_plusplus)
7584 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7585 ExceptionInfo *exception)
7588 message[MaxTextExtent];
7611 assert(image_info != (const ImageInfo *) NULL);
7612 assert(image_info->signature == MagickSignature);
7613 if (image_info->debug != MagickFalse)
7614 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7615 image_info->filename);
7616 assert(image != (Image **) NULL);
7617 msl_image=AcquireImage(image_info);
7618 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7619 if (status == MagickFalse)
7621 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7622 msl_image->filename);
7623 msl_image=DestroyImageList(msl_image);
7624 return(MagickFalse);
7626 msl_image->columns=1;
7631 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7632 msl_info.exception=exception;
7633 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7634 sizeof(*msl_info.image_info));
7635 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7636 sizeof(*msl_info.draw_info));
7637 /* top of the stack is the MSL file itself */
7638 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7639 msl_info.attributes=(Image **) AcquireMagickMemory(
7640 sizeof(*msl_info.attributes));
7641 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7642 sizeof(*msl_info.group_info));
7643 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7644 (msl_info.image == (Image **) NULL) ||
7645 (msl_info.attributes == (Image **) NULL) ||
7646 (msl_info.group_info == (MSLGroupInfo *) NULL))
7647 ThrowFatalException(ResourceLimitFatalError,
7648 "UnableToInterpretMSLImage");
7649 *msl_info.image_info=CloneImageInfo(image_info);
7650 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7651 *msl_info.attributes=AcquireImage(image_info);
7652 msl_info.group_info[0].numImages=0;
7653 /* the first slot is used to point to the MSL file image */
7654 *msl_info.image=msl_image;
7655 if (*image != (Image *) NULL)
7656 MSLPushImage(&msl_info,*image);
7657 (void) xmlSubstituteEntitiesDefault(1);
7658 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7659 sax_modules.internalSubset=MSLInternalSubset;
7660 sax_modules.isStandalone=MSLIsStandalone;
7661 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7662 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7663 sax_modules.resolveEntity=MSLResolveEntity;
7664 sax_modules.getEntity=MSLGetEntity;
7665 sax_modules.entityDecl=MSLEntityDeclaration;
7666 sax_modules.notationDecl=MSLNotationDeclaration;
7667 sax_modules.attributeDecl=MSLAttributeDeclaration;
7668 sax_modules.elementDecl=MSLElementDeclaration;
7669 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7670 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7671 sax_modules.startDocument=MSLStartDocument;
7672 sax_modules.endDocument=MSLEndDocument;
7673 sax_modules.startElement=MSLStartElement;
7674 sax_modules.endElement=MSLEndElement;
7675 sax_modules.reference=MSLReference;
7676 sax_modules.characters=MSLCharacters;
7677 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7678 sax_modules.processingInstruction=MSLProcessingInstructions;
7679 sax_modules.comment=MSLComment;
7680 sax_modules.warning=MSLWarning;
7681 sax_modules.error=MSLError;
7682 sax_modules.fatalError=MSLError;
7683 sax_modules.getParameterEntity=MSLGetParameterEntity;
7684 sax_modules.cdataBlock=MSLCDataBlock;
7685 sax_modules.externalSubset=MSLExternalSubset;
7686 sax_handler=(&sax_modules);
7687 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7688 msl_image->filename);
7689 while (ReadBlobString(msl_image,message) != (char *) NULL)
7691 n=(ssize_t) strlen(message);
7694 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7697 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7698 if (msl_info.exception->severity >= ErrorException)
7701 if (msl_info.exception->severity == UndefinedException)
7702 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7703 xmlFreeParserCtxt(msl_info.parser);
7704 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7706 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7707 msl_info.group_info);
7708 if (*image == (Image *) NULL)
7709 *image=(*msl_info.image);
7710 if ((*msl_info.image)->exception.severity != UndefinedException)
7711 return(MagickFalse);
7715 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7723 assert(image_info != (const ImageInfo *) NULL);
7724 assert(image_info->signature == MagickSignature);
7725 if (image_info->debug != MagickFalse)
7726 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7727 image_info->filename);
7728 assert(exception != (ExceptionInfo *) NULL);
7729 assert(exception->signature == MagickSignature);
7730 image=(Image *) NULL;
7731 (void) ProcessMSLScript(image_info,&image,exception);
7732 return(GetFirstImageInList(image));
7737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7741 % R e g i s t e r M S L I m a g e %
7745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7747 % RegisterMSLImage() adds attributes for the MSL image format to
7748 % the list of supported formats. The attributes include the image format
7749 % tag, a method to read and/or write the format, whether the format
7750 % supports the saving of more than one frame to the same file or blob,
7751 % whether the format supports native in-memory I/O, and a brief
7752 % description of the format.
7754 % The format of the RegisterMSLImage method is:
7756 % size_t RegisterMSLImage(void)
7759 ModuleExport size_t RegisterMSLImage(void)
7764 entry=SetMagickInfo("MSL");
7765 #if defined(MAGICKCORE_XML_DELEGATE)
7766 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7767 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7769 entry->description=ConstantString("Magick Scripting Language");
7770 entry->module=ConstantString("MSL");
7771 (void) RegisterMagickInfo(entry);
7772 return(MagickImageCoderSignature);
7775 #if defined(MAGICKCORE_XML_DELEGATE)
7777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7781 % S e t M S L A t t r i b u t e s %
7785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7787 % SetMSLAttributes() ...
7789 % The format of the SetMSLAttributes method is:
7791 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7792 % const char *keyword,const char *value)
7794 % A description of each parameter follows:
7796 % o msl_info: the MSL info.
7798 % o keyword: the keyword.
7800 % o value: the value.
7803 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7830 assert(msl_info != (MSLInfo *) NULL);
7831 if (keyword == (const char *) NULL)
7833 if (value == (const char *) NULL)
7835 exception=msl_info->exception;
7837 attributes=msl_info->attributes[n];
7838 image_info=msl_info->image_info[n];
7839 draw_info=msl_info->draw_info[n];
7840 image=msl_info->image[n];
7846 if (LocaleCompare(keyword,"adjoin") == 0)
7851 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7853 ThrowMSLException(OptionError,"UnrecognizedType",value);
7854 image_info->adjoin=(MagickBooleanType) adjoin;
7857 if (LocaleCompare(keyword,"alpha") == 0)
7862 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7864 ThrowMSLException(OptionError,"UnrecognizedType",value);
7865 if (image != (Image *) NULL)
7866 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7869 if (LocaleCompare(keyword,"antialias") == 0)
7874 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7876 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7877 image_info->antialias=(MagickBooleanType) antialias;
7880 if (LocaleCompare(keyword,"area-limit") == 0)
7885 limit=MagickResourceInfinity;
7886 if (LocaleCompare(value,"unlimited") != 0)
7887 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7888 (void) SetMagickResourceLimit(AreaResource,limit);
7891 if (LocaleCompare(keyword,"attenuate") == 0)
7893 (void) SetImageOption(image_info,keyword,value);
7896 if (LocaleCompare(keyword,"authenticate") == 0)
7898 (void) CloneString(&image_info->density,value);
7901 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7907 if (LocaleCompare(keyword,"background") == 0)
7909 (void) QueryColorDatabase(value,&image_info->background_color,
7913 if (LocaleCompare(keyword,"bias") == 0)
7915 if (image == (Image *) NULL)
7917 image->bias=SiPrefixToDouble(value,QuantumRange);
7920 if (LocaleCompare(keyword,"blue-primary") == 0)
7922 if (image == (Image *) NULL)
7924 flags=ParseGeometry(value,&geometry_info);
7925 image->chromaticity.blue_primary.x=geometry_info.rho;
7926 image->chromaticity.blue_primary.y=geometry_info.sigma;
7927 if ((flags & SigmaValue) == 0)
7928 image->chromaticity.blue_primary.y=
7929 image->chromaticity.blue_primary.x;
7932 if (LocaleCompare(keyword,"bordercolor") == 0)
7934 (void) QueryColorDatabase(value,&image_info->border_color,
7938 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7944 if (LocaleCompare(keyword,"density") == 0)
7946 (void) CloneString(&image_info->density,value);
7947 (void) CloneString(&draw_info->density,value);
7950 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7956 if (LocaleCompare(keyword,"fill") == 0)
7958 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7959 (void) SetImageOption(image_info,keyword,value);
7962 if (LocaleCompare(keyword,"filename") == 0)
7964 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7967 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7973 if (LocaleCompare(keyword,"gravity") == 0)
7978 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7980 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7981 (void) SetImageOption(image_info,keyword,value);
7984 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7990 if (LocaleCompare(keyword,"id") == 0)
7992 (void) SetImageProperty(attributes,keyword,value);
7995 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8001 if (LocaleCompare(keyword,"magick") == 0)
8003 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8006 if (LocaleCompare(keyword,"mattecolor") == 0)
8008 (void) QueryColorDatabase(value,&image_info->matte_color,
8012 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8018 if (LocaleCompare(keyword,"pointsize") == 0)
8020 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8021 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8024 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8030 if (LocaleCompare(keyword,"quality") == 0)
8032 image_info->quality=StringToLong(value);
8033 if (image == (Image *) NULL)
8035 image->quality=StringToLong(value);
8043 if (LocaleCompare(keyword,"size") == 0)
8045 (void) CloneString(&image_info->size,value);
8048 if (LocaleCompare(keyword,"stroke") == 0)
8050 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8051 (void) SetImageOption(image_info,keyword,value);
8054 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8059 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8072 % U n r e g i s t e r M S L I m a g e %
8076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8078 % UnregisterMSLImage() removes format registrations made by the
8079 % MSL module from the list of supported formats.
8081 % The format of the UnregisterMSLImage method is:
8083 % UnregisterMSLImage(void)
8086 ModuleExport void UnregisterMSLImage(void)
8088 (void) UnregisterMagickInfo("MSL");
8091 #if defined(MAGICKCORE_XML_DELEGATE)
8093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8097 % W r i t e M S L I m a g e %
8101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8103 % WriteMSLImage() writes an image to a file in MVG image format.
8105 % The format of the WriteMSLImage method is:
8107 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8109 % A description of each parameter follows.
8111 % o image_info: the image info.
8113 % o image: The image.
8116 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8118 assert(image_info != (const ImageInfo *) NULL);
8119 assert(image_info->signature == MagickSignature);
8120 assert(image != (Image *) NULL);
8121 assert(image->signature == MagickSignature);
8122 if (image->debug != MagickFalse)
8123 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8124 (void) ReferenceImage(image);
8125 (void) ProcessMSLScript(image_info,&image,&image->exception);