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,
2124 &msl_info->image[n]->exception);
2127 if (LocaleCompare((const char *) tag,"crop") == 0)
2135 if (msl_info->image[n] == (Image *) NULL)
2137 ThrowMSLException(OptionError,"NoImagesDefined",
2138 (const char *) tag);
2141 SetGeometry(msl_info->image[n],&geometry);
2142 if (attributes != (const xmlChar **) NULL)
2143 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2145 keyword=(const char *) attributes[i++];
2146 attribute=InterpretImageProperties(msl_info->image_info[n],
2147 msl_info->attributes[n],(const char *) attributes[i]);
2148 CloneString(&value,attribute);
2154 if (LocaleCompare(keyword,"geometry") == 0)
2156 flags=ParseGravityGeometry(msl_info->image[n],value,
2157 &geometry,&exception);
2160 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2167 if (LocaleCompare(keyword,"height") == 0)
2169 geometry.height=StringToLong(value);
2172 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2179 if (LocaleCompare(keyword,"width") == 0)
2181 geometry.width=StringToLong(value);
2184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2191 if (LocaleCompare(keyword,"x") == 0)
2193 geometry.x=StringToLong(value);
2196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 if (LocaleCompare(keyword,"y") == 0)
2205 geometry.y=StringToLong(value);
2208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2220 crop_image=CropImage(msl_info->image[n],&geometry,
2221 &msl_info->image[n]->exception);
2222 if (crop_image == (Image *) NULL)
2224 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2225 msl_info->image[n]=crop_image;
2228 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2234 Cycle-colormap image.
2236 if (msl_info->image[n] == (Image *) NULL)
2238 ThrowMSLException(OptionError,"NoImagesDefined",
2239 (const char *) tag);
2243 if (attributes != (const xmlChar **) NULL)
2244 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2246 keyword=(const char *) attributes[i++];
2247 attribute=InterpretImageProperties(msl_info->image_info[n],
2248 msl_info->attributes[n],(const char *) attributes[i]);
2249 CloneString(&value,attribute);
2255 if (LocaleCompare(keyword,"display") == 0)
2257 display=StringToLong(value);
2260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2272 (void) CycleColormapImage(msl_info->image[n],display);
2275 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2280 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2288 if (msl_info->image[n] == (Image *) NULL)
2290 ThrowMSLException(OptionError,"NoImagesDefined",
2291 (const char *) tag);
2294 if (attributes != (const xmlChar **) NULL)
2295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2297 keyword=(const char *) attributes[i++];
2298 attribute=InterpretImageProperties(msl_info->image_info[n],
2299 msl_info->attributes[n],(const char *) attributes[i]);
2300 CloneString(&value,attribute);
2301 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2303 despeckle_image=DespeckleImage(msl_info->image[n],
2304 &msl_info->image[n]->exception);
2305 if (despeckle_image == (Image *) NULL)
2307 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2308 msl_info->image[n]=despeckle_image;
2311 if (LocaleCompare((const char *) tag,"display") == 0)
2313 if (msl_info->image[n] == (Image *) NULL)
2315 ThrowMSLException(OptionError,"NoImagesDefined",
2316 (const char *) tag);
2319 if (attributes != (const xmlChar **) NULL)
2320 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2322 keyword=(const char *) attributes[i++];
2323 attribute=InterpretImageProperties(msl_info->image_info[n],
2324 msl_info->attributes[n],(const char *) attributes[i]);
2325 CloneString(&value,attribute);
2330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2336 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2339 if (LocaleCompare((const char *) tag,"draw") == 0)
2342 text[MaxTextExtent];
2347 if (msl_info->image[n] == (Image *) NULL)
2349 ThrowMSLException(OptionError,"NoImagesDefined",
2350 (const char *) tag);
2353 draw_info=CloneDrawInfo(msl_info->image_info[n],
2354 msl_info->draw_info[n]);
2356 current=draw_info->affine;
2357 GetAffineMatrix(&affine);
2358 if (attributes != (const xmlChar **) NULL)
2359 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2361 keyword=(const char *) attributes[i++];
2362 attribute=InterpretImageProperties(msl_info->image_info[n],
2363 msl_info->attributes[n],(const char *) attributes[i]);
2364 CloneString(&value,attribute);
2370 if (LocaleCompare(keyword,"affine") == 0)
2376 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2379 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2382 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2385 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2388 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2391 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2394 if (LocaleCompare(keyword,"align") == 0)
2396 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2399 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2401 draw_info->align=(AlignType) option;
2404 if (LocaleCompare(keyword,"antialias") == 0)
2406 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2409 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2411 draw_info->stroke_antialias=(MagickBooleanType) option;
2412 draw_info->text_antialias=(MagickBooleanType) option;
2415 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2422 if (LocaleCompare(keyword,"density") == 0)
2424 CloneString(&draw_info->density,value);
2427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2434 if (LocaleCompare(keyword,"encoding") == 0)
2436 CloneString(&draw_info->encoding,value);
2439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2446 if (LocaleCompare(keyword, "fill") == 0)
2448 (void) QueryColorDatabase(value,&draw_info->fill,
2452 if (LocaleCompare(keyword,"family") == 0)
2454 CloneString(&draw_info->family,value);
2457 if (LocaleCompare(keyword,"font") == 0)
2459 CloneString(&draw_info->font,value);
2462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2469 if (LocaleCompare(keyword,"geometry") == 0)
2471 flags=ParsePageGeometry(msl_info->image[n],value,
2472 &geometry,&exception);
2473 if ((flags & HeightValue) == 0)
2474 geometry.height=geometry.width;
2477 if (LocaleCompare(keyword,"gravity") == 0)
2479 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2482 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2484 draw_info->gravity=(GravityType) option;
2487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2494 if (LocaleCompare(keyword,"primitive") == 0)
2496 CloneString(&draw_info->primitive,value);
2499 if (LocaleCompare(keyword,"pointsize") == 0)
2501 draw_info->pointsize=InterpretLocaleValue(value,
2505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2512 if (LocaleCompare(keyword,"rotate") == 0)
2514 angle=InterpretLocaleValue(value,(char **) NULL);
2515 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2516 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2517 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2518 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2521 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2528 if (LocaleCompare(keyword,"scale") == 0)
2530 flags=ParseGeometry(value,&geometry_info);
2531 if ((flags & SigmaValue) == 0)
2532 geometry_info.sigma=1.0;
2533 affine.sx=geometry_info.rho;
2534 affine.sy=geometry_info.sigma;
2537 if (LocaleCompare(keyword,"skewX") == 0)
2539 angle=InterpretLocaleValue(value,(char **) NULL);
2540 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2543 if (LocaleCompare(keyword,"skewY") == 0)
2545 angle=InterpretLocaleValue(value,(char **) NULL);
2546 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2549 if (LocaleCompare(keyword,"stretch") == 0)
2551 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2554 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2556 draw_info->stretch=(StretchType) option;
2559 if (LocaleCompare(keyword, "stroke") == 0)
2561 (void) QueryColorDatabase(value,&draw_info->stroke,
2565 if (LocaleCompare(keyword,"strokewidth") == 0)
2567 draw_info->stroke_width=StringToLong(value);
2570 if (LocaleCompare(keyword,"style") == 0)
2572 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2575 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2577 draw_info->style=(StyleType) option;
2580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2587 if (LocaleCompare(keyword,"text") == 0)
2589 CloneString(&draw_info->text,value);
2592 if (LocaleCompare(keyword,"translate") == 0)
2594 flags=ParseGeometry(value,&geometry_info);
2595 if ((flags & SigmaValue) == 0)
2596 geometry_info.sigma=1.0;
2597 affine.tx=geometry_info.rho;
2598 affine.ty=geometry_info.sigma;
2601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2608 if (LocaleCompare(keyword, "undercolor") == 0)
2610 (void) QueryColorDatabase(value,&draw_info->undercolor,
2614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2621 if (LocaleCompare(keyword,"weight") == 0)
2623 draw_info->weight=StringToLong(value);
2626 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2633 if (LocaleCompare(keyword,"x") == 0)
2635 geometry.x=StringToLong(value);
2638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2645 if (LocaleCompare(keyword,"y") == 0)
2647 geometry.y=StringToLong(value);
2650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2662 (void) FormatLocaleString(text,MaxTextExtent,
2663 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2664 geometry.height,(double) geometry.x,(double) geometry.y);
2665 CloneString(&draw_info->geometry,text);
2666 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2667 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2668 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2669 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2670 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2672 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2674 (void) DrawImage(msl_info->image[n],draw_info);
2675 draw_info=DestroyDrawInfo(draw_info);
2678 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2683 if (LocaleCompare((const char *) tag,"edge") == 0)
2691 if (msl_info->image[n] == (Image *) NULL)
2693 ThrowMSLException(OptionError,"NoImagesDefined",
2694 (const char *) tag);
2697 if (attributes != (const xmlChar **) NULL)
2698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2700 keyword=(const char *) attributes[i++];
2701 attribute=InterpretImageProperties(msl_info->image_info[n],
2702 msl_info->attributes[n],(const char *) attributes[i]);
2703 CloneString(&value,attribute);
2709 if (LocaleCompare(keyword,"geometry") == 0)
2711 flags=ParseGeometry(value,&geometry_info);
2712 if ((flags & SigmaValue) == 0)
2713 geometry_info.sigma=1.0;
2716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2723 if (LocaleCompare(keyword,"radius") == 0)
2725 geometry_info.rho=InterpretLocaleValue(value,
2729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2741 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2742 &msl_info->image[n]->exception);
2743 if (edge_image == (Image *) NULL)
2745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2746 msl_info->image[n]=edge_image;
2749 if (LocaleCompare((const char *) tag,"emboss") == 0)
2757 if (msl_info->image[n] == (Image *) NULL)
2759 ThrowMSLException(OptionError,"NoImagesDefined",
2760 (const char *) tag);
2763 if (attributes != (const xmlChar **) NULL)
2764 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2766 keyword=(const char *) attributes[i++];
2767 attribute=InterpretImageProperties(msl_info->image_info[n],
2768 msl_info->attributes[n],(const char *) attributes[i]);
2769 CloneString(&value,attribute);
2775 if (LocaleCompare(keyword,"geometry") == 0)
2777 flags=ParseGeometry(value,&geometry_info);
2778 if ((flags & SigmaValue) == 0)
2779 geometry_info.sigma=1.0;
2782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2789 if (LocaleCompare(keyword,"radius") == 0)
2791 geometry_info.rho=InterpretLocaleValue(value,
2795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2802 if (LocaleCompare(keyword,"sigma") == 0)
2804 geometry_info.sigma=StringToLong(value);
2807 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2819 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2820 geometry_info.sigma,&msl_info->image[n]->exception);
2821 if (emboss_image == (Image *) NULL)
2823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2824 msl_info->image[n]=emboss_image;
2827 if (LocaleCompare((const char *) tag,"enhance") == 0)
2835 if (msl_info->image[n] == (Image *) NULL)
2837 ThrowMSLException(OptionError,"NoImagesDefined",
2838 (const char *) tag);
2841 if (attributes != (const xmlChar **) NULL)
2842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2844 keyword=(const char *) attributes[i++];
2845 attribute=InterpretImageProperties(msl_info->image_info[n],
2846 msl_info->attributes[n],(const char *) attributes[i]);
2847 CloneString(&value,attribute);
2848 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2850 enhance_image=EnhanceImage(msl_info->image[n],
2851 &msl_info->image[n]->exception);
2852 if (enhance_image == (Image *) NULL)
2854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2855 msl_info->image[n]=enhance_image;
2858 if (LocaleCompare((const char *) tag,"equalize") == 0)
2863 if (msl_info->image[n] == (Image *) NULL)
2865 ThrowMSLException(OptionError,"NoImagesDefined",
2866 (const char *) tag);
2869 if (attributes != (const xmlChar **) NULL)
2870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2872 keyword=(const char *) attributes[i++];
2873 attribute=InterpretImageProperties(msl_info->image_info[n],
2874 msl_info->attributes[n],(const char *) attributes[i]);
2875 CloneString(&value,attribute);
2880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2886 (void) EqualizeImage(msl_info->image[n]);
2889 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2894 if (LocaleCompare((const char *) tag, "flatten") == 0)
2896 if (msl_info->image[n] == (Image *) NULL)
2898 ThrowMSLException(OptionError,"NoImagesDefined",
2899 (const char *) tag);
2903 /* no attributes here */
2905 /* process the image */
2910 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2911 &msl_info->image[n]->exception);
2912 if (newImage == (Image *) NULL)
2914 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2915 msl_info->image[n]=newImage;
2919 if (LocaleCompare((const char *) tag,"flip") == 0)
2927 if (msl_info->image[n] == (Image *) NULL)
2929 ThrowMSLException(OptionError,"NoImagesDefined",
2930 (const char *) tag);
2933 if (attributes != (const xmlChar **) NULL)
2934 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2936 keyword=(const char *) attributes[i++];
2937 attribute=InterpretImageProperties(msl_info->image_info[n],
2938 msl_info->attributes[n],(const char *) attributes[i]);
2939 CloneString(&value,attribute);
2940 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2942 flip_image=FlipImage(msl_info->image[n],
2943 &msl_info->image[n]->exception);
2944 if (flip_image == (Image *) NULL)
2946 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2947 msl_info->image[n]=flip_image;
2950 if (LocaleCompare((const char *) tag,"flop") == 0)
2958 if (msl_info->image[n] == (Image *) NULL)
2960 ThrowMSLException(OptionError,"NoImagesDefined",
2961 (const char *) tag);
2964 if (attributes != (const xmlChar **) NULL)
2965 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2967 keyword=(const char *) attributes[i++];
2968 attribute=InterpretImageProperties(msl_info->image_info[n],
2969 msl_info->attributes[n],(const char *) attributes[i]);
2970 CloneString(&value,attribute);
2971 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2973 flop_image=FlopImage(msl_info->image[n],
2974 &msl_info->image[n]->exception);
2975 if (flop_image == (Image *) NULL)
2977 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2978 msl_info->image[n]=flop_image;
2981 if (LocaleCompare((const char *) tag,"frame") == 0)
2992 if (msl_info->image[n] == (Image *) NULL)
2994 ThrowMSLException(OptionError,"NoImagesDefined",
2995 (const char *) tag);
2998 SetGeometry(msl_info->image[n],&geometry);
2999 if (attributes != (const xmlChar **) NULL)
3000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3002 keyword=(const char *) attributes[i++];
3003 attribute=InterpretImageProperties(msl_info->image_info[n],
3004 msl_info->attributes[n],(const char *) attributes[i]);
3005 CloneString(&value,attribute);
3011 if (LocaleCompare(keyword,"compose") == 0)
3013 option=ParseCommandOption(MagickComposeOptions,
3016 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3018 msl_info->image[n]->compose=(CompositeOperator) option;
3021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3028 if (LocaleCompare(keyword, "fill") == 0)
3030 (void) QueryColorDatabase(value,
3031 &msl_info->image[n]->matte_color,&exception);
3034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3041 if (LocaleCompare(keyword,"geometry") == 0)
3043 flags=ParsePageGeometry(msl_info->image[n],value,
3044 &geometry,&exception);
3045 if ((flags & HeightValue) == 0)
3046 geometry.height=geometry.width;
3047 frame_info.width=geometry.width;
3048 frame_info.height=geometry.height;
3049 frame_info.outer_bevel=geometry.x;
3050 frame_info.inner_bevel=geometry.y;
3053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3060 if (LocaleCompare(keyword,"height") == 0)
3062 frame_info.height=StringToLong(value);
3065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3072 if (LocaleCompare(keyword,"inner") == 0)
3074 frame_info.inner_bevel=StringToLong(value);
3077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3084 if (LocaleCompare(keyword,"outer") == 0)
3086 frame_info.outer_bevel=StringToLong(value);
3089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3096 if (LocaleCompare(keyword,"width") == 0)
3098 frame_info.width=StringToLong(value);
3101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3113 frame_info.x=(ssize_t) frame_info.width;
3114 frame_info.y=(ssize_t) frame_info.height;
3115 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3116 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3117 frame_image=FrameImage(msl_info->image[n],&frame_info,
3118 &msl_info->image[n]->exception);
3119 if (frame_image == (Image *) NULL)
3121 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3122 msl_info->image[n]=frame_image;
3125 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3130 if (LocaleCompare((const char *) tag,"gamma") == 0)
3133 gamma[MaxTextExtent];
3141 if (msl_info->image[n] == (Image *) NULL)
3143 ThrowMSLException(OptionError,"NoImagesDefined",
3144 (const char *) tag);
3147 channel=UndefinedChannel;
3152 if (attributes != (const xmlChar **) NULL)
3153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3155 keyword=(const char *) attributes[i++];
3156 attribute=InterpretImageProperties(msl_info->image_info[n],
3157 msl_info->attributes[n],(const char *) attributes[i]);
3158 CloneString(&value,attribute);
3164 if (LocaleCompare(keyword,"blue") == 0)
3166 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3169 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3176 if (LocaleCompare(keyword,"channel") == 0)
3178 option=ParseChannelOption(value);
3180 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3182 channel=(ChannelType) option;
3185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3192 if (LocaleCompare(keyword,"gamma") == 0)
3194 (void) CopyMagickString(gamma,value,MaxTextExtent);
3197 if (LocaleCompare(keyword,"green") == 0)
3199 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3209 if (LocaleCompare(keyword,"red") == 0)
3211 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3227 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3228 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3229 (void) GammaImage(msl_info->image[n],atof(gamma),
3230 &msl_info->image[n]->exception);
3233 else if (LocaleCompare((const char *) tag,"get") == 0)
3235 if (msl_info->image[n] == (Image *) NULL)
3237 ThrowMSLException(OptionError,"NoImagesDefined",
3238 (const char *) tag);
3241 if (attributes == (const xmlChar **) NULL)
3243 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3245 keyword=(const char *) attributes[i++];
3246 CloneString(&value,(const char *) attributes[i]);
3247 (void) CopyMagickString(key,value,MaxTextExtent);
3253 if (LocaleCompare(keyword,"height") == 0)
3255 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3256 (double) msl_info->image[n]->rows);
3257 (void) SetImageProperty(msl_info->attributes[n],key,value);
3260 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3265 if (LocaleCompare(keyword,"width") == 0)
3267 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3268 (double) msl_info->image[n]->columns);
3269 (void) SetImageProperty(msl_info->attributes[n],key,value);
3272 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3276 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3283 else if (LocaleCompare((const char *) tag, "group") == 0)
3285 msl_info->number_groups++;
3286 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3287 msl_info->group_info,msl_info->number_groups+1UL,
3288 sizeof(*msl_info->group_info));
3291 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3296 if (LocaleCompare((const char *) tag,"image") == 0)
3298 MSLPushImage(msl_info,(Image *) NULL);
3299 if (attributes == (const xmlChar **) NULL)
3301 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3303 keyword=(const char *) attributes[i++];
3304 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3305 msl_info->attributes[n],(const char *) attributes[i]));
3311 if (LocaleCompare(keyword,"color") == 0)
3316 (void) CopyMagickString(msl_info->image_info[n]->filename,
3317 "xc:",MaxTextExtent);
3318 (void) ConcatenateMagickString(msl_info->image_info[n]->
3319 filename,value,MaxTextExtent);
3320 next_image=ReadImage(msl_info->image_info[n],&exception);
3321 CatchException(&exception);
3322 if (next_image == (Image *) NULL)
3324 if (msl_info->image[n] == (Image *) NULL)
3325 msl_info->image[n]=next_image;
3332 Link image into image list.
3334 p=msl_info->image[n];
3335 while (p->next != (Image *) NULL)
3336 p=GetNextImageInList(p);
3337 next_image->previous=p;
3342 (void) SetMSLAttributes(msl_info,keyword,value);
3347 (void) SetMSLAttributes(msl_info,keyword,value);
3354 if (LocaleCompare((const char *) tag,"implode") == 0)
3362 if (msl_info->image[n] == (Image *) NULL)
3364 ThrowMSLException(OptionError,"NoImagesDefined",
3365 (const char *) tag);
3368 if (attributes != (const xmlChar **) NULL)
3369 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3371 keyword=(const char *) attributes[i++];
3372 attribute=InterpretImageProperties(msl_info->image_info[n],
3373 msl_info->attributes[n],(const char *) attributes[i]);
3374 CloneString(&value,attribute);
3380 if (LocaleCompare(keyword,"amount") == 0)
3382 geometry_info.rho=InterpretLocaleValue(value,
3386 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3393 if (LocaleCompare(keyword,"geometry") == 0)
3395 flags=ParseGeometry(value,&geometry_info);
3396 if ((flags & SigmaValue) == 0)
3397 geometry_info.sigma=1.0;
3400 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3406 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3412 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3413 &msl_info->image[n]->exception);
3414 if (implode_image == (Image *) NULL)
3416 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3417 msl_info->image[n]=implode_image;
3420 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3425 if (LocaleCompare((const char *) tag,"label") == 0)
3427 if (LocaleCompare((const char *) tag, "level") == 0)
3430 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3432 if (msl_info->image[n] == (Image *) NULL)
3434 ThrowMSLException(OptionError,"NoImagesDefined",
3435 (const char *) tag);
3438 if (attributes == (const xmlChar **) NULL)
3440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3442 keyword=(const char *) attributes[i++];
3443 CloneString(&value,(const char *) attributes[i]);
3444 (void) CopyMagickString(key,value,MaxTextExtent);
3450 if (LocaleCompare(keyword,"black") == 0)
3452 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3455 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3461 if (LocaleCompare(keyword,"gamma") == 0)
3463 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3466 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3472 if (LocaleCompare(keyword,"white") == 0)
3474 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3477 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3489 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3490 &msl_info->image[n]->exception);
3497 if (LocaleCompare((const char *) tag,"magnify") == 0)
3505 if (msl_info->image[n] == (Image *) NULL)
3507 ThrowMSLException(OptionError,"NoImagesDefined",
3508 (const char *) tag);
3511 if (attributes != (const xmlChar **) NULL)
3512 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3514 keyword=(const char *) attributes[i++];
3515 attribute=InterpretImageProperties(msl_info->image_info[n],
3516 msl_info->attributes[n],(const char *) attributes[i]);
3517 CloneString(&value,attribute);
3518 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3520 magnify_image=MagnifyImage(msl_info->image[n],
3521 &msl_info->image[n]->exception);
3522 if (magnify_image == (Image *) NULL)
3524 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3525 msl_info->image[n]=magnify_image;
3528 if (LocaleCompare((const char *) tag,"map") == 0)
3542 if (msl_info->image[n] == (Image *) NULL)
3544 ThrowMSLException(OptionError,"NoImagesDefined",
3545 (const char *) tag);
3548 affinity_image=NewImageList();
3550 if (attributes != (const xmlChar **) NULL)
3551 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3553 keyword=(const char *) attributes[i++];
3554 attribute=InterpretImageProperties(msl_info->image_info[n],
3555 msl_info->attributes[n],(const char *) attributes[i]);
3556 CloneString(&value,attribute);
3562 if (LocaleCompare(keyword,"dither") == 0)
3564 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3567 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3569 dither=(MagickBooleanType) option;
3572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3579 if (LocaleCompare(keyword,"image") == 0)
3580 for (j=0; j < msl_info->n; j++)
3585 attribute=GetImageProperty(msl_info->attributes[j],"id");
3586 if ((attribute != (const char *) NULL) &&
3587 (LocaleCompare(attribute,value) == 0))
3589 affinity_image=CloneImage(msl_info->image[j],0,0,
3590 MagickFalse,&exception);
3598 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3604 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3605 quantize_info->dither=dither;
3606 (void) RemapImages(quantize_info,msl_info->image[n],
3608 quantize_info=DestroyQuantizeInfo(quantize_info);
3609 affinity_image=DestroyImage(affinity_image);
3612 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3624 Matte floodfill image.
3627 if (msl_info->image[n] == (Image *) NULL)
3629 ThrowMSLException(OptionError,"NoImagesDefined",
3630 (const char *) tag);
3633 SetGeometry(msl_info->image[n],&geometry);
3634 paint_method=FloodfillMethod;
3635 if (attributes != (const xmlChar **) NULL)
3636 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3638 keyword=(const char *) attributes[i++];
3639 attribute=InterpretImageProperties(msl_info->image_info[n],
3640 msl_info->attributes[n],(const char *) attributes[i]);
3641 CloneString(&value,attribute);
3647 if (LocaleCompare(keyword,"bordercolor") == 0)
3649 (void) QueryMagickColor(value,&target,&exception);
3650 paint_method=FillToBorderMethod;
3653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3660 if (LocaleCompare(keyword,"fuzz") == 0)
3662 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3673 if (LocaleCompare(keyword,"geometry") == 0)
3675 flags=ParsePageGeometry(msl_info->image[n],value,
3676 &geometry,&exception);
3677 if ((flags & HeightValue) == 0)
3678 geometry.height=geometry.width;
3679 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3680 geometry.x,geometry.y,&target,&exception);
3683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3690 if (LocaleCompare(keyword,"opacity") == 0)
3692 opacity=InterpretLocaleValue(value,(char **) NULL);
3695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3702 if (LocaleCompare(keyword,"x") == 0)
3704 geometry.x=StringToLong(value);
3705 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3706 geometry.x,geometry.y,&target,&exception);
3709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3716 if (LocaleCompare(keyword,"y") == 0)
3718 geometry.y=StringToLong(value);
3719 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3720 geometry.x,geometry.y,&target,&exception);
3723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3735 draw_info=CloneDrawInfo(msl_info->image_info[n],
3736 msl_info->draw_info[n]);
3737 draw_info->fill.alpha=ClampToQuantum(opacity);
3738 PushPixelChannelMap(msl_info->image[n],AlphaChannel);
3739 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3740 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3741 MagickFalse : MagickTrue);
3742 PopPixelChannelMap(msl_info->image[n]);
3743 draw_info=DestroyDrawInfo(draw_info);
3746 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3752 Median-filter image.
3754 if (msl_info->image[n] == (Image *) NULL)
3756 ThrowMSLException(OptionError,"NoImagesDefined",
3757 (const char *) tag);
3760 if (attributes != (const xmlChar **) NULL)
3761 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3763 keyword=(const char *) attributes[i++];
3764 attribute=InterpretImageProperties(msl_info->image_info[n],
3765 msl_info->attributes[n],(const char *) attributes[i]);
3766 CloneString(&value,attribute);
3772 if (LocaleCompare(keyword,"geometry") == 0)
3774 flags=ParseGeometry(value,&geometry_info);
3775 if ((flags & SigmaValue) == 0)
3776 geometry_info.sigma=1.0;
3779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3786 if (LocaleCompare(keyword,"radius") == 0)
3788 geometry_info.rho=InterpretLocaleValue(value,
3792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3804 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3805 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3806 &msl_info->image[n]->exception);
3807 if (median_image == (Image *) NULL)
3809 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3810 msl_info->image[n]=median_image;
3813 if (LocaleCompare((const char *) tag,"minify") == 0)
3821 if (msl_info->image[n] == (Image *) NULL)
3823 ThrowMSLException(OptionError,"NoImagesDefined",
3824 (const char *) tag);
3827 if (attributes != (const xmlChar **) NULL)
3828 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3830 keyword=(const char *) attributes[i++];
3831 attribute=InterpretImageProperties(msl_info->image_info[n],
3832 msl_info->attributes[n],(const char *) attributes[i]);
3833 CloneString(&value,attribute);
3834 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3836 minify_image=MinifyImage(msl_info->image[n],
3837 &msl_info->image[n]->exception);
3838 if (minify_image == (Image *) NULL)
3840 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3841 msl_info->image[n]=minify_image;
3844 if (LocaleCompare((const char *) tag,"msl") == 0 )
3846 if (LocaleCompare((const char *) tag,"modulate") == 0)
3849 modulate[MaxTextExtent];
3854 if (msl_info->image[n] == (Image *) NULL)
3856 ThrowMSLException(OptionError,"NoImagesDefined",
3857 (const char *) tag);
3860 geometry_info.rho=100.0;
3861 geometry_info.sigma=100.0;
3862 geometry_info.xi=100.0;
3863 if (attributes != (const xmlChar **) NULL)
3864 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3866 keyword=(const char *) attributes[i++];
3867 attribute=InterpretImageProperties(msl_info->image_info[n],
3868 msl_info->attributes[n],(const char *) attributes[i]);
3869 CloneString(&value,attribute);
3875 if (LocaleCompare(keyword,"blackness") == 0)
3877 geometry_info.rho=InterpretLocaleValue(value,
3881 if (LocaleCompare(keyword,"brightness") == 0)
3883 geometry_info.rho=InterpretLocaleValue(value,
3887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3894 if (LocaleCompare(keyword,"factor") == 0)
3896 flags=ParseGeometry(value,&geometry_info);
3899 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3906 if (LocaleCompare(keyword,"hue") == 0)
3908 geometry_info.xi=InterpretLocaleValue(value,
3912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3919 if (LocaleCompare(keyword,"lightness") == 0)
3921 geometry_info.rho=InterpretLocaleValue(value,
3925 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3932 if (LocaleCompare(keyword,"saturation") == 0)
3934 geometry_info.sigma=InterpretLocaleValue(value,
3938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3945 if (LocaleCompare(keyword,"whiteness") == 0)
3947 geometry_info.sigma=InterpretLocaleValue(value,
3951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3963 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3964 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3965 (void) ModulateImage(msl_info->image[n],modulate);
3968 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3973 if (LocaleCompare((const char *) tag,"negate") == 0)
3981 if (msl_info->image[n] == (Image *) NULL)
3983 ThrowMSLException(OptionError,"NoImagesDefined",
3984 (const char *) tag);
3988 if (attributes != (const xmlChar **) NULL)
3989 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3991 keyword=(const char *) attributes[i++];
3992 attribute=InterpretImageProperties(msl_info->image_info[n],
3993 msl_info->attributes[n],(const char *) attributes[i]);
3994 CloneString(&value,attribute);
4000 if (LocaleCompare(keyword,"channel") == 0)
4002 option=ParseChannelOption(value);
4004 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4006 channel=(ChannelType) option;
4009 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4016 if (LocaleCompare(keyword,"gray") == 0)
4018 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4021 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4023 gray=(MagickBooleanType) option;
4026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4038 PushPixelChannelMap(msl_info->image[n],channel);
4039 (void) NegateImage(msl_info->image[n],gray,
4040 &msl_info->image[n]->exception);
4041 PopPixelChannelMap(msl_info->image[n]);
4044 if (LocaleCompare((const char *) tag,"normalize") == 0)
4049 if (msl_info->image[n] == (Image *) NULL)
4051 ThrowMSLException(OptionError,"NoImagesDefined",
4052 (const char *) tag);
4055 if (attributes != (const xmlChar **) NULL)
4056 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4058 keyword=(const char *) attributes[i++];
4059 attribute=InterpretImageProperties(msl_info->image_info[n],
4060 msl_info->attributes[n],(const char *) attributes[i]);
4061 CloneString(&value,attribute);
4067 if (LocaleCompare(keyword,"channel") == 0)
4069 option=ParseChannelOption(value);
4071 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4073 channel=(ChannelType) option;
4076 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4082 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4088 (void) NormalizeImage(msl_info->image[n],
4089 &msl_info->image[n]->exception);
4092 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4097 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4105 if (msl_info->image[n] == (Image *) NULL)
4107 ThrowMSLException(OptionError,"NoImagesDefined",
4108 (const char *) tag);
4111 if (attributes != (const xmlChar **) NULL)
4112 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4114 keyword=(const char *) attributes[i++];
4115 attribute=InterpretImageProperties(msl_info->image_info[n],
4116 msl_info->attributes[n],(const char *) attributes[i]);
4117 CloneString(&value,attribute);
4123 if (LocaleCompare(keyword,"geometry") == 0)
4125 flags=ParseGeometry(value,&geometry_info);
4126 if ((flags & SigmaValue) == 0)
4127 geometry_info.sigma=1.0;
4130 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4137 if (LocaleCompare(keyword,"radius") == 0)
4139 geometry_info.rho=InterpretLocaleValue(value,
4143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4155 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4156 &msl_info->image[n]->exception);
4157 if (paint_image == (Image *) NULL)
4159 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4160 msl_info->image[n]=paint_image;
4163 if (LocaleCompare((const char *) tag,"opaque") == 0)
4172 if (msl_info->image[n] == (Image *) NULL)
4174 ThrowMSLException(OptionError,"NoImagesDefined",
4175 (const char *) tag);
4178 (void) QueryMagickColor("none",&target,&exception);
4179 (void) QueryMagickColor("none",&fill_color,&exception);
4180 if (attributes != (const xmlChar **) NULL)
4181 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4183 keyword=(const char *) attributes[i++];
4184 attribute=InterpretImageProperties(msl_info->image_info[n],
4185 msl_info->attributes[n],(const char *) attributes[i]);
4186 CloneString(&value,attribute);
4192 if (LocaleCompare(keyword,"channel") == 0)
4194 option=ParseChannelOption(value);
4196 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4198 channel=(ChannelType) option;
4201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4208 if (LocaleCompare(keyword,"fill") == 0)
4210 (void) QueryMagickColor(value,&fill_color,&exception);
4213 if (LocaleCompare(keyword,"fuzz") == 0)
4215 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4225 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4231 PushPixelChannelMap(msl_info->image[n],channel);
4232 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4234 PopPixelChannelMap(msl_info->image[n]);
4237 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4242 if (LocaleCompare((const char *) tag,"print") == 0)
4244 if (attributes == (const xmlChar **) NULL)
4246 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4248 keyword=(const char *) attributes[i++];
4249 attribute=InterpretImageProperties(msl_info->image_info[n],
4250 msl_info->attributes[n],(const char *) attributes[i]);
4251 CloneString(&value,attribute);
4257 if (LocaleCompare(keyword,"output") == 0)
4259 (void) FormatLocaleFile(stdout,"%s",value);
4262 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4267 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4274 if (LocaleCompare((const char *) tag, "profile") == 0)
4276 if (msl_info->image[n] == (Image *) NULL)
4278 ThrowMSLException(OptionError,"NoImagesDefined",
4279 (const char *) tag);
4282 if (attributes == (const xmlChar **) NULL)
4284 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4298 keyword=(const char *) attributes[i++];
4299 attribute=InterpretImageProperties(msl_info->image_info[n],
4300 msl_info->attributes[n],(const char *) attributes[i]);
4301 CloneString(&value,attribute);
4302 if (*keyword == '+')
4305 Remove a profile from the image.
4307 (void) ProfileImage(msl_info->image[n],keyword,
4308 (const unsigned char *) NULL,0,MagickTrue);
4312 Associate a profile with the image.
4314 profile_info=CloneImageInfo(msl_info->image_info[n]);
4315 profile=GetImageProfile(msl_info->image[n],"iptc");
4316 if (profile != (StringInfo *) NULL)
4317 profile_info->profile=(void *) CloneStringInfo(profile);
4318 profile_image=GetImageCache(profile_info,keyword,&exception);
4319 profile_info=DestroyImageInfo(profile_info);
4320 if (profile_image == (Image *) NULL)
4323 name[MaxTextExtent],
4324 filename[MaxTextExtent];
4332 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4333 (void) CopyMagickString(name,keyword,MaxTextExtent);
4334 for (p=filename; *p != '\0'; p++)
4335 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4336 (IsPathAccessible(keyword) == MagickFalse))
4342 Look for profile name (e.g. name:profile).
4344 (void) CopyMagickString(name,filename,(size_t)
4346 for (q=filename; *q != '\0'; q++)
4350 profile=FileToStringInfo(filename,~0UL,&exception);
4351 if (profile != (StringInfo *) NULL)
4353 (void) ProfileImage(msl_info->image[n],name,
4354 GetStringInfoDatum(profile),(size_t)
4355 GetStringInfoLength(profile),MagickFalse);
4356 profile=DestroyStringInfo(profile);
4360 ResetImageProfileIterator(profile_image);
4361 name=GetNextImageProfile(profile_image);
4362 while (name != (const char *) NULL)
4364 profile=GetImageProfile(profile_image,name);
4365 if (profile != (StringInfo *) NULL)
4366 (void) ProfileImage(msl_info->image[n],name,
4367 GetStringInfoDatum(profile),(size_t)
4368 GetStringInfoLength(profile),MagickFalse);
4369 name=GetNextImageProfile(profile_image);
4371 profile_image=DestroyImage(profile_image);
4375 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4380 if (LocaleCompare((const char *) tag,"quantize") == 0)
4388 if (msl_info->image[n] == (Image *) NULL)
4390 ThrowMSLException(OptionError,"NoImagesDefined",
4391 (const char *) tag);
4394 GetQuantizeInfo(&quantize_info);
4395 if (attributes != (const xmlChar **) NULL)
4396 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4398 keyword=(const char *) attributes[i++];
4399 attribute=InterpretImageProperties(msl_info->image_info[n],
4400 msl_info->attributes[n],(const char *) attributes[i]);
4401 CloneString(&value,attribute);
4407 if (LocaleCompare(keyword,"colors") == 0)
4409 quantize_info.number_colors=StringToLong(value);
4412 if (LocaleCompare(keyword,"colorspace") == 0)
4414 option=ParseCommandOption(MagickColorspaceOptions,
4417 ThrowMSLException(OptionError,
4418 "UnrecognizedColorspaceType",value);
4419 quantize_info.colorspace=(ColorspaceType) option;
4422 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4429 if (LocaleCompare(keyword,"dither") == 0)
4431 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4434 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4436 quantize_info.dither=(MagickBooleanType) option;
4439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4446 if (LocaleCompare(keyword,"measure") == 0)
4448 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4451 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4453 quantize_info.measure_error=(MagickBooleanType) option;
4456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4463 if (LocaleCompare(keyword,"treedepth") == 0)
4465 quantize_info.tree_depth=StringToLong(value);
4468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4474 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4480 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4483 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4486 text[MaxTextExtent];
4497 draw_info=CloneDrawInfo(msl_info->image_info[n],
4498 msl_info->draw_info[n]);
4500 current=draw_info->affine;
4501 GetAffineMatrix(&affine);
4502 if (attributes != (const xmlChar **) NULL)
4503 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4505 keyword=(const char *) attributes[i++];
4506 attribute=InterpretImageProperties(msl_info->image_info[n],
4507 msl_info->attributes[n],(const char *) attributes[i]);
4508 CloneString(&value,attribute);
4514 if (LocaleCompare(keyword,"affine") == 0)
4520 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4523 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4526 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4529 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4532 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4535 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4538 if (LocaleCompare(keyword,"align") == 0)
4540 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4543 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4545 draw_info->align=(AlignType) option;
4548 if (LocaleCompare(keyword,"antialias") == 0)
4550 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4553 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4555 draw_info->stroke_antialias=(MagickBooleanType) option;
4556 draw_info->text_antialias=(MagickBooleanType) option;
4559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4566 if (LocaleCompare(keyword,"density") == 0)
4568 CloneString(&draw_info->density,value);
4571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4578 if (LocaleCompare(keyword,"encoding") == 0)
4580 CloneString(&draw_info->encoding,value);
4583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4590 if (LocaleCompare(keyword, "fill") == 0)
4592 (void) QueryColorDatabase(value,&draw_info->fill,
4596 if (LocaleCompare(keyword,"family") == 0)
4598 CloneString(&draw_info->family,value);
4601 if (LocaleCompare(keyword,"font") == 0)
4603 CloneString(&draw_info->font,value);
4606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4613 if (LocaleCompare(keyword,"geometry") == 0)
4615 flags=ParsePageGeometry(msl_info->image[n],value,
4616 &geometry,&exception);
4617 if ((flags & HeightValue) == 0)
4618 geometry.height=geometry.width;
4621 if (LocaleCompare(keyword,"gravity") == 0)
4623 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4626 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4628 draw_info->gravity=(GravityType) option;
4631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(keyword,"pointsize") == 0)
4640 draw_info->pointsize=InterpretLocaleValue(value,
4644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4651 if (LocaleCompare(keyword,"rotate") == 0)
4653 angle=InterpretLocaleValue(value,(char **) NULL);
4654 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4655 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4656 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4657 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4667 if (LocaleCompare(keyword,"scale") == 0)
4669 flags=ParseGeometry(value,&geometry_info);
4670 if ((flags & SigmaValue) == 0)
4671 geometry_info.sigma=1.0;
4672 affine.sx=geometry_info.rho;
4673 affine.sy=geometry_info.sigma;
4676 if (LocaleCompare(keyword,"skewX") == 0)
4678 angle=InterpretLocaleValue(value,(char **) NULL);
4679 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4682 if (LocaleCompare(keyword,"skewY") == 0)
4684 angle=InterpretLocaleValue(value,(char **) NULL);
4685 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4688 if (LocaleCompare(keyword,"stretch") == 0)
4690 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4693 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4695 draw_info->stretch=(StretchType) option;
4698 if (LocaleCompare(keyword, "stroke") == 0)
4700 (void) QueryColorDatabase(value,&draw_info->stroke,
4704 if (LocaleCompare(keyword,"strokewidth") == 0)
4706 draw_info->stroke_width=StringToLong(value);
4709 if (LocaleCompare(keyword,"style") == 0)
4711 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4714 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4716 draw_info->style=(StyleType) option;
4719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4726 if (LocaleCompare(keyword,"text") == 0)
4728 CloneString(&draw_info->text,value);
4731 if (LocaleCompare(keyword,"translate") == 0)
4733 flags=ParseGeometry(value,&geometry_info);
4734 if ((flags & SigmaValue) == 0)
4735 geometry_info.sigma=1.0;
4736 affine.tx=geometry_info.rho;
4737 affine.ty=geometry_info.sigma;
4740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4747 if (LocaleCompare(keyword, "undercolor") == 0)
4749 (void) QueryColorDatabase(value,&draw_info->undercolor,
4753 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4760 if (LocaleCompare(keyword,"weight") == 0)
4762 draw_info->weight=StringToLong(value);
4765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4772 if (LocaleCompare(keyword,"x") == 0)
4774 geometry.x=StringToLong(value);
4777 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4784 if (LocaleCompare(keyword,"y") == 0)
4786 geometry.y=StringToLong(value);
4789 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4801 (void) FormatLocaleString(text,MaxTextExtent,
4802 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4803 geometry.height,(double) geometry.x,(double) geometry.y);
4804 CloneString(&draw_info->geometry,text);
4805 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4806 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4807 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4808 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4809 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4811 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4813 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4814 if (status != MagickFalse)
4819 image=msl_info->attributes[n];
4820 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4821 "%g",metrics.pixels_per_em.x);
4822 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4823 "%g",metrics.pixels_per_em.y);
4824 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4826 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4828 FormatImageProperty(image,"msl:font-metrics.width","%g",
4830 FormatImageProperty(image,"msl:font-metrics.height","%g",
4832 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4833 metrics.max_advance);
4834 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4836 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4838 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4840 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4842 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4844 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4847 draw_info=DestroyDrawInfo(draw_info);
4850 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4855 if (LocaleCompare((const char *) tag,"raise") == 0)
4863 if (msl_info->image[n] == (Image *) NULL)
4865 ThrowMSLException(OptionError,"NoImagesDefined",
4866 (const char *) tag);
4870 SetGeometry(msl_info->image[n],&geometry);
4871 if (attributes != (const xmlChar **) NULL)
4872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4874 keyword=(const char *) attributes[i++];
4875 attribute=InterpretImageProperties(msl_info->image_info[n],
4876 msl_info->attributes[n],(const char *) attributes[i]);
4877 CloneString(&value,attribute);
4883 if (LocaleCompare(keyword,"geometry") == 0)
4885 flags=ParsePageGeometry(msl_info->image[n],value,
4886 &geometry,&exception);
4887 if ((flags & HeightValue) == 0)
4888 geometry.height=geometry.width;
4891 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4898 if (LocaleCompare(keyword,"height") == 0)
4900 geometry.height=StringToLong(value);
4903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4910 if (LocaleCompare(keyword,"raise") == 0)
4912 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4915 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4917 raise=(MagickBooleanType) option;
4920 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4927 if (LocaleCompare(keyword,"width") == 0)
4929 geometry.width=StringToLong(value);
4932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4944 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4947 if (LocaleCompare((const char *) tag,"read") == 0)
4949 if (attributes == (const xmlChar **) NULL)
4951 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4953 keyword=(const char *) attributes[i++];
4954 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4955 msl_info->attributes[n],(const char *) attributes[i]));
4961 if (LocaleCompare(keyword,"filename") == 0)
4966 (void) CopyMagickString(msl_info->image_info[n]->filename,
4967 value,MaxTextExtent);
4968 image=ReadImage(msl_info->image_info[n],&exception);
4969 CatchException(&exception);
4970 if (image == (Image *) NULL)
4972 AppendImageToList(&msl_info->image[n],image);
4975 (void) SetMSLAttributes(msl_info,keyword,value);
4980 (void) SetMSLAttributes(msl_info,keyword,value);
4987 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4995 if (msl_info->image[n] == (Image *) NULL)
4997 ThrowMSLException(OptionError,"NoImagesDefined",
4998 (const char *) tag);
5001 if (attributes != (const xmlChar **) NULL)
5002 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5004 keyword=(const char *) attributes[i++];
5005 attribute=InterpretImageProperties(msl_info->image_info[n],
5006 msl_info->attributes[n],(const char *) attributes[i]);
5007 CloneString(&value,attribute);
5013 if (LocaleCompare(keyword,"geometry") == 0)
5015 flags=ParseGeometry(value,&geometry_info);
5016 if ((flags & SigmaValue) == 0)
5017 geometry_info.sigma=1.0;
5020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5027 if (LocaleCompare(keyword,"radius") == 0)
5029 geometry_info.rho=InterpretLocaleValue(value,
5033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5045 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5046 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5047 &msl_info->image[n]->exception);
5048 if (paint_image == (Image *) NULL)
5050 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5051 msl_info->image[n]=paint_image;
5054 else if (LocaleCompare((const char *) tag,"repage") == 0)
5056 /* init the values */
5057 width=msl_info->image[n]->page.width;
5058 height=msl_info->image[n]->page.height;
5059 x=msl_info->image[n]->page.x;
5060 y=msl_info->image[n]->page.y;
5062 if (msl_info->image[n] == (Image *) NULL)
5064 ThrowMSLException(OptionError,"NoImagesDefined",
5065 (const char *) tag);
5068 if (attributes == (const xmlChar **) NULL)
5070 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5072 keyword=(const char *) attributes[i++];
5073 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5074 msl_info->attributes[n],(const char *) attributes[i]));
5080 if (LocaleCompare(keyword,"geometry") == 0)
5088 flags=ParseAbsoluteGeometry(value,&geometry);
5089 if ((flags & WidthValue) != 0)
5091 if ((flags & HeightValue) == 0)
5092 geometry.height=geometry.width;
5093 width=geometry.width;
5094 height=geometry.height;
5096 if ((flags & AspectValue) != 0)
5098 if ((flags & XValue) != 0)
5100 if ((flags & YValue) != 0)
5105 if ((flags & XValue) != 0)
5108 if ((width == 0) && (geometry.x > 0))
5109 width=msl_info->image[n]->columns+geometry.x;
5111 if ((flags & YValue) != 0)
5114 if ((height == 0) && (geometry.y > 0))
5115 height=msl_info->image[n]->rows+geometry.y;
5120 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5126 if (LocaleCompare(keyword,"height") == 0)
5128 height = StringToLong( value );
5131 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5137 if (LocaleCompare(keyword,"width") == 0)
5139 width = StringToLong( value );
5142 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5148 if (LocaleCompare(keyword,"x") == 0)
5150 x = StringToLong( value );
5153 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5159 if (LocaleCompare(keyword,"y") == 0)
5161 y = StringToLong( value );
5164 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5169 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5175 msl_info->image[n]->page.width=width;
5176 msl_info->image[n]->page.height=height;
5177 msl_info->image[n]->page.x=x;
5178 msl_info->image[n]->page.y=y;
5181 else if (LocaleCompare((const char *) tag,"resample") == 0)
5187 if (msl_info->image[n] == (Image *) NULL)
5189 ThrowMSLException(OptionError,"NoImagesDefined",
5190 (const char *) tag);
5193 if (attributes == (const xmlChar **) NULL)
5195 x_resolution=DefaultResolution;
5196 y_resolution=DefaultResolution;
5197 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5199 keyword=(const char *) attributes[i++];
5200 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5201 msl_info->attributes[n],(const char *) attributes[i]));
5206 if (LocaleCompare(keyword,"blur") == 0)
5208 msl_info->image[n]->blur=InterpretLocaleValue(value,
5212 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5218 if (LocaleCompare(keyword,"geometry") == 0)
5223 flags=ParseGeometry(value,&geometry_info);
5224 if ((flags & SigmaValue) == 0)
5225 geometry_info.sigma*=geometry_info.rho;
5226 x_resolution=geometry_info.rho;
5227 y_resolution=geometry_info.sigma;
5230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5236 if (LocaleCompare(keyword,"x-resolution") == 0)
5238 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5241 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5247 if (LocaleCompare(keyword,"y-resolution") == 0)
5249 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5252 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5257 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5273 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5275 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5276 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5277 msl_info->image[n]->x_resolution))+0.5);
5278 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5279 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5280 msl_info->image[n]->y_resolution))+0.5);
5281 resample_image=ResizeImage(msl_info->image[n],width,height,
5282 msl_info->image[n]->filter,msl_info->image[n]->blur,
5283 &msl_info->image[n]->exception);
5284 if (resample_image == (Image *) NULL)
5286 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5287 msl_info->image[n]=resample_image;
5291 if (LocaleCompare((const char *) tag,"resize") == 0)
5305 if (msl_info->image[n] == (Image *) NULL)
5307 ThrowMSLException(OptionError,"NoImagesDefined",
5308 (const char *) tag);
5311 filter=UndefinedFilter;
5313 if (attributes != (const xmlChar **) NULL)
5314 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5316 keyword=(const char *) attributes[i++];
5317 attribute=InterpretImageProperties(msl_info->image_info[n],
5318 msl_info->attributes[n],(const char *) attributes[i]);
5319 CloneString(&value,attribute);
5325 if (LocaleCompare(keyword,"filter") == 0)
5327 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5330 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5332 filter=(FilterTypes) option;
5335 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5342 if (LocaleCompare(keyword,"geometry") == 0)
5344 flags=ParseRegionGeometry(msl_info->image[n],value,
5345 &geometry,&exception);
5348 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5355 if (LocaleCompare(keyword,"height") == 0)
5357 geometry.height=StringToUnsignedLong(value);
5360 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5367 if (LocaleCompare(keyword,"support") == 0)
5369 blur=InterpretLocaleValue(value,(char **) NULL);
5372 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5379 if (LocaleCompare(keyword,"width") == 0)
5381 geometry.width=StringToLong(value);
5384 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5390 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5396 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5397 geometry.height,filter,blur,&msl_info->image[n]->exception);
5398 if (resize_image == (Image *) NULL)
5400 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5401 msl_info->image[n]=resize_image;
5404 if (LocaleCompare((const char *) tag,"roll") == 0)
5412 if (msl_info->image[n] == (Image *) NULL)
5414 ThrowMSLException(OptionError,"NoImagesDefined",
5415 (const char *) tag);
5418 SetGeometry(msl_info->image[n],&geometry);
5419 if (attributes != (const xmlChar **) NULL)
5420 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5422 keyword=(const char *) attributes[i++];
5423 attribute=InterpretImageProperties(msl_info->image_info[n],
5424 msl_info->attributes[n],(const char *) attributes[i]);
5425 CloneString(&value,attribute);
5431 if (LocaleCompare(keyword,"geometry") == 0)
5433 flags=ParsePageGeometry(msl_info->image[n],value,
5434 &geometry,&exception);
5435 if ((flags & HeightValue) == 0)
5436 geometry.height=geometry.width;
5439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5446 if (LocaleCompare(keyword,"x") == 0)
5448 geometry.x=StringToLong(value);
5451 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5458 if (LocaleCompare(keyword,"y") == 0)
5460 geometry.y=StringToLong(value);
5463 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5469 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5475 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5476 &msl_info->image[n]->exception);
5477 if (roll_image == (Image *) NULL)
5479 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5480 msl_info->image[n]=roll_image;
5483 else if (LocaleCompare((const char *) tag,"roll") == 0)
5485 /* init the values */
5486 width=msl_info->image[n]->columns;
5487 height=msl_info->image[n]->rows;
5490 if (msl_info->image[n] == (Image *) NULL)
5492 ThrowMSLException(OptionError,"NoImagesDefined",
5493 (const char *) tag);
5496 if (attributes == (const xmlChar **) NULL)
5498 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5500 keyword=(const char *) attributes[i++];
5501 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5502 msl_info->attributes[n],(const char *) attributes[i]));
5508 if (LocaleCompare(keyword,"geometry") == 0)
5510 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5513 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5519 if (LocaleCompare(keyword,"x") == 0)
5521 x = StringToLong( value );
5524 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5530 if (LocaleCompare(keyword,"y") == 0)
5532 y = StringToLong( value );
5535 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5540 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5553 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5554 if (newImage == (Image *) NULL)
5556 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5557 msl_info->image[n]=newImage;
5562 if (LocaleCompare((const char *) tag,"rotate") == 0)
5570 if (msl_info->image[n] == (Image *) NULL)
5572 ThrowMSLException(OptionError,"NoImagesDefined",
5573 (const char *) tag);
5576 if (attributes != (const xmlChar **) NULL)
5577 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5579 keyword=(const char *) attributes[i++];
5580 attribute=InterpretImageProperties(msl_info->image_info[n],
5581 msl_info->attributes[n],(const char *) attributes[i]);
5582 CloneString(&value,attribute);
5588 if (LocaleCompare(keyword,"degrees") == 0)
5590 geometry_info.rho=InterpretLocaleValue(value,
5594 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5601 if (LocaleCompare(keyword,"geometry") == 0)
5603 flags=ParseGeometry(value,&geometry_info);
5604 if ((flags & SigmaValue) == 0)
5605 geometry_info.sigma=1.0;
5608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5620 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5621 &msl_info->image[n]->exception);
5622 if (rotate_image == (Image *) NULL)
5624 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5625 msl_info->image[n]=rotate_image;
5628 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5630 /* init the values */
5633 if (msl_info->image[n] == (Image *) NULL)
5635 ThrowMSLException(OptionError,"NoImagesDefined",
5636 (const char *) tag);
5639 if (attributes == (const xmlChar **) NULL)
5641 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5643 keyword=(const char *) attributes[i++];
5644 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5645 msl_info->attributes[n],(const char *) attributes[i]));
5651 if (LocaleCompare(keyword,"degrees") == 0)
5653 degrees = InterpretLocaleValue(value,(char **) NULL);
5656 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5661 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5674 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5675 if (newImage == (Image *) NULL)
5677 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5678 msl_info->image[n]=newImage;
5683 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5688 if (LocaleCompare((const char *) tag,"sample") == 0)
5696 if (msl_info->image[n] == (Image *) NULL)
5698 ThrowMSLException(OptionError,"NoImagesDefined",
5699 (const char *) tag);
5702 if (attributes != (const xmlChar **) NULL)
5703 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5705 keyword=(const char *) attributes[i++];
5706 attribute=InterpretImageProperties(msl_info->image_info[n],
5707 msl_info->attributes[n],(const char *) attributes[i]);
5708 CloneString(&value,attribute);
5714 if (LocaleCompare(keyword,"geometry") == 0)
5716 flags=ParseRegionGeometry(msl_info->image[n],value,
5717 &geometry,&exception);
5720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5727 if (LocaleCompare(keyword,"height") == 0)
5729 geometry.height=StringToUnsignedLong(value);
5732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5739 if (LocaleCompare(keyword,"width") == 0)
5741 geometry.width=StringToLong(value);
5744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5750 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5756 sample_image=SampleImage(msl_info->image[n],geometry.width,
5757 geometry.height,&msl_info->image[n]->exception);
5758 if (sample_image == (Image *) NULL)
5760 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5761 msl_info->image[n]=sample_image;
5764 if (LocaleCompare((const char *) tag,"scale") == 0)
5772 if (msl_info->image[n] == (Image *) NULL)
5774 ThrowMSLException(OptionError,"NoImagesDefined",
5775 (const char *) tag);
5778 if (attributes != (const xmlChar **) NULL)
5779 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5781 keyword=(const char *) attributes[i++];
5782 attribute=InterpretImageProperties(msl_info->image_info[n],
5783 msl_info->attributes[n],(const char *) attributes[i]);
5784 CloneString(&value,attribute);
5790 if (LocaleCompare(keyword,"geometry") == 0)
5792 flags=ParseRegionGeometry(msl_info->image[n],value,
5793 &geometry,&exception);
5796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5803 if (LocaleCompare(keyword,"height") == 0)
5805 geometry.height=StringToUnsignedLong(value);
5808 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5815 if (LocaleCompare(keyword,"width") == 0)
5817 geometry.width=StringToLong(value);
5820 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5832 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5833 geometry.height,&msl_info->image[n]->exception);
5834 if (scale_image == (Image *) NULL)
5836 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5837 msl_info->image[n]=scale_image;
5840 if (LocaleCompare((const char *) tag,"segment") == 0)
5851 if (msl_info->image[n] == (Image *) NULL)
5853 ThrowMSLException(OptionError,"NoImagesDefined",
5854 (const char *) tag);
5857 geometry_info.rho=1.0;
5858 geometry_info.sigma=1.5;
5859 colorspace=RGBColorspace;
5860 verbose=MagickFalse;
5861 if (attributes != (const xmlChar **) NULL)
5862 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5864 keyword=(const char *) attributes[i++];
5865 attribute=InterpretImageProperties(msl_info->image_info[n],
5866 msl_info->attributes[n],(const char *) attributes[i]);
5867 CloneString(&value,attribute);
5873 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5875 geometry_info.rho=InterpretLocaleValue(value,
5879 if (LocaleCompare(keyword,"colorspace") == 0)
5881 option=ParseCommandOption(MagickColorspaceOptions,
5884 ThrowMSLException(OptionError,
5885 "UnrecognizedColorspaceType",value);
5886 colorspace=(ColorspaceType) option;
5889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5896 if (LocaleCompare(keyword,"geometry") == 0)
5898 flags=ParseGeometry(value,&geometry_info);
5899 if ((flags & SigmaValue) == 0)
5900 geometry_info.sigma=1.5;
5903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5910 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5912 geometry_info.sigma=InterpretLocaleValue(value,
5916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5928 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5929 geometry_info.rho,geometry_info.sigma);
5932 else if (LocaleCompare((const char *) tag, "set") == 0)
5934 if (msl_info->image[n] == (Image *) NULL)
5936 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5940 if (attributes == (const xmlChar **) NULL)
5942 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5944 keyword=(const char *) attributes[i++];
5945 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5946 msl_info->attributes[n],(const char *) attributes[i]));
5952 if (LocaleCompare(keyword,"clip-mask") == 0)
5954 for (j=0; j < msl_info->n; j++)
5959 property=GetImageProperty(msl_info->attributes[j],"id");
5960 if (LocaleCompare(property,value) == 0)
5962 SetImageMask(msl_info->image[n],msl_info->image[j]);
5968 if (LocaleCompare(keyword,"clip-path") == 0)
5970 for (j=0; j < msl_info->n; j++)
5975 property=GetImageProperty(msl_info->attributes[j],"id");
5976 if (LocaleCompare(property,value) == 0)
5978 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5984 if (LocaleCompare(keyword,"colorspace") == 0)
5989 colorspace=(ColorspaceType) ParseCommandOption(
5990 MagickColorspaceOptions,MagickFalse,value);
5992 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5994 (void) TransformImageColorspace(msl_info->image[n],
5995 (ColorspaceType) colorspace);
5998 (void) SetMSLAttributes(msl_info,keyword,value);
5999 (void) SetImageProperty(msl_info->image[n],keyword,value);
6005 if (LocaleCompare(keyword,"density") == 0)
6007 flags=ParseGeometry(value,&geometry_info);
6008 msl_info->image[n]->x_resolution=geometry_info.rho;
6009 msl_info->image[n]->y_resolution=geometry_info.sigma;
6010 if ((flags & SigmaValue) == 0)
6011 msl_info->image[n]->y_resolution=
6012 msl_info->image[n]->x_resolution;
6015 (void) SetMSLAttributes(msl_info,keyword,value);
6016 (void) SetImageProperty(msl_info->image[n],keyword,value);
6022 if (LocaleCompare(keyword, "opacity") == 0)
6024 ssize_t opac = OpaqueAlpha,
6025 len = (ssize_t) strlen( value );
6027 if (value[len-1] == '%') {
6029 (void) CopyMagickString(tmp,value,len);
6030 opac = StringToLong( tmp );
6031 opac = (int)(QuantumRange * ((float)opac/100));
6033 opac = StringToLong( value );
6034 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6037 (void) SetMSLAttributes(msl_info,keyword,value);
6038 (void) SetImageProperty(msl_info->image[n],keyword,value);
6044 if (LocaleCompare(keyword, "page") == 0)
6047 page[MaxTextExtent];
6058 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6059 image_option=GetImageOption(msl_info->image_info[n],"page");
6060 if (image_option != (const char *) NULL)
6061 flags=ParseAbsoluteGeometry(image_option,&geometry);
6062 flags=ParseAbsoluteGeometry(value,&geometry);
6063 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6064 (double) geometry.width,(double) geometry.height);
6065 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6066 (void) FormatLocaleString(page,MaxTextExtent,
6067 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6068 (double) geometry.height,(double) geometry.x,(double)
6070 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6071 msl_info->image_info[n]->page=GetPageGeometry(page);
6074 (void) SetMSLAttributes(msl_info,keyword,value);
6075 (void) SetImageProperty(msl_info->image[n],keyword,value);
6080 (void) SetMSLAttributes(msl_info,keyword,value);
6081 (void) SetImageProperty(msl_info->image[n],keyword,value);
6088 if (LocaleCompare((const char *) tag,"shade") == 0)
6099 if (msl_info->image[n] == (Image *) NULL)
6101 ThrowMSLException(OptionError,"NoImagesDefined",
6102 (const char *) tag);
6106 if (attributes != (const xmlChar **) NULL)
6107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6109 keyword=(const char *) attributes[i++];
6110 attribute=InterpretImageProperties(msl_info->image_info[n],
6111 msl_info->attributes[n],(const char *) attributes[i]);
6112 CloneString(&value,attribute);
6118 if (LocaleCompare(keyword,"azimuth") == 0)
6120 geometry_info.rho=InterpretLocaleValue(value,
6124 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6131 if (LocaleCompare(keyword,"elevation") == 0)
6133 geometry_info.sigma=InterpretLocaleValue(value,
6137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6144 if (LocaleCompare(keyword,"geometry") == 0)
6146 flags=ParseGeometry(value,&geometry_info);
6147 if ((flags & SigmaValue) == 0)
6148 geometry_info.sigma=1.0;
6151 if (LocaleCompare(keyword,"gray") == 0)
6153 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6156 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6158 gray=(MagickBooleanType) option;
6161 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6167 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6173 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6174 geometry_info.sigma,&msl_info->image[n]->exception);
6175 if (shade_image == (Image *) NULL)
6177 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6178 msl_info->image[n]=shade_image;
6181 if (LocaleCompare((const char *) tag,"shadow") == 0)
6189 if (msl_info->image[n] == (Image *) NULL)
6191 ThrowMSLException(OptionError,"NoImagesDefined",
6192 (const char *) tag);
6195 if (attributes != (const xmlChar **) NULL)
6196 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6198 keyword=(const char *) attributes[i++];
6199 attribute=InterpretImageProperties(msl_info->image_info[n],
6200 msl_info->attributes[n],(const char *) attributes[i]);
6201 CloneString(&value,attribute);
6207 if (LocaleCompare(keyword,"geometry") == 0)
6209 flags=ParseGeometry(value,&geometry_info);
6210 if ((flags & SigmaValue) == 0)
6211 geometry_info.sigma=1.0;
6214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6221 if (LocaleCompare(keyword,"opacity") == 0)
6223 geometry_info.rho=StringToLong(value);
6226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6233 if (LocaleCompare(keyword,"sigma") == 0)
6235 geometry_info.sigma=StringToLong(value);
6243 if (LocaleCompare(keyword,"x") == 0)
6245 geometry_info.xi=InterpretLocaleValue(value,
6249 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6256 if (LocaleCompare(keyword,"y") == 0)
6258 geometry_info.psi=StringToLong(value);
6261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6267 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6273 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6274 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6275 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6276 if (shadow_image == (Image *) NULL)
6278 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6279 msl_info->image[n]=shadow_image;
6282 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6284 double radius = 0.0,
6287 if (msl_info->image[n] == (Image *) NULL)
6289 ThrowMSLException(OptionError,"NoImagesDefined",
6290 (const char *) tag);
6294 NOTE: sharpen can have no attributes, since we use all the defaults!
6296 if (attributes != (const xmlChar **) NULL)
6298 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6300 keyword=(const char *) attributes[i++];
6301 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6302 msl_info->attributes[n],(const char *) attributes[i]));
6308 if (LocaleCompare(keyword, "radius") == 0)
6310 radius = InterpretLocaleValue(value,(char **) NULL);
6313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6319 if (LocaleCompare(keyword,"sigma") == 0)
6321 sigma = StringToLong( value );
6324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6329 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6343 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6344 if (newImage == (Image *) NULL)
6346 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6347 msl_info->image[n]=newImage;
6351 else if (LocaleCompare((const char *) tag,"shave") == 0)
6353 /* init the values */
6357 if (msl_info->image[n] == (Image *) NULL)
6359 ThrowMSLException(OptionError,"NoImagesDefined",
6360 (const char *) tag);
6363 if (attributes == (const xmlChar **) NULL)
6365 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6367 keyword=(const char *) attributes[i++];
6368 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6369 msl_info->attributes[n],(const char *) attributes[i]));
6375 if (LocaleCompare(keyword,"geometry") == 0)
6377 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6380 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6386 if (LocaleCompare(keyword,"height") == 0)
6388 height = StringToLong( value );
6391 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6397 if (LocaleCompare(keyword,"width") == 0)
6399 width = StringToLong( value );
6402 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6407 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6422 rectInfo.height = height;
6423 rectInfo.width = width;
6428 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6429 &msl_info->image[n]->exception);
6430 if (newImage == (Image *) NULL)
6432 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6433 msl_info->image[n]=newImage;
6438 if (LocaleCompare((const char *) tag,"shear") == 0)
6446 if (msl_info->image[n] == (Image *) NULL)
6448 ThrowMSLException(OptionError,"NoImagesDefined",
6449 (const char *) tag);
6452 if (attributes != (const xmlChar **) NULL)
6453 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6455 keyword=(const char *) attributes[i++];
6456 attribute=InterpretImageProperties(msl_info->image_info[n],
6457 msl_info->attributes[n],(const char *) attributes[i]);
6458 CloneString(&value,attribute);
6464 if (LocaleCompare(keyword, "fill") == 0)
6466 (void) QueryColorDatabase(value,
6467 &msl_info->image[n]->background_color,&exception);
6470 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6477 if (LocaleCompare(keyword,"geometry") == 0)
6479 flags=ParseGeometry(value,&geometry_info);
6480 if ((flags & SigmaValue) == 0)
6481 geometry_info.sigma=1.0;
6484 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6491 if (LocaleCompare(keyword,"x") == 0)
6493 geometry_info.rho=InterpretLocaleValue(value,
6497 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6504 if (LocaleCompare(keyword,"y") == 0)
6506 geometry_info.sigma=StringToLong(value);
6509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6521 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6522 geometry_info.sigma,&msl_info->image[n]->exception);
6523 if (shear_image == (Image *) NULL)
6525 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6526 msl_info->image[n]=shear_image;
6529 if (LocaleCompare((const char *) tag,"signature") == 0)
6534 if (msl_info->image[n] == (Image *) NULL)
6536 ThrowMSLException(OptionError,"NoImagesDefined",
6537 (const char *) tag);
6540 if (attributes != (const xmlChar **) NULL)
6541 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6543 keyword=(const char *) attributes[i++];
6544 attribute=InterpretImageProperties(msl_info->image_info[n],
6545 msl_info->attributes[n],(const char *) attributes[i]);
6546 CloneString(&value,attribute);
6551 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6557 (void) SignatureImage(msl_info->image[n]);
6560 if (LocaleCompare((const char *) tag,"solarize") == 0)
6565 if (msl_info->image[n] == (Image *) NULL)
6567 ThrowMSLException(OptionError,"NoImagesDefined",
6568 (const char *) tag);
6571 geometry_info.rho=QuantumRange/2.0;
6572 if (attributes != (const xmlChar **) NULL)
6573 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6575 keyword=(const char *) attributes[i++];
6576 attribute=InterpretImageProperties(msl_info->image_info[n],
6577 msl_info->attributes[n],(const char *) attributes[i]);
6578 CloneString(&value,attribute);
6584 if (LocaleCompare(keyword,"geometry") == 0)
6586 flags=ParseGeometry(value,&geometry_info);
6589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6596 if (LocaleCompare(keyword,"threshold") == 0)
6598 geometry_info.rho=InterpretLocaleValue(value,
6602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6614 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6617 if (LocaleCompare((const char *) tag,"spread") == 0)
6625 if (msl_info->image[n] == (Image *) NULL)
6627 ThrowMSLException(OptionError,"NoImagesDefined",
6628 (const char *) tag);
6631 if (attributes != (const xmlChar **) NULL)
6632 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6634 keyword=(const char *) attributes[i++];
6635 attribute=InterpretImageProperties(msl_info->image_info[n],
6636 msl_info->attributes[n],(const char *) attributes[i]);
6637 CloneString(&value,attribute);
6643 if (LocaleCompare(keyword,"geometry") == 0)
6645 flags=ParseGeometry(value,&geometry_info);
6646 if ((flags & SigmaValue) == 0)
6647 geometry_info.sigma=1.0;
6650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6657 if (LocaleCompare(keyword,"radius") == 0)
6659 geometry_info.rho=InterpretLocaleValue(value,
6663 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6669 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6675 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6676 &msl_info->image[n]->exception);
6677 if (spread_image == (Image *) NULL)
6679 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6680 msl_info->image[n]=spread_image;
6683 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6686 watermark = (Image*)NULL;
6688 if (msl_info->image[n] == (Image *) NULL)
6690 ThrowMSLException(OptionError,"NoImagesDefined",
6691 (const char *) tag);
6694 if (attributes == (const xmlChar **) NULL)
6696 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6698 keyword=(const char *) attributes[i++];
6699 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6700 msl_info->attributes[n],(const char *) attributes[i]));
6706 if (LocaleCompare(keyword,"image") == 0)
6708 for (j=0; j<msl_info->n;j++)
6711 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6712 if (theAttr && LocaleCompare(theAttr, value) == 0)
6714 watermark = msl_info->image[j];
6720 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6725 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6734 if ( watermark != (Image*) NULL )
6739 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6740 if (newImage == (Image *) NULL)
6742 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6743 msl_info->image[n]=newImage;
6746 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6748 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6751 stereoImage = (Image*)NULL;
6753 if (msl_info->image[n] == (Image *) NULL)
6755 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6758 if (attributes == (const xmlChar **) NULL)
6760 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6762 keyword=(const char *) attributes[i++];
6763 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6764 msl_info->attributes[n],(const char *) attributes[i]));
6770 if (LocaleCompare(keyword,"image") == 0)
6772 for (j=0; j<msl_info->n;j++)
6775 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6776 if (theAttr && LocaleCompare(theAttr, value) == 0)
6778 stereoImage = msl_info->image[j];
6784 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6789 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6798 if ( stereoImage != (Image*) NULL )
6803 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6804 if (newImage == (Image *) NULL)
6806 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6807 msl_info->image[n]=newImage;
6810 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6812 if (LocaleCompare((const char *) tag,"swap") == 0)
6823 if (msl_info->image[n] == (Image *) NULL)
6825 ThrowMSLException(OptionError,"NoImagesDefined",
6826 (const char *) tag);
6831 if (attributes != (const xmlChar **) NULL)
6832 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6834 keyword=(const char *) attributes[i++];
6835 attribute=InterpretImageProperties(msl_info->image_info[n],
6836 msl_info->attributes[n],(const char *) attributes[i]);
6837 CloneString(&value,attribute);
6843 if (LocaleCompare(keyword,"indexes") == 0)
6845 flags=ParseGeometry(value,&geometry_info);
6846 index=(ssize_t) geometry_info.rho;
6847 if ((flags & SigmaValue) == 0)
6848 swap_index=(ssize_t) geometry_info.sigma;
6851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6866 p=GetImageFromList(msl_info->image[n],index);
6867 q=GetImageFromList(msl_info->image[n],swap_index);
6868 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6870 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6873 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6874 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6875 ReplaceImageInList(&q,swap);
6876 msl_info->image[n]=GetFirstImageInList(q);
6879 if (LocaleCompare((const char *) tag,"swirl") == 0)
6887 if (msl_info->image[n] == (Image *) NULL)
6889 ThrowMSLException(OptionError,"NoImagesDefined",
6890 (const char *) tag);
6893 if (attributes != (const xmlChar **) NULL)
6894 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6896 keyword=(const char *) attributes[i++];
6897 attribute=InterpretImageProperties(msl_info->image_info[n],
6898 msl_info->attributes[n],(const char *) attributes[i]);
6899 CloneString(&value,attribute);
6905 if (LocaleCompare(keyword,"degrees") == 0)
6907 geometry_info.rho=InterpretLocaleValue(value,
6911 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6918 if (LocaleCompare(keyword,"geometry") == 0)
6920 flags=ParseGeometry(value,&geometry_info);
6921 if ((flags & SigmaValue) == 0)
6922 geometry_info.sigma=1.0;
6925 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6931 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6937 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6938 &msl_info->image[n]->exception);
6939 if (swirl_image == (Image *) NULL)
6941 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6942 msl_info->image[n]=swirl_image;
6945 if (LocaleCompare((const char *) tag,"sync") == 0)
6950 if (msl_info->image[n] == (Image *) NULL)
6952 ThrowMSLException(OptionError,"NoImagesDefined",
6953 (const char *) tag);
6956 if (attributes != (const xmlChar **) NULL)
6957 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6959 keyword=(const char *) attributes[i++];
6960 attribute=InterpretImageProperties(msl_info->image_info[n],
6961 msl_info->attributes[n],(const char *) attributes[i]);
6962 CloneString(&value,attribute);
6967 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6973 (void) SyncImage(msl_info->image[n]);
6976 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6981 if (LocaleCompare((const char *) tag,"map") == 0)
6989 if (msl_info->image[n] == (Image *) NULL)
6991 ThrowMSLException(OptionError,"NoImagesDefined",
6992 (const char *) tag);
6995 texture_image=NewImageList();
6996 if (attributes != (const xmlChar **) NULL)
6997 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6999 keyword=(const char *) attributes[i++];
7000 attribute=InterpretImageProperties(msl_info->image_info[n],
7001 msl_info->attributes[n],(const char *) attributes[i]);
7002 CloneString(&value,attribute);
7008 if (LocaleCompare(keyword,"image") == 0)
7009 for (j=0; j < msl_info->n; j++)
7014 attribute=GetImageProperty(msl_info->attributes[j],"id");
7015 if ((attribute != (const char *) NULL) &&
7016 (LocaleCompare(attribute,value) == 0))
7018 texture_image=CloneImage(msl_info->image[j],0,0,
7019 MagickFalse,&exception);
7027 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7033 (void) TextureImage(msl_info->image[n],texture_image);
7034 texture_image=DestroyImage(texture_image);
7037 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7039 /* init the values */
7040 double threshold = 0;
7042 if (msl_info->image[n] == (Image *) NULL)
7044 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7047 if (attributes == (const xmlChar **) NULL)
7049 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7051 keyword=(const char *) attributes[i++];
7052 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7053 msl_info->attributes[n],(const char *) attributes[i]));
7059 if (LocaleCompare(keyword,"threshold") == 0)
7061 threshold = InterpretLocaleValue(value,(char **) NULL);
7064 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7069 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7079 BilevelImage(msl_info->image[n],threshold);
7083 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7085 if (msl_info->image[n] == (Image *) NULL)
7087 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7090 if (attributes == (const xmlChar **) NULL)
7092 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7094 keyword=(const char *) attributes[i++];
7095 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7096 msl_info->attributes[n],(const char *) attributes[i]));
7102 if (LocaleCompare(keyword,"color") == 0)
7107 (void) QueryMagickColor(value,&target,&exception);
7108 (void) TransparentPaintImage(msl_info->image[n],&target,
7109 TransparentAlpha,MagickFalse);
7112 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7117 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7124 else if (LocaleCompare((const char *) tag, "trim") == 0)
7126 if (msl_info->image[n] == (Image *) NULL)
7128 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7132 /* no attributes here */
7134 /* process the image */
7141 /* all zeros on a crop == trim edges! */
7142 rectInfo.height = rectInfo.width = 0;
7143 rectInfo.x = rectInfo.y = 0;
7145 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7146 if (newImage == (Image *) NULL)
7148 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7149 msl_info->image[n]=newImage;
7153 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7158 if (LocaleCompare((const char *) tag,"write") == 0)
7160 if (msl_info->image[n] == (Image *) NULL)
7162 ThrowMSLException(OptionError,"NoImagesDefined",
7163 (const char *) tag);
7166 if (attributes == (const xmlChar **) NULL)
7168 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7170 keyword=(const char *) attributes[i++];
7171 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7172 msl_info->attributes[n],(const char *) attributes[i]));
7178 if (LocaleCompare(keyword,"filename") == 0)
7180 (void) CopyMagickString(msl_info->image[n]->filename,value,
7184 (void) SetMSLAttributes(msl_info,keyword,value);
7188 (void) SetMSLAttributes(msl_info,keyword,value);
7196 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7200 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7204 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7208 if ( value != NULL )
7209 value=DestroyString(value);
7210 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7213 static void MSLEndElement(void *context,const xmlChar *tag)
7222 Called when the end of an element has been detected.
7224 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7226 msl_info=(MSLInfo *) context;
7233 if (LocaleCompare((const char *) tag,"comment") == 0 )
7235 (void) DeleteImageProperty(msl_info->image[n],"comment");
7236 if (msl_info->content == (char *) NULL)
7238 StripString(msl_info->content);
7239 (void) SetImageProperty(msl_info->image[n],"comment",
7248 if (LocaleCompare((const char *) tag, "group") == 0 )
7250 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7252 ssize_t i = (ssize_t)
7253 (msl_info->group_info[msl_info->number_groups-1].numImages);
7256 if (msl_info->image[msl_info->n] != (Image *) NULL)
7257 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7258 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7259 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7263 msl_info->number_groups--;
7270 if (LocaleCompare((const char *) tag, "image") == 0)
7271 MSLPopImage(msl_info);
7277 if (LocaleCompare((const char *) tag,"label") == 0 )
7279 (void) DeleteImageProperty(msl_info->image[n],"label");
7280 if (msl_info->content == (char *) NULL)
7282 StripString(msl_info->content);
7283 (void) SetImageProperty(msl_info->image[n],"label",
7292 if (LocaleCompare((const char *) tag, "msl") == 0 )
7295 This our base element.
7296 at the moment we don't do anything special
7297 but someday we might!
7305 if (msl_info->content != (char *) NULL)
7306 msl_info->content=DestroyString(msl_info->content);
7309 static void MSLCharacters(void *context,const xmlChar *c,int length)
7321 Receiving some characters from the parser.
7323 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7324 " SAX.characters(%s,%d)",c,length);
7325 msl_info=(MSLInfo *) context;
7326 if (msl_info->content != (char *) NULL)
7327 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7328 strlen(msl_info->content)+length+MaxTextExtent,
7329 sizeof(*msl_info->content));
7332 msl_info->content=(char *) NULL;
7333 if (~length >= (MaxTextExtent-1))
7334 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7335 sizeof(*msl_info->content));
7336 if (msl_info->content != (char *) NULL)
7337 *msl_info->content='\0';
7339 if (msl_info->content == (char *) NULL)
7341 p=msl_info->content+strlen(msl_info->content);
7342 for (i=0; i < length; i++)
7347 static void MSLReference(void *context,const xmlChar *name)
7356 Called when an entity reference is detected.
7358 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7359 " SAX.reference(%s)",name);
7360 msl_info=(MSLInfo *) context;
7361 parser=msl_info->parser;
7363 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7365 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7368 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7374 Receiving some ignorable whitespaces from the parser.
7376 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7377 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7378 msl_info=(MSLInfo *) context;
7382 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7383 const xmlChar *data)
7389 A processing instruction has been parsed.
7391 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7392 " SAX.processingInstruction(%s, %s)",
7394 msl_info=(MSLInfo *) context;
7398 static void MSLComment(void *context,const xmlChar *value)
7404 A comment has been parsed.
7406 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7407 " SAX.comment(%s)",value);
7408 msl_info=(MSLInfo *) context;
7412 static void MSLWarning(void *context,const char *format,...)
7416 reason[MaxTextExtent];
7425 Display and format a warning messages, gives file, line, position and
7428 va_start(operands,format);
7429 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7430 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7431 msl_info=(MSLInfo *) context;
7433 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7434 (void) vsprintf(reason,format,operands);
7436 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7438 message=GetExceptionMessage(errno);
7439 ThrowMSLException(CoderError,reason,message);
7440 message=DestroyString(message);
7444 static void MSLError(void *context,const char *format,...)
7447 reason[MaxTextExtent];
7456 Display and format a error formats, gives file, line, position and
7459 va_start(operands,format);
7460 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7461 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7462 msl_info=(MSLInfo *) context;
7464 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7465 (void) vsprintf(reason,format,operands);
7467 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7469 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7473 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7485 Called when a pcdata block has been parsed.
7487 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7488 " SAX.pcdata(%s, %d)",value,length);
7489 msl_info=(MSLInfo *) context;
7491 parser=msl_info->parser;
7492 child=xmlGetLastChild(parser->node);
7493 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7495 xmlTextConcat(child,value,length);
7498 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7501 static void MSLExternalSubset(void *context,const xmlChar *name,
7502 const xmlChar *external_id,const xmlChar *system_id)
7517 Does this document has an external subset?
7519 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7520 " SAX.externalSubset(%s %s %s)",name,
7521 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7522 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7523 msl_info=(MSLInfo *) context;
7525 parser=msl_info->parser;
7526 if (((external_id == NULL) && (system_id == NULL)) ||
7527 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7528 (msl_info->document == 0)))
7530 input=MSLResolveEntity(context,external_id,system_id);
7533 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7534 parser_context=(*parser);
7535 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7536 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7538 parser->errNo=XML_ERR_NO_MEMORY;
7539 parser->input=parser_context.input;
7540 parser->inputNr=parser_context.inputNr;
7541 parser->inputMax=parser_context.inputMax;
7542 parser->inputTab=parser_context.inputTab;
7548 xmlPushInput(parser,input);
7549 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7550 if (input->filename == (char *) NULL)
7551 input->filename=(char *) xmlStrdup(system_id);
7554 input->base=parser->input->cur;
7555 input->cur=parser->input->cur;
7557 xmlParseExternalSubset(parser,external_id,system_id);
7558 while (parser->inputNr > 1)
7559 (void) xmlPopInput(parser);
7560 xmlFreeInputStream(parser->input);
7561 xmlFree(parser->inputTab);
7562 parser->input=parser_context.input;
7563 parser->inputNr=parser_context.inputNr;
7564 parser->inputMax=parser_context.inputMax;
7565 parser->inputTab=parser_context.inputTab;
7568 #if defined(__cplusplus) || defined(c_plusplus)
7572 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7573 ExceptionInfo *exception)
7576 message[MaxTextExtent];
7599 assert(image_info != (const ImageInfo *) NULL);
7600 assert(image_info->signature == MagickSignature);
7601 if (image_info->debug != MagickFalse)
7602 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7603 image_info->filename);
7604 assert(image != (Image **) NULL);
7605 msl_image=AcquireImage(image_info);
7606 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7607 if (status == MagickFalse)
7609 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7610 msl_image->filename);
7611 msl_image=DestroyImageList(msl_image);
7612 return(MagickFalse);
7614 msl_image->columns=1;
7619 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7620 msl_info.exception=exception;
7621 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7622 sizeof(*msl_info.image_info));
7623 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7624 sizeof(*msl_info.draw_info));
7625 /* top of the stack is the MSL file itself */
7626 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7627 msl_info.attributes=(Image **) AcquireMagickMemory(
7628 sizeof(*msl_info.attributes));
7629 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7630 sizeof(*msl_info.group_info));
7631 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7632 (msl_info.image == (Image **) NULL) ||
7633 (msl_info.attributes == (Image **) NULL) ||
7634 (msl_info.group_info == (MSLGroupInfo *) NULL))
7635 ThrowFatalException(ResourceLimitFatalError,
7636 "UnableToInterpretMSLImage");
7637 *msl_info.image_info=CloneImageInfo(image_info);
7638 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7639 *msl_info.attributes=AcquireImage(image_info);
7640 msl_info.group_info[0].numImages=0;
7641 /* the first slot is used to point to the MSL file image */
7642 *msl_info.image=msl_image;
7643 if (*image != (Image *) NULL)
7644 MSLPushImage(&msl_info,*image);
7645 (void) xmlSubstituteEntitiesDefault(1);
7646 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7647 sax_modules.internalSubset=MSLInternalSubset;
7648 sax_modules.isStandalone=MSLIsStandalone;
7649 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7650 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7651 sax_modules.resolveEntity=MSLResolveEntity;
7652 sax_modules.getEntity=MSLGetEntity;
7653 sax_modules.entityDecl=MSLEntityDeclaration;
7654 sax_modules.notationDecl=MSLNotationDeclaration;
7655 sax_modules.attributeDecl=MSLAttributeDeclaration;
7656 sax_modules.elementDecl=MSLElementDeclaration;
7657 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7658 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7659 sax_modules.startDocument=MSLStartDocument;
7660 sax_modules.endDocument=MSLEndDocument;
7661 sax_modules.startElement=MSLStartElement;
7662 sax_modules.endElement=MSLEndElement;
7663 sax_modules.reference=MSLReference;
7664 sax_modules.characters=MSLCharacters;
7665 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7666 sax_modules.processingInstruction=MSLProcessingInstructions;
7667 sax_modules.comment=MSLComment;
7668 sax_modules.warning=MSLWarning;
7669 sax_modules.error=MSLError;
7670 sax_modules.fatalError=MSLError;
7671 sax_modules.getParameterEntity=MSLGetParameterEntity;
7672 sax_modules.cdataBlock=MSLCDataBlock;
7673 sax_modules.externalSubset=MSLExternalSubset;
7674 sax_handler=(&sax_modules);
7675 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7676 msl_image->filename);
7677 while (ReadBlobString(msl_image,message) != (char *) NULL)
7679 n=(ssize_t) strlen(message);
7682 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7685 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7686 if (msl_info.exception->severity >= ErrorException)
7689 if (msl_info.exception->severity == UndefinedException)
7690 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7691 xmlFreeParserCtxt(msl_info.parser);
7692 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7694 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7695 msl_info.group_info);
7696 if (*image == (Image *) NULL)
7697 *image=(*msl_info.image);
7698 if ((*msl_info.image)->exception.severity != UndefinedException)
7699 return(MagickFalse);
7703 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7711 assert(image_info != (const ImageInfo *) NULL);
7712 assert(image_info->signature == MagickSignature);
7713 if (image_info->debug != MagickFalse)
7714 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7715 image_info->filename);
7716 assert(exception != (ExceptionInfo *) NULL);
7717 assert(exception->signature == MagickSignature);
7718 image=(Image *) NULL;
7719 (void) ProcessMSLScript(image_info,&image,exception);
7720 return(GetFirstImageInList(image));
7725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7729 % R e g i s t e r M S L I m a g e %
7733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7735 % RegisterMSLImage() adds attributes for the MSL image format to
7736 % the list of supported formats. The attributes include the image format
7737 % tag, a method to read and/or write the format, whether the format
7738 % supports the saving of more than one frame to the same file or blob,
7739 % whether the format supports native in-memory I/O, and a brief
7740 % description of the format.
7742 % The format of the RegisterMSLImage method is:
7744 % size_t RegisterMSLImage(void)
7747 ModuleExport size_t RegisterMSLImage(void)
7752 entry=SetMagickInfo("MSL");
7753 #if defined(MAGICKCORE_XML_DELEGATE)
7754 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7755 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7757 entry->description=ConstantString("Magick Scripting Language");
7758 entry->module=ConstantString("MSL");
7759 (void) RegisterMagickInfo(entry);
7760 return(MagickImageCoderSignature);
7763 #if defined(MAGICKCORE_XML_DELEGATE)
7765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7769 % S e t M S L A t t r i b u t e s %
7773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7775 % SetMSLAttributes() ...
7777 % The format of the SetMSLAttributes method is:
7779 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7780 % const char *keyword,const char *value)
7782 % A description of each parameter follows:
7784 % o msl_info: the MSL info.
7786 % o keyword: the keyword.
7788 % o value: the value.
7791 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7818 assert(msl_info != (MSLInfo *) NULL);
7819 if (keyword == (const char *) NULL)
7821 if (value == (const char *) NULL)
7823 exception=msl_info->exception;
7825 attributes=msl_info->attributes[n];
7826 image_info=msl_info->image_info[n];
7827 draw_info=msl_info->draw_info[n];
7828 image=msl_info->image[n];
7834 if (LocaleCompare(keyword,"adjoin") == 0)
7839 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7841 ThrowMSLException(OptionError,"UnrecognizedType",value);
7842 image_info->adjoin=(MagickBooleanType) adjoin;
7845 if (LocaleCompare(keyword,"alpha") == 0)
7850 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7852 ThrowMSLException(OptionError,"UnrecognizedType",value);
7853 if (image != (Image *) NULL)
7854 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7858 if (LocaleCompare(keyword,"antialias") == 0)
7863 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7865 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7866 image_info->antialias=(MagickBooleanType) antialias;
7869 if (LocaleCompare(keyword,"area-limit") == 0)
7874 limit=MagickResourceInfinity;
7875 if (LocaleCompare(value,"unlimited") != 0)
7876 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7877 (void) SetMagickResourceLimit(AreaResource,limit);
7880 if (LocaleCompare(keyword,"attenuate") == 0)
7882 (void) SetImageOption(image_info,keyword,value);
7885 if (LocaleCompare(keyword,"authenticate") == 0)
7887 (void) CloneString(&image_info->density,value);
7890 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7896 if (LocaleCompare(keyword,"background") == 0)
7898 (void) QueryColorDatabase(value,&image_info->background_color,
7902 if (LocaleCompare(keyword,"bias") == 0)
7904 if (image == (Image *) NULL)
7906 image->bias=SiPrefixToDouble(value,QuantumRange);
7909 if (LocaleCompare(keyword,"blue-primary") == 0)
7911 if (image == (Image *) NULL)
7913 flags=ParseGeometry(value,&geometry_info);
7914 image->chromaticity.blue_primary.x=geometry_info.rho;
7915 image->chromaticity.blue_primary.y=geometry_info.sigma;
7916 if ((flags & SigmaValue) == 0)
7917 image->chromaticity.blue_primary.y=
7918 image->chromaticity.blue_primary.x;
7921 if (LocaleCompare(keyword,"bordercolor") == 0)
7923 (void) QueryColorDatabase(value,&image_info->border_color,
7927 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7933 if (LocaleCompare(keyword,"density") == 0)
7935 (void) CloneString(&image_info->density,value);
7936 (void) CloneString(&draw_info->density,value);
7939 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7945 if (LocaleCompare(keyword,"fill") == 0)
7947 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7948 (void) SetImageOption(image_info,keyword,value);
7951 if (LocaleCompare(keyword,"filename") == 0)
7953 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7956 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7962 if (LocaleCompare(keyword,"gravity") == 0)
7967 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7969 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7970 (void) SetImageOption(image_info,keyword,value);
7973 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7979 if (LocaleCompare(keyword,"id") == 0)
7981 (void) SetImageProperty(attributes,keyword,value);
7984 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7990 if (LocaleCompare(keyword,"magick") == 0)
7992 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7995 if (LocaleCompare(keyword,"mattecolor") == 0)
7997 (void) QueryColorDatabase(value,&image_info->matte_color,
8001 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8007 if (LocaleCompare(keyword,"pointsize") == 0)
8009 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8010 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8013 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8019 if (LocaleCompare(keyword,"quality") == 0)
8021 image_info->quality=StringToLong(value);
8022 if (image == (Image *) NULL)
8024 image->quality=StringToLong(value);
8032 if (LocaleCompare(keyword,"size") == 0)
8034 (void) CloneString(&image_info->size,value);
8037 if (LocaleCompare(keyword,"stroke") == 0)
8039 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8040 (void) SetImageOption(image_info,keyword,value);
8043 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8048 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8061 % U n r e g i s t e r M S L I m a g e %
8065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8067 % UnregisterMSLImage() removes format registrations made by the
8068 % MSL module from the list of supported formats.
8070 % The format of the UnregisterMSLImage method is:
8072 % UnregisterMSLImage(void)
8075 ModuleExport void UnregisterMSLImage(void)
8077 (void) UnregisterMagickInfo("MSL");
8080 #if defined(MAGICKCORE_XML_DELEGATE)
8082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8086 % W r i t e M S L I m a g e %
8090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8092 % WriteMSLImage() writes an image to a file in MVG image format.
8094 % The format of the WriteMSLImage method is:
8096 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8098 % A description of each parameter follows.
8100 % o image_info: the image info.
8102 % o image: The image.
8105 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8107 assert(image_info != (const ImageInfo *) NULL);
8108 assert(image_info->signature == MagickSignature);
8109 assert(image != (Image *) NULL);
8110 assert(image->signature == MagickSignature);
8111 if (image->debug != MagickFalse)
8112 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8113 (void) ReferenceImage(image);
8114 (void) ProcessMSLScript(image_info,&image,&image->exception);