2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/colormap.h"
53 #include "MagickCore/color-private.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/enhance.h"
61 #include "MagickCore/exception.h"
62 #include "MagickCore/exception-private.h"
63 #include "MagickCore/fx.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/image.h"
66 #include "MagickCore/image-private.h"
67 #include "MagickCore/list.h"
68 #include "MagickCore/log.h"
69 #include "MagickCore/magick.h"
70 #include "MagickCore/memory_.h"
71 #include "MagickCore/module.h"
72 #include "MagickCore/option.h"
73 #include "MagickCore/paint.h"
74 #include "MagickCore/pixel-accessor.h"
75 #include "MagickCore/profile.h"
76 #include "MagickCore/property.h"
77 #include "MagickCore/quantize.h"
78 #include "MagickCore/quantum-private.h"
79 #include "MagickCore/registry.h"
80 #include "MagickCore/resize.h"
81 #include "MagickCore/resource_.h"
82 #include "MagickCore/segment.h"
83 #include "MagickCore/shear.h"
84 #include "MagickCore/signature.h"
85 #include "MagickCore/static.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/string-private.h"
88 #include "MagickCore/transform.h"
89 #include "MagickCore/threshold.h"
90 #include "MagickCore/utility.h"
91 #if defined(MAGICKCORE_XML_DELEGATE)
92 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
93 # if defined(__MINGW32__)
96 # include <win32config.h>
99 # include <libxml/parser.h>
100 # include <libxml/xmlmemory.h>
101 # include <libxml/parserInternals.h>
102 # include <libxml/xmlerror.h>
108 #define ThrowMSLException(severity,tag,reason) \
109 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
113 Typedef declaractions.
115 typedef struct _MSLGroupInfo
118 numImages; /* how many images are in this group */
121 typedef struct _MSLInfo
146 #if defined(MAGICKCORE_XML_DELEGATE)
156 Forward declarations.
158 #if defined(MAGICKCORE_XML_DELEGATE)
159 static MagickBooleanType
160 WriteMSLImage(const ImageInfo *,Image *);
162 static MagickBooleanType
163 SetMSLAttributes(MSLInfo *,const char *,const char *);
166 #if defined(MAGICKCORE_XML_DELEGATE)
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % R e a d M S L I m a g e %
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
180 % It allocates the memory necessary for the new Image structure and returns a
181 % pointer to the new image.
183 % The format of the ReadMSLImage method is:
185 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
187 % A description of each parameter follows:
189 % o image_info: the image info.
191 % o exception: return any errors or warnings in this structure.
195 #if defined(__cplusplus) || defined(c_plusplus)
199 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
200 ExceptionInfo *exception)
214 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
215 sans_exception=AcquireExceptionInfo();
216 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
217 sans_exception=DestroyExceptionInfo(sans_exception);
218 if (image != (Image *) NULL)
220 read_info=CloneImageInfo(image_info);
221 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
222 image=ReadImage(read_info,exception);
223 read_info=DestroyImageInfo(read_info);
224 if (image != (Image *) NULL)
225 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
229 static int IsPathDirectory(const char *path)
237 if ((path == (const char *) NULL) || (*path == '\0'))
239 status=GetPathAttributes(path,&attributes);
240 if (status == MagickFalse)
242 if (S_ISDIR(attributes.st_mode) == 0)
247 static int MSLIsStandalone(void *context)
253 Is this document tagged standalone?
255 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
256 msl_info=(MSLInfo *) context;
257 return(msl_info->document->standalone == 1);
260 static int MSLHasInternalSubset(void *context)
266 Does this document has an internal subset?
268 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
269 " SAX.MSLHasInternalSubset()");
270 msl_info=(MSLInfo *) context;
271 return(msl_info->document->intSubset != NULL);
274 static int MSLHasExternalSubset(void *context)
280 Does this document has an external subset?
282 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
283 " SAX.MSLHasExternalSubset()");
284 msl_info=(MSLInfo *) context;
285 return(msl_info->document->extSubset != NULL);
288 static void MSLInternalSubset(void *context,const xmlChar *name,
289 const xmlChar *external_id,const xmlChar *system_id)
295 Does this document has an internal subset?
297 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
298 " SAX.internalSubset(%s %s %s)",name,
299 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
300 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
301 msl_info=(MSLInfo *) context;
302 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
305 static xmlParserInputPtr MSLResolveEntity(void *context,
306 const xmlChar *public_id,const xmlChar *system_id)
315 Special entity resolver, better left to the parser, it has more
316 context than the application layer. The default behaviour is to
317 not resolve the entities, in that case the ENTITY_REF nodes are
318 built in the structure (and the parameter values).
320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
321 " SAX.resolveEntity(%s, %s)",
322 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
323 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
324 msl_info=(MSLInfo *) context;
325 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
326 public_id,msl_info->parser);
330 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
336 Get an entity by name.
338 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
339 " SAX.MSLGetEntity(%s)",(const char *) name);
340 msl_info=(MSLInfo *) context;
341 return(xmlGetDocEntity(msl_info->document,name));
344 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
350 Get a parameter entity by name.
352 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
353 " SAX.getParameterEntity(%s)",(const char *) name);
354 msl_info=(MSLInfo *) context;
355 return(xmlGetParameterEntity(msl_info->document,name));
358 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
359 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
365 An entity definition has been parsed.
367 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
368 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
369 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
370 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
372 msl_info=(MSLInfo *) context;
373 if (msl_info->parser->inSubset == 1)
374 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
377 if (msl_info->parser->inSubset == 2)
378 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
382 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
383 const xmlChar *name,int type,int value,const xmlChar *default_value,
384 xmlEnumerationPtr tree)
397 An attribute definition has been parsed.
399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
400 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
402 msl_info=(MSLInfo *) context;
403 fullname=(xmlChar *) NULL;
404 prefix=(xmlChar *) NULL;
405 parser=msl_info->parser;
406 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
407 if (parser->inSubset == 1)
408 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
409 element,fullname,prefix,(xmlAttributeType) type,
410 (xmlAttributeDefault) value,default_value,tree);
412 if (parser->inSubset == 2)
413 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
414 element,fullname,prefix,(xmlAttributeType) type,
415 (xmlAttributeDefault) value,default_value,tree);
416 if (prefix != (xmlChar *) NULL)
418 if (fullname != (xmlChar *) NULL)
422 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
423 xmlElementContentPtr content)
432 An element definition has been parsed.
434 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
435 " SAX.elementDecl(%s, %d, ...)",name,type);
436 msl_info=(MSLInfo *) context;
437 parser=msl_info->parser;
438 if (parser->inSubset == 1)
439 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
440 name,(xmlElementTypeVal) type,content);
442 if (parser->inSubset == 2)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
444 name,(xmlElementTypeVal) type,content);
447 static void MSLNotationDeclaration(void *context,const xmlChar *name,
448 const xmlChar *public_id,const xmlChar *system_id)
457 What to do when a notation declaration has been parsed.
459 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
460 " SAX.notationDecl(%s, %s, %s)",name,
461 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
462 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
463 msl_info=(MSLInfo *) context;
464 parser=msl_info->parser;
465 if (parser->inSubset == 1)
466 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
467 name,public_id,system_id);
469 if (parser->inSubset == 2)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
474 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
475 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
481 What to do when an unparsed entity declaration is parsed.
483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
484 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
485 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
486 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
488 msl_info=(MSLInfo *) context;
489 (void) xmlAddDocEntity(msl_info->document,name,
490 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
494 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
500 Receive the document locator at startup, actually xmlDefaultSAXLocator.
502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
503 " SAX.setDocumentLocator()\n");
505 msl_info=(MSLInfo *) context;
509 static void MSLStartDocument(void *context)
518 Called when the document start being processed.
520 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521 " SAX.startDocument()");
522 msl_info=(MSLInfo *) context;
523 parser=msl_info->parser;
524 msl_info->document=xmlNewDoc(parser->version);
525 if (msl_info->document == (xmlDocPtr) NULL)
527 if (parser->encoding == NULL)
528 msl_info->document->encoding=NULL;
530 msl_info->document->encoding=xmlStrdup(parser->encoding);
531 msl_info->document->standalone=parser->standalone;
534 static void MSLEndDocument(void *context)
540 Called when the document end has been detected.
542 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
543 msl_info=(MSLInfo *) context;
544 if (msl_info->content != (char *) NULL)
545 msl_info->content=DestroyString(msl_info->content);
548 static void MSLPushImage(MSLInfo *msl_info,Image *image)
553 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
554 assert(msl_info != (MSLInfo *) NULL);
557 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
558 (n+1),sizeof(*msl_info->image_info));
559 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
560 (n+1),sizeof(*msl_info->draw_info));
561 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
562 (n+1),sizeof(*msl_info->attributes));
563 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
564 sizeof(*msl_info->image));
565 if ((msl_info->image_info == (ImageInfo **) NULL) ||
566 (msl_info->draw_info == (DrawInfo **) NULL) ||
567 (msl_info->attributes == (Image **) NULL) ||
568 (msl_info->image == (Image **) NULL))
569 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
570 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
571 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
572 msl_info->draw_info[n-1]);
573 if (image == (Image *) NULL)
574 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
576 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
577 msl_info->image[n]=(Image *) image;
578 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
579 (msl_info->attributes[n] == (Image *) NULL))
580 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
581 if (msl_info->number_groups != 0)
582 msl_info->group_info[msl_info->number_groups-1].numImages++;
585 static void MSLPopImage(MSLInfo *msl_info)
587 if (msl_info->number_groups != 0)
589 if (msl_info->image[msl_info->n] != (Image *) NULL)
590 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
591 msl_info->attributes[msl_info->n]=DestroyImage(
592 msl_info->attributes[msl_info->n]);
593 msl_info->image_info[msl_info->n]=DestroyImageInfo(
594 msl_info->image_info[msl_info->n]);
598 static void MSLStartElement(void *context,const xmlChar *tag,
599 const xmlChar **attributes)
655 Called when an opening tag has been processed.
657 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
658 " SAX.startElement(%s",tag);
659 GetExceptionInfo(&exception);
660 msl_info=(MSLInfo *) context;
662 keyword=(const char *) NULL;
664 SetGeometryInfo(&geometry_info);
665 channel=DefaultChannels;
671 if (LocaleCompare((const char *) tag,"add-noise") == 0)
682 if (msl_info->image[n] == (Image *) NULL)
684 ThrowMSLException(OptionError,"NoImagesDefined",
689 if (attributes != (const xmlChar **) NULL)
690 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
692 keyword=(const char *) attributes[i++];
693 attribute=InterpretImageProperties(msl_info->image_info[n],
694 msl_info->attributes[n],(const char *) attributes[i]);
695 CloneString(&value,attribute);
701 if (LocaleCompare(keyword,"channel") == 0)
703 option=ParseChannelOption(value);
705 ThrowMSLException(OptionError,"UnrecognizedChannelType",
707 channel=(ChannelType) option;
710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
717 if (LocaleCompare(keyword,"noise") == 0)
719 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
722 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
724 noise=(NoiseType) option;
727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
739 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
740 &msl_info->image[n]->exception);
741 if (noise_image == (Image *) NULL)
743 msl_info->image[n]=DestroyImage(msl_info->image[n]);
744 msl_info->image[n]=noise_image;
747 if (LocaleCompare((const char *) tag,"annotate") == 0)
755 if (msl_info->image[n] == (Image *) NULL)
757 ThrowMSLException(OptionError,"NoImagesDefined",
761 draw_info=CloneDrawInfo(msl_info->image_info[n],
762 msl_info->draw_info[n]);
764 current=draw_info->affine;
765 GetAffineMatrix(&affine);
766 if (attributes != (const xmlChar **) NULL)
767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
769 keyword=(const char *) attributes[i++];
770 attribute=InterpretImageProperties(msl_info->image_info[n],
771 msl_info->attributes[n],(const char *) attributes[i]);
772 CloneString(&value,attribute);
778 if (LocaleCompare(keyword,"affine") == 0)
784 draw_info->affine.sx=InterpretLocaleValue(p,&p);
787 draw_info->affine.rx=InterpretLocaleValue(p,&p);
790 draw_info->affine.ry=InterpretLocaleValue(p,&p);
793 draw_info->affine.sy=InterpretLocaleValue(p,&p);
796 draw_info->affine.tx=InterpretLocaleValue(p,&p);
799 draw_info->affine.ty=InterpretLocaleValue(p,&p);
802 if (LocaleCompare(keyword,"align") == 0)
804 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
807 ThrowMSLException(OptionError,"UnrecognizedAlignType",
809 draw_info->align=(AlignType) option;
812 if (LocaleCompare(keyword,"antialias") == 0)
814 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
817 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
819 draw_info->stroke_antialias=(MagickBooleanType) option;
820 draw_info->text_antialias=(MagickBooleanType) option;
823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
830 if (LocaleCompare(keyword,"density") == 0)
832 CloneString(&draw_info->density,value);
835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
842 if (LocaleCompare(keyword,"encoding") == 0)
844 CloneString(&draw_info->encoding,value);
847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
854 if (LocaleCompare(keyword, "fill") == 0)
856 (void) QueryColorDatabase(value,&draw_info->fill,
860 if (LocaleCompare(keyword,"family") == 0)
862 CloneString(&draw_info->family,value);
865 if (LocaleCompare(keyword,"font") == 0)
867 CloneString(&draw_info->font,value);
870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
877 if (LocaleCompare(keyword,"geometry") == 0)
879 flags=ParsePageGeometry(msl_info->image[n],value,
880 &geometry,&exception);
881 if ((flags & HeightValue) == 0)
882 geometry.height=geometry.width;
885 if (LocaleCompare(keyword,"gravity") == 0)
887 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
890 ThrowMSLException(OptionError,"UnrecognizedGravityType",
892 draw_info->gravity=(GravityType) option;
895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
902 if (LocaleCompare(keyword,"pointsize") == 0)
904 draw_info->pointsize=InterpretLocaleValue(value,
908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
915 if (LocaleCompare(keyword,"rotate") == 0)
917 angle=InterpretLocaleValue(value,(char **) NULL);
918 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
919 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
920 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
921 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
931 if (LocaleCompare(keyword,"scale") == 0)
933 flags=ParseGeometry(value,&geometry_info);
934 if ((flags & SigmaValue) == 0)
935 geometry_info.sigma=1.0;
936 affine.sx=geometry_info.rho;
937 affine.sy=geometry_info.sigma;
940 if (LocaleCompare(keyword,"skewX") == 0)
942 angle=InterpretLocaleValue(value,(char **) NULL);
943 affine.ry=tan(DegreesToRadians(fmod((double) angle,
947 if (LocaleCompare(keyword,"skewY") == 0)
949 angle=InterpretLocaleValue(value,(char **) NULL);
950 affine.rx=tan(DegreesToRadians(fmod((double) angle,
954 if (LocaleCompare(keyword,"stretch") == 0)
956 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
959 ThrowMSLException(OptionError,"UnrecognizedStretchType",
961 draw_info->stretch=(StretchType) option;
964 if (LocaleCompare(keyword, "stroke") == 0)
966 (void) QueryColorDatabase(value,&draw_info->stroke,
970 if (LocaleCompare(keyword,"strokewidth") == 0)
972 draw_info->stroke_width=StringToLong(value);
975 if (LocaleCompare(keyword,"style") == 0)
977 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
980 ThrowMSLException(OptionError,"UnrecognizedStyleType",
982 draw_info->style=(StyleType) option;
985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
992 if (LocaleCompare(keyword,"text") == 0)
994 CloneString(&draw_info->text,value);
997 if (LocaleCompare(keyword,"translate") == 0)
999 flags=ParseGeometry(value,&geometry_info);
1000 if ((flags & SigmaValue) == 0)
1001 geometry_info.sigma=1.0;
1002 affine.tx=geometry_info.rho;
1003 affine.ty=geometry_info.sigma;
1006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1013 if (LocaleCompare(keyword, "undercolor") == 0)
1015 (void) QueryColorDatabase(value,&draw_info->undercolor,
1019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1026 if (LocaleCompare(keyword,"weight") == 0)
1028 draw_info->weight=StringToLong(value);
1031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1038 if (LocaleCompare(keyword,"x") == 0)
1040 geometry.x=StringToLong(value);
1043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1050 if (LocaleCompare(keyword,"y") == 0)
1052 geometry.y=StringToLong(value);
1055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1067 (void) FormatLocaleString(text,MaxTextExtent,
1068 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1069 geometry.height,(double) geometry.x,(double) geometry.y);
1070 CloneString(&draw_info->geometry,text);
1071 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1072 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1073 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1074 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1075 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1077 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1079 (void) AnnotateImage(msl_info->image[n],draw_info);
1080 draw_info=DestroyDrawInfo(draw_info);
1083 if (LocaleCompare((const char *) tag,"append") == 0)
1091 if (msl_info->image[n] == (Image *) NULL)
1093 ThrowMSLException(OptionError,"NoImagesDefined",
1094 (const char *) tag);
1098 if (attributes != (const xmlChar **) NULL)
1099 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1101 keyword=(const char *) attributes[i++];
1102 attribute=InterpretImageProperties(msl_info->image_info[n],
1103 msl_info->attributes[n],(const char *) attributes[i]);
1104 CloneString(&value,attribute);
1110 if (LocaleCompare(keyword,"stack") == 0)
1112 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1115 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1117 stack=(MagickBooleanType) option;
1120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1132 append_image=AppendImages(msl_info->image[n],stack,
1133 &msl_info->image[n]->exception);
1134 if (append_image == (Image *) NULL)
1136 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1137 msl_info->image[n]=append_image;
1140 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1146 if (LocaleCompare((const char *) tag,"blur") == 0)
1154 if (msl_info->image[n] == (Image *) NULL)
1156 ThrowMSLException(OptionError,"NoImagesDefined",
1157 (const char *) tag);
1160 if (attributes != (const xmlChar **) NULL)
1161 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1163 keyword=(const char *) attributes[i++];
1164 attribute=InterpretImageProperties(msl_info->image_info[n],
1165 msl_info->attributes[n],(const char *) attributes[i]);
1166 CloneString(&value,attribute);
1172 if (LocaleCompare(keyword,"channel") == 0)
1174 option=ParseChannelOption(value);
1176 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1178 channel=(ChannelType) option;
1181 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1188 if (LocaleCompare(keyword,"geometry") == 0)
1190 flags=ParseGeometry(value,&geometry_info);
1191 if ((flags & SigmaValue) == 0)
1192 geometry_info.sigma=1.0;
1195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1202 if (LocaleCompare(keyword,"radius") == 0)
1204 geometry_info.rho=InterpretLocaleValue(value,
1208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1215 if (LocaleCompare(keyword,"sigma") == 0)
1217 geometry_info.sigma=StringToLong(value);
1220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1232 blur_image=BlurImageChannel(msl_info->image[n],channel,
1233 geometry_info.rho,geometry_info.sigma,
1234 &msl_info->image[n]->exception);
1235 if (blur_image == (Image *) NULL)
1237 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1238 msl_info->image[n]=blur_image;
1241 if (LocaleCompare((const char *) tag,"border") == 0)
1249 if (msl_info->image[n] == (Image *) NULL)
1251 ThrowMSLException(OptionError,"NoImagesDefined",
1252 (const char *) tag);
1255 SetGeometry(msl_info->image[n],&geometry);
1256 if (attributes != (const xmlChar **) NULL)
1257 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1259 keyword=(const char *) attributes[i++];
1260 attribute=InterpretImageProperties(msl_info->image_info[n],
1261 msl_info->attributes[n],(const char *) attributes[i]);
1262 CloneString(&value,attribute);
1268 if (LocaleCompare(keyword,"compose") == 0)
1270 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1273 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1275 msl_info->image[n]->compose=(CompositeOperator) option;
1278 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1285 if (LocaleCompare(keyword, "fill") == 0)
1287 (void) QueryColorDatabase(value,
1288 &msl_info->image[n]->border_color,&exception);
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword,"geometry") == 0)
1300 flags=ParsePageGeometry(msl_info->image[n],value,
1301 &geometry,&exception);
1302 if ((flags & HeightValue) == 0)
1303 geometry.height=geometry.width;
1306 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1313 if (LocaleCompare(keyword,"height") == 0)
1315 geometry.height=StringToLong(value);
1318 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1325 if (LocaleCompare(keyword,"width") == 0)
1327 geometry.width=StringToLong(value);
1330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1336 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1342 border_image=BorderImage(msl_info->image[n],&geometry,
1343 &msl_info->image[n]->exception);
1344 if (border_image == (Image *) NULL)
1346 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1347 msl_info->image[n]=border_image;
1350 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1355 if (LocaleCompare((const char *) tag,"colorize") == 0)
1358 opacity[MaxTextExtent];
1369 if (msl_info->image[n] == (Image *) NULL)
1371 ThrowMSLException(OptionError,"NoImagesDefined",
1372 (const char *) tag);
1375 target=msl_info->image[n]->background_color;
1376 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1377 if (attributes != (const xmlChar **) NULL)
1378 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1380 keyword=(const char *) attributes[i++];
1381 attribute=InterpretImageProperties(msl_info->image_info[n],
1382 msl_info->attributes[n],(const char *) attributes[i]);
1383 CloneString(&value,attribute);
1389 if (LocaleCompare(keyword,"fill") == 0)
1391 (void) QueryColorDatabase(value,&target,
1392 &msl_info->image[n]->exception);
1395 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1402 if (LocaleCompare(keyword,"opacity") == 0)
1404 (void) CopyMagickString(opacity,value,MaxTextExtent);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1419 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1420 &msl_info->image[n]->exception);
1421 if (colorize_image == (Image *) NULL)
1423 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1424 msl_info->image[n]=colorize_image;
1427 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1429 double radius = 0.0,
1432 if (msl_info->image[n] == (Image *) NULL)
1434 ThrowMSLException(OptionError,"NoImagesDefined",
1435 (const char *) tag);
1439 NOTE: charcoal can have no attributes, since we use all the defaults!
1441 if (attributes != (const xmlChar **) NULL)
1443 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1445 keyword=(const char *) attributes[i++];
1446 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1447 msl_info->attributes[n],(const char *) attributes[i]));
1453 if (LocaleCompare(keyword, "radius") == 0)
1455 radius = InterpretLocaleValue(value,(char **) NULL);
1458 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1464 if (LocaleCompare(keyword,"sigma") == 0)
1466 sigma = StringToLong( value );
1469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1474 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1488 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1489 &msl_info->image[n]->exception);
1490 if (newImage == (Image *) NULL)
1492 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1493 msl_info->image[n]=newImage;
1497 if (LocaleCompare((const char *) tag,"chop") == 0)
1505 if (msl_info->image[n] == (Image *) NULL)
1507 ThrowMSLException(OptionError,"NoImagesDefined",
1508 (const char *) tag);
1511 SetGeometry(msl_info->image[n],&geometry);
1512 if (attributes != (const xmlChar **) NULL)
1513 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1515 keyword=(const char *) attributes[i++];
1516 attribute=InterpretImageProperties(msl_info->image_info[n],
1517 msl_info->attributes[n],(const char *) attributes[i]);
1518 CloneString(&value,attribute);
1524 if (LocaleCompare(keyword,"geometry") == 0)
1526 flags=ParsePageGeometry(msl_info->image[n],value,
1527 &geometry,&exception);
1528 if ((flags & HeightValue) == 0)
1529 geometry.height=geometry.width;
1532 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1539 if (LocaleCompare(keyword,"height") == 0)
1541 geometry.height=StringToLong(value);
1544 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1551 if (LocaleCompare(keyword,"width") == 0)
1553 geometry.width=StringToLong(value);
1556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1563 if (LocaleCompare(keyword,"x") == 0)
1565 geometry.x=StringToLong(value);
1568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1575 if (LocaleCompare(keyword,"y") == 0)
1577 geometry.y=StringToLong(value);
1580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1592 chop_image=ChopImage(msl_info->image[n],&geometry,
1593 &msl_info->image[n]->exception);
1594 if (chop_image == (Image *) NULL)
1596 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1597 msl_info->image[n]=chop_image;
1600 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1609 Color floodfill image.
1611 if (msl_info->image[n] == (Image *) NULL)
1613 ThrowMSLException(OptionError,"NoImagesDefined",
1614 (const char *) tag);
1617 draw_info=CloneDrawInfo(msl_info->image_info[n],
1618 msl_info->draw_info[n]);
1619 SetGeometry(msl_info->image[n],&geometry);
1620 paint_method=FloodfillMethod;
1621 if (attributes != (const xmlChar **) NULL)
1622 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1624 keyword=(const char *) attributes[i++];
1625 attribute=InterpretImageProperties(msl_info->image_info[n],
1626 msl_info->attributes[n],(const char *) attributes[i]);
1627 CloneString(&value,attribute);
1633 if (LocaleCompare(keyword,"bordercolor") == 0)
1635 (void) QueryMagickColor(value,&target,&exception);
1636 paint_method=FillToBorderMethod;
1639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1646 if (LocaleCompare(keyword,"fill") == 0)
1648 (void) QueryColorDatabase(value,&draw_info->fill,
1652 if (LocaleCompare(keyword,"fuzz") == 0)
1654 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1665 if (LocaleCompare(keyword,"geometry") == 0)
1667 flags=ParsePageGeometry(msl_info->image[n],value,
1668 &geometry,&exception);
1669 if ((flags & HeightValue) == 0)
1670 geometry.height=geometry.width;
1671 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1672 geometry.x,geometry.y,&target,&exception);
1675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1682 if (LocaleCompare(keyword,"x") == 0)
1684 geometry.x=StringToLong(value);
1685 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1686 geometry.x,geometry.y,&target,&exception);
1689 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1696 if (LocaleCompare(keyword,"y") == 0)
1698 geometry.y=StringToLong(value);
1699 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1700 geometry.x,geometry.y,&target,&exception);
1703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1715 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1716 draw_info,&target,geometry.x,geometry.y,
1717 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1718 draw_info=DestroyDrawInfo(draw_info);
1721 if (LocaleCompare((const char *) tag,"comment") == 0)
1723 if (LocaleCompare((const char *) tag,"composite") == 0)
1726 composite_geometry[MaxTextExtent];
1741 if (msl_info->image[n] == (Image *) NULL)
1743 ThrowMSLException(OptionError,"NoImagesDefined",
1744 (const char *) tag);
1747 composite_image=NewImageList();
1748 compose=OverCompositeOp;
1749 if (attributes != (const xmlChar **) NULL)
1750 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1752 keyword=(const char *) attributes[i++];
1753 attribute=InterpretImageProperties(msl_info->image_info[n],
1754 msl_info->attributes[n],(const char *) attributes[i]);
1755 CloneString(&value,attribute);
1761 if (LocaleCompare(keyword,"compose") == 0)
1763 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1766 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1768 compose=(CompositeOperator) option;
1776 if (LocaleCompare(keyword,"image") == 0)
1777 for (j=0; j < msl_info->n; j++)
1782 attribute=GetImageProperty(msl_info->attributes[j],"id");
1783 if ((attribute != (const char *) NULL) &&
1784 (LocaleCompare(attribute,value) == 0))
1786 composite_image=CloneImage(msl_info->image[j],0,0,
1787 MagickFalse,&exception);
1797 if (composite_image == (Image *) NULL)
1799 rotate_image=NewImageList();
1800 SetGeometry(msl_info->image[n],&geometry);
1801 if (attributes != (const xmlChar **) NULL)
1802 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1804 keyword=(const char *) attributes[i++];
1805 attribute=InterpretImageProperties(msl_info->image_info[n],
1806 msl_info->attributes[n],(const char *) attributes[i]);
1807 CloneString(&value,attribute);
1813 if (LocaleCompare(keyword,"blend") == 0)
1815 (void) SetImageArtifact(composite_image,
1816 "compose:args",value);
1819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1826 if (LocaleCompare(keyword,"channel") == 0)
1828 option=ParseChannelOption(value);
1830 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1832 channel=(ChannelType) option;
1835 if (LocaleCompare(keyword, "color") == 0)
1837 (void) QueryColorDatabase(value,
1838 &composite_image->background_color,&exception);
1841 if (LocaleCompare(keyword,"compose") == 0)
1843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1850 if (LocaleCompare(keyword,"geometry") == 0)
1852 flags=ParsePageGeometry(msl_info->image[n],value,
1853 &geometry,&exception);
1854 if ((flags & HeightValue) == 0)
1855 geometry.height=geometry.width;
1856 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1857 geometry.y,&target,&exception);
1860 if (LocaleCompare(keyword,"gravity") == 0)
1862 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1865 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1867 msl_info->image[n]->gravity=(GravityType) option;
1870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1877 if (LocaleCompare(keyword,"image") == 0)
1879 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1886 if (LocaleCompare(keyword,"mask") == 0)
1887 for (j=0; j < msl_info->n; j++)
1892 attribute=GetImageProperty(msl_info->attributes[j],"id");
1893 if ((attribute != (const char *) NULL) &&
1894 (LocaleCompare(value,value) == 0))
1896 SetImageType(composite_image,TrueColorMatteType);
1897 (void) CompositeImage(composite_image,
1898 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1909 if (LocaleCompare(keyword,"opacity") == 0)
1924 opacity=StringToLong(value);
1925 if (compose != DissolveCompositeOp)
1927 (void) SetImageOpacity(composite_image,(Quantum)
1931 (void) SetImageArtifact(msl_info->image[n],
1932 "compose:args",value);
1933 if (composite_image->matte != MagickTrue)
1934 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1935 composite_view=AcquireCacheView(composite_image);
1936 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1938 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1939 (ssize_t) composite_image->columns,1,&exception);
1940 for (x=0; x < (ssize_t) composite_image->columns; x++)
1942 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1943 SetPixelAlpha(composite_image,
1944 ClampToQuantum(opacity),q);
1945 q+=GetPixelChannels(composite_image);
1947 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1950 composite_view=DestroyCacheView(composite_view);
1953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1960 if (LocaleCompare(keyword,"rotate") == 0)
1962 rotate_image=RotateImage(composite_image,
1963 InterpretLocaleValue(value,(char **) NULL),&exception);
1966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1973 if (LocaleCompare(keyword,"tile") == 0)
1978 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1981 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1983 tile=(MagickBooleanType) option;
1985 if (rotate_image != (Image *) NULL)
1986 (void) SetImageArtifact(rotate_image,
1987 "compose:outside-overlay","false");
1989 (void) SetImageArtifact(composite_image,
1990 "compose:outside-overlay","false");
1991 image=msl_info->image[n];
1992 height=composite_image->rows;
1993 width=composite_image->columns;
1994 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1995 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1997 if (rotate_image != (Image *) NULL)
1998 (void) CompositeImage(image,compose,rotate_image,
2001 (void) CompositeImage(image,compose,
2002 composite_image,x,y);
2004 if (rotate_image != (Image *) NULL)
2005 rotate_image=DestroyImage(rotate_image);
2008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2015 if (LocaleCompare(keyword,"x") == 0)
2017 geometry.x=StringToLong(value);
2018 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2019 geometry.y,&target,&exception);
2022 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2029 if (LocaleCompare(keyword,"y") == 0)
2031 geometry.y=StringToLong(value);
2032 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2033 geometry.y,&target,&exception);
2036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2048 image=msl_info->image[n];
2049 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2050 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2051 (double) composite_image->rows,(double) geometry.x,(double)
2053 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2055 if (rotate_image == (Image *) NULL)
2056 CompositeImageChannel(image,channel,compose,composite_image,
2057 geometry.x,geometry.y);
2063 geometry.x-=(ssize_t) (rotate_image->columns-
2064 composite_image->columns)/2;
2065 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2066 CompositeImageChannel(image,channel,compose,rotate_image,
2067 geometry.x,geometry.y);
2068 rotate_image=DestroyImage(rotate_image);
2070 composite_image=DestroyImage(composite_image);
2073 if (LocaleCompare((const char *) tag,"contrast") == 0)
2081 if (msl_info->image[n] == (Image *) NULL)
2083 ThrowMSLException(OptionError,"NoImagesDefined",
2084 (const char *) tag);
2087 sharpen=MagickFalse;
2088 if (attributes != (const xmlChar **) NULL)
2089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2091 keyword=(const char *) attributes[i++];
2092 attribute=InterpretImageProperties(msl_info->image_info[n],
2093 msl_info->attributes[n],(const char *) attributes[i]);
2094 CloneString(&value,attribute);
2100 if (LocaleCompare(keyword,"sharpen") == 0)
2102 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2105 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2107 sharpen=(MagickBooleanType) option;
2110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2122 (void) ContrastImage(msl_info->image[n],sharpen);
2125 if (LocaleCompare((const char *) tag,"crop") == 0)
2133 if (msl_info->image[n] == (Image *) NULL)
2135 ThrowMSLException(OptionError,"NoImagesDefined",
2136 (const char *) tag);
2139 SetGeometry(msl_info->image[n],&geometry);
2140 if (attributes != (const xmlChar **) NULL)
2141 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2143 keyword=(const char *) attributes[i++];
2144 attribute=InterpretImageProperties(msl_info->image_info[n],
2145 msl_info->attributes[n],(const char *) attributes[i]);
2146 CloneString(&value,attribute);
2152 if (LocaleCompare(keyword,"geometry") == 0)
2154 flags=ParsePageGeometry(msl_info->image[n],value,
2155 &geometry,&exception);
2156 if ((flags & HeightValue) == 0)
2157 geometry.height=geometry.width;
2160 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2167 if (LocaleCompare(keyword,"height") == 0)
2169 geometry.height=StringToLong(value);
2172 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2179 if (LocaleCompare(keyword,"width") == 0)
2181 geometry.width=StringToLong(value);
2184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2191 if (LocaleCompare(keyword,"x") == 0)
2193 geometry.x=StringToLong(value);
2196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 if (LocaleCompare(keyword,"y") == 0)
2205 geometry.y=StringToLong(value);
2208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2220 crop_image=CropImage(msl_info->image[n],&geometry,
2221 &msl_info->image[n]->exception);
2222 if (crop_image == (Image *) NULL)
2224 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2225 msl_info->image[n]=crop_image;
2228 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2234 Cycle-colormap image.
2236 if (msl_info->image[n] == (Image *) NULL)
2238 ThrowMSLException(OptionError,"NoImagesDefined",
2239 (const char *) tag);
2243 if (attributes != (const xmlChar **) NULL)
2244 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2246 keyword=(const char *) attributes[i++];
2247 attribute=InterpretImageProperties(msl_info->image_info[n],
2248 msl_info->attributes[n],(const char *) attributes[i]);
2249 CloneString(&value,attribute);
2255 if (LocaleCompare(keyword,"display") == 0)
2257 display=StringToLong(value);
2260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2272 (void) CycleColormapImage(msl_info->image[n],display);
2275 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2280 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2288 if (msl_info->image[n] == (Image *) NULL)
2290 ThrowMSLException(OptionError,"NoImagesDefined",
2291 (const char *) tag);
2294 if (attributes != (const xmlChar **) NULL)
2295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2297 keyword=(const char *) attributes[i++];
2298 attribute=InterpretImageProperties(msl_info->image_info[n],
2299 msl_info->attributes[n],(const char *) attributes[i]);
2300 CloneString(&value,attribute);
2301 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2303 despeckle_image=DespeckleImage(msl_info->image[n],
2304 &msl_info->image[n]->exception);
2305 if (despeckle_image == (Image *) NULL)
2307 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2308 msl_info->image[n]=despeckle_image;
2311 if (LocaleCompare((const char *) tag,"display") == 0)
2313 if (msl_info->image[n] == (Image *) NULL)
2315 ThrowMSLException(OptionError,"NoImagesDefined",
2316 (const char *) tag);
2319 if (attributes != (const xmlChar **) NULL)
2320 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2322 keyword=(const char *) attributes[i++];
2323 attribute=InterpretImageProperties(msl_info->image_info[n],
2324 msl_info->attributes[n],(const char *) attributes[i]);
2325 CloneString(&value,attribute);
2330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2336 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2339 if (LocaleCompare((const char *) tag,"draw") == 0)
2342 text[MaxTextExtent];
2347 if (msl_info->image[n] == (Image *) NULL)
2349 ThrowMSLException(OptionError,"NoImagesDefined",
2350 (const char *) tag);
2353 draw_info=CloneDrawInfo(msl_info->image_info[n],
2354 msl_info->draw_info[n]);
2356 current=draw_info->affine;
2357 GetAffineMatrix(&affine);
2358 if (attributes != (const xmlChar **) NULL)
2359 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2361 keyword=(const char *) attributes[i++];
2362 attribute=InterpretImageProperties(msl_info->image_info[n],
2363 msl_info->attributes[n],(const char *) attributes[i]);
2364 CloneString(&value,attribute);
2370 if (LocaleCompare(keyword,"affine") == 0)
2376 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2379 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2382 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2385 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2388 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2391 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2394 if (LocaleCompare(keyword,"align") == 0)
2396 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2399 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2401 draw_info->align=(AlignType) option;
2404 if (LocaleCompare(keyword,"antialias") == 0)
2406 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2409 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2411 draw_info->stroke_antialias=(MagickBooleanType) option;
2412 draw_info->text_antialias=(MagickBooleanType) option;
2415 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2422 if (LocaleCompare(keyword,"density") == 0)
2424 CloneString(&draw_info->density,value);
2427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2434 if (LocaleCompare(keyword,"encoding") == 0)
2436 CloneString(&draw_info->encoding,value);
2439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2446 if (LocaleCompare(keyword, "fill") == 0)
2448 (void) QueryColorDatabase(value,&draw_info->fill,
2452 if (LocaleCompare(keyword,"family") == 0)
2454 CloneString(&draw_info->family,value);
2457 if (LocaleCompare(keyword,"font") == 0)
2459 CloneString(&draw_info->font,value);
2462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2469 if (LocaleCompare(keyword,"geometry") == 0)
2471 flags=ParsePageGeometry(msl_info->image[n],value,
2472 &geometry,&exception);
2473 if ((flags & HeightValue) == 0)
2474 geometry.height=geometry.width;
2477 if (LocaleCompare(keyword,"gravity") == 0)
2479 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2482 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2484 draw_info->gravity=(GravityType) option;
2487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2494 if (LocaleCompare(keyword,"primitive") == 0)
2496 CloneString(&draw_info->primitive,value);
2499 if (LocaleCompare(keyword,"pointsize") == 0)
2501 draw_info->pointsize=InterpretLocaleValue(value,
2505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2512 if (LocaleCompare(keyword,"rotate") == 0)
2514 angle=InterpretLocaleValue(value,(char **) NULL);
2515 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2516 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2517 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2518 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2521 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2528 if (LocaleCompare(keyword,"scale") == 0)
2530 flags=ParseGeometry(value,&geometry_info);
2531 if ((flags & SigmaValue) == 0)
2532 geometry_info.sigma=1.0;
2533 affine.sx=geometry_info.rho;
2534 affine.sy=geometry_info.sigma;
2537 if (LocaleCompare(keyword,"skewX") == 0)
2539 angle=InterpretLocaleValue(value,(char **) NULL);
2540 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2543 if (LocaleCompare(keyword,"skewY") == 0)
2545 angle=InterpretLocaleValue(value,(char **) NULL);
2546 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2549 if (LocaleCompare(keyword,"stretch") == 0)
2551 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2554 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2556 draw_info->stretch=(StretchType) option;
2559 if (LocaleCompare(keyword, "stroke") == 0)
2561 (void) QueryColorDatabase(value,&draw_info->stroke,
2565 if (LocaleCompare(keyword,"strokewidth") == 0)
2567 draw_info->stroke_width=StringToLong(value);
2570 if (LocaleCompare(keyword,"style") == 0)
2572 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2575 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2577 draw_info->style=(StyleType) option;
2580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2587 if (LocaleCompare(keyword,"text") == 0)
2589 CloneString(&draw_info->text,value);
2592 if (LocaleCompare(keyword,"translate") == 0)
2594 flags=ParseGeometry(value,&geometry_info);
2595 if ((flags & SigmaValue) == 0)
2596 geometry_info.sigma=1.0;
2597 affine.tx=geometry_info.rho;
2598 affine.ty=geometry_info.sigma;
2601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2608 if (LocaleCompare(keyword, "undercolor") == 0)
2610 (void) QueryColorDatabase(value,&draw_info->undercolor,
2614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2621 if (LocaleCompare(keyword,"weight") == 0)
2623 draw_info->weight=StringToLong(value);
2626 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2633 if (LocaleCompare(keyword,"x") == 0)
2635 geometry.x=StringToLong(value);
2638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2645 if (LocaleCompare(keyword,"y") == 0)
2647 geometry.y=StringToLong(value);
2650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2662 (void) FormatLocaleString(text,MaxTextExtent,
2663 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2664 geometry.height,(double) geometry.x,(double) geometry.y);
2665 CloneString(&draw_info->geometry,text);
2666 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2667 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2668 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2669 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2670 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2672 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2674 (void) DrawImage(msl_info->image[n],draw_info);
2675 draw_info=DestroyDrawInfo(draw_info);
2678 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2683 if (LocaleCompare((const char *) tag,"edge") == 0)
2691 if (msl_info->image[n] == (Image *) NULL)
2693 ThrowMSLException(OptionError,"NoImagesDefined",
2694 (const char *) tag);
2697 if (attributes != (const xmlChar **) NULL)
2698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2700 keyword=(const char *) attributes[i++];
2701 attribute=InterpretImageProperties(msl_info->image_info[n],
2702 msl_info->attributes[n],(const char *) attributes[i]);
2703 CloneString(&value,attribute);
2709 if (LocaleCompare(keyword,"geometry") == 0)
2711 flags=ParseGeometry(value,&geometry_info);
2712 if ((flags & SigmaValue) == 0)
2713 geometry_info.sigma=1.0;
2716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2723 if (LocaleCompare(keyword,"radius") == 0)
2725 geometry_info.rho=InterpretLocaleValue(value,
2729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2741 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2742 &msl_info->image[n]->exception);
2743 if (edge_image == (Image *) NULL)
2745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2746 msl_info->image[n]=edge_image;
2749 if (LocaleCompare((const char *) tag,"emboss") == 0)
2757 if (msl_info->image[n] == (Image *) NULL)
2759 ThrowMSLException(OptionError,"NoImagesDefined",
2760 (const char *) tag);
2763 if (attributes != (const xmlChar **) NULL)
2764 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2766 keyword=(const char *) attributes[i++];
2767 attribute=InterpretImageProperties(msl_info->image_info[n],
2768 msl_info->attributes[n],(const char *) attributes[i]);
2769 CloneString(&value,attribute);
2775 if (LocaleCompare(keyword,"geometry") == 0)
2777 flags=ParseGeometry(value,&geometry_info);
2778 if ((flags & SigmaValue) == 0)
2779 geometry_info.sigma=1.0;
2782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2789 if (LocaleCompare(keyword,"radius") == 0)
2791 geometry_info.rho=InterpretLocaleValue(value,
2795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2802 if (LocaleCompare(keyword,"sigma") == 0)
2804 geometry_info.sigma=StringToLong(value);
2807 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2819 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2820 geometry_info.sigma,&msl_info->image[n]->exception);
2821 if (emboss_image == (Image *) NULL)
2823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2824 msl_info->image[n]=emboss_image;
2827 if (LocaleCompare((const char *) tag,"enhance") == 0)
2835 if (msl_info->image[n] == (Image *) NULL)
2837 ThrowMSLException(OptionError,"NoImagesDefined",
2838 (const char *) tag);
2841 if (attributes != (const xmlChar **) NULL)
2842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2844 keyword=(const char *) attributes[i++];
2845 attribute=InterpretImageProperties(msl_info->image_info[n],
2846 msl_info->attributes[n],(const char *) attributes[i]);
2847 CloneString(&value,attribute);
2848 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2850 enhance_image=EnhanceImage(msl_info->image[n],
2851 &msl_info->image[n]->exception);
2852 if (enhance_image == (Image *) NULL)
2854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2855 msl_info->image[n]=enhance_image;
2858 if (LocaleCompare((const char *) tag,"equalize") == 0)
2863 if (msl_info->image[n] == (Image *) NULL)
2865 ThrowMSLException(OptionError,"NoImagesDefined",
2866 (const char *) tag);
2869 if (attributes != (const xmlChar **) NULL)
2870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2872 keyword=(const char *) attributes[i++];
2873 attribute=InterpretImageProperties(msl_info->image_info[n],
2874 msl_info->attributes[n],(const char *) attributes[i]);
2875 CloneString(&value,attribute);
2880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2886 (void) EqualizeImage(msl_info->image[n]);
2889 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2894 if (LocaleCompare((const char *) tag, "flatten") == 0)
2896 if (msl_info->image[n] == (Image *) NULL)
2898 ThrowMSLException(OptionError,"NoImagesDefined",
2899 (const char *) tag);
2903 /* no attributes here */
2905 /* process the image */
2910 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2911 &msl_info->image[n]->exception);
2912 if (newImage == (Image *) NULL)
2914 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2915 msl_info->image[n]=newImage;
2919 if (LocaleCompare((const char *) tag,"flip") == 0)
2927 if (msl_info->image[n] == (Image *) NULL)
2929 ThrowMSLException(OptionError,"NoImagesDefined",
2930 (const char *) tag);
2933 if (attributes != (const xmlChar **) NULL)
2934 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2936 keyword=(const char *) attributes[i++];
2937 attribute=InterpretImageProperties(msl_info->image_info[n],
2938 msl_info->attributes[n],(const char *) attributes[i]);
2939 CloneString(&value,attribute);
2940 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2942 flip_image=FlipImage(msl_info->image[n],
2943 &msl_info->image[n]->exception);
2944 if (flip_image == (Image *) NULL)
2946 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2947 msl_info->image[n]=flip_image;
2950 if (LocaleCompare((const char *) tag,"flop") == 0)
2958 if (msl_info->image[n] == (Image *) NULL)
2960 ThrowMSLException(OptionError,"NoImagesDefined",
2961 (const char *) tag);
2964 if (attributes != (const xmlChar **) NULL)
2965 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2967 keyword=(const char *) attributes[i++];
2968 attribute=InterpretImageProperties(msl_info->image_info[n],
2969 msl_info->attributes[n],(const char *) attributes[i]);
2970 CloneString(&value,attribute);
2971 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2973 flop_image=FlopImage(msl_info->image[n],
2974 &msl_info->image[n]->exception);
2975 if (flop_image == (Image *) NULL)
2977 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2978 msl_info->image[n]=flop_image;
2981 if (LocaleCompare((const char *) tag,"frame") == 0)
2992 if (msl_info->image[n] == (Image *) NULL)
2994 ThrowMSLException(OptionError,"NoImagesDefined",
2995 (const char *) tag);
2998 SetGeometry(msl_info->image[n],&geometry);
2999 if (attributes != (const xmlChar **) NULL)
3000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3002 keyword=(const char *) attributes[i++];
3003 attribute=InterpretImageProperties(msl_info->image_info[n],
3004 msl_info->attributes[n],(const char *) attributes[i]);
3005 CloneString(&value,attribute);
3011 if (LocaleCompare(keyword,"compose") == 0)
3013 option=ParseCommandOption(MagickComposeOptions,
3016 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3018 msl_info->image[n]->compose=(CompositeOperator) option;
3021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3028 if (LocaleCompare(keyword, "fill") == 0)
3030 (void) QueryColorDatabase(value,
3031 &msl_info->image[n]->matte_color,&exception);
3034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3041 if (LocaleCompare(keyword,"geometry") == 0)
3043 flags=ParsePageGeometry(msl_info->image[n],value,
3044 &geometry,&exception);
3045 if ((flags & HeightValue) == 0)
3046 geometry.height=geometry.width;
3047 frame_info.width=geometry.width;
3048 frame_info.height=geometry.height;
3049 frame_info.outer_bevel=geometry.x;
3050 frame_info.inner_bevel=geometry.y;
3053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3060 if (LocaleCompare(keyword,"height") == 0)
3062 frame_info.height=StringToLong(value);
3065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3072 if (LocaleCompare(keyword,"inner") == 0)
3074 frame_info.inner_bevel=StringToLong(value);
3077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3084 if (LocaleCompare(keyword,"outer") == 0)
3086 frame_info.outer_bevel=StringToLong(value);
3089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3096 if (LocaleCompare(keyword,"width") == 0)
3098 frame_info.width=StringToLong(value);
3101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3113 frame_info.x=(ssize_t) frame_info.width;
3114 frame_info.y=(ssize_t) frame_info.height;
3115 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3116 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3117 frame_image=FrameImage(msl_info->image[n],&frame_info,
3118 &msl_info->image[n]->exception);
3119 if (frame_image == (Image *) NULL)
3121 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3122 msl_info->image[n]=frame_image;
3125 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3130 if (LocaleCompare((const char *) tag,"gamma") == 0)
3133 gamma[MaxTextExtent];
3141 if (msl_info->image[n] == (Image *) NULL)
3143 ThrowMSLException(OptionError,"NoImagesDefined",
3144 (const char *) tag);
3147 channel=UndefinedChannel;
3152 if (attributes != (const xmlChar **) NULL)
3153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3155 keyword=(const char *) attributes[i++];
3156 attribute=InterpretImageProperties(msl_info->image_info[n],
3157 msl_info->attributes[n],(const char *) attributes[i]);
3158 CloneString(&value,attribute);
3164 if (LocaleCompare(keyword,"blue") == 0)
3166 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3169 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3176 if (LocaleCompare(keyword,"channel") == 0)
3178 option=ParseChannelOption(value);
3180 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3182 channel=(ChannelType) option;
3185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3192 if (LocaleCompare(keyword,"gamma") == 0)
3194 (void) CopyMagickString(gamma,value,MaxTextExtent);
3197 if (LocaleCompare(keyword,"green") == 0)
3199 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3209 if (LocaleCompare(keyword,"red") == 0)
3211 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3227 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3228 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3233 (void) GammaImage(msl_info->image[n],gamma);
3238 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3243 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3249 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3256 else if (LocaleCompare((const char *) tag,"get") == 0)
3258 if (msl_info->image[n] == (Image *) NULL)
3260 ThrowMSLException(OptionError,"NoImagesDefined",
3261 (const char *) tag);
3264 if (attributes == (const xmlChar **) NULL)
3266 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3268 keyword=(const char *) attributes[i++];
3269 CloneString(&value,(const char *) attributes[i]);
3270 (void) CopyMagickString(key,value,MaxTextExtent);
3276 if (LocaleCompare(keyword,"height") == 0)
3278 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3279 (double) msl_info->image[n]->rows);
3280 (void) SetImageProperty(msl_info->attributes[n],key,value);
3283 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3288 if (LocaleCompare(keyword,"width") == 0)
3290 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3291 (double) msl_info->image[n]->columns);
3292 (void) SetImageProperty(msl_info->attributes[n],key,value);
3295 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3299 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3306 else if (LocaleCompare((const char *) tag, "group") == 0)
3308 msl_info->number_groups++;
3309 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3310 msl_info->group_info,msl_info->number_groups+1UL,
3311 sizeof(*msl_info->group_info));
3314 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3319 if (LocaleCompare((const char *) tag,"image") == 0)
3321 MSLPushImage(msl_info,(Image *) NULL);
3322 if (attributes == (const xmlChar **) NULL)
3324 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3326 keyword=(const char *) attributes[i++];
3327 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3328 msl_info->attributes[n],(const char *) attributes[i]));
3334 if (LocaleCompare(keyword,"color") == 0)
3339 (void) CopyMagickString(msl_info->image_info[n]->filename,
3340 "xc:",MaxTextExtent);
3341 (void) ConcatenateMagickString(msl_info->image_info[n]->
3342 filename,value,MaxTextExtent);
3343 next_image=ReadImage(msl_info->image_info[n],&exception);
3344 CatchException(&exception);
3345 if (next_image == (Image *) NULL)
3347 if (msl_info->image[n] == (Image *) NULL)
3348 msl_info->image[n]=next_image;
3355 Link image into image list.
3357 p=msl_info->image[n];
3358 while (p->next != (Image *) NULL)
3359 p=GetNextImageInList(p);
3360 next_image->previous=p;
3365 (void) SetMSLAttributes(msl_info,keyword,value);
3370 (void) SetMSLAttributes(msl_info,keyword,value);
3377 if (LocaleCompare((const char *) tag,"implode") == 0)
3385 if (msl_info->image[n] == (Image *) NULL)
3387 ThrowMSLException(OptionError,"NoImagesDefined",
3388 (const char *) tag);
3391 if (attributes != (const xmlChar **) NULL)
3392 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3394 keyword=(const char *) attributes[i++];
3395 attribute=InterpretImageProperties(msl_info->image_info[n],
3396 msl_info->attributes[n],(const char *) attributes[i]);
3397 CloneString(&value,attribute);
3403 if (LocaleCompare(keyword,"amount") == 0)
3405 geometry_info.rho=InterpretLocaleValue(value,
3409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3416 if (LocaleCompare(keyword,"geometry") == 0)
3418 flags=ParseGeometry(value,&geometry_info);
3419 if ((flags & SigmaValue) == 0)
3420 geometry_info.sigma=1.0;
3423 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3429 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3435 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3436 &msl_info->image[n]->exception);
3437 if (implode_image == (Image *) NULL)
3439 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3440 msl_info->image[n]=implode_image;
3443 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3448 if (LocaleCompare((const char *) tag,"label") == 0)
3450 if (LocaleCompare((const char *) tag, "level") == 0)
3453 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3455 if (msl_info->image[n] == (Image *) NULL)
3457 ThrowMSLException(OptionError,"NoImagesDefined",
3458 (const char *) tag);
3461 if (attributes == (const xmlChar **) NULL)
3463 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3465 keyword=(const char *) attributes[i++];
3466 CloneString(&value,(const char *) attributes[i]);
3467 (void) CopyMagickString(key,value,MaxTextExtent);
3473 if (LocaleCompare(keyword,"black") == 0)
3475 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3484 if (LocaleCompare(keyword,"gamma") == 0)
3486 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3495 if (LocaleCompare(keyword,"white") == 0)
3497 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3500 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3505 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3513 char level[MaxTextExtent + 1];
3514 (void) FormatLocaleString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3515 levelBlack,levelGamma,levelWhite);
3516 LevelImage ( msl_info->image[n], level );
3524 if (LocaleCompare((const char *) tag,"magnify") == 0)
3532 if (msl_info->image[n] == (Image *) NULL)
3534 ThrowMSLException(OptionError,"NoImagesDefined",
3535 (const char *) tag);
3538 if (attributes != (const xmlChar **) NULL)
3539 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3541 keyword=(const char *) attributes[i++];
3542 attribute=InterpretImageProperties(msl_info->image_info[n],
3543 msl_info->attributes[n],(const char *) attributes[i]);
3544 CloneString(&value,attribute);
3545 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3547 magnify_image=MagnifyImage(msl_info->image[n],
3548 &msl_info->image[n]->exception);
3549 if (magnify_image == (Image *) NULL)
3551 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3552 msl_info->image[n]=magnify_image;
3555 if (LocaleCompare((const char *) tag,"map") == 0)
3569 if (msl_info->image[n] == (Image *) NULL)
3571 ThrowMSLException(OptionError,"NoImagesDefined",
3572 (const char *) tag);
3575 affinity_image=NewImageList();
3577 if (attributes != (const xmlChar **) NULL)
3578 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3580 keyword=(const char *) attributes[i++];
3581 attribute=InterpretImageProperties(msl_info->image_info[n],
3582 msl_info->attributes[n],(const char *) attributes[i]);
3583 CloneString(&value,attribute);
3589 if (LocaleCompare(keyword,"dither") == 0)
3591 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3594 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3596 dither=(MagickBooleanType) option;
3599 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3606 if (LocaleCompare(keyword,"image") == 0)
3607 for (j=0; j < msl_info->n; j++)
3612 attribute=GetImageProperty(msl_info->attributes[j],"id");
3613 if ((attribute != (const char *) NULL) &&
3614 (LocaleCompare(attribute,value) == 0))
3616 affinity_image=CloneImage(msl_info->image[j],0,0,
3617 MagickFalse,&exception);
3625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3631 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3632 quantize_info->dither=dither;
3633 (void) RemapImages(quantize_info,msl_info->image[n],
3635 quantize_info=DestroyQuantizeInfo(quantize_info);
3636 affinity_image=DestroyImage(affinity_image);
3639 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3651 Matte floodfill image.
3654 if (msl_info->image[n] == (Image *) NULL)
3656 ThrowMSLException(OptionError,"NoImagesDefined",
3657 (const char *) tag);
3660 SetGeometry(msl_info->image[n],&geometry);
3661 paint_method=FloodfillMethod;
3662 if (attributes != (const xmlChar **) NULL)
3663 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3665 keyword=(const char *) attributes[i++];
3666 attribute=InterpretImageProperties(msl_info->image_info[n],
3667 msl_info->attributes[n],(const char *) attributes[i]);
3668 CloneString(&value,attribute);
3674 if (LocaleCompare(keyword,"bordercolor") == 0)
3676 (void) QueryMagickColor(value,&target,&exception);
3677 paint_method=FillToBorderMethod;
3680 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3687 if (LocaleCompare(keyword,"fuzz") == 0)
3689 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3700 if (LocaleCompare(keyword,"geometry") == 0)
3702 flags=ParsePageGeometry(msl_info->image[n],value,
3703 &geometry,&exception);
3704 if ((flags & HeightValue) == 0)
3705 geometry.height=geometry.width;
3706 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3707 geometry.x,geometry.y,&target,&exception);
3710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3717 if (LocaleCompare(keyword,"opacity") == 0)
3719 opacity=InterpretLocaleValue(value,(char **) NULL);
3722 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3729 if (LocaleCompare(keyword,"x") == 0)
3731 geometry.x=StringToLong(value);
3732 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3733 geometry.x,geometry.y,&target,&exception);
3736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3743 if (LocaleCompare(keyword,"y") == 0)
3745 geometry.y=StringToLong(value);
3746 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3747 geometry.x,geometry.y,&target,&exception);
3750 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3756 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3762 draw_info=CloneDrawInfo(msl_info->image_info[n],
3763 msl_info->draw_info[n]);
3764 draw_info->fill.alpha=ClampToQuantum(opacity);
3765 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3766 draw_info,&target,geometry.x,geometry.y,
3767 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3768 draw_info=DestroyDrawInfo(draw_info);
3771 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3777 Median-filter image.
3779 if (msl_info->image[n] == (Image *) NULL)
3781 ThrowMSLException(OptionError,"NoImagesDefined",
3782 (const char *) tag);
3785 if (attributes != (const xmlChar **) NULL)
3786 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3788 keyword=(const char *) attributes[i++];
3789 attribute=InterpretImageProperties(msl_info->image_info[n],
3790 msl_info->attributes[n],(const char *) attributes[i]);
3791 CloneString(&value,attribute);
3797 if (LocaleCompare(keyword,"geometry") == 0)
3799 flags=ParseGeometry(value,&geometry_info);
3800 if ((flags & SigmaValue) == 0)
3801 geometry_info.sigma=1.0;
3804 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3811 if (LocaleCompare(keyword,"radius") == 0)
3813 geometry_info.rho=InterpretLocaleValue(value,
3817 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3829 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3830 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3831 &msl_info->image[n]->exception);
3832 if (median_image == (Image *) NULL)
3834 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3835 msl_info->image[n]=median_image;
3838 if (LocaleCompare((const char *) tag,"minify") == 0)
3846 if (msl_info->image[n] == (Image *) NULL)
3848 ThrowMSLException(OptionError,"NoImagesDefined",
3849 (const char *) tag);
3852 if (attributes != (const xmlChar **) NULL)
3853 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3855 keyword=(const char *) attributes[i++];
3856 attribute=InterpretImageProperties(msl_info->image_info[n],
3857 msl_info->attributes[n],(const char *) attributes[i]);
3858 CloneString(&value,attribute);
3859 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3861 minify_image=MinifyImage(msl_info->image[n],
3862 &msl_info->image[n]->exception);
3863 if (minify_image == (Image *) NULL)
3865 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3866 msl_info->image[n]=minify_image;
3869 if (LocaleCompare((const char *) tag,"msl") == 0 )
3871 if (LocaleCompare((const char *) tag,"modulate") == 0)
3874 modulate[MaxTextExtent];
3879 if (msl_info->image[n] == (Image *) NULL)
3881 ThrowMSLException(OptionError,"NoImagesDefined",
3882 (const char *) tag);
3885 geometry_info.rho=100.0;
3886 geometry_info.sigma=100.0;
3887 geometry_info.xi=100.0;
3888 if (attributes != (const xmlChar **) NULL)
3889 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3891 keyword=(const char *) attributes[i++];
3892 attribute=InterpretImageProperties(msl_info->image_info[n],
3893 msl_info->attributes[n],(const char *) attributes[i]);
3894 CloneString(&value,attribute);
3900 if (LocaleCompare(keyword,"blackness") == 0)
3902 geometry_info.rho=InterpretLocaleValue(value,
3906 if (LocaleCompare(keyword,"brightness") == 0)
3908 geometry_info.rho=InterpretLocaleValue(value,
3912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3919 if (LocaleCompare(keyword,"factor") == 0)
3921 flags=ParseGeometry(value,&geometry_info);
3924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3931 if (LocaleCompare(keyword,"hue") == 0)
3933 geometry_info.xi=InterpretLocaleValue(value,
3937 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3944 if (LocaleCompare(keyword,"lightness") == 0)
3946 geometry_info.rho=InterpretLocaleValue(value,
3950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3957 if (LocaleCompare(keyword,"saturation") == 0)
3959 geometry_info.sigma=InterpretLocaleValue(value,
3963 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3970 if (LocaleCompare(keyword,"whiteness") == 0)
3972 geometry_info.sigma=InterpretLocaleValue(value,
3976 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3982 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3988 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3989 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3990 (void) ModulateImage(msl_info->image[n],modulate);
3993 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3998 if (LocaleCompare((const char *) tag,"negate") == 0)
4006 if (msl_info->image[n] == (Image *) NULL)
4008 ThrowMSLException(OptionError,"NoImagesDefined",
4009 (const char *) tag);
4013 if (attributes != (const xmlChar **) NULL)
4014 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4016 keyword=(const char *) attributes[i++];
4017 attribute=InterpretImageProperties(msl_info->image_info[n],
4018 msl_info->attributes[n],(const char *) attributes[i]);
4019 CloneString(&value,attribute);
4025 if (LocaleCompare(keyword,"channel") == 0)
4027 option=ParseChannelOption(value);
4029 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4031 channel=(ChannelType) option;
4034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4041 if (LocaleCompare(keyword,"gray") == 0)
4043 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4046 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4048 gray=(MagickBooleanType) option;
4051 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4063 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4066 if (LocaleCompare((const char *) tag,"normalize") == 0)
4071 if (msl_info->image[n] == (Image *) NULL)
4073 ThrowMSLException(OptionError,"NoImagesDefined",
4074 (const char *) tag);
4077 if (attributes != (const xmlChar **) NULL)
4078 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4080 keyword=(const char *) attributes[i++];
4081 attribute=InterpretImageProperties(msl_info->image_info[n],
4082 msl_info->attributes[n],(const char *) attributes[i]);
4083 CloneString(&value,attribute);
4089 if (LocaleCompare(keyword,"channel") == 0)
4091 option=ParseChannelOption(value);
4093 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4095 channel=(ChannelType) option;
4098 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4110 (void) NormalizeImageChannel(msl_info->image[n],channel);
4113 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4118 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4126 if (msl_info->image[n] == (Image *) NULL)
4128 ThrowMSLException(OptionError,"NoImagesDefined",
4129 (const char *) tag);
4132 if (attributes != (const xmlChar **) NULL)
4133 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4135 keyword=(const char *) attributes[i++];
4136 attribute=InterpretImageProperties(msl_info->image_info[n],
4137 msl_info->attributes[n],(const char *) attributes[i]);
4138 CloneString(&value,attribute);
4144 if (LocaleCompare(keyword,"geometry") == 0)
4146 flags=ParseGeometry(value,&geometry_info);
4147 if ((flags & SigmaValue) == 0)
4148 geometry_info.sigma=1.0;
4151 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4158 if (LocaleCompare(keyword,"radius") == 0)
4160 geometry_info.rho=InterpretLocaleValue(value,
4164 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4170 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4176 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4177 &msl_info->image[n]->exception);
4178 if (paint_image == (Image *) NULL)
4180 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4181 msl_info->image[n]=paint_image;
4184 if (LocaleCompare((const char *) tag,"opaque") == 0)
4193 if (msl_info->image[n] == (Image *) NULL)
4195 ThrowMSLException(OptionError,"NoImagesDefined",
4196 (const char *) tag);
4199 (void) QueryMagickColor("none",&target,&exception);
4200 (void) QueryMagickColor("none",&fill_color,&exception);
4201 if (attributes != (const xmlChar **) NULL)
4202 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4204 keyword=(const char *) attributes[i++];
4205 attribute=InterpretImageProperties(msl_info->image_info[n],
4206 msl_info->attributes[n],(const char *) attributes[i]);
4207 CloneString(&value,attribute);
4213 if (LocaleCompare(keyword,"channel") == 0)
4215 option=ParseChannelOption(value);
4217 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4219 channel=(ChannelType) option;
4222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4229 if (LocaleCompare(keyword,"fill") == 0)
4231 (void) QueryMagickColor(value,&fill_color,&exception);
4234 if (LocaleCompare(keyword,"fuzz") == 0)
4236 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4252 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4253 &target,&fill_color,MagickFalse);
4256 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4261 if (LocaleCompare((const char *) tag,"print") == 0)
4263 if (attributes == (const xmlChar **) NULL)
4265 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4267 keyword=(const char *) attributes[i++];
4268 attribute=InterpretImageProperties(msl_info->image_info[n],
4269 msl_info->attributes[n],(const char *) attributes[i]);
4270 CloneString(&value,attribute);
4276 if (LocaleCompare(keyword,"output") == 0)
4278 (void) FormatLocaleFile(stdout,"%s",value);
4281 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4286 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4293 if (LocaleCompare((const char *) tag, "profile") == 0)
4295 if (msl_info->image[n] == (Image *) NULL)
4297 ThrowMSLException(OptionError,"NoImagesDefined",
4298 (const char *) tag);
4301 if (attributes == (const xmlChar **) NULL)
4303 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4317 keyword=(const char *) attributes[i++];
4318 attribute=InterpretImageProperties(msl_info->image_info[n],
4319 msl_info->attributes[n],(const char *) attributes[i]);
4320 CloneString(&value,attribute);
4321 if (*keyword == '+')
4324 Remove a profile from the image.
4326 (void) ProfileImage(msl_info->image[n],keyword,
4327 (const unsigned char *) NULL,0,MagickTrue);
4331 Associate a profile with the image.
4333 profile_info=CloneImageInfo(msl_info->image_info[n]);
4334 profile=GetImageProfile(msl_info->image[n],"iptc");
4335 if (profile != (StringInfo *) NULL)
4336 profile_info->profile=(void *) CloneStringInfo(profile);
4337 profile_image=GetImageCache(profile_info,keyword,&exception);
4338 profile_info=DestroyImageInfo(profile_info);
4339 if (profile_image == (Image *) NULL)
4342 name[MaxTextExtent],
4343 filename[MaxTextExtent];
4351 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4352 (void) CopyMagickString(name,keyword,MaxTextExtent);
4353 for (p=filename; *p != '\0'; p++)
4354 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4355 (IsPathAccessible(keyword) == MagickFalse))
4361 Look for profile name (e.g. name:profile).
4363 (void) CopyMagickString(name,filename,(size_t)
4365 for (q=filename; *q != '\0'; q++)
4369 profile=FileToStringInfo(filename,~0UL,&exception);
4370 if (profile != (StringInfo *) NULL)
4372 (void) ProfileImage(msl_info->image[n],name,
4373 GetStringInfoDatum(profile),(size_t)
4374 GetStringInfoLength(profile),MagickFalse);
4375 profile=DestroyStringInfo(profile);
4379 ResetImageProfileIterator(profile_image);
4380 name=GetNextImageProfile(profile_image);
4381 while (name != (const char *) NULL)
4383 profile=GetImageProfile(profile_image,name);
4384 if (profile != (StringInfo *) NULL)
4385 (void) ProfileImage(msl_info->image[n],name,
4386 GetStringInfoDatum(profile),(size_t)
4387 GetStringInfoLength(profile),MagickFalse);
4388 name=GetNextImageProfile(profile_image);
4390 profile_image=DestroyImage(profile_image);
4394 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4399 if (LocaleCompare((const char *) tag,"quantize") == 0)
4407 if (msl_info->image[n] == (Image *) NULL)
4409 ThrowMSLException(OptionError,"NoImagesDefined",
4410 (const char *) tag);
4413 GetQuantizeInfo(&quantize_info);
4414 if (attributes != (const xmlChar **) NULL)
4415 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4417 keyword=(const char *) attributes[i++];
4418 attribute=InterpretImageProperties(msl_info->image_info[n],
4419 msl_info->attributes[n],(const char *) attributes[i]);
4420 CloneString(&value,attribute);
4426 if (LocaleCompare(keyword,"colors") == 0)
4428 quantize_info.number_colors=StringToLong(value);
4431 if (LocaleCompare(keyword,"colorspace") == 0)
4433 option=ParseCommandOption(MagickColorspaceOptions,
4436 ThrowMSLException(OptionError,
4437 "UnrecognizedColorspaceType",value);
4438 quantize_info.colorspace=(ColorspaceType) option;
4441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4448 if (LocaleCompare(keyword,"dither") == 0)
4450 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4453 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4455 quantize_info.dither=(MagickBooleanType) option;
4458 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4465 if (LocaleCompare(keyword,"measure") == 0)
4467 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4470 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4472 quantize_info.measure_error=(MagickBooleanType) option;
4475 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4482 if (LocaleCompare(keyword,"treedepth") == 0)
4484 quantize_info.tree_depth=StringToLong(value);
4487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4493 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4499 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4502 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4505 text[MaxTextExtent];
4516 draw_info=CloneDrawInfo(msl_info->image_info[n],
4517 msl_info->draw_info[n]);
4519 current=draw_info->affine;
4520 GetAffineMatrix(&affine);
4521 if (attributes != (const xmlChar **) NULL)
4522 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4524 keyword=(const char *) attributes[i++];
4525 attribute=InterpretImageProperties(msl_info->image_info[n],
4526 msl_info->attributes[n],(const char *) attributes[i]);
4527 CloneString(&value,attribute);
4533 if (LocaleCompare(keyword,"affine") == 0)
4539 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4542 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4545 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4548 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4551 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4554 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4557 if (LocaleCompare(keyword,"align") == 0)
4559 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4562 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4564 draw_info->align=(AlignType) option;
4567 if (LocaleCompare(keyword,"antialias") == 0)
4569 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4572 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4574 draw_info->stroke_antialias=(MagickBooleanType) option;
4575 draw_info->text_antialias=(MagickBooleanType) option;
4578 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4585 if (LocaleCompare(keyword,"density") == 0)
4587 CloneString(&draw_info->density,value);
4590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4597 if (LocaleCompare(keyword,"encoding") == 0)
4599 CloneString(&draw_info->encoding,value);
4602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4609 if (LocaleCompare(keyword, "fill") == 0)
4611 (void) QueryColorDatabase(value,&draw_info->fill,
4615 if (LocaleCompare(keyword,"family") == 0)
4617 CloneString(&draw_info->family,value);
4620 if (LocaleCompare(keyword,"font") == 0)
4622 CloneString(&draw_info->font,value);
4625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4632 if (LocaleCompare(keyword,"geometry") == 0)
4634 flags=ParsePageGeometry(msl_info->image[n],value,
4635 &geometry,&exception);
4636 if ((flags & HeightValue) == 0)
4637 geometry.height=geometry.width;
4640 if (LocaleCompare(keyword,"gravity") == 0)
4642 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4645 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4647 draw_info->gravity=(GravityType) option;
4650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4657 if (LocaleCompare(keyword,"pointsize") == 0)
4659 draw_info->pointsize=InterpretLocaleValue(value,
4663 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4670 if (LocaleCompare(keyword,"rotate") == 0)
4672 angle=InterpretLocaleValue(value,(char **) NULL);
4673 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4674 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4675 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4676 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4686 if (LocaleCompare(keyword,"scale") == 0)
4688 flags=ParseGeometry(value,&geometry_info);
4689 if ((flags & SigmaValue) == 0)
4690 geometry_info.sigma=1.0;
4691 affine.sx=geometry_info.rho;
4692 affine.sy=geometry_info.sigma;
4695 if (LocaleCompare(keyword,"skewX") == 0)
4697 angle=InterpretLocaleValue(value,(char **) NULL);
4698 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4701 if (LocaleCompare(keyword,"skewY") == 0)
4703 angle=InterpretLocaleValue(value,(char **) NULL);
4704 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4707 if (LocaleCompare(keyword,"stretch") == 0)
4709 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4712 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4714 draw_info->stretch=(StretchType) option;
4717 if (LocaleCompare(keyword, "stroke") == 0)
4719 (void) QueryColorDatabase(value,&draw_info->stroke,
4723 if (LocaleCompare(keyword,"strokewidth") == 0)
4725 draw_info->stroke_width=StringToLong(value);
4728 if (LocaleCompare(keyword,"style") == 0)
4730 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4733 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4735 draw_info->style=(StyleType) option;
4738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4745 if (LocaleCompare(keyword,"text") == 0)
4747 CloneString(&draw_info->text,value);
4750 if (LocaleCompare(keyword,"translate") == 0)
4752 flags=ParseGeometry(value,&geometry_info);
4753 if ((flags & SigmaValue) == 0)
4754 geometry_info.sigma=1.0;
4755 affine.tx=geometry_info.rho;
4756 affine.ty=geometry_info.sigma;
4759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4766 if (LocaleCompare(keyword, "undercolor") == 0)
4768 (void) QueryColorDatabase(value,&draw_info->undercolor,
4772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4779 if (LocaleCompare(keyword,"weight") == 0)
4781 draw_info->weight=StringToLong(value);
4784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4791 if (LocaleCompare(keyword,"x") == 0)
4793 geometry.x=StringToLong(value);
4796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4803 if (LocaleCompare(keyword,"y") == 0)
4805 geometry.y=StringToLong(value);
4808 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4814 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4820 (void) FormatLocaleString(text,MaxTextExtent,
4821 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4822 geometry.height,(double) geometry.x,(double) geometry.y);
4823 CloneString(&draw_info->geometry,text);
4824 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4825 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4826 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4827 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4828 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4830 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4832 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4833 if (status != MagickFalse)
4838 image=msl_info->attributes[n];
4839 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4840 "%g",metrics.pixels_per_em.x);
4841 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4842 "%g",metrics.pixels_per_em.y);
4843 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4845 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4847 FormatImageProperty(image,"msl:font-metrics.width","%g",
4849 FormatImageProperty(image,"msl:font-metrics.height","%g",
4851 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4852 metrics.max_advance);
4853 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4855 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4857 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4859 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4861 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4863 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4866 draw_info=DestroyDrawInfo(draw_info);
4869 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4874 if (LocaleCompare((const char *) tag,"raise") == 0)
4882 if (msl_info->image[n] == (Image *) NULL)
4884 ThrowMSLException(OptionError,"NoImagesDefined",
4885 (const char *) tag);
4889 SetGeometry(msl_info->image[n],&geometry);
4890 if (attributes != (const xmlChar **) NULL)
4891 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4893 keyword=(const char *) attributes[i++];
4894 attribute=InterpretImageProperties(msl_info->image_info[n],
4895 msl_info->attributes[n],(const char *) attributes[i]);
4896 CloneString(&value,attribute);
4902 if (LocaleCompare(keyword,"geometry") == 0)
4904 flags=ParsePageGeometry(msl_info->image[n],value,
4905 &geometry,&exception);
4906 if ((flags & HeightValue) == 0)
4907 geometry.height=geometry.width;
4910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4917 if (LocaleCompare(keyword,"height") == 0)
4919 geometry.height=StringToLong(value);
4922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4929 if (LocaleCompare(keyword,"raise") == 0)
4931 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4934 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4936 raise=(MagickBooleanType) option;
4939 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4946 if (LocaleCompare(keyword,"width") == 0)
4948 geometry.width=StringToLong(value);
4951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4963 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4966 if (LocaleCompare((const char *) tag,"read") == 0)
4968 if (attributes == (const xmlChar **) NULL)
4970 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4972 keyword=(const char *) attributes[i++];
4973 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4974 msl_info->attributes[n],(const char *) attributes[i]));
4980 if (LocaleCompare(keyword,"filename") == 0)
4985 (void) CopyMagickString(msl_info->image_info[n]->filename,
4986 value,MaxTextExtent);
4987 image=ReadImage(msl_info->image_info[n],&exception);
4988 CatchException(&exception);
4989 if (image == (Image *) NULL)
4991 AppendImageToList(&msl_info->image[n],image);
4994 (void) SetMSLAttributes(msl_info,keyword,value);
4999 (void) SetMSLAttributes(msl_info,keyword,value);
5006 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5014 if (msl_info->image[n] == (Image *) NULL)
5016 ThrowMSLException(OptionError,"NoImagesDefined",
5017 (const char *) tag);
5020 if (attributes != (const xmlChar **) NULL)
5021 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5023 keyword=(const char *) attributes[i++];
5024 attribute=InterpretImageProperties(msl_info->image_info[n],
5025 msl_info->attributes[n],(const char *) attributes[i]);
5026 CloneString(&value,attribute);
5032 if (LocaleCompare(keyword,"geometry") == 0)
5034 flags=ParseGeometry(value,&geometry_info);
5035 if ((flags & SigmaValue) == 0)
5036 geometry_info.sigma=1.0;
5039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5046 if (LocaleCompare(keyword,"radius") == 0)
5048 geometry_info.rho=InterpretLocaleValue(value,
5052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5064 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5065 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5066 &msl_info->image[n]->exception);
5067 if (paint_image == (Image *) NULL)
5069 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5070 msl_info->image[n]=paint_image;
5073 else if (LocaleCompare((const char *) tag,"repage") == 0)
5075 /* init the values */
5076 width=msl_info->image[n]->page.width;
5077 height=msl_info->image[n]->page.height;
5078 x=msl_info->image[n]->page.x;
5079 y=msl_info->image[n]->page.y;
5081 if (msl_info->image[n] == (Image *) NULL)
5083 ThrowMSLException(OptionError,"NoImagesDefined",
5084 (const char *) tag);
5087 if (attributes == (const xmlChar **) NULL)
5089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5091 keyword=(const char *) attributes[i++];
5092 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5093 msl_info->attributes[n],(const char *) attributes[i]));
5099 if (LocaleCompare(keyword,"geometry") == 0)
5107 flags=ParseAbsoluteGeometry(value,&geometry);
5108 if ((flags & WidthValue) != 0)
5110 if ((flags & HeightValue) == 0)
5111 geometry.height=geometry.width;
5112 width=geometry.width;
5113 height=geometry.height;
5115 if ((flags & AspectValue) != 0)
5117 if ((flags & XValue) != 0)
5119 if ((flags & YValue) != 0)
5124 if ((flags & XValue) != 0)
5127 if ((width == 0) && (geometry.x > 0))
5128 width=msl_info->image[n]->columns+geometry.x;
5130 if ((flags & YValue) != 0)
5133 if ((height == 0) && (geometry.y > 0))
5134 height=msl_info->image[n]->rows+geometry.y;
5139 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5145 if (LocaleCompare(keyword,"height") == 0)
5147 height = StringToLong( value );
5150 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5156 if (LocaleCompare(keyword,"width") == 0)
5158 width = StringToLong( value );
5161 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5167 if (LocaleCompare(keyword,"x") == 0)
5169 x = StringToLong( value );
5172 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5178 if (LocaleCompare(keyword,"y") == 0)
5180 y = StringToLong( value );
5183 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5188 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5194 msl_info->image[n]->page.width=width;
5195 msl_info->image[n]->page.height=height;
5196 msl_info->image[n]->page.x=x;
5197 msl_info->image[n]->page.y=y;
5200 else if (LocaleCompare((const char *) tag,"resample") == 0)
5206 if (msl_info->image[n] == (Image *) NULL)
5208 ThrowMSLException(OptionError,"NoImagesDefined",
5209 (const char *) tag);
5212 if (attributes == (const xmlChar **) NULL)
5214 x_resolution=DefaultResolution;
5215 y_resolution=DefaultResolution;
5216 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5218 keyword=(const char *) attributes[i++];
5219 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5220 msl_info->attributes[n],(const char *) attributes[i]));
5225 if (LocaleCompare(keyword,"blur") == 0)
5227 msl_info->image[n]->blur=InterpretLocaleValue(value,
5231 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5237 if (LocaleCompare(keyword,"geometry") == 0)
5242 flags=ParseGeometry(value,&geometry_info);
5243 if ((flags & SigmaValue) == 0)
5244 geometry_info.sigma*=geometry_info.rho;
5245 x_resolution=geometry_info.rho;
5246 y_resolution=geometry_info.sigma;
5249 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5255 if (LocaleCompare(keyword,"x-resolution") == 0)
5257 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5260 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5266 if (LocaleCompare(keyword,"y-resolution") == 0)
5268 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5271 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5276 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5292 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5294 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5295 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5296 msl_info->image[n]->x_resolution))+0.5);
5297 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5298 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5299 msl_info->image[n]->y_resolution))+0.5);
5300 resample_image=ResizeImage(msl_info->image[n],width,height,
5301 msl_info->image[n]->filter,msl_info->image[n]->blur,
5302 &msl_info->image[n]->exception);
5303 if (resample_image == (Image *) NULL)
5305 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5306 msl_info->image[n]=resample_image;
5310 if (LocaleCompare((const char *) tag,"resize") == 0)
5324 if (msl_info->image[n] == (Image *) NULL)
5326 ThrowMSLException(OptionError,"NoImagesDefined",
5327 (const char *) tag);
5330 filter=UndefinedFilter;
5332 if (attributes != (const xmlChar **) NULL)
5333 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5335 keyword=(const char *) attributes[i++];
5336 attribute=InterpretImageProperties(msl_info->image_info[n],
5337 msl_info->attributes[n],(const char *) attributes[i]);
5338 CloneString(&value,attribute);
5344 if (LocaleCompare(keyword,"filter") == 0)
5346 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5349 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5351 filter=(FilterTypes) option;
5354 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5361 if (LocaleCompare(keyword,"geometry") == 0)
5363 flags=ParseRegionGeometry(msl_info->image[n],value,
5364 &geometry,&exception);
5367 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5374 if (LocaleCompare(keyword,"height") == 0)
5376 geometry.height=StringToUnsignedLong(value);
5379 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5386 if (LocaleCompare(keyword,"support") == 0)
5388 blur=InterpretLocaleValue(value,(char **) NULL);
5391 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5398 if (LocaleCompare(keyword,"width") == 0)
5400 geometry.width=StringToLong(value);
5403 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5415 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5416 geometry.height,filter,blur,&msl_info->image[n]->exception);
5417 if (resize_image == (Image *) NULL)
5419 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5420 msl_info->image[n]=resize_image;
5423 if (LocaleCompare((const char *) tag,"roll") == 0)
5431 if (msl_info->image[n] == (Image *) NULL)
5433 ThrowMSLException(OptionError,"NoImagesDefined",
5434 (const char *) tag);
5437 SetGeometry(msl_info->image[n],&geometry);
5438 if (attributes != (const xmlChar **) NULL)
5439 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5441 keyword=(const char *) attributes[i++];
5442 attribute=InterpretImageProperties(msl_info->image_info[n],
5443 msl_info->attributes[n],(const char *) attributes[i]);
5444 CloneString(&value,attribute);
5450 if (LocaleCompare(keyword,"geometry") == 0)
5452 flags=ParsePageGeometry(msl_info->image[n],value,
5453 &geometry,&exception);
5454 if ((flags & HeightValue) == 0)
5455 geometry.height=geometry.width;
5458 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5465 if (LocaleCompare(keyword,"x") == 0)
5467 geometry.x=StringToLong(value);
5470 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5477 if (LocaleCompare(keyword,"y") == 0)
5479 geometry.y=StringToLong(value);
5482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5488 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5494 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5495 &msl_info->image[n]->exception);
5496 if (roll_image == (Image *) NULL)
5498 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5499 msl_info->image[n]=roll_image;
5502 else if (LocaleCompare((const char *) tag,"roll") == 0)
5504 /* init the values */
5505 width=msl_info->image[n]->columns;
5506 height=msl_info->image[n]->rows;
5509 if (msl_info->image[n] == (Image *) NULL)
5511 ThrowMSLException(OptionError,"NoImagesDefined",
5512 (const char *) tag);
5515 if (attributes == (const xmlChar **) NULL)
5517 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5519 keyword=(const char *) attributes[i++];
5520 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5521 msl_info->attributes[n],(const char *) attributes[i]));
5527 if (LocaleCompare(keyword,"geometry") == 0)
5529 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5538 if (LocaleCompare(keyword,"x") == 0)
5540 x = StringToLong( value );
5543 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5549 if (LocaleCompare(keyword,"y") == 0)
5551 y = StringToLong( value );
5554 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5559 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5572 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5573 if (newImage == (Image *) NULL)
5575 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5576 msl_info->image[n]=newImage;
5581 if (LocaleCompare((const char *) tag,"rotate") == 0)
5589 if (msl_info->image[n] == (Image *) NULL)
5591 ThrowMSLException(OptionError,"NoImagesDefined",
5592 (const char *) tag);
5595 if (attributes != (const xmlChar **) NULL)
5596 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5598 keyword=(const char *) attributes[i++];
5599 attribute=InterpretImageProperties(msl_info->image_info[n],
5600 msl_info->attributes[n],(const char *) attributes[i]);
5601 CloneString(&value,attribute);
5607 if (LocaleCompare(keyword,"degrees") == 0)
5609 geometry_info.rho=InterpretLocaleValue(value,
5613 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5620 if (LocaleCompare(keyword,"geometry") == 0)
5622 flags=ParseGeometry(value,&geometry_info);
5623 if ((flags & SigmaValue) == 0)
5624 geometry_info.sigma=1.0;
5627 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5633 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5639 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5640 &msl_info->image[n]->exception);
5641 if (rotate_image == (Image *) NULL)
5643 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5644 msl_info->image[n]=rotate_image;
5647 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5649 /* init the values */
5652 if (msl_info->image[n] == (Image *) NULL)
5654 ThrowMSLException(OptionError,"NoImagesDefined",
5655 (const char *) tag);
5658 if (attributes == (const xmlChar **) NULL)
5660 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5662 keyword=(const char *) attributes[i++];
5663 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5664 msl_info->attributes[n],(const char *) attributes[i]));
5670 if (LocaleCompare(keyword,"degrees") == 0)
5672 degrees = InterpretLocaleValue(value,(char **) NULL);
5675 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5680 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5693 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5694 if (newImage == (Image *) NULL)
5696 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5697 msl_info->image[n]=newImage;
5702 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5707 if (LocaleCompare((const char *) tag,"sample") == 0)
5715 if (msl_info->image[n] == (Image *) NULL)
5717 ThrowMSLException(OptionError,"NoImagesDefined",
5718 (const char *) tag);
5721 if (attributes != (const xmlChar **) NULL)
5722 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5724 keyword=(const char *) attributes[i++];
5725 attribute=InterpretImageProperties(msl_info->image_info[n],
5726 msl_info->attributes[n],(const char *) attributes[i]);
5727 CloneString(&value,attribute);
5733 if (LocaleCompare(keyword,"geometry") == 0)
5735 flags=ParseRegionGeometry(msl_info->image[n],value,
5736 &geometry,&exception);
5739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5746 if (LocaleCompare(keyword,"height") == 0)
5748 geometry.height=StringToUnsignedLong(value);
5751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5758 if (LocaleCompare(keyword,"width") == 0)
5760 geometry.width=StringToLong(value);
5763 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5769 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5775 sample_image=SampleImage(msl_info->image[n],geometry.width,
5776 geometry.height,&msl_info->image[n]->exception);
5777 if (sample_image == (Image *) NULL)
5779 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5780 msl_info->image[n]=sample_image;
5783 if (LocaleCompare((const char *) tag,"scale") == 0)
5791 if (msl_info->image[n] == (Image *) NULL)
5793 ThrowMSLException(OptionError,"NoImagesDefined",
5794 (const char *) tag);
5797 if (attributes != (const xmlChar **) NULL)
5798 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5800 keyword=(const char *) attributes[i++];
5801 attribute=InterpretImageProperties(msl_info->image_info[n],
5802 msl_info->attributes[n],(const char *) attributes[i]);
5803 CloneString(&value,attribute);
5809 if (LocaleCompare(keyword,"geometry") == 0)
5811 flags=ParseRegionGeometry(msl_info->image[n],value,
5812 &geometry,&exception);
5815 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5822 if (LocaleCompare(keyword,"height") == 0)
5824 geometry.height=StringToUnsignedLong(value);
5827 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5834 if (LocaleCompare(keyword,"width") == 0)
5836 geometry.width=StringToLong(value);
5839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5851 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5852 geometry.height,&msl_info->image[n]->exception);
5853 if (scale_image == (Image *) NULL)
5855 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5856 msl_info->image[n]=scale_image;
5859 if (LocaleCompare((const char *) tag,"segment") == 0)
5870 if (msl_info->image[n] == (Image *) NULL)
5872 ThrowMSLException(OptionError,"NoImagesDefined",
5873 (const char *) tag);
5876 geometry_info.rho=1.0;
5877 geometry_info.sigma=1.5;
5878 colorspace=RGBColorspace;
5879 verbose=MagickFalse;
5880 if (attributes != (const xmlChar **) NULL)
5881 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5883 keyword=(const char *) attributes[i++];
5884 attribute=InterpretImageProperties(msl_info->image_info[n],
5885 msl_info->attributes[n],(const char *) attributes[i]);
5886 CloneString(&value,attribute);
5892 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5894 geometry_info.rho=InterpretLocaleValue(value,
5898 if (LocaleCompare(keyword,"colorspace") == 0)
5900 option=ParseCommandOption(MagickColorspaceOptions,
5903 ThrowMSLException(OptionError,
5904 "UnrecognizedColorspaceType",value);
5905 colorspace=(ColorspaceType) option;
5908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5915 if (LocaleCompare(keyword,"geometry") == 0)
5917 flags=ParseGeometry(value,&geometry_info);
5918 if ((flags & SigmaValue) == 0)
5919 geometry_info.sigma=1.5;
5922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5929 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5931 geometry_info.sigma=InterpretLocaleValue(value,
5935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5941 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5947 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5948 geometry_info.rho,geometry_info.sigma);
5951 else if (LocaleCompare((const char *) tag, "set") == 0)
5953 if (msl_info->image[n] == (Image *) NULL)
5955 ThrowMSLException(OptionError,"NoImagesDefined",
5956 (const char *) tag);
5960 if (attributes == (const xmlChar **) NULL)
5962 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5964 keyword=(const char *) attributes[i++];
5965 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5966 msl_info->attributes[n],(const char *) attributes[i]));
5972 if (LocaleCompare(keyword,"clip-mask") == 0)
5974 for (j=0; j < msl_info->n; j++)
5979 property=GetImageProperty(msl_info->attributes[j],"id");
5980 if (LocaleCompare(property,value) == 0)
5982 SetImageMask(msl_info->image[n],msl_info->image[j]);
5988 if (LocaleCompare(keyword,"clip-path") == 0)
5990 for (j=0; j < msl_info->n; j++)
5995 property=GetImageProperty(msl_info->attributes[j],"id");
5996 if (LocaleCompare(property,value) == 0)
5998 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
6004 if (LocaleCompare(keyword,"colorspace") == 0)
6009 colorspace=(ColorspaceType) ParseCommandOption(
6010 MagickColorspaceOptions,MagickFalse,value);
6012 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6014 (void) TransformImageColorspace(msl_info->image[n],
6015 (ColorspaceType) colorspace);
6018 (void) SetMSLAttributes(msl_info,keyword,value);
6024 if (LocaleCompare(keyword,"density") == 0)
6026 flags=ParseGeometry(value,&geometry_info);
6027 msl_info->image[n]->x_resolution=geometry_info.rho;
6028 msl_info->image[n]->y_resolution=geometry_info.sigma;
6029 if ((flags & SigmaValue) == 0)
6030 msl_info->image[n]->y_resolution=
6031 msl_info->image[n]->x_resolution;
6034 (void) SetMSLAttributes(msl_info,keyword,value);
6040 if (LocaleCompare(keyword, "opacity") == 0)
6042 ssize_t opac = OpaqueAlpha,
6043 len = (ssize_t) strlen( value );
6045 if (value[len-1] == '%') {
6047 (void) CopyMagickString(tmp,value,len);
6048 opac = StringToLong( tmp );
6049 opac = (int)(QuantumRange * ((float)opac/100));
6051 opac = StringToLong( value );
6052 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6055 (void) SetMSLAttributes(msl_info,keyword,value);
6061 if (LocaleCompare(keyword, "page") == 0)
6064 page[MaxTextExtent];
6075 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6076 image_option=GetImageOption(msl_info->image_info[n],"page");
6077 if (image_option != (const char *) NULL)
6078 flags=ParseAbsoluteGeometry(image_option,&geometry);
6079 flags=ParseAbsoluteGeometry(value,&geometry);
6080 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6081 (double) geometry.width,(double) geometry.height);
6082 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6083 (void) FormatLocaleString(page,MaxTextExtent,
6084 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6085 (double) geometry.height,(double) geometry.x,(double)
6087 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6088 msl_info->image_info[n]->page=GetPageGeometry(page);
6091 (void) SetMSLAttributes(msl_info,keyword,value);
6096 (void) SetMSLAttributes(msl_info,keyword,value);
6103 if (LocaleCompare((const char *) tag,"shade") == 0)
6114 if (msl_info->image[n] == (Image *) NULL)
6116 ThrowMSLException(OptionError,"NoImagesDefined",
6117 (const char *) tag);
6121 if (attributes != (const xmlChar **) NULL)
6122 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6124 keyword=(const char *) attributes[i++];
6125 attribute=InterpretImageProperties(msl_info->image_info[n],
6126 msl_info->attributes[n],(const char *) attributes[i]);
6127 CloneString(&value,attribute);
6133 if (LocaleCompare(keyword,"azimuth") == 0)
6135 geometry_info.rho=InterpretLocaleValue(value,
6139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6146 if (LocaleCompare(keyword,"elevation") == 0)
6148 geometry_info.sigma=InterpretLocaleValue(value,
6152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6159 if (LocaleCompare(keyword,"geometry") == 0)
6161 flags=ParseGeometry(value,&geometry_info);
6162 if ((flags & SigmaValue) == 0)
6163 geometry_info.sigma=1.0;
6166 if (LocaleCompare(keyword,"gray") == 0)
6168 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6171 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6173 gray=(MagickBooleanType) option;
6176 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6182 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6188 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6189 geometry_info.sigma,&msl_info->image[n]->exception);
6190 if (shade_image == (Image *) NULL)
6192 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6193 msl_info->image[n]=shade_image;
6196 if (LocaleCompare((const char *) tag,"shadow") == 0)
6204 if (msl_info->image[n] == (Image *) NULL)
6206 ThrowMSLException(OptionError,"NoImagesDefined",
6207 (const char *) tag);
6210 if (attributes != (const xmlChar **) NULL)
6211 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6213 keyword=(const char *) attributes[i++];
6214 attribute=InterpretImageProperties(msl_info->image_info[n],
6215 msl_info->attributes[n],(const char *) attributes[i]);
6216 CloneString(&value,attribute);
6222 if (LocaleCompare(keyword,"geometry") == 0)
6224 flags=ParseGeometry(value,&geometry_info);
6225 if ((flags & SigmaValue) == 0)
6226 geometry_info.sigma=1.0;
6229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6236 if (LocaleCompare(keyword,"opacity") == 0)
6238 geometry_info.rho=StringToLong(value);
6241 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6248 if (LocaleCompare(keyword,"sigma") == 0)
6250 geometry_info.sigma=StringToLong(value);
6258 if (LocaleCompare(keyword,"x") == 0)
6260 geometry_info.xi=InterpretLocaleValue(value,
6264 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6271 if (LocaleCompare(keyword,"y") == 0)
6273 geometry_info.psi=StringToLong(value);
6276 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6282 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6288 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6289 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6290 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6291 if (shadow_image == (Image *) NULL)
6293 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6294 msl_info->image[n]=shadow_image;
6297 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6299 double radius = 0.0,
6302 if (msl_info->image[n] == (Image *) NULL)
6304 ThrowMSLException(OptionError,"NoImagesDefined",
6305 (const char *) tag);
6309 NOTE: sharpen can have no attributes, since we use all the defaults!
6311 if (attributes != (const xmlChar **) NULL)
6313 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6315 keyword=(const char *) attributes[i++];
6316 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6317 msl_info->attributes[n],(const char *) attributes[i]));
6323 if (LocaleCompare(keyword, "radius") == 0)
6325 radius = InterpretLocaleValue(value,(char **) NULL);
6328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6334 if (LocaleCompare(keyword,"sigma") == 0)
6336 sigma = StringToLong( value );
6339 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6344 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6358 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6359 if (newImage == (Image *) NULL)
6361 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6362 msl_info->image[n]=newImage;
6366 else if (LocaleCompare((const char *) tag,"shave") == 0)
6368 /* init the values */
6372 if (msl_info->image[n] == (Image *) NULL)
6374 ThrowMSLException(OptionError,"NoImagesDefined",
6375 (const char *) tag);
6378 if (attributes == (const xmlChar **) NULL)
6380 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6382 keyword=(const char *) attributes[i++];
6383 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6384 msl_info->attributes[n],(const char *) attributes[i]));
6390 if (LocaleCompare(keyword,"geometry") == 0)
6392 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6395 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6401 if (LocaleCompare(keyword,"height") == 0)
6403 height = StringToLong( value );
6406 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6412 if (LocaleCompare(keyword,"width") == 0)
6414 width = StringToLong( value );
6417 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6422 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6437 rectInfo.height = height;
6438 rectInfo.width = width;
6443 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6444 &msl_info->image[n]->exception);
6445 if (newImage == (Image *) NULL)
6447 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6448 msl_info->image[n]=newImage;
6453 if (LocaleCompare((const char *) tag,"shear") == 0)
6461 if (msl_info->image[n] == (Image *) NULL)
6463 ThrowMSLException(OptionError,"NoImagesDefined",
6464 (const char *) tag);
6467 if (attributes != (const xmlChar **) NULL)
6468 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6470 keyword=(const char *) attributes[i++];
6471 attribute=InterpretImageProperties(msl_info->image_info[n],
6472 msl_info->attributes[n],(const char *) attributes[i]);
6473 CloneString(&value,attribute);
6479 if (LocaleCompare(keyword, "fill") == 0)
6481 (void) QueryColorDatabase(value,
6482 &msl_info->image[n]->background_color,&exception);
6485 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6492 if (LocaleCompare(keyword,"geometry") == 0)
6494 flags=ParseGeometry(value,&geometry_info);
6495 if ((flags & SigmaValue) == 0)
6496 geometry_info.sigma=1.0;
6499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6506 if (LocaleCompare(keyword,"x") == 0)
6508 geometry_info.rho=InterpretLocaleValue(value,
6512 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6519 if (LocaleCompare(keyword,"y") == 0)
6521 geometry_info.sigma=StringToLong(value);
6524 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6530 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6536 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6537 geometry_info.sigma,&msl_info->image[n]->exception);
6538 if (shear_image == (Image *) NULL)
6540 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6541 msl_info->image[n]=shear_image;
6544 if (LocaleCompare((const char *) tag,"signature") == 0)
6549 if (msl_info->image[n] == (Image *) NULL)
6551 ThrowMSLException(OptionError,"NoImagesDefined",
6552 (const char *) tag);
6555 if (attributes != (const xmlChar **) NULL)
6556 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6558 keyword=(const char *) attributes[i++];
6559 attribute=InterpretImageProperties(msl_info->image_info[n],
6560 msl_info->attributes[n],(const char *) attributes[i]);
6561 CloneString(&value,attribute);
6566 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6572 (void) SignatureImage(msl_info->image[n]);
6575 if (LocaleCompare((const char *) tag,"solarize") == 0)
6580 if (msl_info->image[n] == (Image *) NULL)
6582 ThrowMSLException(OptionError,"NoImagesDefined",
6583 (const char *) tag);
6586 geometry_info.rho=QuantumRange/2.0;
6587 if (attributes != (const xmlChar **) NULL)
6588 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6590 keyword=(const char *) attributes[i++];
6591 attribute=InterpretImageProperties(msl_info->image_info[n],
6592 msl_info->attributes[n],(const char *) attributes[i]);
6593 CloneString(&value,attribute);
6599 if (LocaleCompare(keyword,"geometry") == 0)
6601 flags=ParseGeometry(value,&geometry_info);
6604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6611 if (LocaleCompare(keyword,"threshold") == 0)
6613 geometry_info.rho=InterpretLocaleValue(value,
6617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6629 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6632 if (LocaleCompare((const char *) tag,"spread") == 0)
6640 if (msl_info->image[n] == (Image *) NULL)
6642 ThrowMSLException(OptionError,"NoImagesDefined",
6643 (const char *) tag);
6646 if (attributes != (const xmlChar **) NULL)
6647 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6649 keyword=(const char *) attributes[i++];
6650 attribute=InterpretImageProperties(msl_info->image_info[n],
6651 msl_info->attributes[n],(const char *) attributes[i]);
6652 CloneString(&value,attribute);
6658 if (LocaleCompare(keyword,"geometry") == 0)
6660 flags=ParseGeometry(value,&geometry_info);
6661 if ((flags & SigmaValue) == 0)
6662 geometry_info.sigma=1.0;
6665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6672 if (LocaleCompare(keyword,"radius") == 0)
6674 geometry_info.rho=InterpretLocaleValue(value,
6678 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6684 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6690 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6691 &msl_info->image[n]->exception);
6692 if (spread_image == (Image *) NULL)
6694 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6695 msl_info->image[n]=spread_image;
6698 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6701 watermark = (Image*)NULL;
6703 if (msl_info->image[n] == (Image *) NULL)
6705 ThrowMSLException(OptionError,"NoImagesDefined",
6706 (const char *) tag);
6709 if (attributes == (const xmlChar **) NULL)
6711 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6713 keyword=(const char *) attributes[i++];
6714 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6715 msl_info->attributes[n],(const char *) attributes[i]));
6721 if (LocaleCompare(keyword,"image") == 0)
6723 for (j=0; j<msl_info->n;j++)
6726 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6727 if (theAttr && LocaleCompare(theAttr, value) == 0)
6729 watermark = msl_info->image[j];
6735 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6740 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6749 if ( watermark != (Image*) NULL )
6754 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6755 if (newImage == (Image *) NULL)
6757 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6758 msl_info->image[n]=newImage;
6761 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6763 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6766 stereoImage = (Image*)NULL;
6768 if (msl_info->image[n] == (Image *) NULL)
6770 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6773 if (attributes == (const xmlChar **) NULL)
6775 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6777 keyword=(const char *) attributes[i++];
6778 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6779 msl_info->attributes[n],(const char *) attributes[i]));
6785 if (LocaleCompare(keyword,"image") == 0)
6787 for (j=0; j<msl_info->n;j++)
6790 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6791 if (theAttr && LocaleCompare(theAttr, value) == 0)
6793 stereoImage = msl_info->image[j];
6799 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6804 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6813 if ( stereoImage != (Image*) NULL )
6818 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6819 if (newImage == (Image *) NULL)
6821 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6822 msl_info->image[n]=newImage;
6825 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6827 if (LocaleCompare((const char *) tag,"swap") == 0)
6838 if (msl_info->image[n] == (Image *) NULL)
6840 ThrowMSLException(OptionError,"NoImagesDefined",
6841 (const char *) tag);
6846 if (attributes != (const xmlChar **) NULL)
6847 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6849 keyword=(const char *) attributes[i++];
6850 attribute=InterpretImageProperties(msl_info->image_info[n],
6851 msl_info->attributes[n],(const char *) attributes[i]);
6852 CloneString(&value,attribute);
6858 if (LocaleCompare(keyword,"indexes") == 0)
6860 flags=ParseGeometry(value,&geometry_info);
6861 index=(ssize_t) geometry_info.rho;
6862 if ((flags & SigmaValue) == 0)
6863 swap_index=(ssize_t) geometry_info.sigma;
6866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6881 p=GetImageFromList(msl_info->image[n],index);
6882 q=GetImageFromList(msl_info->image[n],swap_index);
6883 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6885 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6888 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6889 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6890 ReplaceImageInList(&q,swap);
6891 msl_info->image[n]=GetFirstImageInList(q);
6894 if (LocaleCompare((const char *) tag,"swirl") == 0)
6902 if (msl_info->image[n] == (Image *) NULL)
6904 ThrowMSLException(OptionError,"NoImagesDefined",
6905 (const char *) tag);
6908 if (attributes != (const xmlChar **) NULL)
6909 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6911 keyword=(const char *) attributes[i++];
6912 attribute=InterpretImageProperties(msl_info->image_info[n],
6913 msl_info->attributes[n],(const char *) attributes[i]);
6914 CloneString(&value,attribute);
6920 if (LocaleCompare(keyword,"degrees") == 0)
6922 geometry_info.rho=InterpretLocaleValue(value,
6926 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6933 if (LocaleCompare(keyword,"geometry") == 0)
6935 flags=ParseGeometry(value,&geometry_info);
6936 if ((flags & SigmaValue) == 0)
6937 geometry_info.sigma=1.0;
6940 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6952 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6953 &msl_info->image[n]->exception);
6954 if (swirl_image == (Image *) NULL)
6956 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6957 msl_info->image[n]=swirl_image;
6960 if (LocaleCompare((const char *) tag,"sync") == 0)
6965 if (msl_info->image[n] == (Image *) NULL)
6967 ThrowMSLException(OptionError,"NoImagesDefined",
6968 (const char *) tag);
6971 if (attributes != (const xmlChar **) NULL)
6972 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6974 keyword=(const char *) attributes[i++];
6975 attribute=InterpretImageProperties(msl_info->image_info[n],
6976 msl_info->attributes[n],(const char *) attributes[i]);
6977 CloneString(&value,attribute);
6982 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6988 (void) SyncImage(msl_info->image[n]);
6991 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6996 if (LocaleCompare((const char *) tag,"map") == 0)
7004 if (msl_info->image[n] == (Image *) NULL)
7006 ThrowMSLException(OptionError,"NoImagesDefined",
7007 (const char *) tag);
7010 texture_image=NewImageList();
7011 if (attributes != (const xmlChar **) NULL)
7012 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7014 keyword=(const char *) attributes[i++];
7015 attribute=InterpretImageProperties(msl_info->image_info[n],
7016 msl_info->attributes[n],(const char *) attributes[i]);
7017 CloneString(&value,attribute);
7023 if (LocaleCompare(keyword,"image") == 0)
7024 for (j=0; j < msl_info->n; j++)
7029 attribute=GetImageProperty(msl_info->attributes[j],"id");
7030 if ((attribute != (const char *) NULL) &&
7031 (LocaleCompare(attribute,value) == 0))
7033 texture_image=CloneImage(msl_info->image[j],0,0,
7034 MagickFalse,&exception);
7042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7048 (void) TextureImage(msl_info->image[n],texture_image);
7049 texture_image=DestroyImage(texture_image);
7052 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7054 /* init the values */
7055 double threshold = 0;
7057 if (msl_info->image[n] == (Image *) NULL)
7059 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7062 if (attributes == (const xmlChar **) NULL)
7064 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7066 keyword=(const char *) attributes[i++];
7067 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7068 msl_info->attributes[n],(const char *) attributes[i]));
7074 if (LocaleCompare(keyword,"threshold") == 0)
7076 threshold = InterpretLocaleValue(value,(char **) NULL);
7079 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7084 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7094 BilevelImageChannel(msl_info->image[n],
7095 (ChannelType) ((ssize_t) (CompositeChannels &~ (ssize_t) OpacityChannel)),
7100 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7102 if (msl_info->image[n] == (Image *) NULL)
7104 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7107 if (attributes == (const xmlChar **) NULL)
7109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7111 keyword=(const char *) attributes[i++];
7112 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7113 msl_info->attributes[n],(const char *) attributes[i]));
7119 if (LocaleCompare(keyword,"color") == 0)
7124 (void) QueryMagickColor(value,&target,&exception);
7125 (void) TransparentPaintImage(msl_info->image[n],&target,
7126 TransparentAlpha,MagickFalse);
7129 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7134 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7141 else if (LocaleCompare((const char *) tag, "trim") == 0)
7143 if (msl_info->image[n] == (Image *) NULL)
7145 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7149 /* no attributes here */
7151 /* process the image */
7158 /* all zeros on a crop == trim edges! */
7159 rectInfo.height = rectInfo.width = 0;
7160 rectInfo.x = rectInfo.y = 0;
7162 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7163 if (newImage == (Image *) NULL)
7165 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7166 msl_info->image[n]=newImage;
7170 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7175 if (LocaleCompare((const char *) tag,"write") == 0)
7177 if (msl_info->image[n] == (Image *) NULL)
7179 ThrowMSLException(OptionError,"NoImagesDefined",
7180 (const char *) tag);
7183 if (attributes == (const xmlChar **) NULL)
7185 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7187 keyword=(const char *) attributes[i++];
7188 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7189 msl_info->attributes[n],(const char *) attributes[i]));
7195 if (LocaleCompare(keyword,"filename") == 0)
7197 (void) CopyMagickString(msl_info->image[n]->filename,value,
7201 (void) SetMSLAttributes(msl_info,keyword,value);
7205 (void) SetMSLAttributes(msl_info,keyword,value);
7213 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7217 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7221 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7225 if ( value != NULL )
7226 value=DestroyString(value);
7227 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7230 static void MSLEndElement(void *context,const xmlChar *tag)
7239 Called when the end of an element has been detected.
7241 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7243 msl_info=(MSLInfo *) context;
7250 if (LocaleCompare((const char *) tag,"comment") == 0 )
7252 (void) DeleteImageProperty(msl_info->image[n],"comment");
7253 if (msl_info->content == (char *) NULL)
7255 StripString(msl_info->content);
7256 (void) SetImageProperty(msl_info->image[n],"comment",
7265 if (LocaleCompare((const char *) tag, "group") == 0 )
7267 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7269 ssize_t i = (ssize_t)
7270 (msl_info->group_info[msl_info->number_groups-1].numImages);
7273 if (msl_info->image[msl_info->n] != (Image *) NULL)
7274 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7275 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7276 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7280 msl_info->number_groups--;
7287 if (LocaleCompare((const char *) tag, "image") == 0)
7288 MSLPopImage(msl_info);
7294 if (LocaleCompare((const char *) tag,"label") == 0 )
7296 (void) DeleteImageProperty(msl_info->image[n],"label");
7297 if (msl_info->content == (char *) NULL)
7299 StripString(msl_info->content);
7300 (void) SetImageProperty(msl_info->image[n],"label",
7309 if (LocaleCompare((const char *) tag, "msl") == 0 )
7312 This our base element.
7313 at the moment we don't do anything special
7314 but someday we might!
7322 if (msl_info->content != (char *) NULL)
7323 msl_info->content=DestroyString(msl_info->content);
7326 static void MSLCharacters(void *context,const xmlChar *c,int length)
7338 Receiving some characters from the parser.
7340 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7341 " SAX.characters(%s,%d)",c,length);
7342 msl_info=(MSLInfo *) context;
7343 if (msl_info->content != (char *) NULL)
7344 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7345 strlen(msl_info->content)+length+MaxTextExtent,
7346 sizeof(*msl_info->content));
7349 msl_info->content=(char *) NULL;
7350 if (~length >= (MaxTextExtent-1))
7351 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7352 sizeof(*msl_info->content));
7353 if (msl_info->content != (char *) NULL)
7354 *msl_info->content='\0';
7356 if (msl_info->content == (char *) NULL)
7358 p=msl_info->content+strlen(msl_info->content);
7359 for (i=0; i < length; i++)
7364 static void MSLReference(void *context,const xmlChar *name)
7373 Called when an entity reference is detected.
7375 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7376 " SAX.reference(%s)",name);
7377 msl_info=(MSLInfo *) context;
7378 parser=msl_info->parser;
7380 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7382 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7385 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7391 Receiving some ignorable whitespaces from the parser.
7393 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7394 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7395 msl_info=(MSLInfo *) context;
7399 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7400 const xmlChar *data)
7406 A processing instruction has been parsed.
7408 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7409 " SAX.processingInstruction(%s, %s)",
7411 msl_info=(MSLInfo *) context;
7415 static void MSLComment(void *context,const xmlChar *value)
7421 A comment has been parsed.
7423 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7424 " SAX.comment(%s)",value);
7425 msl_info=(MSLInfo *) context;
7429 static void MSLWarning(void *context,const char *format,...)
7433 reason[MaxTextExtent];
7442 Display and format a warning messages, gives file, line, position and
7445 va_start(operands,format);
7446 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7447 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7448 msl_info=(MSLInfo *) context;
7450 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7451 (void) vsprintf(reason,format,operands);
7453 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7455 message=GetExceptionMessage(errno);
7456 ThrowMSLException(CoderError,reason,message);
7457 message=DestroyString(message);
7461 static void MSLError(void *context,const char *format,...)
7464 reason[MaxTextExtent];
7473 Display and format a error formats, gives file, line, position and
7476 va_start(operands,format);
7477 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7478 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7479 msl_info=(MSLInfo *) context;
7481 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7482 (void) vsprintf(reason,format,operands);
7484 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7486 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7490 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7502 Called when a pcdata block has been parsed.
7504 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7505 " SAX.pcdata(%s, %d)",value,length);
7506 msl_info=(MSLInfo *) context;
7508 parser=msl_info->parser;
7509 child=xmlGetLastChild(parser->node);
7510 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7512 xmlTextConcat(child,value,length);
7515 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7518 static void MSLExternalSubset(void *context,const xmlChar *name,
7519 const xmlChar *external_id,const xmlChar *system_id)
7534 Does this document has an external subset?
7536 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7537 " SAX.externalSubset(%s %s %s)",name,
7538 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7539 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7540 msl_info=(MSLInfo *) context;
7542 parser=msl_info->parser;
7543 if (((external_id == NULL) && (system_id == NULL)) ||
7544 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7545 (msl_info->document == 0)))
7547 input=MSLResolveEntity(context,external_id,system_id);
7550 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7551 parser_context=(*parser);
7552 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7553 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7555 parser->errNo=XML_ERR_NO_MEMORY;
7556 parser->input=parser_context.input;
7557 parser->inputNr=parser_context.inputNr;
7558 parser->inputMax=parser_context.inputMax;
7559 parser->inputTab=parser_context.inputTab;
7565 xmlPushInput(parser,input);
7566 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7567 if (input->filename == (char *) NULL)
7568 input->filename=(char *) xmlStrdup(system_id);
7571 input->base=parser->input->cur;
7572 input->cur=parser->input->cur;
7574 xmlParseExternalSubset(parser,external_id,system_id);
7575 while (parser->inputNr > 1)
7576 (void) xmlPopInput(parser);
7577 xmlFreeInputStream(parser->input);
7578 xmlFree(parser->inputTab);
7579 parser->input=parser_context.input;
7580 parser->inputNr=parser_context.inputNr;
7581 parser->inputMax=parser_context.inputMax;
7582 parser->inputTab=parser_context.inputTab;
7585 #if defined(__cplusplus) || defined(c_plusplus)
7589 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7590 ExceptionInfo *exception)
7593 message[MaxTextExtent];
7616 assert(image_info != (const ImageInfo *) NULL);
7617 assert(image_info->signature == MagickSignature);
7618 if (image_info->debug != MagickFalse)
7619 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7620 image_info->filename);
7621 assert(image != (Image **) NULL);
7622 msl_image=AcquireImage(image_info);
7623 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7624 if (status == MagickFalse)
7626 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7627 msl_image->filename);
7628 msl_image=DestroyImageList(msl_image);
7629 return(MagickFalse);
7631 msl_image->columns=1;
7636 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7637 msl_info.exception=exception;
7638 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7639 sizeof(*msl_info.image_info));
7640 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7641 sizeof(*msl_info.draw_info));
7642 /* top of the stack is the MSL file itself */
7643 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7644 msl_info.attributes=(Image **) AcquireMagickMemory(
7645 sizeof(*msl_info.attributes));
7646 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7647 sizeof(*msl_info.group_info));
7648 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7649 (msl_info.image == (Image **) NULL) ||
7650 (msl_info.attributes == (Image **) NULL) ||
7651 (msl_info.group_info == (MSLGroupInfo *) NULL))
7652 ThrowFatalException(ResourceLimitFatalError,
7653 "UnableToInterpretMSLImage");
7654 *msl_info.image_info=CloneImageInfo(image_info);
7655 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7656 *msl_info.attributes=AcquireImage(image_info);
7657 msl_info.group_info[0].numImages=0;
7658 /* the first slot is used to point to the MSL file image */
7659 *msl_info.image=msl_image;
7660 if (*image != (Image *) NULL)
7661 MSLPushImage(&msl_info,*image);
7662 (void) xmlSubstituteEntitiesDefault(1);
7663 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7664 sax_modules.internalSubset=MSLInternalSubset;
7665 sax_modules.isStandalone=MSLIsStandalone;
7666 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7667 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7668 sax_modules.resolveEntity=MSLResolveEntity;
7669 sax_modules.getEntity=MSLGetEntity;
7670 sax_modules.entityDecl=MSLEntityDeclaration;
7671 sax_modules.notationDecl=MSLNotationDeclaration;
7672 sax_modules.attributeDecl=MSLAttributeDeclaration;
7673 sax_modules.elementDecl=MSLElementDeclaration;
7674 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7675 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7676 sax_modules.startDocument=MSLStartDocument;
7677 sax_modules.endDocument=MSLEndDocument;
7678 sax_modules.startElement=MSLStartElement;
7679 sax_modules.endElement=MSLEndElement;
7680 sax_modules.reference=MSLReference;
7681 sax_modules.characters=MSLCharacters;
7682 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7683 sax_modules.processingInstruction=MSLProcessingInstructions;
7684 sax_modules.comment=MSLComment;
7685 sax_modules.warning=MSLWarning;
7686 sax_modules.error=MSLError;
7687 sax_modules.fatalError=MSLError;
7688 sax_modules.getParameterEntity=MSLGetParameterEntity;
7689 sax_modules.cdataBlock=MSLCDataBlock;
7690 sax_modules.externalSubset=MSLExternalSubset;
7691 sax_handler=(&sax_modules);
7692 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7693 msl_image->filename);
7694 while (ReadBlobString(msl_image,message) != (char *) NULL)
7696 n=(ssize_t) strlen(message);
7699 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7702 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7703 if (msl_info.exception->severity >= ErrorException)
7706 if (msl_info.exception->severity == UndefinedException)
7707 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7708 xmlFreeParserCtxt(msl_info.parser);
7709 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7711 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7712 msl_info.group_info);
7713 if (*image == (Image *) NULL)
7714 *image=(*msl_info.image);
7715 if ((*msl_info.image)->exception.severity != UndefinedException)
7716 return(MagickFalse);
7720 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7728 assert(image_info != (const ImageInfo *) NULL);
7729 assert(image_info->signature == MagickSignature);
7730 if (image_info->debug != MagickFalse)
7731 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7732 image_info->filename);
7733 assert(exception != (ExceptionInfo *) NULL);
7734 assert(exception->signature == MagickSignature);
7735 image=(Image *) NULL;
7736 (void) ProcessMSLScript(image_info,&image,exception);
7737 return(GetFirstImageInList(image));
7742 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7746 % R e g i s t e r M S L I m a g e %
7750 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7752 % RegisterMSLImage() adds attributes for the MSL image format to
7753 % the list of supported formats. The attributes include the image format
7754 % tag, a method to read and/or write the format, whether the format
7755 % supports the saving of more than one frame to the same file or blob,
7756 % whether the format supports native in-memory I/O, and a brief
7757 % description of the format.
7759 % The format of the RegisterMSLImage method is:
7761 % size_t RegisterMSLImage(void)
7764 ModuleExport size_t RegisterMSLImage(void)
7769 entry=SetMagickInfo("MSL");
7770 #if defined(MAGICKCORE_XML_DELEGATE)
7771 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7772 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7774 entry->description=ConstantString("Magick Scripting Language");
7775 entry->module=ConstantString("MSL");
7776 (void) RegisterMagickInfo(entry);
7777 return(MagickImageCoderSignature);
7780 #if defined(MAGICKCORE_XML_DELEGATE)
7782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7786 % S e t M S L A t t r i b u t e s %
7790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7792 % SetMSLAttributes() ...
7794 % The format of the SetMSLAttributes method is:
7796 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7797 % const char *keyword,const char *value)
7799 % A description of each parameter follows:
7801 % o msl_info: the MSL info.
7803 % o keyword: the keyword.
7805 % o value: the value.
7808 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7835 assert(msl_info != (MSLInfo *) NULL);
7836 if (keyword == (const char *) NULL)
7838 if (value == (const char *) NULL)
7840 exception=msl_info->exception;
7842 attributes=msl_info->attributes[n];
7843 image_info=msl_info->image_info[n];
7844 draw_info=msl_info->draw_info[n];
7845 image=msl_info->image[n];
7851 if (LocaleCompare(keyword,"adjoin") == 0)
7856 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7858 ThrowMSLException(OptionError,"UnrecognizedType",value);
7859 image_info->adjoin=(MagickBooleanType) adjoin;
7862 if (LocaleCompare(keyword,"alpha") == 0)
7867 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7869 ThrowMSLException(OptionError,"UnrecognizedType",value);
7870 if (image != (Image *) NULL)
7871 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7874 if (LocaleCompare(keyword,"antialias") == 0)
7879 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7881 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7882 image_info->antialias=(MagickBooleanType) antialias;
7885 if (LocaleCompare(keyword,"area-limit") == 0)
7890 limit=MagickResourceInfinity;
7891 if (LocaleCompare(value,"unlimited") != 0)
7892 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7893 (void) SetMagickResourceLimit(AreaResource,limit);
7896 if (LocaleCompare(keyword,"attenuate") == 0)
7898 (void) SetImageOption(image_info,keyword,value);
7901 if (LocaleCompare(keyword,"authenticate") == 0)
7903 (void) CloneString(&image_info->density,value);
7906 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7912 if (LocaleCompare(keyword,"background") == 0)
7914 (void) QueryColorDatabase(value,&image_info->background_color,
7918 if (LocaleCompare(keyword,"bias") == 0)
7920 if (image == (Image *) NULL)
7922 image->bias=SiPrefixToDouble(value,QuantumRange);
7925 if (LocaleCompare(keyword,"blue-primary") == 0)
7927 if (image == (Image *) NULL)
7929 flags=ParseGeometry(value,&geometry_info);
7930 image->chromaticity.blue_primary.x=geometry_info.rho;
7931 image->chromaticity.blue_primary.y=geometry_info.sigma;
7932 if ((flags & SigmaValue) == 0)
7933 image->chromaticity.blue_primary.y=
7934 image->chromaticity.blue_primary.x;
7937 if (LocaleCompare(keyword,"bordercolor") == 0)
7939 (void) QueryColorDatabase(value,&image_info->border_color,
7943 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7949 if (LocaleCompare(keyword,"density") == 0)
7951 (void) CloneString(&image_info->density,value);
7952 (void) CloneString(&draw_info->density,value);
7955 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7961 if (LocaleCompare(keyword,"fill") == 0)
7963 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7964 (void) SetImageOption(image_info,keyword,value);
7967 if (LocaleCompare(keyword,"filename") == 0)
7969 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7972 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7978 if (LocaleCompare(keyword,"gravity") == 0)
7983 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7985 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7986 (void) SetImageOption(image_info,keyword,value);
7989 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7995 if (LocaleCompare(keyword,"id") == 0)
7997 (void) SetImageProperty(attributes,keyword,value);
8000 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8006 if (LocaleCompare(keyword,"magick") == 0)
8008 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8011 if (LocaleCompare(keyword,"mattecolor") == 0)
8013 (void) QueryColorDatabase(value,&image_info->matte_color,
8017 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8023 if (LocaleCompare(keyword,"pointsize") == 0)
8025 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8026 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8029 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8035 if (LocaleCompare(keyword,"quality") == 0)
8037 image_info->quality=StringToLong(value);
8038 if (image == (Image *) NULL)
8040 image->quality=StringToLong(value);
8048 if (LocaleCompare(keyword,"size") == 0)
8050 (void) CloneString(&image_info->size,value);
8053 if (LocaleCompare(keyword,"stroke") == 0)
8055 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8056 (void) SetImageOption(image_info,keyword,value);
8059 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8064 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8077 % U n r e g i s t e r M S L I m a g e %
8081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8083 % UnregisterMSLImage() removes format registrations made by the
8084 % MSL module from the list of supported formats.
8086 % The format of the UnregisterMSLImage method is:
8088 % UnregisterMSLImage(void)
8091 ModuleExport void UnregisterMSLImage(void)
8093 (void) UnregisterMagickInfo("MSL");
8096 #if defined(MAGICKCORE_XML_DELEGATE)
8098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8102 % W r i t e M S L I m a g e %
8106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8108 % WriteMSLImage() writes an image to a file in MVG image format.
8110 % The format of the WriteMSLImage method is:
8112 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8114 % A description of each parameter follows.
8116 % o image_info: the image info.
8118 % o image: The image.
8121 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8123 assert(image_info != (const ImageInfo *) NULL);
8124 assert(image_info->signature == MagickSignature);
8125 assert(image != (Image *) NULL);
8126 assert(image->signature == MagickSignature);
8127 if (image->debug != MagickFalse)
8128 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8129 (void) ReferenceImage(image);
8130 (void) ProcessMSLScript(image_info,&image,&image->exception);