2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2012 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/attribute.h"
48 #include "MagickCore/blob.h"
49 #include "MagickCore/blob-private.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/cache-view.h"
52 #include "MagickCore/color.h"
53 #include "MagickCore/color-private.h"
54 #include "MagickCore/colormap.h"
55 #include "MagickCore/composite.h"
56 #include "MagickCore/constitute.h"
57 #include "MagickCore/decorate.h"
58 #include "MagickCore/display.h"
59 #include "MagickCore/distort.h"
60 #include "MagickCore/draw.h"
61 #include "MagickCore/effect.h"
62 #include "MagickCore/enhance.h"
63 #include "MagickCore/exception.h"
64 #include "MagickCore/exception-private.h"
65 #include "MagickCore/fx.h"
66 #include "MagickCore/geometry.h"
67 #include "MagickCore/image.h"
68 #include "MagickCore/image-private.h"
69 #include "MagickCore/list.h"
70 #include "MagickCore/log.h"
71 #include "MagickCore/magick.h"
72 #include "MagickCore/memory_.h"
73 #include "MagickCore/module.h"
74 #include "MagickCore/option.h"
75 #include "MagickCore/paint.h"
76 #include "MagickCore/pixel-accessor.h"
77 #include "MagickCore/profile.h"
78 #include "MagickCore/property.h"
79 #include "MagickCore/quantize.h"
80 #include "MagickCore/quantum-private.h"
81 #include "MagickCore/registry.h"
82 #include "MagickCore/resize.h"
83 #include "MagickCore/resource_.h"
84 #include "MagickCore/segment.h"
85 #include "MagickCore/shear.h"
86 #include "MagickCore/signature.h"
87 #include "MagickCore/statistic.h"
88 #include "MagickCore/static.h"
89 #include "MagickCore/string_.h"
90 #include "MagickCore/string-private.h"
91 #include "MagickCore/transform.h"
92 #include "MagickCore/threshold.h"
93 #include "MagickCore/utility.h"
94 #if defined(MAGICKCORE_XML_DELEGATE)
95 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
96 # if defined(__MINGW32__)
99 # include <win32config.h>
102 # include <libxml/parser.h>
103 # include <libxml/xmlmemory.h>
104 # include <libxml/parserInternals.h>
105 # include <libxml/xmlerror.h>
111 #define ThrowMSLException(severity,tag,reason) \
112 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
116 Typedef declaractions.
118 typedef struct _MSLGroupInfo
121 numImages; /* how many images are in this group */
124 typedef struct _MSLInfo
149 #if defined(MAGICKCORE_XML_DELEGATE)
159 Forward declarations.
161 #if defined(MAGICKCORE_XML_DELEGATE)
162 static MagickBooleanType
163 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
165 static MagickBooleanType
166 SetMSLAttributes(MSLInfo *,const char *,const char *);
169 #if defined(MAGICKCORE_XML_DELEGATE)
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 % R e a d M S L I m a g e %
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
183 % It allocates the memory necessary for the new Image structure and returns a
184 % pointer to the new image.
186 % The format of the ReadMSLImage method is:
188 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
190 % A description of each parameter follows:
192 % o image_info: the image info.
194 % o exception: return any errors or warnings in this structure.
198 #if defined(__cplusplus) || defined(c_plusplus)
202 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
203 ExceptionInfo *exception)
217 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
218 sans_exception=AcquireExceptionInfo();
219 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
220 sans_exception=DestroyExceptionInfo(sans_exception);
221 if (image != (Image *) NULL)
223 read_info=CloneImageInfo(image_info);
224 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
225 image=ReadImage(read_info,exception);
226 read_info=DestroyImageInfo(read_info);
227 if (image != (Image *) NULL)
228 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
232 static int IsPathDirectory(const char *path)
240 if ((path == (const char *) NULL) || (*path == '\0'))
242 status=GetPathAttributes(path,&attributes);
243 if (status == MagickFalse)
245 if (S_ISDIR(attributes.st_mode) == 0)
250 static int MSLIsStandalone(void *context)
256 Is this document tagged standalone?
258 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
259 msl_info=(MSLInfo *) context;
260 return(msl_info->document->standalone == 1);
263 static int MSLHasInternalSubset(void *context)
269 Does this document has an internal subset?
271 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
272 " SAX.MSLHasInternalSubset()");
273 msl_info=(MSLInfo *) context;
274 return(msl_info->document->intSubset != NULL);
277 static int MSLHasExternalSubset(void *context)
283 Does this document has an external subset?
285 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
286 " SAX.MSLHasExternalSubset()");
287 msl_info=(MSLInfo *) context;
288 return(msl_info->document->extSubset != NULL);
291 static void MSLInternalSubset(void *context,const xmlChar *name,
292 const xmlChar *external_id,const xmlChar *system_id)
298 Does this document has an internal subset?
300 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
301 " SAX.internalSubset(%s %s %s)",name,
302 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
303 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
304 msl_info=(MSLInfo *) context;
305 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
308 static xmlParserInputPtr MSLResolveEntity(void *context,
309 const xmlChar *public_id,const xmlChar *system_id)
318 Special entity resolver, better left to the parser, it has more
319 context than the application layer. The default behaviour is to
320 not resolve the entities, in that case the ENTITY_REF nodes are
321 built in the structure (and the parameter values).
323 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
324 " SAX.resolveEntity(%s, %s)",
325 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
326 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
327 msl_info=(MSLInfo *) context;
328 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
329 public_id,msl_info->parser);
333 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
339 Get an entity by name.
341 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
342 " SAX.MSLGetEntity(%s)",(const char *) name);
343 msl_info=(MSLInfo *) context;
344 return(xmlGetDocEntity(msl_info->document,name));
347 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
353 Get a parameter entity by name.
355 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
356 " SAX.getParameterEntity(%s)",(const char *) name);
357 msl_info=(MSLInfo *) context;
358 return(xmlGetParameterEntity(msl_info->document,name));
361 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
362 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
368 An entity definition has been parsed.
370 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
371 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
372 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
373 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
375 msl_info=(MSLInfo *) context;
376 if (msl_info->parser->inSubset == 1)
377 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
380 if (msl_info->parser->inSubset == 2)
381 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
385 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
386 const xmlChar *name,int type,int value,const xmlChar *default_value,
387 xmlEnumerationPtr tree)
400 An attribute definition has been parsed.
402 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
403 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
405 msl_info=(MSLInfo *) context;
406 fullname=(xmlChar *) NULL;
407 prefix=(xmlChar *) NULL;
408 parser=msl_info->parser;
409 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
410 if (parser->inSubset == 1)
411 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
412 element,fullname,prefix,(xmlAttributeType) type,
413 (xmlAttributeDefault) value,default_value,tree);
415 if (parser->inSubset == 2)
416 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
417 element,fullname,prefix,(xmlAttributeType) type,
418 (xmlAttributeDefault) value,default_value,tree);
419 if (prefix != (xmlChar *) NULL)
421 if (fullname != (xmlChar *) NULL)
425 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
426 xmlElementContentPtr content)
435 An element definition has been parsed.
437 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
438 " SAX.elementDecl(%s, %d, ...)",name,type);
439 msl_info=(MSLInfo *) context;
440 parser=msl_info->parser;
441 if (parser->inSubset == 1)
442 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
443 name,(xmlElementTypeVal) type,content);
445 if (parser->inSubset == 2)
446 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
447 name,(xmlElementTypeVal) type,content);
450 static void MSLNotationDeclaration(void *context,const xmlChar *name,
451 const xmlChar *public_id,const xmlChar *system_id)
460 What to do when a notation declaration has been parsed.
462 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
463 " SAX.notationDecl(%s, %s, %s)",name,
464 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
465 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
466 msl_info=(MSLInfo *) context;
467 parser=msl_info->parser;
468 if (parser->inSubset == 1)
469 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
470 name,public_id,system_id);
472 if (parser->inSubset == 2)
473 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
474 name,public_id,system_id);
477 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
478 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
484 What to do when an unparsed entity declaration is parsed.
486 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
487 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
488 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
489 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
491 msl_info=(MSLInfo *) context;
492 (void) xmlAddDocEntity(msl_info->document,name,
493 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
497 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
503 Receive the document locator at startup, actually xmlDefaultSAXLocator.
505 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
506 " SAX.setDocumentLocator()\n");
508 msl_info=(MSLInfo *) context;
512 static void MSLStartDocument(void *context)
521 Called when the document start being processed.
523 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
524 " SAX.startDocument()");
525 msl_info=(MSLInfo *) context;
526 parser=msl_info->parser;
527 msl_info->document=xmlNewDoc(parser->version);
528 if (msl_info->document == (xmlDocPtr) NULL)
530 if (parser->encoding == NULL)
531 msl_info->document->encoding=NULL;
533 msl_info->document->encoding=xmlStrdup(parser->encoding);
534 msl_info->document->standalone=parser->standalone;
537 static void MSLEndDocument(void *context)
543 Called when the document end has been detected.
545 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
546 msl_info=(MSLInfo *) context;
547 if (msl_info->content != (char *) NULL)
548 msl_info->content=DestroyString(msl_info->content);
551 static void MSLPushImage(MSLInfo *msl_info,Image *image)
556 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
557 assert(msl_info != (MSLInfo *) NULL);
560 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
561 (n+1),sizeof(*msl_info->image_info));
562 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
563 (n+1),sizeof(*msl_info->draw_info));
564 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
565 (n+1),sizeof(*msl_info->attributes));
566 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
567 sizeof(*msl_info->image));
568 if ((msl_info->image_info == (ImageInfo **) NULL) ||
569 (msl_info->draw_info == (DrawInfo **) NULL) ||
570 (msl_info->attributes == (Image **) NULL) ||
571 (msl_info->image == (Image **) NULL))
572 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
573 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
574 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
575 msl_info->draw_info[n-1]);
576 if (image == (Image *) NULL)
577 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
578 msl_info->exception);
580 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
581 msl_info->exception);
582 msl_info->image[n]=(Image *) image;
583 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
584 (msl_info->attributes[n] == (Image *) NULL))
585 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
586 if (msl_info->number_groups != 0)
587 msl_info->group_info[msl_info->number_groups-1].numImages++;
590 static void MSLPopImage(MSLInfo *msl_info)
592 if (msl_info->number_groups != 0)
594 if (msl_info->image[msl_info->n] != (Image *) NULL)
595 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
596 msl_info->attributes[msl_info->n]=DestroyImage(
597 msl_info->attributes[msl_info->n]);
598 msl_info->image_info[msl_info->n]=DestroyImageInfo(
599 msl_info->image_info[msl_info->n]);
603 static void MSLStartElement(void *context,const xmlChar *tag,
604 const xmlChar **attributes)
663 Called when an opening tag has been processed.
665 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
666 " SAX.startElement(%s",tag);
667 GetExceptionInfo(&exception);
668 msl_info=(MSLInfo *) context;
670 keyword=(const char *) NULL;
672 SetGeometryInfo(&geometry_info);
673 channel=DefaultChannels;
679 if (LocaleCompare((const char *) tag,"add-noise") == 0)
690 if (msl_info->image[n] == (Image *) NULL)
692 ThrowMSLException(OptionError,"NoImagesDefined",
697 if (attributes != (const xmlChar **) NULL)
698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
700 keyword=(const char *) attributes[i++];
701 attribute=InterpretImageProperties(msl_info->image_info[n],
702 msl_info->attributes[n],(const char *) attributes[i],
704 CloneString(&value,attribute);
710 if (LocaleCompare(keyword,"channel") == 0)
712 option=ParseChannelOption(value);
714 ThrowMSLException(OptionError,"UnrecognizedChannelType",
716 channel=(ChannelType) option;
719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
726 if (LocaleCompare(keyword,"noise") == 0)
728 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
731 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
733 noise=(NoiseType) option;
736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
748 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
749 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
750 msl_info->exception);
751 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
752 if (noise_image == (Image *) NULL)
754 msl_info->image[n]=DestroyImage(msl_info->image[n]);
755 msl_info->image[n]=noise_image;
758 if (LocaleCompare((const char *) tag,"annotate") == 0)
766 if (msl_info->image[n] == (Image *) NULL)
768 ThrowMSLException(OptionError,"NoImagesDefined",
772 draw_info=CloneDrawInfo(msl_info->image_info[n],
773 msl_info->draw_info[n]);
775 current=draw_info->affine;
776 GetAffineMatrix(&affine);
777 if (attributes != (const xmlChar **) NULL)
778 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
780 keyword=(const char *) attributes[i++];
781 attribute=InterpretImageProperties(msl_info->image_info[n],
782 msl_info->attributes[n],(const char *) attributes[i],
784 CloneString(&value,attribute);
790 if (LocaleCompare(keyword,"affine") == 0)
796 draw_info->affine.sx=StringToDouble(p,&p);
799 draw_info->affine.rx=StringToDouble(p,&p);
802 draw_info->affine.ry=StringToDouble(p,&p);
805 draw_info->affine.sy=StringToDouble(p,&p);
808 draw_info->affine.tx=StringToDouble(p,&p);
811 draw_info->affine.ty=StringToDouble(p,&p);
814 if (LocaleCompare(keyword,"align") == 0)
816 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
819 ThrowMSLException(OptionError,"UnrecognizedAlignType",
821 draw_info->align=(AlignType) option;
824 if (LocaleCompare(keyword,"antialias") == 0)
826 option=ParseCommandOption(MagickBooleanOptions,
829 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
831 draw_info->stroke_antialias=(MagickBooleanType) option;
832 draw_info->text_antialias=(MagickBooleanType) option;
835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
842 if (LocaleCompare(keyword,"density") == 0)
844 CloneString(&draw_info->density,value);
847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
854 if (LocaleCompare(keyword,"encoding") == 0)
856 CloneString(&draw_info->encoding,value);
859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
866 if (LocaleCompare(keyword, "fill") == 0)
868 (void) QueryColorCompliance(value,AllCompliance,
869 &draw_info->fill,&exception);
872 if (LocaleCompare(keyword,"family") == 0)
874 CloneString(&draw_info->family,value);
877 if (LocaleCompare(keyword,"font") == 0)
879 CloneString(&draw_info->font,value);
882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
889 if (LocaleCompare(keyword,"geometry") == 0)
891 flags=ParseGravityGeometry(msl_info->image[n],value,
892 &geometry,&exception);
895 if (LocaleCompare(keyword,"gravity") == 0)
897 option=ParseCommandOption(MagickGravityOptions,
900 ThrowMSLException(OptionError,"UnrecognizedGravityType",
902 draw_info->gravity=(GravityType) option;
905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
912 if (LocaleCompare(keyword,"pointsize") == 0)
914 draw_info->pointsize=StringToDouble(value,(char **) NULL);
917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
924 if (LocaleCompare(keyword,"rotate") == 0)
926 angle=StringToDouble(value,(char **) NULL);
927 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
928 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
929 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
930 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
940 if (LocaleCompare(keyword,"scale") == 0)
942 flags=ParseGeometry(value,&geometry_info);
943 if ((flags & SigmaValue) == 0)
944 geometry_info.sigma=1.0;
945 affine.sx=geometry_info.rho;
946 affine.sy=geometry_info.sigma;
949 if (LocaleCompare(keyword,"skewX") == 0)
951 angle=StringToDouble(value,(char **) NULL);
952 affine.ry=tan(DegreesToRadians(fmod((double) angle,
956 if (LocaleCompare(keyword,"skewY") == 0)
958 angle=StringToDouble(value,(char **) NULL);
959 affine.rx=tan(DegreesToRadians(fmod((double) angle,
963 if (LocaleCompare(keyword,"stretch") == 0)
965 option=ParseCommandOption(MagickStretchOptions,
968 ThrowMSLException(OptionError,"UnrecognizedStretchType",
970 draw_info->stretch=(StretchType) option;
973 if (LocaleCompare(keyword, "stroke") == 0)
975 (void) QueryColorCompliance(value,AllCompliance,
976 &draw_info->stroke,&exception);
979 if (LocaleCompare(keyword,"strokewidth") == 0)
981 draw_info->stroke_width=StringToLong(value);
984 if (LocaleCompare(keyword,"style") == 0)
986 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
989 ThrowMSLException(OptionError,"UnrecognizedStyleType",
991 draw_info->style=(StyleType) option;
994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1001 if (LocaleCompare(keyword,"text") == 0)
1003 CloneString(&draw_info->text,value);
1006 if (LocaleCompare(keyword,"translate") == 0)
1008 flags=ParseGeometry(value,&geometry_info);
1009 if ((flags & SigmaValue) == 0)
1010 geometry_info.sigma=1.0;
1011 affine.tx=geometry_info.rho;
1012 affine.ty=geometry_info.sigma;
1015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1022 if (LocaleCompare(keyword, "undercolor") == 0)
1024 (void) QueryColorCompliance(value,AllCompliance,
1025 &draw_info->undercolor,&exception);
1028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1035 if (LocaleCompare(keyword,"weight") == 0)
1037 draw_info->weight=StringToLong(value);
1040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1047 if (LocaleCompare(keyword,"x") == 0)
1049 geometry.x=StringToLong(value);
1052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1059 if (LocaleCompare(keyword,"y") == 0)
1061 geometry.y=StringToLong(value);
1064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1076 (void) FormatLocaleString(text,MaxTextExtent,
1077 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1078 geometry.height,(double) geometry.x,(double) geometry.y);
1079 CloneString(&draw_info->geometry,text);
1080 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1081 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1082 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1083 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1084 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1086 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1088 (void) AnnotateImage(msl_info->image[n],draw_info,
1089 msl_info->exception);
1090 draw_info=DestroyDrawInfo(draw_info);
1093 if (LocaleCompare((const char *) tag,"append") == 0)
1101 if (msl_info->image[n] == (Image *) NULL)
1103 ThrowMSLException(OptionError,"NoImagesDefined",
1104 (const char *) tag);
1108 if (attributes != (const xmlChar **) NULL)
1109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1111 keyword=(const char *) attributes[i++];
1112 attribute=InterpretImageProperties(msl_info->image_info[n],
1113 msl_info->attributes[n],(const char *) attributes[i],
1115 CloneString(&value,attribute);
1121 if (LocaleCompare(keyword,"stack") == 0)
1123 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1126 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1128 stack=(MagickBooleanType) option;
1131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1143 append_image=AppendImages(msl_info->image[n],stack,
1144 msl_info->exception);
1145 if (append_image == (Image *) NULL)
1147 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1148 msl_info->image[n]=append_image;
1151 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1157 if (LocaleCompare((const char *) tag,"blur") == 0)
1165 if (msl_info->image[n] == (Image *) NULL)
1167 ThrowMSLException(OptionError,"NoImagesDefined",
1168 (const char *) tag);
1171 if (attributes != (const xmlChar **) NULL)
1172 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1174 keyword=(const char *) attributes[i++];
1175 attribute=InterpretImageProperties(msl_info->image_info[n],
1176 msl_info->attributes[n],(const char *) attributes[i],
1178 CloneString(&value,attribute);
1184 if (LocaleCompare(keyword,"channel") == 0)
1186 option=ParseChannelOption(value);
1188 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1190 channel=(ChannelType) option;
1193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1200 if (LocaleCompare(keyword,"geometry") == 0)
1202 flags=ParseGeometry(value,&geometry_info);
1203 if ((flags & SigmaValue) == 0)
1204 geometry_info.sigma=1.0;
1207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1214 if (LocaleCompare(keyword,"radius") == 0)
1216 geometry_info.rho=StringToDouble(value,(char **) NULL);
1219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1226 if (LocaleCompare(keyword,"sigma") == 0)
1228 geometry_info.sigma=StringToLong(value);
1231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1243 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
1244 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1245 geometry_info.sigma,msl_info->exception);
1246 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
1247 if (blur_image == (Image *) NULL)
1249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1250 msl_info->image[n]=blur_image;
1253 if (LocaleCompare((const char *) tag,"border") == 0)
1261 if (msl_info->image[n] == (Image *) NULL)
1263 ThrowMSLException(OptionError,"NoImagesDefined",
1264 (const char *) tag);
1267 SetGeometry(msl_info->image[n],&geometry);
1268 if (attributes != (const xmlChar **) NULL)
1269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1271 keyword=(const char *) attributes[i++];
1272 attribute=InterpretImageProperties(msl_info->image_info[n],
1273 msl_info->attributes[n],(const char *) attributes[i],
1275 CloneString(&value,attribute);
1281 if (LocaleCompare(keyword,"compose") == 0)
1283 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1286 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1288 msl_info->image[n]->compose=(CompositeOperator) option;
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword, "fill") == 0)
1300 (void) QueryColorCompliance(value,AllCompliance,
1301 &msl_info->image[n]->border_color,&exception);
1304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1311 if (LocaleCompare(keyword,"geometry") == 0)
1313 flags=ParsePageGeometry(msl_info->image[n],value,
1314 &geometry,&exception);
1315 if ((flags & HeightValue) == 0)
1316 geometry.height=geometry.width;
1319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1326 if (LocaleCompare(keyword,"height") == 0)
1328 geometry.height=StringToLong(value);
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 if (LocaleCompare(keyword,"width") == 0)
1340 geometry.width=StringToLong(value);
1343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1355 border_image=BorderImage(msl_info->image[n],&geometry,
1356 msl_info->image[n]->compose,msl_info->exception);
1357 if (border_image == (Image *) NULL)
1359 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1360 msl_info->image[n]=border_image;
1363 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1368 if (LocaleCompare((const char *) tag,"colorize") == 0)
1371 blend[MaxTextExtent];
1382 if (msl_info->image[n] == (Image *) NULL)
1384 ThrowMSLException(OptionError,"NoImagesDefined",
1385 (const char *) tag);
1388 GetPixelInfo(msl_info->image[n],&target);
1389 (void) CopyMagickString(blend,"100",MaxTextExtent);
1390 if (attributes != (const xmlChar **) NULL)
1391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1393 keyword=(const char *) attributes[i++];
1394 attribute=InterpretImageProperties(msl_info->image_info[n],
1395 msl_info->attributes[n],(const char *) attributes[i],
1397 CloneString(&value,attribute);
1403 if (LocaleCompare(keyword,"blend") == 0)
1405 (void) CopyMagickString(blend,value,MaxTextExtent);
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 if (LocaleCompare(keyword,"fill") == 0)
1417 (void) QueryColorCompliance(value,AllCompliance,
1418 &target,msl_info->exception);
1421 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1433 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1434 msl_info->exception);
1435 if (colorize_image == (Image *) NULL)
1437 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1438 msl_info->image[n]=colorize_image;
1441 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1447 if (msl_info->image[n] == (Image *) NULL)
1449 ThrowMSLException(OptionError,"NoImagesDefined",
1450 (const char *) tag);
1454 NOTE: charcoal can have no attributes, since we use all the defaults!
1456 if (attributes != (const xmlChar **) NULL)
1458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1460 keyword=(const char *) attributes[i++];
1461 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1462 msl_info->attributes[n],(const char *) attributes[i],&exception));
1468 if (LocaleCompare(keyword,"radius") == 0)
1470 radius=StringToDouble(value,(char **) NULL);
1473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1479 if (LocaleCompare(keyword,"sigma") == 0)
1481 sigma = StringToLong( value );
1484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1503 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1504 msl_info->exception);
1505 if (newImage == (Image *) NULL)
1507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1508 msl_info->image[n]=newImage;
1512 if (LocaleCompare((const char *) tag,"chop") == 0)
1520 if (msl_info->image[n] == (Image *) NULL)
1522 ThrowMSLException(OptionError,"NoImagesDefined",
1523 (const char *) tag);
1526 SetGeometry(msl_info->image[n],&geometry);
1527 if (attributes != (const xmlChar **) NULL)
1528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1530 keyword=(const char *) attributes[i++];
1531 attribute=InterpretImageProperties(msl_info->image_info[n],
1532 msl_info->attributes[n],(const char *) attributes[i],
1534 CloneString(&value,attribute);
1540 if (LocaleCompare(keyword,"geometry") == 0)
1542 flags=ParsePageGeometry(msl_info->image[n],value,
1543 &geometry,&exception);
1544 if ((flags & HeightValue) == 0)
1545 geometry.height=geometry.width;
1548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1555 if (LocaleCompare(keyword,"height") == 0)
1557 geometry.height=StringToLong(value);
1560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1567 if (LocaleCompare(keyword,"width") == 0)
1569 geometry.width=StringToLong(value);
1572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 if (LocaleCompare(keyword,"x") == 0)
1581 geometry.x=StringToLong(value);
1584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1591 if (LocaleCompare(keyword,"y") == 0)
1593 geometry.y=StringToLong(value);
1596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1608 chop_image=ChopImage(msl_info->image[n],&geometry,
1609 msl_info->exception);
1610 if (chop_image == (Image *) NULL)
1612 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1613 msl_info->image[n]=chop_image;
1616 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1625 Color floodfill image.
1627 if (msl_info->image[n] == (Image *) NULL)
1629 ThrowMSLException(OptionError,"NoImagesDefined",
1630 (const char *) tag);
1633 draw_info=CloneDrawInfo(msl_info->image_info[n],
1634 msl_info->draw_info[n]);
1635 SetGeometry(msl_info->image[n],&geometry);
1636 paint_method=FloodfillMethod;
1637 if (attributes != (const xmlChar **) NULL)
1638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1640 keyword=(const char *) attributes[i++];
1641 attribute=InterpretImageProperties(msl_info->image_info[n],
1642 msl_info->attributes[n],(const char *) attributes[i],
1644 CloneString(&value,attribute);
1650 if (LocaleCompare(keyword,"bordercolor") == 0)
1652 (void) QueryColorCompliance(value,AllCompliance,
1653 &target,&exception);
1654 paint_method=FillToBorderMethod;
1657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1664 if (LocaleCompare(keyword,"fill") == 0)
1666 (void) QueryColorCompliance(value,AllCompliance,
1667 &draw_info->fill,&exception);
1670 if (LocaleCompare(keyword,"fuzz") == 0)
1672 msl_info->image[n]->fuzz=StringToDouble(value,
1676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1683 if (LocaleCompare(keyword,"geometry") == 0)
1685 flags=ParsePageGeometry(msl_info->image[n],value,
1686 &geometry,&exception);
1687 if ((flags & HeightValue) == 0)
1688 geometry.height=geometry.width;
1689 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1690 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1701 if (LocaleCompare(keyword,"x") == 0)
1703 geometry.x=StringToLong(value);
1704 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1705 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1716 if (LocaleCompare(keyword,"y") == 0)
1718 geometry.y=StringToLong(value);
1719 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1720 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1736 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1737 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1738 MagickFalse : MagickTrue,msl_info->exception);
1739 draw_info=DestroyDrawInfo(draw_info);
1742 if (LocaleCompare((const char *) tag,"comment") == 0)
1744 if (LocaleCompare((const char *) tag,"composite") == 0)
1747 composite_geometry[MaxTextExtent];
1759 if (msl_info->image[n] == (Image *) NULL)
1761 ThrowMSLException(OptionError,"NoImagesDefined",
1762 (const char *) tag);
1765 composite_image=NewImageList();
1766 compose=OverCompositeOp;
1767 if (attributes != (const xmlChar **) NULL)
1768 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1770 keyword=(const char *) attributes[i++];
1771 attribute=InterpretImageProperties(msl_info->image_info[n],
1772 msl_info->attributes[n],(const char *) attributes[i],
1774 CloneString(&value,attribute);
1780 if (LocaleCompare(keyword,"compose") == 0)
1782 option=ParseCommandOption(MagickComposeOptions,
1785 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1787 compose=(CompositeOperator) option;
1795 if (LocaleCompare(keyword,"image") == 0)
1796 for (j=0; j < msl_info->n; j++)
1801 attribute=GetImageProperty(msl_info->attributes[j],"id",
1803 if ((attribute != (const char *) NULL) &&
1804 (LocaleCompare(attribute,value) == 0))
1806 composite_image=CloneImage(msl_info->image[j],0,0,
1807 MagickFalse,&exception);
1817 if (composite_image == (Image *) NULL)
1819 rotate_image=NewImageList();
1820 SetGeometry(msl_info->image[n],&geometry);
1821 if (attributes != (const xmlChar **) NULL)
1822 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1824 keyword=(const char *) attributes[i++];
1825 attribute=InterpretImageProperties(msl_info->image_info[n],
1826 msl_info->attributes[n],(const char *) attributes[i],
1828 CloneString(&value,attribute);
1834 if (LocaleCompare(keyword,"blend") == 0)
1836 (void) SetImageArtifact(composite_image,
1837 "compose:args",value);
1840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1847 if (LocaleCompare(keyword,"channel") == 0)
1849 option=ParseChannelOption(value);
1851 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1853 channel=(ChannelType) option;
1856 if (LocaleCompare(keyword, "color") == 0)
1858 (void) QueryColorCompliance(value,AllCompliance,
1859 &composite_image->background_color,&exception);
1862 if (LocaleCompare(keyword,"compose") == 0)
1864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1871 if (LocaleCompare(keyword,"geometry") == 0)
1873 flags=ParsePageGeometry(msl_info->image[n],value,
1874 &geometry,&exception);
1875 if ((flags & HeightValue) == 0)
1876 geometry.height=geometry.width;
1879 if (LocaleCompare(keyword,"gravity") == 0)
1881 option=ParseCommandOption(MagickGravityOptions,
1884 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1886 msl_info->image[n]->gravity=(GravityType) option;
1889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1896 if (LocaleCompare(keyword,"image") == 0)
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"mask") == 0)
1906 for (j=0; j < msl_info->n; j++)
1911 attribute=GetImageProperty(msl_info->attributes[j],"id",
1913 if ((attribute != (const char *) NULL) &&
1914 (LocaleCompare(value,value) == 0))
1916 SetImageType(composite_image,TrueColorMatteType,
1918 (void) CompositeImage(composite_image,
1919 msl_info->image[j],CopyAlphaCompositeOp,MagickTrue,
1924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1931 if (LocaleCompare(keyword,"opacity") == 0)
1946 opacity=StringToLong(value);
1947 if (compose != DissolveCompositeOp)
1949 (void) SetImageAlpha(composite_image,(Quantum)
1950 opacity,&exception);
1953 (void) SetImageArtifact(msl_info->image[n],
1954 "compose:args",value);
1955 if (composite_image->matte != MagickTrue)
1956 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1958 composite_view=AcquireAuthenticCacheView(composite_image,
1960 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1962 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1963 (ssize_t) composite_image->columns,1,&exception);
1964 for (x=0; x < (ssize_t) composite_image->columns; x++)
1966 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1967 SetPixelAlpha(composite_image,
1968 ClampToQuantum(opacity),q);
1969 q+=GetPixelChannels(composite_image);
1971 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1974 composite_view=DestroyCacheView(composite_view);
1977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1984 if (LocaleCompare(keyword,"rotate") == 0)
1986 rotate_image=RotateImage(composite_image,
1987 StringToDouble(value,(char **) NULL),&exception);
1990 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1997 if (LocaleCompare(keyword,"tile") == 0)
2002 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2005 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2007 tile=(MagickBooleanType) option;
2009 if (rotate_image != (Image *) NULL)
2010 (void) SetImageArtifact(rotate_image,
2011 "compose:outside-overlay","false");
2013 (void) SetImageArtifact(composite_image,
2014 "compose:outside-overlay","false");
2015 image=msl_info->image[n];
2016 height=composite_image->rows;
2017 width=composite_image->columns;
2018 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2019 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2021 if (rotate_image != (Image *) NULL)
2022 (void) CompositeImage(image,rotate_image,compose,
2023 MagickTrue,x,y,&exception);
2025 (void) CompositeImage(image,composite_image,
2026 compose,MagickTrue,x,y,&exception);
2028 if (rotate_image != (Image *) NULL)
2029 rotate_image=DestroyImage(rotate_image);
2032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2039 if (LocaleCompare(keyword,"x") == 0)
2041 geometry.x=StringToLong(value);
2044 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2051 if (LocaleCompare(keyword,"y") == 0)
2053 geometry.y=StringToLong(value);
2056 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2068 image=msl_info->image[n];
2069 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2070 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2071 (double) composite_image->rows,(double) geometry.x,(double)
2073 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2075 channel_mask=SetImageChannelMask(image,channel);
2076 if (rotate_image == (Image *) NULL)
2077 CompositeImage(image,composite_image,compose,MagickTrue,geometry.x,
2078 geometry.y,&exception);
2084 geometry.x-=(ssize_t) (rotate_image->columns-
2085 composite_image->columns)/2;
2086 geometry.y-=(ssize_t) (rotate_image->rows-
2087 composite_image->rows)/2;
2088 CompositeImage(image,rotate_image,compose,MagickTrue,geometry.x,
2089 geometry.y,&exception);
2090 rotate_image=DestroyImage(rotate_image);
2092 (void) SetImageChannelMask(image,channel_mask);
2093 composite_image=DestroyImage(composite_image);
2096 if (LocaleCompare((const char *) tag,"contrast") == 0)
2104 if (msl_info->image[n] == (Image *) NULL)
2106 ThrowMSLException(OptionError,"NoImagesDefined",
2107 (const char *) tag);
2110 sharpen=MagickFalse;
2111 if (attributes != (const xmlChar **) NULL)
2112 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2114 keyword=(const char *) attributes[i++];
2115 attribute=InterpretImageProperties(msl_info->image_info[n],
2116 msl_info->attributes[n],(const char *) attributes[i],
2118 CloneString(&value,attribute);
2124 if (LocaleCompare(keyword,"sharpen") == 0)
2126 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2129 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2131 sharpen=(MagickBooleanType) option;
2134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2146 (void) ContrastImage(msl_info->image[n],sharpen,
2147 msl_info->exception);
2150 if (LocaleCompare((const char *) tag,"crop") == 0)
2158 if (msl_info->image[n] == (Image *) NULL)
2160 ThrowMSLException(OptionError,"NoImagesDefined",
2161 (const char *) tag);
2164 SetGeometry(msl_info->image[n],&geometry);
2165 if (attributes != (const xmlChar **) NULL)
2166 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2168 keyword=(const char *) attributes[i++];
2169 attribute=InterpretImageProperties(msl_info->image_info[n],
2170 msl_info->attributes[n],(const char *) attributes[i],
2172 CloneString(&value,attribute);
2178 if (LocaleCompare(keyword,"geometry") == 0)
2180 flags=ParseGravityGeometry(msl_info->image[n],value,
2181 &geometry,&exception);
2184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2191 if (LocaleCompare(keyword,"height") == 0)
2193 geometry.height=StringToLong(value);
2196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 if (LocaleCompare(keyword,"width") == 0)
2205 geometry.width=StringToLong(value);
2208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2215 if (LocaleCompare(keyword,"x") == 0)
2217 geometry.x=StringToLong(value);
2220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2227 if (LocaleCompare(keyword,"y") == 0)
2229 geometry.y=StringToLong(value);
2232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2244 crop_image=CropImage(msl_info->image[n],&geometry,
2245 msl_info->exception);
2246 if (crop_image == (Image *) NULL)
2248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2249 msl_info->image[n]=crop_image;
2252 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2258 Cycle-colormap image.
2260 if (msl_info->image[n] == (Image *) NULL)
2262 ThrowMSLException(OptionError,"NoImagesDefined",
2263 (const char *) tag);
2267 if (attributes != (const xmlChar **) NULL)
2268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2270 keyword=(const char *) attributes[i++];
2271 attribute=InterpretImageProperties(msl_info->image_info[n],
2272 msl_info->attributes[n],(const char *) attributes[i],
2274 CloneString(&value,attribute);
2280 if (LocaleCompare(keyword,"display") == 0)
2282 display=StringToLong(value);
2285 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2297 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2300 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2305 if (LocaleCompare((const char *) tag,"despeckle") == 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],
2326 CloneString(&value,attribute);
2327 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2329 despeckle_image=DespeckleImage(msl_info->image[n],
2330 msl_info->exception);
2331 if (despeckle_image == (Image *) NULL)
2333 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2334 msl_info->image[n]=despeckle_image;
2337 if (LocaleCompare((const char *) tag,"display") == 0)
2339 if (msl_info->image[n] == (Image *) NULL)
2341 ThrowMSLException(OptionError,"NoImagesDefined",
2342 (const char *) tag);
2345 if (attributes != (const xmlChar **) NULL)
2346 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2348 keyword=(const char *) attributes[i++];
2349 attribute=InterpretImageProperties(msl_info->image_info[n],
2350 msl_info->attributes[n],(const char *) attributes[i],
2352 CloneString(&value,attribute);
2357 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2363 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2364 msl_info->exception);
2367 if (LocaleCompare((const char *) tag,"draw") == 0)
2370 text[MaxTextExtent];
2375 if (msl_info->image[n] == (Image *) NULL)
2377 ThrowMSLException(OptionError,"NoImagesDefined",
2378 (const char *) tag);
2381 draw_info=CloneDrawInfo(msl_info->image_info[n],
2382 msl_info->draw_info[n]);
2384 current=draw_info->affine;
2385 GetAffineMatrix(&affine);
2386 if (attributes != (const xmlChar **) NULL)
2387 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2389 keyword=(const char *) attributes[i++];
2390 attribute=InterpretImageProperties(msl_info->image_info[n],
2391 msl_info->attributes[n],(const char *) attributes[i],
2393 CloneString(&value,attribute);
2399 if (LocaleCompare(keyword,"affine") == 0)
2405 draw_info->affine.sx=StringToDouble(p,&p);
2408 draw_info->affine.rx=StringToDouble(p,&p);
2411 draw_info->affine.ry=StringToDouble(p,&p);
2414 draw_info->affine.sy=StringToDouble(p,&p);
2417 draw_info->affine.tx=StringToDouble(p,&p);
2420 draw_info->affine.ty=StringToDouble(p,&p);
2423 if (LocaleCompare(keyword,"align") == 0)
2425 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2428 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2430 draw_info->align=(AlignType) option;
2433 if (LocaleCompare(keyword,"antialias") == 0)
2435 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2438 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2440 draw_info->stroke_antialias=(MagickBooleanType) option;
2441 draw_info->text_antialias=(MagickBooleanType) option;
2444 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2451 if (LocaleCompare(keyword,"density") == 0)
2453 CloneString(&draw_info->density,value);
2456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2463 if (LocaleCompare(keyword,"encoding") == 0)
2465 CloneString(&draw_info->encoding,value);
2468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2475 if (LocaleCompare(keyword, "fill") == 0)
2477 (void) QueryColorCompliance(value,AllCompliance,
2478 &draw_info->fill,&exception);
2481 if (LocaleCompare(keyword,"family") == 0)
2483 CloneString(&draw_info->family,value);
2486 if (LocaleCompare(keyword,"font") == 0)
2488 CloneString(&draw_info->font,value);
2491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2498 if (LocaleCompare(keyword,"geometry") == 0)
2500 flags=ParsePageGeometry(msl_info->image[n],value,
2501 &geometry,&exception);
2502 if ((flags & HeightValue) == 0)
2503 geometry.height=geometry.width;
2506 if (LocaleCompare(keyword,"gravity") == 0)
2508 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2511 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2513 draw_info->gravity=(GravityType) option;
2516 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2523 if (LocaleCompare(keyword,"primitive") == 0)
2525 CloneString(&draw_info->primitive,value);
2528 if (LocaleCompare(keyword,"pointsize") == 0)
2530 draw_info->pointsize=StringToDouble(value,
2534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2541 if (LocaleCompare(keyword,"rotate") == 0)
2543 angle=StringToDouble(value,(char **) NULL);
2544 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2545 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2546 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2547 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2550 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2557 if (LocaleCompare(keyword,"scale") == 0)
2559 flags=ParseGeometry(value,&geometry_info);
2560 if ((flags & SigmaValue) == 0)
2561 geometry_info.sigma=1.0;
2562 affine.sx=geometry_info.rho;
2563 affine.sy=geometry_info.sigma;
2566 if (LocaleCompare(keyword,"skewX") == 0)
2568 angle=StringToDouble(value,(char **) NULL);
2569 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2572 if (LocaleCompare(keyword,"skewY") == 0)
2574 angle=StringToDouble(value,(char **) NULL);
2575 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2578 if (LocaleCompare(keyword,"stretch") == 0)
2580 option=ParseCommandOption(MagickStretchOptions,
2583 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2585 draw_info->stretch=(StretchType) option;
2588 if (LocaleCompare(keyword, "stroke") == 0)
2590 (void) QueryColorCompliance(value,AllCompliance,
2591 &draw_info->stroke,&exception);
2594 if (LocaleCompare(keyword,"strokewidth") == 0)
2596 draw_info->stroke_width=StringToLong(value);
2599 if (LocaleCompare(keyword,"style") == 0)
2601 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2604 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2606 draw_info->style=(StyleType) option;
2609 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2616 if (LocaleCompare(keyword,"text") == 0)
2618 CloneString(&draw_info->text,value);
2621 if (LocaleCompare(keyword,"translate") == 0)
2623 flags=ParseGeometry(value,&geometry_info);
2624 if ((flags & SigmaValue) == 0)
2625 geometry_info.sigma=1.0;
2626 affine.tx=geometry_info.rho;
2627 affine.ty=geometry_info.sigma;
2630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2637 if (LocaleCompare(keyword, "undercolor") == 0)
2639 (void) QueryColorCompliance(value,AllCompliance,
2640 &draw_info->undercolor,&exception);
2643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2650 if (LocaleCompare(keyword,"weight") == 0)
2652 draw_info->weight=StringToLong(value);
2655 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2662 if (LocaleCompare(keyword,"x") == 0)
2664 geometry.x=StringToLong(value);
2667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2674 if (LocaleCompare(keyword,"y") == 0)
2676 geometry.y=StringToLong(value);
2679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2691 (void) FormatLocaleString(text,MaxTextExtent,
2692 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2693 geometry.height,(double) geometry.x,(double) geometry.y);
2694 CloneString(&draw_info->geometry,text);
2695 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2696 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2697 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2698 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2699 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2701 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2703 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2704 draw_info=DestroyDrawInfo(draw_info);
2707 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2712 if (LocaleCompare((const char *) tag,"edge") == 0)
2720 if (msl_info->image[n] == (Image *) NULL)
2722 ThrowMSLException(OptionError,"NoImagesDefined",
2723 (const char *) tag);
2726 if (attributes != (const xmlChar **) NULL)
2727 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2729 keyword=(const char *) attributes[i++];
2730 attribute=InterpretImageProperties(msl_info->image_info[n],
2731 msl_info->attributes[n],(const char *) attributes[i],
2733 CloneString(&value,attribute);
2739 if (LocaleCompare(keyword,"geometry") == 0)
2741 flags=ParseGeometry(value,&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=1.0;
2746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2753 if (LocaleCompare(keyword,"radius") == 0)
2755 geometry_info.rho=StringToDouble(value,(char **) NULL);
2758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2770 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2771 geometry_info.sigma,msl_info->exception);
2772 if (edge_image == (Image *) NULL)
2774 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2775 msl_info->image[n]=edge_image;
2778 if (LocaleCompare((const char *) tag,"emboss") == 0)
2786 if (msl_info->image[n] == (Image *) NULL)
2788 ThrowMSLException(OptionError,"NoImagesDefined",
2789 (const char *) tag);
2792 if (attributes != (const xmlChar **) NULL)
2793 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2795 keyword=(const char *) attributes[i++];
2796 attribute=InterpretImageProperties(msl_info->image_info[n],
2797 msl_info->attributes[n],(const char *) attributes[i],
2799 CloneString(&value,attribute);
2805 if (LocaleCompare(keyword,"geometry") == 0)
2807 flags=ParseGeometry(value,&geometry_info);
2808 if ((flags & SigmaValue) == 0)
2809 geometry_info.sigma=1.0;
2812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2819 if (LocaleCompare(keyword,"radius") == 0)
2821 geometry_info.rho=StringToDouble(value,
2825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2832 if (LocaleCompare(keyword,"sigma") == 0)
2834 geometry_info.sigma=StringToLong(value);
2837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2849 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2850 geometry_info.sigma,msl_info->exception);
2851 if (emboss_image == (Image *) NULL)
2853 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2854 msl_info->image[n]=emboss_image;
2857 if (LocaleCompare((const char *) tag,"enhance") == 0)
2865 if (msl_info->image[n] == (Image *) NULL)
2867 ThrowMSLException(OptionError,"NoImagesDefined",
2868 (const char *) tag);
2871 if (attributes != (const xmlChar **) NULL)
2872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2874 keyword=(const char *) attributes[i++];
2875 attribute=InterpretImageProperties(msl_info->image_info[n],
2876 msl_info->attributes[n],(const char *) attributes[i],
2878 CloneString(&value,attribute);
2879 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2881 enhance_image=EnhanceImage(msl_info->image[n],
2882 msl_info->exception);
2883 if (enhance_image == (Image *) NULL)
2885 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2886 msl_info->image[n]=enhance_image;
2889 if (LocaleCompare((const char *) tag,"equalize") == 0)
2894 if (msl_info->image[n] == (Image *) NULL)
2896 ThrowMSLException(OptionError,"NoImagesDefined",
2897 (const char *) tag);
2900 if (attributes != (const xmlChar **) NULL)
2901 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2903 keyword=(const char *) attributes[i++];
2904 attribute=InterpretImageProperties(msl_info->image_info[n],
2905 msl_info->attributes[n],(const char *) attributes[i],
2907 CloneString(&value,attribute);
2912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2918 (void) EqualizeImage(msl_info->image[n],
2919 msl_info->exception);
2922 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2927 if (LocaleCompare((const char *) tag, "flatten") == 0)
2929 if (msl_info->image[n] == (Image *) NULL)
2931 ThrowMSLException(OptionError,"NoImagesDefined",
2932 (const char *) tag);
2936 /* no attributes here */
2938 /* process the image */
2943 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2944 msl_info->exception);
2945 if (newImage == (Image *) NULL)
2947 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2948 msl_info->image[n]=newImage;
2952 if (LocaleCompare((const char *) tag,"flip") == 0)
2960 if (msl_info->image[n] == (Image *) NULL)
2962 ThrowMSLException(OptionError,"NoImagesDefined",
2963 (const char *) tag);
2966 if (attributes != (const xmlChar **) NULL)
2967 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2969 keyword=(const char *) attributes[i++];
2970 attribute=InterpretImageProperties(msl_info->image_info[n],
2971 msl_info->attributes[n],(const char *) attributes[i],
2973 CloneString(&value,attribute);
2974 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2976 flip_image=FlipImage(msl_info->image[n],
2977 msl_info->exception);
2978 if (flip_image == (Image *) NULL)
2980 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2981 msl_info->image[n]=flip_image;
2984 if (LocaleCompare((const char *) tag,"flop") == 0)
2992 if (msl_info->image[n] == (Image *) NULL)
2994 ThrowMSLException(OptionError,"NoImagesDefined",
2995 (const char *) tag);
2998 if (attributes != (const xmlChar **) NULL)
2999 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3001 keyword=(const char *) attributes[i++];
3002 attribute=InterpretImageProperties(msl_info->image_info[n],
3003 msl_info->attributes[n],(const char *) attributes[i],
3005 CloneString(&value,attribute);
3006 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3008 flop_image=FlopImage(msl_info->image[n],
3009 msl_info->exception);
3010 if (flop_image == (Image *) NULL)
3012 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3013 msl_info->image[n]=flop_image;
3016 if (LocaleCompare((const char *) tag,"frame") == 0)
3027 if (msl_info->image[n] == (Image *) NULL)
3029 ThrowMSLException(OptionError,"NoImagesDefined",
3030 (const char *) tag);
3033 SetGeometry(msl_info->image[n],&geometry);
3034 if (attributes != (const xmlChar **) NULL)
3035 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3037 keyword=(const char *) attributes[i++];
3038 attribute=InterpretImageProperties(msl_info->image_info[n],
3039 msl_info->attributes[n],(const char *) attributes[i],
3041 CloneString(&value,attribute);
3047 if (LocaleCompare(keyword,"compose") == 0)
3049 option=ParseCommandOption(MagickComposeOptions,
3052 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3054 msl_info->image[n]->compose=(CompositeOperator) option;
3057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3064 if (LocaleCompare(keyword, "fill") == 0)
3066 (void) QueryColorCompliance(value,AllCompliance,
3067 &msl_info->image[n]->matte_color,&exception);
3070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3077 if (LocaleCompare(keyword,"geometry") == 0)
3079 flags=ParsePageGeometry(msl_info->image[n],value,
3080 &geometry,&exception);
3081 if ((flags & HeightValue) == 0)
3082 geometry.height=geometry.width;
3083 frame_info.width=geometry.width;
3084 frame_info.height=geometry.height;
3085 frame_info.outer_bevel=geometry.x;
3086 frame_info.inner_bevel=geometry.y;
3089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3096 if (LocaleCompare(keyword,"height") == 0)
3098 frame_info.height=StringToLong(value);
3101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3108 if (LocaleCompare(keyword,"inner") == 0)
3110 frame_info.inner_bevel=StringToLong(value);
3113 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3120 if (LocaleCompare(keyword,"outer") == 0)
3122 frame_info.outer_bevel=StringToLong(value);
3125 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3132 if (LocaleCompare(keyword,"width") == 0)
3134 frame_info.width=StringToLong(value);
3137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3149 frame_info.x=(ssize_t) frame_info.width;
3150 frame_info.y=(ssize_t) frame_info.height;
3151 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3152 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3153 frame_image=FrameImage(msl_info->image[n],&frame_info,
3154 msl_info->image[n]->compose,msl_info->exception);
3155 if (frame_image == (Image *) NULL)
3157 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3158 msl_info->image[n]=frame_image;
3161 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3166 if (LocaleCompare((const char *) tag,"gamma") == 0)
3169 gamma[MaxTextExtent];
3177 if (msl_info->image[n] == (Image *) NULL)
3179 ThrowMSLException(OptionError,"NoImagesDefined",
3180 (const char *) tag);
3183 channel=UndefinedChannel;
3188 if (attributes != (const xmlChar **) NULL)
3189 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3191 keyword=(const char *) attributes[i++];
3192 attribute=InterpretImageProperties(msl_info->image_info[n],
3193 msl_info->attributes[n],(const char *) attributes[i],
3195 CloneString(&value,attribute);
3201 if (LocaleCompare(keyword,"blue") == 0)
3203 pixel.blue=StringToDouble(value,(char **) NULL);
3206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3213 if (LocaleCompare(keyword,"channel") == 0)
3215 option=ParseChannelOption(value);
3217 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3219 channel=(ChannelType) option;
3222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3229 if (LocaleCompare(keyword,"gamma") == 0)
3231 (void) CopyMagickString(gamma,value,MaxTextExtent);
3234 if (LocaleCompare(keyword,"green") == 0)
3236 pixel.green=StringToDouble(value,(char **) NULL);
3239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3246 if (LocaleCompare(keyword,"red") == 0)
3248 pixel.red=StringToDouble(value,(char **) NULL);
3251 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3257 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3264 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3265 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3266 (void) GammaImage(msl_info->image[n],atof(gamma),
3267 msl_info->exception);
3270 else if (LocaleCompare((const char *) tag,"get") == 0)
3272 if (msl_info->image[n] == (Image *) NULL)
3274 ThrowMSLException(OptionError,"NoImagesDefined",
3275 (const char *) tag);
3278 if (attributes == (const xmlChar **) NULL)
3280 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3282 keyword=(const char *) attributes[i++];
3283 CloneString(&value,(const char *) attributes[i]);
3284 (void) CopyMagickString(key,value,MaxTextExtent);
3290 if (LocaleCompare(keyword,"height") == 0)
3292 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3293 (double) msl_info->image[n]->rows);
3294 (void) SetImageProperty(msl_info->attributes[n],key,value,
3298 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3303 if (LocaleCompare(keyword,"width") == 0)
3305 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3306 (double) msl_info->image[n]->columns);
3307 (void) SetImageProperty(msl_info->attributes[n],key,value,
3311 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3315 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3322 else if (LocaleCompare((const char *) tag, "group") == 0)
3324 msl_info->number_groups++;
3325 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3326 msl_info->group_info,msl_info->number_groups+1UL,
3327 sizeof(*msl_info->group_info));
3330 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3335 if (LocaleCompare((const char *) tag,"image") == 0)
3337 MSLPushImage(msl_info,(Image *) NULL);
3338 if (attributes == (const xmlChar **) NULL)
3340 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3342 keyword=(const char *) attributes[i++];
3343 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3344 msl_info->attributes[n],(const char *) attributes[i],&exception));
3350 if (LocaleCompare(keyword,"color") == 0)
3355 (void) CopyMagickString(msl_info->image_info[n]->filename,
3356 "xc:",MaxTextExtent);
3357 (void) ConcatenateMagickString(msl_info->image_info[n]->
3358 filename,value,MaxTextExtent);
3359 next_image=ReadImage(msl_info->image_info[n],&exception);
3360 CatchException(&exception);
3361 if (next_image == (Image *) NULL)
3363 if (msl_info->image[n] == (Image *) NULL)
3364 msl_info->image[n]=next_image;
3371 Link image into image list.
3373 p=msl_info->image[n];
3374 while (p->next != (Image *) NULL)
3375 p=GetNextImageInList(p);
3376 next_image->previous=p;
3381 (void) SetMSLAttributes(msl_info,keyword,value);
3386 (void) SetMSLAttributes(msl_info,keyword,value);
3393 if (LocaleCompare((const char *) tag,"implode") == 0)
3401 if (msl_info->image[n] == (Image *) NULL)
3403 ThrowMSLException(OptionError,"NoImagesDefined",
3404 (const char *) tag);
3407 if (attributes != (const xmlChar **) NULL)
3408 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3410 keyword=(const char *) attributes[i++];
3411 attribute=InterpretImageProperties(msl_info->image_info[n],
3412 msl_info->attributes[n],(const char *) attributes[i],
3414 CloneString(&value,attribute);
3420 if (LocaleCompare(keyword,"amount") == 0)
3422 geometry_info.rho=StringToDouble(value,
3426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3433 if (LocaleCompare(keyword,"geometry") == 0)
3435 flags=ParseGeometry(value,&geometry_info);
3436 if ((flags & SigmaValue) == 0)
3437 geometry_info.sigma=1.0;
3440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3446 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3452 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3453 msl_info->image[n]->interpolate,msl_info->exception);
3454 if (implode_image == (Image *) NULL)
3456 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3457 msl_info->image[n]=implode_image;
3460 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3465 if (LocaleCompare((const char *) tag,"label") == 0)
3467 if (LocaleCompare((const char *) tag, "level") == 0)
3470 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3472 if (msl_info->image[n] == (Image *) NULL)
3474 ThrowMSLException(OptionError,"NoImagesDefined",
3475 (const char *) tag);
3478 if (attributes == (const xmlChar **) NULL)
3480 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3482 keyword=(const char *) attributes[i++];
3483 CloneString(&value,(const char *) attributes[i]);
3484 (void) CopyMagickString(key,value,MaxTextExtent);
3490 if (LocaleCompare(keyword,"black") == 0)
3492 levelBlack = StringToDouble(value,(char **) NULL);
3495 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3501 if (LocaleCompare(keyword,"gamma") == 0)
3503 levelGamma = StringToDouble(value,(char **) NULL);
3506 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3512 if (LocaleCompare(keyword,"white") == 0)
3514 levelWhite = StringToDouble(value,(char **) NULL);
3517 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3522 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3529 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3530 msl_info->exception);
3537 if (LocaleCompare((const char *) tag,"magnify") == 0)
3545 if (msl_info->image[n] == (Image *) NULL)
3547 ThrowMSLException(OptionError,"NoImagesDefined",
3548 (const char *) tag);
3551 if (attributes != (const xmlChar **) NULL)
3552 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3554 keyword=(const char *) attributes[i++];
3555 attribute=InterpretImageProperties(msl_info->image_info[n],
3556 msl_info->attributes[n],(const char *) attributes[i],
3558 CloneString(&value,attribute);
3559 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3561 magnify_image=MagnifyImage(msl_info->image[n],
3562 msl_info->exception);
3563 if (magnify_image == (Image *) NULL)
3565 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3566 msl_info->image[n]=magnify_image;
3569 if (LocaleCompare((const char *) tag,"map") == 0)
3583 if (msl_info->image[n] == (Image *) NULL)
3585 ThrowMSLException(OptionError,"NoImagesDefined",
3586 (const char *) tag);
3589 affinity_image=NewImageList();
3591 if (attributes != (const xmlChar **) NULL)
3592 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3594 keyword=(const char *) attributes[i++];
3595 attribute=InterpretImageProperties(msl_info->image_info[n],
3596 msl_info->attributes[n],(const char *) attributes[i],
3598 CloneString(&value,attribute);
3604 if (LocaleCompare(keyword,"dither") == 0)
3606 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3609 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3611 dither=(MagickBooleanType) option;
3614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3621 if (LocaleCompare(keyword,"image") == 0)
3622 for (j=0; j < msl_info->n; j++)
3627 attribute=GetImageProperty(msl_info->attributes[j],"id",
3629 if ((attribute != (const char *) NULL) &&
3630 (LocaleCompare(attribute,value) == 0))
3632 affinity_image=CloneImage(msl_info->image[j],0,0,
3633 MagickFalse,&exception);
3641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3647 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3648 quantize_info->dither_method=dither != MagickFalse ?
3649 RiemersmaDitherMethod : NoDitherMethod;
3650 (void) RemapImages(quantize_info,msl_info->image[n],
3651 affinity_image,&exception);
3652 quantize_info=DestroyQuantizeInfo(quantize_info);
3653 affinity_image=DestroyImage(affinity_image);
3656 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3668 Matte floodfill image.
3671 if (msl_info->image[n] == (Image *) NULL)
3673 ThrowMSLException(OptionError,"NoImagesDefined",
3674 (const char *) tag);
3677 SetGeometry(msl_info->image[n],&geometry);
3678 paint_method=FloodfillMethod;
3679 if (attributes != (const xmlChar **) NULL)
3680 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3682 keyword=(const char *) attributes[i++];
3683 attribute=InterpretImageProperties(msl_info->image_info[n],
3684 msl_info->attributes[n],(const char *) attributes[i],
3686 CloneString(&value,attribute);
3692 if (LocaleCompare(keyword,"bordercolor") == 0)
3694 (void) QueryColorCompliance(value,AllCompliance,
3695 &target,&exception);
3696 paint_method=FillToBorderMethod;
3699 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3706 if (LocaleCompare(keyword,"fuzz") == 0)
3708 msl_info->image[n]->fuzz=StringToDouble(value,
3712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3719 if (LocaleCompare(keyword,"geometry") == 0)
3721 flags=ParsePageGeometry(msl_info->image[n],value,
3722 &geometry,&exception);
3723 if ((flags & HeightValue) == 0)
3724 geometry.height=geometry.width;
3725 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3726 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3737 if (LocaleCompare(keyword,"opacity") == 0)
3739 opacity=StringToDouble(value,(char **) NULL);
3742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3749 if (LocaleCompare(keyword,"x") == 0)
3751 geometry.x=StringToLong(value);
3752 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3753 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3757 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3764 if (LocaleCompare(keyword,"y") == 0)
3766 geometry.y=StringToLong(value);
3767 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3768 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3778 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3784 draw_info=CloneDrawInfo(msl_info->image_info[n],
3785 msl_info->draw_info[n]);
3786 draw_info->fill.alpha=ClampToQuantum(opacity);
3787 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3788 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3789 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3790 MagickFalse : MagickTrue,msl_info->exception);
3791 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3792 draw_info=DestroyDrawInfo(draw_info);
3795 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3801 Median-filter image.
3803 if (msl_info->image[n] == (Image *) NULL)
3805 ThrowMSLException(OptionError,"NoImagesDefined",
3806 (const char *) tag);
3809 if (attributes != (const xmlChar **) NULL)
3810 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3812 keyword=(const char *) attributes[i++];
3813 attribute=InterpretImageProperties(msl_info->image_info[n],
3814 msl_info->attributes[n],(const char *) attributes[i],
3816 CloneString(&value,attribute);
3822 if (LocaleCompare(keyword,"geometry") == 0)
3824 flags=ParseGeometry(value,&geometry_info);
3825 if ((flags & SigmaValue) == 0)
3826 geometry_info.sigma=1.0;
3829 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3836 if (LocaleCompare(keyword,"radius") == 0)
3838 geometry_info.rho=StringToDouble(value,
3842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3848 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3854 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3855 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3856 msl_info->exception);
3857 if (median_image == (Image *) NULL)
3859 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3860 msl_info->image[n]=median_image;
3863 if (LocaleCompare((const char *) tag,"minify") == 0)
3871 if (msl_info->image[n] == (Image *) NULL)
3873 ThrowMSLException(OptionError,"NoImagesDefined",
3874 (const char *) tag);
3877 if (attributes != (const xmlChar **) NULL)
3878 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3880 keyword=(const char *) attributes[i++];
3881 attribute=InterpretImageProperties(msl_info->image_info[n],
3882 msl_info->attributes[n],(const char *) attributes[i],
3884 CloneString(&value,attribute);
3885 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3887 minify_image=MinifyImage(msl_info->image[n],
3888 msl_info->exception);
3889 if (minify_image == (Image *) NULL)
3891 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3892 msl_info->image[n]=minify_image;
3895 if (LocaleCompare((const char *) tag,"msl") == 0 )
3897 if (LocaleCompare((const char *) tag,"modulate") == 0)
3900 modulate[MaxTextExtent];
3905 if (msl_info->image[n] == (Image *) NULL)
3907 ThrowMSLException(OptionError,"NoImagesDefined",
3908 (const char *) tag);
3911 geometry_info.rho=100.0;
3912 geometry_info.sigma=100.0;
3913 geometry_info.xi=100.0;
3914 if (attributes != (const xmlChar **) NULL)
3915 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3917 keyword=(const char *) attributes[i++];
3918 attribute=InterpretImageProperties(msl_info->image_info[n],
3919 msl_info->attributes[n],(const char *) attributes[i],
3921 CloneString(&value,attribute);
3927 if (LocaleCompare(keyword,"blackness") == 0)
3929 geometry_info.rho=StringToDouble(value,
3933 if (LocaleCompare(keyword,"brightness") == 0)
3935 geometry_info.rho=StringToDouble(value,
3939 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3946 if (LocaleCompare(keyword,"factor") == 0)
3948 flags=ParseGeometry(value,&geometry_info);
3951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3958 if (LocaleCompare(keyword,"hue") == 0)
3960 geometry_info.xi=StringToDouble(value,
3964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3971 if (LocaleCompare(keyword,"lightness") == 0)
3973 geometry_info.rho=StringToDouble(value,
3977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3984 if (LocaleCompare(keyword,"saturation") == 0)
3986 geometry_info.sigma=StringToDouble(value,
3990 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3997 if (LocaleCompare(keyword,"whiteness") == 0)
3999 geometry_info.sigma=StringToDouble(value,
4003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4009 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4015 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4016 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4017 (void) ModulateImage(msl_info->image[n],modulate,
4018 msl_info->exception);
4021 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4026 if (LocaleCompare((const char *) tag,"negate") == 0)
4034 if (msl_info->image[n] == (Image *) NULL)
4036 ThrowMSLException(OptionError,"NoImagesDefined",
4037 (const char *) tag);
4041 if (attributes != (const xmlChar **) NULL)
4042 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4044 keyword=(const char *) attributes[i++];
4045 attribute=InterpretImageProperties(msl_info->image_info[n],
4046 msl_info->attributes[n],(const char *) attributes[i],
4048 CloneString(&value,attribute);
4054 if (LocaleCompare(keyword,"channel") == 0)
4056 option=ParseChannelOption(value);
4058 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4060 channel=(ChannelType) option;
4063 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4070 if (LocaleCompare(keyword,"gray") == 0)
4072 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4075 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4077 gray=(MagickBooleanType) option;
4080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4086 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4092 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4093 (void) NegateImage(msl_info->image[n],gray,
4094 msl_info->exception);
4095 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4098 if (LocaleCompare((const char *) tag,"normalize") == 0)
4103 if (msl_info->image[n] == (Image *) NULL)
4105 ThrowMSLException(OptionError,"NoImagesDefined",
4106 (const char *) tag);
4109 if (attributes != (const xmlChar **) NULL)
4110 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4112 keyword=(const char *) attributes[i++];
4113 attribute=InterpretImageProperties(msl_info->image_info[n],
4114 msl_info->attributes[n],(const char *) attributes[i],
4116 CloneString(&value,attribute);
4122 if (LocaleCompare(keyword,"channel") == 0)
4124 option=ParseChannelOption(value);
4126 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4128 channel=(ChannelType) option;
4131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4143 (void) NormalizeImage(msl_info->image[n],
4144 msl_info->exception);
4147 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4152 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4160 if (msl_info->image[n] == (Image *) NULL)
4162 ThrowMSLException(OptionError,"NoImagesDefined",
4163 (const char *) tag);
4166 if (attributes != (const xmlChar **) NULL)
4167 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4169 keyword=(const char *) attributes[i++];
4170 attribute=InterpretImageProperties(msl_info->image_info[n],
4171 msl_info->attributes[n],(const char *) attributes[i],
4173 CloneString(&value,attribute);
4179 if (LocaleCompare(keyword,"geometry") == 0)
4181 flags=ParseGeometry(value,&geometry_info);
4182 if ((flags & SigmaValue) == 0)
4183 geometry_info.sigma=1.0;
4186 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4193 if (LocaleCompare(keyword,"radius") == 0)
4195 geometry_info.rho=StringToDouble(value,
4199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4211 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4212 geometry_info.sigma,msl_info->exception);
4213 if (paint_image == (Image *) NULL)
4215 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4216 msl_info->image[n]=paint_image;
4219 if (LocaleCompare((const char *) tag,"opaque") == 0)
4228 if (msl_info->image[n] == (Image *) NULL)
4230 ThrowMSLException(OptionError,"NoImagesDefined",
4231 (const char *) tag);
4234 (void) QueryColorCompliance("none",AllCompliance,&target,
4236 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4238 if (attributes != (const xmlChar **) NULL)
4239 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4241 keyword=(const char *) attributes[i++];
4242 attribute=InterpretImageProperties(msl_info->image_info[n],
4243 msl_info->attributes[n],(const char *) attributes[i],
4245 CloneString(&value,attribute);
4251 if (LocaleCompare(keyword,"channel") == 0)
4253 option=ParseChannelOption(value);
4255 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4257 channel=(ChannelType) option;
4260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4267 if (LocaleCompare(keyword,"fill") == 0)
4269 (void) QueryColorCompliance(value,AllCompliance,
4270 &fill_color,&exception);
4273 if (LocaleCompare(keyword,"fuzz") == 0)
4275 msl_info->image[n]->fuzz=StringToDouble(value,
4279 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4285 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4291 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4292 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4293 MagickFalse,msl_info->exception);
4294 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4297 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4302 if (LocaleCompare((const char *) tag,"print") == 0)
4304 if (attributes == (const xmlChar **) NULL)
4306 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4308 keyword=(const char *) attributes[i++];
4309 attribute=InterpretImageProperties(msl_info->image_info[n],
4310 msl_info->attributes[n],(const char *) attributes[i],
4312 CloneString(&value,attribute);
4318 if (LocaleCompare(keyword,"output") == 0)
4320 (void) FormatLocaleFile(stdout,"%s",value);
4323 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4335 if (LocaleCompare((const char *) tag, "profile") == 0)
4337 if (msl_info->image[n] == (Image *) NULL)
4339 ThrowMSLException(OptionError,"NoImagesDefined",
4340 (const char *) tag);
4343 if (attributes == (const xmlChar **) NULL)
4345 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4359 keyword=(const char *) attributes[i++];
4360 attribute=InterpretImageProperties(msl_info->image_info[n],
4361 msl_info->attributes[n],(const char *) attributes[i],
4363 CloneString(&value,attribute);
4364 if (*keyword == '!')
4367 Remove a profile from the image.
4369 (void) ProfileImage(msl_info->image[n],keyword,
4370 (const unsigned char *) NULL,0,&exception);
4374 Associate a profile with the image.
4376 profile_info=CloneImageInfo(msl_info->image_info[n]);
4377 profile=GetImageProfile(msl_info->image[n],"iptc");
4378 if (profile != (StringInfo *) NULL)
4379 profile_info->profile=(void *) CloneStringInfo(profile);
4380 profile_image=GetImageCache(profile_info,keyword,&exception);
4381 profile_info=DestroyImageInfo(profile_info);
4382 if (profile_image == (Image *) NULL)
4385 name[MaxTextExtent],
4386 filename[MaxTextExtent];
4394 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4395 (void) CopyMagickString(name,keyword,MaxTextExtent);
4396 for (p=filename; *p != '\0'; p++)
4397 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4398 (IsPathAccessible(keyword) == MagickFalse))
4404 Look for profile name (e.g. name:profile).
4406 (void) CopyMagickString(name,filename,(size_t)
4408 for (q=filename; *q != '\0'; q++)
4412 profile=FileToStringInfo(filename,~0UL,&exception);
4413 if (profile != (StringInfo *) NULL)
4415 (void) ProfileImage(msl_info->image[n],name,
4416 GetStringInfoDatum(profile),(size_t)
4417 GetStringInfoLength(profile),&exception);
4418 profile=DestroyStringInfo(profile);
4422 ResetImageProfileIterator(profile_image);
4423 name=GetNextImageProfile(profile_image);
4424 while (name != (const char *) NULL)
4426 profile=GetImageProfile(profile_image,name);
4427 if (profile != (StringInfo *) NULL)
4428 (void) ProfileImage(msl_info->image[n],name,
4429 GetStringInfoDatum(profile),(size_t)
4430 GetStringInfoLength(profile),&exception);
4431 name=GetNextImageProfile(profile_image);
4433 profile_image=DestroyImage(profile_image);
4437 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4442 if (LocaleCompare((const char *) tag,"quantize") == 0)
4450 if (msl_info->image[n] == (Image *) NULL)
4452 ThrowMSLException(OptionError,"NoImagesDefined",
4453 (const char *) tag);
4456 GetQuantizeInfo(&quantize_info);
4457 if (attributes != (const xmlChar **) NULL)
4458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4460 keyword=(const char *) attributes[i++];
4461 attribute=InterpretImageProperties(msl_info->image_info[n],
4462 msl_info->attributes[n],(const char *) attributes[i],
4464 CloneString(&value,attribute);
4470 if (LocaleCompare(keyword,"colors") == 0)
4472 quantize_info.number_colors=StringToLong(value);
4475 if (LocaleCompare(keyword,"colorspace") == 0)
4477 option=ParseCommandOption(MagickColorspaceOptions,
4480 ThrowMSLException(OptionError,
4481 "UnrecognizedColorspaceType",value);
4482 quantize_info.colorspace=(ColorspaceType) option;
4485 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4492 if (LocaleCompare(keyword,"dither") == 0)
4494 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4497 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4499 quantize_info.dither_method=(DitherMethod) option;
4502 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4509 if (LocaleCompare(keyword,"measure") == 0)
4511 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4514 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4516 quantize_info.measure_error=(MagickBooleanType) option;
4519 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4526 if (LocaleCompare(keyword,"treedepth") == 0)
4528 quantize_info.tree_depth=StringToLong(value);
4531 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4537 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4543 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4546 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4549 text[MaxTextExtent];
4560 draw_info=CloneDrawInfo(msl_info->image_info[n],
4561 msl_info->draw_info[n]);
4563 current=draw_info->affine;
4564 GetAffineMatrix(&affine);
4565 if (attributes != (const xmlChar **) NULL)
4566 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4568 keyword=(const char *) attributes[i++];
4569 attribute=InterpretImageProperties(msl_info->image_info[n],
4570 msl_info->attributes[n],(const char *) attributes[i],
4572 CloneString(&value,attribute);
4578 if (LocaleCompare(keyword,"affine") == 0)
4584 draw_info->affine.sx=StringToDouble(p,&p);
4587 draw_info->affine.rx=StringToDouble(p,&p);
4590 draw_info->affine.ry=StringToDouble(p,&p);
4593 draw_info->affine.sy=StringToDouble(p,&p);
4596 draw_info->affine.tx=StringToDouble(p,&p);
4599 draw_info->affine.ty=StringToDouble(p,&p);
4602 if (LocaleCompare(keyword,"align") == 0)
4604 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4607 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4609 draw_info->align=(AlignType) option;
4612 if (LocaleCompare(keyword,"antialias") == 0)
4614 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4617 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4619 draw_info->stroke_antialias=(MagickBooleanType) option;
4620 draw_info->text_antialias=(MagickBooleanType) option;
4623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4630 if (LocaleCompare(keyword,"density") == 0)
4632 CloneString(&draw_info->density,value);
4635 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4642 if (LocaleCompare(keyword,"encoding") == 0)
4644 CloneString(&draw_info->encoding,value);
4647 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4654 if (LocaleCompare(keyword, "fill") == 0)
4656 (void) QueryColorCompliance(value,AllCompliance,
4657 &draw_info->fill,&exception);
4660 if (LocaleCompare(keyword,"family") == 0)
4662 CloneString(&draw_info->family,value);
4665 if (LocaleCompare(keyword,"font") == 0)
4667 CloneString(&draw_info->font,value);
4670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4677 if (LocaleCompare(keyword,"geometry") == 0)
4679 flags=ParsePageGeometry(msl_info->image[n],value,
4680 &geometry,&exception);
4681 if ((flags & HeightValue) == 0)
4682 geometry.height=geometry.width;
4685 if (LocaleCompare(keyword,"gravity") == 0)
4687 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4690 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4692 draw_info->gravity=(GravityType) option;
4695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4702 if (LocaleCompare(keyword,"pointsize") == 0)
4704 draw_info->pointsize=StringToDouble(value,
4708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4715 if (LocaleCompare(keyword,"rotate") == 0)
4717 angle=StringToDouble(value,(char **) NULL);
4718 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4719 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4720 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4721 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4731 if (LocaleCompare(keyword,"scale") == 0)
4733 flags=ParseGeometry(value,&geometry_info);
4734 if ((flags & SigmaValue) == 0)
4735 geometry_info.sigma=1.0;
4736 affine.sx=geometry_info.rho;
4737 affine.sy=geometry_info.sigma;
4740 if (LocaleCompare(keyword,"skewX") == 0)
4742 angle=StringToDouble(value,(char **) NULL);
4743 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4746 if (LocaleCompare(keyword,"skewY") == 0)
4748 angle=StringToDouble(value,(char **) NULL);
4749 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4752 if (LocaleCompare(keyword,"stretch") == 0)
4754 option=ParseCommandOption(MagickStretchOptions,
4757 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4759 draw_info->stretch=(StretchType) option;
4762 if (LocaleCompare(keyword, "stroke") == 0)
4764 (void) QueryColorCompliance(value,AllCompliance,
4765 &draw_info->stroke,&exception);
4768 if (LocaleCompare(keyword,"strokewidth") == 0)
4770 draw_info->stroke_width=StringToLong(value);
4773 if (LocaleCompare(keyword,"style") == 0)
4775 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4778 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4780 draw_info->style=(StyleType) option;
4783 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4790 if (LocaleCompare(keyword,"text") == 0)
4792 CloneString(&draw_info->text,value);
4795 if (LocaleCompare(keyword,"translate") == 0)
4797 flags=ParseGeometry(value,&geometry_info);
4798 if ((flags & SigmaValue) == 0)
4799 geometry_info.sigma=1.0;
4800 affine.tx=geometry_info.rho;
4801 affine.ty=geometry_info.sigma;
4804 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4811 if (LocaleCompare(keyword, "undercolor") == 0)
4813 (void) QueryColorCompliance(value,AllCompliance,
4814 &draw_info->undercolor,&exception);
4817 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4824 if (LocaleCompare(keyword,"weight") == 0)
4826 draw_info->weight=StringToLong(value);
4829 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4836 if (LocaleCompare(keyword,"x") == 0)
4838 geometry.x=StringToLong(value);
4841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4848 if (LocaleCompare(keyword,"y") == 0)
4850 geometry.y=StringToLong(value);
4853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4865 (void) FormatLocaleString(text,MaxTextExtent,
4866 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4867 geometry.height,(double) geometry.x,(double) geometry.y);
4868 CloneString(&draw_info->geometry,text);
4869 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4870 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4871 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4872 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4873 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4875 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4877 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4878 msl_info->exception);
4879 if (status != MagickFalse)
4884 image=msl_info->attributes[n];
4885 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4886 "%g",metrics.pixels_per_em.x);
4887 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4888 "%g",metrics.pixels_per_em.y);
4889 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4891 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4893 FormatImageProperty(image,"msl:font-metrics.width","%g",
4895 FormatImageProperty(image,"msl:font-metrics.height","%g",
4897 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4898 metrics.max_advance);
4899 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4901 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4903 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4905 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4907 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4909 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4912 draw_info=DestroyDrawInfo(draw_info);
4915 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4920 if (LocaleCompare((const char *) tag,"raise") == 0)
4928 if (msl_info->image[n] == (Image *) NULL)
4930 ThrowMSLException(OptionError,"NoImagesDefined",
4931 (const char *) tag);
4935 SetGeometry(msl_info->image[n],&geometry);
4936 if (attributes != (const xmlChar **) NULL)
4937 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4939 keyword=(const char *) attributes[i++];
4940 attribute=InterpretImageProperties(msl_info->image_info[n],
4941 msl_info->attributes[n],(const char *) attributes[i],
4943 CloneString(&value,attribute);
4949 if (LocaleCompare(keyword,"geometry") == 0)
4951 flags=ParsePageGeometry(msl_info->image[n],value,
4952 &geometry,&exception);
4953 if ((flags & HeightValue) == 0)
4954 geometry.height=geometry.width;
4957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4964 if (LocaleCompare(keyword,"height") == 0)
4966 geometry.height=StringToLong(value);
4969 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4976 if (LocaleCompare(keyword,"raise") == 0)
4978 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4981 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4983 raise=(MagickBooleanType) option;
4986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4993 if (LocaleCompare(keyword,"width") == 0)
4995 geometry.width=StringToLong(value);
4998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5010 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5011 msl_info->exception);
5014 if (LocaleCompare((const char *) tag,"read") == 0)
5016 if (attributes == (const xmlChar **) NULL)
5018 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5020 keyword=(const char *) attributes[i++];
5021 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5022 msl_info->attributes[n],(const char *) attributes[i],&exception));
5028 if (LocaleCompare(keyword,"filename") == 0)
5033 (void) CopyMagickString(msl_info->image_info[n]->filename,
5034 value,MaxTextExtent);
5035 image=ReadImage(msl_info->image_info[n],&exception);
5036 CatchException(&exception);
5037 if (image == (Image *) NULL)
5039 AppendImageToList(&msl_info->image[n],image);
5042 (void) SetMSLAttributes(msl_info,keyword,value);
5047 (void) SetMSLAttributes(msl_info,keyword,value);
5054 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5062 if (msl_info->image[n] == (Image *) NULL)
5064 ThrowMSLException(OptionError,"NoImagesDefined",
5065 (const char *) tag);
5068 if (attributes != (const xmlChar **) NULL)
5069 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5071 keyword=(const char *) attributes[i++];
5072 attribute=InterpretImageProperties(msl_info->image_info[n],
5073 msl_info->attributes[n],(const char *) attributes[i],
5075 CloneString(&value,attribute);
5081 if (LocaleCompare(keyword,"geometry") == 0)
5083 flags=ParseGeometry(value,&geometry_info);
5084 if ((flags & SigmaValue) == 0)
5085 geometry_info.sigma=1.0;
5088 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5095 if (LocaleCompare(keyword,"radius") == 0)
5097 geometry_info.rho=StringToDouble(value,
5101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5113 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5114 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5115 msl_info->exception);
5116 if (paint_image == (Image *) NULL)
5118 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5119 msl_info->image[n]=paint_image;
5122 else if (LocaleCompare((const char *) tag,"repage") == 0)
5124 /* init the values */
5125 width=msl_info->image[n]->page.width;
5126 height=msl_info->image[n]->page.height;
5127 x=msl_info->image[n]->page.x;
5128 y=msl_info->image[n]->page.y;
5130 if (msl_info->image[n] == (Image *) NULL)
5132 ThrowMSLException(OptionError,"NoImagesDefined",
5133 (const char *) tag);
5136 if (attributes == (const xmlChar **) NULL)
5138 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5140 keyword=(const char *) attributes[i++];
5141 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5142 msl_info->attributes[n],(const char *) attributes[i],&exception));
5148 if (LocaleCompare(keyword,"geometry") == 0)
5156 flags=ParseAbsoluteGeometry(value,&geometry);
5157 if ((flags & WidthValue) != 0)
5159 if ((flags & HeightValue) == 0)
5160 geometry.height=geometry.width;
5161 width=geometry.width;
5162 height=geometry.height;
5164 if ((flags & AspectValue) != 0)
5166 if ((flags & XValue) != 0)
5168 if ((flags & YValue) != 0)
5173 if ((flags & XValue) != 0)
5176 if ((width == 0) && (geometry.x > 0))
5177 width=msl_info->image[n]->columns+geometry.x;
5179 if ((flags & YValue) != 0)
5182 if ((height == 0) && (geometry.y > 0))
5183 height=msl_info->image[n]->rows+geometry.y;
5188 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5194 if (LocaleCompare(keyword,"height") == 0)
5196 height = StringToLong( value );
5199 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5205 if (LocaleCompare(keyword,"width") == 0)
5207 width = StringToLong( value );
5210 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5216 if (LocaleCompare(keyword,"x") == 0)
5218 x = StringToLong( value );
5221 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5227 if (LocaleCompare(keyword,"y") == 0)
5229 y = StringToLong( value );
5232 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5237 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5243 msl_info->image[n]->page.width=width;
5244 msl_info->image[n]->page.height=height;
5245 msl_info->image[n]->page.x=x;
5246 msl_info->image[n]->page.y=y;
5249 else if (LocaleCompare((const char *) tag,"resample") == 0)
5255 if (msl_info->image[n] == (Image *) NULL)
5257 ThrowMSLException(OptionError,"NoImagesDefined",
5258 (const char *) tag);
5261 if (attributes == (const xmlChar **) NULL)
5263 x_resolution=DefaultResolution;
5264 y_resolution=DefaultResolution;
5265 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5267 keyword=(const char *) attributes[i++];
5268 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5269 msl_info->attributes[n],(const char *) attributes[i],&exception));
5275 if (LocaleCompare(keyword,"geometry") == 0)
5280 flags=ParseGeometry(value,&geometry_info);
5281 if ((flags & SigmaValue) == 0)
5282 geometry_info.sigma*=geometry_info.rho;
5283 x_resolution=geometry_info.rho;
5284 y_resolution=geometry_info.sigma;
5287 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5293 if (LocaleCompare(keyword,"x-resolution") == 0)
5295 x_resolution=StringToDouble(value,(char **) NULL);
5298 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5304 if (LocaleCompare(keyword,"y-resolution") == 0)
5306 y_resolution=StringToDouble(value,(char **) NULL);
5309 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5330 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5332 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5333 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5334 msl_info->image[n]->resolution.x))+0.5);
5335 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5336 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5337 msl_info->image[n]->resolution.y))+0.5);
5338 resample_image=ResizeImage(msl_info->image[n],width,height,
5339 msl_info->image[n]->filter,msl_info->exception);
5340 if (resample_image == (Image *) NULL)
5342 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5343 msl_info->image[n]=resample_image;
5347 if (LocaleCompare((const char *) tag,"resize") == 0)
5358 if (msl_info->image[n] == (Image *) NULL)
5360 ThrowMSLException(OptionError,"NoImagesDefined",
5361 (const char *) tag);
5364 filter=UndefinedFilter;
5365 if (attributes != (const xmlChar **) NULL)
5366 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5368 keyword=(const char *) attributes[i++];
5369 attribute=InterpretImageProperties(msl_info->image_info[n],
5370 msl_info->attributes[n],(const char *) attributes[i],
5372 CloneString(&value,attribute);
5378 if (LocaleCompare(keyword,"filter") == 0)
5380 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5383 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5385 filter=(FilterTypes) option;
5388 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5395 if (LocaleCompare(keyword,"geometry") == 0)
5397 flags=ParseRegionGeometry(msl_info->image[n],value,
5398 &geometry,&exception);
5401 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5408 if (LocaleCompare(keyword,"height") == 0)
5410 geometry.height=StringToUnsignedLong(value);
5413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5420 if (LocaleCompare(keyword,"width") == 0)
5422 geometry.width=StringToLong(value);
5425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5431 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5437 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5438 geometry.height,filter,msl_info->exception);
5439 if (resize_image == (Image *) NULL)
5441 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5442 msl_info->image[n]=resize_image;
5445 if (LocaleCompare((const char *) tag,"roll") == 0)
5453 if (msl_info->image[n] == (Image *) NULL)
5455 ThrowMSLException(OptionError,"NoImagesDefined",
5456 (const char *) tag);
5459 SetGeometry(msl_info->image[n],&geometry);
5460 if (attributes != (const xmlChar **) NULL)
5461 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5463 keyword=(const char *) attributes[i++];
5464 attribute=InterpretImageProperties(msl_info->image_info[n],
5465 msl_info->attributes[n],(const char *) attributes[i],
5467 CloneString(&value,attribute);
5473 if (LocaleCompare(keyword,"geometry") == 0)
5475 flags=ParsePageGeometry(msl_info->image[n],value,
5476 &geometry,&exception);
5477 if ((flags & HeightValue) == 0)
5478 geometry.height=geometry.width;
5481 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5488 if (LocaleCompare(keyword,"x") == 0)
5490 geometry.x=StringToLong(value);
5493 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5500 if (LocaleCompare(keyword,"y") == 0)
5502 geometry.y=StringToLong(value);
5505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5511 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5517 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5518 msl_info->exception);
5519 if (roll_image == (Image *) NULL)
5521 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5522 msl_info->image[n]=roll_image;
5525 else if (LocaleCompare((const char *) tag,"roll") == 0)
5527 /* init the values */
5528 width=msl_info->image[n]->columns;
5529 height=msl_info->image[n]->rows;
5532 if (msl_info->image[n] == (Image *) NULL)
5534 ThrowMSLException(OptionError,"NoImagesDefined",
5535 (const char *) tag);
5538 if (attributes == (const xmlChar **) NULL)
5540 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5542 keyword=(const char *) attributes[i++];
5543 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5544 msl_info->attributes[n],(const char *) attributes[i],&exception));
5550 if (LocaleCompare(keyword,"geometry") == 0)
5552 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5555 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5561 if (LocaleCompare(keyword,"x") == 0)
5563 x = StringToLong( value );
5566 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5572 if (LocaleCompare(keyword,"y") == 0)
5574 y = StringToLong( value );
5577 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5582 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5595 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5596 if (newImage == (Image *) NULL)
5598 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5599 msl_info->image[n]=newImage;
5604 if (LocaleCompare((const char *) tag,"rotate") == 0)
5612 if (msl_info->image[n] == (Image *) NULL)
5614 ThrowMSLException(OptionError,"NoImagesDefined",
5615 (const char *) tag);
5618 if (attributes != (const xmlChar **) NULL)
5619 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5621 keyword=(const char *) attributes[i++];
5622 attribute=InterpretImageProperties(msl_info->image_info[n],
5623 msl_info->attributes[n],(const char *) attributes[i],
5625 CloneString(&value,attribute);
5631 if (LocaleCompare(keyword,"degrees") == 0)
5633 geometry_info.rho=StringToDouble(value,
5637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5644 if (LocaleCompare(keyword,"geometry") == 0)
5646 flags=ParseGeometry(value,&geometry_info);
5647 if ((flags & SigmaValue) == 0)
5648 geometry_info.sigma=1.0;
5651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5663 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5664 msl_info->exception);
5665 if (rotate_image == (Image *) NULL)
5667 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5668 msl_info->image[n]=rotate_image;
5671 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5673 /* init the values */
5676 if (msl_info->image[n] == (Image *) NULL)
5678 ThrowMSLException(OptionError,"NoImagesDefined",
5679 (const char *) tag);
5682 if (attributes == (const xmlChar **) NULL)
5684 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5686 keyword=(const char *) attributes[i++];
5687 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5688 msl_info->attributes[n],(const char *) attributes[i],&exception));
5694 if (LocaleCompare(keyword,"degrees") == 0)
5696 degrees = StringToDouble(value,(char **) NULL);
5699 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5704 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5717 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5718 if (newImage == (Image *) NULL)
5720 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5721 msl_info->image[n]=newImage;
5726 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5731 if (LocaleCompare((const char *) tag,"sample") == 0)
5739 if (msl_info->image[n] == (Image *) NULL)
5741 ThrowMSLException(OptionError,"NoImagesDefined",
5742 (const char *) tag);
5745 if (attributes != (const xmlChar **) NULL)
5746 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5748 keyword=(const char *) attributes[i++];
5749 attribute=InterpretImageProperties(msl_info->image_info[n],
5750 msl_info->attributes[n],(const char *) attributes[i],
5752 CloneString(&value,attribute);
5758 if (LocaleCompare(keyword,"geometry") == 0)
5760 flags=ParseRegionGeometry(msl_info->image[n],value,
5761 &geometry,&exception);
5764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5771 if (LocaleCompare(keyword,"height") == 0)
5773 geometry.height=StringToUnsignedLong(value);
5776 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5783 if (LocaleCompare(keyword,"width") == 0)
5785 geometry.width=StringToLong(value);
5788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5800 sample_image=SampleImage(msl_info->image[n],geometry.width,
5801 geometry.height,msl_info->exception);
5802 if (sample_image == (Image *) NULL)
5804 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5805 msl_info->image[n]=sample_image;
5808 if (LocaleCompare((const char *) tag,"scale") == 0)
5816 if (msl_info->image[n] == (Image *) NULL)
5818 ThrowMSLException(OptionError,"NoImagesDefined",
5819 (const char *) tag);
5822 if (attributes != (const xmlChar **) NULL)
5823 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5825 keyword=(const char *) attributes[i++];
5826 attribute=InterpretImageProperties(msl_info->image_info[n],
5827 msl_info->attributes[n],(const char *) attributes[i],
5829 CloneString(&value,attribute);
5835 if (LocaleCompare(keyword,"geometry") == 0)
5837 flags=ParseRegionGeometry(msl_info->image[n],value,
5838 &geometry,&exception);
5841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5848 if (LocaleCompare(keyword,"height") == 0)
5850 geometry.height=StringToUnsignedLong(value);
5853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5860 if (LocaleCompare(keyword,"width") == 0)
5862 geometry.width=StringToLong(value);
5865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5871 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5877 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5878 geometry.height,msl_info->exception);
5879 if (scale_image == (Image *) NULL)
5881 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5882 msl_info->image[n]=scale_image;
5885 if (LocaleCompare((const char *) tag,"segment") == 0)
5896 if (msl_info->image[n] == (Image *) NULL)
5898 ThrowMSLException(OptionError,"NoImagesDefined",
5899 (const char *) tag);
5902 geometry_info.rho=1.0;
5903 geometry_info.sigma=1.5;
5904 colorspace=sRGBColorspace;
5905 verbose=MagickFalse;
5906 if (attributes != (const xmlChar **) NULL)
5907 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5909 keyword=(const char *) attributes[i++];
5910 attribute=InterpretImageProperties(msl_info->image_info[n],
5911 msl_info->attributes[n],(const char *) attributes[i],
5913 CloneString(&value,attribute);
5919 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5921 geometry_info.rho=StringToDouble(value,
5925 if (LocaleCompare(keyword,"colorspace") == 0)
5927 option=ParseCommandOption(MagickColorspaceOptions,
5930 ThrowMSLException(OptionError,
5931 "UnrecognizedColorspaceType",value);
5932 colorspace=(ColorspaceType) option;
5935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5942 if (LocaleCompare(keyword,"geometry") == 0)
5944 flags=ParseGeometry(value,&geometry_info);
5945 if ((flags & SigmaValue) == 0)
5946 geometry_info.sigma=1.5;
5949 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5956 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5958 geometry_info.sigma=StringToDouble(value,
5962 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5968 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5974 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5975 geometry_info.rho,geometry_info.sigma,&exception);
5978 else if (LocaleCompare((const char *) tag, "set") == 0)
5980 if (msl_info->image[n] == (Image *) NULL)
5982 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5986 if (attributes == (const xmlChar **) NULL)
5988 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5990 keyword=(const char *) attributes[i++];
5991 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5992 msl_info->attributes[n],(const char *) attributes[i],&exception));
5998 if (LocaleCompare(keyword,"clip-mask") == 0)
6000 for (j=0; j < msl_info->n; j++)
6005 property=GetImageProperty(msl_info->attributes[j],"id",
6007 if (LocaleCompare(property,value) == 0)
6009 SetImageMask(msl_info->image[n],msl_info->image[j],
6016 if (LocaleCompare(keyword,"clip-path") == 0)
6018 for (j=0; j < msl_info->n; j++)
6023 property=GetImageProperty(msl_info->attributes[j],"id",
6025 if (LocaleCompare(property,value) == 0)
6027 SetImageMask(msl_info->image[n],msl_info->image[j],
6034 if (LocaleCompare(keyword,"colorspace") == 0)
6039 colorspace=(ColorspaceType) ParseCommandOption(
6040 MagickColorspaceOptions,MagickFalse,value);
6042 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6044 (void) TransformImageColorspace(msl_info->image[n],
6045 (ColorspaceType) colorspace,&exception);
6048 (void) SetMSLAttributes(msl_info,keyword,value);
6049 (void) SetImageProperty(msl_info->image[n],keyword,value,
6056 if (LocaleCompare(keyword,"density") == 0)
6058 flags=ParseGeometry(value,&geometry_info);
6059 msl_info->image[n]->resolution.x=geometry_info.rho;
6060 msl_info->image[n]->resolution.y=geometry_info.sigma;
6061 if ((flags & SigmaValue) == 0)
6062 msl_info->image[n]->resolution.y=
6063 msl_info->image[n]->resolution.x;
6066 (void) SetMSLAttributes(msl_info,keyword,value);
6067 (void) SetImageProperty(msl_info->image[n],keyword,value,
6074 if (LocaleCompare(keyword, "opacity") == 0)
6076 ssize_t opac = OpaqueAlpha,
6077 len = (ssize_t) strlen( value );
6079 if (value[len-1] == '%') {
6081 (void) CopyMagickString(tmp,value,len);
6082 opac = StringToLong( tmp );
6083 opac = (int)(QuantumRange * ((float)opac/100));
6085 opac = StringToLong( value );
6086 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6090 (void) SetMSLAttributes(msl_info,keyword,value);
6091 (void) SetImageProperty(msl_info->image[n],keyword,value,
6092 msl_info->exception);
6098 if (LocaleCompare(keyword, "page") == 0)
6101 page[MaxTextExtent];
6112 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6113 image_option=GetImageOption(msl_info->image_info[n],"page");
6114 if (image_option != (const char *) NULL)
6115 flags=ParseAbsoluteGeometry(image_option,&geometry);
6116 flags=ParseAbsoluteGeometry(value,&geometry);
6117 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6118 (double) geometry.width,(double) geometry.height);
6119 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6120 (void) FormatLocaleString(page,MaxTextExtent,
6121 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6122 (double) geometry.height,(double) geometry.x,(double)
6124 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6125 msl_info->image_info[n]->page=GetPageGeometry(page);
6128 (void) SetMSLAttributes(msl_info,keyword,value);
6129 (void) SetImageProperty(msl_info->image[n],keyword,value,
6130 msl_info->exception);
6135 (void) SetMSLAttributes(msl_info,keyword,value);
6136 (void) SetImageProperty(msl_info->image[n],keyword,value,
6137 msl_info->exception);
6144 if (LocaleCompare((const char *) tag,"shade") == 0)
6155 if (msl_info->image[n] == (Image *) NULL)
6157 ThrowMSLException(OptionError,"NoImagesDefined",
6158 (const char *) tag);
6162 if (attributes != (const xmlChar **) NULL)
6163 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6165 keyword=(const char *) attributes[i++];
6166 attribute=InterpretImageProperties(msl_info->image_info[n],
6167 msl_info->attributes[n],(const char *) attributes[i],
6169 CloneString(&value,attribute);
6175 if (LocaleCompare(keyword,"azimuth") == 0)
6177 geometry_info.rho=StringToDouble(value,
6181 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6188 if (LocaleCompare(keyword,"elevation") == 0)
6190 geometry_info.sigma=StringToDouble(value,
6194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6201 if (LocaleCompare(keyword,"geometry") == 0)
6203 flags=ParseGeometry(value,&geometry_info);
6204 if ((flags & SigmaValue) == 0)
6205 geometry_info.sigma=1.0;
6208 if (LocaleCompare(keyword,"gray") == 0)
6210 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6213 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6215 gray=(MagickBooleanType) option;
6218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6224 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6230 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6231 geometry_info.sigma,msl_info->exception);
6232 if (shade_image == (Image *) NULL)
6234 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6235 msl_info->image[n]=shade_image;
6238 if (LocaleCompare((const char *) tag,"shadow") == 0)
6246 if (msl_info->image[n] == (Image *) NULL)
6248 ThrowMSLException(OptionError,"NoImagesDefined",
6249 (const char *) tag);
6252 if (attributes != (const xmlChar **) NULL)
6253 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6255 keyword=(const char *) attributes[i++];
6256 attribute=InterpretImageProperties(msl_info->image_info[n],
6257 msl_info->attributes[n],(const char *) attributes[i],
6259 CloneString(&value,attribute);
6265 if (LocaleCompare(keyword,"geometry") == 0)
6267 flags=ParseGeometry(value,&geometry_info);
6268 if ((flags & SigmaValue) == 0)
6269 geometry_info.sigma=1.0;
6272 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6279 if (LocaleCompare(keyword,"opacity") == 0)
6281 geometry_info.rho=StringToLong(value);
6284 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6291 if (LocaleCompare(keyword,"sigma") == 0)
6293 geometry_info.sigma=StringToLong(value);
6301 if (LocaleCompare(keyword,"x") == 0)
6303 geometry_info.xi=StringToDouble(value,
6307 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6314 if (LocaleCompare(keyword,"y") == 0)
6316 geometry_info.psi=StringToLong(value);
6319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6325 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6331 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6332 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6333 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6334 if (shadow_image == (Image *) NULL)
6336 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6337 msl_info->image[n]=shadow_image;
6340 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6346 if (msl_info->image[n] == (Image *) NULL)
6348 ThrowMSLException(OptionError,"NoImagesDefined",
6349 (const char *) tag);
6353 NOTE: sharpen can have no attributes, since we use all the defaults!
6355 if (attributes != (const xmlChar **) NULL)
6357 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6359 keyword=(const char *) attributes[i++];
6360 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6361 msl_info->attributes[n],(const char *) attributes[i],&exception));
6367 if (LocaleCompare(keyword, "radius") == 0)
6369 radius = StringToDouble(value,(char **) NULL);
6372 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6378 if (LocaleCompare(keyword,"sigma") == 0)
6380 sigma = StringToLong( value );
6383 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6402 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6403 msl_info->exception);
6404 if (newImage == (Image *) NULL)
6406 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6407 msl_info->image[n]=newImage;
6411 else if (LocaleCompare((const char *) tag,"shave") == 0)
6413 /* init the values */
6417 if (msl_info->image[n] == (Image *) NULL)
6419 ThrowMSLException(OptionError,"NoImagesDefined",
6420 (const char *) tag);
6423 if (attributes == (const xmlChar **) NULL)
6425 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6427 keyword=(const char *) attributes[i++];
6428 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6429 msl_info->attributes[n],(const char *) attributes[i],&exception));
6435 if (LocaleCompare(keyword,"geometry") == 0)
6437 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6440 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6446 if (LocaleCompare(keyword,"height") == 0)
6448 height = StringToLong( value );
6451 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6457 if (LocaleCompare(keyword,"width") == 0)
6459 width = StringToLong( value );
6462 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6482 rectInfo.height = height;
6483 rectInfo.width = width;
6488 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6489 msl_info->exception);
6490 if (newImage == (Image *) NULL)
6492 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6493 msl_info->image[n]=newImage;
6498 if (LocaleCompare((const char *) tag,"shear") == 0)
6506 if (msl_info->image[n] == (Image *) NULL)
6508 ThrowMSLException(OptionError,"NoImagesDefined",
6509 (const char *) tag);
6512 if (attributes != (const xmlChar **) NULL)
6513 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6515 keyword=(const char *) attributes[i++];
6516 attribute=InterpretImageProperties(msl_info->image_info[n],
6517 msl_info->attributes[n],(const char *) attributes[i],
6519 CloneString(&value,attribute);
6525 if (LocaleCompare(keyword, "fill") == 0)
6527 (void) QueryColorCompliance(value,AllCompliance,
6528 &msl_info->image[n]->background_color,&exception);
6531 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6538 if (LocaleCompare(keyword,"geometry") == 0)
6540 flags=ParseGeometry(value,&geometry_info);
6541 if ((flags & SigmaValue) == 0)
6542 geometry_info.sigma=1.0;
6545 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6552 if (LocaleCompare(keyword,"x") == 0)
6554 geometry_info.rho=StringToDouble(value,
6558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6565 if (LocaleCompare(keyword,"y") == 0)
6567 geometry_info.sigma=StringToLong(value);
6570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6576 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6582 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6583 geometry_info.sigma,msl_info->exception);
6584 if (shear_image == (Image *) NULL)
6586 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6587 msl_info->image[n]=shear_image;
6590 if (LocaleCompare((const char *) tag,"signature") == 0)
6595 if (msl_info->image[n] == (Image *) NULL)
6597 ThrowMSLException(OptionError,"NoImagesDefined",
6598 (const char *) tag);
6601 if (attributes != (const xmlChar **) NULL)
6602 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6604 keyword=(const char *) attributes[i++];
6605 attribute=InterpretImageProperties(msl_info->image_info[n],
6606 msl_info->attributes[n],(const char *) attributes[i],
6608 CloneString(&value,attribute);
6613 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6619 (void) SignatureImage(msl_info->image[n],&exception);
6622 if (LocaleCompare((const char *) tag,"solarize") == 0)
6627 if (msl_info->image[n] == (Image *) NULL)
6629 ThrowMSLException(OptionError,"NoImagesDefined",
6630 (const char *) tag);
6633 geometry_info.rho=QuantumRange/2.0;
6634 if (attributes != (const xmlChar **) NULL)
6635 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6637 keyword=(const char *) attributes[i++];
6638 attribute=InterpretImageProperties(msl_info->image_info[n],
6639 msl_info->attributes[n],(const char *) attributes[i],
6641 CloneString(&value,attribute);
6647 if (LocaleCompare(keyword,"geometry") == 0)
6649 flags=ParseGeometry(value,&geometry_info);
6652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6659 if (LocaleCompare(keyword,"threshold") == 0)
6661 geometry_info.rho=StringToDouble(value,
6665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6677 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6678 msl_info->exception);
6681 if (LocaleCompare((const char *) tag,"spread") == 0)
6689 if (msl_info->image[n] == (Image *) NULL)
6691 ThrowMSLException(OptionError,"NoImagesDefined",
6692 (const char *) tag);
6695 if (attributes != (const xmlChar **) NULL)
6696 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6698 keyword=(const char *) attributes[i++];
6699 attribute=InterpretImageProperties(msl_info->image_info[n],
6700 msl_info->attributes[n],(const char *) attributes[i],
6702 CloneString(&value,attribute);
6708 if (LocaleCompare(keyword,"geometry") == 0)
6710 flags=ParseGeometry(value,&geometry_info);
6711 if ((flags & SigmaValue) == 0)
6712 geometry_info.sigma=1.0;
6715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6722 if (LocaleCompare(keyword,"radius") == 0)
6724 geometry_info.rho=StringToDouble(value,
6728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6740 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6741 msl_info->image[n]->interpolate,msl_info->exception);
6742 if (spread_image == (Image *) NULL)
6744 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6745 msl_info->image[n]=spread_image;
6748 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6751 watermark = (Image*)NULL;
6753 if (msl_info->image[n] == (Image *) NULL)
6755 ThrowMSLException(OptionError,"NoImagesDefined",
6756 (const char *) tag);
6759 if (attributes == (const xmlChar **) NULL)
6761 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6763 keyword=(const char *) attributes[i++];
6764 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6765 msl_info->attributes[n],(const char *) attributes[i],&exception));
6771 if (LocaleCompare(keyword,"image") == 0)
6773 for (j=0; j<msl_info->n;j++)
6776 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6778 if (theAttr && LocaleCompare(theAttr, value) == 0)
6780 watermark = msl_info->image[j];
6786 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6791 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6800 if ( watermark != (Image*) NULL )
6805 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6806 if (newImage == (Image *) NULL)
6808 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6809 msl_info->image[n]=newImage;
6812 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6814 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6817 stereoImage = (Image*)NULL;
6819 if (msl_info->image[n] == (Image *) NULL)
6821 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6824 if (attributes == (const xmlChar **) NULL)
6826 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6828 keyword=(const char *) attributes[i++];
6829 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6830 msl_info->attributes[n],(const char *) attributes[i],&exception));
6836 if (LocaleCompare(keyword,"image") == 0)
6838 for (j=0; j<msl_info->n;j++)
6841 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6843 if (theAttr && LocaleCompare(theAttr, value) == 0)
6845 stereoImage = msl_info->image[j];
6851 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6856 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6865 if ( stereoImage != (Image*) NULL )
6870 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6871 if (newImage == (Image *) NULL)
6873 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6874 msl_info->image[n]=newImage;
6877 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6879 if (LocaleCompare((const char *) tag,"strip") == 0)
6884 if (msl_info->image[n] == (Image *) NULL)
6886 ThrowMSLException(OptionError,"NoImagesDefined",
6887 (const char *) tag);
6890 if (attributes != (const xmlChar **) NULL)
6891 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6893 keyword=(const char *) attributes[i++];
6894 attribute=InterpretImageProperties(msl_info->image_info[n],
6895 msl_info->attributes[n],(const char *) attributes[i],
6897 CloneString(&value,attribute);
6898 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6900 (void) StripImage(msl_info->image[n],msl_info->exception);
6903 if (LocaleCompare((const char *) tag,"swap") == 0)
6914 if (msl_info->image[n] == (Image *) NULL)
6916 ThrowMSLException(OptionError,"NoImagesDefined",
6917 (const char *) tag);
6922 if (attributes != (const xmlChar **) NULL)
6923 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6925 keyword=(const char *) attributes[i++];
6926 attribute=InterpretImageProperties(msl_info->image_info[n],
6927 msl_info->attributes[n],(const char *) attributes[i],
6929 CloneString(&value,attribute);
6935 if (LocaleCompare(keyword,"indexes") == 0)
6937 flags=ParseGeometry(value,&geometry_info);
6938 index=(ssize_t) geometry_info.rho;
6939 if ((flags & SigmaValue) == 0)
6940 swap_index=(ssize_t) geometry_info.sigma;
6943 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6949 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6958 p=GetImageFromList(msl_info->image[n],index);
6959 q=GetImageFromList(msl_info->image[n],swap_index);
6960 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6962 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6965 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6966 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6967 msl_info->exception));
6968 ReplaceImageInList(&q,swap);
6969 msl_info->image[n]=GetFirstImageInList(q);
6972 if (LocaleCompare((const char *) tag,"swirl") == 0)
6980 if (msl_info->image[n] == (Image *) NULL)
6982 ThrowMSLException(OptionError,"NoImagesDefined",
6983 (const char *) tag);
6986 if (attributes != (const xmlChar **) NULL)
6987 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6989 keyword=(const char *) attributes[i++];
6990 attribute=InterpretImageProperties(msl_info->image_info[n],
6991 msl_info->attributes[n],(const char *) attributes[i],
6993 CloneString(&value,attribute);
6999 if (LocaleCompare(keyword,"degrees") == 0)
7001 geometry_info.rho=StringToDouble(value,
7005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7012 if (LocaleCompare(keyword,"geometry") == 0)
7014 flags=ParseGeometry(value,&geometry_info);
7015 if ((flags & SigmaValue) == 0)
7016 geometry_info.sigma=1.0;
7019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7031 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7032 msl_info->image[n]->interpolate,msl_info->exception);
7033 if (swirl_image == (Image *) NULL)
7035 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7036 msl_info->image[n]=swirl_image;
7039 if (LocaleCompare((const char *) tag,"sync") == 0)
7044 if (msl_info->image[n] == (Image *) NULL)
7046 ThrowMSLException(OptionError,"NoImagesDefined",
7047 (const char *) tag);
7050 if (attributes != (const xmlChar **) NULL)
7051 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7053 keyword=(const char *) attributes[i++];
7054 attribute=InterpretImageProperties(msl_info->image_info[n],
7055 msl_info->attributes[n],(const char *) attributes[i],
7057 CloneString(&value,attribute);
7062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7068 (void) SyncImage(msl_info->image[n],&exception);
7071 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7076 if (LocaleCompare((const char *) tag,"map") == 0)
7084 if (msl_info->image[n] == (Image *) NULL)
7086 ThrowMSLException(OptionError,"NoImagesDefined",
7087 (const char *) tag);
7090 texture_image=NewImageList();
7091 if (attributes != (const xmlChar **) NULL)
7092 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7094 keyword=(const char *) attributes[i++];
7095 attribute=InterpretImageProperties(msl_info->image_info[n],
7096 msl_info->attributes[n],(const char *) attributes[i],
7098 CloneString(&value,attribute);
7104 if (LocaleCompare(keyword,"image") == 0)
7105 for (j=0; j < msl_info->n; j++)
7110 attribute=GetImageProperty(msl_info->attributes[j],"id",
7112 if ((attribute != (const char *) NULL) &&
7113 (LocaleCompare(attribute,value) == 0))
7115 texture_image=CloneImage(msl_info->image[j],0,0,
7116 MagickFalse,&exception);
7124 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7130 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7131 texture_image=DestroyImage(texture_image);
7134 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7136 /* init the values */
7137 double threshold = 0;
7139 if (msl_info->image[n] == (Image *) NULL)
7141 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7144 if (attributes == (const xmlChar **) NULL)
7146 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7148 keyword=(const char *) attributes[i++];
7149 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7150 msl_info->attributes[n],(const char *) attributes[i],&exception));
7156 if (LocaleCompare(keyword,"threshold") == 0)
7158 threshold = StringToDouble(value,(char **) NULL);
7161 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7166 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7176 BilevelImage(msl_info->image[n],threshold,&exception);
7180 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7182 if (msl_info->image[n] == (Image *) NULL)
7184 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7187 if (attributes == (const xmlChar **) NULL)
7189 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7191 keyword=(const char *) attributes[i++];
7192 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7193 msl_info->attributes[n],(const char *) attributes[i],&exception));
7199 if (LocaleCompare(keyword,"color") == 0)
7204 (void) QueryColorCompliance(value,AllCompliance,&target,
7206 (void) TransparentPaintImage(msl_info->image[n],&target,
7207 TransparentAlpha,MagickFalse,msl_info->exception);
7210 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7215 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7222 else if (LocaleCompare((const char *) tag, "trim") == 0)
7224 if (msl_info->image[n] == (Image *) NULL)
7226 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7230 /* no attributes here */
7232 /* process the image */
7239 /* all zeros on a crop == trim edges! */
7240 rectInfo.height = rectInfo.width = 0;
7241 rectInfo.x = rectInfo.y = 0;
7243 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7244 if (newImage == (Image *) NULL)
7246 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7247 msl_info->image[n]=newImage;
7251 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7256 if (LocaleCompare((const char *) tag,"write") == 0)
7258 if (msl_info->image[n] == (Image *) NULL)
7260 ThrowMSLException(OptionError,"NoImagesDefined",
7261 (const char *) tag);
7264 if (attributes == (const xmlChar **) NULL)
7266 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7268 keyword=(const char *) attributes[i++];
7269 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7270 msl_info->attributes[n],(const char *) attributes[i],&exception));
7276 if (LocaleCompare(keyword,"filename") == 0)
7278 (void) CopyMagickString(msl_info->image[n]->filename,value,
7282 (void) SetMSLAttributes(msl_info,keyword,value);
7286 (void) SetMSLAttributes(msl_info,keyword,value);
7294 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7295 msl_info->exception);
7299 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7303 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7307 if ( value != NULL )
7308 value=DestroyString(value);
7309 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7312 static void MSLEndElement(void *context,const xmlChar *tag)
7321 Called when the end of an element has been detected.
7323 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7325 msl_info=(MSLInfo *) context;
7332 if (LocaleCompare((const char *) tag,"comment") == 0 )
7334 (void) DeleteImageProperty(msl_info->image[n],"comment");
7335 if (msl_info->content == (char *) NULL)
7337 StripString(msl_info->content);
7338 (void) SetImageProperty(msl_info->image[n],"comment",
7339 msl_info->content,msl_info->exception);
7347 if (LocaleCompare((const char *) tag, "group") == 0 )
7349 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7351 ssize_t i = (ssize_t)
7352 (msl_info->group_info[msl_info->number_groups-1].numImages);
7355 if (msl_info->image[msl_info->n] != (Image *) NULL)
7356 msl_info->image[msl_info->n]=DestroyImage(
7357 msl_info->image[msl_info->n]);
7358 msl_info->attributes[msl_info->n]=DestroyImage(
7359 msl_info->attributes[msl_info->n]);
7360 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7361 msl_info->image_info[msl_info->n]);
7365 msl_info->number_groups--;
7372 if (LocaleCompare((const char *) tag, "image") == 0)
7373 MSLPopImage(msl_info);
7379 if (LocaleCompare((const char *) tag,"label") == 0 )
7381 (void) DeleteImageProperty(msl_info->image[n],"label");
7382 if (msl_info->content == (char *) NULL)
7384 StripString(msl_info->content);
7385 (void) SetImageProperty(msl_info->image[n],"label",
7386 msl_info->content,msl_info->exception);
7394 if (LocaleCompare((const char *) tag, "msl") == 0 )
7397 This our base element.
7398 at the moment we don't do anything special
7399 but someday we might!
7407 if (msl_info->content != (char *) NULL)
7408 msl_info->content=DestroyString(msl_info->content);
7411 static void MSLCharacters(void *context,const xmlChar *c,int length)
7423 Receiving some characters from the parser.
7425 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7426 " SAX.characters(%s,%d)",c,length);
7427 msl_info=(MSLInfo *) context;
7428 if (msl_info->content != (char *) NULL)
7429 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7430 strlen(msl_info->content)+length+MaxTextExtent,
7431 sizeof(*msl_info->content));
7434 msl_info->content=(char *) NULL;
7435 if (~length >= (MaxTextExtent-1))
7436 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7437 sizeof(*msl_info->content));
7438 if (msl_info->content != (char *) NULL)
7439 *msl_info->content='\0';
7441 if (msl_info->content == (char *) NULL)
7443 p=msl_info->content+strlen(msl_info->content);
7444 for (i=0; i < length; i++)
7449 static void MSLReference(void *context,const xmlChar *name)
7458 Called when an entity reference is detected.
7460 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7461 " SAX.reference(%s)",name);
7462 msl_info=(MSLInfo *) context;
7463 parser=msl_info->parser;
7465 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7467 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7470 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7476 Receiving some ignorable whitespaces from the parser.
7478 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7479 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7480 msl_info=(MSLInfo *) context;
7484 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7485 const xmlChar *data)
7491 A processing instruction has been parsed.
7493 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7494 " SAX.processingInstruction(%s, %s)",
7496 msl_info=(MSLInfo *) context;
7500 static void MSLComment(void *context,const xmlChar *value)
7506 A comment has been parsed.
7508 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7509 " SAX.comment(%s)",value);
7510 msl_info=(MSLInfo *) context;
7514 static void MSLWarning(void *context,const char *format,...)
7518 reason[MaxTextExtent];
7527 Display and format a warning messages, gives file, line, position and
7530 va_start(operands,format);
7531 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7532 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7533 msl_info=(MSLInfo *) context;
7535 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7536 (void) vsprintf(reason,format,operands);
7538 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7540 message=GetExceptionMessage(errno);
7541 ThrowMSLException(CoderError,reason,message);
7542 message=DestroyString(message);
7546 static void MSLError(void *context,const char *format,...)
7549 reason[MaxTextExtent];
7558 Display and format a error formats, gives file, line, position and
7561 va_start(operands,format);
7562 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7563 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7564 msl_info=(MSLInfo *) context;
7566 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7567 (void) vsprintf(reason,format,operands);
7569 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7571 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7575 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7587 Called when a pcdata block has been parsed.
7589 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7590 " SAX.pcdata(%s, %d)",value,length);
7591 msl_info=(MSLInfo *) context;
7593 parser=msl_info->parser;
7594 child=xmlGetLastChild(parser->node);
7595 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7597 xmlTextConcat(child,value,length);
7600 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7603 static void MSLExternalSubset(void *context,const xmlChar *name,
7604 const xmlChar *external_id,const xmlChar *system_id)
7619 Does this document has an external subset?
7621 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7622 " SAX.externalSubset(%s %s %s)",name,
7623 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7624 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7625 msl_info=(MSLInfo *) context;
7627 parser=msl_info->parser;
7628 if (((external_id == NULL) && (system_id == NULL)) ||
7629 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7630 (msl_info->document == 0)))
7632 input=MSLResolveEntity(context,external_id,system_id);
7635 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7636 parser_context=(*parser);
7637 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7638 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7640 parser->errNo=XML_ERR_NO_MEMORY;
7641 parser->input=parser_context.input;
7642 parser->inputNr=parser_context.inputNr;
7643 parser->inputMax=parser_context.inputMax;
7644 parser->inputTab=parser_context.inputTab;
7650 xmlPushInput(parser,input);
7651 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7652 if (input->filename == (char *) NULL)
7653 input->filename=(char *) xmlStrdup(system_id);
7656 input->base=parser->input->cur;
7657 input->cur=parser->input->cur;
7659 xmlParseExternalSubset(parser,external_id,system_id);
7660 while (parser->inputNr > 1)
7661 (void) xmlPopInput(parser);
7662 xmlFreeInputStream(parser->input);
7663 xmlFree(parser->inputTab);
7664 parser->input=parser_context.input;
7665 parser->inputNr=parser_context.inputNr;
7666 parser->inputMax=parser_context.inputMax;
7667 parser->inputTab=parser_context.inputTab;
7670 #if defined(__cplusplus) || defined(c_plusplus)
7674 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7675 Image **image,ExceptionInfo *exception)
7678 message[MaxTextExtent];
7701 assert(image_info != (const ImageInfo *) NULL);
7702 assert(image_info->signature == MagickSignature);
7703 if (image_info->debug != MagickFalse)
7704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7705 image_info->filename);
7706 assert(image != (Image **) NULL);
7707 msl_image=AcquireImage(image_info,exception);
7708 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7709 if (status == MagickFalse)
7711 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7712 msl_image->filename);
7713 msl_image=DestroyImageList(msl_image);
7714 return(MagickFalse);
7716 msl_image->columns=1;
7721 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7722 msl_info.exception=exception;
7723 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7724 sizeof(*msl_info.image_info));
7725 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7726 sizeof(*msl_info.draw_info));
7727 /* top of the stack is the MSL file itself */
7728 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7729 msl_info.attributes=(Image **) AcquireMagickMemory(
7730 sizeof(*msl_info.attributes));
7731 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7732 sizeof(*msl_info.group_info));
7733 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7734 (msl_info.image == (Image **) NULL) ||
7735 (msl_info.attributes == (Image **) NULL) ||
7736 (msl_info.group_info == (MSLGroupInfo *) NULL))
7737 ThrowFatalException(ResourceLimitFatalError,
7738 "UnableToInterpretMSLImage");
7739 *msl_info.image_info=CloneImageInfo(image_info);
7740 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7741 *msl_info.attributes=AcquireImage(image_info,exception);
7742 msl_info.group_info[0].numImages=0;
7743 /* the first slot is used to point to the MSL file image */
7744 *msl_info.image=msl_image;
7745 if (*image != (Image *) NULL)
7746 MSLPushImage(&msl_info,*image);
7747 (void) xmlSubstituteEntitiesDefault(1);
7748 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7749 sax_modules.internalSubset=MSLInternalSubset;
7750 sax_modules.isStandalone=MSLIsStandalone;
7751 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7752 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7753 sax_modules.resolveEntity=MSLResolveEntity;
7754 sax_modules.getEntity=MSLGetEntity;
7755 sax_modules.entityDecl=MSLEntityDeclaration;
7756 sax_modules.notationDecl=MSLNotationDeclaration;
7757 sax_modules.attributeDecl=MSLAttributeDeclaration;
7758 sax_modules.elementDecl=MSLElementDeclaration;
7759 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7760 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7761 sax_modules.startDocument=MSLStartDocument;
7762 sax_modules.endDocument=MSLEndDocument;
7763 sax_modules.startElement=MSLStartElement;
7764 sax_modules.endElement=MSLEndElement;
7765 sax_modules.reference=MSLReference;
7766 sax_modules.characters=MSLCharacters;
7767 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7768 sax_modules.processingInstruction=MSLProcessingInstructions;
7769 sax_modules.comment=MSLComment;
7770 sax_modules.warning=MSLWarning;
7771 sax_modules.error=MSLError;
7772 sax_modules.fatalError=MSLError;
7773 sax_modules.getParameterEntity=MSLGetParameterEntity;
7774 sax_modules.cdataBlock=MSLCDataBlock;
7775 sax_modules.externalSubset=MSLExternalSubset;
7776 sax_handler=(&sax_modules);
7777 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7778 msl_image->filename);
7779 while (ReadBlobString(msl_image,message) != (char *) NULL)
7781 n=(ssize_t) strlen(message);
7784 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7787 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7788 if (msl_info.exception->severity >= ErrorException)
7791 if (msl_info.exception->severity == UndefinedException)
7792 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7793 xmlFreeParserCtxt(msl_info.parser);
7794 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7796 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7797 msl_info.group_info);
7798 if (*image == (Image *) NULL)
7799 *image=(*msl_info.image);
7800 if (msl_info.exception->severity != UndefinedException)
7801 return(MagickFalse);
7805 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7813 assert(image_info != (const ImageInfo *) NULL);
7814 assert(image_info->signature == MagickSignature);
7815 if (image_info->debug != MagickFalse)
7816 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7817 image_info->filename);
7818 assert(exception != (ExceptionInfo *) NULL);
7819 assert(exception->signature == MagickSignature);
7820 image=(Image *) NULL;
7821 (void) ProcessMSLScript(image_info,&image,exception);
7822 return(GetFirstImageInList(image));
7827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7831 % R e g i s t e r M S L I m a g e %
7835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7837 % RegisterMSLImage() adds attributes for the MSL image format to
7838 % the list of supported formats. The attributes include the image format
7839 % tag, a method to read and/or write the format, whether the format
7840 % supports the saving of more than one frame to the same file or blob,
7841 % whether the format supports native in-memory I/O, and a brief
7842 % description of the format.
7844 % The format of the RegisterMSLImage method is:
7846 % size_t RegisterMSLImage(void)
7849 ModuleExport size_t RegisterMSLImage(void)
7854 entry=SetMagickInfo("MSL");
7855 #if defined(MAGICKCORE_XML_DELEGATE)
7856 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7857 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7859 entry->description=ConstantString("Magick Scripting Language");
7860 entry->module=ConstantString("MSL");
7861 (void) RegisterMagickInfo(entry);
7862 return(MagickImageCoderSignature);
7865 #if defined(MAGICKCORE_XML_DELEGATE)
7867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7871 % S e t M S L A t t r i b u t e s %
7875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7877 % SetMSLAttributes() ...
7879 % The format of the SetMSLAttributes method is:
7881 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7882 % const char *keyword,const char *value)
7884 % A description of each parameter follows:
7886 % o msl_info: the MSL info.
7888 % o keyword: the keyword.
7890 % o value: the value.
7893 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7920 assert(msl_info != (MSLInfo *) NULL);
7921 if (keyword == (const char *) NULL)
7923 if (value == (const char *) NULL)
7925 exception=msl_info->exception;
7927 attributes=msl_info->attributes[n];
7928 image_info=msl_info->image_info[n];
7929 draw_info=msl_info->draw_info[n];
7930 image=msl_info->image[n];
7936 if (LocaleCompare(keyword,"adjoin") == 0)
7941 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7943 ThrowMSLException(OptionError,"UnrecognizedType",value);
7944 image_info->adjoin=(MagickBooleanType) adjoin;
7947 if (LocaleCompare(keyword,"alpha") == 0)
7952 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7954 ThrowMSLException(OptionError,"UnrecognizedType",value);
7955 if (image != (Image *) NULL)
7956 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7960 if (LocaleCompare(keyword,"antialias") == 0)
7965 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7967 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7968 image_info->antialias=(MagickBooleanType) antialias;
7971 if (LocaleCompare(keyword,"area-limit") == 0)
7976 limit=MagickResourceInfinity;
7977 if (LocaleCompare(value,"unlimited") != 0)
7978 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7979 (void) SetMagickResourceLimit(AreaResource,limit);
7982 if (LocaleCompare(keyword,"attenuate") == 0)
7984 (void) SetImageOption(image_info,keyword,value);
7987 if (LocaleCompare(keyword,"authenticate") == 0)
7989 (void) CloneString(&image_info->density,value);
7992 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7998 if (LocaleCompare(keyword,"background") == 0)
8000 (void) QueryColorCompliance(value,AllCompliance,
8001 &image_info->background_color,exception);
8004 if (LocaleCompare(keyword,"blue-primary") == 0)
8006 if (image == (Image *) NULL)
8008 flags=ParseGeometry(value,&geometry_info);
8009 image->chromaticity.blue_primary.x=geometry_info.rho;
8010 image->chromaticity.blue_primary.y=geometry_info.sigma;
8011 if ((flags & SigmaValue) == 0)
8012 image->chromaticity.blue_primary.y=
8013 image->chromaticity.blue_primary.x;
8016 if (LocaleCompare(keyword,"bordercolor") == 0)
8018 (void) QueryColorCompliance(value,AllCompliance,
8019 &image_info->border_color,exception);
8022 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8028 if (LocaleCompare(keyword,"density") == 0)
8030 (void) CloneString(&image_info->density,value);
8031 (void) CloneString(&draw_info->density,value);
8034 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8040 if (LocaleCompare(keyword,"fill") == 0)
8042 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8044 (void) SetImageOption(image_info,keyword,value);
8047 if (LocaleCompare(keyword,"filename") == 0)
8049 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8052 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8058 if (LocaleCompare(keyword,"gravity") == 0)
8063 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8065 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8066 (void) SetImageOption(image_info,keyword,value);
8069 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8075 if (LocaleCompare(keyword,"id") == 0)
8077 (void) SetImageProperty(attributes,keyword,value,exception);
8080 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8086 if (LocaleCompare(keyword,"magick") == 0)
8088 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8091 if (LocaleCompare(keyword,"mattecolor") == 0)
8093 (void) QueryColorCompliance(value,AllCompliance,
8094 &image_info->matte_color,exception);
8097 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8103 if (LocaleCompare(keyword,"pointsize") == 0)
8105 image_info->pointsize=StringToDouble(value,(char **) NULL);
8106 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8109 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8115 if (LocaleCompare(keyword,"quality") == 0)
8117 image_info->quality=StringToLong(value);
8118 if (image == (Image *) NULL)
8120 image->quality=StringToLong(value);
8128 if (LocaleCompare(keyword,"size") == 0)
8130 (void) CloneString(&image_info->size,value);
8133 if (LocaleCompare(keyword,"stroke") == 0)
8135 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8137 (void) SetImageOption(image_info,keyword,value);
8140 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8145 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8158 % U n r e g i s t e r M S L I m a g e %
8162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8164 % UnregisterMSLImage() removes format registrations made by the
8165 % MSL module from the list of supported formats.
8167 % The format of the UnregisterMSLImage method is:
8169 % UnregisterMSLImage(void)
8172 ModuleExport void UnregisterMSLImage(void)
8174 (void) UnregisterMagickInfo("MSL");
8177 #if defined(MAGICKCORE_XML_DELEGATE)
8179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8183 % W r i t e M S L I m a g e %
8187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8189 % WriteMSLImage() writes an image to a file in MVG image format.
8191 % The format of the WriteMSLImage method is:
8193 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8194 % Image *image,ExceptionInfo *exception)
8196 % A description of each parameter follows.
8198 % o image_info: the image info.
8200 % o image: The image.
8202 % o exception: return any errors or warnings in this structure.
8205 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8206 ExceptionInfo *exception)
8208 assert(image_info != (const ImageInfo *) NULL);
8209 assert(image_info->signature == MagickSignature);
8210 assert(image != (Image *) NULL);
8211 assert(image->signature == MagickSignature);
8212 if (image->debug != MagickFalse)
8213 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8214 (void) ReferenceImage(image);
8215 (void) ProcessMSLScript(image_info,&image,exception);