2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/attribute.h"
48 #include "MagickCore/blob.h"
49 #include "MagickCore/blob-private.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/cache-view.h"
52 #include "MagickCore/channel.h"
53 #include "MagickCore/color.h"
54 #include "MagickCore/color-private.h"
55 #include "MagickCore/colormap.h"
56 #include "MagickCore/composite.h"
57 #include "MagickCore/constitute.h"
58 #include "MagickCore/decorate.h"
59 #include "MagickCore/display.h"
60 #include "MagickCore/distort.h"
61 #include "MagickCore/draw.h"
62 #include "MagickCore/effect.h"
63 #include "MagickCore/enhance.h"
64 #include "MagickCore/exception.h"
65 #include "MagickCore/exception-private.h"
66 #include "MagickCore/fx.h"
67 #include "MagickCore/geometry.h"
68 #include "MagickCore/image.h"
69 #include "MagickCore/image-private.h"
70 #include "MagickCore/list.h"
71 #include "MagickCore/log.h"
72 #include "MagickCore/magick.h"
73 #include "MagickCore/memory_.h"
74 #include "MagickCore/module.h"
75 #include "MagickCore/option.h"
76 #include "MagickCore/paint.h"
77 #include "MagickCore/pixel-accessor.h"
78 #include "MagickCore/profile.h"
79 #include "MagickCore/property.h"
80 #include "MagickCore/quantize.h"
81 #include "MagickCore/quantum-private.h"
82 #include "MagickCore/registry.h"
83 #include "MagickCore/resize.h"
84 #include "MagickCore/resource_.h"
85 #include "MagickCore/segment.h"
86 #include "MagickCore/shear.h"
87 #include "MagickCore/signature.h"
88 #include "MagickCore/statistic.h"
89 #include "MagickCore/static.h"
90 #include "MagickCore/string_.h"
91 #include "MagickCore/string-private.h"
92 #include "MagickCore/transform.h"
93 #include "MagickCore/threshold.h"
94 #include "MagickCore/utility.h"
95 #if defined(MAGICKCORE_XML_DELEGATE)
96 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
97 # if defined(__MINGW32__) || defined(__MINGW64__)
100 # include <win32config.h>
103 # include <libxml/parser.h>
104 # include <libxml/xmlmemory.h>
105 # include <libxml/parserInternals.h>
106 # include <libxml/xmlerror.h>
112 #define ThrowMSLException(severity,tag,reason) \
113 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
117 Typedef declaractions.
119 typedef struct _MSLGroupInfo
122 numImages; /* how many images are in this group */
125 typedef struct _MSLInfo
150 #if defined(MAGICKCORE_XML_DELEGATE)
160 Forward declarations.
162 #if defined(MAGICKCORE_XML_DELEGATE)
163 static MagickBooleanType
164 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
166 static MagickBooleanType
167 SetMSLAttributes(MSLInfo *,const char *,const char *);
170 #if defined(MAGICKCORE_XML_DELEGATE)
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 % R e a d M S L I m a g e %
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
184 % It allocates the memory necessary for the new Image structure and returns a
185 % pointer to the new image.
187 % The format of the ReadMSLImage method is:
189 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
191 % A description of each parameter follows:
193 % o image_info: the image info.
195 % o exception: return any errors or warnings in this structure.
199 #if defined(__cplusplus) || defined(c_plusplus)
203 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
204 ExceptionInfo *exception)
218 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
219 sans_exception=AcquireExceptionInfo();
220 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
221 sans_exception=DestroyExceptionInfo(sans_exception);
222 if (image != (Image *) NULL)
224 read_info=CloneImageInfo(image_info);
225 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
226 image=ReadImage(read_info,exception);
227 read_info=DestroyImageInfo(read_info);
228 if (image != (Image *) NULL)
229 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
233 static int IsPathDirectory(const char *path)
241 if ((path == (const char *) NULL) || (*path == '\0'))
243 status=GetPathAttributes(path,&attributes);
244 if (status == MagickFalse)
246 if (S_ISDIR(attributes.st_mode) == 0)
251 static int MSLIsStandalone(void *context)
257 Is this document tagged standalone?
259 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
260 msl_info=(MSLInfo *) context;
261 return(msl_info->document->standalone == 1);
264 static int MSLHasInternalSubset(void *context)
270 Does this document has an internal subset?
272 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
273 " SAX.MSLHasInternalSubset()");
274 msl_info=(MSLInfo *) context;
275 return(msl_info->document->intSubset != NULL);
278 static int MSLHasExternalSubset(void *context)
284 Does this document has an external subset?
286 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
287 " SAX.MSLHasExternalSubset()");
288 msl_info=(MSLInfo *) context;
289 return(msl_info->document->extSubset != NULL);
292 static void MSLInternalSubset(void *context,const xmlChar *name,
293 const xmlChar *external_id,const xmlChar *system_id)
299 Does this document has an internal subset?
301 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
302 " SAX.internalSubset(%s %s %s)",name,
303 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
304 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
305 msl_info=(MSLInfo *) context;
306 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
309 static xmlParserInputPtr MSLResolveEntity(void *context,
310 const xmlChar *public_id,const xmlChar *system_id)
319 Special entity resolver, better left to the parser, it has more
320 context than the application layer. The default behaviour is to
321 not resolve the entities, in that case the ENTITY_REF nodes are
322 built in the structure (and the parameter values).
324 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
325 " SAX.resolveEntity(%s, %s)",
326 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
327 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
328 msl_info=(MSLInfo *) context;
329 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
330 public_id,msl_info->parser);
334 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
340 Get an entity by name.
342 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
343 " SAX.MSLGetEntity(%s)",(const char *) name);
344 msl_info=(MSLInfo *) context;
345 return(xmlGetDocEntity(msl_info->document,name));
348 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
354 Get a parameter entity by name.
356 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
357 " SAX.getParameterEntity(%s)",(const char *) name);
358 msl_info=(MSLInfo *) context;
359 return(xmlGetParameterEntity(msl_info->document,name));
362 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
363 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
369 An entity definition has been parsed.
371 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
372 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
373 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
374 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
376 msl_info=(MSLInfo *) context;
377 if (msl_info->parser->inSubset == 1)
378 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
381 if (msl_info->parser->inSubset == 2)
382 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
386 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
387 const xmlChar *name,int type,int value,const xmlChar *default_value,
388 xmlEnumerationPtr tree)
401 An attribute definition has been parsed.
403 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
404 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
406 msl_info=(MSLInfo *) context;
407 fullname=(xmlChar *) NULL;
408 prefix=(xmlChar *) NULL;
409 parser=msl_info->parser;
410 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
411 if (parser->inSubset == 1)
412 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
413 element,fullname,prefix,(xmlAttributeType) type,
414 (xmlAttributeDefault) value,default_value,tree);
416 if (parser->inSubset == 2)
417 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
418 element,fullname,prefix,(xmlAttributeType) type,
419 (xmlAttributeDefault) value,default_value,tree);
420 if (prefix != (xmlChar *) NULL)
422 if (fullname != (xmlChar *) NULL)
426 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
427 xmlElementContentPtr content)
436 An element definition has been parsed.
438 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
439 " SAX.elementDecl(%s, %d, ...)",name,type);
440 msl_info=(MSLInfo *) context;
441 parser=msl_info->parser;
442 if (parser->inSubset == 1)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
444 name,(xmlElementTypeVal) type,content);
446 if (parser->inSubset == 2)
447 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
448 name,(xmlElementTypeVal) type,content);
451 static void MSLNotationDeclaration(void *context,const xmlChar *name,
452 const xmlChar *public_id,const xmlChar *system_id)
461 What to do when a notation declaration has been parsed.
463 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
464 " SAX.notationDecl(%s, %s, %s)",name,
465 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
466 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
467 msl_info=(MSLInfo *) context;
468 parser=msl_info->parser;
469 if (parser->inSubset == 1)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
473 if (parser->inSubset == 2)
474 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
475 name,public_id,system_id);
478 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
479 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
485 What to do when an unparsed entity declaration is parsed.
487 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
488 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
489 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
490 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
492 msl_info=(MSLInfo *) context;
493 (void) xmlAddDocEntity(msl_info->document,name,
494 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
498 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
504 Receive the document locator at startup, actually xmlDefaultSAXLocator.
506 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
507 " SAX.setDocumentLocator()\n");
509 msl_info=(MSLInfo *) context;
513 static void MSLStartDocument(void *context)
522 Called when the document start being processed.
524 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
525 " SAX.startDocument()");
526 msl_info=(MSLInfo *) context;
527 parser=msl_info->parser;
528 msl_info->document=xmlNewDoc(parser->version);
529 if (msl_info->document == (xmlDocPtr) NULL)
531 if (parser->encoding == NULL)
532 msl_info->document->encoding=NULL;
534 msl_info->document->encoding=xmlStrdup(parser->encoding);
535 msl_info->document->standalone=parser->standalone;
538 static void MSLEndDocument(void *context)
544 Called when the document end has been detected.
546 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
547 msl_info=(MSLInfo *) context;
548 if (msl_info->content != (char *) NULL)
549 msl_info->content=DestroyString(msl_info->content);
552 static void MSLPushImage(MSLInfo *msl_info,Image *image)
557 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
558 assert(msl_info != (MSLInfo *) NULL);
561 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
562 (n+1),sizeof(*msl_info->image_info));
563 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
564 (n+1),sizeof(*msl_info->draw_info));
565 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
566 (n+1),sizeof(*msl_info->attributes));
567 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
568 sizeof(*msl_info->image));
569 if ((msl_info->image_info == (ImageInfo **) NULL) ||
570 (msl_info->draw_info == (DrawInfo **) NULL) ||
571 (msl_info->attributes == (Image **) NULL) ||
572 (msl_info->image == (Image **) NULL))
573 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
574 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
575 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
576 msl_info->draw_info[n-1]);
577 if (image == (Image *) NULL)
578 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
579 msl_info->exception);
581 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
582 msl_info->exception);
583 msl_info->image[n]=(Image *) image;
584 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
585 (msl_info->attributes[n] == (Image *) NULL))
586 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
587 if (msl_info->number_groups != 0)
588 msl_info->group_info[msl_info->number_groups-1].numImages++;
591 static void MSLPopImage(MSLInfo *msl_info)
593 if (msl_info->number_groups != 0)
595 if (msl_info->image[msl_info->n] != (Image *) NULL)
596 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
597 msl_info->attributes[msl_info->n]=DestroyImage(
598 msl_info->attributes[msl_info->n]);
599 msl_info->image_info[msl_info->n]=DestroyImageInfo(
600 msl_info->image_info[msl_info->n]);
604 static void MSLStartElement(void *context,const xmlChar *tag,
605 const xmlChar **attributes)
664 Called when an opening tag has been processed.
666 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
667 " SAX.startElement(%s",tag);
668 GetExceptionInfo(&exception);
669 msl_info=(MSLInfo *) context;
671 keyword=(const char *) NULL;
673 SetGeometryInfo(&geometry_info);
674 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
675 channel=DefaultChannels;
681 if (LocaleCompare((const char *) tag,"add-noise") == 0)
692 if (msl_info->image[n] == (Image *) NULL)
694 ThrowMSLException(OptionError,"NoImagesDefined",
699 if (attributes != (const xmlChar **) NULL)
700 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
702 keyword=(const char *) attributes[i++];
703 attribute=InterpretImageProperties(msl_info->image_info[n],
704 msl_info->attributes[n],(const char *) attributes[i],
706 CloneString(&value,attribute);
712 if (LocaleCompare(keyword,"channel") == 0)
714 option=ParseChannelOption(value);
716 ThrowMSLException(OptionError,"UnrecognizedChannelType",
718 channel=(ChannelType) option;
721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
728 if (LocaleCompare(keyword,"noise") == 0)
730 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
733 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
735 noise=(NoiseType) option;
738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
750 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
751 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
752 msl_info->exception);
753 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
754 if (noise_image == (Image *) NULL)
756 msl_info->image[n]=DestroyImage(msl_info->image[n]);
757 msl_info->image[n]=noise_image;
760 if (LocaleCompare((const char *) tag,"annotate") == 0)
768 if (msl_info->image[n] == (Image *) NULL)
770 ThrowMSLException(OptionError,"NoImagesDefined",
774 draw_info=CloneDrawInfo(msl_info->image_info[n],
775 msl_info->draw_info[n]);
777 current=draw_info->affine;
778 GetAffineMatrix(&affine);
779 if (attributes != (const xmlChar **) NULL)
780 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
782 keyword=(const char *) attributes[i++];
783 attribute=InterpretImageProperties(msl_info->image_info[n],
784 msl_info->attributes[n],(const char *) attributes[i],
786 CloneString(&value,attribute);
792 if (LocaleCompare(keyword,"affine") == 0)
798 draw_info->affine.sx=StringToDouble(p,&p);
801 draw_info->affine.rx=StringToDouble(p,&p);
804 draw_info->affine.ry=StringToDouble(p,&p);
807 draw_info->affine.sy=StringToDouble(p,&p);
810 draw_info->affine.tx=StringToDouble(p,&p);
813 draw_info->affine.ty=StringToDouble(p,&p);
816 if (LocaleCompare(keyword,"align") == 0)
818 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
821 ThrowMSLException(OptionError,"UnrecognizedAlignType",
823 draw_info->align=(AlignType) option;
826 if (LocaleCompare(keyword,"antialias") == 0)
828 option=ParseCommandOption(MagickBooleanOptions,
831 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
833 draw_info->stroke_antialias=(MagickBooleanType) option;
834 draw_info->text_antialias=(MagickBooleanType) option;
837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
844 if (LocaleCompare(keyword,"density") == 0)
846 CloneString(&draw_info->density,value);
849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
856 if (LocaleCompare(keyword,"encoding") == 0)
858 CloneString(&draw_info->encoding,value);
861 ThrowMSLException(OptionError,"UnrecognizedAttribute",
868 if (LocaleCompare(keyword, "fill") == 0)
870 (void) QueryColorCompliance(value,AllCompliance,
871 &draw_info->fill,&exception);
874 if (LocaleCompare(keyword,"family") == 0)
876 CloneString(&draw_info->family,value);
879 if (LocaleCompare(keyword,"font") == 0)
881 CloneString(&draw_info->font,value);
884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
891 if (LocaleCompare(keyword,"geometry") == 0)
893 flags=ParseGravityGeometry(msl_info->image[n],value,
894 &geometry,&exception);
897 if (LocaleCompare(keyword,"gravity") == 0)
899 option=ParseCommandOption(MagickGravityOptions,
902 ThrowMSLException(OptionError,"UnrecognizedGravityType",
904 draw_info->gravity=(GravityType) option;
907 ThrowMSLException(OptionError,"UnrecognizedAttribute",
914 if (LocaleCompare(keyword,"pointsize") == 0)
916 draw_info->pointsize=StringToDouble(value,(char **) NULL);
919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
926 if (LocaleCompare(keyword,"rotate") == 0)
928 angle=StringToDouble(value,(char **) NULL);
929 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
930 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
931 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
932 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
942 if (LocaleCompare(keyword,"scale") == 0)
944 flags=ParseGeometry(value,&geometry_info);
945 if ((flags & SigmaValue) == 0)
946 geometry_info.sigma=1.0;
947 affine.sx=geometry_info.rho;
948 affine.sy=geometry_info.sigma;
951 if (LocaleCompare(keyword,"skewX") == 0)
953 angle=StringToDouble(value,(char **) NULL);
954 affine.ry=tan(DegreesToRadians(fmod((double) angle,
958 if (LocaleCompare(keyword,"skewY") == 0)
960 angle=StringToDouble(value,(char **) NULL);
961 affine.rx=tan(DegreesToRadians(fmod((double) angle,
965 if (LocaleCompare(keyword,"stretch") == 0)
967 option=ParseCommandOption(MagickStretchOptions,
970 ThrowMSLException(OptionError,"UnrecognizedStretchType",
972 draw_info->stretch=(StretchType) option;
975 if (LocaleCompare(keyword, "stroke") == 0)
977 (void) QueryColorCompliance(value,AllCompliance,
978 &draw_info->stroke,&exception);
981 if (LocaleCompare(keyword,"strokewidth") == 0)
983 draw_info->stroke_width=StringToLong(value);
986 if (LocaleCompare(keyword,"style") == 0)
988 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
991 ThrowMSLException(OptionError,"UnrecognizedStyleType",
993 draw_info->style=(StyleType) option;
996 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1003 if (LocaleCompare(keyword,"text") == 0)
1005 CloneString(&draw_info->text,value);
1008 if (LocaleCompare(keyword,"translate") == 0)
1010 flags=ParseGeometry(value,&geometry_info);
1011 if ((flags & SigmaValue) == 0)
1012 geometry_info.sigma=1.0;
1013 affine.tx=geometry_info.rho;
1014 affine.ty=geometry_info.sigma;
1017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1024 if (LocaleCompare(keyword, "undercolor") == 0)
1026 (void) QueryColorCompliance(value,AllCompliance,
1027 &draw_info->undercolor,&exception);
1030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1037 if (LocaleCompare(keyword,"weight") == 0)
1039 draw_info->weight=StringToLong(value);
1042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1049 if (LocaleCompare(keyword,"x") == 0)
1051 geometry.x=StringToLong(value);
1054 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1061 if (LocaleCompare(keyword,"y") == 0)
1063 geometry.y=StringToLong(value);
1066 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1072 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1078 (void) FormatLocaleString(text,MaxTextExtent,
1079 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1080 geometry.height,(double) geometry.x,(double) geometry.y);
1081 CloneString(&draw_info->geometry,text);
1082 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1083 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1084 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1085 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1086 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1088 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1090 (void) AnnotateImage(msl_info->image[n],draw_info,
1091 msl_info->exception);
1092 draw_info=DestroyDrawInfo(draw_info);
1095 if (LocaleCompare((const char *) tag,"append") == 0)
1103 if (msl_info->image[n] == (Image *) NULL)
1105 ThrowMSLException(OptionError,"NoImagesDefined",
1106 (const char *) tag);
1110 if (attributes != (const xmlChar **) NULL)
1111 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1113 keyword=(const char *) attributes[i++];
1114 attribute=InterpretImageProperties(msl_info->image_info[n],
1115 msl_info->attributes[n],(const char *) attributes[i],
1117 CloneString(&value,attribute);
1123 if (LocaleCompare(keyword,"stack") == 0)
1125 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1128 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1130 stack=(MagickBooleanType) option;
1133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1145 append_image=AppendImages(msl_info->image[n],stack,
1146 msl_info->exception);
1147 if (append_image == (Image *) NULL)
1149 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1150 msl_info->image[n]=append_image;
1153 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1159 if (LocaleCompare((const char *) tag,"blur") == 0)
1167 if (msl_info->image[n] == (Image *) NULL)
1169 ThrowMSLException(OptionError,"NoImagesDefined",
1170 (const char *) tag);
1173 if (attributes != (const xmlChar **) NULL)
1174 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1176 keyword=(const char *) attributes[i++];
1177 attribute=InterpretImageProperties(msl_info->image_info[n],
1178 msl_info->attributes[n],(const char *) attributes[i],
1180 CloneString(&value,attribute);
1186 if (LocaleCompare(keyword,"channel") == 0)
1188 option=ParseChannelOption(value);
1190 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1192 channel=(ChannelType) option;
1195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1202 if (LocaleCompare(keyword,"geometry") == 0)
1204 flags=ParseGeometry(value,&geometry_info);
1205 if ((flags & SigmaValue) == 0)
1206 geometry_info.sigma=1.0;
1209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1216 if (LocaleCompare(keyword,"radius") == 0)
1218 geometry_info.rho=StringToDouble(value,(char **) NULL);
1221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1228 if (LocaleCompare(keyword,"sigma") == 0)
1230 geometry_info.sigma=StringToLong(value);
1233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1245 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
1246 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1247 geometry_info.sigma,msl_info->exception);
1248 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
1249 if (blur_image == (Image *) NULL)
1251 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1252 msl_info->image[n]=blur_image;
1255 if (LocaleCompare((const char *) tag,"border") == 0)
1263 if (msl_info->image[n] == (Image *) NULL)
1265 ThrowMSLException(OptionError,"NoImagesDefined",
1266 (const char *) tag);
1269 SetGeometry(msl_info->image[n],&geometry);
1270 if (attributes != (const xmlChar **) NULL)
1271 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1273 keyword=(const char *) attributes[i++];
1274 attribute=InterpretImageProperties(msl_info->image_info[n],
1275 msl_info->attributes[n],(const char *) attributes[i],
1277 CloneString(&value,attribute);
1283 if (LocaleCompare(keyword,"compose") == 0)
1285 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1288 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1290 msl_info->image[n]->compose=(CompositeOperator) option;
1293 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1300 if (LocaleCompare(keyword, "fill") == 0)
1302 (void) QueryColorCompliance(value,AllCompliance,
1303 &msl_info->image[n]->border_color,&exception);
1306 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1313 if (LocaleCompare(keyword,"geometry") == 0)
1315 flags=ParsePageGeometry(msl_info->image[n],value,
1316 &geometry,&exception);
1317 if ((flags & HeightValue) == 0)
1318 geometry.height=geometry.width;
1321 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1328 if (LocaleCompare(keyword,"height") == 0)
1330 geometry.height=StringToLong(value);
1333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1340 if (LocaleCompare(keyword,"width") == 0)
1342 geometry.width=StringToLong(value);
1345 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1351 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1357 border_image=BorderImage(msl_info->image[n],&geometry,
1358 msl_info->image[n]->compose,msl_info->exception);
1359 if (border_image == (Image *) NULL)
1361 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1362 msl_info->image[n]=border_image;
1365 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1370 if (LocaleCompare((const char *) tag,"colorize") == 0)
1373 blend[MaxTextExtent];
1384 if (msl_info->image[n] == (Image *) NULL)
1386 ThrowMSLException(OptionError,"NoImagesDefined",
1387 (const char *) tag);
1390 GetPixelInfo(msl_info->image[n],&target);
1391 (void) CopyMagickString(blend,"100",MaxTextExtent);
1392 if (attributes != (const xmlChar **) NULL)
1393 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1395 keyword=(const char *) attributes[i++];
1396 attribute=InterpretImageProperties(msl_info->image_info[n],
1397 msl_info->attributes[n],(const char *) attributes[i],
1399 CloneString(&value,attribute);
1405 if (LocaleCompare(keyword,"blend") == 0)
1407 (void) CopyMagickString(blend,value,MaxTextExtent);
1410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1417 if (LocaleCompare(keyword,"fill") == 0)
1419 (void) QueryColorCompliance(value,AllCompliance,
1420 &target,msl_info->exception);
1423 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1429 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1435 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1436 msl_info->exception);
1437 if (colorize_image == (Image *) NULL)
1439 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1440 msl_info->image[n]=colorize_image;
1443 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1449 if (msl_info->image[n] == (Image *) NULL)
1451 ThrowMSLException(OptionError,"NoImagesDefined",
1452 (const char *) tag);
1456 NOTE: charcoal can have no attributes, since we use all the defaults!
1458 if (attributes != (const xmlChar **) NULL)
1460 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1462 keyword=(const char *) attributes[i++];
1463 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1464 msl_info->attributes[n],(const char *) attributes[i],&exception));
1470 if (LocaleCompare(keyword,"radius") == 0)
1472 radius=StringToDouble(value,(char **) NULL);
1475 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1481 if (LocaleCompare(keyword,"sigma") == 0)
1483 sigma = StringToLong( value );
1486 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1491 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1505 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1506 msl_info->exception);
1507 if (newImage == (Image *) NULL)
1509 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1510 msl_info->image[n]=newImage;
1514 if (LocaleCompare((const char *) tag,"chop") == 0)
1522 if (msl_info->image[n] == (Image *) NULL)
1524 ThrowMSLException(OptionError,"NoImagesDefined",
1525 (const char *) tag);
1528 SetGeometry(msl_info->image[n],&geometry);
1529 if (attributes != (const xmlChar **) NULL)
1530 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1532 keyword=(const char *) attributes[i++];
1533 attribute=InterpretImageProperties(msl_info->image_info[n],
1534 msl_info->attributes[n],(const char *) attributes[i],
1536 CloneString(&value,attribute);
1542 if (LocaleCompare(keyword,"geometry") == 0)
1544 flags=ParsePageGeometry(msl_info->image[n],value,
1545 &geometry,&exception);
1546 if ((flags & HeightValue) == 0)
1547 geometry.height=geometry.width;
1550 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1557 if (LocaleCompare(keyword,"height") == 0)
1559 geometry.height=StringToLong(value);
1562 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1569 if (LocaleCompare(keyword,"width") == 0)
1571 geometry.width=StringToLong(value);
1574 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1581 if (LocaleCompare(keyword,"x") == 0)
1583 geometry.x=StringToLong(value);
1586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1593 if (LocaleCompare(keyword,"y") == 0)
1595 geometry.y=StringToLong(value);
1598 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1610 chop_image=ChopImage(msl_info->image[n],&geometry,
1611 msl_info->exception);
1612 if (chop_image == (Image *) NULL)
1614 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1615 msl_info->image[n]=chop_image;
1618 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1627 Color floodfill image.
1629 if (msl_info->image[n] == (Image *) NULL)
1631 ThrowMSLException(OptionError,"NoImagesDefined",
1632 (const char *) tag);
1635 draw_info=CloneDrawInfo(msl_info->image_info[n],
1636 msl_info->draw_info[n]);
1637 SetGeometry(msl_info->image[n],&geometry);
1638 paint_method=FloodfillMethod;
1639 if (attributes != (const xmlChar **) NULL)
1640 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1642 keyword=(const char *) attributes[i++];
1643 attribute=InterpretImageProperties(msl_info->image_info[n],
1644 msl_info->attributes[n],(const char *) attributes[i],
1646 CloneString(&value,attribute);
1652 if (LocaleCompare(keyword,"bordercolor") == 0)
1654 (void) QueryColorCompliance(value,AllCompliance,
1655 &target,&exception);
1656 paint_method=FillToBorderMethod;
1659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1666 if (LocaleCompare(keyword,"fill") == 0)
1668 (void) QueryColorCompliance(value,AllCompliance,
1669 &draw_info->fill,&exception);
1672 if (LocaleCompare(keyword,"fuzz") == 0)
1674 msl_info->image[n]->fuzz=StringToDouble(value,
1678 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1685 if (LocaleCompare(keyword,"geometry") == 0)
1687 flags=ParsePageGeometry(msl_info->image[n],value,
1688 &geometry,&exception);
1689 if ((flags & HeightValue) == 0)
1690 geometry.height=geometry.width;
1691 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1692 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1696 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1703 if (LocaleCompare(keyword,"x") == 0)
1705 geometry.x=StringToLong(value);
1706 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1707 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1711 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1718 if (LocaleCompare(keyword,"y") == 0)
1720 geometry.y=StringToLong(value);
1721 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1722 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1738 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1739 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1740 MagickFalse : MagickTrue,msl_info->exception);
1741 draw_info=DestroyDrawInfo(draw_info);
1744 if (LocaleCompare((const char *) tag,"comment") == 0)
1746 if (LocaleCompare((const char *) tag,"composite") == 0)
1749 composite_geometry[MaxTextExtent];
1761 if (msl_info->image[n] == (Image *) NULL)
1763 ThrowMSLException(OptionError,"NoImagesDefined",
1764 (const char *) tag);
1767 composite_image=NewImageList();
1768 compose=OverCompositeOp;
1769 if (attributes != (const xmlChar **) NULL)
1770 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1772 keyword=(const char *) attributes[i++];
1773 attribute=InterpretImageProperties(msl_info->image_info[n],
1774 msl_info->attributes[n],(const char *) attributes[i],
1776 CloneString(&value,attribute);
1782 if (LocaleCompare(keyword,"compose") == 0)
1784 option=ParseCommandOption(MagickComposeOptions,
1787 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1789 compose=(CompositeOperator) option;
1797 if (LocaleCompare(keyword,"image") == 0)
1798 for (j=0; j < msl_info->n; j++)
1803 attribute=GetImageProperty(msl_info->attributes[j],"id",
1805 if ((attribute != (const char *) NULL) &&
1806 (LocaleCompare(attribute,value) == 0))
1808 composite_image=CloneImage(msl_info->image[j],0,0,
1809 MagickFalse,&exception);
1819 if (composite_image == (Image *) NULL)
1821 rotate_image=NewImageList();
1822 SetGeometry(msl_info->image[n],&geometry);
1823 if (attributes != (const xmlChar **) NULL)
1824 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1826 keyword=(const char *) attributes[i++];
1827 attribute=InterpretImageProperties(msl_info->image_info[n],
1828 msl_info->attributes[n],(const char *) attributes[i],
1830 CloneString(&value,attribute);
1836 if (LocaleCompare(keyword,"blend") == 0)
1838 (void) SetImageArtifact(composite_image,
1839 "compose:args",value);
1842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1849 if (LocaleCompare(keyword,"channel") == 0)
1851 option=ParseChannelOption(value);
1853 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1855 channel=(ChannelType) option;
1858 if (LocaleCompare(keyword, "color") == 0)
1860 (void) QueryColorCompliance(value,AllCompliance,
1861 &composite_image->background_color,&exception);
1864 if (LocaleCompare(keyword,"compose") == 0)
1866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1873 if (LocaleCompare(keyword,"geometry") == 0)
1875 flags=ParsePageGeometry(msl_info->image[n],value,
1876 &geometry,&exception);
1877 if ((flags & HeightValue) == 0)
1878 geometry.height=geometry.width;
1881 if (LocaleCompare(keyword,"gravity") == 0)
1883 option=ParseCommandOption(MagickGravityOptions,
1886 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1888 msl_info->image[n]->gravity=(GravityType) option;
1891 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1898 if (LocaleCompare(keyword,"image") == 0)
1900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1907 if (LocaleCompare(keyword,"mask") == 0)
1908 for (j=0; j < msl_info->n; j++)
1913 attribute=GetImageProperty(msl_info->attributes[j],"id",
1915 if ((attribute != (const char *) NULL) &&
1916 (LocaleCompare(value,value) == 0))
1918 SetImageType(composite_image,TrueColorMatteType,
1920 (void) CompositeImage(composite_image,
1921 msl_info->image[j],CopyAlphaCompositeOp,MagickTrue,
1926 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1933 if (LocaleCompare(keyword,"opacity") == 0)
1948 opacity=StringToLong(value);
1949 if (compose != DissolveCompositeOp)
1951 (void) SetImageAlpha(composite_image,(Quantum)
1952 opacity,&exception);
1955 (void) SetImageArtifact(msl_info->image[n],
1956 "compose:args",value);
1957 if (composite_image->alpha_trait == UndefinedPixelTrait)
1958 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1960 composite_view=AcquireAuthenticCacheView(composite_image,&exception);
1961 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1963 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1964 (ssize_t) composite_image->columns,1,&exception);
1965 for (x=0; x < (ssize_t) composite_image->columns; x++)
1967 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1968 SetPixelAlpha(composite_image,
1969 ClampToQuantum(opacity),q);
1970 q+=GetPixelChannels(composite_image);
1972 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1975 composite_view=DestroyCacheView(composite_view);
1978 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1985 if (LocaleCompare(keyword,"rotate") == 0)
1987 rotate_image=RotateImage(composite_image,
1988 StringToDouble(value,(char **) NULL),&exception);
1991 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1998 if (LocaleCompare(keyword,"tile") == 0)
2003 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2006 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2008 tile=(MagickBooleanType) option;
2010 if (rotate_image != (Image *) NULL)
2011 (void) SetImageArtifact(rotate_image,
2012 "compose:outside-overlay","false");
2014 (void) SetImageArtifact(composite_image,
2015 "compose:outside-overlay","false");
2016 image=msl_info->image[n];
2017 height=composite_image->rows;
2018 width=composite_image->columns;
2019 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2020 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2022 if (rotate_image != (Image *) NULL)
2023 (void) CompositeImage(image,rotate_image,compose,
2024 MagickTrue,x,y,&exception);
2026 (void) CompositeImage(image,composite_image,
2027 compose,MagickTrue,x,y,&exception);
2029 if (rotate_image != (Image *) NULL)
2030 rotate_image=DestroyImage(rotate_image);
2033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2040 if (LocaleCompare(keyword,"x") == 0)
2042 geometry.x=StringToLong(value);
2045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2052 if (LocaleCompare(keyword,"y") == 0)
2054 geometry.y=StringToLong(value);
2057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2063 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2069 image=msl_info->image[n];
2070 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2071 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2072 (double) composite_image->rows,(double) geometry.x,(double)
2074 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2076 channel_mask=SetImageChannelMask(image,channel);
2077 if (rotate_image == (Image *) NULL)
2078 CompositeImage(image,composite_image,compose,MagickTrue,geometry.x,
2079 geometry.y,&exception);
2085 geometry.x-=(ssize_t) (rotate_image->columns-
2086 composite_image->columns)/2;
2087 geometry.y-=(ssize_t) (rotate_image->rows-
2088 composite_image->rows)/2;
2089 CompositeImage(image,rotate_image,compose,MagickTrue,geometry.x,
2090 geometry.y,&exception);
2091 rotate_image=DestroyImage(rotate_image);
2093 (void) SetImageChannelMask(image,channel_mask);
2094 composite_image=DestroyImage(composite_image);
2097 if (LocaleCompare((const char *) tag,"contrast") == 0)
2105 if (msl_info->image[n] == (Image *) NULL)
2107 ThrowMSLException(OptionError,"NoImagesDefined",
2108 (const char *) tag);
2111 sharpen=MagickFalse;
2112 if (attributes != (const xmlChar **) NULL)
2113 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2115 keyword=(const char *) attributes[i++];
2116 attribute=InterpretImageProperties(msl_info->image_info[n],
2117 msl_info->attributes[n],(const char *) attributes[i],
2119 CloneString(&value,attribute);
2125 if (LocaleCompare(keyword,"sharpen") == 0)
2127 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2130 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2132 sharpen=(MagickBooleanType) option;
2135 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2141 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2147 (void) ContrastImage(msl_info->image[n],sharpen,
2148 msl_info->exception);
2151 if (LocaleCompare((const char *) tag,"crop") == 0)
2159 if (msl_info->image[n] == (Image *) NULL)
2161 ThrowMSLException(OptionError,"NoImagesDefined",
2162 (const char *) tag);
2165 SetGeometry(msl_info->image[n],&geometry);
2166 if (attributes != (const xmlChar **) NULL)
2167 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2169 keyword=(const char *) attributes[i++];
2170 attribute=InterpretImageProperties(msl_info->image_info[n],
2171 msl_info->attributes[n],(const char *) attributes[i],
2173 CloneString(&value,attribute);
2179 if (LocaleCompare(keyword,"geometry") == 0)
2181 flags=ParseGravityGeometry(msl_info->image[n],value,
2182 &geometry,&exception);
2185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2192 if (LocaleCompare(keyword,"height") == 0)
2194 geometry.height=StringToLong(value);
2197 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2204 if (LocaleCompare(keyword,"width") == 0)
2206 geometry.width=StringToLong(value);
2209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2216 if (LocaleCompare(keyword,"x") == 0)
2218 geometry.x=StringToLong(value);
2221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2228 if (LocaleCompare(keyword,"y") == 0)
2230 geometry.y=StringToLong(value);
2233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2245 crop_image=CropImage(msl_info->image[n],&geometry,
2246 msl_info->exception);
2247 if (crop_image == (Image *) NULL)
2249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2250 msl_info->image[n]=crop_image;
2253 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2259 Cycle-colormap image.
2261 if (msl_info->image[n] == (Image *) NULL)
2263 ThrowMSLException(OptionError,"NoImagesDefined",
2264 (const char *) tag);
2268 if (attributes != (const xmlChar **) NULL)
2269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2271 keyword=(const char *) attributes[i++];
2272 attribute=InterpretImageProperties(msl_info->image_info[n],
2273 msl_info->attributes[n],(const char *) attributes[i],
2275 CloneString(&value,attribute);
2281 if (LocaleCompare(keyword,"display") == 0)
2283 display=StringToLong(value);
2286 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2292 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2298 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2301 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2306 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2314 if (msl_info->image[n] == (Image *) NULL)
2316 ThrowMSLException(OptionError,"NoImagesDefined",
2317 (const char *) tag);
2320 if (attributes != (const xmlChar **) NULL)
2321 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2323 keyword=(const char *) attributes[i++];
2324 attribute=InterpretImageProperties(msl_info->image_info[n],
2325 msl_info->attributes[n],(const char *) attributes[i],
2327 CloneString(&value,attribute);
2328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2330 despeckle_image=DespeckleImage(msl_info->image[n],
2331 msl_info->exception);
2332 if (despeckle_image == (Image *) NULL)
2334 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2335 msl_info->image[n]=despeckle_image;
2338 if (LocaleCompare((const char *) tag,"display") == 0)
2340 if (msl_info->image[n] == (Image *) NULL)
2342 ThrowMSLException(OptionError,"NoImagesDefined",
2343 (const char *) tag);
2346 if (attributes != (const xmlChar **) NULL)
2347 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2349 keyword=(const char *) attributes[i++];
2350 attribute=InterpretImageProperties(msl_info->image_info[n],
2351 msl_info->attributes[n],(const char *) attributes[i],
2353 CloneString(&value,attribute);
2358 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2364 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2365 msl_info->exception);
2368 if (LocaleCompare((const char *) tag,"draw") == 0)
2371 text[MaxTextExtent];
2376 if (msl_info->image[n] == (Image *) NULL)
2378 ThrowMSLException(OptionError,"NoImagesDefined",
2379 (const char *) tag);
2382 draw_info=CloneDrawInfo(msl_info->image_info[n],
2383 msl_info->draw_info[n]);
2385 current=draw_info->affine;
2386 GetAffineMatrix(&affine);
2387 if (attributes != (const xmlChar **) NULL)
2388 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2390 keyword=(const char *) attributes[i++];
2391 attribute=InterpretImageProperties(msl_info->image_info[n],
2392 msl_info->attributes[n],(const char *) attributes[i],
2394 CloneString(&value,attribute);
2400 if (LocaleCompare(keyword,"affine") == 0)
2406 draw_info->affine.sx=StringToDouble(p,&p);
2409 draw_info->affine.rx=StringToDouble(p,&p);
2412 draw_info->affine.ry=StringToDouble(p,&p);
2415 draw_info->affine.sy=StringToDouble(p,&p);
2418 draw_info->affine.tx=StringToDouble(p,&p);
2421 draw_info->affine.ty=StringToDouble(p,&p);
2424 if (LocaleCompare(keyword,"align") == 0)
2426 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2429 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2431 draw_info->align=(AlignType) option;
2434 if (LocaleCompare(keyword,"antialias") == 0)
2436 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2439 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2441 draw_info->stroke_antialias=(MagickBooleanType) option;
2442 draw_info->text_antialias=(MagickBooleanType) option;
2445 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2452 if (LocaleCompare(keyword,"density") == 0)
2454 CloneString(&draw_info->density,value);
2457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2464 if (LocaleCompare(keyword,"encoding") == 0)
2466 CloneString(&draw_info->encoding,value);
2469 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2476 if (LocaleCompare(keyword, "fill") == 0)
2478 (void) QueryColorCompliance(value,AllCompliance,
2479 &draw_info->fill,&exception);
2482 if (LocaleCompare(keyword,"family") == 0)
2484 CloneString(&draw_info->family,value);
2487 if (LocaleCompare(keyword,"font") == 0)
2489 CloneString(&draw_info->font,value);
2492 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2499 if (LocaleCompare(keyword,"geometry") == 0)
2501 flags=ParsePageGeometry(msl_info->image[n],value,
2502 &geometry,&exception);
2503 if ((flags & HeightValue) == 0)
2504 geometry.height=geometry.width;
2507 if (LocaleCompare(keyword,"gravity") == 0)
2509 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2512 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2514 draw_info->gravity=(GravityType) option;
2517 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2524 if (LocaleCompare(keyword,"primitive") == 0)
2526 CloneString(&draw_info->primitive,value);
2529 if (LocaleCompare(keyword,"pointsize") == 0)
2531 draw_info->pointsize=StringToDouble(value,
2535 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2542 if (LocaleCompare(keyword,"rotate") == 0)
2544 angle=StringToDouble(value,(char **) NULL);
2545 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2546 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2547 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2548 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2551 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2558 if (LocaleCompare(keyword,"scale") == 0)
2560 flags=ParseGeometry(value,&geometry_info);
2561 if ((flags & SigmaValue) == 0)
2562 geometry_info.sigma=1.0;
2563 affine.sx=geometry_info.rho;
2564 affine.sy=geometry_info.sigma;
2567 if (LocaleCompare(keyword,"skewX") == 0)
2569 angle=StringToDouble(value,(char **) NULL);
2570 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2573 if (LocaleCompare(keyword,"skewY") == 0)
2575 angle=StringToDouble(value,(char **) NULL);
2576 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2579 if (LocaleCompare(keyword,"stretch") == 0)
2581 option=ParseCommandOption(MagickStretchOptions,
2584 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2586 draw_info->stretch=(StretchType) option;
2589 if (LocaleCompare(keyword, "stroke") == 0)
2591 (void) QueryColorCompliance(value,AllCompliance,
2592 &draw_info->stroke,&exception);
2595 if (LocaleCompare(keyword,"strokewidth") == 0)
2597 draw_info->stroke_width=StringToLong(value);
2600 if (LocaleCompare(keyword,"style") == 0)
2602 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2605 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2607 draw_info->style=(StyleType) option;
2610 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2617 if (LocaleCompare(keyword,"text") == 0)
2619 CloneString(&draw_info->text,value);
2622 if (LocaleCompare(keyword,"translate") == 0)
2624 flags=ParseGeometry(value,&geometry_info);
2625 if ((flags & SigmaValue) == 0)
2626 geometry_info.sigma=1.0;
2627 affine.tx=geometry_info.rho;
2628 affine.ty=geometry_info.sigma;
2631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2638 if (LocaleCompare(keyword, "undercolor") == 0)
2640 (void) QueryColorCompliance(value,AllCompliance,
2641 &draw_info->undercolor,&exception);
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2651 if (LocaleCompare(keyword,"weight") == 0)
2653 draw_info->weight=StringToLong(value);
2656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2663 if (LocaleCompare(keyword,"x") == 0)
2665 geometry.x=StringToLong(value);
2668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2675 if (LocaleCompare(keyword,"y") == 0)
2677 geometry.y=StringToLong(value);
2680 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2692 (void) FormatLocaleString(text,MaxTextExtent,
2693 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2694 geometry.height,(double) geometry.x,(double) geometry.y);
2695 CloneString(&draw_info->geometry,text);
2696 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2697 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2698 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2699 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2700 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2702 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2704 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2705 draw_info=DestroyDrawInfo(draw_info);
2708 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2713 if (LocaleCompare((const char *) tag,"edge") == 0)
2721 if (msl_info->image[n] == (Image *) NULL)
2723 ThrowMSLException(OptionError,"NoImagesDefined",
2724 (const char *) tag);
2727 if (attributes != (const xmlChar **) NULL)
2728 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2730 keyword=(const char *) attributes[i++];
2731 attribute=InterpretImageProperties(msl_info->image_info[n],
2732 msl_info->attributes[n],(const char *) attributes[i],
2734 CloneString(&value,attribute);
2740 if (LocaleCompare(keyword,"geometry") == 0)
2742 flags=ParseGeometry(value,&geometry_info);
2743 if ((flags & SigmaValue) == 0)
2744 geometry_info.sigma=1.0;
2747 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2754 if (LocaleCompare(keyword,"radius") == 0)
2756 geometry_info.rho=StringToDouble(value,(char **) NULL);
2759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2771 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2772 msl_info->exception);
2773 if (edge_image == (Image *) NULL)
2775 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2776 msl_info->image[n]=edge_image;
2779 if (LocaleCompare((const char *) tag,"emboss") == 0)
2787 if (msl_info->image[n] == (Image *) NULL)
2789 ThrowMSLException(OptionError,"NoImagesDefined",
2790 (const char *) tag);
2793 if (attributes != (const xmlChar **) NULL)
2794 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2796 keyword=(const char *) attributes[i++];
2797 attribute=InterpretImageProperties(msl_info->image_info[n],
2798 msl_info->attributes[n],(const char *) attributes[i],
2800 CloneString(&value,attribute);
2806 if (LocaleCompare(keyword,"geometry") == 0)
2808 flags=ParseGeometry(value,&geometry_info);
2809 if ((flags & SigmaValue) == 0)
2810 geometry_info.sigma=1.0;
2813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2820 if (LocaleCompare(keyword,"radius") == 0)
2822 geometry_info.rho=StringToDouble(value,
2826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2833 if (LocaleCompare(keyword,"sigma") == 0)
2835 geometry_info.sigma=StringToLong(value);
2838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2850 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2851 geometry_info.sigma,msl_info->exception);
2852 if (emboss_image == (Image *) NULL)
2854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2855 msl_info->image[n]=emboss_image;
2858 if (LocaleCompare((const char *) tag,"enhance") == 0)
2866 if (msl_info->image[n] == (Image *) NULL)
2868 ThrowMSLException(OptionError,"NoImagesDefined",
2869 (const char *) tag);
2872 if (attributes != (const xmlChar **) NULL)
2873 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2875 keyword=(const char *) attributes[i++];
2876 attribute=InterpretImageProperties(msl_info->image_info[n],
2877 msl_info->attributes[n],(const char *) attributes[i],
2879 CloneString(&value,attribute);
2880 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2882 enhance_image=EnhanceImage(msl_info->image[n],
2883 msl_info->exception);
2884 if (enhance_image == (Image *) NULL)
2886 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2887 msl_info->image[n]=enhance_image;
2890 if (LocaleCompare((const char *) tag,"equalize") == 0)
2895 if (msl_info->image[n] == (Image *) NULL)
2897 ThrowMSLException(OptionError,"NoImagesDefined",
2898 (const char *) tag);
2901 if (attributes != (const xmlChar **) NULL)
2902 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2904 keyword=(const char *) attributes[i++];
2905 attribute=InterpretImageProperties(msl_info->image_info[n],
2906 msl_info->attributes[n],(const char *) attributes[i],
2908 CloneString(&value,attribute);
2913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2919 (void) EqualizeImage(msl_info->image[n],
2920 msl_info->exception);
2923 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2928 if (LocaleCompare((const char *) tag, "flatten") == 0)
2930 if (msl_info->image[n] == (Image *) NULL)
2932 ThrowMSLException(OptionError,"NoImagesDefined",
2933 (const char *) tag);
2937 /* no attributes here */
2939 /* process the image */
2944 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2945 msl_info->exception);
2946 if (newImage == (Image *) NULL)
2948 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2949 msl_info->image[n]=newImage;
2953 if (LocaleCompare((const char *) tag,"flip") == 0)
2961 if (msl_info->image[n] == (Image *) NULL)
2963 ThrowMSLException(OptionError,"NoImagesDefined",
2964 (const char *) tag);
2967 if (attributes != (const xmlChar **) NULL)
2968 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2970 keyword=(const char *) attributes[i++];
2971 attribute=InterpretImageProperties(msl_info->image_info[n],
2972 msl_info->attributes[n],(const char *) attributes[i],
2974 CloneString(&value,attribute);
2975 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2977 flip_image=FlipImage(msl_info->image[n],
2978 msl_info->exception);
2979 if (flip_image == (Image *) NULL)
2981 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2982 msl_info->image[n]=flip_image;
2985 if (LocaleCompare((const char *) tag,"flop") == 0)
2993 if (msl_info->image[n] == (Image *) NULL)
2995 ThrowMSLException(OptionError,"NoImagesDefined",
2996 (const char *) tag);
2999 if (attributes != (const xmlChar **) NULL)
3000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3002 keyword=(const char *) attributes[i++];
3003 attribute=InterpretImageProperties(msl_info->image_info[n],
3004 msl_info->attributes[n],(const char *) attributes[i],
3006 CloneString(&value,attribute);
3007 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3009 flop_image=FlopImage(msl_info->image[n],
3010 msl_info->exception);
3011 if (flop_image == (Image *) NULL)
3013 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3014 msl_info->image[n]=flop_image;
3017 if (LocaleCompare((const char *) tag,"frame") == 0)
3028 if (msl_info->image[n] == (Image *) NULL)
3030 ThrowMSLException(OptionError,"NoImagesDefined",
3031 (const char *) tag);
3034 SetGeometry(msl_info->image[n],&geometry);
3035 if (attributes != (const xmlChar **) NULL)
3036 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3038 keyword=(const char *) attributes[i++];
3039 attribute=InterpretImageProperties(msl_info->image_info[n],
3040 msl_info->attributes[n],(const char *) attributes[i],
3042 CloneString(&value,attribute);
3048 if (LocaleCompare(keyword,"compose") == 0)
3050 option=ParseCommandOption(MagickComposeOptions,
3053 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3055 msl_info->image[n]->compose=(CompositeOperator) option;
3058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3065 if (LocaleCompare(keyword, "fill") == 0)
3067 (void) QueryColorCompliance(value,AllCompliance,
3068 &msl_info->image[n]->matte_color,&exception);
3071 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3078 if (LocaleCompare(keyword,"geometry") == 0)
3080 flags=ParsePageGeometry(msl_info->image[n],value,
3081 &geometry,&exception);
3082 if ((flags & HeightValue) == 0)
3083 geometry.height=geometry.width;
3084 frame_info.width=geometry.width;
3085 frame_info.height=geometry.height;
3086 frame_info.outer_bevel=geometry.x;
3087 frame_info.inner_bevel=geometry.y;
3090 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3097 if (LocaleCompare(keyword,"height") == 0)
3099 frame_info.height=StringToLong(value);
3102 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3109 if (LocaleCompare(keyword,"inner") == 0)
3111 frame_info.inner_bevel=StringToLong(value);
3114 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3121 if (LocaleCompare(keyword,"outer") == 0)
3123 frame_info.outer_bevel=StringToLong(value);
3126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3133 if (LocaleCompare(keyword,"width") == 0)
3135 frame_info.width=StringToLong(value);
3138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3150 frame_info.x=(ssize_t) frame_info.width;
3151 frame_info.y=(ssize_t) frame_info.height;
3152 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3153 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3154 frame_image=FrameImage(msl_info->image[n],&frame_info,
3155 msl_info->image[n]->compose,msl_info->exception);
3156 if (frame_image == (Image *) NULL)
3158 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3159 msl_info->image[n]=frame_image;
3162 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3167 if (LocaleCompare((const char *) tag,"gamma") == 0)
3170 gamma[MaxTextExtent];
3178 if (msl_info->image[n] == (Image *) NULL)
3180 ThrowMSLException(OptionError,"NoImagesDefined",
3181 (const char *) tag);
3184 channel=UndefinedChannel;
3189 if (attributes != (const xmlChar **) NULL)
3190 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3192 keyword=(const char *) attributes[i++];
3193 attribute=InterpretImageProperties(msl_info->image_info[n],
3194 msl_info->attributes[n],(const char *) attributes[i],
3196 CloneString(&value,attribute);
3202 if (LocaleCompare(keyword,"blue") == 0)
3204 pixel.blue=StringToDouble(value,(char **) NULL);
3207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3214 if (LocaleCompare(keyword,"channel") == 0)
3216 option=ParseChannelOption(value);
3218 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3220 channel=(ChannelType) option;
3223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3230 if (LocaleCompare(keyword,"gamma") == 0)
3232 (void) CopyMagickString(gamma,value,MaxTextExtent);
3235 if (LocaleCompare(keyword,"green") == 0)
3237 pixel.green=StringToDouble(value,(char **) NULL);
3240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3247 if (LocaleCompare(keyword,"red") == 0)
3249 pixel.red=StringToDouble(value,(char **) NULL);
3252 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3258 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3265 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3266 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3267 (void) GammaImage(msl_info->image[n],atof(gamma),
3268 msl_info->exception);
3271 else if (LocaleCompare((const char *) tag,"get") == 0)
3273 if (msl_info->image[n] == (Image *) NULL)
3275 ThrowMSLException(OptionError,"NoImagesDefined",
3276 (const char *) tag);
3279 if (attributes == (const xmlChar **) NULL)
3281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3283 keyword=(const char *) attributes[i++];
3284 CloneString(&value,(const char *) attributes[i]);
3285 (void) CopyMagickString(key,value,MaxTextExtent);
3291 if (LocaleCompare(keyword,"height") == 0)
3293 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3294 (double) msl_info->image[n]->rows);
3295 (void) SetImageProperty(msl_info->attributes[n],key,value,
3299 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3304 if (LocaleCompare(keyword,"width") == 0)
3306 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3307 (double) msl_info->image[n]->columns);
3308 (void) SetImageProperty(msl_info->attributes[n],key,value,
3312 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3316 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3323 else if (LocaleCompare((const char *) tag, "group") == 0)
3325 msl_info->number_groups++;
3326 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3327 msl_info->group_info,msl_info->number_groups+1UL,
3328 sizeof(*msl_info->group_info));
3331 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3336 if (LocaleCompare((const char *) tag,"image") == 0)
3338 MSLPushImage(msl_info,(Image *) NULL);
3339 if (attributes == (const xmlChar **) NULL)
3341 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3343 keyword=(const char *) attributes[i++];
3344 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3345 msl_info->attributes[n],(const char *) attributes[i],&exception));
3351 if (LocaleCompare(keyword,"color") == 0)
3356 (void) CopyMagickString(msl_info->image_info[n]->filename,
3357 "xc:",MaxTextExtent);
3358 (void) ConcatenateMagickString(msl_info->image_info[n]->
3359 filename,value,MaxTextExtent);
3360 next_image=ReadImage(msl_info->image_info[n],&exception);
3361 CatchException(&exception);
3362 if (next_image == (Image *) NULL)
3364 if (msl_info->image[n] == (Image *) NULL)
3365 msl_info->image[n]=next_image;
3372 Link image into image list.
3374 p=msl_info->image[n];
3375 while (p->next != (Image *) NULL)
3376 p=GetNextImageInList(p);
3377 next_image->previous=p;
3382 (void) SetMSLAttributes(msl_info,keyword,value);
3387 (void) SetMSLAttributes(msl_info,keyword,value);
3394 if (LocaleCompare((const char *) tag,"implode") == 0)
3402 if (msl_info->image[n] == (Image *) NULL)
3404 ThrowMSLException(OptionError,"NoImagesDefined",
3405 (const char *) tag);
3408 if (attributes != (const xmlChar **) NULL)
3409 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3411 keyword=(const char *) attributes[i++];
3412 attribute=InterpretImageProperties(msl_info->image_info[n],
3413 msl_info->attributes[n],(const char *) attributes[i],
3415 CloneString(&value,attribute);
3421 if (LocaleCompare(keyword,"amount") == 0)
3423 geometry_info.rho=StringToDouble(value,
3427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3434 if (LocaleCompare(keyword,"geometry") == 0)
3436 flags=ParseGeometry(value,&geometry_info);
3437 if ((flags & SigmaValue) == 0)
3438 geometry_info.sigma=1.0;
3441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3447 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3453 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3454 msl_info->image[n]->interpolate,msl_info->exception);
3455 if (implode_image == (Image *) NULL)
3457 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3458 msl_info->image[n]=implode_image;
3461 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3466 if (LocaleCompare((const char *) tag,"label") == 0)
3468 if (LocaleCompare((const char *) tag, "level") == 0)
3471 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3473 if (msl_info->image[n] == (Image *) NULL)
3475 ThrowMSLException(OptionError,"NoImagesDefined",
3476 (const char *) tag);
3479 if (attributes == (const xmlChar **) NULL)
3481 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3483 keyword=(const char *) attributes[i++];
3484 CloneString(&value,(const char *) attributes[i]);
3485 (void) CopyMagickString(key,value,MaxTextExtent);
3491 if (LocaleCompare(keyword,"black") == 0)
3493 levelBlack = StringToDouble(value,(char **) NULL);
3496 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3502 if (LocaleCompare(keyword,"gamma") == 0)
3504 levelGamma = StringToDouble(value,(char **) NULL);
3507 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3513 if (LocaleCompare(keyword,"white") == 0)
3515 levelWhite = StringToDouble(value,(char **) NULL);
3518 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3523 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3530 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3531 msl_info->exception);
3538 if (LocaleCompare((const char *) tag,"magnify") == 0)
3546 if (msl_info->image[n] == (Image *) NULL)
3548 ThrowMSLException(OptionError,"NoImagesDefined",
3549 (const char *) tag);
3552 if (attributes != (const xmlChar **) NULL)
3553 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3555 keyword=(const char *) attributes[i++];
3556 attribute=InterpretImageProperties(msl_info->image_info[n],
3557 msl_info->attributes[n],(const char *) attributes[i],
3559 CloneString(&value,attribute);
3560 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3562 magnify_image=MagnifyImage(msl_info->image[n],
3563 msl_info->exception);
3564 if (magnify_image == (Image *) NULL)
3566 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3567 msl_info->image[n]=magnify_image;
3570 if (LocaleCompare((const char *) tag,"map") == 0)
3584 if (msl_info->image[n] == (Image *) NULL)
3586 ThrowMSLException(OptionError,"NoImagesDefined",
3587 (const char *) tag);
3590 affinity_image=NewImageList();
3592 if (attributes != (const xmlChar **) NULL)
3593 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3595 keyword=(const char *) attributes[i++];
3596 attribute=InterpretImageProperties(msl_info->image_info[n],
3597 msl_info->attributes[n],(const char *) attributes[i],
3599 CloneString(&value,attribute);
3605 if (LocaleCompare(keyword,"dither") == 0)
3607 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3610 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3612 dither=(MagickBooleanType) option;
3615 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3622 if (LocaleCompare(keyword,"image") == 0)
3623 for (j=0; j < msl_info->n; j++)
3628 attribute=GetImageProperty(msl_info->attributes[j],"id",
3630 if ((attribute != (const char *) NULL) &&
3631 (LocaleCompare(attribute,value) == 0))
3633 affinity_image=CloneImage(msl_info->image[j],0,0,
3634 MagickFalse,&exception);
3642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3648 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3649 quantize_info->dither_method=dither != MagickFalse ?
3650 RiemersmaDitherMethod : NoDitherMethod;
3651 (void) RemapImages(quantize_info,msl_info->image[n],
3652 affinity_image,&exception);
3653 quantize_info=DestroyQuantizeInfo(quantize_info);
3654 affinity_image=DestroyImage(affinity_image);
3657 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3669 Matte floodfill image.
3672 if (msl_info->image[n] == (Image *) NULL)
3674 ThrowMSLException(OptionError,"NoImagesDefined",
3675 (const char *) tag);
3678 SetGeometry(msl_info->image[n],&geometry);
3679 paint_method=FloodfillMethod;
3680 if (attributes != (const xmlChar **) NULL)
3681 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3683 keyword=(const char *) attributes[i++];
3684 attribute=InterpretImageProperties(msl_info->image_info[n],
3685 msl_info->attributes[n],(const char *) attributes[i],
3687 CloneString(&value,attribute);
3693 if (LocaleCompare(keyword,"bordercolor") == 0)
3695 (void) QueryColorCompliance(value,AllCompliance,
3696 &target,&exception);
3697 paint_method=FillToBorderMethod;
3700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3707 if (LocaleCompare(keyword,"fuzz") == 0)
3709 msl_info->image[n]->fuzz=StringToDouble(value,
3713 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3720 if (LocaleCompare(keyword,"geometry") == 0)
3722 flags=ParsePageGeometry(msl_info->image[n],value,
3723 &geometry,&exception);
3724 if ((flags & HeightValue) == 0)
3725 geometry.height=geometry.width;
3726 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3727 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3738 if (LocaleCompare(keyword,"opacity") == 0)
3740 opacity=StringToDouble(value,(char **) NULL);
3743 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3750 if (LocaleCompare(keyword,"x") == 0)
3752 geometry.x=StringToLong(value);
3753 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3754 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3765 if (LocaleCompare(keyword,"y") == 0)
3767 geometry.y=StringToLong(value);
3768 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3769 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3785 draw_info=CloneDrawInfo(msl_info->image_info[n],
3786 msl_info->draw_info[n]);
3787 draw_info->fill.alpha=ClampToQuantum(opacity);
3788 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3789 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3790 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3791 MagickFalse : MagickTrue,msl_info->exception);
3792 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3793 draw_info=DestroyDrawInfo(draw_info);
3796 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3802 Median-filter image.
3804 if (msl_info->image[n] == (Image *) NULL)
3806 ThrowMSLException(OptionError,"NoImagesDefined",
3807 (const char *) tag);
3810 if (attributes != (const xmlChar **) NULL)
3811 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3813 keyword=(const char *) attributes[i++];
3814 attribute=InterpretImageProperties(msl_info->image_info[n],
3815 msl_info->attributes[n],(const char *) attributes[i],
3817 CloneString(&value,attribute);
3823 if (LocaleCompare(keyword,"geometry") == 0)
3825 flags=ParseGeometry(value,&geometry_info);
3826 if ((flags & SigmaValue) == 0)
3827 geometry_info.sigma=1.0;
3830 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3837 if (LocaleCompare(keyword,"radius") == 0)
3839 geometry_info.rho=StringToDouble(value,
3843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3855 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3856 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3857 msl_info->exception);
3858 if (median_image == (Image *) NULL)
3860 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3861 msl_info->image[n]=median_image;
3864 if (LocaleCompare((const char *) tag,"minify") == 0)
3872 if (msl_info->image[n] == (Image *) NULL)
3874 ThrowMSLException(OptionError,"NoImagesDefined",
3875 (const char *) tag);
3878 if (attributes != (const xmlChar **) NULL)
3879 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3881 keyword=(const char *) attributes[i++];
3882 attribute=InterpretImageProperties(msl_info->image_info[n],
3883 msl_info->attributes[n],(const char *) attributes[i],
3885 CloneString(&value,attribute);
3886 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3888 minify_image=MinifyImage(msl_info->image[n],
3889 msl_info->exception);
3890 if (minify_image == (Image *) NULL)
3892 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3893 msl_info->image[n]=minify_image;
3896 if (LocaleCompare((const char *) tag,"msl") == 0 )
3898 if (LocaleCompare((const char *) tag,"modulate") == 0)
3901 modulate[MaxTextExtent];
3906 if (msl_info->image[n] == (Image *) NULL)
3908 ThrowMSLException(OptionError,"NoImagesDefined",
3909 (const char *) tag);
3912 geometry_info.rho=100.0;
3913 geometry_info.sigma=100.0;
3914 geometry_info.xi=100.0;
3915 if (attributes != (const xmlChar **) NULL)
3916 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3918 keyword=(const char *) attributes[i++];
3919 attribute=InterpretImageProperties(msl_info->image_info[n],
3920 msl_info->attributes[n],(const char *) attributes[i],
3922 CloneString(&value,attribute);
3928 if (LocaleCompare(keyword,"blackness") == 0)
3930 geometry_info.rho=StringToDouble(value,
3934 if (LocaleCompare(keyword,"brightness") == 0)
3936 geometry_info.rho=StringToDouble(value,
3940 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3947 if (LocaleCompare(keyword,"factor") == 0)
3949 flags=ParseGeometry(value,&geometry_info);
3952 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3959 if (LocaleCompare(keyword,"hue") == 0)
3961 geometry_info.xi=StringToDouble(value,
3965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3972 if (LocaleCompare(keyword,"lightness") == 0)
3974 geometry_info.rho=StringToDouble(value,
3978 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3985 if (LocaleCompare(keyword,"saturation") == 0)
3987 geometry_info.sigma=StringToDouble(value,
3991 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3998 if (LocaleCompare(keyword,"whiteness") == 0)
4000 geometry_info.sigma=StringToDouble(value,
4004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4010 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4016 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4017 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4018 (void) ModulateImage(msl_info->image[n],modulate,
4019 msl_info->exception);
4022 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4027 if (LocaleCompare((const char *) tag,"negate") == 0)
4035 if (msl_info->image[n] == (Image *) NULL)
4037 ThrowMSLException(OptionError,"NoImagesDefined",
4038 (const char *) tag);
4042 if (attributes != (const xmlChar **) NULL)
4043 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4045 keyword=(const char *) attributes[i++];
4046 attribute=InterpretImageProperties(msl_info->image_info[n],
4047 msl_info->attributes[n],(const char *) attributes[i],
4049 CloneString(&value,attribute);
4055 if (LocaleCompare(keyword,"channel") == 0)
4057 option=ParseChannelOption(value);
4059 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4061 channel=(ChannelType) option;
4064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4071 if (LocaleCompare(keyword,"gray") == 0)
4073 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4076 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4078 gray=(MagickBooleanType) option;
4081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4087 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4093 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4094 (void) NegateImage(msl_info->image[n],gray,
4095 msl_info->exception);
4096 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4099 if (LocaleCompare((const char *) tag,"normalize") == 0)
4104 if (msl_info->image[n] == (Image *) NULL)
4106 ThrowMSLException(OptionError,"NoImagesDefined",
4107 (const char *) tag);
4110 if (attributes != (const xmlChar **) NULL)
4111 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4113 keyword=(const char *) attributes[i++];
4114 attribute=InterpretImageProperties(msl_info->image_info[n],
4115 msl_info->attributes[n],(const char *) attributes[i],
4117 CloneString(&value,attribute);
4123 if (LocaleCompare(keyword,"channel") == 0)
4125 option=ParseChannelOption(value);
4127 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4129 channel=(ChannelType) option;
4132 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4144 (void) NormalizeImage(msl_info->image[n],
4145 msl_info->exception);
4148 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4153 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4161 if (msl_info->image[n] == (Image *) NULL)
4163 ThrowMSLException(OptionError,"NoImagesDefined",
4164 (const char *) tag);
4167 if (attributes != (const xmlChar **) NULL)
4168 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4170 keyword=(const char *) attributes[i++];
4171 attribute=InterpretImageProperties(msl_info->image_info[n],
4172 msl_info->attributes[n],(const char *) attributes[i],
4174 CloneString(&value,attribute);
4180 if (LocaleCompare(keyword,"geometry") == 0)
4182 flags=ParseGeometry(value,&geometry_info);
4183 if ((flags & SigmaValue) == 0)
4184 geometry_info.sigma=1.0;
4187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4194 if (LocaleCompare(keyword,"radius") == 0)
4196 geometry_info.rho=StringToDouble(value,
4200 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4212 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4213 geometry_info.sigma,msl_info->exception);
4214 if (paint_image == (Image *) NULL)
4216 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4217 msl_info->image[n]=paint_image;
4220 if (LocaleCompare((const char *) tag,"opaque") == 0)
4229 if (msl_info->image[n] == (Image *) NULL)
4231 ThrowMSLException(OptionError,"NoImagesDefined",
4232 (const char *) tag);
4235 (void) QueryColorCompliance("none",AllCompliance,&target,
4237 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4239 if (attributes != (const xmlChar **) NULL)
4240 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4242 keyword=(const char *) attributes[i++];
4243 attribute=InterpretImageProperties(msl_info->image_info[n],
4244 msl_info->attributes[n],(const char *) attributes[i],
4246 CloneString(&value,attribute);
4252 if (LocaleCompare(keyword,"channel") == 0)
4254 option=ParseChannelOption(value);
4256 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4258 channel=(ChannelType) option;
4261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4268 if (LocaleCompare(keyword,"fill") == 0)
4270 (void) QueryColorCompliance(value,AllCompliance,
4271 &fill_color,&exception);
4274 if (LocaleCompare(keyword,"fuzz") == 0)
4276 msl_info->image[n]->fuzz=StringToDouble(value,
4280 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4286 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4292 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4293 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4294 MagickFalse,msl_info->exception);
4295 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4298 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4303 if (LocaleCompare((const char *) tag,"print") == 0)
4305 if (attributes == (const xmlChar **) NULL)
4307 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4309 keyword=(const char *) attributes[i++];
4310 attribute=InterpretImageProperties(msl_info->image_info[n],
4311 msl_info->attributes[n],(const char *) attributes[i],
4313 CloneString(&value,attribute);
4319 if (LocaleCompare(keyword,"output") == 0)
4321 (void) FormatLocaleFile(stdout,"%s",value);
4324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4329 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4336 if (LocaleCompare((const char *) tag, "profile") == 0)
4338 if (msl_info->image[n] == (Image *) NULL)
4340 ThrowMSLException(OptionError,"NoImagesDefined",
4341 (const char *) tag);
4344 if (attributes == (const xmlChar **) NULL)
4346 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4360 keyword=(const char *) attributes[i++];
4361 attribute=InterpretImageProperties(msl_info->image_info[n],
4362 msl_info->attributes[n],(const char *) attributes[i],
4364 CloneString(&value,attribute);
4365 if (*keyword == '!')
4368 Remove a profile from the image.
4370 (void) ProfileImage(msl_info->image[n],keyword,
4371 (const unsigned char *) NULL,0,&exception);
4375 Associate a profile with the image.
4377 profile_info=CloneImageInfo(msl_info->image_info[n]);
4378 profile=GetImageProfile(msl_info->image[n],"iptc");
4379 if (profile != (StringInfo *) NULL)
4380 profile_info->profile=(void *) CloneStringInfo(profile);
4381 profile_image=GetImageCache(profile_info,keyword,&exception);
4382 profile_info=DestroyImageInfo(profile_info);
4383 if (profile_image == (Image *) NULL)
4386 name[MaxTextExtent],
4387 filename[MaxTextExtent];
4395 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4396 (void) CopyMagickString(name,keyword,MaxTextExtent);
4397 for (p=filename; *p != '\0'; p++)
4398 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4399 (IsPathAccessible(keyword) == MagickFalse))
4405 Look for profile name (e.g. name:profile).
4407 (void) CopyMagickString(name,filename,(size_t)
4409 for (q=filename; *q != '\0'; q++)
4413 profile=FileToStringInfo(filename,~0UL,&exception);
4414 if (profile != (StringInfo *) NULL)
4416 (void) ProfileImage(msl_info->image[n],name,
4417 GetStringInfoDatum(profile),(size_t)
4418 GetStringInfoLength(profile),&exception);
4419 profile=DestroyStringInfo(profile);
4423 ResetImageProfileIterator(profile_image);
4424 name=GetNextImageProfile(profile_image);
4425 while (name != (const char *) NULL)
4427 profile=GetImageProfile(profile_image,name);
4428 if (profile != (StringInfo *) NULL)
4429 (void) ProfileImage(msl_info->image[n],name,
4430 GetStringInfoDatum(profile),(size_t)
4431 GetStringInfoLength(profile),&exception);
4432 name=GetNextImageProfile(profile_image);
4434 profile_image=DestroyImage(profile_image);
4438 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4443 if (LocaleCompare((const char *) tag,"quantize") == 0)
4451 if (msl_info->image[n] == (Image *) NULL)
4453 ThrowMSLException(OptionError,"NoImagesDefined",
4454 (const char *) tag);
4457 GetQuantizeInfo(&quantize_info);
4458 if (attributes != (const xmlChar **) NULL)
4459 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4461 keyword=(const char *) attributes[i++];
4462 attribute=InterpretImageProperties(msl_info->image_info[n],
4463 msl_info->attributes[n],(const char *) attributes[i],
4465 CloneString(&value,attribute);
4471 if (LocaleCompare(keyword,"colors") == 0)
4473 quantize_info.number_colors=StringToLong(value);
4476 if (LocaleCompare(keyword,"colorspace") == 0)
4478 option=ParseCommandOption(MagickColorspaceOptions,
4481 ThrowMSLException(OptionError,
4482 "UnrecognizedColorspaceType",value);
4483 quantize_info.colorspace=(ColorspaceType) option;
4486 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4493 if (LocaleCompare(keyword,"dither") == 0)
4495 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4498 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4500 quantize_info.dither_method=(DitherMethod) option;
4503 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4510 if (LocaleCompare(keyword,"measure") == 0)
4512 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4515 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4517 quantize_info.measure_error=(MagickBooleanType) option;
4520 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4527 if (LocaleCompare(keyword,"treedepth") == 0)
4529 quantize_info.tree_depth=StringToLong(value);
4532 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4538 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4544 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4547 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4550 text[MaxTextExtent];
4561 draw_info=CloneDrawInfo(msl_info->image_info[n],
4562 msl_info->draw_info[n]);
4564 current=draw_info->affine;
4565 GetAffineMatrix(&affine);
4566 if (attributes != (const xmlChar **) NULL)
4567 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4569 keyword=(const char *) attributes[i++];
4570 attribute=InterpretImageProperties(msl_info->image_info[n],
4571 msl_info->attributes[n],(const char *) attributes[i],
4573 CloneString(&value,attribute);
4579 if (LocaleCompare(keyword,"affine") == 0)
4585 draw_info->affine.sx=StringToDouble(p,&p);
4588 draw_info->affine.rx=StringToDouble(p,&p);
4591 draw_info->affine.ry=StringToDouble(p,&p);
4594 draw_info->affine.sy=StringToDouble(p,&p);
4597 draw_info->affine.tx=StringToDouble(p,&p);
4600 draw_info->affine.ty=StringToDouble(p,&p);
4603 if (LocaleCompare(keyword,"align") == 0)
4605 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4608 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4610 draw_info->align=(AlignType) option;
4613 if (LocaleCompare(keyword,"antialias") == 0)
4615 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4618 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4620 draw_info->stroke_antialias=(MagickBooleanType) option;
4621 draw_info->text_antialias=(MagickBooleanType) option;
4624 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4631 if (LocaleCompare(keyword,"density") == 0)
4633 CloneString(&draw_info->density,value);
4636 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4643 if (LocaleCompare(keyword,"encoding") == 0)
4645 CloneString(&draw_info->encoding,value);
4648 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4655 if (LocaleCompare(keyword, "fill") == 0)
4657 (void) QueryColorCompliance(value,AllCompliance,
4658 &draw_info->fill,&exception);
4661 if (LocaleCompare(keyword,"family") == 0)
4663 CloneString(&draw_info->family,value);
4666 if (LocaleCompare(keyword,"font") == 0)
4668 CloneString(&draw_info->font,value);
4671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4678 if (LocaleCompare(keyword,"geometry") == 0)
4680 flags=ParsePageGeometry(msl_info->image[n],value,
4681 &geometry,&exception);
4682 if ((flags & HeightValue) == 0)
4683 geometry.height=geometry.width;
4686 if (LocaleCompare(keyword,"gravity") == 0)
4688 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4691 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4693 draw_info->gravity=(GravityType) option;
4696 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4703 if (LocaleCompare(keyword,"pointsize") == 0)
4705 draw_info->pointsize=StringToDouble(value,
4709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4716 if (LocaleCompare(keyword,"rotate") == 0)
4718 angle=StringToDouble(value,(char **) NULL);
4719 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4720 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4721 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4722 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4732 if (LocaleCompare(keyword,"scale") == 0)
4734 flags=ParseGeometry(value,&geometry_info);
4735 if ((flags & SigmaValue) == 0)
4736 geometry_info.sigma=1.0;
4737 affine.sx=geometry_info.rho;
4738 affine.sy=geometry_info.sigma;
4741 if (LocaleCompare(keyword,"skewX") == 0)
4743 angle=StringToDouble(value,(char **) NULL);
4744 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4747 if (LocaleCompare(keyword,"skewY") == 0)
4749 angle=StringToDouble(value,(char **) NULL);
4750 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4753 if (LocaleCompare(keyword,"stretch") == 0)
4755 option=ParseCommandOption(MagickStretchOptions,
4758 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4760 draw_info->stretch=(StretchType) option;
4763 if (LocaleCompare(keyword, "stroke") == 0)
4765 (void) QueryColorCompliance(value,AllCompliance,
4766 &draw_info->stroke,&exception);
4769 if (LocaleCompare(keyword,"strokewidth") == 0)
4771 draw_info->stroke_width=StringToLong(value);
4774 if (LocaleCompare(keyword,"style") == 0)
4776 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4779 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4781 draw_info->style=(StyleType) option;
4784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4791 if (LocaleCompare(keyword,"text") == 0)
4793 CloneString(&draw_info->text,value);
4796 if (LocaleCompare(keyword,"translate") == 0)
4798 flags=ParseGeometry(value,&geometry_info);
4799 if ((flags & SigmaValue) == 0)
4800 geometry_info.sigma=1.0;
4801 affine.tx=geometry_info.rho;
4802 affine.ty=geometry_info.sigma;
4805 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4812 if (LocaleCompare(keyword, "undercolor") == 0)
4814 (void) QueryColorCompliance(value,AllCompliance,
4815 &draw_info->undercolor,&exception);
4818 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4825 if (LocaleCompare(keyword,"weight") == 0)
4827 draw_info->weight=StringToLong(value);
4830 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4837 if (LocaleCompare(keyword,"x") == 0)
4839 geometry.x=StringToLong(value);
4842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4849 if (LocaleCompare(keyword,"y") == 0)
4851 geometry.y=StringToLong(value);
4854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4860 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4866 (void) FormatLocaleString(text,MaxTextExtent,
4867 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4868 geometry.height,(double) geometry.x,(double) geometry.y);
4869 CloneString(&draw_info->geometry,text);
4870 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4871 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4872 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4873 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4874 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4876 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4878 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4879 msl_info->exception);
4880 if (status != MagickFalse)
4885 image=msl_info->attributes[n];
4886 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4887 "%g",metrics.pixels_per_em.x);
4888 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4889 "%g",metrics.pixels_per_em.y);
4890 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4892 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4894 FormatImageProperty(image,"msl:font-metrics.width","%g",
4896 FormatImageProperty(image,"msl:font-metrics.height","%g",
4898 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4899 metrics.max_advance);
4900 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4902 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4904 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4906 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4908 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4910 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4913 draw_info=DestroyDrawInfo(draw_info);
4916 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4921 if (LocaleCompare((const char *) tag,"raise") == 0)
4929 if (msl_info->image[n] == (Image *) NULL)
4931 ThrowMSLException(OptionError,"NoImagesDefined",
4932 (const char *) tag);
4936 SetGeometry(msl_info->image[n],&geometry);
4937 if (attributes != (const xmlChar **) NULL)
4938 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4940 keyword=(const char *) attributes[i++];
4941 attribute=InterpretImageProperties(msl_info->image_info[n],
4942 msl_info->attributes[n],(const char *) attributes[i],
4944 CloneString(&value,attribute);
4950 if (LocaleCompare(keyword,"geometry") == 0)
4952 flags=ParsePageGeometry(msl_info->image[n],value,
4953 &geometry,&exception);
4954 if ((flags & HeightValue) == 0)
4955 geometry.height=geometry.width;
4958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4965 if (LocaleCompare(keyword,"height") == 0)
4967 geometry.height=StringToLong(value);
4970 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4977 if (LocaleCompare(keyword,"raise") == 0)
4979 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4982 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4984 raise=(MagickBooleanType) option;
4987 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4994 if (LocaleCompare(keyword,"width") == 0)
4996 geometry.width=StringToLong(value);
4999 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5011 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5012 msl_info->exception);
5015 if (LocaleCompare((const char *) tag,"read") == 0)
5017 if (attributes == (const xmlChar **) NULL)
5019 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5021 keyword=(const char *) attributes[i++];
5022 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5023 msl_info->attributes[n],(const char *) attributes[i],&exception));
5029 if (LocaleCompare(keyword,"filename") == 0)
5034 (void) CopyMagickString(msl_info->image_info[n]->filename,
5035 value,MaxTextExtent);
5036 image=ReadImage(msl_info->image_info[n],&exception);
5037 CatchException(&exception);
5038 if (image == (Image *) NULL)
5040 AppendImageToList(&msl_info->image[n],image);
5043 (void) SetMSLAttributes(msl_info,keyword,value);
5048 (void) SetMSLAttributes(msl_info,keyword,value);
5055 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5063 if (msl_info->image[n] == (Image *) NULL)
5065 ThrowMSLException(OptionError,"NoImagesDefined",
5066 (const char *) tag);
5069 if (attributes != (const xmlChar **) NULL)
5070 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5072 keyword=(const char *) attributes[i++];
5073 attribute=InterpretImageProperties(msl_info->image_info[n],
5074 msl_info->attributes[n],(const char *) attributes[i],
5076 CloneString(&value,attribute);
5082 if (LocaleCompare(keyword,"geometry") == 0)
5084 flags=ParseGeometry(value,&geometry_info);
5085 if ((flags & SigmaValue) == 0)
5086 geometry_info.sigma=1.0;
5089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5096 if (LocaleCompare(keyword,"radius") == 0)
5098 geometry_info.rho=StringToDouble(value,
5102 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5108 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5114 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5115 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5116 msl_info->exception);
5117 if (paint_image == (Image *) NULL)
5119 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5120 msl_info->image[n]=paint_image;
5123 else if (LocaleCompare((const char *) tag,"repage") == 0)
5125 /* init the values */
5126 width=msl_info->image[n]->page.width;
5127 height=msl_info->image[n]->page.height;
5128 x=msl_info->image[n]->page.x;
5129 y=msl_info->image[n]->page.y;
5131 if (msl_info->image[n] == (Image *) NULL)
5133 ThrowMSLException(OptionError,"NoImagesDefined",
5134 (const char *) tag);
5137 if (attributes == (const xmlChar **) NULL)
5139 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5141 keyword=(const char *) attributes[i++];
5142 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5143 msl_info->attributes[n],(const char *) attributes[i],&exception));
5149 if (LocaleCompare(keyword,"geometry") == 0)
5157 flags=ParseAbsoluteGeometry(value,&geometry);
5158 if ((flags & WidthValue) != 0)
5160 if ((flags & HeightValue) == 0)
5161 geometry.height=geometry.width;
5162 width=geometry.width;
5163 height=geometry.height;
5165 if ((flags & AspectValue) != 0)
5167 if ((flags & XValue) != 0)
5169 if ((flags & YValue) != 0)
5174 if ((flags & XValue) != 0)
5177 if ((width == 0) && (geometry.x > 0))
5178 width=msl_info->image[n]->columns+geometry.x;
5180 if ((flags & YValue) != 0)
5183 if ((height == 0) && (geometry.y > 0))
5184 height=msl_info->image[n]->rows+geometry.y;
5189 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5195 if (LocaleCompare(keyword,"height") == 0)
5197 height = StringToLong( value );
5200 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5206 if (LocaleCompare(keyword,"width") == 0)
5208 width = StringToLong( value );
5211 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5217 if (LocaleCompare(keyword,"x") == 0)
5219 x = StringToLong( value );
5222 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5228 if (LocaleCompare(keyword,"y") == 0)
5230 y = StringToLong( value );
5233 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5238 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5244 msl_info->image[n]->page.width=width;
5245 msl_info->image[n]->page.height=height;
5246 msl_info->image[n]->page.x=x;
5247 msl_info->image[n]->page.y=y;
5250 else if (LocaleCompare((const char *) tag,"resample") == 0)
5256 if (msl_info->image[n] == (Image *) NULL)
5258 ThrowMSLException(OptionError,"NoImagesDefined",
5259 (const char *) tag);
5262 if (attributes == (const xmlChar **) NULL)
5264 x_resolution=DefaultResolution;
5265 y_resolution=DefaultResolution;
5266 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5268 keyword=(const char *) attributes[i++];
5269 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5270 msl_info->attributes[n],(const char *) attributes[i],&exception));
5276 if (LocaleCompare(keyword,"geometry") == 0)
5281 flags=ParseGeometry(value,&geometry_info);
5282 if ((flags & SigmaValue) == 0)
5283 geometry_info.sigma*=geometry_info.rho;
5284 x_resolution=geometry_info.rho;
5285 y_resolution=geometry_info.sigma;
5288 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5294 if (LocaleCompare(keyword,"x-resolution") == 0)
5296 x_resolution=StringToDouble(value,(char **) NULL);
5299 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5305 if (LocaleCompare(keyword,"y-resolution") == 0)
5307 y_resolution=StringToDouble(value,(char **) NULL);
5310 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5315 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5331 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5333 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5334 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5335 msl_info->image[n]->resolution.x))+0.5);
5336 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5337 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5338 msl_info->image[n]->resolution.y))+0.5);
5339 resample_image=ResizeImage(msl_info->image[n],width,height,
5340 msl_info->image[n]->filter,msl_info->exception);
5341 if (resample_image == (Image *) NULL)
5343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5344 msl_info->image[n]=resample_image;
5348 if (LocaleCompare((const char *) tag,"resize") == 0)
5359 if (msl_info->image[n] == (Image *) NULL)
5361 ThrowMSLException(OptionError,"NoImagesDefined",
5362 (const char *) tag);
5365 filter=UndefinedFilter;
5366 if (attributes != (const xmlChar **) NULL)
5367 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5369 keyword=(const char *) attributes[i++];
5370 attribute=InterpretImageProperties(msl_info->image_info[n],
5371 msl_info->attributes[n],(const char *) attributes[i],
5373 CloneString(&value,attribute);
5379 if (LocaleCompare(keyword,"filter") == 0)
5381 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5384 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5386 filter=(FilterTypes) option;
5389 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5396 if (LocaleCompare(keyword,"geometry") == 0)
5398 flags=ParseRegionGeometry(msl_info->image[n],value,
5399 &geometry,&exception);
5402 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5409 if (LocaleCompare(keyword,"height") == 0)
5411 geometry.height=StringToUnsignedLong(value);
5414 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5421 if (LocaleCompare(keyword,"width") == 0)
5423 geometry.width=StringToLong(value);
5426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5432 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5438 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5439 geometry.height,filter,msl_info->exception);
5440 if (resize_image == (Image *) NULL)
5442 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5443 msl_info->image[n]=resize_image;
5446 if (LocaleCompare((const char *) tag,"roll") == 0)
5454 if (msl_info->image[n] == (Image *) NULL)
5456 ThrowMSLException(OptionError,"NoImagesDefined",
5457 (const char *) tag);
5460 SetGeometry(msl_info->image[n],&geometry);
5461 if (attributes != (const xmlChar **) NULL)
5462 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5464 keyword=(const char *) attributes[i++];
5465 attribute=InterpretImageProperties(msl_info->image_info[n],
5466 msl_info->attributes[n],(const char *) attributes[i],
5468 CloneString(&value,attribute);
5474 if (LocaleCompare(keyword,"geometry") == 0)
5476 flags=ParsePageGeometry(msl_info->image[n],value,
5477 &geometry,&exception);
5478 if ((flags & HeightValue) == 0)
5479 geometry.height=geometry.width;
5482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5489 if (LocaleCompare(keyword,"x") == 0)
5491 geometry.x=StringToLong(value);
5494 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5501 if (LocaleCompare(keyword,"y") == 0)
5503 geometry.y=StringToLong(value);
5506 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5512 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5518 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5519 msl_info->exception);
5520 if (roll_image == (Image *) NULL)
5522 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5523 msl_info->image[n]=roll_image;
5526 else if (LocaleCompare((const char *) tag,"roll") == 0)
5528 /* init the values */
5529 width=msl_info->image[n]->columns;
5530 height=msl_info->image[n]->rows;
5533 if (msl_info->image[n] == (Image *) NULL)
5535 ThrowMSLException(OptionError,"NoImagesDefined",
5536 (const char *) tag);
5539 if (attributes == (const xmlChar **) NULL)
5541 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5543 keyword=(const char *) attributes[i++];
5544 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5545 msl_info->attributes[n],(const char *) attributes[i],&exception));
5551 if (LocaleCompare(keyword,"geometry") == 0)
5553 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5556 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5562 if (LocaleCompare(keyword,"x") == 0)
5564 x = StringToLong( value );
5567 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5573 if (LocaleCompare(keyword,"y") == 0)
5575 y = StringToLong( value );
5578 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5583 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5596 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5597 if (newImage == (Image *) NULL)
5599 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5600 msl_info->image[n]=newImage;
5605 if (LocaleCompare((const char *) tag,"rotate") == 0)
5613 if (msl_info->image[n] == (Image *) NULL)
5615 ThrowMSLException(OptionError,"NoImagesDefined",
5616 (const char *) tag);
5619 if (attributes != (const xmlChar **) NULL)
5620 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5622 keyword=(const char *) attributes[i++];
5623 attribute=InterpretImageProperties(msl_info->image_info[n],
5624 msl_info->attributes[n],(const char *) attributes[i],
5626 CloneString(&value,attribute);
5632 if (LocaleCompare(keyword,"degrees") == 0)
5634 geometry_info.rho=StringToDouble(value,
5638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5645 if (LocaleCompare(keyword,"geometry") == 0)
5647 flags=ParseGeometry(value,&geometry_info);
5648 if ((flags & SigmaValue) == 0)
5649 geometry_info.sigma=1.0;
5652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5664 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5665 msl_info->exception);
5666 if (rotate_image == (Image *) NULL)
5668 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5669 msl_info->image[n]=rotate_image;
5672 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5674 /* init the values */
5677 if (msl_info->image[n] == (Image *) NULL)
5679 ThrowMSLException(OptionError,"NoImagesDefined",
5680 (const char *) tag);
5683 if (attributes == (const xmlChar **) NULL)
5685 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5687 keyword=(const char *) attributes[i++];
5688 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5689 msl_info->attributes[n],(const char *) attributes[i],&exception));
5695 if (LocaleCompare(keyword,"degrees") == 0)
5697 degrees = StringToDouble(value,(char **) NULL);
5700 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5705 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5718 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5719 if (newImage == (Image *) NULL)
5721 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5722 msl_info->image[n]=newImage;
5727 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5732 if (LocaleCompare((const char *) tag,"sample") == 0)
5740 if (msl_info->image[n] == (Image *) NULL)
5742 ThrowMSLException(OptionError,"NoImagesDefined",
5743 (const char *) tag);
5746 if (attributes != (const xmlChar **) NULL)
5747 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5749 keyword=(const char *) attributes[i++];
5750 attribute=InterpretImageProperties(msl_info->image_info[n],
5751 msl_info->attributes[n],(const char *) attributes[i],
5753 CloneString(&value,attribute);
5759 if (LocaleCompare(keyword,"geometry") == 0)
5761 flags=ParseRegionGeometry(msl_info->image[n],value,
5762 &geometry,&exception);
5765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5772 if (LocaleCompare(keyword,"height") == 0)
5774 geometry.height=StringToUnsignedLong(value);
5777 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5784 if (LocaleCompare(keyword,"width") == 0)
5786 geometry.width=StringToLong(value);
5789 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5801 sample_image=SampleImage(msl_info->image[n],geometry.width,
5802 geometry.height,msl_info->exception);
5803 if (sample_image == (Image *) NULL)
5805 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5806 msl_info->image[n]=sample_image;
5809 if (LocaleCompare((const char *) tag,"scale") == 0)
5817 if (msl_info->image[n] == (Image *) NULL)
5819 ThrowMSLException(OptionError,"NoImagesDefined",
5820 (const char *) tag);
5823 if (attributes != (const xmlChar **) NULL)
5824 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5826 keyword=(const char *) attributes[i++];
5827 attribute=InterpretImageProperties(msl_info->image_info[n],
5828 msl_info->attributes[n],(const char *) attributes[i],
5830 CloneString(&value,attribute);
5836 if (LocaleCompare(keyword,"geometry") == 0)
5838 flags=ParseRegionGeometry(msl_info->image[n],value,
5839 &geometry,&exception);
5842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5849 if (LocaleCompare(keyword,"height") == 0)
5851 geometry.height=StringToUnsignedLong(value);
5854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5861 if (LocaleCompare(keyword,"width") == 0)
5863 geometry.width=StringToLong(value);
5866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5878 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5879 geometry.height,msl_info->exception);
5880 if (scale_image == (Image *) NULL)
5882 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5883 msl_info->image[n]=scale_image;
5886 if (LocaleCompare((const char *) tag,"segment") == 0)
5897 if (msl_info->image[n] == (Image *) NULL)
5899 ThrowMSLException(OptionError,"NoImagesDefined",
5900 (const char *) tag);
5903 geometry_info.rho=1.0;
5904 geometry_info.sigma=1.5;
5905 colorspace=sRGBColorspace;
5906 verbose=MagickFalse;
5907 if (attributes != (const xmlChar **) NULL)
5908 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5910 keyword=(const char *) attributes[i++];
5911 attribute=InterpretImageProperties(msl_info->image_info[n],
5912 msl_info->attributes[n],(const char *) attributes[i],
5914 CloneString(&value,attribute);
5920 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5922 geometry_info.rho=StringToDouble(value,
5926 if (LocaleCompare(keyword,"colorspace") == 0)
5928 option=ParseCommandOption(MagickColorspaceOptions,
5931 ThrowMSLException(OptionError,
5932 "UnrecognizedColorspaceType",value);
5933 colorspace=(ColorspaceType) option;
5936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5943 if (LocaleCompare(keyword,"geometry") == 0)
5945 flags=ParseGeometry(value,&geometry_info);
5946 if ((flags & SigmaValue) == 0)
5947 geometry_info.sigma=1.5;
5950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5957 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5959 geometry_info.sigma=StringToDouble(value,
5963 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5969 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5975 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5976 geometry_info.rho,geometry_info.sigma,&exception);
5979 else if (LocaleCompare((const char *) tag, "set") == 0)
5981 if (msl_info->image[n] == (Image *) NULL)
5983 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5987 if (attributes == (const xmlChar **) NULL)
5989 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5991 keyword=(const char *) attributes[i++];
5992 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5993 msl_info->attributes[n],(const char *) attributes[i],&exception));
5999 if (LocaleCompare(keyword,"clip-mask") == 0)
6001 for (j=0; j < msl_info->n; j++)
6006 property=GetImageProperty(msl_info->attributes[j],"id",
6008 if (LocaleCompare(property,value) == 0)
6010 SetImageMask(msl_info->image[n],msl_info->image[j],
6017 if (LocaleCompare(keyword,"clip-path") == 0)
6019 for (j=0; j < msl_info->n; j++)
6024 property=GetImageProperty(msl_info->attributes[j],"id",
6026 if (LocaleCompare(property,value) == 0)
6028 SetImageMask(msl_info->image[n],msl_info->image[j],
6035 if (LocaleCompare(keyword,"colorspace") == 0)
6040 colorspace=(ColorspaceType) ParseCommandOption(
6041 MagickColorspaceOptions,MagickFalse,value);
6043 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6045 (void) TransformImageColorspace(msl_info->image[n],
6046 (ColorspaceType) colorspace,&exception);
6049 (void) SetMSLAttributes(msl_info,keyword,value);
6050 (void) SetImageProperty(msl_info->image[n],keyword,value,
6057 if (LocaleCompare(keyword,"density") == 0)
6059 flags=ParseGeometry(value,&geometry_info);
6060 msl_info->image[n]->resolution.x=geometry_info.rho;
6061 msl_info->image[n]->resolution.y=geometry_info.sigma;
6062 if ((flags & SigmaValue) == 0)
6063 msl_info->image[n]->resolution.y=
6064 msl_info->image[n]->resolution.x;
6067 (void) SetMSLAttributes(msl_info,keyword,value);
6068 (void) SetImageProperty(msl_info->image[n],keyword,value,
6075 if (LocaleCompare(keyword, "opacity") == 0)
6077 ssize_t opac = OpaqueAlpha,
6078 len = (ssize_t) strlen( value );
6080 if (value[len-1] == '%') {
6082 (void) CopyMagickString(tmp,value,len);
6083 opac = StringToLong( tmp );
6084 opac = (int)(QuantumRange * ((float)opac/100));
6086 opac = StringToLong( value );
6087 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6091 (void) SetMSLAttributes(msl_info,keyword,value);
6092 (void) SetImageProperty(msl_info->image[n],keyword,value,
6093 msl_info->exception);
6099 if (LocaleCompare(keyword, "page") == 0)
6102 page[MaxTextExtent];
6113 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6114 image_option=GetImageArtifact(msl_info->image[n],"page");
6115 if (image_option != (const char *) NULL)
6116 flags=ParseAbsoluteGeometry(image_option,&geometry);
6117 flags=ParseAbsoluteGeometry(value,&geometry);
6118 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6119 (double) geometry.width,(double) geometry.height);
6120 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6121 (void) FormatLocaleString(page,MaxTextExtent,
6122 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6123 (double) geometry.height,(double) geometry.x,(double)
6125 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6126 msl_info->image_info[n]->page=GetPageGeometry(page);
6129 (void) SetMSLAttributes(msl_info,keyword,value);
6130 (void) SetImageProperty(msl_info->image[n],keyword,value,
6131 msl_info->exception);
6136 (void) SetMSLAttributes(msl_info,keyword,value);
6137 (void) SetImageProperty(msl_info->image[n],keyword,value,
6138 msl_info->exception);
6145 if (LocaleCompare((const char *) tag,"shade") == 0)
6156 if (msl_info->image[n] == (Image *) NULL)
6158 ThrowMSLException(OptionError,"NoImagesDefined",
6159 (const char *) tag);
6163 if (attributes != (const xmlChar **) NULL)
6164 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6166 keyword=(const char *) attributes[i++];
6167 attribute=InterpretImageProperties(msl_info->image_info[n],
6168 msl_info->attributes[n],(const char *) attributes[i],
6170 CloneString(&value,attribute);
6176 if (LocaleCompare(keyword,"azimuth") == 0)
6178 geometry_info.rho=StringToDouble(value,
6182 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6189 if (LocaleCompare(keyword,"elevation") == 0)
6191 geometry_info.sigma=StringToDouble(value,
6195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6202 if (LocaleCompare(keyword,"geometry") == 0)
6204 flags=ParseGeometry(value,&geometry_info);
6205 if ((flags & SigmaValue) == 0)
6206 geometry_info.sigma=1.0;
6209 if (LocaleCompare(keyword,"gray") == 0)
6211 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6214 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6216 gray=(MagickBooleanType) option;
6219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6225 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6231 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6232 geometry_info.sigma,msl_info->exception);
6233 if (shade_image == (Image *) NULL)
6235 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6236 msl_info->image[n]=shade_image;
6239 if (LocaleCompare((const char *) tag,"shadow") == 0)
6247 if (msl_info->image[n] == (Image *) NULL)
6249 ThrowMSLException(OptionError,"NoImagesDefined",
6250 (const char *) tag);
6253 if (attributes != (const xmlChar **) NULL)
6254 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6256 keyword=(const char *) attributes[i++];
6257 attribute=InterpretImageProperties(msl_info->image_info[n],
6258 msl_info->attributes[n],(const char *) attributes[i],
6260 CloneString(&value,attribute);
6266 if (LocaleCompare(keyword,"geometry") == 0)
6268 flags=ParseGeometry(value,&geometry_info);
6269 if ((flags & SigmaValue) == 0)
6270 geometry_info.sigma=1.0;
6273 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6280 if (LocaleCompare(keyword,"opacity") == 0)
6282 geometry_info.rho=StringToLong(value);
6285 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6292 if (LocaleCompare(keyword,"sigma") == 0)
6294 geometry_info.sigma=StringToLong(value);
6302 if (LocaleCompare(keyword,"x") == 0)
6304 geometry_info.xi=StringToDouble(value,
6308 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6315 if (LocaleCompare(keyword,"y") == 0)
6317 geometry_info.psi=StringToLong(value);
6320 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6326 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6332 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6333 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6334 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6335 if (shadow_image == (Image *) NULL)
6337 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6338 msl_info->image[n]=shadow_image;
6341 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6347 if (msl_info->image[n] == (Image *) NULL)
6349 ThrowMSLException(OptionError,"NoImagesDefined",
6350 (const char *) tag);
6354 NOTE: sharpen can have no attributes, since we use all the defaults!
6356 if (attributes != (const xmlChar **) NULL)
6358 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6360 keyword=(const char *) attributes[i++];
6361 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6362 msl_info->attributes[n],(const char *) attributes[i],&exception));
6368 if (LocaleCompare(keyword, "radius") == 0)
6370 radius = StringToDouble(value,(char **) NULL);
6373 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6379 if (LocaleCompare(keyword,"sigma") == 0)
6381 sigma = StringToLong( value );
6384 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6389 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6403 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6404 msl_info->exception);
6405 if (newImage == (Image *) NULL)
6407 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6408 msl_info->image[n]=newImage;
6412 else if (LocaleCompare((const char *) tag,"shave") == 0)
6414 /* init the values */
6418 if (msl_info->image[n] == (Image *) NULL)
6420 ThrowMSLException(OptionError,"NoImagesDefined",
6421 (const char *) tag);
6424 if (attributes == (const xmlChar **) NULL)
6426 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6428 keyword=(const char *) attributes[i++];
6429 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6430 msl_info->attributes[n],(const char *) attributes[i],&exception));
6436 if (LocaleCompare(keyword,"geometry") == 0)
6438 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6441 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6447 if (LocaleCompare(keyword,"height") == 0)
6449 height = StringToLong( value );
6452 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6458 if (LocaleCompare(keyword,"width") == 0)
6460 width = StringToLong( value );
6463 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6468 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6483 rectInfo.height = height;
6484 rectInfo.width = width;
6489 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6490 msl_info->exception);
6491 if (newImage == (Image *) NULL)
6493 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6494 msl_info->image[n]=newImage;
6499 if (LocaleCompare((const char *) tag,"shear") == 0)
6507 if (msl_info->image[n] == (Image *) NULL)
6509 ThrowMSLException(OptionError,"NoImagesDefined",
6510 (const char *) tag);
6513 if (attributes != (const xmlChar **) NULL)
6514 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6516 keyword=(const char *) attributes[i++];
6517 attribute=InterpretImageProperties(msl_info->image_info[n],
6518 msl_info->attributes[n],(const char *) attributes[i],
6520 CloneString(&value,attribute);
6526 if (LocaleCompare(keyword, "fill") == 0)
6528 (void) QueryColorCompliance(value,AllCompliance,
6529 &msl_info->image[n]->background_color,&exception);
6532 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6539 if (LocaleCompare(keyword,"geometry") == 0)
6541 flags=ParseGeometry(value,&geometry_info);
6542 if ((flags & SigmaValue) == 0)
6543 geometry_info.sigma=1.0;
6546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6553 if (LocaleCompare(keyword,"x") == 0)
6555 geometry_info.rho=StringToDouble(value,
6559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6566 if (LocaleCompare(keyword,"y") == 0)
6568 geometry_info.sigma=StringToLong(value);
6571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6583 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6584 geometry_info.sigma,msl_info->exception);
6585 if (shear_image == (Image *) NULL)
6587 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6588 msl_info->image[n]=shear_image;
6591 if (LocaleCompare((const char *) tag,"signature") == 0)
6596 if (msl_info->image[n] == (Image *) NULL)
6598 ThrowMSLException(OptionError,"NoImagesDefined",
6599 (const char *) tag);
6602 if (attributes != (const xmlChar **) NULL)
6603 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6605 keyword=(const char *) attributes[i++];
6606 attribute=InterpretImageProperties(msl_info->image_info[n],
6607 msl_info->attributes[n],(const char *) attributes[i],
6609 CloneString(&value,attribute);
6614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6620 (void) SignatureImage(msl_info->image[n],&exception);
6623 if (LocaleCompare((const char *) tag,"solarize") == 0)
6628 if (msl_info->image[n] == (Image *) NULL)
6630 ThrowMSLException(OptionError,"NoImagesDefined",
6631 (const char *) tag);
6634 geometry_info.rho=QuantumRange/2.0;
6635 if (attributes != (const xmlChar **) NULL)
6636 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6638 keyword=(const char *) attributes[i++];
6639 attribute=InterpretImageProperties(msl_info->image_info[n],
6640 msl_info->attributes[n],(const char *) attributes[i],
6642 CloneString(&value,attribute);
6648 if (LocaleCompare(keyword,"geometry") == 0)
6650 flags=ParseGeometry(value,&geometry_info);
6653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6660 if (LocaleCompare(keyword,"threshold") == 0)
6662 geometry_info.rho=StringToDouble(value,
6666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6672 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6678 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6679 msl_info->exception);
6682 if (LocaleCompare((const char *) tag,"spread") == 0)
6690 if (msl_info->image[n] == (Image *) NULL)
6692 ThrowMSLException(OptionError,"NoImagesDefined",
6693 (const char *) tag);
6696 if (attributes != (const xmlChar **) NULL)
6697 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6699 keyword=(const char *) attributes[i++];
6700 attribute=InterpretImageProperties(msl_info->image_info[n],
6701 msl_info->attributes[n],(const char *) attributes[i],
6703 CloneString(&value,attribute);
6709 if (LocaleCompare(keyword,"geometry") == 0)
6711 flags=ParseGeometry(value,&geometry_info);
6712 if ((flags & SigmaValue) == 0)
6713 geometry_info.sigma=1.0;
6716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6723 if (LocaleCompare(keyword,"radius") == 0)
6725 geometry_info.rho=StringToDouble(value,
6729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6741 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6742 msl_info->image[n]->interpolate,msl_info->exception);
6743 if (spread_image == (Image *) NULL)
6745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6746 msl_info->image[n]=spread_image;
6749 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6752 watermark = (Image*)NULL;
6754 if (msl_info->image[n] == (Image *) NULL)
6756 ThrowMSLException(OptionError,"NoImagesDefined",
6757 (const char *) tag);
6760 if (attributes == (const xmlChar **) NULL)
6762 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6764 keyword=(const char *) attributes[i++];
6765 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6766 msl_info->attributes[n],(const char *) attributes[i],&exception));
6772 if (LocaleCompare(keyword,"image") == 0)
6774 for (j=0; j<msl_info->n;j++)
6777 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6779 if (theAttr && LocaleCompare(theAttr, value) == 0)
6781 watermark = msl_info->image[j];
6787 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6792 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6801 if ( watermark != (Image*) NULL )
6806 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6807 if (newImage == (Image *) NULL)
6809 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6810 msl_info->image[n]=newImage;
6813 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6815 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6818 stereoImage = (Image*)NULL;
6820 if (msl_info->image[n] == (Image *) NULL)
6822 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6825 if (attributes == (const xmlChar **) NULL)
6827 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6829 keyword=(const char *) attributes[i++];
6830 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6831 msl_info->attributes[n],(const char *) attributes[i],&exception));
6837 if (LocaleCompare(keyword,"image") == 0)
6839 for (j=0; j<msl_info->n;j++)
6842 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6844 if (theAttr && LocaleCompare(theAttr, value) == 0)
6846 stereoImage = msl_info->image[j];
6852 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6857 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6866 if ( stereoImage != (Image*) NULL )
6871 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6872 if (newImage == (Image *) NULL)
6874 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6875 msl_info->image[n]=newImage;
6878 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6880 if (LocaleCompare((const char *) tag,"strip") == 0)
6885 if (msl_info->image[n] == (Image *) NULL)
6887 ThrowMSLException(OptionError,"NoImagesDefined",
6888 (const char *) tag);
6891 if (attributes != (const xmlChar **) NULL)
6892 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6894 keyword=(const char *) attributes[i++];
6895 attribute=InterpretImageProperties(msl_info->image_info[n],
6896 msl_info->attributes[n],(const char *) attributes[i],
6898 CloneString(&value,attribute);
6899 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6901 (void) StripImage(msl_info->image[n],msl_info->exception);
6904 if (LocaleCompare((const char *) tag,"swap") == 0)
6915 if (msl_info->image[n] == (Image *) NULL)
6917 ThrowMSLException(OptionError,"NoImagesDefined",
6918 (const char *) tag);
6923 if (attributes != (const xmlChar **) NULL)
6924 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6926 keyword=(const char *) attributes[i++];
6927 attribute=InterpretImageProperties(msl_info->image_info[n],
6928 msl_info->attributes[n],(const char *) attributes[i],
6930 CloneString(&value,attribute);
6936 if (LocaleCompare(keyword,"indexes") == 0)
6938 flags=ParseGeometry(value,&geometry_info);
6939 index=(ssize_t) geometry_info.rho;
6940 if ((flags & SigmaValue) == 0)
6941 swap_index=(ssize_t) geometry_info.sigma;
6944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6959 p=GetImageFromList(msl_info->image[n],index);
6960 q=GetImageFromList(msl_info->image[n],swap_index);
6961 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6963 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6966 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6967 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6968 msl_info->exception));
6969 ReplaceImageInList(&q,swap);
6970 msl_info->image[n]=GetFirstImageInList(q);
6973 if (LocaleCompare((const char *) tag,"swirl") == 0)
6981 if (msl_info->image[n] == (Image *) NULL)
6983 ThrowMSLException(OptionError,"NoImagesDefined",
6984 (const char *) tag);
6987 if (attributes != (const xmlChar **) NULL)
6988 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6990 keyword=(const char *) attributes[i++];
6991 attribute=InterpretImageProperties(msl_info->image_info[n],
6992 msl_info->attributes[n],(const char *) attributes[i],
6994 CloneString(&value,attribute);
7000 if (LocaleCompare(keyword,"degrees") == 0)
7002 geometry_info.rho=StringToDouble(value,
7006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7013 if (LocaleCompare(keyword,"geometry") == 0)
7015 flags=ParseGeometry(value,&geometry_info);
7016 if ((flags & SigmaValue) == 0)
7017 geometry_info.sigma=1.0;
7020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7032 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7033 msl_info->image[n]->interpolate,msl_info->exception);
7034 if (swirl_image == (Image *) NULL)
7036 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7037 msl_info->image[n]=swirl_image;
7040 if (LocaleCompare((const char *) tag,"sync") == 0)
7045 if (msl_info->image[n] == (Image *) NULL)
7047 ThrowMSLException(OptionError,"NoImagesDefined",
7048 (const char *) tag);
7051 if (attributes != (const xmlChar **) NULL)
7052 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7054 keyword=(const char *) attributes[i++];
7055 attribute=InterpretImageProperties(msl_info->image_info[n],
7056 msl_info->attributes[n],(const char *) attributes[i],
7058 CloneString(&value,attribute);
7063 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7069 (void) SyncImage(msl_info->image[n],&exception);
7072 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7077 if (LocaleCompare((const char *) tag,"map") == 0)
7085 if (msl_info->image[n] == (Image *) NULL)
7087 ThrowMSLException(OptionError,"NoImagesDefined",
7088 (const char *) tag);
7091 texture_image=NewImageList();
7092 if (attributes != (const xmlChar **) NULL)
7093 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7095 keyword=(const char *) attributes[i++];
7096 attribute=InterpretImageProperties(msl_info->image_info[n],
7097 msl_info->attributes[n],(const char *) attributes[i],
7099 CloneString(&value,attribute);
7105 if (LocaleCompare(keyword,"image") == 0)
7106 for (j=0; j < msl_info->n; j++)
7111 attribute=GetImageProperty(msl_info->attributes[j],"id",
7113 if ((attribute != (const char *) NULL) &&
7114 (LocaleCompare(attribute,value) == 0))
7116 texture_image=CloneImage(msl_info->image[j],0,0,
7117 MagickFalse,&exception);
7125 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7131 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7132 texture_image=DestroyImage(texture_image);
7135 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7137 /* init the values */
7138 double threshold = 0;
7140 if (msl_info->image[n] == (Image *) NULL)
7142 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7145 if (attributes == (const xmlChar **) NULL)
7147 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7149 keyword=(const char *) attributes[i++];
7150 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7151 msl_info->attributes[n],(const char *) attributes[i],&exception));
7157 if (LocaleCompare(keyword,"threshold") == 0)
7159 threshold = StringToDouble(value,(char **) NULL);
7162 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7167 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7177 BilevelImage(msl_info->image[n],threshold,&exception);
7181 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7183 if (msl_info->image[n] == (Image *) NULL)
7185 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7188 if (attributes == (const xmlChar **) NULL)
7190 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7192 keyword=(const char *) attributes[i++];
7193 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7194 msl_info->attributes[n],(const char *) attributes[i],&exception));
7200 if (LocaleCompare(keyword,"color") == 0)
7205 (void) QueryColorCompliance(value,AllCompliance,&target,
7207 (void) TransparentPaintImage(msl_info->image[n],&target,
7208 TransparentAlpha,MagickFalse,msl_info->exception);
7211 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7216 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7223 else if (LocaleCompare((const char *) tag, "trim") == 0)
7225 if (msl_info->image[n] == (Image *) NULL)
7227 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7231 /* no attributes here */
7233 /* process the image */
7240 /* all zeros on a crop == trim edges! */
7241 rectInfo.height = rectInfo.width = 0;
7242 rectInfo.x = rectInfo.y = 0;
7244 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7245 if (newImage == (Image *) NULL)
7247 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7248 msl_info->image[n]=newImage;
7252 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7257 if (LocaleCompare((const char *) tag,"write") == 0)
7259 if (msl_info->image[n] == (Image *) NULL)
7261 ThrowMSLException(OptionError,"NoImagesDefined",
7262 (const char *) tag);
7265 if (attributes == (const xmlChar **) NULL)
7267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7269 keyword=(const char *) attributes[i++];
7270 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7271 msl_info->attributes[n],(const char *) attributes[i],&exception));
7277 if (LocaleCompare(keyword,"filename") == 0)
7279 (void) CopyMagickString(msl_info->image[n]->filename,value,
7283 (void) SetMSLAttributes(msl_info,keyword,value);
7287 (void) SetMSLAttributes(msl_info,keyword,value);
7295 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7296 msl_info->exception);
7300 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7304 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7308 if ( value != NULL )
7309 value=DestroyString(value);
7310 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7313 static void MSLEndElement(void *context,const xmlChar *tag)
7322 Called when the end of an element has been detected.
7324 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7326 msl_info=(MSLInfo *) context;
7333 if (LocaleCompare((const char *) tag,"comment") == 0 )
7335 (void) DeleteImageProperty(msl_info->image[n],"comment");
7336 if (msl_info->content == (char *) NULL)
7338 StripString(msl_info->content);
7339 (void) SetImageProperty(msl_info->image[n],"comment",
7340 msl_info->content,msl_info->exception);
7348 if (LocaleCompare((const char *) tag, "group") == 0 )
7350 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7352 ssize_t i = (ssize_t)
7353 (msl_info->group_info[msl_info->number_groups-1].numImages);
7356 if (msl_info->image[msl_info->n] != (Image *) NULL)
7357 msl_info->image[msl_info->n]=DestroyImage(
7358 msl_info->image[msl_info->n]);
7359 msl_info->attributes[msl_info->n]=DestroyImage(
7360 msl_info->attributes[msl_info->n]);
7361 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7362 msl_info->image_info[msl_info->n]);
7366 msl_info->number_groups--;
7373 if (LocaleCompare((const char *) tag, "image") == 0)
7374 MSLPopImage(msl_info);
7380 if (LocaleCompare((const char *) tag,"label") == 0 )
7382 (void) DeleteImageProperty(msl_info->image[n],"label");
7383 if (msl_info->content == (char *) NULL)
7385 StripString(msl_info->content);
7386 (void) SetImageProperty(msl_info->image[n],"label",
7387 msl_info->content,msl_info->exception);
7395 if (LocaleCompare((const char *) tag, "msl") == 0 )
7398 This our base element.
7399 at the moment we don't do anything special
7400 but someday we might!
7408 if (msl_info->content != (char *) NULL)
7409 msl_info->content=DestroyString(msl_info->content);
7412 static void MSLCharacters(void *context,const xmlChar *c,int length)
7424 Receiving some characters from the parser.
7426 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7427 " SAX.characters(%s,%d)",c,length);
7428 msl_info=(MSLInfo *) context;
7429 if (msl_info->content != (char *) NULL)
7430 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7431 strlen(msl_info->content)+length+MaxTextExtent,
7432 sizeof(*msl_info->content));
7435 msl_info->content=(char *) NULL;
7436 if (~length >= (MaxTextExtent-1))
7437 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7438 sizeof(*msl_info->content));
7439 if (msl_info->content != (char *) NULL)
7440 *msl_info->content='\0';
7442 if (msl_info->content == (char *) NULL)
7444 p=msl_info->content+strlen(msl_info->content);
7445 for (i=0; i < length; i++)
7450 static void MSLReference(void *context,const xmlChar *name)
7459 Called when an entity reference is detected.
7461 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7462 " SAX.reference(%s)",name);
7463 msl_info=(MSLInfo *) context;
7464 parser=msl_info->parser;
7466 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7468 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7471 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7477 Receiving some ignorable whitespaces from the parser.
7479 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7480 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7481 msl_info=(MSLInfo *) context;
7485 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7486 const xmlChar *data)
7492 A processing instruction has been parsed.
7494 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7495 " SAX.processingInstruction(%s, %s)",
7497 msl_info=(MSLInfo *) context;
7501 static void MSLComment(void *context,const xmlChar *value)
7507 A comment has been parsed.
7509 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7510 " SAX.comment(%s)",value);
7511 msl_info=(MSLInfo *) context;
7515 static void MSLWarning(void *context,const char *format,...)
7519 reason[MaxTextExtent];
7528 Display and format a warning messages, gives file, line, position and
7531 va_start(operands,format);
7532 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7533 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7534 msl_info=(MSLInfo *) context;
7536 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7537 (void) vsprintf(reason,format,operands);
7539 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7541 message=GetExceptionMessage(errno);
7542 ThrowMSLException(CoderError,reason,message);
7543 message=DestroyString(message);
7547 static void MSLError(void *context,const char *format,...)
7550 reason[MaxTextExtent];
7559 Display and format a error formats, gives file, line, position and
7562 va_start(operands,format);
7563 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7564 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7565 msl_info=(MSLInfo *) context;
7567 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7568 (void) vsprintf(reason,format,operands);
7570 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7572 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7576 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7588 Called when a pcdata block has been parsed.
7590 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7591 " SAX.pcdata(%s, %d)",value,length);
7592 msl_info=(MSLInfo *) context;
7594 parser=msl_info->parser;
7595 child=xmlGetLastChild(parser->node);
7596 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7598 xmlTextConcat(child,value,length);
7601 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7604 static void MSLExternalSubset(void *context,const xmlChar *name,
7605 const xmlChar *external_id,const xmlChar *system_id)
7620 Does this document has an external subset?
7622 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7623 " SAX.externalSubset(%s %s %s)",name,
7624 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7625 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7626 msl_info=(MSLInfo *) context;
7628 parser=msl_info->parser;
7629 if (((external_id == NULL) && (system_id == NULL)) ||
7630 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7631 (msl_info->document == 0)))
7633 input=MSLResolveEntity(context,external_id,system_id);
7636 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7637 parser_context=(*parser);
7638 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7639 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7641 parser->errNo=XML_ERR_NO_MEMORY;
7642 parser->input=parser_context.input;
7643 parser->inputNr=parser_context.inputNr;
7644 parser->inputMax=parser_context.inputMax;
7645 parser->inputTab=parser_context.inputTab;
7651 xmlPushInput(parser,input);
7652 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7653 if (input->filename == (char *) NULL)
7654 input->filename=(char *) xmlStrdup(system_id);
7657 input->base=parser->input->cur;
7658 input->cur=parser->input->cur;
7660 xmlParseExternalSubset(parser,external_id,system_id);
7661 while (parser->inputNr > 1)
7662 (void) xmlPopInput(parser);
7663 xmlFreeInputStream(parser->input);
7664 xmlFree(parser->inputTab);
7665 parser->input=parser_context.input;
7666 parser->inputNr=parser_context.inputNr;
7667 parser->inputMax=parser_context.inputMax;
7668 parser->inputTab=parser_context.inputTab;
7671 #if defined(__cplusplus) || defined(c_plusplus)
7675 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7676 Image **image,ExceptionInfo *exception)
7679 message[MaxTextExtent];
7702 assert(image_info != (const ImageInfo *) NULL);
7703 assert(image_info->signature == MagickSignature);
7704 if (image_info->debug != MagickFalse)
7705 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7706 image_info->filename);
7707 assert(image != (Image **) NULL);
7708 msl_image=AcquireImage(image_info,exception);
7709 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7710 if (status == MagickFalse)
7712 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7713 msl_image->filename);
7714 msl_image=DestroyImageList(msl_image);
7715 return(MagickFalse);
7717 msl_image->columns=1;
7722 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7723 msl_info.exception=exception;
7724 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7725 sizeof(*msl_info.image_info));
7726 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7727 sizeof(*msl_info.draw_info));
7728 /* top of the stack is the MSL file itself */
7729 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7730 msl_info.attributes=(Image **) AcquireMagickMemory(
7731 sizeof(*msl_info.attributes));
7732 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7733 sizeof(*msl_info.group_info));
7734 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7735 (msl_info.image == (Image **) NULL) ||
7736 (msl_info.attributes == (Image **) NULL) ||
7737 (msl_info.group_info == (MSLGroupInfo *) NULL))
7738 ThrowFatalException(ResourceLimitFatalError,
7739 "UnableToInterpretMSLImage");
7740 *msl_info.image_info=CloneImageInfo(image_info);
7741 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7742 *msl_info.attributes=AcquireImage(image_info,exception);
7743 msl_info.group_info[0].numImages=0;
7744 /* the first slot is used to point to the MSL file image */
7745 *msl_info.image=msl_image;
7746 if (*image != (Image *) NULL)
7747 MSLPushImage(&msl_info,*image);
7748 (void) xmlSubstituteEntitiesDefault(1);
7749 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7750 sax_modules.internalSubset=MSLInternalSubset;
7751 sax_modules.isStandalone=MSLIsStandalone;
7752 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7753 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7754 sax_modules.resolveEntity=MSLResolveEntity;
7755 sax_modules.getEntity=MSLGetEntity;
7756 sax_modules.entityDecl=MSLEntityDeclaration;
7757 sax_modules.notationDecl=MSLNotationDeclaration;
7758 sax_modules.attributeDecl=MSLAttributeDeclaration;
7759 sax_modules.elementDecl=MSLElementDeclaration;
7760 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7761 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7762 sax_modules.startDocument=MSLStartDocument;
7763 sax_modules.endDocument=MSLEndDocument;
7764 sax_modules.startElement=MSLStartElement;
7765 sax_modules.endElement=MSLEndElement;
7766 sax_modules.reference=MSLReference;
7767 sax_modules.characters=MSLCharacters;
7768 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7769 sax_modules.processingInstruction=MSLProcessingInstructions;
7770 sax_modules.comment=MSLComment;
7771 sax_modules.warning=MSLWarning;
7772 sax_modules.error=MSLError;
7773 sax_modules.fatalError=MSLError;
7774 sax_modules.getParameterEntity=MSLGetParameterEntity;
7775 sax_modules.cdataBlock=MSLCDataBlock;
7776 sax_modules.externalSubset=MSLExternalSubset;
7777 sax_handler=(&sax_modules);
7778 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7779 msl_image->filename);
7780 while (ReadBlobString(msl_image,message) != (char *) NULL)
7782 n=(ssize_t) strlen(message);
7785 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7788 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7789 if (msl_info.exception->severity >= ErrorException)
7792 if (msl_info.exception->severity == UndefinedException)
7793 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7794 xmlFreeParserCtxt(msl_info.parser);
7795 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7796 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7797 msl_info.group_info);
7798 if (*image == (Image *) NULL)
7799 *image=(*msl_info.image);
7800 if (msl_info.exception->severity != UndefinedException)
7801 return(MagickFalse);
7805 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7813 assert(image_info != (const ImageInfo *) NULL);
7814 assert(image_info->signature == MagickSignature);
7815 if (image_info->debug != MagickFalse)
7816 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7817 image_info->filename);
7818 assert(exception != (ExceptionInfo *) NULL);
7819 assert(exception->signature == MagickSignature);
7820 image=(Image *) NULL;
7821 (void) ProcessMSLScript(image_info,&image,exception);
7822 return(GetFirstImageInList(image));
7827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7831 % R e g i s t e r M S L I m a g e %
7835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7837 % RegisterMSLImage() adds attributes for the MSL image format to
7838 % the list of supported formats. The attributes include the image format
7839 % tag, a method to read and/or write the format, whether the format
7840 % supports the saving of more than one frame to the same file or blob,
7841 % whether the format supports native in-memory I/O, and a brief
7842 % description of the format.
7844 % The format of the RegisterMSLImage method is:
7846 % size_t RegisterMSLImage(void)
7849 ModuleExport size_t RegisterMSLImage(void)
7854 #if defined(MAGICKCORE_XML_DELEGATE)
7857 entry=SetMagickInfo("MSL");
7858 #if defined(MAGICKCORE_XML_DELEGATE)
7859 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7860 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7862 entry->description=ConstantString("Magick Scripting Language");
7863 entry->module=ConstantString("MSL");
7864 (void) RegisterMagickInfo(entry);
7865 return(MagickImageCoderSignature);
7868 #if defined(MAGICKCORE_XML_DELEGATE)
7870 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7874 % S e t M S L A t t r i b u t e s %
7878 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7880 % SetMSLAttributes() ...
7882 % The format of the SetMSLAttributes method is:
7884 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7885 % const char *keyword,const char *value)
7887 % A description of each parameter follows:
7889 % o msl_info: the MSL info.
7891 % o keyword: the keyword.
7893 % o value: the value.
7896 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7923 assert(msl_info != (MSLInfo *) NULL);
7924 if (keyword == (const char *) NULL)
7926 if (value == (const char *) NULL)
7928 exception=msl_info->exception;
7930 attributes=msl_info->attributes[n];
7931 image_info=msl_info->image_info[n];
7932 draw_info=msl_info->draw_info[n];
7933 image=msl_info->image[n];
7939 if (LocaleCompare(keyword,"adjoin") == 0)
7944 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7946 ThrowMSLException(OptionError,"UnrecognizedType",value);
7947 image_info->adjoin=(MagickBooleanType) adjoin;
7950 if (LocaleCompare(keyword,"alpha") == 0)
7955 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
7957 ThrowMSLException(OptionError,"UnrecognizedType",value);
7958 if (image != (Image *) NULL)
7959 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
7963 if (LocaleCompare(keyword,"antialias") == 0)
7968 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7970 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7971 image_info->antialias=(MagickBooleanType) antialias;
7974 if (LocaleCompare(keyword,"area-limit") == 0)
7979 limit=MagickResourceInfinity;
7980 if (LocaleCompare(value,"unlimited") != 0)
7981 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7982 (void) SetMagickResourceLimit(AreaResource,limit);
7985 if (LocaleCompare(keyword,"attenuate") == 0)
7987 (void) SetImageOption(image_info,keyword,value);
7990 if (LocaleCompare(keyword,"authenticate") == 0)
7992 (void) CloneString(&image_info->density,value);
7995 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8001 if (LocaleCompare(keyword,"background") == 0)
8003 (void) QueryColorCompliance(value,AllCompliance,
8004 &image_info->background_color,exception);
8007 if (LocaleCompare(keyword,"blue-primary") == 0)
8009 if (image == (Image *) NULL)
8011 flags=ParseGeometry(value,&geometry_info);
8012 image->chromaticity.blue_primary.x=geometry_info.rho;
8013 image->chromaticity.blue_primary.y=geometry_info.sigma;
8014 if ((flags & SigmaValue) == 0)
8015 image->chromaticity.blue_primary.y=
8016 image->chromaticity.blue_primary.x;
8019 if (LocaleCompare(keyword,"bordercolor") == 0)
8021 (void) QueryColorCompliance(value,AllCompliance,
8022 &image_info->border_color,exception);
8025 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8031 if (LocaleCompare(keyword,"density") == 0)
8033 (void) CloneString(&image_info->density,value);
8034 (void) CloneString(&draw_info->density,value);
8037 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8043 if (LocaleCompare(keyword,"fill") == 0)
8045 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8047 (void) SetImageOption(image_info,keyword,value);
8050 if (LocaleCompare(keyword,"filename") == 0)
8052 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8055 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8061 if (LocaleCompare(keyword,"gravity") == 0)
8066 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8068 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8069 (void) SetImageOption(image_info,keyword,value);
8072 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8078 if (LocaleCompare(keyword,"id") == 0)
8080 (void) SetImageProperty(attributes,keyword,value,exception);
8083 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8089 if (LocaleCompare(keyword,"magick") == 0)
8091 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8094 if (LocaleCompare(keyword,"mattecolor") == 0)
8096 (void) QueryColorCompliance(value,AllCompliance,
8097 &image_info->matte_color,exception);
8100 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8106 if (LocaleCompare(keyword,"pointsize") == 0)
8108 image_info->pointsize=StringToDouble(value,(char **) NULL);
8109 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8112 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8118 if (LocaleCompare(keyword,"quality") == 0)
8120 image_info->quality=StringToLong(value);
8121 if (image == (Image *) NULL)
8123 image->quality=StringToLong(value);
8131 if (LocaleCompare(keyword,"size") == 0)
8133 (void) CloneString(&image_info->size,value);
8136 if (LocaleCompare(keyword,"stroke") == 0)
8138 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8140 (void) SetImageOption(image_info,keyword,value);
8143 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8148 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8161 % U n r e g i s t e r M S L I m a g e %
8165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8167 % UnregisterMSLImage() removes format registrations made by the
8168 % MSL module from the list of supported formats.
8170 % The format of the UnregisterMSLImage method is:
8172 % UnregisterMSLImage(void)
8175 ModuleExport void UnregisterMSLImage(void)
8177 (void) UnregisterMagickInfo("MSL");
8178 #if defined(MAGICKCORE_XML_DELEGATE)
8183 #if defined(MAGICKCORE_XML_DELEGATE)
8185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8189 % W r i t e M S L I m a g e %
8193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8195 % WriteMSLImage() writes an image to a file in MVG image format.
8197 % The format of the WriteMSLImage method is:
8199 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8200 % Image *image,ExceptionInfo *exception)
8202 % A description of each parameter follows.
8204 % o image_info: the image info.
8206 % o image: The image.
8208 % o exception: return any errors or warnings in this structure.
8211 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8212 ExceptionInfo *exception)
8214 assert(image_info != (const ImageInfo *) NULL);
8215 assert(image_info->signature == MagickSignature);
8216 assert(image != (Image *) NULL);
8217 assert(image->signature == MagickSignature);
8218 if (image->debug != MagickFalse)
8219 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8220 (void) ReferenceImage(image);
8221 (void) ProcessMSLScript(image_info,&image,exception);