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 PushPixelChannelMap(msl_info->image[n],channel);
740 noise_image=AddNoiseImage(msl_info->image[n],noise,
741 &msl_info->image[n]->exception);
742 PopPixelChannelMap(msl_info->image[n]);
743 if (noise_image == (Image *) NULL)
745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
746 msl_info->image[n]=noise_image;
749 if (LocaleCompare((const char *) tag,"annotate") == 0)
757 if (msl_info->image[n] == (Image *) NULL)
759 ThrowMSLException(OptionError,"NoImagesDefined",
763 draw_info=CloneDrawInfo(msl_info->image_info[n],
764 msl_info->draw_info[n]);
766 current=draw_info->affine;
767 GetAffineMatrix(&affine);
768 if (attributes != (const xmlChar **) NULL)
769 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
771 keyword=(const char *) attributes[i++];
772 attribute=InterpretImageProperties(msl_info->image_info[n],
773 msl_info->attributes[n],(const char *) attributes[i]);
774 CloneString(&value,attribute);
780 if (LocaleCompare(keyword,"affine") == 0)
786 draw_info->affine.sx=InterpretLocaleValue(p,&p);
789 draw_info->affine.rx=InterpretLocaleValue(p,&p);
792 draw_info->affine.ry=InterpretLocaleValue(p,&p);
795 draw_info->affine.sy=InterpretLocaleValue(p,&p);
798 draw_info->affine.tx=InterpretLocaleValue(p,&p);
801 draw_info->affine.ty=InterpretLocaleValue(p,&p);
804 if (LocaleCompare(keyword,"align") == 0)
806 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
809 ThrowMSLException(OptionError,"UnrecognizedAlignType",
811 draw_info->align=(AlignType) option;
814 if (LocaleCompare(keyword,"antialias") == 0)
816 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
819 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
821 draw_info->stroke_antialias=(MagickBooleanType) option;
822 draw_info->text_antialias=(MagickBooleanType) option;
825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
832 if (LocaleCompare(keyword,"density") == 0)
834 CloneString(&draw_info->density,value);
837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
844 if (LocaleCompare(keyword,"encoding") == 0)
846 CloneString(&draw_info->encoding,value);
849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
856 if (LocaleCompare(keyword, "fill") == 0)
858 (void) QueryColorDatabase(value,&draw_info->fill,
862 if (LocaleCompare(keyword,"family") == 0)
864 CloneString(&draw_info->family,value);
867 if (LocaleCompare(keyword,"font") == 0)
869 CloneString(&draw_info->font,value);
872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
879 if (LocaleCompare(keyword,"geometry") == 0)
881 flags=ParseGravityGeometry(msl_info->image[n],value,
882 &geometry,&exception);
885 if (LocaleCompare(keyword,"gravity") == 0)
887 option=ParseCommandOption(MagickGravityOptions,
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 PushPixelChannelMap(msl_info->image[n],channel);
1233 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1234 geometry_info.sigma,&msl_info->image[n]->exception);
1235 PopPixelChannelMap(msl_info->image[n]);
1236 if (blur_image == (Image *) NULL)
1238 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1239 msl_info->image[n]=blur_image;
1242 if (LocaleCompare((const char *) tag,"border") == 0)
1250 if (msl_info->image[n] == (Image *) NULL)
1252 ThrowMSLException(OptionError,"NoImagesDefined",
1253 (const char *) tag);
1256 SetGeometry(msl_info->image[n],&geometry);
1257 if (attributes != (const xmlChar **) NULL)
1258 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1260 keyword=(const char *) attributes[i++];
1261 attribute=InterpretImageProperties(msl_info->image_info[n],
1262 msl_info->attributes[n],(const char *) attributes[i]);
1263 CloneString(&value,attribute);
1269 if (LocaleCompare(keyword,"compose") == 0)
1271 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1274 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1276 msl_info->image[n]->compose=(CompositeOperator) option;
1279 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1286 if (LocaleCompare(keyword, "fill") == 0)
1288 (void) QueryColorDatabase(value,
1289 &msl_info->image[n]->border_color,&exception);
1292 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1299 if (LocaleCompare(keyword,"geometry") == 0)
1301 flags=ParsePageGeometry(msl_info->image[n],value,
1302 &geometry,&exception);
1303 if ((flags & HeightValue) == 0)
1304 geometry.height=geometry.width;
1307 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1314 if (LocaleCompare(keyword,"height") == 0)
1316 geometry.height=StringToLong(value);
1319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1326 if (LocaleCompare(keyword,"width") == 0)
1328 geometry.width=StringToLong(value);
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1337 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1343 border_image=BorderImage(msl_info->image[n],&geometry,
1344 &msl_info->image[n]->exception);
1345 if (border_image == (Image *) NULL)
1347 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1348 msl_info->image[n]=border_image;
1351 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1356 if (LocaleCompare((const char *) tag,"colorize") == 0)
1359 opacity[MaxTextExtent];
1370 if (msl_info->image[n] == (Image *) NULL)
1372 ThrowMSLException(OptionError,"NoImagesDefined",
1373 (const char *) tag);
1376 target=msl_info->image[n]->background_color;
1377 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1378 if (attributes != (const xmlChar **) NULL)
1379 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1381 keyword=(const char *) attributes[i++];
1382 attribute=InterpretImageProperties(msl_info->image_info[n],
1383 msl_info->attributes[n],(const char *) attributes[i]);
1384 CloneString(&value,attribute);
1390 if (LocaleCompare(keyword,"fill") == 0)
1392 (void) QueryColorDatabase(value,&target,
1393 &msl_info->image[n]->exception);
1396 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1403 if (LocaleCompare(keyword,"opacity") == 0)
1405 (void) CopyMagickString(opacity,value,MaxTextExtent);
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1420 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1421 &msl_info->image[n]->exception);
1422 if (colorize_image == (Image *) NULL)
1424 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1425 msl_info->image[n]=colorize_image;
1428 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1430 double radius = 0.0,
1433 if (msl_info->image[n] == (Image *) NULL)
1435 ThrowMSLException(OptionError,"NoImagesDefined",
1436 (const char *) tag);
1440 NOTE: charcoal can have no attributes, since we use all the defaults!
1442 if (attributes != (const xmlChar **) NULL)
1444 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1446 keyword=(const char *) attributes[i++];
1447 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1448 msl_info->attributes[n],(const char *) attributes[i]));
1454 if (LocaleCompare(keyword, "radius") == 0)
1456 radius = InterpretLocaleValue(value,(char **) NULL);
1459 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1465 if (LocaleCompare(keyword,"sigma") == 0)
1467 sigma = StringToLong( value );
1470 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1475 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1490 &msl_info->image[n]->exception);
1491 if (newImage == (Image *) NULL)
1493 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1494 msl_info->image[n]=newImage;
1498 if (LocaleCompare((const char *) tag,"chop") == 0)
1506 if (msl_info->image[n] == (Image *) NULL)
1508 ThrowMSLException(OptionError,"NoImagesDefined",
1509 (const char *) tag);
1512 SetGeometry(msl_info->image[n],&geometry);
1513 if (attributes != (const xmlChar **) NULL)
1514 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1516 keyword=(const char *) attributes[i++];
1517 attribute=InterpretImageProperties(msl_info->image_info[n],
1518 msl_info->attributes[n],(const char *) attributes[i]);
1519 CloneString(&value,attribute);
1525 if (LocaleCompare(keyword,"geometry") == 0)
1527 flags=ParsePageGeometry(msl_info->image[n],value,
1528 &geometry,&exception);
1529 if ((flags & HeightValue) == 0)
1530 geometry.height=geometry.width;
1533 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1540 if (LocaleCompare(keyword,"height") == 0)
1542 geometry.height=StringToLong(value);
1545 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1552 if (LocaleCompare(keyword,"width") == 0)
1554 geometry.width=StringToLong(value);
1557 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1564 if (LocaleCompare(keyword,"x") == 0)
1566 geometry.x=StringToLong(value);
1569 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1576 if (LocaleCompare(keyword,"y") == 0)
1578 geometry.y=StringToLong(value);
1581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1587 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1593 chop_image=ChopImage(msl_info->image[n],&geometry,
1594 &msl_info->image[n]->exception);
1595 if (chop_image == (Image *) NULL)
1597 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1598 msl_info->image[n]=chop_image;
1601 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1610 Color floodfill image.
1612 if (msl_info->image[n] == (Image *) NULL)
1614 ThrowMSLException(OptionError,"NoImagesDefined",
1615 (const char *) tag);
1618 draw_info=CloneDrawInfo(msl_info->image_info[n],
1619 msl_info->draw_info[n]);
1620 SetGeometry(msl_info->image[n],&geometry);
1621 paint_method=FloodfillMethod;
1622 if (attributes != (const xmlChar **) NULL)
1623 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1625 keyword=(const char *) attributes[i++];
1626 attribute=InterpretImageProperties(msl_info->image_info[n],
1627 msl_info->attributes[n],(const char *) attributes[i]);
1628 CloneString(&value,attribute);
1634 if (LocaleCompare(keyword,"bordercolor") == 0)
1636 (void) QueryMagickColor(value,&target,&exception);
1637 paint_method=FillToBorderMethod;
1640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1647 if (LocaleCompare(keyword,"fill") == 0)
1649 (void) QueryColorDatabase(value,&draw_info->fill,
1653 if (LocaleCompare(keyword,"fuzz") == 0)
1655 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1666 if (LocaleCompare(keyword,"geometry") == 0)
1668 flags=ParsePageGeometry(msl_info->image[n],value,
1669 &geometry,&exception);
1670 if ((flags & HeightValue) == 0)
1671 geometry.height=geometry.width;
1672 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1673 geometry.x,geometry.y,&target,&exception);
1676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1683 if (LocaleCompare(keyword,"x") == 0)
1685 geometry.x=StringToLong(value);
1686 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1687 geometry.x,geometry.y,&target,&exception);
1690 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1697 if (LocaleCompare(keyword,"y") == 0)
1699 geometry.y=StringToLong(value);
1700 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1701 geometry.x,geometry.y,&target,&exception);
1704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1716 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1717 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1718 MagickFalse : MagickTrue);
1719 draw_info=DestroyDrawInfo(draw_info);
1722 if (LocaleCompare((const char *) tag,"comment") == 0)
1724 if (LocaleCompare((const char *) tag,"composite") == 0)
1727 composite_geometry[MaxTextExtent];
1742 if (msl_info->image[n] == (Image *) NULL)
1744 ThrowMSLException(OptionError,"NoImagesDefined",
1745 (const char *) tag);
1748 composite_image=NewImageList();
1749 compose=OverCompositeOp;
1750 if (attributes != (const xmlChar **) NULL)
1751 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1753 keyword=(const char *) attributes[i++];
1754 attribute=InterpretImageProperties(msl_info->image_info[n],
1755 msl_info->attributes[n],(const char *) attributes[i]);
1756 CloneString(&value,attribute);
1762 if (LocaleCompare(keyword,"compose") == 0)
1764 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1767 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1769 compose=(CompositeOperator) option;
1777 if (LocaleCompare(keyword,"image") == 0)
1778 for (j=0; j < msl_info->n; j++)
1783 attribute=GetImageProperty(msl_info->attributes[j],"id");
1784 if ((attribute != (const char *) NULL) &&
1785 (LocaleCompare(attribute,value) == 0))
1787 composite_image=CloneImage(msl_info->image[j],0,0,
1788 MagickFalse,&exception);
1798 if (composite_image == (Image *) NULL)
1800 rotate_image=NewImageList();
1801 SetGeometry(msl_info->image[n],&geometry);
1802 if (attributes != (const xmlChar **) NULL)
1803 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1805 keyword=(const char *) attributes[i++];
1806 attribute=InterpretImageProperties(msl_info->image_info[n],
1807 msl_info->attributes[n],(const char *) attributes[i]);
1808 CloneString(&value,attribute);
1814 if (LocaleCompare(keyword,"blend") == 0)
1816 (void) SetImageArtifact(composite_image,
1817 "compose:args",value);
1820 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1827 if (LocaleCompare(keyword,"channel") == 0)
1829 option=ParseChannelOption(value);
1831 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1833 channel=(ChannelType) option;
1836 if (LocaleCompare(keyword, "color") == 0)
1838 (void) QueryColorDatabase(value,
1839 &composite_image->background_color,&exception);
1842 if (LocaleCompare(keyword,"compose") == 0)
1844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1851 if (LocaleCompare(keyword,"geometry") == 0)
1853 flags=ParsePageGeometry(msl_info->image[n],value,
1854 &geometry,&exception);
1855 if ((flags & HeightValue) == 0)
1856 geometry.height=geometry.width;
1857 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1858 geometry.y,&target,&exception);
1861 if (LocaleCompare(keyword,"gravity") == 0)
1863 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1866 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1868 msl_info->image[n]->gravity=(GravityType) option;
1871 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1878 if (LocaleCompare(keyword,"image") == 0)
1880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1887 if (LocaleCompare(keyword,"mask") == 0)
1888 for (j=0; j < msl_info->n; j++)
1893 attribute=GetImageProperty(msl_info->attributes[j],"id");
1894 if ((attribute != (const char *) NULL) &&
1895 (LocaleCompare(value,value) == 0))
1897 SetImageType(composite_image,TrueColorMatteType);
1898 (void) CompositeImage(composite_image,
1899 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1910 if (LocaleCompare(keyword,"opacity") == 0)
1925 opacity=StringToLong(value);
1926 if (compose != DissolveCompositeOp)
1928 (void) SetImageOpacity(composite_image,(Quantum)
1932 (void) SetImageArtifact(msl_info->image[n],
1933 "compose:args",value);
1934 if (composite_image->matte != MagickTrue)
1935 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1936 composite_view=AcquireCacheView(composite_image);
1937 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1939 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1940 (ssize_t) composite_image->columns,1,&exception);
1941 for (x=0; x < (ssize_t) composite_image->columns; x++)
1943 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1944 SetPixelAlpha(composite_image,
1945 ClampToQuantum(opacity),q);
1946 q+=GetPixelChannels(composite_image);
1948 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1951 composite_view=DestroyCacheView(composite_view);
1954 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1961 if (LocaleCompare(keyword,"rotate") == 0)
1963 rotate_image=RotateImage(composite_image,
1964 InterpretLocaleValue(value,(char **) NULL),&exception);
1967 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1974 if (LocaleCompare(keyword,"tile") == 0)
1979 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1982 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1984 tile=(MagickBooleanType) option;
1986 if (rotate_image != (Image *) NULL)
1987 (void) SetImageArtifact(rotate_image,
1988 "compose:outside-overlay","false");
1990 (void) SetImageArtifact(composite_image,
1991 "compose:outside-overlay","false");
1992 image=msl_info->image[n];
1993 height=composite_image->rows;
1994 width=composite_image->columns;
1995 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1996 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1998 if (rotate_image != (Image *) NULL)
1999 (void) CompositeImage(image,compose,rotate_image,
2002 (void) CompositeImage(image,compose,
2003 composite_image,x,y);
2005 if (rotate_image != (Image *) NULL)
2006 rotate_image=DestroyImage(rotate_image);
2009 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2016 if (LocaleCompare(keyword,"x") == 0)
2018 geometry.x=StringToLong(value);
2019 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2020 geometry.y,&target,&exception);
2023 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2030 if (LocaleCompare(keyword,"y") == 0)
2032 geometry.y=StringToLong(value);
2033 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2034 geometry.y,&target,&exception);
2037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2049 image=msl_info->image[n];
2050 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2051 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2052 (double) composite_image->rows,(double) geometry.x,(double)
2054 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2056 PushPixelChannelMap(image,channel);
2057 if (rotate_image == (Image *) NULL)
2058 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
2064 geometry.x-=(ssize_t) (rotate_image->columns-
2065 composite_image->columns)/2;
2066 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2067 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
2068 rotate_image=DestroyImage(rotate_image);
2070 PopPixelChannelMap(image);
2071 composite_image=DestroyImage(composite_image);
2074 if (LocaleCompare((const char *) tag,"contrast") == 0)
2082 if (msl_info->image[n] == (Image *) NULL)
2084 ThrowMSLException(OptionError,"NoImagesDefined",
2085 (const char *) tag);
2088 sharpen=MagickFalse;
2089 if (attributes != (const xmlChar **) NULL)
2090 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2092 keyword=(const char *) attributes[i++];
2093 attribute=InterpretImageProperties(msl_info->image_info[n],
2094 msl_info->attributes[n],(const char *) attributes[i]);
2095 CloneString(&value,attribute);
2101 if (LocaleCompare(keyword,"sharpen") == 0)
2103 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2106 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2108 sharpen=(MagickBooleanType) option;
2111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2117 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2123 (void) ContrastImage(msl_info->image[n],sharpen);
2126 if (LocaleCompare((const char *) tag,"crop") == 0)
2134 if (msl_info->image[n] == (Image *) NULL)
2136 ThrowMSLException(OptionError,"NoImagesDefined",
2137 (const char *) tag);
2140 SetGeometry(msl_info->image[n],&geometry);
2141 if (attributes != (const xmlChar **) NULL)
2142 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2144 keyword=(const char *) attributes[i++];
2145 attribute=InterpretImageProperties(msl_info->image_info[n],
2146 msl_info->attributes[n],(const char *) attributes[i]);
2147 CloneString(&value,attribute);
2153 if (LocaleCompare(keyword,"geometry") == 0)
2155 flags=ParseGravityGeometry(msl_info->image[n],value,
2156 &geometry,&exception);
2159 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2166 if (LocaleCompare(keyword,"height") == 0)
2168 geometry.height=StringToLong(value);
2171 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2178 if (LocaleCompare(keyword,"width") == 0)
2180 geometry.width=StringToLong(value);
2183 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2190 if (LocaleCompare(keyword,"x") == 0)
2192 geometry.x=StringToLong(value);
2195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2202 if (LocaleCompare(keyword,"y") == 0)
2204 geometry.y=StringToLong(value);
2207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2219 crop_image=CropImage(msl_info->image[n],&geometry,
2220 &msl_info->image[n]->exception);
2221 if (crop_image == (Image *) NULL)
2223 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2224 msl_info->image[n]=crop_image;
2227 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2233 Cycle-colormap image.
2235 if (msl_info->image[n] == (Image *) NULL)
2237 ThrowMSLException(OptionError,"NoImagesDefined",
2238 (const char *) tag);
2242 if (attributes != (const xmlChar **) NULL)
2243 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2245 keyword=(const char *) attributes[i++];
2246 attribute=InterpretImageProperties(msl_info->image_info[n],
2247 msl_info->attributes[n],(const char *) attributes[i]);
2248 CloneString(&value,attribute);
2254 if (LocaleCompare(keyword,"display") == 0)
2256 display=StringToLong(value);
2259 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2265 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2271 (void) CycleColormapImage(msl_info->image[n],display);
2274 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2279 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2287 if (msl_info->image[n] == (Image *) NULL)
2289 ThrowMSLException(OptionError,"NoImagesDefined",
2290 (const char *) tag);
2293 if (attributes != (const xmlChar **) NULL)
2294 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2296 keyword=(const char *) attributes[i++];
2297 attribute=InterpretImageProperties(msl_info->image_info[n],
2298 msl_info->attributes[n],(const char *) attributes[i]);
2299 CloneString(&value,attribute);
2300 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2302 despeckle_image=DespeckleImage(msl_info->image[n],
2303 &msl_info->image[n]->exception);
2304 if (despeckle_image == (Image *) NULL)
2306 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2307 msl_info->image[n]=despeckle_image;
2310 if (LocaleCompare((const char *) tag,"display") == 0)
2312 if (msl_info->image[n] == (Image *) NULL)
2314 ThrowMSLException(OptionError,"NoImagesDefined",
2315 (const char *) tag);
2318 if (attributes != (const xmlChar **) NULL)
2319 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2321 keyword=(const char *) attributes[i++];
2322 attribute=InterpretImageProperties(msl_info->image_info[n],
2323 msl_info->attributes[n],(const char *) attributes[i]);
2324 CloneString(&value,attribute);
2329 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2335 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2338 if (LocaleCompare((const char *) tag,"draw") == 0)
2341 text[MaxTextExtent];
2346 if (msl_info->image[n] == (Image *) NULL)
2348 ThrowMSLException(OptionError,"NoImagesDefined",
2349 (const char *) tag);
2352 draw_info=CloneDrawInfo(msl_info->image_info[n],
2353 msl_info->draw_info[n]);
2355 current=draw_info->affine;
2356 GetAffineMatrix(&affine);
2357 if (attributes != (const xmlChar **) NULL)
2358 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2360 keyword=(const char *) attributes[i++];
2361 attribute=InterpretImageProperties(msl_info->image_info[n],
2362 msl_info->attributes[n],(const char *) attributes[i]);
2363 CloneString(&value,attribute);
2369 if (LocaleCompare(keyword,"affine") == 0)
2375 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2378 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2381 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2384 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2387 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2390 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2393 if (LocaleCompare(keyword,"align") == 0)
2395 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2398 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2400 draw_info->align=(AlignType) option;
2403 if (LocaleCompare(keyword,"antialias") == 0)
2405 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2408 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2410 draw_info->stroke_antialias=(MagickBooleanType) option;
2411 draw_info->text_antialias=(MagickBooleanType) option;
2414 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2421 if (LocaleCompare(keyword,"density") == 0)
2423 CloneString(&draw_info->density,value);
2426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2433 if (LocaleCompare(keyword,"encoding") == 0)
2435 CloneString(&draw_info->encoding,value);
2438 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2445 if (LocaleCompare(keyword, "fill") == 0)
2447 (void) QueryColorDatabase(value,&draw_info->fill,
2451 if (LocaleCompare(keyword,"family") == 0)
2453 CloneString(&draw_info->family,value);
2456 if (LocaleCompare(keyword,"font") == 0)
2458 CloneString(&draw_info->font,value);
2461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2468 if (LocaleCompare(keyword,"geometry") == 0)
2470 flags=ParsePageGeometry(msl_info->image[n],value,
2471 &geometry,&exception);
2472 if ((flags & HeightValue) == 0)
2473 geometry.height=geometry.width;
2476 if (LocaleCompare(keyword,"gravity") == 0)
2478 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2481 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2483 draw_info->gravity=(GravityType) option;
2486 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2493 if (LocaleCompare(keyword,"primitive") == 0)
2495 CloneString(&draw_info->primitive,value);
2498 if (LocaleCompare(keyword,"pointsize") == 0)
2500 draw_info->pointsize=InterpretLocaleValue(value,
2504 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2511 if (LocaleCompare(keyword,"rotate") == 0)
2513 angle=InterpretLocaleValue(value,(char **) NULL);
2514 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2515 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2516 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2517 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2520 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2527 if (LocaleCompare(keyword,"scale") == 0)
2529 flags=ParseGeometry(value,&geometry_info);
2530 if ((flags & SigmaValue) == 0)
2531 geometry_info.sigma=1.0;
2532 affine.sx=geometry_info.rho;
2533 affine.sy=geometry_info.sigma;
2536 if (LocaleCompare(keyword,"skewX") == 0)
2538 angle=InterpretLocaleValue(value,(char **) NULL);
2539 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2542 if (LocaleCompare(keyword,"skewY") == 0)
2544 angle=InterpretLocaleValue(value,(char **) NULL);
2545 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2548 if (LocaleCompare(keyword,"stretch") == 0)
2550 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2553 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2555 draw_info->stretch=(StretchType) option;
2558 if (LocaleCompare(keyword, "stroke") == 0)
2560 (void) QueryColorDatabase(value,&draw_info->stroke,
2564 if (LocaleCompare(keyword,"strokewidth") == 0)
2566 draw_info->stroke_width=StringToLong(value);
2569 if (LocaleCompare(keyword,"style") == 0)
2571 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2574 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2576 draw_info->style=(StyleType) option;
2579 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2586 if (LocaleCompare(keyword,"text") == 0)
2588 CloneString(&draw_info->text,value);
2591 if (LocaleCompare(keyword,"translate") == 0)
2593 flags=ParseGeometry(value,&geometry_info);
2594 if ((flags & SigmaValue) == 0)
2595 geometry_info.sigma=1.0;
2596 affine.tx=geometry_info.rho;
2597 affine.ty=geometry_info.sigma;
2600 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2607 if (LocaleCompare(keyword, "undercolor") == 0)
2609 (void) QueryColorDatabase(value,&draw_info->undercolor,
2613 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2620 if (LocaleCompare(keyword,"weight") == 0)
2622 draw_info->weight=StringToLong(value);
2625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2632 if (LocaleCompare(keyword,"x") == 0)
2634 geometry.x=StringToLong(value);
2637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2644 if (LocaleCompare(keyword,"y") == 0)
2646 geometry.y=StringToLong(value);
2649 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2655 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2661 (void) FormatLocaleString(text,MaxTextExtent,
2662 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2663 geometry.height,(double) geometry.x,(double) geometry.y);
2664 CloneString(&draw_info->geometry,text);
2665 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2666 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2667 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2668 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2669 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2671 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2673 (void) DrawImage(msl_info->image[n],draw_info);
2674 draw_info=DestroyDrawInfo(draw_info);
2677 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2682 if (LocaleCompare((const char *) tag,"edge") == 0)
2690 if (msl_info->image[n] == (Image *) NULL)
2692 ThrowMSLException(OptionError,"NoImagesDefined",
2693 (const char *) tag);
2696 if (attributes != (const xmlChar **) NULL)
2697 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2699 keyword=(const char *) attributes[i++];
2700 attribute=InterpretImageProperties(msl_info->image_info[n],
2701 msl_info->attributes[n],(const char *) attributes[i]);
2702 CloneString(&value,attribute);
2708 if (LocaleCompare(keyword,"geometry") == 0)
2710 flags=ParseGeometry(value,&geometry_info);
2711 if ((flags & SigmaValue) == 0)
2712 geometry_info.sigma=1.0;
2715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2722 if (LocaleCompare(keyword,"radius") == 0)
2724 geometry_info.rho=InterpretLocaleValue(value,
2728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2740 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2741 &msl_info->image[n]->exception);
2742 if (edge_image == (Image *) NULL)
2744 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2745 msl_info->image[n]=edge_image;
2748 if (LocaleCompare((const char *) tag,"emboss") == 0)
2756 if (msl_info->image[n] == (Image *) NULL)
2758 ThrowMSLException(OptionError,"NoImagesDefined",
2759 (const char *) tag);
2762 if (attributes != (const xmlChar **) NULL)
2763 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2765 keyword=(const char *) attributes[i++];
2766 attribute=InterpretImageProperties(msl_info->image_info[n],
2767 msl_info->attributes[n],(const char *) attributes[i]);
2768 CloneString(&value,attribute);
2774 if (LocaleCompare(keyword,"geometry") == 0)
2776 flags=ParseGeometry(value,&geometry_info);
2777 if ((flags & SigmaValue) == 0)
2778 geometry_info.sigma=1.0;
2781 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2788 if (LocaleCompare(keyword,"radius") == 0)
2790 geometry_info.rho=InterpretLocaleValue(value,
2794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2801 if (LocaleCompare(keyword,"sigma") == 0)
2803 geometry_info.sigma=StringToLong(value);
2806 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2818 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2819 geometry_info.sigma,&msl_info->image[n]->exception);
2820 if (emboss_image == (Image *) NULL)
2822 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2823 msl_info->image[n]=emboss_image;
2826 if (LocaleCompare((const char *) tag,"enhance") == 0)
2834 if (msl_info->image[n] == (Image *) NULL)
2836 ThrowMSLException(OptionError,"NoImagesDefined",
2837 (const char *) tag);
2840 if (attributes != (const xmlChar **) NULL)
2841 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2843 keyword=(const char *) attributes[i++];
2844 attribute=InterpretImageProperties(msl_info->image_info[n],
2845 msl_info->attributes[n],(const char *) attributes[i]);
2846 CloneString(&value,attribute);
2847 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2849 enhance_image=EnhanceImage(msl_info->image[n],
2850 &msl_info->image[n]->exception);
2851 if (enhance_image == (Image *) NULL)
2853 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2854 msl_info->image[n]=enhance_image;
2857 if (LocaleCompare((const char *) tag,"equalize") == 0)
2862 if (msl_info->image[n] == (Image *) NULL)
2864 ThrowMSLException(OptionError,"NoImagesDefined",
2865 (const char *) tag);
2868 if (attributes != (const xmlChar **) NULL)
2869 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2871 keyword=(const char *) attributes[i++];
2872 attribute=InterpretImageProperties(msl_info->image_info[n],
2873 msl_info->attributes[n],(const char *) attributes[i]);
2874 CloneString(&value,attribute);
2879 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2885 (void) EqualizeImage(msl_info->image[n]);
2888 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2893 if (LocaleCompare((const char *) tag, "flatten") == 0)
2895 if (msl_info->image[n] == (Image *) NULL)
2897 ThrowMSLException(OptionError,"NoImagesDefined",
2898 (const char *) tag);
2902 /* no attributes here */
2904 /* process the image */
2909 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2910 &msl_info->image[n]->exception);
2911 if (newImage == (Image *) NULL)
2913 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2914 msl_info->image[n]=newImage;
2918 if (LocaleCompare((const char *) tag,"flip") == 0)
2926 if (msl_info->image[n] == (Image *) NULL)
2928 ThrowMSLException(OptionError,"NoImagesDefined",
2929 (const char *) tag);
2932 if (attributes != (const xmlChar **) NULL)
2933 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2935 keyword=(const char *) attributes[i++];
2936 attribute=InterpretImageProperties(msl_info->image_info[n],
2937 msl_info->attributes[n],(const char *) attributes[i]);
2938 CloneString(&value,attribute);
2939 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2941 flip_image=FlipImage(msl_info->image[n],
2942 &msl_info->image[n]->exception);
2943 if (flip_image == (Image *) NULL)
2945 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2946 msl_info->image[n]=flip_image;
2949 if (LocaleCompare((const char *) tag,"flop") == 0)
2957 if (msl_info->image[n] == (Image *) NULL)
2959 ThrowMSLException(OptionError,"NoImagesDefined",
2960 (const char *) tag);
2963 if (attributes != (const xmlChar **) NULL)
2964 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2966 keyword=(const char *) attributes[i++];
2967 attribute=InterpretImageProperties(msl_info->image_info[n],
2968 msl_info->attributes[n],(const char *) attributes[i]);
2969 CloneString(&value,attribute);
2970 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2972 flop_image=FlopImage(msl_info->image[n],
2973 &msl_info->image[n]->exception);
2974 if (flop_image == (Image *) NULL)
2976 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2977 msl_info->image[n]=flop_image;
2980 if (LocaleCompare((const char *) tag,"frame") == 0)
2991 if (msl_info->image[n] == (Image *) NULL)
2993 ThrowMSLException(OptionError,"NoImagesDefined",
2994 (const char *) tag);
2997 SetGeometry(msl_info->image[n],&geometry);
2998 if (attributes != (const xmlChar **) NULL)
2999 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3001 keyword=(const char *) attributes[i++];
3002 attribute=InterpretImageProperties(msl_info->image_info[n],
3003 msl_info->attributes[n],(const char *) attributes[i]);
3004 CloneString(&value,attribute);
3010 if (LocaleCompare(keyword,"compose") == 0)
3012 option=ParseCommandOption(MagickComposeOptions,
3015 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3017 msl_info->image[n]->compose=(CompositeOperator) option;
3020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3027 if (LocaleCompare(keyword, "fill") == 0)
3029 (void) QueryColorDatabase(value,
3030 &msl_info->image[n]->matte_color,&exception);
3033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3040 if (LocaleCompare(keyword,"geometry") == 0)
3042 flags=ParsePageGeometry(msl_info->image[n],value,
3043 &geometry,&exception);
3044 if ((flags & HeightValue) == 0)
3045 geometry.height=geometry.width;
3046 frame_info.width=geometry.width;
3047 frame_info.height=geometry.height;
3048 frame_info.outer_bevel=geometry.x;
3049 frame_info.inner_bevel=geometry.y;
3052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3059 if (LocaleCompare(keyword,"height") == 0)
3061 frame_info.height=StringToLong(value);
3064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3071 if (LocaleCompare(keyword,"inner") == 0)
3073 frame_info.inner_bevel=StringToLong(value);
3076 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3083 if (LocaleCompare(keyword,"outer") == 0)
3085 frame_info.outer_bevel=StringToLong(value);
3088 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3095 if (LocaleCompare(keyword,"width") == 0)
3097 frame_info.width=StringToLong(value);
3100 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3106 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3112 frame_info.x=(ssize_t) frame_info.width;
3113 frame_info.y=(ssize_t) frame_info.height;
3114 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3115 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3116 frame_image=FrameImage(msl_info->image[n],&frame_info,
3117 &msl_info->image[n]->exception);
3118 if (frame_image == (Image *) NULL)
3120 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3121 msl_info->image[n]=frame_image;
3124 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3129 if (LocaleCompare((const char *) tag,"gamma") == 0)
3132 gamma[MaxTextExtent];
3140 if (msl_info->image[n] == (Image *) NULL)
3142 ThrowMSLException(OptionError,"NoImagesDefined",
3143 (const char *) tag);
3146 channel=UndefinedChannel;
3151 if (attributes != (const xmlChar **) NULL)
3152 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3154 keyword=(const char *) attributes[i++];
3155 attribute=InterpretImageProperties(msl_info->image_info[n],
3156 msl_info->attributes[n],(const char *) attributes[i]);
3157 CloneString(&value,attribute);
3163 if (LocaleCompare(keyword,"blue") == 0)
3165 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3168 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3175 if (LocaleCompare(keyword,"channel") == 0)
3177 option=ParseChannelOption(value);
3179 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3181 channel=(ChannelType) option;
3184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3191 if (LocaleCompare(keyword,"gamma") == 0)
3193 (void) CopyMagickString(gamma,value,MaxTextExtent);
3196 if (LocaleCompare(keyword,"green") == 0)
3198 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3208 if (LocaleCompare(keyword,"red") == 0)
3210 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3226 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3227 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3228 (void) GammaImage(msl_info->image[n],atof(gamma),
3229 &msl_info->image[n]->exception);
3232 else if (LocaleCompare((const char *) tag,"get") == 0)
3234 if (msl_info->image[n] == (Image *) NULL)
3236 ThrowMSLException(OptionError,"NoImagesDefined",
3237 (const char *) tag);
3240 if (attributes == (const xmlChar **) NULL)
3242 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3244 keyword=(const char *) attributes[i++];
3245 CloneString(&value,(const char *) attributes[i]);
3246 (void) CopyMagickString(key,value,MaxTextExtent);
3252 if (LocaleCompare(keyword,"height") == 0)
3254 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3255 (double) msl_info->image[n]->rows);
3256 (void) SetImageProperty(msl_info->attributes[n],key,value);
3259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3264 if (LocaleCompare(keyword,"width") == 0)
3266 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3267 (double) msl_info->image[n]->columns);
3268 (void) SetImageProperty(msl_info->attributes[n],key,value);
3271 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3275 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3282 else if (LocaleCompare((const char *) tag, "group") == 0)
3284 msl_info->number_groups++;
3285 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3286 msl_info->group_info,msl_info->number_groups+1UL,
3287 sizeof(*msl_info->group_info));
3290 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3295 if (LocaleCompare((const char *) tag,"image") == 0)
3297 MSLPushImage(msl_info,(Image *) NULL);
3298 if (attributes == (const xmlChar **) NULL)
3300 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3302 keyword=(const char *) attributes[i++];
3303 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3304 msl_info->attributes[n],(const char *) attributes[i]));
3310 if (LocaleCompare(keyword,"color") == 0)
3315 (void) CopyMagickString(msl_info->image_info[n]->filename,
3316 "xc:",MaxTextExtent);
3317 (void) ConcatenateMagickString(msl_info->image_info[n]->
3318 filename,value,MaxTextExtent);
3319 next_image=ReadImage(msl_info->image_info[n],&exception);
3320 CatchException(&exception);
3321 if (next_image == (Image *) NULL)
3323 if (msl_info->image[n] == (Image *) NULL)
3324 msl_info->image[n]=next_image;
3331 Link image into image list.
3333 p=msl_info->image[n];
3334 while (p->next != (Image *) NULL)
3335 p=GetNextImageInList(p);
3336 next_image->previous=p;
3341 (void) SetMSLAttributes(msl_info,keyword,value);
3346 (void) SetMSLAttributes(msl_info,keyword,value);
3353 if (LocaleCompare((const char *) tag,"implode") == 0)
3361 if (msl_info->image[n] == (Image *) NULL)
3363 ThrowMSLException(OptionError,"NoImagesDefined",
3364 (const char *) tag);
3367 if (attributes != (const xmlChar **) NULL)
3368 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3370 keyword=(const char *) attributes[i++];
3371 attribute=InterpretImageProperties(msl_info->image_info[n],
3372 msl_info->attributes[n],(const char *) attributes[i]);
3373 CloneString(&value,attribute);
3379 if (LocaleCompare(keyword,"amount") == 0)
3381 geometry_info.rho=InterpretLocaleValue(value,
3385 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3392 if (LocaleCompare(keyword,"geometry") == 0)
3394 flags=ParseGeometry(value,&geometry_info);
3395 if ((flags & SigmaValue) == 0)
3396 geometry_info.sigma=1.0;
3399 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3405 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3411 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3412 &msl_info->image[n]->exception);
3413 if (implode_image == (Image *) NULL)
3415 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3416 msl_info->image[n]=implode_image;
3419 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3424 if (LocaleCompare((const char *) tag,"label") == 0)
3426 if (LocaleCompare((const char *) tag, "level") == 0)
3429 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3431 if (msl_info->image[n] == (Image *) NULL)
3433 ThrowMSLException(OptionError,"NoImagesDefined",
3434 (const char *) tag);
3437 if (attributes == (const xmlChar **) NULL)
3439 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3441 keyword=(const char *) attributes[i++];
3442 CloneString(&value,(const char *) attributes[i]);
3443 (void) CopyMagickString(key,value,MaxTextExtent);
3449 if (LocaleCompare(keyword,"black") == 0)
3451 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3454 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3460 if (LocaleCompare(keyword,"gamma") == 0)
3462 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3465 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3471 if (LocaleCompare(keyword,"white") == 0)
3473 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3476 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3481 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3488 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma);
3495 if (LocaleCompare((const char *) tag,"magnify") == 0)
3503 if (msl_info->image[n] == (Image *) NULL)
3505 ThrowMSLException(OptionError,"NoImagesDefined",
3506 (const char *) tag);
3509 if (attributes != (const xmlChar **) NULL)
3510 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3512 keyword=(const char *) attributes[i++];
3513 attribute=InterpretImageProperties(msl_info->image_info[n],
3514 msl_info->attributes[n],(const char *) attributes[i]);
3515 CloneString(&value,attribute);
3516 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3518 magnify_image=MagnifyImage(msl_info->image[n],
3519 &msl_info->image[n]->exception);
3520 if (magnify_image == (Image *) NULL)
3522 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3523 msl_info->image[n]=magnify_image;
3526 if (LocaleCompare((const char *) tag,"map") == 0)
3540 if (msl_info->image[n] == (Image *) NULL)
3542 ThrowMSLException(OptionError,"NoImagesDefined",
3543 (const char *) tag);
3546 affinity_image=NewImageList();
3548 if (attributes != (const xmlChar **) NULL)
3549 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3551 keyword=(const char *) attributes[i++];
3552 attribute=InterpretImageProperties(msl_info->image_info[n],
3553 msl_info->attributes[n],(const char *) attributes[i]);
3554 CloneString(&value,attribute);
3560 if (LocaleCompare(keyword,"dither") == 0)
3562 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3565 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3567 dither=(MagickBooleanType) option;
3570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3577 if (LocaleCompare(keyword,"image") == 0)
3578 for (j=0; j < msl_info->n; j++)
3583 attribute=GetImageProperty(msl_info->attributes[j],"id");
3584 if ((attribute != (const char *) NULL) &&
3585 (LocaleCompare(attribute,value) == 0))
3587 affinity_image=CloneImage(msl_info->image[j],0,0,
3588 MagickFalse,&exception);
3596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3602 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3603 quantize_info->dither=dither;
3604 (void) RemapImages(quantize_info,msl_info->image[n],
3606 quantize_info=DestroyQuantizeInfo(quantize_info);
3607 affinity_image=DestroyImage(affinity_image);
3610 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3622 Matte floodfill image.
3625 if (msl_info->image[n] == (Image *) NULL)
3627 ThrowMSLException(OptionError,"NoImagesDefined",
3628 (const char *) tag);
3631 SetGeometry(msl_info->image[n],&geometry);
3632 paint_method=FloodfillMethod;
3633 if (attributes != (const xmlChar **) NULL)
3634 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3636 keyword=(const char *) attributes[i++];
3637 attribute=InterpretImageProperties(msl_info->image_info[n],
3638 msl_info->attributes[n],(const char *) attributes[i]);
3639 CloneString(&value,attribute);
3645 if (LocaleCompare(keyword,"bordercolor") == 0)
3647 (void) QueryMagickColor(value,&target,&exception);
3648 paint_method=FillToBorderMethod;
3651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3658 if (LocaleCompare(keyword,"fuzz") == 0)
3660 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3664 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3671 if (LocaleCompare(keyword,"geometry") == 0)
3673 flags=ParsePageGeometry(msl_info->image[n],value,
3674 &geometry,&exception);
3675 if ((flags & HeightValue) == 0)
3676 geometry.height=geometry.width;
3677 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3678 geometry.x,geometry.y,&target,&exception);
3681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3688 if (LocaleCompare(keyword,"opacity") == 0)
3690 opacity=InterpretLocaleValue(value,(char **) NULL);
3693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3700 if (LocaleCompare(keyword,"x") == 0)
3702 geometry.x=StringToLong(value);
3703 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3704 geometry.x,geometry.y,&target,&exception);
3707 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3714 if (LocaleCompare(keyword,"y") == 0)
3716 geometry.y=StringToLong(value);
3717 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3718 geometry.x,geometry.y,&target,&exception);
3721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3733 draw_info=CloneDrawInfo(msl_info->image_info[n],
3734 msl_info->draw_info[n]);
3735 draw_info->fill.alpha=ClampToQuantum(opacity);
3736 PushPixelChannelMap(msl_info->image[n],AlphaChannel);
3737 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3738 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3739 MagickFalse : MagickTrue);
3740 PopPixelChannelMap(msl_info->image[n]);
3741 draw_info=DestroyDrawInfo(draw_info);
3744 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3750 Median-filter image.
3752 if (msl_info->image[n] == (Image *) NULL)
3754 ThrowMSLException(OptionError,"NoImagesDefined",
3755 (const char *) tag);
3758 if (attributes != (const xmlChar **) NULL)
3759 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3761 keyword=(const char *) attributes[i++];
3762 attribute=InterpretImageProperties(msl_info->image_info[n],
3763 msl_info->attributes[n],(const char *) attributes[i]);
3764 CloneString(&value,attribute);
3770 if (LocaleCompare(keyword,"geometry") == 0)
3772 flags=ParseGeometry(value,&geometry_info);
3773 if ((flags & SigmaValue) == 0)
3774 geometry_info.sigma=1.0;
3777 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3784 if (LocaleCompare(keyword,"radius") == 0)
3786 geometry_info.rho=InterpretLocaleValue(value,
3790 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3802 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3803 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3804 &msl_info->image[n]->exception);
3805 if (median_image == (Image *) NULL)
3807 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3808 msl_info->image[n]=median_image;
3811 if (LocaleCompare((const char *) tag,"minify") == 0)
3819 if (msl_info->image[n] == (Image *) NULL)
3821 ThrowMSLException(OptionError,"NoImagesDefined",
3822 (const char *) tag);
3825 if (attributes != (const xmlChar **) NULL)
3826 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3828 keyword=(const char *) attributes[i++];
3829 attribute=InterpretImageProperties(msl_info->image_info[n],
3830 msl_info->attributes[n],(const char *) attributes[i]);
3831 CloneString(&value,attribute);
3832 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3834 minify_image=MinifyImage(msl_info->image[n],
3835 &msl_info->image[n]->exception);
3836 if (minify_image == (Image *) NULL)
3838 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3839 msl_info->image[n]=minify_image;
3842 if (LocaleCompare((const char *) tag,"msl") == 0 )
3844 if (LocaleCompare((const char *) tag,"modulate") == 0)
3847 modulate[MaxTextExtent];
3852 if (msl_info->image[n] == (Image *) NULL)
3854 ThrowMSLException(OptionError,"NoImagesDefined",
3855 (const char *) tag);
3858 geometry_info.rho=100.0;
3859 geometry_info.sigma=100.0;
3860 geometry_info.xi=100.0;
3861 if (attributes != (const xmlChar **) NULL)
3862 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3864 keyword=(const char *) attributes[i++];
3865 attribute=InterpretImageProperties(msl_info->image_info[n],
3866 msl_info->attributes[n],(const char *) attributes[i]);
3867 CloneString(&value,attribute);
3873 if (LocaleCompare(keyword,"blackness") == 0)
3875 geometry_info.rho=InterpretLocaleValue(value,
3879 if (LocaleCompare(keyword,"brightness") == 0)
3881 geometry_info.rho=InterpretLocaleValue(value,
3885 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3892 if (LocaleCompare(keyword,"factor") == 0)
3894 flags=ParseGeometry(value,&geometry_info);
3897 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3904 if (LocaleCompare(keyword,"hue") == 0)
3906 geometry_info.xi=InterpretLocaleValue(value,
3910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3917 if (LocaleCompare(keyword,"lightness") == 0)
3919 geometry_info.rho=InterpretLocaleValue(value,
3923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3930 if (LocaleCompare(keyword,"saturation") == 0)
3932 geometry_info.sigma=InterpretLocaleValue(value,
3936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3943 if (LocaleCompare(keyword,"whiteness") == 0)
3945 geometry_info.sigma=InterpretLocaleValue(value,
3949 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3955 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3961 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3962 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3963 (void) ModulateImage(msl_info->image[n],modulate);
3966 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3971 if (LocaleCompare((const char *) tag,"negate") == 0)
3979 if (msl_info->image[n] == (Image *) NULL)
3981 ThrowMSLException(OptionError,"NoImagesDefined",
3982 (const char *) tag);
3986 if (attributes != (const xmlChar **) NULL)
3987 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3989 keyword=(const char *) attributes[i++];
3990 attribute=InterpretImageProperties(msl_info->image_info[n],
3991 msl_info->attributes[n],(const char *) attributes[i]);
3992 CloneString(&value,attribute);
3998 if (LocaleCompare(keyword,"channel") == 0)
4000 option=ParseChannelOption(value);
4002 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4004 channel=(ChannelType) option;
4007 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4014 if (LocaleCompare(keyword,"gray") == 0)
4016 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4019 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4021 gray=(MagickBooleanType) option;
4024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4036 PushPixelChannelMap(msl_info->image[n],channel);
4037 (void) NegateImage(msl_info->image[n],gray,
4038 &msl_info->image[n]->exception);
4039 PopPixelChannelMap(msl_info->image[n]);
4042 if (LocaleCompare((const char *) tag,"normalize") == 0)
4047 if (msl_info->image[n] == (Image *) NULL)
4049 ThrowMSLException(OptionError,"NoImagesDefined",
4050 (const char *) tag);
4053 if (attributes != (const xmlChar **) NULL)
4054 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4056 keyword=(const char *) attributes[i++];
4057 attribute=InterpretImageProperties(msl_info->image_info[n],
4058 msl_info->attributes[n],(const char *) attributes[i]);
4059 CloneString(&value,attribute);
4065 if (LocaleCompare(keyword,"channel") == 0)
4067 option=ParseChannelOption(value);
4069 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4071 channel=(ChannelType) option;
4074 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4086 (void) NormalizeImage(msl_info->image[n]);
4089 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4094 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4102 if (msl_info->image[n] == (Image *) NULL)
4104 ThrowMSLException(OptionError,"NoImagesDefined",
4105 (const char *) tag);
4108 if (attributes != (const xmlChar **) NULL)
4109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4111 keyword=(const char *) attributes[i++];
4112 attribute=InterpretImageProperties(msl_info->image_info[n],
4113 msl_info->attributes[n],(const char *) attributes[i]);
4114 CloneString(&value,attribute);
4120 if (LocaleCompare(keyword,"geometry") == 0)
4122 flags=ParseGeometry(value,&geometry_info);
4123 if ((flags & SigmaValue) == 0)
4124 geometry_info.sigma=1.0;
4127 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4134 if (LocaleCompare(keyword,"radius") == 0)
4136 geometry_info.rho=InterpretLocaleValue(value,
4140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4153 &msl_info->image[n]->exception);
4154 if (paint_image == (Image *) NULL)
4156 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4157 msl_info->image[n]=paint_image;
4160 if (LocaleCompare((const char *) tag,"opaque") == 0)
4169 if (msl_info->image[n] == (Image *) NULL)
4171 ThrowMSLException(OptionError,"NoImagesDefined",
4172 (const char *) tag);
4175 (void) QueryMagickColor("none",&target,&exception);
4176 (void) QueryMagickColor("none",&fill_color,&exception);
4177 if (attributes != (const xmlChar **) NULL)
4178 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4180 keyword=(const char *) attributes[i++];
4181 attribute=InterpretImageProperties(msl_info->image_info[n],
4182 msl_info->attributes[n],(const char *) attributes[i]);
4183 CloneString(&value,attribute);
4189 if (LocaleCompare(keyword,"channel") == 0)
4191 option=ParseChannelOption(value);
4193 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4195 channel=(ChannelType) option;
4198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4205 if (LocaleCompare(keyword,"fill") == 0)
4207 (void) QueryMagickColor(value,&fill_color,&exception);
4210 if (LocaleCompare(keyword,"fuzz") == 0)
4212 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4228 PushPixelChannelMap(msl_info->image[n],channel);
4229 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4231 PopPixelChannelMap(msl_info->image[n]);
4234 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4239 if (LocaleCompare((const char *) tag,"print") == 0)
4241 if (attributes == (const xmlChar **) NULL)
4243 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4245 keyword=(const char *) attributes[i++];
4246 attribute=InterpretImageProperties(msl_info->image_info[n],
4247 msl_info->attributes[n],(const char *) attributes[i]);
4248 CloneString(&value,attribute);
4254 if (LocaleCompare(keyword,"output") == 0)
4256 (void) FormatLocaleFile(stdout,"%s",value);
4259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4264 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4271 if (LocaleCompare((const char *) tag, "profile") == 0)
4273 if (msl_info->image[n] == (Image *) NULL)
4275 ThrowMSLException(OptionError,"NoImagesDefined",
4276 (const char *) tag);
4279 if (attributes == (const xmlChar **) NULL)
4281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4295 keyword=(const char *) attributes[i++];
4296 attribute=InterpretImageProperties(msl_info->image_info[n],
4297 msl_info->attributes[n],(const char *) attributes[i]);
4298 CloneString(&value,attribute);
4299 if (*keyword == '+')
4302 Remove a profile from the image.
4304 (void) ProfileImage(msl_info->image[n],keyword,
4305 (const unsigned char *) NULL,0,MagickTrue);
4309 Associate a profile with the image.
4311 profile_info=CloneImageInfo(msl_info->image_info[n]);
4312 profile=GetImageProfile(msl_info->image[n],"iptc");
4313 if (profile != (StringInfo *) NULL)
4314 profile_info->profile=(void *) CloneStringInfo(profile);
4315 profile_image=GetImageCache(profile_info,keyword,&exception);
4316 profile_info=DestroyImageInfo(profile_info);
4317 if (profile_image == (Image *) NULL)
4320 name[MaxTextExtent],
4321 filename[MaxTextExtent];
4329 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4330 (void) CopyMagickString(name,keyword,MaxTextExtent);
4331 for (p=filename; *p != '\0'; p++)
4332 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4333 (IsPathAccessible(keyword) == MagickFalse))
4339 Look for profile name (e.g. name:profile).
4341 (void) CopyMagickString(name,filename,(size_t)
4343 for (q=filename; *q != '\0'; q++)
4347 profile=FileToStringInfo(filename,~0UL,&exception);
4348 if (profile != (StringInfo *) NULL)
4350 (void) ProfileImage(msl_info->image[n],name,
4351 GetStringInfoDatum(profile),(size_t)
4352 GetStringInfoLength(profile),MagickFalse);
4353 profile=DestroyStringInfo(profile);
4357 ResetImageProfileIterator(profile_image);
4358 name=GetNextImageProfile(profile_image);
4359 while (name != (const char *) NULL)
4361 profile=GetImageProfile(profile_image,name);
4362 if (profile != (StringInfo *) NULL)
4363 (void) ProfileImage(msl_info->image[n],name,
4364 GetStringInfoDatum(profile),(size_t)
4365 GetStringInfoLength(profile),MagickFalse);
4366 name=GetNextImageProfile(profile_image);
4368 profile_image=DestroyImage(profile_image);
4372 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4377 if (LocaleCompare((const char *) tag,"quantize") == 0)
4385 if (msl_info->image[n] == (Image *) NULL)
4387 ThrowMSLException(OptionError,"NoImagesDefined",
4388 (const char *) tag);
4391 GetQuantizeInfo(&quantize_info);
4392 if (attributes != (const xmlChar **) NULL)
4393 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4395 keyword=(const char *) attributes[i++];
4396 attribute=InterpretImageProperties(msl_info->image_info[n],
4397 msl_info->attributes[n],(const char *) attributes[i]);
4398 CloneString(&value,attribute);
4404 if (LocaleCompare(keyword,"colors") == 0)
4406 quantize_info.number_colors=StringToLong(value);
4409 if (LocaleCompare(keyword,"colorspace") == 0)
4411 option=ParseCommandOption(MagickColorspaceOptions,
4414 ThrowMSLException(OptionError,
4415 "UnrecognizedColorspaceType",value);
4416 quantize_info.colorspace=(ColorspaceType) option;
4419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4426 if (LocaleCompare(keyword,"dither") == 0)
4428 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4431 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4433 quantize_info.dither=(MagickBooleanType) option;
4436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4443 if (LocaleCompare(keyword,"measure") == 0)
4445 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4448 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4450 quantize_info.measure_error=(MagickBooleanType) option;
4453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4460 if (LocaleCompare(keyword,"treedepth") == 0)
4462 quantize_info.tree_depth=StringToLong(value);
4465 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4471 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4477 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4480 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4483 text[MaxTextExtent];
4494 draw_info=CloneDrawInfo(msl_info->image_info[n],
4495 msl_info->draw_info[n]);
4497 current=draw_info->affine;
4498 GetAffineMatrix(&affine);
4499 if (attributes != (const xmlChar **) NULL)
4500 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4502 keyword=(const char *) attributes[i++];
4503 attribute=InterpretImageProperties(msl_info->image_info[n],
4504 msl_info->attributes[n],(const char *) attributes[i]);
4505 CloneString(&value,attribute);
4511 if (LocaleCompare(keyword,"affine") == 0)
4517 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4520 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4523 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4526 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4529 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4532 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4535 if (LocaleCompare(keyword,"align") == 0)
4537 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4540 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4542 draw_info->align=(AlignType) option;
4545 if (LocaleCompare(keyword,"antialias") == 0)
4547 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4550 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4552 draw_info->stroke_antialias=(MagickBooleanType) option;
4553 draw_info->text_antialias=(MagickBooleanType) option;
4556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4563 if (LocaleCompare(keyword,"density") == 0)
4565 CloneString(&draw_info->density,value);
4568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4575 if (LocaleCompare(keyword,"encoding") == 0)
4577 CloneString(&draw_info->encoding,value);
4580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4587 if (LocaleCompare(keyword, "fill") == 0)
4589 (void) QueryColorDatabase(value,&draw_info->fill,
4593 if (LocaleCompare(keyword,"family") == 0)
4595 CloneString(&draw_info->family,value);
4598 if (LocaleCompare(keyword,"font") == 0)
4600 CloneString(&draw_info->font,value);
4603 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4610 if (LocaleCompare(keyword,"geometry") == 0)
4612 flags=ParsePageGeometry(msl_info->image[n],value,
4613 &geometry,&exception);
4614 if ((flags & HeightValue) == 0)
4615 geometry.height=geometry.width;
4618 if (LocaleCompare(keyword,"gravity") == 0)
4620 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4623 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4625 draw_info->gravity=(GravityType) option;
4628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4635 if (LocaleCompare(keyword,"pointsize") == 0)
4637 draw_info->pointsize=InterpretLocaleValue(value,
4641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4648 if (LocaleCompare(keyword,"rotate") == 0)
4650 angle=InterpretLocaleValue(value,(char **) NULL);
4651 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4652 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4653 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4654 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4664 if (LocaleCompare(keyword,"scale") == 0)
4666 flags=ParseGeometry(value,&geometry_info);
4667 if ((flags & SigmaValue) == 0)
4668 geometry_info.sigma=1.0;
4669 affine.sx=geometry_info.rho;
4670 affine.sy=geometry_info.sigma;
4673 if (LocaleCompare(keyword,"skewX") == 0)
4675 angle=InterpretLocaleValue(value,(char **) NULL);
4676 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4679 if (LocaleCompare(keyword,"skewY") == 0)
4681 angle=InterpretLocaleValue(value,(char **) NULL);
4682 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4685 if (LocaleCompare(keyword,"stretch") == 0)
4687 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4690 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4692 draw_info->stretch=(StretchType) option;
4695 if (LocaleCompare(keyword, "stroke") == 0)
4697 (void) QueryColorDatabase(value,&draw_info->stroke,
4701 if (LocaleCompare(keyword,"strokewidth") == 0)
4703 draw_info->stroke_width=StringToLong(value);
4706 if (LocaleCompare(keyword,"style") == 0)
4708 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4711 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4713 draw_info->style=(StyleType) option;
4716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4723 if (LocaleCompare(keyword,"text") == 0)
4725 CloneString(&draw_info->text,value);
4728 if (LocaleCompare(keyword,"translate") == 0)
4730 flags=ParseGeometry(value,&geometry_info);
4731 if ((flags & SigmaValue) == 0)
4732 geometry_info.sigma=1.0;
4733 affine.tx=geometry_info.rho;
4734 affine.ty=geometry_info.sigma;
4737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4744 if (LocaleCompare(keyword, "undercolor") == 0)
4746 (void) QueryColorDatabase(value,&draw_info->undercolor,
4750 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4757 if (LocaleCompare(keyword,"weight") == 0)
4759 draw_info->weight=StringToLong(value);
4762 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4769 if (LocaleCompare(keyword,"x") == 0)
4771 geometry.x=StringToLong(value);
4774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4781 if (LocaleCompare(keyword,"y") == 0)
4783 geometry.y=StringToLong(value);
4786 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4798 (void) FormatLocaleString(text,MaxTextExtent,
4799 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4800 geometry.height,(double) geometry.x,(double) geometry.y);
4801 CloneString(&draw_info->geometry,text);
4802 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4803 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4804 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4805 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4806 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4808 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4810 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4811 if (status != MagickFalse)
4816 image=msl_info->attributes[n];
4817 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4818 "%g",metrics.pixels_per_em.x);
4819 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4820 "%g",metrics.pixels_per_em.y);
4821 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4823 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4825 FormatImageProperty(image,"msl:font-metrics.width","%g",
4827 FormatImageProperty(image,"msl:font-metrics.height","%g",
4829 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4830 metrics.max_advance);
4831 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4833 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4835 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4837 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4839 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4841 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4844 draw_info=DestroyDrawInfo(draw_info);
4847 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4852 if (LocaleCompare((const char *) tag,"raise") == 0)
4860 if (msl_info->image[n] == (Image *) NULL)
4862 ThrowMSLException(OptionError,"NoImagesDefined",
4863 (const char *) tag);
4867 SetGeometry(msl_info->image[n],&geometry);
4868 if (attributes != (const xmlChar **) NULL)
4869 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4871 keyword=(const char *) attributes[i++];
4872 attribute=InterpretImageProperties(msl_info->image_info[n],
4873 msl_info->attributes[n],(const char *) attributes[i]);
4874 CloneString(&value,attribute);
4880 if (LocaleCompare(keyword,"geometry") == 0)
4882 flags=ParsePageGeometry(msl_info->image[n],value,
4883 &geometry,&exception);
4884 if ((flags & HeightValue) == 0)
4885 geometry.height=geometry.width;
4888 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4895 if (LocaleCompare(keyword,"height") == 0)
4897 geometry.height=StringToLong(value);
4900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4907 if (LocaleCompare(keyword,"raise") == 0)
4909 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4912 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4914 raise=(MagickBooleanType) option;
4917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4924 if (LocaleCompare(keyword,"width") == 0)
4926 geometry.width=StringToLong(value);
4929 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4941 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4944 if (LocaleCompare((const char *) tag,"read") == 0)
4946 if (attributes == (const xmlChar **) NULL)
4948 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4950 keyword=(const char *) attributes[i++];
4951 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4952 msl_info->attributes[n],(const char *) attributes[i]));
4958 if (LocaleCompare(keyword,"filename") == 0)
4963 (void) CopyMagickString(msl_info->image_info[n]->filename,
4964 value,MaxTextExtent);
4965 image=ReadImage(msl_info->image_info[n],&exception);
4966 CatchException(&exception);
4967 if (image == (Image *) NULL)
4969 AppendImageToList(&msl_info->image[n],image);
4972 (void) SetMSLAttributes(msl_info,keyword,value);
4977 (void) SetMSLAttributes(msl_info,keyword,value);
4984 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4992 if (msl_info->image[n] == (Image *) NULL)
4994 ThrowMSLException(OptionError,"NoImagesDefined",
4995 (const char *) tag);
4998 if (attributes != (const xmlChar **) NULL)
4999 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5001 keyword=(const char *) attributes[i++];
5002 attribute=InterpretImageProperties(msl_info->image_info[n],
5003 msl_info->attributes[n],(const char *) attributes[i]);
5004 CloneString(&value,attribute);
5010 if (LocaleCompare(keyword,"geometry") == 0)
5012 flags=ParseGeometry(value,&geometry_info);
5013 if ((flags & SigmaValue) == 0)
5014 geometry_info.sigma=1.0;
5017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5024 if (LocaleCompare(keyword,"radius") == 0)
5026 geometry_info.rho=InterpretLocaleValue(value,
5030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5042 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5043 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5044 &msl_info->image[n]->exception);
5045 if (paint_image == (Image *) NULL)
5047 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5048 msl_info->image[n]=paint_image;
5051 else if (LocaleCompare((const char *) tag,"repage") == 0)
5053 /* init the values */
5054 width=msl_info->image[n]->page.width;
5055 height=msl_info->image[n]->page.height;
5056 x=msl_info->image[n]->page.x;
5057 y=msl_info->image[n]->page.y;
5059 if (msl_info->image[n] == (Image *) NULL)
5061 ThrowMSLException(OptionError,"NoImagesDefined",
5062 (const char *) tag);
5065 if (attributes == (const xmlChar **) NULL)
5067 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5069 keyword=(const char *) attributes[i++];
5070 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5071 msl_info->attributes[n],(const char *) attributes[i]));
5077 if (LocaleCompare(keyword,"geometry") == 0)
5085 flags=ParseAbsoluteGeometry(value,&geometry);
5086 if ((flags & WidthValue) != 0)
5088 if ((flags & HeightValue) == 0)
5089 geometry.height=geometry.width;
5090 width=geometry.width;
5091 height=geometry.height;
5093 if ((flags & AspectValue) != 0)
5095 if ((flags & XValue) != 0)
5097 if ((flags & YValue) != 0)
5102 if ((flags & XValue) != 0)
5105 if ((width == 0) && (geometry.x > 0))
5106 width=msl_info->image[n]->columns+geometry.x;
5108 if ((flags & YValue) != 0)
5111 if ((height == 0) && (geometry.y > 0))
5112 height=msl_info->image[n]->rows+geometry.y;
5117 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5123 if (LocaleCompare(keyword,"height") == 0)
5125 height = StringToLong( value );
5128 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5134 if (LocaleCompare(keyword,"width") == 0)
5136 width = StringToLong( value );
5139 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5145 if (LocaleCompare(keyword,"x") == 0)
5147 x = StringToLong( value );
5150 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5156 if (LocaleCompare(keyword,"y") == 0)
5158 y = StringToLong( value );
5161 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5166 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5172 msl_info->image[n]->page.width=width;
5173 msl_info->image[n]->page.height=height;
5174 msl_info->image[n]->page.x=x;
5175 msl_info->image[n]->page.y=y;
5178 else if (LocaleCompare((const char *) tag,"resample") == 0)
5184 if (msl_info->image[n] == (Image *) NULL)
5186 ThrowMSLException(OptionError,"NoImagesDefined",
5187 (const char *) tag);
5190 if (attributes == (const xmlChar **) NULL)
5192 x_resolution=DefaultResolution;
5193 y_resolution=DefaultResolution;
5194 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5196 keyword=(const char *) attributes[i++];
5197 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5198 msl_info->attributes[n],(const char *) attributes[i]));
5203 if (LocaleCompare(keyword,"blur") == 0)
5205 msl_info->image[n]->blur=InterpretLocaleValue(value,
5209 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5215 if (LocaleCompare(keyword,"geometry") == 0)
5220 flags=ParseGeometry(value,&geometry_info);
5221 if ((flags & SigmaValue) == 0)
5222 geometry_info.sigma*=geometry_info.rho;
5223 x_resolution=geometry_info.rho;
5224 y_resolution=geometry_info.sigma;
5227 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5233 if (LocaleCompare(keyword,"x-resolution") == 0)
5235 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5238 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5244 if (LocaleCompare(keyword,"y-resolution") == 0)
5246 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5249 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5254 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5270 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5272 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5273 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5274 msl_info->image[n]->x_resolution))+0.5);
5275 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5276 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5277 msl_info->image[n]->y_resolution))+0.5);
5278 resample_image=ResizeImage(msl_info->image[n],width,height,
5279 msl_info->image[n]->filter,msl_info->image[n]->blur,
5280 &msl_info->image[n]->exception);
5281 if (resample_image == (Image *) NULL)
5283 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5284 msl_info->image[n]=resample_image;
5288 if (LocaleCompare((const char *) tag,"resize") == 0)
5302 if (msl_info->image[n] == (Image *) NULL)
5304 ThrowMSLException(OptionError,"NoImagesDefined",
5305 (const char *) tag);
5308 filter=UndefinedFilter;
5310 if (attributes != (const xmlChar **) NULL)
5311 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5313 keyword=(const char *) attributes[i++];
5314 attribute=InterpretImageProperties(msl_info->image_info[n],
5315 msl_info->attributes[n],(const char *) attributes[i]);
5316 CloneString(&value,attribute);
5322 if (LocaleCompare(keyword,"filter") == 0)
5324 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5327 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5329 filter=(FilterTypes) option;
5332 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5339 if (LocaleCompare(keyword,"geometry") == 0)
5341 flags=ParseRegionGeometry(msl_info->image[n],value,
5342 &geometry,&exception);
5345 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5352 if (LocaleCompare(keyword,"height") == 0)
5354 geometry.height=StringToUnsignedLong(value);
5357 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5364 if (LocaleCompare(keyword,"support") == 0)
5366 blur=InterpretLocaleValue(value,(char **) NULL);
5369 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5376 if (LocaleCompare(keyword,"width") == 0)
5378 geometry.width=StringToLong(value);
5381 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5387 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5393 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5394 geometry.height,filter,blur,&msl_info->image[n]->exception);
5395 if (resize_image == (Image *) NULL)
5397 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5398 msl_info->image[n]=resize_image;
5401 if (LocaleCompare((const char *) tag,"roll") == 0)
5409 if (msl_info->image[n] == (Image *) NULL)
5411 ThrowMSLException(OptionError,"NoImagesDefined",
5412 (const char *) tag);
5415 SetGeometry(msl_info->image[n],&geometry);
5416 if (attributes != (const xmlChar **) NULL)
5417 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5419 keyword=(const char *) attributes[i++];
5420 attribute=InterpretImageProperties(msl_info->image_info[n],
5421 msl_info->attributes[n],(const char *) attributes[i]);
5422 CloneString(&value,attribute);
5428 if (LocaleCompare(keyword,"geometry") == 0)
5430 flags=ParsePageGeometry(msl_info->image[n],value,
5431 &geometry,&exception);
5432 if ((flags & HeightValue) == 0)
5433 geometry.height=geometry.width;
5436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5443 if (LocaleCompare(keyword,"x") == 0)
5445 geometry.x=StringToLong(value);
5448 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5455 if (LocaleCompare(keyword,"y") == 0)
5457 geometry.y=StringToLong(value);
5460 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5472 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5473 &msl_info->image[n]->exception);
5474 if (roll_image == (Image *) NULL)
5476 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5477 msl_info->image[n]=roll_image;
5480 else if (LocaleCompare((const char *) tag,"roll") == 0)
5482 /* init the values */
5483 width=msl_info->image[n]->columns;
5484 height=msl_info->image[n]->rows;
5487 if (msl_info->image[n] == (Image *) NULL)
5489 ThrowMSLException(OptionError,"NoImagesDefined",
5490 (const char *) tag);
5493 if (attributes == (const xmlChar **) NULL)
5495 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5497 keyword=(const char *) attributes[i++];
5498 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5499 msl_info->attributes[n],(const char *) attributes[i]));
5505 if (LocaleCompare(keyword,"geometry") == 0)
5507 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5510 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5516 if (LocaleCompare(keyword,"x") == 0)
5518 x = StringToLong( value );
5521 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5527 if (LocaleCompare(keyword,"y") == 0)
5529 y = StringToLong( value );
5532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5537 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5550 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5551 if (newImage == (Image *) NULL)
5553 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5554 msl_info->image[n]=newImage;
5559 if (LocaleCompare((const char *) tag,"rotate") == 0)
5567 if (msl_info->image[n] == (Image *) NULL)
5569 ThrowMSLException(OptionError,"NoImagesDefined",
5570 (const char *) tag);
5573 if (attributes != (const xmlChar **) NULL)
5574 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5576 keyword=(const char *) attributes[i++];
5577 attribute=InterpretImageProperties(msl_info->image_info[n],
5578 msl_info->attributes[n],(const char *) attributes[i]);
5579 CloneString(&value,attribute);
5585 if (LocaleCompare(keyword,"degrees") == 0)
5587 geometry_info.rho=InterpretLocaleValue(value,
5591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5598 if (LocaleCompare(keyword,"geometry") == 0)
5600 flags=ParseGeometry(value,&geometry_info);
5601 if ((flags & SigmaValue) == 0)
5602 geometry_info.sigma=1.0;
5605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5611 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5617 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5618 &msl_info->image[n]->exception);
5619 if (rotate_image == (Image *) NULL)
5621 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5622 msl_info->image[n]=rotate_image;
5625 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5627 /* init the values */
5630 if (msl_info->image[n] == (Image *) NULL)
5632 ThrowMSLException(OptionError,"NoImagesDefined",
5633 (const char *) tag);
5636 if (attributes == (const xmlChar **) NULL)
5638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5640 keyword=(const char *) attributes[i++];
5641 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5642 msl_info->attributes[n],(const char *) attributes[i]));
5648 if (LocaleCompare(keyword,"degrees") == 0)
5650 degrees = InterpretLocaleValue(value,(char **) NULL);
5653 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5658 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5671 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5672 if (newImage == (Image *) NULL)
5674 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5675 msl_info->image[n]=newImage;
5680 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5685 if (LocaleCompare((const char *) tag,"sample") == 0)
5693 if (msl_info->image[n] == (Image *) NULL)
5695 ThrowMSLException(OptionError,"NoImagesDefined",
5696 (const char *) tag);
5699 if (attributes != (const xmlChar **) NULL)
5700 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5702 keyword=(const char *) attributes[i++];
5703 attribute=InterpretImageProperties(msl_info->image_info[n],
5704 msl_info->attributes[n],(const char *) attributes[i]);
5705 CloneString(&value,attribute);
5711 if (LocaleCompare(keyword,"geometry") == 0)
5713 flags=ParseRegionGeometry(msl_info->image[n],value,
5714 &geometry,&exception);
5717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5724 if (LocaleCompare(keyword,"height") == 0)
5726 geometry.height=StringToUnsignedLong(value);
5729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5736 if (LocaleCompare(keyword,"width") == 0)
5738 geometry.width=StringToLong(value);
5741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5747 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5753 sample_image=SampleImage(msl_info->image[n],geometry.width,
5754 geometry.height,&msl_info->image[n]->exception);
5755 if (sample_image == (Image *) NULL)
5757 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5758 msl_info->image[n]=sample_image;
5761 if (LocaleCompare((const char *) tag,"scale") == 0)
5769 if (msl_info->image[n] == (Image *) NULL)
5771 ThrowMSLException(OptionError,"NoImagesDefined",
5772 (const char *) tag);
5775 if (attributes != (const xmlChar **) NULL)
5776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5778 keyword=(const char *) attributes[i++];
5779 attribute=InterpretImageProperties(msl_info->image_info[n],
5780 msl_info->attributes[n],(const char *) attributes[i]);
5781 CloneString(&value,attribute);
5787 if (LocaleCompare(keyword,"geometry") == 0)
5789 flags=ParseRegionGeometry(msl_info->image[n],value,
5790 &geometry,&exception);
5793 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5800 if (LocaleCompare(keyword,"height") == 0)
5802 geometry.height=StringToUnsignedLong(value);
5805 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5812 if (LocaleCompare(keyword,"width") == 0)
5814 geometry.width=StringToLong(value);
5817 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5829 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5830 geometry.height,&msl_info->image[n]->exception);
5831 if (scale_image == (Image *) NULL)
5833 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5834 msl_info->image[n]=scale_image;
5837 if (LocaleCompare((const char *) tag,"segment") == 0)
5848 if (msl_info->image[n] == (Image *) NULL)
5850 ThrowMSLException(OptionError,"NoImagesDefined",
5851 (const char *) tag);
5854 geometry_info.rho=1.0;
5855 geometry_info.sigma=1.5;
5856 colorspace=RGBColorspace;
5857 verbose=MagickFalse;
5858 if (attributes != (const xmlChar **) NULL)
5859 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5861 keyword=(const char *) attributes[i++];
5862 attribute=InterpretImageProperties(msl_info->image_info[n],
5863 msl_info->attributes[n],(const char *) attributes[i]);
5864 CloneString(&value,attribute);
5870 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5872 geometry_info.rho=InterpretLocaleValue(value,
5876 if (LocaleCompare(keyword,"colorspace") == 0)
5878 option=ParseCommandOption(MagickColorspaceOptions,
5881 ThrowMSLException(OptionError,
5882 "UnrecognizedColorspaceType",value);
5883 colorspace=(ColorspaceType) option;
5886 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5893 if (LocaleCompare(keyword,"geometry") == 0)
5895 flags=ParseGeometry(value,&geometry_info);
5896 if ((flags & SigmaValue) == 0)
5897 geometry_info.sigma=1.5;
5900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5907 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5909 geometry_info.sigma=InterpretLocaleValue(value,
5913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5925 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5926 geometry_info.rho,geometry_info.sigma);
5929 else if (LocaleCompare((const char *) tag, "set") == 0)
5931 if (msl_info->image[n] == (Image *) NULL)
5933 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5937 if (attributes == (const xmlChar **) NULL)
5939 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5941 keyword=(const char *) attributes[i++];
5942 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5943 msl_info->attributes[n],(const char *) attributes[i]));
5949 if (LocaleCompare(keyword,"clip-mask") == 0)
5951 for (j=0; j < msl_info->n; j++)
5956 property=GetImageProperty(msl_info->attributes[j],"id");
5957 if (LocaleCompare(property,value) == 0)
5959 SetImageMask(msl_info->image[n],msl_info->image[j]);
5965 if (LocaleCompare(keyword,"clip-path") == 0)
5967 for (j=0; j < msl_info->n; j++)
5972 property=GetImageProperty(msl_info->attributes[j],"id");
5973 if (LocaleCompare(property,value) == 0)
5975 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5981 if (LocaleCompare(keyword,"colorspace") == 0)
5986 colorspace=(ColorspaceType) ParseCommandOption(
5987 MagickColorspaceOptions,MagickFalse,value);
5989 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5991 (void) TransformImageColorspace(msl_info->image[n],
5992 (ColorspaceType) colorspace);
5995 (void) SetMSLAttributes(msl_info,keyword,value);
5996 (void) SetImageProperty(msl_info->image[n],keyword,value);
6002 if (LocaleCompare(keyword,"density") == 0)
6004 flags=ParseGeometry(value,&geometry_info);
6005 msl_info->image[n]->x_resolution=geometry_info.rho;
6006 msl_info->image[n]->y_resolution=geometry_info.sigma;
6007 if ((flags & SigmaValue) == 0)
6008 msl_info->image[n]->y_resolution=
6009 msl_info->image[n]->x_resolution;
6012 (void) SetMSLAttributes(msl_info,keyword,value);
6013 (void) SetImageProperty(msl_info->image[n],keyword,value);
6019 if (LocaleCompare(keyword, "opacity") == 0)
6021 ssize_t opac = OpaqueAlpha,
6022 len = (ssize_t) strlen( value );
6024 if (value[len-1] == '%') {
6026 (void) CopyMagickString(tmp,value,len);
6027 opac = StringToLong( tmp );
6028 opac = (int)(QuantumRange * ((float)opac/100));
6030 opac = StringToLong( value );
6031 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6034 (void) SetMSLAttributes(msl_info,keyword,value);
6035 (void) SetImageProperty(msl_info->image[n],keyword,value);
6041 if (LocaleCompare(keyword, "page") == 0)
6044 page[MaxTextExtent];
6055 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6056 image_option=GetImageOption(msl_info->image_info[n],"page");
6057 if (image_option != (const char *) NULL)
6058 flags=ParseAbsoluteGeometry(image_option,&geometry);
6059 flags=ParseAbsoluteGeometry(value,&geometry);
6060 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6061 (double) geometry.width,(double) geometry.height);
6062 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6063 (void) FormatLocaleString(page,MaxTextExtent,
6064 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6065 (double) geometry.height,(double) geometry.x,(double)
6067 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6068 msl_info->image_info[n]->page=GetPageGeometry(page);
6071 (void) SetMSLAttributes(msl_info,keyword,value);
6072 (void) SetImageProperty(msl_info->image[n],keyword,value);
6077 (void) SetMSLAttributes(msl_info,keyword,value);
6078 (void) SetImageProperty(msl_info->image[n],keyword,value);
6085 if (LocaleCompare((const char *) tag,"shade") == 0)
6096 if (msl_info->image[n] == (Image *) NULL)
6098 ThrowMSLException(OptionError,"NoImagesDefined",
6099 (const char *) tag);
6103 if (attributes != (const xmlChar **) NULL)
6104 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6106 keyword=(const char *) attributes[i++];
6107 attribute=InterpretImageProperties(msl_info->image_info[n],
6108 msl_info->attributes[n],(const char *) attributes[i]);
6109 CloneString(&value,attribute);
6115 if (LocaleCompare(keyword,"azimuth") == 0)
6117 geometry_info.rho=InterpretLocaleValue(value,
6121 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6128 if (LocaleCompare(keyword,"elevation") == 0)
6130 geometry_info.sigma=InterpretLocaleValue(value,
6134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(keyword,"geometry") == 0)
6143 flags=ParseGeometry(value,&geometry_info);
6144 if ((flags & SigmaValue) == 0)
6145 geometry_info.sigma=1.0;
6148 if (LocaleCompare(keyword,"gray") == 0)
6150 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6153 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6155 gray=(MagickBooleanType) option;
6158 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6164 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6170 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6171 geometry_info.sigma,&msl_info->image[n]->exception);
6172 if (shade_image == (Image *) NULL)
6174 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6175 msl_info->image[n]=shade_image;
6178 if (LocaleCompare((const char *) tag,"shadow") == 0)
6186 if (msl_info->image[n] == (Image *) NULL)
6188 ThrowMSLException(OptionError,"NoImagesDefined",
6189 (const char *) tag);
6192 if (attributes != (const xmlChar **) NULL)
6193 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6195 keyword=(const char *) attributes[i++];
6196 attribute=InterpretImageProperties(msl_info->image_info[n],
6197 msl_info->attributes[n],(const char *) attributes[i]);
6198 CloneString(&value,attribute);
6204 if (LocaleCompare(keyword,"geometry") == 0)
6206 flags=ParseGeometry(value,&geometry_info);
6207 if ((flags & SigmaValue) == 0)
6208 geometry_info.sigma=1.0;
6211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6218 if (LocaleCompare(keyword,"opacity") == 0)
6220 geometry_info.rho=StringToLong(value);
6223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6230 if (LocaleCompare(keyword,"sigma") == 0)
6232 geometry_info.sigma=StringToLong(value);
6240 if (LocaleCompare(keyword,"x") == 0)
6242 geometry_info.xi=InterpretLocaleValue(value,
6246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6253 if (LocaleCompare(keyword,"y") == 0)
6255 geometry_info.psi=StringToLong(value);
6258 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6264 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6270 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6271 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6272 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6273 if (shadow_image == (Image *) NULL)
6275 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6276 msl_info->image[n]=shadow_image;
6279 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6281 double radius = 0.0,
6284 if (msl_info->image[n] == (Image *) NULL)
6286 ThrowMSLException(OptionError,"NoImagesDefined",
6287 (const char *) tag);
6291 NOTE: sharpen can have no attributes, since we use all the defaults!
6293 if (attributes != (const xmlChar **) NULL)
6295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6297 keyword=(const char *) attributes[i++];
6298 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6299 msl_info->attributes[n],(const char *) attributes[i]));
6305 if (LocaleCompare(keyword, "radius") == 0)
6307 radius = InterpretLocaleValue(value,(char **) NULL);
6310 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6316 if (LocaleCompare(keyword,"sigma") == 0)
6318 sigma = StringToLong( value );
6321 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6340 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6341 if (newImage == (Image *) NULL)
6343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6344 msl_info->image[n]=newImage;
6348 else if (LocaleCompare((const char *) tag,"shave") == 0)
6350 /* init the values */
6354 if (msl_info->image[n] == (Image *) NULL)
6356 ThrowMSLException(OptionError,"NoImagesDefined",
6357 (const char *) tag);
6360 if (attributes == (const xmlChar **) NULL)
6362 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6364 keyword=(const char *) attributes[i++];
6365 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6366 msl_info->attributes[n],(const char *) attributes[i]));
6372 if (LocaleCompare(keyword,"geometry") == 0)
6374 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6377 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6383 if (LocaleCompare(keyword,"height") == 0)
6385 height = StringToLong( value );
6388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6394 if (LocaleCompare(keyword,"width") == 0)
6396 width = StringToLong( value );
6399 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6404 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6419 rectInfo.height = height;
6420 rectInfo.width = width;
6425 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6426 &msl_info->image[n]->exception);
6427 if (newImage == (Image *) NULL)
6429 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6430 msl_info->image[n]=newImage;
6435 if (LocaleCompare((const char *) tag,"shear") == 0)
6443 if (msl_info->image[n] == (Image *) NULL)
6445 ThrowMSLException(OptionError,"NoImagesDefined",
6446 (const char *) tag);
6449 if (attributes != (const xmlChar **) NULL)
6450 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6452 keyword=(const char *) attributes[i++];
6453 attribute=InterpretImageProperties(msl_info->image_info[n],
6454 msl_info->attributes[n],(const char *) attributes[i]);
6455 CloneString(&value,attribute);
6461 if (LocaleCompare(keyword, "fill") == 0)
6463 (void) QueryColorDatabase(value,
6464 &msl_info->image[n]->background_color,&exception);
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6474 if (LocaleCompare(keyword,"geometry") == 0)
6476 flags=ParseGeometry(value,&geometry_info);
6477 if ((flags & SigmaValue) == 0)
6478 geometry_info.sigma=1.0;
6481 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6488 if (LocaleCompare(keyword,"x") == 0)
6490 geometry_info.rho=InterpretLocaleValue(value,
6494 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6501 if (LocaleCompare(keyword,"y") == 0)
6503 geometry_info.sigma=StringToLong(value);
6506 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6512 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6518 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6519 geometry_info.sigma,&msl_info->image[n]->exception);
6520 if (shear_image == (Image *) NULL)
6522 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6523 msl_info->image[n]=shear_image;
6526 if (LocaleCompare((const char *) tag,"signature") == 0)
6531 if (msl_info->image[n] == (Image *) NULL)
6533 ThrowMSLException(OptionError,"NoImagesDefined",
6534 (const char *) tag);
6537 if (attributes != (const xmlChar **) NULL)
6538 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6540 keyword=(const char *) attributes[i++];
6541 attribute=InterpretImageProperties(msl_info->image_info[n],
6542 msl_info->attributes[n],(const char *) attributes[i]);
6543 CloneString(&value,attribute);
6548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6554 (void) SignatureImage(msl_info->image[n]);
6557 if (LocaleCompare((const char *) tag,"solarize") == 0)
6562 if (msl_info->image[n] == (Image *) NULL)
6564 ThrowMSLException(OptionError,"NoImagesDefined",
6565 (const char *) tag);
6568 geometry_info.rho=QuantumRange/2.0;
6569 if (attributes != (const xmlChar **) NULL)
6570 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6572 keyword=(const char *) attributes[i++];
6573 attribute=InterpretImageProperties(msl_info->image_info[n],
6574 msl_info->attributes[n],(const char *) attributes[i]);
6575 CloneString(&value,attribute);
6581 if (LocaleCompare(keyword,"geometry") == 0)
6583 flags=ParseGeometry(value,&geometry_info);
6586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6593 if (LocaleCompare(keyword,"threshold") == 0)
6595 geometry_info.rho=InterpretLocaleValue(value,
6599 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6611 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6614 if (LocaleCompare((const char *) tag,"spread") == 0)
6622 if (msl_info->image[n] == (Image *) NULL)
6624 ThrowMSLException(OptionError,"NoImagesDefined",
6625 (const char *) tag);
6628 if (attributes != (const xmlChar **) NULL)
6629 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6631 keyword=(const char *) attributes[i++];
6632 attribute=InterpretImageProperties(msl_info->image_info[n],
6633 msl_info->attributes[n],(const char *) attributes[i]);
6634 CloneString(&value,attribute);
6640 if (LocaleCompare(keyword,"geometry") == 0)
6642 flags=ParseGeometry(value,&geometry_info);
6643 if ((flags & SigmaValue) == 0)
6644 geometry_info.sigma=1.0;
6647 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6654 if (LocaleCompare(keyword,"radius") == 0)
6656 geometry_info.rho=InterpretLocaleValue(value,
6660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6672 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6673 &msl_info->image[n]->exception);
6674 if (spread_image == (Image *) NULL)
6676 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6677 msl_info->image[n]=spread_image;
6680 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6683 watermark = (Image*)NULL;
6685 if (msl_info->image[n] == (Image *) NULL)
6687 ThrowMSLException(OptionError,"NoImagesDefined",
6688 (const char *) tag);
6691 if (attributes == (const xmlChar **) NULL)
6693 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6695 keyword=(const char *) attributes[i++];
6696 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6697 msl_info->attributes[n],(const char *) attributes[i]));
6703 if (LocaleCompare(keyword,"image") == 0)
6705 for (j=0; j<msl_info->n;j++)
6708 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6709 if (theAttr && LocaleCompare(theAttr, value) == 0)
6711 watermark = msl_info->image[j];
6717 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6722 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6731 if ( watermark != (Image*) NULL )
6736 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6737 if (newImage == (Image *) NULL)
6739 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6740 msl_info->image[n]=newImage;
6743 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6745 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6748 stereoImage = (Image*)NULL;
6750 if (msl_info->image[n] == (Image *) NULL)
6752 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6755 if (attributes == (const xmlChar **) NULL)
6757 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6759 keyword=(const char *) attributes[i++];
6760 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6761 msl_info->attributes[n],(const char *) attributes[i]));
6767 if (LocaleCompare(keyword,"image") == 0)
6769 for (j=0; j<msl_info->n;j++)
6772 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6773 if (theAttr && LocaleCompare(theAttr, value) == 0)
6775 stereoImage = msl_info->image[j];
6781 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6786 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6795 if ( stereoImage != (Image*) NULL )
6800 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6801 if (newImage == (Image *) NULL)
6803 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6804 msl_info->image[n]=newImage;
6807 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6809 if (LocaleCompare((const char *) tag,"swap") == 0)
6820 if (msl_info->image[n] == (Image *) NULL)
6822 ThrowMSLException(OptionError,"NoImagesDefined",
6823 (const char *) tag);
6828 if (attributes != (const xmlChar **) NULL)
6829 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6831 keyword=(const char *) attributes[i++];
6832 attribute=InterpretImageProperties(msl_info->image_info[n],
6833 msl_info->attributes[n],(const char *) attributes[i]);
6834 CloneString(&value,attribute);
6840 if (LocaleCompare(keyword,"indexes") == 0)
6842 flags=ParseGeometry(value,&geometry_info);
6843 index=(ssize_t) geometry_info.rho;
6844 if ((flags & SigmaValue) == 0)
6845 swap_index=(ssize_t) geometry_info.sigma;
6848 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6863 p=GetImageFromList(msl_info->image[n],index);
6864 q=GetImageFromList(msl_info->image[n],swap_index);
6865 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6867 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6870 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6871 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6872 ReplaceImageInList(&q,swap);
6873 msl_info->image[n]=GetFirstImageInList(q);
6876 if (LocaleCompare((const char *) tag,"swirl") == 0)
6884 if (msl_info->image[n] == (Image *) NULL)
6886 ThrowMSLException(OptionError,"NoImagesDefined",
6887 (const char *) tag);
6890 if (attributes != (const xmlChar **) NULL)
6891 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6893 keyword=(const char *) attributes[i++];
6894 attribute=InterpretImageProperties(msl_info->image_info[n],
6895 msl_info->attributes[n],(const char *) attributes[i]);
6896 CloneString(&value,attribute);
6902 if (LocaleCompare(keyword,"degrees") == 0)
6904 geometry_info.rho=InterpretLocaleValue(value,
6908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6915 if (LocaleCompare(keyword,"geometry") == 0)
6917 flags=ParseGeometry(value,&geometry_info);
6918 if ((flags & SigmaValue) == 0)
6919 geometry_info.sigma=1.0;
6922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6934 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6935 &msl_info->image[n]->exception);
6936 if (swirl_image == (Image *) NULL)
6938 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6939 msl_info->image[n]=swirl_image;
6942 if (LocaleCompare((const char *) tag,"sync") == 0)
6947 if (msl_info->image[n] == (Image *) NULL)
6949 ThrowMSLException(OptionError,"NoImagesDefined",
6950 (const char *) tag);
6953 if (attributes != (const xmlChar **) NULL)
6954 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6956 keyword=(const char *) attributes[i++];
6957 attribute=InterpretImageProperties(msl_info->image_info[n],
6958 msl_info->attributes[n],(const char *) attributes[i]);
6959 CloneString(&value,attribute);
6964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6970 (void) SyncImage(msl_info->image[n]);
6973 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6978 if (LocaleCompare((const char *) tag,"map") == 0)
6986 if (msl_info->image[n] == (Image *) NULL)
6988 ThrowMSLException(OptionError,"NoImagesDefined",
6989 (const char *) tag);
6992 texture_image=NewImageList();
6993 if (attributes != (const xmlChar **) NULL)
6994 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6996 keyword=(const char *) attributes[i++];
6997 attribute=InterpretImageProperties(msl_info->image_info[n],
6998 msl_info->attributes[n],(const char *) attributes[i]);
6999 CloneString(&value,attribute);
7005 if (LocaleCompare(keyword,"image") == 0)
7006 for (j=0; j < msl_info->n; j++)
7011 attribute=GetImageProperty(msl_info->attributes[j],"id");
7012 if ((attribute != (const char *) NULL) &&
7013 (LocaleCompare(attribute,value) == 0))
7015 texture_image=CloneImage(msl_info->image[j],0,0,
7016 MagickFalse,&exception);
7024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7030 (void) TextureImage(msl_info->image[n],texture_image);
7031 texture_image=DestroyImage(texture_image);
7034 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7036 /* init the values */
7037 double threshold = 0;
7039 if (msl_info->image[n] == (Image *) NULL)
7041 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7044 if (attributes == (const xmlChar **) NULL)
7046 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7048 keyword=(const char *) attributes[i++];
7049 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7050 msl_info->attributes[n],(const char *) attributes[i]));
7056 if (LocaleCompare(keyword,"threshold") == 0)
7058 threshold = InterpretLocaleValue(value,(char **) NULL);
7061 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7066 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7076 BilevelImage(msl_info->image[n],threshold);
7080 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7082 if (msl_info->image[n] == (Image *) NULL)
7084 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7087 if (attributes == (const xmlChar **) NULL)
7089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7091 keyword=(const char *) attributes[i++];
7092 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7093 msl_info->attributes[n],(const char *) attributes[i]));
7099 if (LocaleCompare(keyword,"color") == 0)
7104 (void) QueryMagickColor(value,&target,&exception);
7105 (void) TransparentPaintImage(msl_info->image[n],&target,
7106 TransparentAlpha,MagickFalse);
7109 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7114 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7121 else if (LocaleCompare((const char *) tag, "trim") == 0)
7123 if (msl_info->image[n] == (Image *) NULL)
7125 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7129 /* no attributes here */
7131 /* process the image */
7138 /* all zeros on a crop == trim edges! */
7139 rectInfo.height = rectInfo.width = 0;
7140 rectInfo.x = rectInfo.y = 0;
7142 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7143 if (newImage == (Image *) NULL)
7145 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7146 msl_info->image[n]=newImage;
7150 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7155 if (LocaleCompare((const char *) tag,"write") == 0)
7157 if (msl_info->image[n] == (Image *) NULL)
7159 ThrowMSLException(OptionError,"NoImagesDefined",
7160 (const char *) tag);
7163 if (attributes == (const xmlChar **) NULL)
7165 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7167 keyword=(const char *) attributes[i++];
7168 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7169 msl_info->attributes[n],(const char *) attributes[i]));
7175 if (LocaleCompare(keyword,"filename") == 0)
7177 (void) CopyMagickString(msl_info->image[n]->filename,value,
7181 (void) SetMSLAttributes(msl_info,keyword,value);
7185 (void) SetMSLAttributes(msl_info,keyword,value);
7193 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7197 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7201 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7205 if ( value != NULL )
7206 value=DestroyString(value);
7207 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7210 static void MSLEndElement(void *context,const xmlChar *tag)
7219 Called when the end of an element has been detected.
7221 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7223 msl_info=(MSLInfo *) context;
7230 if (LocaleCompare((const char *) tag,"comment") == 0 )
7232 (void) DeleteImageProperty(msl_info->image[n],"comment");
7233 if (msl_info->content == (char *) NULL)
7235 StripString(msl_info->content);
7236 (void) SetImageProperty(msl_info->image[n],"comment",
7245 if (LocaleCompare((const char *) tag, "group") == 0 )
7247 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7249 ssize_t i = (ssize_t)
7250 (msl_info->group_info[msl_info->number_groups-1].numImages);
7253 if (msl_info->image[msl_info->n] != (Image *) NULL)
7254 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7255 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7256 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7260 msl_info->number_groups--;
7267 if (LocaleCompare((const char *) tag, "image") == 0)
7268 MSLPopImage(msl_info);
7274 if (LocaleCompare((const char *) tag,"label") == 0 )
7276 (void) DeleteImageProperty(msl_info->image[n],"label");
7277 if (msl_info->content == (char *) NULL)
7279 StripString(msl_info->content);
7280 (void) SetImageProperty(msl_info->image[n],"label",
7289 if (LocaleCompare((const char *) tag, "msl") == 0 )
7292 This our base element.
7293 at the moment we don't do anything special
7294 but someday we might!
7302 if (msl_info->content != (char *) NULL)
7303 msl_info->content=DestroyString(msl_info->content);
7306 static void MSLCharacters(void *context,const xmlChar *c,int length)
7318 Receiving some characters from the parser.
7320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7321 " SAX.characters(%s,%d)",c,length);
7322 msl_info=(MSLInfo *) context;
7323 if (msl_info->content != (char *) NULL)
7324 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7325 strlen(msl_info->content)+length+MaxTextExtent,
7326 sizeof(*msl_info->content));
7329 msl_info->content=(char *) NULL;
7330 if (~length >= (MaxTextExtent-1))
7331 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7332 sizeof(*msl_info->content));
7333 if (msl_info->content != (char *) NULL)
7334 *msl_info->content='\0';
7336 if (msl_info->content == (char *) NULL)
7338 p=msl_info->content+strlen(msl_info->content);
7339 for (i=0; i < length; i++)
7344 static void MSLReference(void *context,const xmlChar *name)
7353 Called when an entity reference is detected.
7355 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7356 " SAX.reference(%s)",name);
7357 msl_info=(MSLInfo *) context;
7358 parser=msl_info->parser;
7360 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7362 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7365 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7371 Receiving some ignorable whitespaces from the parser.
7373 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7374 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7375 msl_info=(MSLInfo *) context;
7379 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7380 const xmlChar *data)
7386 A processing instruction has been parsed.
7388 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7389 " SAX.processingInstruction(%s, %s)",
7391 msl_info=(MSLInfo *) context;
7395 static void MSLComment(void *context,const xmlChar *value)
7401 A comment has been parsed.
7403 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7404 " SAX.comment(%s)",value);
7405 msl_info=(MSLInfo *) context;
7409 static void MSLWarning(void *context,const char *format,...)
7413 reason[MaxTextExtent];
7422 Display and format a warning messages, gives file, line, position and
7425 va_start(operands,format);
7426 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7427 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7428 msl_info=(MSLInfo *) context;
7430 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7431 (void) vsprintf(reason,format,operands);
7433 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7435 message=GetExceptionMessage(errno);
7436 ThrowMSLException(CoderError,reason,message);
7437 message=DestroyString(message);
7441 static void MSLError(void *context,const char *format,...)
7444 reason[MaxTextExtent];
7453 Display and format a error formats, gives file, line, position and
7456 va_start(operands,format);
7457 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7458 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7459 msl_info=(MSLInfo *) context;
7461 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7462 (void) vsprintf(reason,format,operands);
7464 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7466 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7470 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7482 Called when a pcdata block has been parsed.
7484 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7485 " SAX.pcdata(%s, %d)",value,length);
7486 msl_info=(MSLInfo *) context;
7488 parser=msl_info->parser;
7489 child=xmlGetLastChild(parser->node);
7490 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7492 xmlTextConcat(child,value,length);
7495 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7498 static void MSLExternalSubset(void *context,const xmlChar *name,
7499 const xmlChar *external_id,const xmlChar *system_id)
7514 Does this document has an external subset?
7516 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7517 " SAX.externalSubset(%s %s %s)",name,
7518 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7519 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7520 msl_info=(MSLInfo *) context;
7522 parser=msl_info->parser;
7523 if (((external_id == NULL) && (system_id == NULL)) ||
7524 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7525 (msl_info->document == 0)))
7527 input=MSLResolveEntity(context,external_id,system_id);
7530 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7531 parser_context=(*parser);
7532 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7533 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7535 parser->errNo=XML_ERR_NO_MEMORY;
7536 parser->input=parser_context.input;
7537 parser->inputNr=parser_context.inputNr;
7538 parser->inputMax=parser_context.inputMax;
7539 parser->inputTab=parser_context.inputTab;
7545 xmlPushInput(parser,input);
7546 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7547 if (input->filename == (char *) NULL)
7548 input->filename=(char *) xmlStrdup(system_id);
7551 input->base=parser->input->cur;
7552 input->cur=parser->input->cur;
7554 xmlParseExternalSubset(parser,external_id,system_id);
7555 while (parser->inputNr > 1)
7556 (void) xmlPopInput(parser);
7557 xmlFreeInputStream(parser->input);
7558 xmlFree(parser->inputTab);
7559 parser->input=parser_context.input;
7560 parser->inputNr=parser_context.inputNr;
7561 parser->inputMax=parser_context.inputMax;
7562 parser->inputTab=parser_context.inputTab;
7565 #if defined(__cplusplus) || defined(c_plusplus)
7569 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7570 ExceptionInfo *exception)
7573 message[MaxTextExtent];
7596 assert(image_info != (const ImageInfo *) NULL);
7597 assert(image_info->signature == MagickSignature);
7598 if (image_info->debug != MagickFalse)
7599 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7600 image_info->filename);
7601 assert(image != (Image **) NULL);
7602 msl_image=AcquireImage(image_info);
7603 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7604 if (status == MagickFalse)
7606 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7607 msl_image->filename);
7608 msl_image=DestroyImageList(msl_image);
7609 return(MagickFalse);
7611 msl_image->columns=1;
7616 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7617 msl_info.exception=exception;
7618 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7619 sizeof(*msl_info.image_info));
7620 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7621 sizeof(*msl_info.draw_info));
7622 /* top of the stack is the MSL file itself */
7623 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7624 msl_info.attributes=(Image **) AcquireMagickMemory(
7625 sizeof(*msl_info.attributes));
7626 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7627 sizeof(*msl_info.group_info));
7628 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7629 (msl_info.image == (Image **) NULL) ||
7630 (msl_info.attributes == (Image **) NULL) ||
7631 (msl_info.group_info == (MSLGroupInfo *) NULL))
7632 ThrowFatalException(ResourceLimitFatalError,
7633 "UnableToInterpretMSLImage");
7634 *msl_info.image_info=CloneImageInfo(image_info);
7635 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7636 *msl_info.attributes=AcquireImage(image_info);
7637 msl_info.group_info[0].numImages=0;
7638 /* the first slot is used to point to the MSL file image */
7639 *msl_info.image=msl_image;
7640 if (*image != (Image *) NULL)
7641 MSLPushImage(&msl_info,*image);
7642 (void) xmlSubstituteEntitiesDefault(1);
7643 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7644 sax_modules.internalSubset=MSLInternalSubset;
7645 sax_modules.isStandalone=MSLIsStandalone;
7646 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7647 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7648 sax_modules.resolveEntity=MSLResolveEntity;
7649 sax_modules.getEntity=MSLGetEntity;
7650 sax_modules.entityDecl=MSLEntityDeclaration;
7651 sax_modules.notationDecl=MSLNotationDeclaration;
7652 sax_modules.attributeDecl=MSLAttributeDeclaration;
7653 sax_modules.elementDecl=MSLElementDeclaration;
7654 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7655 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7656 sax_modules.startDocument=MSLStartDocument;
7657 sax_modules.endDocument=MSLEndDocument;
7658 sax_modules.startElement=MSLStartElement;
7659 sax_modules.endElement=MSLEndElement;
7660 sax_modules.reference=MSLReference;
7661 sax_modules.characters=MSLCharacters;
7662 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7663 sax_modules.processingInstruction=MSLProcessingInstructions;
7664 sax_modules.comment=MSLComment;
7665 sax_modules.warning=MSLWarning;
7666 sax_modules.error=MSLError;
7667 sax_modules.fatalError=MSLError;
7668 sax_modules.getParameterEntity=MSLGetParameterEntity;
7669 sax_modules.cdataBlock=MSLCDataBlock;
7670 sax_modules.externalSubset=MSLExternalSubset;
7671 sax_handler=(&sax_modules);
7672 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7673 msl_image->filename);
7674 while (ReadBlobString(msl_image,message) != (char *) NULL)
7676 n=(ssize_t) strlen(message);
7679 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7682 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7683 if (msl_info.exception->severity >= ErrorException)
7686 if (msl_info.exception->severity == UndefinedException)
7687 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7688 xmlFreeParserCtxt(msl_info.parser);
7689 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7691 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7692 msl_info.group_info);
7693 if (*image == (Image *) NULL)
7694 *image=(*msl_info.image);
7695 if ((*msl_info.image)->exception.severity != UndefinedException)
7696 return(MagickFalse);
7700 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7708 assert(image_info != (const ImageInfo *) NULL);
7709 assert(image_info->signature == MagickSignature);
7710 if (image_info->debug != MagickFalse)
7711 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7712 image_info->filename);
7713 assert(exception != (ExceptionInfo *) NULL);
7714 assert(exception->signature == MagickSignature);
7715 image=(Image *) NULL;
7716 (void) ProcessMSLScript(image_info,&image,exception);
7717 return(GetFirstImageInList(image));
7722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7726 % R e g i s t e r M S L I m a g e %
7730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7732 % RegisterMSLImage() adds attributes for the MSL image format to
7733 % the list of supported formats. The attributes include the image format
7734 % tag, a method to read and/or write the format, whether the format
7735 % supports the saving of more than one frame to the same file or blob,
7736 % whether the format supports native in-memory I/O, and a brief
7737 % description of the format.
7739 % The format of the RegisterMSLImage method is:
7741 % size_t RegisterMSLImage(void)
7744 ModuleExport size_t RegisterMSLImage(void)
7749 entry=SetMagickInfo("MSL");
7750 #if defined(MAGICKCORE_XML_DELEGATE)
7751 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7752 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7754 entry->description=ConstantString("Magick Scripting Language");
7755 entry->module=ConstantString("MSL");
7756 (void) RegisterMagickInfo(entry);
7757 return(MagickImageCoderSignature);
7760 #if defined(MAGICKCORE_XML_DELEGATE)
7762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7766 % S e t M S L A t t r i b u t e s %
7770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7772 % SetMSLAttributes() ...
7774 % The format of the SetMSLAttributes method is:
7776 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7777 % const char *keyword,const char *value)
7779 % A description of each parameter follows:
7781 % o msl_info: the MSL info.
7783 % o keyword: the keyword.
7785 % o value: the value.
7788 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7815 assert(msl_info != (MSLInfo *) NULL);
7816 if (keyword == (const char *) NULL)
7818 if (value == (const char *) NULL)
7820 exception=msl_info->exception;
7822 attributes=msl_info->attributes[n];
7823 image_info=msl_info->image_info[n];
7824 draw_info=msl_info->draw_info[n];
7825 image=msl_info->image[n];
7831 if (LocaleCompare(keyword,"adjoin") == 0)
7836 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7838 ThrowMSLException(OptionError,"UnrecognizedType",value);
7839 image_info->adjoin=(MagickBooleanType) adjoin;
7842 if (LocaleCompare(keyword,"alpha") == 0)
7847 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7849 ThrowMSLException(OptionError,"UnrecognizedType",value);
7850 if (image != (Image *) NULL)
7851 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7855 if (LocaleCompare(keyword,"antialias") == 0)
7860 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7862 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7863 image_info->antialias=(MagickBooleanType) antialias;
7866 if (LocaleCompare(keyword,"area-limit") == 0)
7871 limit=MagickResourceInfinity;
7872 if (LocaleCompare(value,"unlimited") != 0)
7873 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7874 (void) SetMagickResourceLimit(AreaResource,limit);
7877 if (LocaleCompare(keyword,"attenuate") == 0)
7879 (void) SetImageOption(image_info,keyword,value);
7882 if (LocaleCompare(keyword,"authenticate") == 0)
7884 (void) CloneString(&image_info->density,value);
7887 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7893 if (LocaleCompare(keyword,"background") == 0)
7895 (void) QueryColorDatabase(value,&image_info->background_color,
7899 if (LocaleCompare(keyword,"bias") == 0)
7901 if (image == (Image *) NULL)
7903 image->bias=SiPrefixToDouble(value,QuantumRange);
7906 if (LocaleCompare(keyword,"blue-primary") == 0)
7908 if (image == (Image *) NULL)
7910 flags=ParseGeometry(value,&geometry_info);
7911 image->chromaticity.blue_primary.x=geometry_info.rho;
7912 image->chromaticity.blue_primary.y=geometry_info.sigma;
7913 if ((flags & SigmaValue) == 0)
7914 image->chromaticity.blue_primary.y=
7915 image->chromaticity.blue_primary.x;
7918 if (LocaleCompare(keyword,"bordercolor") == 0)
7920 (void) QueryColorDatabase(value,&image_info->border_color,
7924 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7930 if (LocaleCompare(keyword,"density") == 0)
7932 (void) CloneString(&image_info->density,value);
7933 (void) CloneString(&draw_info->density,value);
7936 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7942 if (LocaleCompare(keyword,"fill") == 0)
7944 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7945 (void) SetImageOption(image_info,keyword,value);
7948 if (LocaleCompare(keyword,"filename") == 0)
7950 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7953 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7959 if (LocaleCompare(keyword,"gravity") == 0)
7964 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7966 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7967 (void) SetImageOption(image_info,keyword,value);
7970 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7976 if (LocaleCompare(keyword,"id") == 0)
7978 (void) SetImageProperty(attributes,keyword,value);
7981 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7987 if (LocaleCompare(keyword,"magick") == 0)
7989 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7992 if (LocaleCompare(keyword,"mattecolor") == 0)
7994 (void) QueryColorDatabase(value,&image_info->matte_color,
7998 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8004 if (LocaleCompare(keyword,"pointsize") == 0)
8006 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8007 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8010 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8016 if (LocaleCompare(keyword,"quality") == 0)
8018 image_info->quality=StringToLong(value);
8019 if (image == (Image *) NULL)
8021 image->quality=StringToLong(value);
8029 if (LocaleCompare(keyword,"size") == 0)
8031 (void) CloneString(&image_info->size,value);
8034 if (LocaleCompare(keyword,"stroke") == 0)
8036 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8037 (void) SetImageOption(image_info,keyword,value);
8040 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8045 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8058 % U n r e g i s t e r M S L I m a g e %
8062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8064 % UnregisterMSLImage() removes format registrations made by the
8065 % MSL module from the list of supported formats.
8067 % The format of the UnregisterMSLImage method is:
8069 % UnregisterMSLImage(void)
8072 ModuleExport void UnregisterMSLImage(void)
8074 (void) UnregisterMagickInfo("MSL");
8077 #if defined(MAGICKCORE_XML_DELEGATE)
8079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8083 % W r i t e M S L I m a g e %
8087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8089 % WriteMSLImage() writes an image to a file in MVG image format.
8091 % The format of the WriteMSLImage method is:
8093 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8095 % A description of each parameter follows.
8097 % o image_info: the image info.
8099 % o image: The image.
8102 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8104 assert(image_info != (const ImageInfo *) NULL);
8105 assert(image_info->signature == MagickSignature);
8106 assert(image != (Image *) NULL);
8107 assert(image->signature == MagickSignature);
8108 if (image->debug != MagickFalse)
8109 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8110 (void) ReferenceImage(image);
8111 (void) ProcessMSLScript(image_info,&image,&image->exception);