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/color-private.h"
53 #include "MagickCore/colormap.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 *,ExceptionInfo *);
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],
575 msl_info->exception);
577 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
578 msl_info->exception);
579 msl_info->image[n]=(Image *) image;
580 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
581 (msl_info->attributes[n] == (Image *) NULL))
582 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
583 if (msl_info->number_groups != 0)
584 msl_info->group_info[msl_info->number_groups-1].numImages++;
587 static void MSLPopImage(MSLInfo *msl_info)
589 if (msl_info->number_groups != 0)
591 if (msl_info->image[msl_info->n] != (Image *) NULL)
592 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
593 msl_info->attributes[msl_info->n]=DestroyImage(
594 msl_info->attributes[msl_info->n]);
595 msl_info->image_info[msl_info->n]=DestroyImageInfo(
596 msl_info->image_info[msl_info->n]);
600 static void MSLStartElement(void *context,const xmlChar *tag,
601 const xmlChar **attributes)
660 Called when an opening tag has been processed.
662 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
663 " SAX.startElement(%s",tag);
664 GetExceptionInfo(&exception);
665 msl_info=(MSLInfo *) context;
667 keyword=(const char *) NULL;
669 SetGeometryInfo(&geometry_info);
670 channel=DefaultChannels;
676 if (LocaleCompare((const char *) tag,"add-noise") == 0)
687 if (msl_info->image[n] == (Image *) NULL)
689 ThrowMSLException(OptionError,"NoImagesDefined",
694 if (attributes != (const xmlChar **) NULL)
695 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
697 keyword=(const char *) attributes[i++];
698 attribute=InterpretImageProperties(msl_info->image_info[n],
699 msl_info->attributes[n],(const char *) attributes[i],
701 CloneString(&value,attribute);
707 if (LocaleCompare(keyword,"channel") == 0)
709 option=ParseChannelOption(value);
711 ThrowMSLException(OptionError,"UnrecognizedChannelType",
713 channel=(ChannelType) option;
716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
723 if (LocaleCompare(keyword,"noise") == 0)
725 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
728 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
730 noise=(NoiseType) option;
733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
745 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
746 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
747 msl_info->exception);
748 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
749 if (noise_image == (Image *) NULL)
751 msl_info->image[n]=DestroyImage(msl_info->image[n]);
752 msl_info->image[n]=noise_image;
755 if (LocaleCompare((const char *) tag,"annotate") == 0)
763 if (msl_info->image[n] == (Image *) NULL)
765 ThrowMSLException(OptionError,"NoImagesDefined",
769 draw_info=CloneDrawInfo(msl_info->image_info[n],
770 msl_info->draw_info[n]);
772 current=draw_info->affine;
773 GetAffineMatrix(&affine);
774 if (attributes != (const xmlChar **) NULL)
775 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
777 keyword=(const char *) attributes[i++];
778 attribute=InterpretImageProperties(msl_info->image_info[n],
779 msl_info->attributes[n],(const char *) attributes[i],
781 CloneString(&value,attribute);
787 if (LocaleCompare(keyword,"affine") == 0)
793 draw_info->affine.sx=StringToDouble(p,&p);
796 draw_info->affine.rx=StringToDouble(p,&p);
799 draw_info->affine.ry=StringToDouble(p,&p);
802 draw_info->affine.sy=StringToDouble(p,&p);
805 draw_info->affine.tx=StringToDouble(p,&p);
808 draw_info->affine.ty=StringToDouble(p,&p);
811 if (LocaleCompare(keyword,"align") == 0)
813 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
816 ThrowMSLException(OptionError,"UnrecognizedAlignType",
818 draw_info->align=(AlignType) option;
821 if (LocaleCompare(keyword,"antialias") == 0)
823 option=ParseCommandOption(MagickBooleanOptions,
826 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
828 draw_info->stroke_antialias=(MagickBooleanType) option;
829 draw_info->text_antialias=(MagickBooleanType) option;
832 ThrowMSLException(OptionError,"UnrecognizedAttribute",
839 if (LocaleCompare(keyword,"density") == 0)
841 CloneString(&draw_info->density,value);
844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
851 if (LocaleCompare(keyword,"encoding") == 0)
853 CloneString(&draw_info->encoding,value);
856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
863 if (LocaleCompare(keyword, "fill") == 0)
865 (void) QueryColorCompliance(value,AllCompliance,
866 &draw_info->fill,&exception);
869 if (LocaleCompare(keyword,"family") == 0)
871 CloneString(&draw_info->family,value);
874 if (LocaleCompare(keyword,"font") == 0)
876 CloneString(&draw_info->font,value);
879 ThrowMSLException(OptionError,"UnrecognizedAttribute",
886 if (LocaleCompare(keyword,"geometry") == 0)
888 flags=ParseGravityGeometry(msl_info->image[n],value,
889 &geometry,&exception);
892 if (LocaleCompare(keyword,"gravity") == 0)
894 option=ParseCommandOption(MagickGravityOptions,
897 ThrowMSLException(OptionError,"UnrecognizedGravityType",
899 draw_info->gravity=(GravityType) option;
902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
909 if (LocaleCompare(keyword,"pointsize") == 0)
911 draw_info->pointsize=StringToDouble(value,(char **) NULL);
914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
921 if (LocaleCompare(keyword,"rotate") == 0)
923 angle=StringToDouble(value,(char **) NULL);
924 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
925 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
926 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
927 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
937 if (LocaleCompare(keyword,"scale") == 0)
939 flags=ParseGeometry(value,&geometry_info);
940 if ((flags & SigmaValue) == 0)
941 geometry_info.sigma=1.0;
942 affine.sx=geometry_info.rho;
943 affine.sy=geometry_info.sigma;
946 if (LocaleCompare(keyword,"skewX") == 0)
948 angle=StringToDouble(value,(char **) NULL);
949 affine.ry=tan(DegreesToRadians(fmod((double) angle,
953 if (LocaleCompare(keyword,"skewY") == 0)
955 angle=StringToDouble(value,(char **) NULL);
956 affine.rx=tan(DegreesToRadians(fmod((double) angle,
960 if (LocaleCompare(keyword,"stretch") == 0)
962 option=ParseCommandOption(MagickStretchOptions,
965 ThrowMSLException(OptionError,"UnrecognizedStretchType",
967 draw_info->stretch=(StretchType) option;
970 if (LocaleCompare(keyword, "stroke") == 0)
972 (void) QueryColorCompliance(value,AllCompliance,
973 &draw_info->stroke,&exception);
976 if (LocaleCompare(keyword,"strokewidth") == 0)
978 draw_info->stroke_width=StringToLong(value);
981 if (LocaleCompare(keyword,"style") == 0)
983 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
986 ThrowMSLException(OptionError,"UnrecognizedStyleType",
988 draw_info->style=(StyleType) option;
991 ThrowMSLException(OptionError,"UnrecognizedAttribute",
998 if (LocaleCompare(keyword,"text") == 0)
1000 CloneString(&draw_info->text,value);
1003 if (LocaleCompare(keyword,"translate") == 0)
1005 flags=ParseGeometry(value,&geometry_info);
1006 if ((flags & SigmaValue) == 0)
1007 geometry_info.sigma=1.0;
1008 affine.tx=geometry_info.rho;
1009 affine.ty=geometry_info.sigma;
1012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1019 if (LocaleCompare(keyword, "undercolor") == 0)
1021 (void) QueryColorCompliance(value,AllCompliance,
1022 &draw_info->undercolor,&exception);
1025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1032 if (LocaleCompare(keyword,"weight") == 0)
1034 draw_info->weight=StringToLong(value);
1037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1044 if (LocaleCompare(keyword,"x") == 0)
1046 geometry.x=StringToLong(value);
1049 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1056 if (LocaleCompare(keyword,"y") == 0)
1058 geometry.y=StringToLong(value);
1061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1067 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1073 (void) FormatLocaleString(text,MaxTextExtent,
1074 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1075 geometry.height,(double) geometry.x,(double) geometry.y);
1076 CloneString(&draw_info->geometry,text);
1077 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1078 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1079 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1080 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1081 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1083 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1085 (void) AnnotateImage(msl_info->image[n],draw_info,
1086 msl_info->exception);
1087 draw_info=DestroyDrawInfo(draw_info);
1090 if (LocaleCompare((const char *) tag,"append") == 0)
1098 if (msl_info->image[n] == (Image *) NULL)
1100 ThrowMSLException(OptionError,"NoImagesDefined",
1101 (const char *) tag);
1105 if (attributes != (const xmlChar **) NULL)
1106 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1108 keyword=(const char *) attributes[i++];
1109 attribute=InterpretImageProperties(msl_info->image_info[n],
1110 msl_info->attributes[n],(const char *) attributes[i],
1112 CloneString(&value,attribute);
1118 if (LocaleCompare(keyword,"stack") == 0)
1120 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1123 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1125 stack=(MagickBooleanType) option;
1128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1140 append_image=AppendImages(msl_info->image[n],stack,
1141 msl_info->exception);
1142 if (append_image == (Image *) NULL)
1144 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1145 msl_info->image[n]=append_image;
1148 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1154 if (LocaleCompare((const char *) tag,"blur") == 0)
1162 if (msl_info->image[n] == (Image *) NULL)
1164 ThrowMSLException(OptionError,"NoImagesDefined",
1165 (const char *) tag);
1168 if (attributes != (const xmlChar **) NULL)
1169 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1171 keyword=(const char *) attributes[i++];
1172 attribute=InterpretImageProperties(msl_info->image_info[n],
1173 msl_info->attributes[n],(const char *) attributes[i],
1175 CloneString(&value,attribute);
1181 if (LocaleCompare(keyword,"channel") == 0)
1183 option=ParseChannelOption(value);
1185 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1187 channel=(ChannelType) option;
1190 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1197 if (LocaleCompare(keyword,"geometry") == 0)
1199 flags=ParseGeometry(value,&geometry_info);
1200 if ((flags & SigmaValue) == 0)
1201 geometry_info.sigma=1.0;
1204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1211 if (LocaleCompare(keyword,"radius") == 0)
1213 geometry_info.rho=StringToDouble(value,(char **) NULL);
1216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1223 if (LocaleCompare(keyword,"sigma") == 0)
1225 geometry_info.sigma=StringToLong(value);
1228 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1234 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1240 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1241 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1242 geometry_info.sigma,geometry_info.xi,
1243 msl_info->exception);
1244 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
1245 if (blur_image == (Image *) NULL)
1247 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1248 msl_info->image[n]=blur_image;
1251 if (LocaleCompare((const char *) tag,"border") == 0)
1259 if (msl_info->image[n] == (Image *) NULL)
1261 ThrowMSLException(OptionError,"NoImagesDefined",
1262 (const char *) tag);
1265 SetGeometry(msl_info->image[n],&geometry);
1266 if (attributes != (const xmlChar **) NULL)
1267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1269 keyword=(const char *) attributes[i++];
1270 attribute=InterpretImageProperties(msl_info->image_info[n],
1271 msl_info->attributes[n],(const char *) attributes[i],
1273 CloneString(&value,attribute);
1279 if (LocaleCompare(keyword,"compose") == 0)
1281 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1284 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1286 msl_info->image[n]->compose=(CompositeOperator) option;
1289 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1296 if (LocaleCompare(keyword, "fill") == 0)
1298 (void) QueryColorCompliance(value,AllCompliance,
1299 &msl_info->image[n]->border_color,&exception);
1302 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1309 if (LocaleCompare(keyword,"geometry") == 0)
1311 flags=ParsePageGeometry(msl_info->image[n],value,
1312 &geometry,&exception);
1313 if ((flags & HeightValue) == 0)
1314 geometry.height=geometry.width;
1317 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1324 if (LocaleCompare(keyword,"height") == 0)
1326 geometry.height=StringToLong(value);
1329 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1336 if (LocaleCompare(keyword,"width") == 0)
1338 geometry.width=StringToLong(value);
1341 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1347 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1353 border_image=BorderImage(msl_info->image[n],&geometry,
1354 msl_info->image[n]->compose,msl_info->exception);
1355 if (border_image == (Image *) NULL)
1357 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1358 msl_info->image[n]=border_image;
1361 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1366 if (LocaleCompare((const char *) tag,"colorize") == 0)
1369 blend[MaxTextExtent];
1380 if (msl_info->image[n] == (Image *) NULL)
1382 ThrowMSLException(OptionError,"NoImagesDefined",
1383 (const char *) tag);
1386 GetPixelInfo(msl_info->image[n],&target);
1387 (void) CopyMagickString(blend,"100",MaxTextExtent);
1388 if (attributes != (const xmlChar **) NULL)
1389 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1391 keyword=(const char *) attributes[i++];
1392 attribute=InterpretImageProperties(msl_info->image_info[n],
1393 msl_info->attributes[n],(const char *) attributes[i],
1395 CloneString(&value,attribute);
1401 if (LocaleCompare(keyword,"blend") == 0)
1403 (void) CopyMagickString(blend,value,MaxTextExtent);
1406 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1413 if (LocaleCompare(keyword,"fill") == 0)
1415 (void) QueryColorCompliance(value,AllCompliance,
1416 &target,msl_info->exception);
1419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1431 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1432 msl_info->exception);
1433 if (colorize_image == (Image *) NULL)
1435 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1436 msl_info->image[n]=colorize_image;
1439 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1445 if (msl_info->image[n] == (Image *) NULL)
1447 ThrowMSLException(OptionError,"NoImagesDefined",
1448 (const char *) tag);
1452 NOTE: charcoal can have no attributes, since we use all the defaults!
1454 if (attributes != (const xmlChar **) NULL)
1456 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1458 keyword=(const char *) attributes[i++];
1459 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1460 msl_info->attributes[n],(const char *) attributes[i],&exception));
1466 if (LocaleCompare(keyword, "bias") == 0)
1468 bias=StringToDouble(value,(char **) NULL);
1471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1477 if (LocaleCompare(keyword,"radius") == 0)
1479 radius=StringToDouble(value,(char **) NULL);
1482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1488 if (LocaleCompare(keyword,"sigma") == 0)
1490 sigma = StringToLong( value );
1493 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1498 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1512 newImage=CharcoalImage(msl_info->image[n],radius,sigma,bias,
1513 msl_info->exception);
1514 if (newImage == (Image *) NULL)
1516 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1517 msl_info->image[n]=newImage;
1521 if (LocaleCompare((const char *) tag,"chop") == 0)
1529 if (msl_info->image[n] == (Image *) NULL)
1531 ThrowMSLException(OptionError,"NoImagesDefined",
1532 (const char *) tag);
1535 SetGeometry(msl_info->image[n],&geometry);
1536 if (attributes != (const xmlChar **) NULL)
1537 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1539 keyword=(const char *) attributes[i++];
1540 attribute=InterpretImageProperties(msl_info->image_info[n],
1541 msl_info->attributes[n],(const char *) attributes[i],
1543 CloneString(&value,attribute);
1549 if (LocaleCompare(keyword,"geometry") == 0)
1551 flags=ParsePageGeometry(msl_info->image[n],value,
1552 &geometry,&exception);
1553 if ((flags & HeightValue) == 0)
1554 geometry.height=geometry.width;
1557 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1564 if (LocaleCompare(keyword,"height") == 0)
1566 geometry.height=StringToLong(value);
1569 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1576 if (LocaleCompare(keyword,"width") == 0)
1578 geometry.width=StringToLong(value);
1581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1588 if (LocaleCompare(keyword,"x") == 0)
1590 geometry.x=StringToLong(value);
1593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1600 if (LocaleCompare(keyword,"y") == 0)
1602 geometry.y=StringToLong(value);
1605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1611 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1617 chop_image=ChopImage(msl_info->image[n],&geometry,
1618 msl_info->exception);
1619 if (chop_image == (Image *) NULL)
1621 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1622 msl_info->image[n]=chop_image;
1625 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1634 Color floodfill image.
1636 if (msl_info->image[n] == (Image *) NULL)
1638 ThrowMSLException(OptionError,"NoImagesDefined",
1639 (const char *) tag);
1642 draw_info=CloneDrawInfo(msl_info->image_info[n],
1643 msl_info->draw_info[n]);
1644 SetGeometry(msl_info->image[n],&geometry);
1645 paint_method=FloodfillMethod;
1646 if (attributes != (const xmlChar **) NULL)
1647 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1649 keyword=(const char *) attributes[i++];
1650 attribute=InterpretImageProperties(msl_info->image_info[n],
1651 msl_info->attributes[n],(const char *) attributes[i],
1653 CloneString(&value,attribute);
1659 if (LocaleCompare(keyword,"bordercolor") == 0)
1661 (void) QueryColorCompliance(value,AllCompliance,
1662 &target,&exception);
1663 paint_method=FillToBorderMethod;
1666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1673 if (LocaleCompare(keyword,"fill") == 0)
1675 (void) QueryColorCompliance(value,AllCompliance,
1676 &draw_info->fill,&exception);
1679 if (LocaleCompare(keyword,"fuzz") == 0)
1681 msl_info->image[n]->fuzz=StringToDouble(value,
1685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1692 if (LocaleCompare(keyword,"geometry") == 0)
1694 flags=ParsePageGeometry(msl_info->image[n],value,
1695 &geometry,&exception);
1696 if ((flags & HeightValue) == 0)
1697 geometry.height=geometry.width;
1698 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1699 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1710 if (LocaleCompare(keyword,"x") == 0)
1712 geometry.x=StringToLong(value);
1713 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1714 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1725 if (LocaleCompare(keyword,"y") == 0)
1727 geometry.y=StringToLong(value);
1728 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1729 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1745 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1746 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1747 MagickFalse : MagickTrue,msl_info->exception);
1748 draw_info=DestroyDrawInfo(draw_info);
1751 if (LocaleCompare((const char *) tag,"comment") == 0)
1753 if (LocaleCompare((const char *) tag,"composite") == 0)
1756 composite_geometry[MaxTextExtent];
1768 if (msl_info->image[n] == (Image *) NULL)
1770 ThrowMSLException(OptionError,"NoImagesDefined",
1771 (const char *) tag);
1774 composite_image=NewImageList();
1775 compose=OverCompositeOp;
1776 if (attributes != (const xmlChar **) NULL)
1777 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1779 keyword=(const char *) attributes[i++];
1780 attribute=InterpretImageProperties(msl_info->image_info[n],
1781 msl_info->attributes[n],(const char *) attributes[i],
1783 CloneString(&value,attribute);
1789 if (LocaleCompare(keyword,"compose") == 0)
1791 option=ParseCommandOption(MagickComposeOptions,
1794 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1796 compose=(CompositeOperator) option;
1804 if (LocaleCompare(keyword,"image") == 0)
1805 for (j=0; j < msl_info->n; j++)
1810 attribute=GetImageProperty(msl_info->attributes[j],"id",
1812 if ((attribute != (const char *) NULL) &&
1813 (LocaleCompare(attribute,value) == 0))
1815 composite_image=CloneImage(msl_info->image[j],0,0,
1816 MagickFalse,&exception);
1826 if (composite_image == (Image *) NULL)
1828 rotate_image=NewImageList();
1829 SetGeometry(msl_info->image[n],&geometry);
1830 if (attributes != (const xmlChar **) NULL)
1831 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1833 keyword=(const char *) attributes[i++];
1834 attribute=InterpretImageProperties(msl_info->image_info[n],
1835 msl_info->attributes[n],(const char *) attributes[i],
1837 CloneString(&value,attribute);
1843 if (LocaleCompare(keyword,"blend") == 0)
1845 (void) SetImageArtifact(composite_image,
1846 "compose:args",value);
1849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1856 if (LocaleCompare(keyword,"channel") == 0)
1858 option=ParseChannelOption(value);
1860 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1862 channel=(ChannelType) option;
1865 if (LocaleCompare(keyword, "color") == 0)
1867 (void) QueryColorCompliance(value,AllCompliance,
1868 &composite_image->background_color,&exception);
1871 if (LocaleCompare(keyword,"compose") == 0)
1873 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1880 if (LocaleCompare(keyword,"geometry") == 0)
1882 flags=ParsePageGeometry(msl_info->image[n],value,
1883 &geometry,&exception);
1884 if ((flags & HeightValue) == 0)
1885 geometry.height=geometry.width;
1888 if (LocaleCompare(keyword,"gravity") == 0)
1890 option=ParseCommandOption(MagickGravityOptions,
1893 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1895 msl_info->image[n]->gravity=(GravityType) option;
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"image") == 0)
1907 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1914 if (LocaleCompare(keyword,"mask") == 0)
1915 for (j=0; j < msl_info->n; j++)
1920 attribute=GetImageProperty(msl_info->attributes[j],"id",
1922 if ((attribute != (const char *) NULL) &&
1923 (LocaleCompare(value,value) == 0))
1925 SetImageType(composite_image,TrueColorMatteType,
1927 (void) CompositeImage(composite_image,
1928 CopyOpacityCompositeOp,msl_info->image[j],0,0,
1933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1940 if (LocaleCompare(keyword,"opacity") == 0)
1955 opacity=StringToLong(value);
1956 if (compose != DissolveCompositeOp)
1958 (void) SetImageAlpha(composite_image,(Quantum)
1959 opacity,&exception);
1962 (void) SetImageArtifact(msl_info->image[n],
1963 "compose:args",value);
1964 if (composite_image->matte != MagickTrue)
1965 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1967 composite_view=AcquireCacheView(composite_image);
1968 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1970 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1971 (ssize_t) composite_image->columns,1,&exception);
1972 for (x=0; x < (ssize_t) composite_image->columns; x++)
1974 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1975 SetPixelAlpha(composite_image,
1976 ClampToQuantum(opacity),q);
1977 q+=GetPixelChannels(composite_image);
1979 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1982 composite_view=DestroyCacheView(composite_view);
1985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1992 if (LocaleCompare(keyword,"rotate") == 0)
1994 rotate_image=RotateImage(composite_image,
1995 StringToDouble(value,(char **) NULL),&exception);
1998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2005 if (LocaleCompare(keyword,"tile") == 0)
2010 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2013 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2015 tile=(MagickBooleanType) option;
2017 if (rotate_image != (Image *) NULL)
2018 (void) SetImageArtifact(rotate_image,
2019 "compose:outside-overlay","false");
2021 (void) SetImageArtifact(composite_image,
2022 "compose:outside-overlay","false");
2023 image=msl_info->image[n];
2024 height=composite_image->rows;
2025 width=composite_image->columns;
2026 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2027 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2029 if (rotate_image != (Image *) NULL)
2030 (void) CompositeImage(image,compose,rotate_image,
2033 (void) CompositeImage(image,compose,
2034 composite_image,x,y,&exception);
2036 if (rotate_image != (Image *) NULL)
2037 rotate_image=DestroyImage(rotate_image);
2040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2047 if (LocaleCompare(keyword,"x") == 0)
2049 geometry.x=StringToLong(value);
2052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2059 if (LocaleCompare(keyword,"y") == 0)
2061 geometry.y=StringToLong(value);
2064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2076 image=msl_info->image[n];
2077 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2078 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2079 (double) composite_image->rows,(double) geometry.x,(double)
2081 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2083 channel_mask=SetPixelChannelMask(image,channel);
2084 if (rotate_image == (Image *) NULL)
2085 CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
2092 geometry.x-=(ssize_t) (rotate_image->columns-
2093 composite_image->columns)/2;
2094 geometry.y-=(ssize_t) (rotate_image->rows-
2095 composite_image->rows)/2;
2096 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
2098 rotate_image=DestroyImage(rotate_image);
2100 (void) SetPixelChannelMask(image,channel_mask);
2101 composite_image=DestroyImage(composite_image);
2104 if (LocaleCompare((const char *) tag,"contrast") == 0)
2112 if (msl_info->image[n] == (Image *) NULL)
2114 ThrowMSLException(OptionError,"NoImagesDefined",
2115 (const char *) tag);
2118 sharpen=MagickFalse;
2119 if (attributes != (const xmlChar **) NULL)
2120 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2122 keyword=(const char *) attributes[i++];
2123 attribute=InterpretImageProperties(msl_info->image_info[n],
2124 msl_info->attributes[n],(const char *) attributes[i],
2126 CloneString(&value,attribute);
2132 if (LocaleCompare(keyword,"sharpen") == 0)
2134 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2137 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2139 sharpen=(MagickBooleanType) option;
2142 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2148 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2154 (void) ContrastImage(msl_info->image[n],sharpen,
2155 msl_info->exception);
2158 if (LocaleCompare((const char *) tag,"crop") == 0)
2166 if (msl_info->image[n] == (Image *) NULL)
2168 ThrowMSLException(OptionError,"NoImagesDefined",
2169 (const char *) tag);
2172 SetGeometry(msl_info->image[n],&geometry);
2173 if (attributes != (const xmlChar **) NULL)
2174 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2176 keyword=(const char *) attributes[i++];
2177 attribute=InterpretImageProperties(msl_info->image_info[n],
2178 msl_info->attributes[n],(const char *) attributes[i],
2180 CloneString(&value,attribute);
2186 if (LocaleCompare(keyword,"geometry") == 0)
2188 flags=ParseGravityGeometry(msl_info->image[n],value,
2189 &geometry,&exception);
2192 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2199 if (LocaleCompare(keyword,"height") == 0)
2201 geometry.height=StringToLong(value);
2204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2211 if (LocaleCompare(keyword,"width") == 0)
2213 geometry.width=StringToLong(value);
2216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2223 if (LocaleCompare(keyword,"x") == 0)
2225 geometry.x=StringToLong(value);
2228 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2235 if (LocaleCompare(keyword,"y") == 0)
2237 geometry.y=StringToLong(value);
2240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2252 crop_image=CropImage(msl_info->image[n],&geometry,
2253 msl_info->exception);
2254 if (crop_image == (Image *) NULL)
2256 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2257 msl_info->image[n]=crop_image;
2260 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2266 Cycle-colormap image.
2268 if (msl_info->image[n] == (Image *) NULL)
2270 ThrowMSLException(OptionError,"NoImagesDefined",
2271 (const char *) tag);
2275 if (attributes != (const xmlChar **) NULL)
2276 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2278 keyword=(const char *) attributes[i++];
2279 attribute=InterpretImageProperties(msl_info->image_info[n],
2280 msl_info->attributes[n],(const char *) attributes[i],
2282 CloneString(&value,attribute);
2288 if (LocaleCompare(keyword,"display") == 0)
2290 display=StringToLong(value);
2293 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2299 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2305 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2308 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2313 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2321 if (msl_info->image[n] == (Image *) NULL)
2323 ThrowMSLException(OptionError,"NoImagesDefined",
2324 (const char *) tag);
2327 if (attributes != (const xmlChar **) NULL)
2328 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2330 keyword=(const char *) attributes[i++];
2331 attribute=InterpretImageProperties(msl_info->image_info[n],
2332 msl_info->attributes[n],(const char *) attributes[i],
2334 CloneString(&value,attribute);
2335 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2337 despeckle_image=DespeckleImage(msl_info->image[n],
2338 msl_info->exception);
2339 if (despeckle_image == (Image *) NULL)
2341 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2342 msl_info->image[n]=despeckle_image;
2345 if (LocaleCompare((const char *) tag,"display") == 0)
2347 if (msl_info->image[n] == (Image *) NULL)
2349 ThrowMSLException(OptionError,"NoImagesDefined",
2350 (const char *) tag);
2353 if (attributes != (const xmlChar **) NULL)
2354 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2356 keyword=(const char *) attributes[i++];
2357 attribute=InterpretImageProperties(msl_info->image_info[n],
2358 msl_info->attributes[n],(const char *) attributes[i],
2360 CloneString(&value,attribute);
2365 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2371 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2372 msl_info->exception);
2375 if (LocaleCompare((const char *) tag,"draw") == 0)
2378 text[MaxTextExtent];
2383 if (msl_info->image[n] == (Image *) NULL)
2385 ThrowMSLException(OptionError,"NoImagesDefined",
2386 (const char *) tag);
2389 draw_info=CloneDrawInfo(msl_info->image_info[n],
2390 msl_info->draw_info[n]);
2392 current=draw_info->affine;
2393 GetAffineMatrix(&affine);
2394 if (attributes != (const xmlChar **) NULL)
2395 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2397 keyword=(const char *) attributes[i++];
2398 attribute=InterpretImageProperties(msl_info->image_info[n],
2399 msl_info->attributes[n],(const char *) attributes[i],
2401 CloneString(&value,attribute);
2407 if (LocaleCompare(keyword,"affine") == 0)
2413 draw_info->affine.sx=StringToDouble(p,&p);
2416 draw_info->affine.rx=StringToDouble(p,&p);
2419 draw_info->affine.ry=StringToDouble(p,&p);
2422 draw_info->affine.sy=StringToDouble(p,&p);
2425 draw_info->affine.tx=StringToDouble(p,&p);
2428 draw_info->affine.ty=StringToDouble(p,&p);
2431 if (LocaleCompare(keyword,"align") == 0)
2433 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2436 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2438 draw_info->align=(AlignType) option;
2441 if (LocaleCompare(keyword,"antialias") == 0)
2443 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2446 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2448 draw_info->stroke_antialias=(MagickBooleanType) option;
2449 draw_info->text_antialias=(MagickBooleanType) option;
2452 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2459 if (LocaleCompare(keyword,"density") == 0)
2461 CloneString(&draw_info->density,value);
2464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2471 if (LocaleCompare(keyword,"encoding") == 0)
2473 CloneString(&draw_info->encoding,value);
2476 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2483 if (LocaleCompare(keyword, "fill") == 0)
2485 (void) QueryColorCompliance(value,AllCompliance,
2486 &draw_info->fill,&exception);
2489 if (LocaleCompare(keyword,"family") == 0)
2491 CloneString(&draw_info->family,value);
2494 if (LocaleCompare(keyword,"font") == 0)
2496 CloneString(&draw_info->font,value);
2499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2506 if (LocaleCompare(keyword,"geometry") == 0)
2508 flags=ParsePageGeometry(msl_info->image[n],value,
2509 &geometry,&exception);
2510 if ((flags & HeightValue) == 0)
2511 geometry.height=geometry.width;
2514 if (LocaleCompare(keyword,"gravity") == 0)
2516 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2519 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2521 draw_info->gravity=(GravityType) option;
2524 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2531 if (LocaleCompare(keyword,"primitive") == 0)
2533 CloneString(&draw_info->primitive,value);
2536 if (LocaleCompare(keyword,"pointsize") == 0)
2538 draw_info->pointsize=StringToDouble(value,
2542 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2549 if (LocaleCompare(keyword,"rotate") == 0)
2551 angle=StringToDouble(value,(char **) NULL);
2552 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2553 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2554 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2555 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2565 if (LocaleCompare(keyword,"scale") == 0)
2567 flags=ParseGeometry(value,&geometry_info);
2568 if ((flags & SigmaValue) == 0)
2569 geometry_info.sigma=1.0;
2570 affine.sx=geometry_info.rho;
2571 affine.sy=geometry_info.sigma;
2574 if (LocaleCompare(keyword,"skewX") == 0)
2576 angle=StringToDouble(value,(char **) NULL);
2577 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2580 if (LocaleCompare(keyword,"skewY") == 0)
2582 angle=StringToDouble(value,(char **) NULL);
2583 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2586 if (LocaleCompare(keyword,"stretch") == 0)
2588 option=ParseCommandOption(MagickStretchOptions,
2591 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2593 draw_info->stretch=(StretchType) option;
2596 if (LocaleCompare(keyword, "stroke") == 0)
2598 (void) QueryColorCompliance(value,AllCompliance,
2599 &draw_info->stroke,&exception);
2602 if (LocaleCompare(keyword,"strokewidth") == 0)
2604 draw_info->stroke_width=StringToLong(value);
2607 if (LocaleCompare(keyword,"style") == 0)
2609 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2612 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2614 draw_info->style=(StyleType) option;
2617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2624 if (LocaleCompare(keyword,"text") == 0)
2626 CloneString(&draw_info->text,value);
2629 if (LocaleCompare(keyword,"translate") == 0)
2631 flags=ParseGeometry(value,&geometry_info);
2632 if ((flags & SigmaValue) == 0)
2633 geometry_info.sigma=1.0;
2634 affine.tx=geometry_info.rho;
2635 affine.ty=geometry_info.sigma;
2638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2645 if (LocaleCompare(keyword, "undercolor") == 0)
2647 (void) QueryColorCompliance(value,AllCompliance,
2648 &draw_info->undercolor,&exception);
2651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2658 if (LocaleCompare(keyword,"weight") == 0)
2660 draw_info->weight=StringToLong(value);
2663 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2670 if (LocaleCompare(keyword,"x") == 0)
2672 geometry.x=StringToLong(value);
2675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2682 if (LocaleCompare(keyword,"y") == 0)
2684 geometry.y=StringToLong(value);
2687 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2699 (void) FormatLocaleString(text,MaxTextExtent,
2700 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2701 geometry.height,(double) geometry.x,(double) geometry.y);
2702 CloneString(&draw_info->geometry,text);
2703 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2704 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2705 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2706 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2707 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2709 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2711 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2712 draw_info=DestroyDrawInfo(draw_info);
2715 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2720 if (LocaleCompare((const char *) tag,"edge") == 0)
2728 if (msl_info->image[n] == (Image *) NULL)
2730 ThrowMSLException(OptionError,"NoImagesDefined",
2731 (const char *) tag);
2734 if (attributes != (const xmlChar **) NULL)
2735 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2737 keyword=(const char *) attributes[i++];
2738 attribute=InterpretImageProperties(msl_info->image_info[n],
2739 msl_info->attributes[n],(const char *) attributes[i],
2741 CloneString(&value,attribute);
2747 if (LocaleCompare(keyword,"geometry") == 0)
2749 flags=ParseGeometry(value,&geometry_info);
2750 if ((flags & SigmaValue) == 0)
2751 geometry_info.sigma=1.0;
2754 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2761 if (LocaleCompare(keyword,"radius") == 0)
2763 geometry_info.rho=StringToDouble(value,(char **) NULL);
2766 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2778 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2779 geometry_info.sigma,msl_info->exception);
2780 if (edge_image == (Image *) NULL)
2782 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2783 msl_info->image[n]=edge_image;
2786 if (LocaleCompare((const char *) tag,"emboss") == 0)
2794 if (msl_info->image[n] == (Image *) NULL)
2796 ThrowMSLException(OptionError,"NoImagesDefined",
2797 (const char *) tag);
2800 if (attributes != (const xmlChar **) NULL)
2801 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2803 keyword=(const char *) attributes[i++];
2804 attribute=InterpretImageProperties(msl_info->image_info[n],
2805 msl_info->attributes[n],(const char *) attributes[i],
2807 CloneString(&value,attribute);
2813 if (LocaleCompare(keyword,"geometry") == 0)
2815 flags=ParseGeometry(value,&geometry_info);
2816 if ((flags & SigmaValue) == 0)
2817 geometry_info.sigma=1.0;
2820 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2827 if (LocaleCompare(keyword,"radius") == 0)
2829 geometry_info.rho=StringToDouble(value,
2833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2840 if (LocaleCompare(keyword,"sigma") == 0)
2842 geometry_info.sigma=StringToLong(value);
2845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2857 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2858 geometry_info.sigma,msl_info->exception);
2859 if (emboss_image == (Image *) NULL)
2861 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2862 msl_info->image[n]=emboss_image;
2865 if (LocaleCompare((const char *) tag,"enhance") == 0)
2873 if (msl_info->image[n] == (Image *) NULL)
2875 ThrowMSLException(OptionError,"NoImagesDefined",
2876 (const char *) tag);
2879 if (attributes != (const xmlChar **) NULL)
2880 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2882 keyword=(const char *) attributes[i++];
2883 attribute=InterpretImageProperties(msl_info->image_info[n],
2884 msl_info->attributes[n],(const char *) attributes[i],
2886 CloneString(&value,attribute);
2887 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2889 enhance_image=EnhanceImage(msl_info->image[n],
2890 msl_info->exception);
2891 if (enhance_image == (Image *) NULL)
2893 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2894 msl_info->image[n]=enhance_image;
2897 if (LocaleCompare((const char *) tag,"equalize") == 0)
2902 if (msl_info->image[n] == (Image *) NULL)
2904 ThrowMSLException(OptionError,"NoImagesDefined",
2905 (const char *) tag);
2908 if (attributes != (const xmlChar **) NULL)
2909 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2911 keyword=(const char *) attributes[i++];
2912 attribute=InterpretImageProperties(msl_info->image_info[n],
2913 msl_info->attributes[n],(const char *) attributes[i],
2915 CloneString(&value,attribute);
2920 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2926 (void) EqualizeImage(msl_info->image[n],
2927 msl_info->exception);
2930 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2935 if (LocaleCompare((const char *) tag, "flatten") == 0)
2937 if (msl_info->image[n] == (Image *) NULL)
2939 ThrowMSLException(OptionError,"NoImagesDefined",
2940 (const char *) tag);
2944 /* no attributes here */
2946 /* process the image */
2951 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2952 msl_info->exception);
2953 if (newImage == (Image *) NULL)
2955 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2956 msl_info->image[n]=newImage;
2960 if (LocaleCompare((const char *) tag,"flip") == 0)
2968 if (msl_info->image[n] == (Image *) NULL)
2970 ThrowMSLException(OptionError,"NoImagesDefined",
2971 (const char *) tag);
2974 if (attributes != (const xmlChar **) NULL)
2975 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2977 keyword=(const char *) attributes[i++];
2978 attribute=InterpretImageProperties(msl_info->image_info[n],
2979 msl_info->attributes[n],(const char *) attributes[i],
2981 CloneString(&value,attribute);
2982 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2984 flip_image=FlipImage(msl_info->image[n],
2985 msl_info->exception);
2986 if (flip_image == (Image *) NULL)
2988 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2989 msl_info->image[n]=flip_image;
2992 if (LocaleCompare((const char *) tag,"flop") == 0)
3000 if (msl_info->image[n] == (Image *) NULL)
3002 ThrowMSLException(OptionError,"NoImagesDefined",
3003 (const char *) tag);
3006 if (attributes != (const xmlChar **) NULL)
3007 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3009 keyword=(const char *) attributes[i++];
3010 attribute=InterpretImageProperties(msl_info->image_info[n],
3011 msl_info->attributes[n],(const char *) attributes[i],
3013 CloneString(&value,attribute);
3014 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3016 flop_image=FlopImage(msl_info->image[n],
3017 msl_info->exception);
3018 if (flop_image == (Image *) NULL)
3020 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3021 msl_info->image[n]=flop_image;
3024 if (LocaleCompare((const char *) tag,"frame") == 0)
3035 if (msl_info->image[n] == (Image *) NULL)
3037 ThrowMSLException(OptionError,"NoImagesDefined",
3038 (const char *) tag);
3041 SetGeometry(msl_info->image[n],&geometry);
3042 if (attributes != (const xmlChar **) NULL)
3043 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3045 keyword=(const char *) attributes[i++];
3046 attribute=InterpretImageProperties(msl_info->image_info[n],
3047 msl_info->attributes[n],(const char *) attributes[i],
3049 CloneString(&value,attribute);
3055 if (LocaleCompare(keyword,"compose") == 0)
3057 option=ParseCommandOption(MagickComposeOptions,
3060 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3062 msl_info->image[n]->compose=(CompositeOperator) option;
3065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3072 if (LocaleCompare(keyword, "fill") == 0)
3074 (void) QueryColorCompliance(value,AllCompliance,
3075 &msl_info->image[n]->matte_color,&exception);
3078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3085 if (LocaleCompare(keyword,"geometry") == 0)
3087 flags=ParsePageGeometry(msl_info->image[n],value,
3088 &geometry,&exception);
3089 if ((flags & HeightValue) == 0)
3090 geometry.height=geometry.width;
3091 frame_info.width=geometry.width;
3092 frame_info.height=geometry.height;
3093 frame_info.outer_bevel=geometry.x;
3094 frame_info.inner_bevel=geometry.y;
3097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3104 if (LocaleCompare(keyword,"height") == 0)
3106 frame_info.height=StringToLong(value);
3109 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3116 if (LocaleCompare(keyword,"inner") == 0)
3118 frame_info.inner_bevel=StringToLong(value);
3121 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3128 if (LocaleCompare(keyword,"outer") == 0)
3130 frame_info.outer_bevel=StringToLong(value);
3133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3140 if (LocaleCompare(keyword,"width") == 0)
3142 frame_info.width=StringToLong(value);
3145 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3151 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3157 frame_info.x=(ssize_t) frame_info.width;
3158 frame_info.y=(ssize_t) frame_info.height;
3159 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3160 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3161 frame_image=FrameImage(msl_info->image[n],&frame_info,
3162 msl_info->image[n]->compose,msl_info->exception);
3163 if (frame_image == (Image *) NULL)
3165 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3166 msl_info->image[n]=frame_image;
3169 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3174 if (LocaleCompare((const char *) tag,"gamma") == 0)
3177 gamma[MaxTextExtent];
3185 if (msl_info->image[n] == (Image *) NULL)
3187 ThrowMSLException(OptionError,"NoImagesDefined",
3188 (const char *) tag);
3191 channel=UndefinedChannel;
3196 if (attributes != (const xmlChar **) NULL)
3197 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3199 keyword=(const char *) attributes[i++];
3200 attribute=InterpretImageProperties(msl_info->image_info[n],
3201 msl_info->attributes[n],(const char *) attributes[i],
3203 CloneString(&value,attribute);
3209 if (LocaleCompare(keyword,"blue") == 0)
3211 pixel.blue=StringToDouble(value,(char **) NULL);
3214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3221 if (LocaleCompare(keyword,"channel") == 0)
3223 option=ParseChannelOption(value);
3225 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3227 channel=(ChannelType) option;
3230 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3237 if (LocaleCompare(keyword,"gamma") == 0)
3239 (void) CopyMagickString(gamma,value,MaxTextExtent);
3242 if (LocaleCompare(keyword,"green") == 0)
3244 pixel.green=StringToDouble(value,(char **) NULL);
3247 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3254 if (LocaleCompare(keyword,"red") == 0)
3256 pixel.red=StringToDouble(value,(char **) NULL);
3259 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3265 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3272 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3273 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3274 (void) GammaImage(msl_info->image[n],atof(gamma),
3275 msl_info->exception);
3278 else if (LocaleCompare((const char *) tag,"get") == 0)
3280 if (msl_info->image[n] == (Image *) NULL)
3282 ThrowMSLException(OptionError,"NoImagesDefined",
3283 (const char *) tag);
3286 if (attributes == (const xmlChar **) NULL)
3288 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3290 keyword=(const char *) attributes[i++];
3291 CloneString(&value,(const char *) attributes[i]);
3292 (void) CopyMagickString(key,value,MaxTextExtent);
3298 if (LocaleCompare(keyword,"height") == 0)
3300 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3301 (double) msl_info->image[n]->rows);
3302 (void) SetImageProperty(msl_info->attributes[n],key,value,
3306 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3311 if (LocaleCompare(keyword,"width") == 0)
3313 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3314 (double) msl_info->image[n]->columns);
3315 (void) SetImageProperty(msl_info->attributes[n],key,value,
3319 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3323 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3330 else if (LocaleCompare((const char *) tag, "group") == 0)
3332 msl_info->number_groups++;
3333 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3334 msl_info->group_info,msl_info->number_groups+1UL,
3335 sizeof(*msl_info->group_info));
3338 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3343 if (LocaleCompare((const char *) tag,"image") == 0)
3345 MSLPushImage(msl_info,(Image *) NULL);
3346 if (attributes == (const xmlChar **) NULL)
3348 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3350 keyword=(const char *) attributes[i++];
3351 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3352 msl_info->attributes[n],(const char *) attributes[i],&exception));
3358 if (LocaleCompare(keyword,"color") == 0)
3363 (void) CopyMagickString(msl_info->image_info[n]->filename,
3364 "xc:",MaxTextExtent);
3365 (void) ConcatenateMagickString(msl_info->image_info[n]->
3366 filename,value,MaxTextExtent);
3367 next_image=ReadImage(msl_info->image_info[n],&exception);
3368 CatchException(&exception);
3369 if (next_image == (Image *) NULL)
3371 if (msl_info->image[n] == (Image *) NULL)
3372 msl_info->image[n]=next_image;
3379 Link image into image list.
3381 p=msl_info->image[n];
3382 while (p->next != (Image *) NULL)
3383 p=GetNextImageInList(p);
3384 next_image->previous=p;
3389 (void) SetMSLAttributes(msl_info,keyword,value);
3394 (void) SetMSLAttributes(msl_info,keyword,value);
3401 if (LocaleCompare((const char *) tag,"implode") == 0)
3409 if (msl_info->image[n] == (Image *) NULL)
3411 ThrowMSLException(OptionError,"NoImagesDefined",
3412 (const char *) tag);
3415 if (attributes != (const xmlChar **) NULL)
3416 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3418 keyword=(const char *) attributes[i++];
3419 attribute=InterpretImageProperties(msl_info->image_info[n],
3420 msl_info->attributes[n],(const char *) attributes[i],
3422 CloneString(&value,attribute);
3428 if (LocaleCompare(keyword,"amount") == 0)
3430 geometry_info.rho=StringToDouble(value,
3434 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3441 if (LocaleCompare(keyword,"geometry") == 0)
3443 flags=ParseGeometry(value,&geometry_info);
3444 if ((flags & SigmaValue) == 0)
3445 geometry_info.sigma=1.0;
3448 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3454 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3460 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3461 msl_info->image[n]->interpolate,msl_info->exception);
3462 if (implode_image == (Image *) NULL)
3464 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3465 msl_info->image[n]=implode_image;
3468 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3473 if (LocaleCompare((const char *) tag,"label") == 0)
3475 if (LocaleCompare((const char *) tag, "level") == 0)
3478 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3480 if (msl_info->image[n] == (Image *) NULL)
3482 ThrowMSLException(OptionError,"NoImagesDefined",
3483 (const char *) tag);
3486 if (attributes == (const xmlChar **) NULL)
3488 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3490 keyword=(const char *) attributes[i++];
3491 CloneString(&value,(const char *) attributes[i]);
3492 (void) CopyMagickString(key,value,MaxTextExtent);
3498 if (LocaleCompare(keyword,"black") == 0)
3500 levelBlack = StringToDouble(value,(char **) NULL);
3503 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3509 if (LocaleCompare(keyword,"gamma") == 0)
3511 levelGamma = StringToDouble(value,(char **) NULL);
3514 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3520 if (LocaleCompare(keyword,"white") == 0)
3522 levelWhite = StringToDouble(value,(char **) NULL);
3525 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3530 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3537 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3538 msl_info->exception);
3545 if (LocaleCompare((const char *) tag,"magnify") == 0)
3553 if (msl_info->image[n] == (Image *) NULL)
3555 ThrowMSLException(OptionError,"NoImagesDefined",
3556 (const char *) tag);
3559 if (attributes != (const xmlChar **) NULL)
3560 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3562 keyword=(const char *) attributes[i++];
3563 attribute=InterpretImageProperties(msl_info->image_info[n],
3564 msl_info->attributes[n],(const char *) attributes[i],
3566 CloneString(&value,attribute);
3567 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3569 magnify_image=MagnifyImage(msl_info->image[n],
3570 msl_info->exception);
3571 if (magnify_image == (Image *) NULL)
3573 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3574 msl_info->image[n]=magnify_image;
3577 if (LocaleCompare((const char *) tag,"map") == 0)
3591 if (msl_info->image[n] == (Image *) NULL)
3593 ThrowMSLException(OptionError,"NoImagesDefined",
3594 (const char *) tag);
3597 affinity_image=NewImageList();
3599 if (attributes != (const xmlChar **) NULL)
3600 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3602 keyword=(const char *) attributes[i++];
3603 attribute=InterpretImageProperties(msl_info->image_info[n],
3604 msl_info->attributes[n],(const char *) attributes[i],
3606 CloneString(&value,attribute);
3612 if (LocaleCompare(keyword,"dither") == 0)
3614 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3617 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3619 dither=(MagickBooleanType) option;
3622 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3629 if (LocaleCompare(keyword,"image") == 0)
3630 for (j=0; j < msl_info->n; j++)
3635 attribute=GetImageProperty(msl_info->attributes[j],"id",
3637 if ((attribute != (const char *) NULL) &&
3638 (LocaleCompare(attribute,value) == 0))
3640 affinity_image=CloneImage(msl_info->image[j],0,0,
3641 MagickFalse,&exception);
3649 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3655 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3656 quantize_info->dither=dither;
3657 (void) RemapImages(quantize_info,msl_info->image[n],
3658 affinity_image,&exception);
3659 quantize_info=DestroyQuantizeInfo(quantize_info);
3660 affinity_image=DestroyImage(affinity_image);
3663 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3675 Matte floodfill image.
3678 if (msl_info->image[n] == (Image *) NULL)
3680 ThrowMSLException(OptionError,"NoImagesDefined",
3681 (const char *) tag);
3684 SetGeometry(msl_info->image[n],&geometry);
3685 paint_method=FloodfillMethod;
3686 if (attributes != (const xmlChar **) NULL)
3687 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3689 keyword=(const char *) attributes[i++];
3690 attribute=InterpretImageProperties(msl_info->image_info[n],
3691 msl_info->attributes[n],(const char *) attributes[i],
3693 CloneString(&value,attribute);
3699 if (LocaleCompare(keyword,"bordercolor") == 0)
3701 (void) QueryColorCompliance(value,AllCompliance,
3702 &target,&exception);
3703 paint_method=FillToBorderMethod;
3706 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3713 if (LocaleCompare(keyword,"fuzz") == 0)
3715 msl_info->image[n]->fuzz=StringToDouble(value,
3719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3726 if (LocaleCompare(keyword,"geometry") == 0)
3728 flags=ParsePageGeometry(msl_info->image[n],value,
3729 &geometry,&exception);
3730 if ((flags & HeightValue) == 0)
3731 geometry.height=geometry.width;
3732 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3733 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3744 if (LocaleCompare(keyword,"opacity") == 0)
3746 opacity=StringToDouble(value,(char **) NULL);
3749 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3756 if (LocaleCompare(keyword,"x") == 0)
3758 geometry.x=StringToLong(value);
3759 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3760 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3771 if (LocaleCompare(keyword,"y") == 0)
3773 geometry.y=StringToLong(value);
3774 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3775 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3785 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3791 draw_info=CloneDrawInfo(msl_info->image_info[n],
3792 msl_info->draw_info[n]);
3793 draw_info->fill.alpha=ClampToQuantum(opacity);
3794 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3795 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3796 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3797 MagickFalse : MagickTrue,msl_info->exception);
3798 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
3799 draw_info=DestroyDrawInfo(draw_info);
3802 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3808 Median-filter image.
3810 if (msl_info->image[n] == (Image *) NULL)
3812 ThrowMSLException(OptionError,"NoImagesDefined",
3813 (const char *) tag);
3816 if (attributes != (const xmlChar **) NULL)
3817 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3819 keyword=(const char *) attributes[i++];
3820 attribute=InterpretImageProperties(msl_info->image_info[n],
3821 msl_info->attributes[n],(const char *) attributes[i],
3823 CloneString(&value,attribute);
3829 if (LocaleCompare(keyword,"geometry") == 0)
3831 flags=ParseGeometry(value,&geometry_info);
3832 if ((flags & SigmaValue) == 0)
3833 geometry_info.sigma=1.0;
3836 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3843 if (LocaleCompare(keyword,"radius") == 0)
3845 geometry_info.rho=StringToDouble(value,
3849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3855 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3861 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3862 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3863 msl_info->exception);
3864 if (median_image == (Image *) NULL)
3866 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3867 msl_info->image[n]=median_image;
3870 if (LocaleCompare((const char *) tag,"minify") == 0)
3878 if (msl_info->image[n] == (Image *) NULL)
3880 ThrowMSLException(OptionError,"NoImagesDefined",
3881 (const char *) tag);
3884 if (attributes != (const xmlChar **) NULL)
3885 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3887 keyword=(const char *) attributes[i++];
3888 attribute=InterpretImageProperties(msl_info->image_info[n],
3889 msl_info->attributes[n],(const char *) attributes[i],
3891 CloneString(&value,attribute);
3892 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3894 minify_image=MinifyImage(msl_info->image[n],
3895 msl_info->exception);
3896 if (minify_image == (Image *) NULL)
3898 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3899 msl_info->image[n]=minify_image;
3902 if (LocaleCompare((const char *) tag,"msl") == 0 )
3904 if (LocaleCompare((const char *) tag,"modulate") == 0)
3907 modulate[MaxTextExtent];
3912 if (msl_info->image[n] == (Image *) NULL)
3914 ThrowMSLException(OptionError,"NoImagesDefined",
3915 (const char *) tag);
3918 geometry_info.rho=100.0;
3919 geometry_info.sigma=100.0;
3920 geometry_info.xi=100.0;
3921 if (attributes != (const xmlChar **) NULL)
3922 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3924 keyword=(const char *) attributes[i++];
3925 attribute=InterpretImageProperties(msl_info->image_info[n],
3926 msl_info->attributes[n],(const char *) attributes[i],
3928 CloneString(&value,attribute);
3934 if (LocaleCompare(keyword,"blackness") == 0)
3936 geometry_info.rho=StringToDouble(value,
3940 if (LocaleCompare(keyword,"brightness") == 0)
3942 geometry_info.rho=StringToDouble(value,
3946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3953 if (LocaleCompare(keyword,"factor") == 0)
3955 flags=ParseGeometry(value,&geometry_info);
3958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 if (LocaleCompare(keyword,"hue") == 0)
3967 geometry_info.xi=StringToDouble(value,
3971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3978 if (LocaleCompare(keyword,"lightness") == 0)
3980 geometry_info.rho=StringToDouble(value,
3984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3991 if (LocaleCompare(keyword,"saturation") == 0)
3993 geometry_info.sigma=StringToDouble(value,
3997 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4004 if (LocaleCompare(keyword,"whiteness") == 0)
4006 geometry_info.sigma=StringToDouble(value,
4010 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4016 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4022 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4023 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4024 (void) ModulateImage(msl_info->image[n],modulate,
4025 msl_info->exception);
4028 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4033 if (LocaleCompare((const char *) tag,"negate") == 0)
4041 if (msl_info->image[n] == (Image *) NULL)
4043 ThrowMSLException(OptionError,"NoImagesDefined",
4044 (const char *) tag);
4048 if (attributes != (const xmlChar **) NULL)
4049 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4051 keyword=(const char *) attributes[i++];
4052 attribute=InterpretImageProperties(msl_info->image_info[n],
4053 msl_info->attributes[n],(const char *) attributes[i],
4055 CloneString(&value,attribute);
4061 if (LocaleCompare(keyword,"channel") == 0)
4063 option=ParseChannelOption(value);
4065 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4067 channel=(ChannelType) option;
4070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4077 if (LocaleCompare(keyword,"gray") == 0)
4079 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4082 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4084 gray=(MagickBooleanType) option;
4087 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4093 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4099 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4100 (void) NegateImage(msl_info->image[n],gray,
4101 msl_info->exception);
4102 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4105 if (LocaleCompare((const char *) tag,"normalize") == 0)
4110 if (msl_info->image[n] == (Image *) NULL)
4112 ThrowMSLException(OptionError,"NoImagesDefined",
4113 (const char *) tag);
4116 if (attributes != (const xmlChar **) NULL)
4117 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4119 keyword=(const char *) attributes[i++];
4120 attribute=InterpretImageProperties(msl_info->image_info[n],
4121 msl_info->attributes[n],(const char *) attributes[i],
4123 CloneString(&value,attribute);
4129 if (LocaleCompare(keyword,"channel") == 0)
4131 option=ParseChannelOption(value);
4133 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4135 channel=(ChannelType) option;
4138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4150 (void) NormalizeImage(msl_info->image[n],
4151 msl_info->exception);
4154 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4159 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4167 if (msl_info->image[n] == (Image *) NULL)
4169 ThrowMSLException(OptionError,"NoImagesDefined",
4170 (const char *) tag);
4173 if (attributes != (const xmlChar **) NULL)
4174 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4176 keyword=(const char *) attributes[i++];
4177 attribute=InterpretImageProperties(msl_info->image_info[n],
4178 msl_info->attributes[n],(const char *) attributes[i],
4180 CloneString(&value,attribute);
4186 if (LocaleCompare(keyword,"geometry") == 0)
4188 flags=ParseGeometry(value,&geometry_info);
4189 if ((flags & SigmaValue) == 0)
4190 geometry_info.sigma=1.0;
4193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4200 if (LocaleCompare(keyword,"radius") == 0)
4202 geometry_info.rho=StringToDouble(value,
4206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4212 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4218 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4219 geometry_info.sigma,msl_info->exception);
4220 if (paint_image == (Image *) NULL)
4222 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4223 msl_info->image[n]=paint_image;
4226 if (LocaleCompare((const char *) tag,"opaque") == 0)
4235 if (msl_info->image[n] == (Image *) NULL)
4237 ThrowMSLException(OptionError,"NoImagesDefined",
4238 (const char *) tag);
4241 (void) QueryColorCompliance("none",AllCompliance,&target,
4243 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4245 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],
4252 CloneString(&value,attribute);
4258 if (LocaleCompare(keyword,"channel") == 0)
4260 option=ParseChannelOption(value);
4262 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4264 channel=(ChannelType) option;
4267 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4274 if (LocaleCompare(keyword,"fill") == 0)
4276 (void) QueryColorCompliance(value,AllCompliance,
4277 &fill_color,&exception);
4280 if (LocaleCompare(keyword,"fuzz") == 0)
4282 msl_info->image[n]->fuzz=StringToDouble(value,
4286 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4292 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4298 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4299 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4300 MagickFalse,msl_info->exception);
4301 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4304 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4309 if (LocaleCompare((const char *) tag,"print") == 0)
4311 if (attributes == (const xmlChar **) NULL)
4313 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4315 keyword=(const char *) attributes[i++];
4316 attribute=InterpretImageProperties(msl_info->image_info[n],
4317 msl_info->attributes[n],(const char *) attributes[i],
4319 CloneString(&value,attribute);
4325 if (LocaleCompare(keyword,"output") == 0)
4327 (void) FormatLocaleFile(stdout,"%s",value);
4330 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4335 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4342 if (LocaleCompare((const char *) tag, "profile") == 0)
4344 if (msl_info->image[n] == (Image *) NULL)
4346 ThrowMSLException(OptionError,"NoImagesDefined",
4347 (const char *) tag);
4350 if (attributes == (const xmlChar **) NULL)
4352 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4366 keyword=(const char *) attributes[i++];
4367 attribute=InterpretImageProperties(msl_info->image_info[n],
4368 msl_info->attributes[n],(const char *) attributes[i],
4370 CloneString(&value,attribute);
4371 if (*keyword == '+')
4374 Remove a profile from the image.
4376 (void) ProfileImage(msl_info->image[n],keyword,
4377 (const unsigned char *) NULL,0,&exception);
4381 Associate a profile with the image.
4383 profile_info=CloneImageInfo(msl_info->image_info[n]);
4384 profile=GetImageProfile(msl_info->image[n],"iptc");
4385 if (profile != (StringInfo *) NULL)
4386 profile_info->profile=(void *) CloneStringInfo(profile);
4387 profile_image=GetImageCache(profile_info,keyword,&exception);
4388 profile_info=DestroyImageInfo(profile_info);
4389 if (profile_image == (Image *) NULL)
4392 name[MaxTextExtent],
4393 filename[MaxTextExtent];
4401 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4402 (void) CopyMagickString(name,keyword,MaxTextExtent);
4403 for (p=filename; *p != '\0'; p++)
4404 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4405 (IsPathAccessible(keyword) == MagickFalse))
4411 Look for profile name (e.g. name:profile).
4413 (void) CopyMagickString(name,filename,(size_t)
4415 for (q=filename; *q != '\0'; q++)
4419 profile=FileToStringInfo(filename,~0UL,&exception);
4420 if (profile != (StringInfo *) NULL)
4422 (void) ProfileImage(msl_info->image[n],name,
4423 GetStringInfoDatum(profile),(size_t)
4424 GetStringInfoLength(profile),MagickFalse);
4425 profile=DestroyStringInfo(profile);
4429 ResetImageProfileIterator(profile_image);
4430 name=GetNextImageProfile(profile_image);
4431 while (name != (const char *) NULL)
4433 profile=GetImageProfile(profile_image,name);
4434 if (profile != (StringInfo *) NULL)
4435 (void) ProfileImage(msl_info->image[n],name,
4436 GetStringInfoDatum(profile),(size_t)
4437 GetStringInfoLength(profile),MagickFalse);
4438 name=GetNextImageProfile(profile_image);
4440 profile_image=DestroyImage(profile_image);
4444 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4449 if (LocaleCompare((const char *) tag,"quantize") == 0)
4457 if (msl_info->image[n] == (Image *) NULL)
4459 ThrowMSLException(OptionError,"NoImagesDefined",
4460 (const char *) tag);
4463 GetQuantizeInfo(&quantize_info);
4464 if (attributes != (const xmlChar **) NULL)
4465 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4467 keyword=(const char *) attributes[i++];
4468 attribute=InterpretImageProperties(msl_info->image_info[n],
4469 msl_info->attributes[n],(const char *) attributes[i],
4471 CloneString(&value,attribute);
4477 if (LocaleCompare(keyword,"colors") == 0)
4479 quantize_info.number_colors=StringToLong(value);
4482 if (LocaleCompare(keyword,"colorspace") == 0)
4484 option=ParseCommandOption(MagickColorspaceOptions,
4487 ThrowMSLException(OptionError,
4488 "UnrecognizedColorspaceType",value);
4489 quantize_info.colorspace=(ColorspaceType) option;
4492 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4499 if (LocaleCompare(keyword,"dither") == 0)
4501 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4504 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4506 quantize_info.dither=(MagickBooleanType) option;
4509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4516 if (LocaleCompare(keyword,"measure") == 0)
4518 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4521 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4523 quantize_info.measure_error=(MagickBooleanType) option;
4526 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4533 if (LocaleCompare(keyword,"treedepth") == 0)
4535 quantize_info.tree_depth=StringToLong(value);
4538 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4544 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4550 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4553 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4556 text[MaxTextExtent];
4567 draw_info=CloneDrawInfo(msl_info->image_info[n],
4568 msl_info->draw_info[n]);
4570 current=draw_info->affine;
4571 GetAffineMatrix(&affine);
4572 if (attributes != (const xmlChar **) NULL)
4573 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4575 keyword=(const char *) attributes[i++];
4576 attribute=InterpretImageProperties(msl_info->image_info[n],
4577 msl_info->attributes[n],(const char *) attributes[i],
4579 CloneString(&value,attribute);
4585 if (LocaleCompare(keyword,"affine") == 0)
4591 draw_info->affine.sx=StringToDouble(p,&p);
4594 draw_info->affine.rx=StringToDouble(p,&p);
4597 draw_info->affine.ry=StringToDouble(p,&p);
4600 draw_info->affine.sy=StringToDouble(p,&p);
4603 draw_info->affine.tx=StringToDouble(p,&p);
4606 draw_info->affine.ty=StringToDouble(p,&p);
4609 if (LocaleCompare(keyword,"align") == 0)
4611 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4614 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4616 draw_info->align=(AlignType) option;
4619 if (LocaleCompare(keyword,"antialias") == 0)
4621 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4624 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4626 draw_info->stroke_antialias=(MagickBooleanType) option;
4627 draw_info->text_antialias=(MagickBooleanType) option;
4630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4637 if (LocaleCompare(keyword,"density") == 0)
4639 CloneString(&draw_info->density,value);
4642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4649 if (LocaleCompare(keyword,"encoding") == 0)
4651 CloneString(&draw_info->encoding,value);
4654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4661 if (LocaleCompare(keyword, "fill") == 0)
4663 (void) QueryColorCompliance(value,AllCompliance,
4664 &draw_info->fill,&exception);
4667 if (LocaleCompare(keyword,"family") == 0)
4669 CloneString(&draw_info->family,value);
4672 if (LocaleCompare(keyword,"font") == 0)
4674 CloneString(&draw_info->font,value);
4677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4684 if (LocaleCompare(keyword,"geometry") == 0)
4686 flags=ParsePageGeometry(msl_info->image[n],value,
4687 &geometry,&exception);
4688 if ((flags & HeightValue) == 0)
4689 geometry.height=geometry.width;
4692 if (LocaleCompare(keyword,"gravity") == 0)
4694 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4697 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4699 draw_info->gravity=(GravityType) option;
4702 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4709 if (LocaleCompare(keyword,"pointsize") == 0)
4711 draw_info->pointsize=StringToDouble(value,
4715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4722 if (LocaleCompare(keyword,"rotate") == 0)
4724 angle=StringToDouble(value,(char **) NULL);
4725 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4726 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4727 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4728 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4738 if (LocaleCompare(keyword,"scale") == 0)
4740 flags=ParseGeometry(value,&geometry_info);
4741 if ((flags & SigmaValue) == 0)
4742 geometry_info.sigma=1.0;
4743 affine.sx=geometry_info.rho;
4744 affine.sy=geometry_info.sigma;
4747 if (LocaleCompare(keyword,"skewX") == 0)
4749 angle=StringToDouble(value,(char **) NULL);
4750 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4753 if (LocaleCompare(keyword,"skewY") == 0)
4755 angle=StringToDouble(value,(char **) NULL);
4756 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4759 if (LocaleCompare(keyword,"stretch") == 0)
4761 option=ParseCommandOption(MagickStretchOptions,
4764 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4766 draw_info->stretch=(StretchType) option;
4769 if (LocaleCompare(keyword, "stroke") == 0)
4771 (void) QueryColorCompliance(value,AllCompliance,
4772 &draw_info->stroke,&exception);
4775 if (LocaleCompare(keyword,"strokewidth") == 0)
4777 draw_info->stroke_width=StringToLong(value);
4780 if (LocaleCompare(keyword,"style") == 0)
4782 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4785 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4787 draw_info->style=(StyleType) option;
4790 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4797 if (LocaleCompare(keyword,"text") == 0)
4799 CloneString(&draw_info->text,value);
4802 if (LocaleCompare(keyword,"translate") == 0)
4804 flags=ParseGeometry(value,&geometry_info);
4805 if ((flags & SigmaValue) == 0)
4806 geometry_info.sigma=1.0;
4807 affine.tx=geometry_info.rho;
4808 affine.ty=geometry_info.sigma;
4811 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4818 if (LocaleCompare(keyword, "undercolor") == 0)
4820 (void) QueryColorCompliance(value,AllCompliance,
4821 &draw_info->undercolor,&exception);
4824 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4831 if (LocaleCompare(keyword,"weight") == 0)
4833 draw_info->weight=StringToLong(value);
4836 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4843 if (LocaleCompare(keyword,"x") == 0)
4845 geometry.x=StringToLong(value);
4848 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4855 if (LocaleCompare(keyword,"y") == 0)
4857 geometry.y=StringToLong(value);
4860 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4872 (void) FormatLocaleString(text,MaxTextExtent,
4873 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4874 geometry.height,(double) geometry.x,(double) geometry.y);
4875 CloneString(&draw_info->geometry,text);
4876 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4877 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4878 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4879 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4880 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4882 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4884 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4885 msl_info->exception);
4886 if (status != MagickFalse)
4891 image=msl_info->attributes[n];
4892 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4893 "%g",metrics.pixels_per_em.x);
4894 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4895 "%g",metrics.pixels_per_em.y);
4896 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4898 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4900 FormatImageProperty(image,"msl:font-metrics.width","%g",
4902 FormatImageProperty(image,"msl:font-metrics.height","%g",
4904 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4905 metrics.max_advance);
4906 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4908 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4910 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4912 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4914 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4916 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4919 draw_info=DestroyDrawInfo(draw_info);
4922 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4927 if (LocaleCompare((const char *) tag,"raise") == 0)
4935 if (msl_info->image[n] == (Image *) NULL)
4937 ThrowMSLException(OptionError,"NoImagesDefined",
4938 (const char *) tag);
4942 SetGeometry(msl_info->image[n],&geometry);
4943 if (attributes != (const xmlChar **) NULL)
4944 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4946 keyword=(const char *) attributes[i++];
4947 attribute=InterpretImageProperties(msl_info->image_info[n],
4948 msl_info->attributes[n],(const char *) attributes[i],
4950 CloneString(&value,attribute);
4956 if (LocaleCompare(keyword,"geometry") == 0)
4958 flags=ParsePageGeometry(msl_info->image[n],value,
4959 &geometry,&exception);
4960 if ((flags & HeightValue) == 0)
4961 geometry.height=geometry.width;
4964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4971 if (LocaleCompare(keyword,"height") == 0)
4973 geometry.height=StringToLong(value);
4976 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4983 if (LocaleCompare(keyword,"raise") == 0)
4985 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4988 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4990 raise=(MagickBooleanType) option;
4993 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5000 if (LocaleCompare(keyword,"width") == 0)
5002 geometry.width=StringToLong(value);
5005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5017 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5018 msl_info->exception);
5021 if (LocaleCompare((const char *) tag,"read") == 0)
5023 if (attributes == (const xmlChar **) NULL)
5025 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5027 keyword=(const char *) attributes[i++];
5028 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5029 msl_info->attributes[n],(const char *) attributes[i],&exception));
5035 if (LocaleCompare(keyword,"filename") == 0)
5040 (void) CopyMagickString(msl_info->image_info[n]->filename,
5041 value,MaxTextExtent);
5042 image=ReadImage(msl_info->image_info[n],&exception);
5043 CatchException(&exception);
5044 if (image == (Image *) NULL)
5046 AppendImageToList(&msl_info->image[n],image);
5049 (void) SetMSLAttributes(msl_info,keyword,value);
5054 (void) SetMSLAttributes(msl_info,keyword,value);
5061 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5069 if (msl_info->image[n] == (Image *) NULL)
5071 ThrowMSLException(OptionError,"NoImagesDefined",
5072 (const char *) tag);
5075 if (attributes != (const xmlChar **) NULL)
5076 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5078 keyword=(const char *) attributes[i++];
5079 attribute=InterpretImageProperties(msl_info->image_info[n],
5080 msl_info->attributes[n],(const char *) attributes[i],
5082 CloneString(&value,attribute);
5088 if (LocaleCompare(keyword,"geometry") == 0)
5090 flags=ParseGeometry(value,&geometry_info);
5091 if ((flags & SigmaValue) == 0)
5092 geometry_info.sigma=1.0;
5095 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5102 if (LocaleCompare(keyword,"radius") == 0)
5104 geometry_info.rho=StringToDouble(value,
5108 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5114 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5120 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5121 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5122 msl_info->exception);
5123 if (paint_image == (Image *) NULL)
5125 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5126 msl_info->image[n]=paint_image;
5129 else if (LocaleCompare((const char *) tag,"repage") == 0)
5131 /* init the values */
5132 width=msl_info->image[n]->page.width;
5133 height=msl_info->image[n]->page.height;
5134 x=msl_info->image[n]->page.x;
5135 y=msl_info->image[n]->page.y;
5137 if (msl_info->image[n] == (Image *) NULL)
5139 ThrowMSLException(OptionError,"NoImagesDefined",
5140 (const char *) tag);
5143 if (attributes == (const xmlChar **) NULL)
5145 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5147 keyword=(const char *) attributes[i++];
5148 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5149 msl_info->attributes[n],(const char *) attributes[i],&exception));
5155 if (LocaleCompare(keyword,"geometry") == 0)
5163 flags=ParseAbsoluteGeometry(value,&geometry);
5164 if ((flags & WidthValue) != 0)
5166 if ((flags & HeightValue) == 0)
5167 geometry.height=geometry.width;
5168 width=geometry.width;
5169 height=geometry.height;
5171 if ((flags & AspectValue) != 0)
5173 if ((flags & XValue) != 0)
5175 if ((flags & YValue) != 0)
5180 if ((flags & XValue) != 0)
5183 if ((width == 0) && (geometry.x > 0))
5184 width=msl_info->image[n]->columns+geometry.x;
5186 if ((flags & YValue) != 0)
5189 if ((height == 0) && (geometry.y > 0))
5190 height=msl_info->image[n]->rows+geometry.y;
5195 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5201 if (LocaleCompare(keyword,"height") == 0)
5203 height = StringToLong( value );
5206 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5212 if (LocaleCompare(keyword,"width") == 0)
5214 width = StringToLong( value );
5217 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5223 if (LocaleCompare(keyword,"x") == 0)
5225 x = StringToLong( value );
5228 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5234 if (LocaleCompare(keyword,"y") == 0)
5236 y = StringToLong( value );
5239 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5244 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5250 msl_info->image[n]->page.width=width;
5251 msl_info->image[n]->page.height=height;
5252 msl_info->image[n]->page.x=x;
5253 msl_info->image[n]->page.y=y;
5256 else if (LocaleCompare((const char *) tag,"resample") == 0)
5262 if (msl_info->image[n] == (Image *) NULL)
5264 ThrowMSLException(OptionError,"NoImagesDefined",
5265 (const char *) tag);
5268 if (attributes == (const xmlChar **) NULL)
5270 x_resolution=DefaultResolution;
5271 y_resolution=DefaultResolution;
5272 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5274 keyword=(const char *) attributes[i++];
5275 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5276 msl_info->attributes[n],(const char *) attributes[i],&exception));
5281 if (LocaleCompare(keyword,"blur") == 0)
5283 msl_info->image[n]->blur=StringToDouble(value,
5287 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5293 if (LocaleCompare(keyword,"geometry") == 0)
5298 flags=ParseGeometry(value,&geometry_info);
5299 if ((flags & SigmaValue) == 0)
5300 geometry_info.sigma*=geometry_info.rho;
5301 x_resolution=geometry_info.rho;
5302 y_resolution=geometry_info.sigma;
5305 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5311 if (LocaleCompare(keyword,"x-resolution") == 0)
5313 x_resolution=StringToDouble(value,(char **) NULL);
5316 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5322 if (LocaleCompare(keyword,"y-resolution") == 0)
5324 y_resolution=StringToDouble(value,(char **) NULL);
5327 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5332 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5348 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5350 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5351 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5352 msl_info->image[n]->resolution.x))+0.5);
5353 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5354 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5355 msl_info->image[n]->resolution.y))+0.5);
5356 resample_image=ResizeImage(msl_info->image[n],width,height,
5357 msl_info->image[n]->filter,msl_info->image[n]->blur,
5358 msl_info->exception);
5359 if (resample_image == (Image *) NULL)
5361 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5362 msl_info->image[n]=resample_image;
5366 if (LocaleCompare((const char *) tag,"resize") == 0)
5380 if (msl_info->image[n] == (Image *) NULL)
5382 ThrowMSLException(OptionError,"NoImagesDefined",
5383 (const char *) tag);
5386 filter=UndefinedFilter;
5388 if (attributes != (const xmlChar **) NULL)
5389 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5391 keyword=(const char *) attributes[i++];
5392 attribute=InterpretImageProperties(msl_info->image_info[n],
5393 msl_info->attributes[n],(const char *) attributes[i],
5395 CloneString(&value,attribute);
5401 if (LocaleCompare(keyword,"filter") == 0)
5403 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5406 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5408 filter=(FilterTypes) option;
5411 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5418 if (LocaleCompare(keyword,"geometry") == 0)
5420 flags=ParseRegionGeometry(msl_info->image[n],value,
5421 &geometry,&exception);
5424 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5431 if (LocaleCompare(keyword,"height") == 0)
5433 geometry.height=StringToUnsignedLong(value);
5436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5443 if (LocaleCompare(keyword,"support") == 0)
5445 blur=StringToDouble(value,(char **) NULL);
5448 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5455 if (LocaleCompare(keyword,"width") == 0)
5457 geometry.width=StringToLong(value);
5460 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5472 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5473 geometry.height,filter,blur,msl_info->exception);
5474 if (resize_image == (Image *) NULL)
5476 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5477 msl_info->image[n]=resize_image;
5480 if (LocaleCompare((const char *) tag,"roll") == 0)
5488 if (msl_info->image[n] == (Image *) NULL)
5490 ThrowMSLException(OptionError,"NoImagesDefined",
5491 (const char *) tag);
5494 SetGeometry(msl_info->image[n],&geometry);
5495 if (attributes != (const xmlChar **) NULL)
5496 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5498 keyword=(const char *) attributes[i++];
5499 attribute=InterpretImageProperties(msl_info->image_info[n],
5500 msl_info->attributes[n],(const char *) attributes[i],
5502 CloneString(&value,attribute);
5508 if (LocaleCompare(keyword,"geometry") == 0)
5510 flags=ParsePageGeometry(msl_info->image[n],value,
5511 &geometry,&exception);
5512 if ((flags & HeightValue) == 0)
5513 geometry.height=geometry.width;
5516 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5523 if (LocaleCompare(keyword,"x") == 0)
5525 geometry.x=StringToLong(value);
5528 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5535 if (LocaleCompare(keyword,"y") == 0)
5537 geometry.y=StringToLong(value);
5540 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5552 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5553 msl_info->exception);
5554 if (roll_image == (Image *) NULL)
5556 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5557 msl_info->image[n]=roll_image;
5560 else if (LocaleCompare((const char *) tag,"roll") == 0)
5562 /* init the values */
5563 width=msl_info->image[n]->columns;
5564 height=msl_info->image[n]->rows;
5567 if (msl_info->image[n] == (Image *) NULL)
5569 ThrowMSLException(OptionError,"NoImagesDefined",
5570 (const char *) tag);
5573 if (attributes == (const xmlChar **) NULL)
5575 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5577 keyword=(const char *) attributes[i++];
5578 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5579 msl_info->attributes[n],(const char *) attributes[i],&exception));
5585 if (LocaleCompare(keyword,"geometry") == 0)
5587 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5590 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5596 if (LocaleCompare(keyword,"x") == 0)
5598 x = StringToLong( value );
5601 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5607 if (LocaleCompare(keyword,"y") == 0)
5609 y = StringToLong( value );
5612 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5617 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5630 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5631 if (newImage == (Image *) NULL)
5633 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5634 msl_info->image[n]=newImage;
5639 if (LocaleCompare((const char *) tag,"rotate") == 0)
5647 if (msl_info->image[n] == (Image *) NULL)
5649 ThrowMSLException(OptionError,"NoImagesDefined",
5650 (const char *) tag);
5653 if (attributes != (const xmlChar **) NULL)
5654 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5656 keyword=(const char *) attributes[i++];
5657 attribute=InterpretImageProperties(msl_info->image_info[n],
5658 msl_info->attributes[n],(const char *) attributes[i],
5660 CloneString(&value,attribute);
5666 if (LocaleCompare(keyword,"degrees") == 0)
5668 geometry_info.rho=StringToDouble(value,
5672 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5679 if (LocaleCompare(keyword,"geometry") == 0)
5681 flags=ParseGeometry(value,&geometry_info);
5682 if ((flags & SigmaValue) == 0)
5683 geometry_info.sigma=1.0;
5686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5698 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5699 msl_info->exception);
5700 if (rotate_image == (Image *) NULL)
5702 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5703 msl_info->image[n]=rotate_image;
5706 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5708 /* init the values */
5711 if (msl_info->image[n] == (Image *) NULL)
5713 ThrowMSLException(OptionError,"NoImagesDefined",
5714 (const char *) tag);
5717 if (attributes == (const xmlChar **) NULL)
5719 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5721 keyword=(const char *) attributes[i++];
5722 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5723 msl_info->attributes[n],(const char *) attributes[i],&exception));
5729 if (LocaleCompare(keyword,"degrees") == 0)
5731 degrees = StringToDouble(value,(char **) NULL);
5734 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5739 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5752 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5753 if (newImage == (Image *) NULL)
5755 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5756 msl_info->image[n]=newImage;
5761 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5766 if (LocaleCompare((const char *) tag,"sample") == 0)
5774 if (msl_info->image[n] == (Image *) NULL)
5776 ThrowMSLException(OptionError,"NoImagesDefined",
5777 (const char *) tag);
5780 if (attributes != (const xmlChar **) NULL)
5781 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5783 keyword=(const char *) attributes[i++];
5784 attribute=InterpretImageProperties(msl_info->image_info[n],
5785 msl_info->attributes[n],(const char *) attributes[i],
5787 CloneString(&value,attribute);
5793 if (LocaleCompare(keyword,"geometry") == 0)
5795 flags=ParseRegionGeometry(msl_info->image[n],value,
5796 &geometry,&exception);
5799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5806 if (LocaleCompare(keyword,"height") == 0)
5808 geometry.height=StringToUnsignedLong(value);
5811 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5818 if (LocaleCompare(keyword,"width") == 0)
5820 geometry.width=StringToLong(value);
5823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5829 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5835 sample_image=SampleImage(msl_info->image[n],geometry.width,
5836 geometry.height,msl_info->exception);
5837 if (sample_image == (Image *) NULL)
5839 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5840 msl_info->image[n]=sample_image;
5843 if (LocaleCompare((const char *) tag,"scale") == 0)
5851 if (msl_info->image[n] == (Image *) NULL)
5853 ThrowMSLException(OptionError,"NoImagesDefined",
5854 (const char *) tag);
5857 if (attributes != (const xmlChar **) NULL)
5858 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5860 keyword=(const char *) attributes[i++];
5861 attribute=InterpretImageProperties(msl_info->image_info[n],
5862 msl_info->attributes[n],(const char *) attributes[i],
5864 CloneString(&value,attribute);
5870 if (LocaleCompare(keyword,"geometry") == 0)
5872 flags=ParseRegionGeometry(msl_info->image[n],value,
5873 &geometry,&exception);
5876 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5883 if (LocaleCompare(keyword,"height") == 0)
5885 geometry.height=StringToUnsignedLong(value);
5888 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5895 if (LocaleCompare(keyword,"width") == 0)
5897 geometry.width=StringToLong(value);
5900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5912 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5913 geometry.height,msl_info->exception);
5914 if (scale_image == (Image *) NULL)
5916 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5917 msl_info->image[n]=scale_image;
5920 if (LocaleCompare((const char *) tag,"segment") == 0)
5931 if (msl_info->image[n] == (Image *) NULL)
5933 ThrowMSLException(OptionError,"NoImagesDefined",
5934 (const char *) tag);
5937 geometry_info.rho=1.0;
5938 geometry_info.sigma=1.5;
5939 colorspace=RGBColorspace;
5940 verbose=MagickFalse;
5941 if (attributes != (const xmlChar **) NULL)
5942 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5944 keyword=(const char *) attributes[i++];
5945 attribute=InterpretImageProperties(msl_info->image_info[n],
5946 msl_info->attributes[n],(const char *) attributes[i],
5948 CloneString(&value,attribute);
5954 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5956 geometry_info.rho=StringToDouble(value,
5960 if (LocaleCompare(keyword,"colorspace") == 0)
5962 option=ParseCommandOption(MagickColorspaceOptions,
5965 ThrowMSLException(OptionError,
5966 "UnrecognizedColorspaceType",value);
5967 colorspace=(ColorspaceType) option;
5970 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5977 if (LocaleCompare(keyword,"geometry") == 0)
5979 flags=ParseGeometry(value,&geometry_info);
5980 if ((flags & SigmaValue) == 0)
5981 geometry_info.sigma=1.5;
5984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5991 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5993 geometry_info.sigma=StringToDouble(value,
5997 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6009 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
6010 geometry_info.rho,geometry_info.sigma,&exception);
6013 else if (LocaleCompare((const char *) tag, "set") == 0)
6015 if (msl_info->image[n] == (Image *) NULL)
6017 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6021 if (attributes == (const xmlChar **) NULL)
6023 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6025 keyword=(const char *) attributes[i++];
6026 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6027 msl_info->attributes[n],(const char *) attributes[i],&exception));
6033 if (LocaleCompare(keyword,"clip-mask") == 0)
6035 for (j=0; j < msl_info->n; j++)
6040 property=GetImageProperty(msl_info->attributes[j],"id",
6042 if (LocaleCompare(property,value) == 0)
6044 SetImageMask(msl_info->image[n],msl_info->image[j],
6051 if (LocaleCompare(keyword,"clip-path") == 0)
6053 for (j=0; j < msl_info->n; j++)
6058 property=GetImageProperty(msl_info->attributes[j],"id",
6060 if (LocaleCompare(property,value) == 0)
6062 SetImageClipMask(msl_info->image[n],msl_info->image[j],
6069 if (LocaleCompare(keyword,"colorspace") == 0)
6074 colorspace=(ColorspaceType) ParseCommandOption(
6075 MagickColorspaceOptions,MagickFalse,value);
6077 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6079 (void) TransformImageColorspace(msl_info->image[n],
6080 (ColorspaceType) colorspace,&exception);
6083 (void) SetMSLAttributes(msl_info,keyword,value);
6084 (void) SetImageProperty(msl_info->image[n],keyword,value,
6091 if (LocaleCompare(keyword,"density") == 0)
6093 flags=ParseGeometry(value,&geometry_info);
6094 msl_info->image[n]->resolution.x=geometry_info.rho;
6095 msl_info->image[n]->resolution.y=geometry_info.sigma;
6096 if ((flags & SigmaValue) == 0)
6097 msl_info->image[n]->resolution.y=
6098 msl_info->image[n]->resolution.x;
6101 (void) SetMSLAttributes(msl_info,keyword,value);
6102 (void) SetImageProperty(msl_info->image[n],keyword,value,
6109 if (LocaleCompare(keyword, "opacity") == 0)
6111 ssize_t opac = OpaqueAlpha,
6112 len = (ssize_t) strlen( value );
6114 if (value[len-1] == '%') {
6116 (void) CopyMagickString(tmp,value,len);
6117 opac = StringToLong( tmp );
6118 opac = (int)(QuantumRange * ((float)opac/100));
6120 opac = StringToLong( value );
6121 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6125 (void) SetMSLAttributes(msl_info,keyword,value);
6126 (void) SetImageProperty(msl_info->image[n],keyword,value,
6127 msl_info->exception);
6133 if (LocaleCompare(keyword, "page") == 0)
6136 page[MaxTextExtent];
6147 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6148 image_option=GetImageOption(msl_info->image_info[n],"page");
6149 if (image_option != (const char *) NULL)
6150 flags=ParseAbsoluteGeometry(image_option,&geometry);
6151 flags=ParseAbsoluteGeometry(value,&geometry);
6152 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6153 (double) geometry.width,(double) geometry.height);
6154 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6155 (void) FormatLocaleString(page,MaxTextExtent,
6156 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6157 (double) geometry.height,(double) geometry.x,(double)
6159 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6160 msl_info->image_info[n]->page=GetPageGeometry(page);
6163 (void) SetMSLAttributes(msl_info,keyword,value);
6164 (void) SetImageProperty(msl_info->image[n],keyword,value,
6165 msl_info->exception);
6170 (void) SetMSLAttributes(msl_info,keyword,value);
6171 (void) SetImageProperty(msl_info->image[n],keyword,value,
6172 msl_info->exception);
6179 if (LocaleCompare((const char *) tag,"shade") == 0)
6190 if (msl_info->image[n] == (Image *) NULL)
6192 ThrowMSLException(OptionError,"NoImagesDefined",
6193 (const char *) tag);
6197 if (attributes != (const xmlChar **) NULL)
6198 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6200 keyword=(const char *) attributes[i++];
6201 attribute=InterpretImageProperties(msl_info->image_info[n],
6202 msl_info->attributes[n],(const char *) attributes[i],
6204 CloneString(&value,attribute);
6210 if (LocaleCompare(keyword,"azimuth") == 0)
6212 geometry_info.rho=StringToDouble(value,
6216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6223 if (LocaleCompare(keyword,"elevation") == 0)
6225 geometry_info.sigma=StringToDouble(value,
6229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6236 if (LocaleCompare(keyword,"geometry") == 0)
6238 flags=ParseGeometry(value,&geometry_info);
6239 if ((flags & SigmaValue) == 0)
6240 geometry_info.sigma=1.0;
6243 if (LocaleCompare(keyword,"gray") == 0)
6245 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6248 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6250 gray=(MagickBooleanType) option;
6253 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6259 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6265 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6266 geometry_info.sigma,msl_info->exception);
6267 if (shade_image == (Image *) NULL)
6269 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6270 msl_info->image[n]=shade_image;
6273 if (LocaleCompare((const char *) tag,"shadow") == 0)
6281 if (msl_info->image[n] == (Image *) NULL)
6283 ThrowMSLException(OptionError,"NoImagesDefined",
6284 (const char *) tag);
6287 if (attributes != (const xmlChar **) NULL)
6288 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6290 keyword=(const char *) attributes[i++];
6291 attribute=InterpretImageProperties(msl_info->image_info[n],
6292 msl_info->attributes[n],(const char *) attributes[i],
6294 CloneString(&value,attribute);
6300 if (LocaleCompare(keyword,"geometry") == 0)
6302 flags=ParseGeometry(value,&geometry_info);
6303 if ((flags & SigmaValue) == 0)
6304 geometry_info.sigma=1.0;
6307 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6314 if (LocaleCompare(keyword,"opacity") == 0)
6316 geometry_info.rho=StringToLong(value);
6319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6326 if (LocaleCompare(keyword,"sigma") == 0)
6328 geometry_info.sigma=StringToLong(value);
6336 if (LocaleCompare(keyword,"x") == 0)
6338 geometry_info.xi=StringToDouble(value,
6342 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6349 if (LocaleCompare(keyword,"y") == 0)
6351 geometry_info.psi=StringToLong(value);
6354 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6360 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6366 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6367 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6368 ceil(geometry_info.psi-0.5),msl_info->exception);
6369 if (shadow_image == (Image *) NULL)
6371 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6372 msl_info->image[n]=shadow_image;
6375 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6381 if (msl_info->image[n] == (Image *) NULL)
6383 ThrowMSLException(OptionError,"NoImagesDefined",
6384 (const char *) tag);
6388 NOTE: sharpen can have no attributes, since we use all the defaults!
6390 if (attributes != (const xmlChar **) NULL)
6392 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6394 keyword=(const char *) attributes[i++];
6395 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6396 msl_info->attributes[n],(const char *) attributes[i],&exception));
6402 if (LocaleCompare(keyword, "bias") == 0)
6404 bias = StringToDouble(value,(char **) NULL);
6407 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6413 if (LocaleCompare(keyword, "radius") == 0)
6415 radius = StringToDouble(value,(char **) NULL);
6418 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6424 if (LocaleCompare(keyword,"sigma") == 0)
6426 sigma = StringToLong( value );
6429 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6434 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6448 newImage=SharpenImage(msl_info->image[n],radius,sigma,bias,
6449 msl_info->exception);
6450 if (newImage == (Image *) NULL)
6452 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6453 msl_info->image[n]=newImage;
6457 else if (LocaleCompare((const char *) tag,"shave") == 0)
6459 /* init the values */
6463 if (msl_info->image[n] == (Image *) NULL)
6465 ThrowMSLException(OptionError,"NoImagesDefined",
6466 (const char *) tag);
6469 if (attributes == (const xmlChar **) NULL)
6471 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6473 keyword=(const char *) attributes[i++];
6474 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6475 msl_info->attributes[n],(const char *) attributes[i],&exception));
6481 if (LocaleCompare(keyword,"geometry") == 0)
6483 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6486 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6492 if (LocaleCompare(keyword,"height") == 0)
6494 height = StringToLong( value );
6497 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6503 if (LocaleCompare(keyword,"width") == 0)
6505 width = StringToLong( value );
6508 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6513 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6528 rectInfo.height = height;
6529 rectInfo.width = width;
6534 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6535 msl_info->exception);
6536 if (newImage == (Image *) NULL)
6538 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6539 msl_info->image[n]=newImage;
6544 if (LocaleCompare((const char *) tag,"shear") == 0)
6552 if (msl_info->image[n] == (Image *) NULL)
6554 ThrowMSLException(OptionError,"NoImagesDefined",
6555 (const char *) tag);
6558 if (attributes != (const xmlChar **) NULL)
6559 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6561 keyword=(const char *) attributes[i++];
6562 attribute=InterpretImageProperties(msl_info->image_info[n],
6563 msl_info->attributes[n],(const char *) attributes[i],
6565 CloneString(&value,attribute);
6571 if (LocaleCompare(keyword, "fill") == 0)
6573 (void) QueryColorCompliance(value,AllCompliance,
6574 &msl_info->image[n]->background_color,&exception);
6577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6584 if (LocaleCompare(keyword,"geometry") == 0)
6586 flags=ParseGeometry(value,&geometry_info);
6587 if ((flags & SigmaValue) == 0)
6588 geometry_info.sigma=1.0;
6591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6598 if (LocaleCompare(keyword,"x") == 0)
6600 geometry_info.rho=StringToDouble(value,
6604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6611 if (LocaleCompare(keyword,"y") == 0)
6613 geometry_info.sigma=StringToLong(value);
6616 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6622 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6628 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6629 geometry_info.sigma,msl_info->exception);
6630 if (shear_image == (Image *) NULL)
6632 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6633 msl_info->image[n]=shear_image;
6636 if (LocaleCompare((const char *) tag,"signature") == 0)
6641 if (msl_info->image[n] == (Image *) NULL)
6643 ThrowMSLException(OptionError,"NoImagesDefined",
6644 (const char *) tag);
6647 if (attributes != (const xmlChar **) NULL)
6648 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6650 keyword=(const char *) attributes[i++];
6651 attribute=InterpretImageProperties(msl_info->image_info[n],
6652 msl_info->attributes[n],(const char *) attributes[i],
6654 CloneString(&value,attribute);
6659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6665 (void) SignatureImage(msl_info->image[n],&exception);
6668 if (LocaleCompare((const char *) tag,"solarize") == 0)
6673 if (msl_info->image[n] == (Image *) NULL)
6675 ThrowMSLException(OptionError,"NoImagesDefined",
6676 (const char *) tag);
6679 geometry_info.rho=QuantumRange/2.0;
6680 if (attributes != (const xmlChar **) NULL)
6681 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6683 keyword=(const char *) attributes[i++];
6684 attribute=InterpretImageProperties(msl_info->image_info[n],
6685 msl_info->attributes[n],(const char *) attributes[i],
6687 CloneString(&value,attribute);
6693 if (LocaleCompare(keyword,"geometry") == 0)
6695 flags=ParseGeometry(value,&geometry_info);
6698 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6705 if (LocaleCompare(keyword,"threshold") == 0)
6707 geometry_info.rho=StringToDouble(value,
6711 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6723 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6724 msl_info->exception);
6727 if (LocaleCompare((const char *) tag,"spread") == 0)
6735 if (msl_info->image[n] == (Image *) NULL)
6737 ThrowMSLException(OptionError,"NoImagesDefined",
6738 (const char *) tag);
6741 if (attributes != (const xmlChar **) NULL)
6742 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6744 keyword=(const char *) attributes[i++];
6745 attribute=InterpretImageProperties(msl_info->image_info[n],
6746 msl_info->attributes[n],(const char *) attributes[i],
6748 CloneString(&value,attribute);
6754 if (LocaleCompare(keyword,"geometry") == 0)
6756 flags=ParseGeometry(value,&geometry_info);
6757 if ((flags & SigmaValue) == 0)
6758 geometry_info.sigma=1.0;
6761 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6768 if (LocaleCompare(keyword,"radius") == 0)
6770 geometry_info.rho=StringToDouble(value,
6774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6786 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6787 msl_info->image[n]->interpolate,msl_info->exception);
6788 if (spread_image == (Image *) NULL)
6790 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6791 msl_info->image[n]=spread_image;
6794 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6797 watermark = (Image*)NULL;
6799 if (msl_info->image[n] == (Image *) NULL)
6801 ThrowMSLException(OptionError,"NoImagesDefined",
6802 (const char *) tag);
6805 if (attributes == (const xmlChar **) NULL)
6807 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6809 keyword=(const char *) attributes[i++];
6810 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6811 msl_info->attributes[n],(const char *) attributes[i],&exception));
6817 if (LocaleCompare(keyword,"image") == 0)
6819 for (j=0; j<msl_info->n;j++)
6822 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6824 if (theAttr && LocaleCompare(theAttr, value) == 0)
6826 watermark = msl_info->image[j];
6832 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6837 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6846 if ( watermark != (Image*) NULL )
6851 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6852 if (newImage == (Image *) NULL)
6854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6855 msl_info->image[n]=newImage;
6858 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6860 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6863 stereoImage = (Image*)NULL;
6865 if (msl_info->image[n] == (Image *) NULL)
6867 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6870 if (attributes == (const xmlChar **) NULL)
6872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6874 keyword=(const char *) attributes[i++];
6875 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6876 msl_info->attributes[n],(const char *) attributes[i],&exception));
6882 if (LocaleCompare(keyword,"image") == 0)
6884 for (j=0; j<msl_info->n;j++)
6887 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6889 if (theAttr && LocaleCompare(theAttr, value) == 0)
6891 stereoImage = msl_info->image[j];
6897 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6902 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6911 if ( stereoImage != (Image*) NULL )
6916 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6917 if (newImage == (Image *) NULL)
6919 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6920 msl_info->image[n]=newImage;
6923 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6925 if (LocaleCompare((const char *) tag,"swap") == 0)
6936 if (msl_info->image[n] == (Image *) NULL)
6938 ThrowMSLException(OptionError,"NoImagesDefined",
6939 (const char *) tag);
6944 if (attributes != (const xmlChar **) NULL)
6945 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6947 keyword=(const char *) attributes[i++];
6948 attribute=InterpretImageProperties(msl_info->image_info[n],
6949 msl_info->attributes[n],(const char *) attributes[i],
6951 CloneString(&value,attribute);
6957 if (LocaleCompare(keyword,"indexes") == 0)
6959 flags=ParseGeometry(value,&geometry_info);
6960 index=(ssize_t) geometry_info.rho;
6961 if ((flags & SigmaValue) == 0)
6962 swap_index=(ssize_t) geometry_info.sigma;
6965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6980 p=GetImageFromList(msl_info->image[n],index);
6981 q=GetImageFromList(msl_info->image[n],swap_index);
6982 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6984 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6987 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6988 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6989 msl_info->exception));
6990 ReplaceImageInList(&q,swap);
6991 msl_info->image[n]=GetFirstImageInList(q);
6994 if (LocaleCompare((const char *) tag,"swirl") == 0)
7002 if (msl_info->image[n] == (Image *) NULL)
7004 ThrowMSLException(OptionError,"NoImagesDefined",
7005 (const char *) tag);
7008 if (attributes != (const xmlChar **) NULL)
7009 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7011 keyword=(const char *) attributes[i++];
7012 attribute=InterpretImageProperties(msl_info->image_info[n],
7013 msl_info->attributes[n],(const char *) attributes[i],
7015 CloneString(&value,attribute);
7021 if (LocaleCompare(keyword,"degrees") == 0)
7023 geometry_info.rho=StringToDouble(value,
7027 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7034 if (LocaleCompare(keyword,"geometry") == 0)
7036 flags=ParseGeometry(value,&geometry_info);
7037 if ((flags & SigmaValue) == 0)
7038 geometry_info.sigma=1.0;
7041 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7047 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7053 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7054 msl_info->image[n]->interpolate,msl_info->exception);
7055 if (swirl_image == (Image *) NULL)
7057 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7058 msl_info->image[n]=swirl_image;
7061 if (LocaleCompare((const char *) tag,"sync") == 0)
7066 if (msl_info->image[n] == (Image *) NULL)
7068 ThrowMSLException(OptionError,"NoImagesDefined",
7069 (const char *) tag);
7072 if (attributes != (const xmlChar **) NULL)
7073 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7075 keyword=(const char *) attributes[i++];
7076 attribute=InterpretImageProperties(msl_info->image_info[n],
7077 msl_info->attributes[n],(const char *) attributes[i],
7079 CloneString(&value,attribute);
7084 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7090 (void) SyncImage(msl_info->image[n],&exception);
7093 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7098 if (LocaleCompare((const char *) tag,"map") == 0)
7106 if (msl_info->image[n] == (Image *) NULL)
7108 ThrowMSLException(OptionError,"NoImagesDefined",
7109 (const char *) tag);
7112 texture_image=NewImageList();
7113 if (attributes != (const xmlChar **) NULL)
7114 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7116 keyword=(const char *) attributes[i++];
7117 attribute=InterpretImageProperties(msl_info->image_info[n],
7118 msl_info->attributes[n],(const char *) attributes[i],
7120 CloneString(&value,attribute);
7126 if (LocaleCompare(keyword,"image") == 0)
7127 for (j=0; j < msl_info->n; j++)
7132 attribute=GetImageProperty(msl_info->attributes[j],"id",
7134 if ((attribute != (const char *) NULL) &&
7135 (LocaleCompare(attribute,value) == 0))
7137 texture_image=CloneImage(msl_info->image[j],0,0,
7138 MagickFalse,&exception);
7146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7152 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7153 texture_image=DestroyImage(texture_image);
7156 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7158 /* init the values */
7159 double threshold = 0;
7161 if (msl_info->image[n] == (Image *) NULL)
7163 ThrowMSLException(OptionError,"NoImagesDefined",(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],&exception));
7178 if (LocaleCompare(keyword,"threshold") == 0)
7180 threshold = StringToDouble(value,(char **) NULL);
7183 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7188 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7198 BilevelImage(msl_info->image[n],threshold,&exception);
7202 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7204 if (msl_info->image[n] == (Image *) NULL)
7206 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7209 if (attributes == (const xmlChar **) NULL)
7211 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7213 keyword=(const char *) attributes[i++];
7214 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7215 msl_info->attributes[n],(const char *) attributes[i],&exception));
7221 if (LocaleCompare(keyword,"color") == 0)
7226 (void) QueryColorCompliance(value,AllCompliance,&target,
7228 (void) TransparentPaintImage(msl_info->image[n],&target,
7229 TransparentAlpha,MagickFalse,msl_info->exception);
7232 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7237 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7244 else if (LocaleCompare((const char *) tag, "trim") == 0)
7246 if (msl_info->image[n] == (Image *) NULL)
7248 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7252 /* no attributes here */
7254 /* process the image */
7261 /* all zeros on a crop == trim edges! */
7262 rectInfo.height = rectInfo.width = 0;
7263 rectInfo.x = rectInfo.y = 0;
7265 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7266 if (newImage == (Image *) NULL)
7268 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7269 msl_info->image[n]=newImage;
7273 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7278 if (LocaleCompare((const char *) tag,"write") == 0)
7280 if (msl_info->image[n] == (Image *) NULL)
7282 ThrowMSLException(OptionError,"NoImagesDefined",
7283 (const char *) tag);
7286 if (attributes == (const xmlChar **) NULL)
7288 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7290 keyword=(const char *) attributes[i++];
7291 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7292 msl_info->attributes[n],(const char *) attributes[i],&exception));
7298 if (LocaleCompare(keyword,"filename") == 0)
7300 (void) CopyMagickString(msl_info->image[n]->filename,value,
7304 (void) SetMSLAttributes(msl_info,keyword,value);
7308 (void) SetMSLAttributes(msl_info,keyword,value);
7316 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7317 msl_info->exception);
7321 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7325 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7329 if ( value != NULL )
7330 value=DestroyString(value);
7331 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7334 static void MSLEndElement(void *context,const xmlChar *tag)
7343 Called when the end of an element has been detected.
7345 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7347 msl_info=(MSLInfo *) context;
7354 if (LocaleCompare((const char *) tag,"comment") == 0 )
7356 (void) DeleteImageProperty(msl_info->image[n],"comment");
7357 if (msl_info->content == (char *) NULL)
7359 StripString(msl_info->content);
7360 (void) SetImageProperty(msl_info->image[n],"comment",
7361 msl_info->content,msl_info->exception);
7369 if (LocaleCompare((const char *) tag, "group") == 0 )
7371 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7373 ssize_t i = (ssize_t)
7374 (msl_info->group_info[msl_info->number_groups-1].numImages);
7377 if (msl_info->image[msl_info->n] != (Image *) NULL)
7378 msl_info->image[msl_info->n]=DestroyImage(
7379 msl_info->image[msl_info->n]);
7380 msl_info->attributes[msl_info->n]=DestroyImage(
7381 msl_info->attributes[msl_info->n]);
7382 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7383 msl_info->image_info[msl_info->n]);
7387 msl_info->number_groups--;
7394 if (LocaleCompare((const char *) tag, "image") == 0)
7395 MSLPopImage(msl_info);
7401 if (LocaleCompare((const char *) tag,"label") == 0 )
7403 (void) DeleteImageProperty(msl_info->image[n],"label");
7404 if (msl_info->content == (char *) NULL)
7406 StripString(msl_info->content);
7407 (void) SetImageProperty(msl_info->image[n],"label",
7408 msl_info->content,msl_info->exception);
7416 if (LocaleCompare((const char *) tag, "msl") == 0 )
7419 This our base element.
7420 at the moment we don't do anything special
7421 but someday we might!
7429 if (msl_info->content != (char *) NULL)
7430 msl_info->content=DestroyString(msl_info->content);
7433 static void MSLCharacters(void *context,const xmlChar *c,int length)
7445 Receiving some characters from the parser.
7447 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7448 " SAX.characters(%s,%d)",c,length);
7449 msl_info=(MSLInfo *) context;
7450 if (msl_info->content != (char *) NULL)
7451 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7452 strlen(msl_info->content)+length+MaxTextExtent,
7453 sizeof(*msl_info->content));
7456 msl_info->content=(char *) NULL;
7457 if (~length >= (MaxTextExtent-1))
7458 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7459 sizeof(*msl_info->content));
7460 if (msl_info->content != (char *) NULL)
7461 *msl_info->content='\0';
7463 if (msl_info->content == (char *) NULL)
7465 p=msl_info->content+strlen(msl_info->content);
7466 for (i=0; i < length; i++)
7471 static void MSLReference(void *context,const xmlChar *name)
7480 Called when an entity reference is detected.
7482 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7483 " SAX.reference(%s)",name);
7484 msl_info=(MSLInfo *) context;
7485 parser=msl_info->parser;
7487 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7489 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7492 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7498 Receiving some ignorable whitespaces from the parser.
7500 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7501 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7502 msl_info=(MSLInfo *) context;
7506 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7507 const xmlChar *data)
7513 A processing instruction has been parsed.
7515 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7516 " SAX.processingInstruction(%s, %s)",
7518 msl_info=(MSLInfo *) context;
7522 static void MSLComment(void *context,const xmlChar *value)
7528 A comment has been parsed.
7530 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7531 " SAX.comment(%s)",value);
7532 msl_info=(MSLInfo *) context;
7536 static void MSLWarning(void *context,const char *format,...)
7540 reason[MaxTextExtent];
7549 Display and format a warning messages, gives file, line, position and
7552 va_start(operands,format);
7553 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7554 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7555 msl_info=(MSLInfo *) context;
7557 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7558 (void) vsprintf(reason,format,operands);
7560 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7562 message=GetExceptionMessage(errno);
7563 ThrowMSLException(CoderError,reason,message);
7564 message=DestroyString(message);
7568 static void MSLError(void *context,const char *format,...)
7571 reason[MaxTextExtent];
7580 Display and format a error formats, gives file, line, position and
7583 va_start(operands,format);
7584 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7585 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7586 msl_info=(MSLInfo *) context;
7588 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7589 (void) vsprintf(reason,format,operands);
7591 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7593 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7597 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7609 Called when a pcdata block has been parsed.
7611 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7612 " SAX.pcdata(%s, %d)",value,length);
7613 msl_info=(MSLInfo *) context;
7615 parser=msl_info->parser;
7616 child=xmlGetLastChild(parser->node);
7617 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7619 xmlTextConcat(child,value,length);
7622 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7625 static void MSLExternalSubset(void *context,const xmlChar *name,
7626 const xmlChar *external_id,const xmlChar *system_id)
7641 Does this document has an external subset?
7643 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7644 " SAX.externalSubset(%s %s %s)",name,
7645 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7646 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7647 msl_info=(MSLInfo *) context;
7649 parser=msl_info->parser;
7650 if (((external_id == NULL) && (system_id == NULL)) ||
7651 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7652 (msl_info->document == 0)))
7654 input=MSLResolveEntity(context,external_id,system_id);
7657 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7658 parser_context=(*parser);
7659 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7660 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7662 parser->errNo=XML_ERR_NO_MEMORY;
7663 parser->input=parser_context.input;
7664 parser->inputNr=parser_context.inputNr;
7665 parser->inputMax=parser_context.inputMax;
7666 parser->inputTab=parser_context.inputTab;
7672 xmlPushInput(parser,input);
7673 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7674 if (input->filename == (char *) NULL)
7675 input->filename=(char *) xmlStrdup(system_id);
7678 input->base=parser->input->cur;
7679 input->cur=parser->input->cur;
7681 xmlParseExternalSubset(parser,external_id,system_id);
7682 while (parser->inputNr > 1)
7683 (void) xmlPopInput(parser);
7684 xmlFreeInputStream(parser->input);
7685 xmlFree(parser->inputTab);
7686 parser->input=parser_context.input;
7687 parser->inputNr=parser_context.inputNr;
7688 parser->inputMax=parser_context.inputMax;
7689 parser->inputTab=parser_context.inputTab;
7692 #if defined(__cplusplus) || defined(c_plusplus)
7696 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7697 ExceptionInfo *exception)
7700 message[MaxTextExtent];
7723 assert(image_info != (const ImageInfo *) NULL);
7724 assert(image_info->signature == MagickSignature);
7725 if (image_info->debug != MagickFalse)
7726 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7727 image_info->filename);
7728 assert(image != (Image **) NULL);
7729 msl_image=AcquireImage(image_info,exception);
7730 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7731 if (status == MagickFalse)
7733 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7734 msl_image->filename);
7735 msl_image=DestroyImageList(msl_image);
7736 return(MagickFalse);
7738 msl_image->columns=1;
7743 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7744 msl_info.exception=exception;
7745 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7746 sizeof(*msl_info.image_info));
7747 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7748 sizeof(*msl_info.draw_info));
7749 /* top of the stack is the MSL file itself */
7750 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7751 msl_info.attributes=(Image **) AcquireMagickMemory(
7752 sizeof(*msl_info.attributes));
7753 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7754 sizeof(*msl_info.group_info));
7755 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7756 (msl_info.image == (Image **) NULL) ||
7757 (msl_info.attributes == (Image **) NULL) ||
7758 (msl_info.group_info == (MSLGroupInfo *) NULL))
7759 ThrowFatalException(ResourceLimitFatalError,
7760 "UnableToInterpretMSLImage");
7761 *msl_info.image_info=CloneImageInfo(image_info);
7762 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7763 *msl_info.attributes=AcquireImage(image_info,exception);
7764 msl_info.group_info[0].numImages=0;
7765 /* the first slot is used to point to the MSL file image */
7766 *msl_info.image=msl_image;
7767 if (*image != (Image *) NULL)
7768 MSLPushImage(&msl_info,*image);
7769 (void) xmlSubstituteEntitiesDefault(1);
7770 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7771 sax_modules.internalSubset=MSLInternalSubset;
7772 sax_modules.isStandalone=MSLIsStandalone;
7773 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7774 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7775 sax_modules.resolveEntity=MSLResolveEntity;
7776 sax_modules.getEntity=MSLGetEntity;
7777 sax_modules.entityDecl=MSLEntityDeclaration;
7778 sax_modules.notationDecl=MSLNotationDeclaration;
7779 sax_modules.attributeDecl=MSLAttributeDeclaration;
7780 sax_modules.elementDecl=MSLElementDeclaration;
7781 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7782 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7783 sax_modules.startDocument=MSLStartDocument;
7784 sax_modules.endDocument=MSLEndDocument;
7785 sax_modules.startElement=MSLStartElement;
7786 sax_modules.endElement=MSLEndElement;
7787 sax_modules.reference=MSLReference;
7788 sax_modules.characters=MSLCharacters;
7789 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7790 sax_modules.processingInstruction=MSLProcessingInstructions;
7791 sax_modules.comment=MSLComment;
7792 sax_modules.warning=MSLWarning;
7793 sax_modules.error=MSLError;
7794 sax_modules.fatalError=MSLError;
7795 sax_modules.getParameterEntity=MSLGetParameterEntity;
7796 sax_modules.cdataBlock=MSLCDataBlock;
7797 sax_modules.externalSubset=MSLExternalSubset;
7798 sax_handler=(&sax_modules);
7799 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7800 msl_image->filename);
7801 while (ReadBlobString(msl_image,message) != (char *) NULL)
7803 n=(ssize_t) strlen(message);
7806 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7809 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7810 if (msl_info.exception->severity >= ErrorException)
7813 if (msl_info.exception->severity == UndefinedException)
7814 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7815 xmlFreeParserCtxt(msl_info.parser);
7816 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7818 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7819 msl_info.group_info);
7820 if (*image == (Image *) NULL)
7821 *image=(*msl_info.image);
7822 if (msl_info.exception->severity != UndefinedException)
7823 return(MagickFalse);
7827 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7835 assert(image_info != (const ImageInfo *) NULL);
7836 assert(image_info->signature == MagickSignature);
7837 if (image_info->debug != MagickFalse)
7838 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7839 image_info->filename);
7840 assert(exception != (ExceptionInfo *) NULL);
7841 assert(exception->signature == MagickSignature);
7842 image=(Image *) NULL;
7843 (void) ProcessMSLScript(image_info,&image,exception);
7844 return(GetFirstImageInList(image));
7849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7853 % R e g i s t e r M S L I m a g e %
7857 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7859 % RegisterMSLImage() adds attributes for the MSL image format to
7860 % the list of supported formats. The attributes include the image format
7861 % tag, a method to read and/or write the format, whether the format
7862 % supports the saving of more than one frame to the same file or blob,
7863 % whether the format supports native in-memory I/O, and a brief
7864 % description of the format.
7866 % The format of the RegisterMSLImage method is:
7868 % size_t RegisterMSLImage(void)
7871 ModuleExport size_t RegisterMSLImage(void)
7876 entry=SetMagickInfo("MSL");
7877 #if defined(MAGICKCORE_XML_DELEGATE)
7878 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7879 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7881 entry->description=ConstantString("Magick Scripting Language");
7882 entry->module=ConstantString("MSL");
7883 (void) RegisterMagickInfo(entry);
7884 return(MagickImageCoderSignature);
7887 #if defined(MAGICKCORE_XML_DELEGATE)
7889 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7893 % S e t M S L A t t r i b u t e s %
7897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7899 % SetMSLAttributes() ...
7901 % The format of the SetMSLAttributes method is:
7903 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7904 % const char *keyword,const char *value)
7906 % A description of each parameter follows:
7908 % o msl_info: the MSL info.
7910 % o keyword: the keyword.
7912 % o value: the value.
7915 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7942 assert(msl_info != (MSLInfo *) NULL);
7943 if (keyword == (const char *) NULL)
7945 if (value == (const char *) NULL)
7947 exception=msl_info->exception;
7949 attributes=msl_info->attributes[n];
7950 image_info=msl_info->image_info[n];
7951 draw_info=msl_info->draw_info[n];
7952 image=msl_info->image[n];
7958 if (LocaleCompare(keyword,"adjoin") == 0)
7963 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7965 ThrowMSLException(OptionError,"UnrecognizedType",value);
7966 image_info->adjoin=(MagickBooleanType) adjoin;
7969 if (LocaleCompare(keyword,"alpha") == 0)
7974 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7976 ThrowMSLException(OptionError,"UnrecognizedType",value);
7977 if (image != (Image *) NULL)
7978 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7982 if (LocaleCompare(keyword,"antialias") == 0)
7987 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7989 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7990 image_info->antialias=(MagickBooleanType) antialias;
7993 if (LocaleCompare(keyword,"area-limit") == 0)
7998 limit=MagickResourceInfinity;
7999 if (LocaleCompare(value,"unlimited") != 0)
8000 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
8001 (void) SetMagickResourceLimit(AreaResource,limit);
8004 if (LocaleCompare(keyword,"attenuate") == 0)
8006 (void) SetImageOption(image_info,keyword,value);
8009 if (LocaleCompare(keyword,"authenticate") == 0)
8011 (void) CloneString(&image_info->density,value);
8014 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8020 if (LocaleCompare(keyword,"background") == 0)
8022 (void) QueryColorCompliance(value,AllCompliance,
8023 &image_info->background_color,exception);
8026 if (LocaleCompare(keyword,"bias") == 0)
8028 if (image == (Image *) NULL)
8030 image->bias=StringToDoubleInterval(value,QuantumRange);
8033 if (LocaleCompare(keyword,"blue-primary") == 0)
8035 if (image == (Image *) NULL)
8037 flags=ParseGeometry(value,&geometry_info);
8038 image->chromaticity.blue_primary.x=geometry_info.rho;
8039 image->chromaticity.blue_primary.y=geometry_info.sigma;
8040 if ((flags & SigmaValue) == 0)
8041 image->chromaticity.blue_primary.y=
8042 image->chromaticity.blue_primary.x;
8045 if (LocaleCompare(keyword,"bordercolor") == 0)
8047 (void) QueryColorCompliance(value,AllCompliance,
8048 &image_info->border_color,exception);
8051 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8057 if (LocaleCompare(keyword,"density") == 0)
8059 (void) CloneString(&image_info->density,value);
8060 (void) CloneString(&draw_info->density,value);
8063 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8069 if (LocaleCompare(keyword,"fill") == 0)
8071 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8073 (void) SetImageOption(image_info,keyword,value);
8076 if (LocaleCompare(keyword,"filename") == 0)
8078 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8081 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8087 if (LocaleCompare(keyword,"gravity") == 0)
8092 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8094 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8095 (void) SetImageOption(image_info,keyword,value);
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"id") == 0)
8106 (void) SetImageProperty(attributes,keyword,value,exception);
8109 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8115 if (LocaleCompare(keyword,"magick") == 0)
8117 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8120 if (LocaleCompare(keyword,"mattecolor") == 0)
8122 (void) QueryColorCompliance(value,AllCompliance,
8123 &image_info->matte_color,exception);
8126 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8132 if (LocaleCompare(keyword,"pointsize") == 0)
8134 image_info->pointsize=StringToDouble(value,(char **) NULL);
8135 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8138 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8144 if (LocaleCompare(keyword,"quality") == 0)
8146 image_info->quality=StringToLong(value);
8147 if (image == (Image *) NULL)
8149 image->quality=StringToLong(value);
8157 if (LocaleCompare(keyword,"size") == 0)
8159 (void) CloneString(&image_info->size,value);
8162 if (LocaleCompare(keyword,"stroke") == 0)
8164 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8166 (void) SetImageOption(image_info,keyword,value);
8169 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8174 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8183 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8187 % U n r e g i s t e r M S L I m a g e %
8191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8193 % UnregisterMSLImage() removes format registrations made by the
8194 % MSL module from the list of supported formats.
8196 % The format of the UnregisterMSLImage method is:
8198 % UnregisterMSLImage(void)
8201 ModuleExport void UnregisterMSLImage(void)
8203 (void) UnregisterMagickInfo("MSL");
8206 #if defined(MAGICKCORE_XML_DELEGATE)
8208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8212 % W r i t e M S L I m a g e %
8216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8218 % WriteMSLImage() writes an image to a file in MVG image format.
8220 % The format of the WriteMSLImage method is:
8222 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8223 % Image *image,ExceptionInfo *exception)
8225 % A description of each parameter follows.
8227 % o image_info: the image info.
8229 % o image: The image.
8231 % o exception: return any errors or warnings in this structure.
8234 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8235 ExceptionInfo *exception)
8237 assert(image_info != (const ImageInfo *) NULL);
8238 assert(image_info->signature == MagickSignature);
8239 assert(image != (Image *) NULL);
8240 assert(image->signature == MagickSignature);
8241 if (image->debug != MagickFalse)
8242 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8243 (void) ReferenceImage(image);
8244 (void) ProcessMSLScript(image_info,&image,exception);