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,"points") == 0)
2526 if (LocaleCompare(draw_info->primitive,"path") == 0)
2528 (void) ConcatenateString(&draw_info->primitive," '");
2529 ConcatenateString(&draw_info->primitive,value);
2530 (void) ConcatenateString(&draw_info->primitive,"'");
2534 (void) ConcatenateString(&draw_info->primitive," ");
2535 ConcatenateString(&draw_info->primitive,value);
2538 if (LocaleCompare(keyword,"pointsize") == 0)
2540 draw_info->pointsize=StringToDouble(value,
2544 if (LocaleCompare(keyword,"primitive") == 0)
2546 CloneString(&draw_info->primitive,value);
2549 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2556 if (LocaleCompare(keyword,"rotate") == 0)
2558 angle=StringToDouble(value,(char **) NULL);
2559 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2560 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2561 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2562 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2572 if (LocaleCompare(keyword,"scale") == 0)
2574 flags=ParseGeometry(value,&geometry_info);
2575 if ((flags & SigmaValue) == 0)
2576 geometry_info.sigma=1.0;
2577 affine.sx=geometry_info.rho;
2578 affine.sy=geometry_info.sigma;
2581 if (LocaleCompare(keyword,"skewX") == 0)
2583 angle=StringToDouble(value,(char **) NULL);
2584 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2587 if (LocaleCompare(keyword,"skewY") == 0)
2589 angle=StringToDouble(value,(char **) NULL);
2590 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2593 if (LocaleCompare(keyword,"stretch") == 0)
2595 option=ParseCommandOption(MagickStretchOptions,
2598 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2600 draw_info->stretch=(StretchType) option;
2603 if (LocaleCompare(keyword, "stroke") == 0)
2605 (void) QueryColorCompliance(value,AllCompliance,
2606 &draw_info->stroke,&exception);
2609 if (LocaleCompare(keyword,"strokewidth") == 0)
2611 draw_info->stroke_width=StringToLong(value);
2614 if (LocaleCompare(keyword,"style") == 0)
2616 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2619 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2621 draw_info->style=(StyleType) option;
2624 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2631 if (LocaleCompare(keyword,"text") == 0)
2633 CloneString(&draw_info->text,value);
2636 if (LocaleCompare(keyword,"translate") == 0)
2638 flags=ParseGeometry(value,&geometry_info);
2639 if ((flags & SigmaValue) == 0)
2640 geometry_info.sigma=1.0;
2641 affine.tx=geometry_info.rho;
2642 affine.ty=geometry_info.sigma;
2645 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2652 if (LocaleCompare(keyword, "undercolor") == 0)
2654 (void) QueryColorCompliance(value,AllCompliance,
2655 &draw_info->undercolor,&exception);
2658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2665 if (LocaleCompare(keyword,"weight") == 0)
2667 draw_info->weight=StringToLong(value);
2670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2677 if (LocaleCompare(keyword,"x") == 0)
2679 geometry.x=StringToLong(value);
2682 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2689 if (LocaleCompare(keyword,"y") == 0)
2691 geometry.y=StringToLong(value);
2694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2706 (void) FormatLocaleString(text,MaxTextExtent,
2707 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2708 geometry.height,(double) geometry.x,(double) geometry.y);
2709 CloneString(&draw_info->geometry,text);
2710 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2711 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2712 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2713 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2714 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2716 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2718 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2719 draw_info=DestroyDrawInfo(draw_info);
2722 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2727 if (LocaleCompare((const char *) tag,"edge") == 0)
2735 if (msl_info->image[n] == (Image *) NULL)
2737 ThrowMSLException(OptionError,"NoImagesDefined",
2738 (const char *) tag);
2741 if (attributes != (const xmlChar **) NULL)
2742 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2744 keyword=(const char *) attributes[i++];
2745 attribute=InterpretImageProperties(msl_info->image_info[n],
2746 msl_info->attributes[n],(const char *) attributes[i],
2748 CloneString(&value,attribute);
2754 if (LocaleCompare(keyword,"geometry") == 0)
2756 flags=ParseGeometry(value,&geometry_info);
2757 if ((flags & SigmaValue) == 0)
2758 geometry_info.sigma=1.0;
2761 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2768 if (LocaleCompare(keyword,"radius") == 0)
2770 geometry_info.rho=StringToDouble(value,(char **) NULL);
2773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2785 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2786 msl_info->exception);
2787 if (edge_image == (Image *) NULL)
2789 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2790 msl_info->image[n]=edge_image;
2793 if (LocaleCompare((const char *) tag,"emboss") == 0)
2801 if (msl_info->image[n] == (Image *) NULL)
2803 ThrowMSLException(OptionError,"NoImagesDefined",
2804 (const char *) tag);
2807 if (attributes != (const xmlChar **) NULL)
2808 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2810 keyword=(const char *) attributes[i++];
2811 attribute=InterpretImageProperties(msl_info->image_info[n],
2812 msl_info->attributes[n],(const char *) attributes[i],
2814 CloneString(&value,attribute);
2820 if (LocaleCompare(keyword,"geometry") == 0)
2822 flags=ParseGeometry(value,&geometry_info);
2823 if ((flags & SigmaValue) == 0)
2824 geometry_info.sigma=1.0;
2827 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2834 if (LocaleCompare(keyword,"radius") == 0)
2836 geometry_info.rho=StringToDouble(value,
2840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2847 if (LocaleCompare(keyword,"sigma") == 0)
2849 geometry_info.sigma=StringToLong(value);
2852 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2858 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2864 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2865 geometry_info.sigma,msl_info->exception);
2866 if (emboss_image == (Image *) NULL)
2868 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2869 msl_info->image[n]=emboss_image;
2872 if (LocaleCompare((const char *) tag,"enhance") == 0)
2880 if (msl_info->image[n] == (Image *) NULL)
2882 ThrowMSLException(OptionError,"NoImagesDefined",
2883 (const char *) tag);
2886 if (attributes != (const xmlChar **) NULL)
2887 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2889 keyword=(const char *) attributes[i++];
2890 attribute=InterpretImageProperties(msl_info->image_info[n],
2891 msl_info->attributes[n],(const char *) attributes[i],
2893 CloneString(&value,attribute);
2894 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2896 enhance_image=EnhanceImage(msl_info->image[n],
2897 msl_info->exception);
2898 if (enhance_image == (Image *) NULL)
2900 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2901 msl_info->image[n]=enhance_image;
2904 if (LocaleCompare((const char *) tag,"equalize") == 0)
2909 if (msl_info->image[n] == (Image *) NULL)
2911 ThrowMSLException(OptionError,"NoImagesDefined",
2912 (const char *) tag);
2915 if (attributes != (const xmlChar **) NULL)
2916 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2918 keyword=(const char *) attributes[i++];
2919 attribute=InterpretImageProperties(msl_info->image_info[n],
2920 msl_info->attributes[n],(const char *) attributes[i],
2922 CloneString(&value,attribute);
2927 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2933 (void) EqualizeImage(msl_info->image[n],
2934 msl_info->exception);
2937 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2942 if (LocaleCompare((const char *) tag, "flatten") == 0)
2944 if (msl_info->image[n] == (Image *) NULL)
2946 ThrowMSLException(OptionError,"NoImagesDefined",
2947 (const char *) tag);
2951 /* no attributes here */
2953 /* process the image */
2958 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2959 msl_info->exception);
2960 if (newImage == (Image *) NULL)
2962 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2963 msl_info->image[n]=newImage;
2967 if (LocaleCompare((const char *) tag,"flip") == 0)
2975 if (msl_info->image[n] == (Image *) NULL)
2977 ThrowMSLException(OptionError,"NoImagesDefined",
2978 (const char *) tag);
2981 if (attributes != (const xmlChar **) NULL)
2982 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2984 keyword=(const char *) attributes[i++];
2985 attribute=InterpretImageProperties(msl_info->image_info[n],
2986 msl_info->attributes[n],(const char *) attributes[i],
2988 CloneString(&value,attribute);
2989 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2991 flip_image=FlipImage(msl_info->image[n],
2992 msl_info->exception);
2993 if (flip_image == (Image *) NULL)
2995 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2996 msl_info->image[n]=flip_image;
2999 if (LocaleCompare((const char *) tag,"flop") == 0)
3007 if (msl_info->image[n] == (Image *) NULL)
3009 ThrowMSLException(OptionError,"NoImagesDefined",
3010 (const char *) tag);
3013 if (attributes != (const xmlChar **) NULL)
3014 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3016 keyword=(const char *) attributes[i++];
3017 attribute=InterpretImageProperties(msl_info->image_info[n],
3018 msl_info->attributes[n],(const char *) attributes[i],
3020 CloneString(&value,attribute);
3021 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3023 flop_image=FlopImage(msl_info->image[n],
3024 msl_info->exception);
3025 if (flop_image == (Image *) NULL)
3027 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3028 msl_info->image[n]=flop_image;
3031 if (LocaleCompare((const char *) tag,"frame") == 0)
3042 if (msl_info->image[n] == (Image *) NULL)
3044 ThrowMSLException(OptionError,"NoImagesDefined",
3045 (const char *) tag);
3048 SetGeometry(msl_info->image[n],&geometry);
3049 if (attributes != (const xmlChar **) NULL)
3050 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3052 keyword=(const char *) attributes[i++];
3053 attribute=InterpretImageProperties(msl_info->image_info[n],
3054 msl_info->attributes[n],(const char *) attributes[i],
3056 CloneString(&value,attribute);
3062 if (LocaleCompare(keyword,"compose") == 0)
3064 option=ParseCommandOption(MagickComposeOptions,
3067 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3069 msl_info->image[n]->compose=(CompositeOperator) option;
3072 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3079 if (LocaleCompare(keyword, "fill") == 0)
3081 (void) QueryColorCompliance(value,AllCompliance,
3082 &msl_info->image[n]->matte_color,&exception);
3085 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3092 if (LocaleCompare(keyword,"geometry") == 0)
3094 flags=ParsePageGeometry(msl_info->image[n],value,
3095 &geometry,&exception);
3096 if ((flags & HeightValue) == 0)
3097 geometry.height=geometry.width;
3098 frame_info.width=geometry.width;
3099 frame_info.height=geometry.height;
3100 frame_info.outer_bevel=geometry.x;
3101 frame_info.inner_bevel=geometry.y;
3104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3111 if (LocaleCompare(keyword,"height") == 0)
3113 frame_info.height=StringToLong(value);
3116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3123 if (LocaleCompare(keyword,"inner") == 0)
3125 frame_info.inner_bevel=StringToLong(value);
3128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3135 if (LocaleCompare(keyword,"outer") == 0)
3137 frame_info.outer_bevel=StringToLong(value);
3140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3147 if (LocaleCompare(keyword,"width") == 0)
3149 frame_info.width=StringToLong(value);
3152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3158 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3164 frame_info.x=(ssize_t) frame_info.width;
3165 frame_info.y=(ssize_t) frame_info.height;
3166 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3167 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3168 frame_image=FrameImage(msl_info->image[n],&frame_info,
3169 msl_info->image[n]->compose,msl_info->exception);
3170 if (frame_image == (Image *) NULL)
3172 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3173 msl_info->image[n]=frame_image;
3176 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3181 if (LocaleCompare((const char *) tag,"gamma") == 0)
3184 gamma[MaxTextExtent];
3192 if (msl_info->image[n] == (Image *) NULL)
3194 ThrowMSLException(OptionError,"NoImagesDefined",
3195 (const char *) tag);
3198 channel=UndefinedChannel;
3203 if (attributes != (const xmlChar **) NULL)
3204 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3206 keyword=(const char *) attributes[i++];
3207 attribute=InterpretImageProperties(msl_info->image_info[n],
3208 msl_info->attributes[n],(const char *) attributes[i],
3210 CloneString(&value,attribute);
3216 if (LocaleCompare(keyword,"blue") == 0)
3218 pixel.blue=StringToDouble(value,(char **) NULL);
3221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3228 if (LocaleCompare(keyword,"channel") == 0)
3230 option=ParseChannelOption(value);
3232 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3234 channel=(ChannelType) option;
3237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3244 if (LocaleCompare(keyword,"gamma") == 0)
3246 (void) CopyMagickString(gamma,value,MaxTextExtent);
3249 if (LocaleCompare(keyword,"green") == 0)
3251 pixel.green=StringToDouble(value,(char **) NULL);
3254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3261 if (LocaleCompare(keyword,"red") == 0)
3263 pixel.red=StringToDouble(value,(char **) NULL);
3266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3272 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3279 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3280 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3281 (void) GammaImage(msl_info->image[n],atof(gamma),
3282 msl_info->exception);
3285 else if (LocaleCompare((const char *) tag,"get") == 0)
3287 if (msl_info->image[n] == (Image *) NULL)
3289 ThrowMSLException(OptionError,"NoImagesDefined",
3290 (const char *) tag);
3293 if (attributes == (const xmlChar **) NULL)
3295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3297 keyword=(const char *) attributes[i++];
3298 CloneString(&value,(const char *) attributes[i]);
3299 (void) CopyMagickString(key,value,MaxTextExtent);
3305 if (LocaleCompare(keyword,"height") == 0)
3307 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3308 (double) msl_info->image[n]->rows);
3309 (void) SetImageProperty(msl_info->attributes[n],key,value,
3313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3318 if (LocaleCompare(keyword,"width") == 0)
3320 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3321 (double) msl_info->image[n]->columns);
3322 (void) SetImageProperty(msl_info->attributes[n],key,value,
3326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3330 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3337 else if (LocaleCompare((const char *) tag, "group") == 0)
3339 msl_info->number_groups++;
3340 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3341 msl_info->group_info,msl_info->number_groups+1UL,
3342 sizeof(*msl_info->group_info));
3345 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3350 if (LocaleCompare((const char *) tag,"image") == 0)
3352 MSLPushImage(msl_info,(Image *) NULL);
3353 if (attributes == (const xmlChar **) NULL)
3355 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3357 keyword=(const char *) attributes[i++];
3358 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3359 msl_info->attributes[n],(const char *) attributes[i],&exception));
3365 if (LocaleCompare(keyword,"color") == 0)
3370 (void) CopyMagickString(msl_info->image_info[n]->filename,
3371 "xc:",MaxTextExtent);
3372 (void) ConcatenateMagickString(msl_info->image_info[n]->
3373 filename,value,MaxTextExtent);
3374 next_image=ReadImage(msl_info->image_info[n],&exception);
3375 CatchException(&exception);
3376 if (next_image == (Image *) NULL)
3378 if (msl_info->image[n] == (Image *) NULL)
3379 msl_info->image[n]=next_image;
3386 Link image into image list.
3388 p=msl_info->image[n];
3389 while (p->next != (Image *) NULL)
3390 p=GetNextImageInList(p);
3391 next_image->previous=p;
3396 (void) SetMSLAttributes(msl_info,keyword,value);
3401 (void) SetMSLAttributes(msl_info,keyword,value);
3408 if (LocaleCompare((const char *) tag,"implode") == 0)
3416 if (msl_info->image[n] == (Image *) NULL)
3418 ThrowMSLException(OptionError,"NoImagesDefined",
3419 (const char *) tag);
3422 if (attributes != (const xmlChar **) NULL)
3423 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3425 keyword=(const char *) attributes[i++];
3426 attribute=InterpretImageProperties(msl_info->image_info[n],
3427 msl_info->attributes[n],(const char *) attributes[i],
3429 CloneString(&value,attribute);
3435 if (LocaleCompare(keyword,"amount") == 0)
3437 geometry_info.rho=StringToDouble(value,
3441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3448 if (LocaleCompare(keyword,"geometry") == 0)
3450 flags=ParseGeometry(value,&geometry_info);
3451 if ((flags & SigmaValue) == 0)
3452 geometry_info.sigma=1.0;
3455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3467 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3468 msl_info->image[n]->interpolate,msl_info->exception);
3469 if (implode_image == (Image *) NULL)
3471 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3472 msl_info->image[n]=implode_image;
3475 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3480 if (LocaleCompare((const char *) tag,"label") == 0)
3482 if (LocaleCompare((const char *) tag, "level") == 0)
3485 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3487 if (msl_info->image[n] == (Image *) NULL)
3489 ThrowMSLException(OptionError,"NoImagesDefined",
3490 (const char *) tag);
3493 if (attributes == (const xmlChar **) NULL)
3495 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3497 keyword=(const char *) attributes[i++];
3498 CloneString(&value,(const char *) attributes[i]);
3499 (void) CopyMagickString(key,value,MaxTextExtent);
3505 if (LocaleCompare(keyword,"black") == 0)
3507 levelBlack = StringToDouble(value,(char **) NULL);
3510 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3516 if (LocaleCompare(keyword,"gamma") == 0)
3518 levelGamma = StringToDouble(value,(char **) NULL);
3521 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3527 if (LocaleCompare(keyword,"white") == 0)
3529 levelWhite = StringToDouble(value,(char **) NULL);
3532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3537 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3544 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3545 msl_info->exception);
3552 if (LocaleCompare((const char *) tag,"magnify") == 0)
3560 if (msl_info->image[n] == (Image *) NULL)
3562 ThrowMSLException(OptionError,"NoImagesDefined",
3563 (const char *) tag);
3566 if (attributes != (const xmlChar **) NULL)
3567 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3569 keyword=(const char *) attributes[i++];
3570 attribute=InterpretImageProperties(msl_info->image_info[n],
3571 msl_info->attributes[n],(const char *) attributes[i],
3573 CloneString(&value,attribute);
3574 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3576 magnify_image=MagnifyImage(msl_info->image[n],
3577 msl_info->exception);
3578 if (magnify_image == (Image *) NULL)
3580 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3581 msl_info->image[n]=magnify_image;
3584 if (LocaleCompare((const char *) tag,"map") == 0)
3598 if (msl_info->image[n] == (Image *) NULL)
3600 ThrowMSLException(OptionError,"NoImagesDefined",
3601 (const char *) tag);
3604 affinity_image=NewImageList();
3606 if (attributes != (const xmlChar **) NULL)
3607 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3609 keyword=(const char *) attributes[i++];
3610 attribute=InterpretImageProperties(msl_info->image_info[n],
3611 msl_info->attributes[n],(const char *) attributes[i],
3613 CloneString(&value,attribute);
3619 if (LocaleCompare(keyword,"dither") == 0)
3621 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3624 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3626 dither=(MagickBooleanType) option;
3629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3636 if (LocaleCompare(keyword,"image") == 0)
3637 for (j=0; j < msl_info->n; j++)
3642 attribute=GetImageProperty(msl_info->attributes[j],"id",
3644 if ((attribute != (const char *) NULL) &&
3645 (LocaleCompare(attribute,value) == 0))
3647 affinity_image=CloneImage(msl_info->image[j],0,0,
3648 MagickFalse,&exception);
3656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3662 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3663 quantize_info->dither_method=dither != MagickFalse ?
3664 RiemersmaDitherMethod : NoDitherMethod;
3665 (void) RemapImages(quantize_info,msl_info->image[n],
3666 affinity_image,&exception);
3667 quantize_info=DestroyQuantizeInfo(quantize_info);
3668 affinity_image=DestroyImage(affinity_image);
3671 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3683 Matte floodfill image.
3686 if (msl_info->image[n] == (Image *) NULL)
3688 ThrowMSLException(OptionError,"NoImagesDefined",
3689 (const char *) tag);
3692 SetGeometry(msl_info->image[n],&geometry);
3693 paint_method=FloodfillMethod;
3694 if (attributes != (const xmlChar **) NULL)
3695 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3697 keyword=(const char *) attributes[i++];
3698 attribute=InterpretImageProperties(msl_info->image_info[n],
3699 msl_info->attributes[n],(const char *) attributes[i],
3701 CloneString(&value,attribute);
3707 if (LocaleCompare(keyword,"bordercolor") == 0)
3709 (void) QueryColorCompliance(value,AllCompliance,
3710 &target,&exception);
3711 paint_method=FillToBorderMethod;
3714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3721 if (LocaleCompare(keyword,"fuzz") == 0)
3723 msl_info->image[n]->fuzz=StringToDouble(value,
3727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3734 if (LocaleCompare(keyword,"geometry") == 0)
3736 flags=ParsePageGeometry(msl_info->image[n],value,
3737 &geometry,&exception);
3738 if ((flags & HeightValue) == 0)
3739 geometry.height=geometry.width;
3740 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3741 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3745 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3752 if (LocaleCompare(keyword,"opacity") == 0)
3754 opacity=StringToDouble(value,(char **) NULL);
3757 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3764 if (LocaleCompare(keyword,"x") == 0)
3766 geometry.x=StringToLong(value);
3767 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3768 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3779 if (LocaleCompare(keyword,"y") == 0)
3781 geometry.y=StringToLong(value);
3782 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3783 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3793 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3799 draw_info=CloneDrawInfo(msl_info->image_info[n],
3800 msl_info->draw_info[n]);
3801 draw_info->fill.alpha=ClampToQuantum(opacity);
3802 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3803 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3804 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3805 MagickFalse : MagickTrue,msl_info->exception);
3806 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3807 draw_info=DestroyDrawInfo(draw_info);
3810 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3816 Median-filter image.
3818 if (msl_info->image[n] == (Image *) NULL)
3820 ThrowMSLException(OptionError,"NoImagesDefined",
3821 (const char *) tag);
3824 if (attributes != (const xmlChar **) NULL)
3825 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3827 keyword=(const char *) attributes[i++];
3828 attribute=InterpretImageProperties(msl_info->image_info[n],
3829 msl_info->attributes[n],(const char *) attributes[i],
3831 CloneString(&value,attribute);
3837 if (LocaleCompare(keyword,"geometry") == 0)
3839 flags=ParseGeometry(value,&geometry_info);
3840 if ((flags & SigmaValue) == 0)
3841 geometry_info.sigma=1.0;
3844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3851 if (LocaleCompare(keyword,"radius") == 0)
3853 geometry_info.rho=StringToDouble(value,
3857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3863 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3869 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3870 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3871 msl_info->exception);
3872 if (median_image == (Image *) NULL)
3874 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3875 msl_info->image[n]=median_image;
3878 if (LocaleCompare((const char *) tag,"minify") == 0)
3886 if (msl_info->image[n] == (Image *) NULL)
3888 ThrowMSLException(OptionError,"NoImagesDefined",
3889 (const char *) tag);
3892 if (attributes != (const xmlChar **) NULL)
3893 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3895 keyword=(const char *) attributes[i++];
3896 attribute=InterpretImageProperties(msl_info->image_info[n],
3897 msl_info->attributes[n],(const char *) attributes[i],
3899 CloneString(&value,attribute);
3900 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3902 minify_image=MinifyImage(msl_info->image[n],
3903 msl_info->exception);
3904 if (minify_image == (Image *) NULL)
3906 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3907 msl_info->image[n]=minify_image;
3910 if (LocaleCompare((const char *) tag,"msl") == 0 )
3912 if (LocaleCompare((const char *) tag,"modulate") == 0)
3915 modulate[MaxTextExtent];
3920 if (msl_info->image[n] == (Image *) NULL)
3922 ThrowMSLException(OptionError,"NoImagesDefined",
3923 (const char *) tag);
3926 geometry_info.rho=100.0;
3927 geometry_info.sigma=100.0;
3928 geometry_info.xi=100.0;
3929 if (attributes != (const xmlChar **) NULL)
3930 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3932 keyword=(const char *) attributes[i++];
3933 attribute=InterpretImageProperties(msl_info->image_info[n],
3934 msl_info->attributes[n],(const char *) attributes[i],
3936 CloneString(&value,attribute);
3942 if (LocaleCompare(keyword,"blackness") == 0)
3944 geometry_info.rho=StringToDouble(value,
3948 if (LocaleCompare(keyword,"brightness") == 0)
3950 geometry_info.rho=StringToDouble(value,
3954 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3961 if (LocaleCompare(keyword,"factor") == 0)
3963 flags=ParseGeometry(value,&geometry_info);
3966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3973 if (LocaleCompare(keyword,"hue") == 0)
3975 geometry_info.xi=StringToDouble(value,
3979 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3986 if (LocaleCompare(keyword,"lightness") == 0)
3988 geometry_info.rho=StringToDouble(value,
3992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3999 if (LocaleCompare(keyword,"saturation") == 0)
4001 geometry_info.sigma=StringToDouble(value,
4005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4012 if (LocaleCompare(keyword,"whiteness") == 0)
4014 geometry_info.sigma=StringToDouble(value,
4018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4030 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4031 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4032 (void) ModulateImage(msl_info->image[n],modulate,
4033 msl_info->exception);
4036 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4041 if (LocaleCompare((const char *) tag,"negate") == 0)
4049 if (msl_info->image[n] == (Image *) NULL)
4051 ThrowMSLException(OptionError,"NoImagesDefined",
4052 (const char *) tag);
4056 if (attributes != (const xmlChar **) NULL)
4057 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4059 keyword=(const char *) attributes[i++];
4060 attribute=InterpretImageProperties(msl_info->image_info[n],
4061 msl_info->attributes[n],(const char *) attributes[i],
4063 CloneString(&value,attribute);
4069 if (LocaleCompare(keyword,"channel") == 0)
4071 option=ParseChannelOption(value);
4073 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4075 channel=(ChannelType) option;
4078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4085 if (LocaleCompare(keyword,"gray") == 0)
4087 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4090 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4092 gray=(MagickBooleanType) option;
4095 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4107 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4108 (void) NegateImage(msl_info->image[n],gray,
4109 msl_info->exception);
4110 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4113 if (LocaleCompare((const char *) tag,"normalize") == 0)
4118 if (msl_info->image[n] == (Image *) NULL)
4120 ThrowMSLException(OptionError,"NoImagesDefined",
4121 (const char *) tag);
4124 if (attributes != (const xmlChar **) NULL)
4125 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4127 keyword=(const char *) attributes[i++];
4128 attribute=InterpretImageProperties(msl_info->image_info[n],
4129 msl_info->attributes[n],(const char *) attributes[i],
4131 CloneString(&value,attribute);
4137 if (LocaleCompare(keyword,"channel") == 0)
4139 option=ParseChannelOption(value);
4141 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4143 channel=(ChannelType) option;
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4158 (void) NormalizeImage(msl_info->image[n],
4159 msl_info->exception);
4162 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4167 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4175 if (msl_info->image[n] == (Image *) NULL)
4177 ThrowMSLException(OptionError,"NoImagesDefined",
4178 (const char *) tag);
4181 if (attributes != (const xmlChar **) NULL)
4182 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4184 keyword=(const char *) attributes[i++];
4185 attribute=InterpretImageProperties(msl_info->image_info[n],
4186 msl_info->attributes[n],(const char *) attributes[i],
4188 CloneString(&value,attribute);
4194 if (LocaleCompare(keyword,"geometry") == 0)
4196 flags=ParseGeometry(value,&geometry_info);
4197 if ((flags & SigmaValue) == 0)
4198 geometry_info.sigma=1.0;
4201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4208 if (LocaleCompare(keyword,"radius") == 0)
4210 geometry_info.rho=StringToDouble(value,
4214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4226 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4227 geometry_info.sigma,msl_info->exception);
4228 if (paint_image == (Image *) NULL)
4230 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4231 msl_info->image[n]=paint_image;
4234 if (LocaleCompare((const char *) tag,"opaque") == 0)
4243 if (msl_info->image[n] == (Image *) NULL)
4245 ThrowMSLException(OptionError,"NoImagesDefined",
4246 (const char *) tag);
4249 (void) QueryColorCompliance("none",AllCompliance,&target,
4251 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4253 if (attributes != (const xmlChar **) NULL)
4254 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4256 keyword=(const char *) attributes[i++];
4257 attribute=InterpretImageProperties(msl_info->image_info[n],
4258 msl_info->attributes[n],(const char *) attributes[i],
4260 CloneString(&value,attribute);
4266 if (LocaleCompare(keyword,"channel") == 0)
4268 option=ParseChannelOption(value);
4270 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4272 channel=(ChannelType) option;
4275 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4282 if (LocaleCompare(keyword,"fill") == 0)
4284 (void) QueryColorCompliance(value,AllCompliance,
4285 &fill_color,&exception);
4288 if (LocaleCompare(keyword,"fuzz") == 0)
4290 msl_info->image[n]->fuzz=StringToDouble(value,
4294 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4300 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4306 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4307 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4308 MagickFalse,msl_info->exception);
4309 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4312 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4317 if (LocaleCompare((const char *) tag,"print") == 0)
4319 if (attributes == (const xmlChar **) NULL)
4321 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4323 keyword=(const char *) attributes[i++];
4324 attribute=InterpretImageProperties(msl_info->image_info[n],
4325 msl_info->attributes[n],(const char *) attributes[i],
4327 CloneString(&value,attribute);
4333 if (LocaleCompare(keyword,"output") == 0)
4335 (void) FormatLocaleFile(stdout,"%s",value);
4338 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4343 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4350 if (LocaleCompare((const char *) tag, "profile") == 0)
4352 if (msl_info->image[n] == (Image *) NULL)
4354 ThrowMSLException(OptionError,"NoImagesDefined",
4355 (const char *) tag);
4358 if (attributes == (const xmlChar **) NULL)
4360 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4374 keyword=(const char *) attributes[i++];
4375 attribute=InterpretImageProperties(msl_info->image_info[n],
4376 msl_info->attributes[n],(const char *) attributes[i],
4378 CloneString(&value,attribute);
4379 if (*keyword == '!')
4382 Remove a profile from the image.
4384 (void) ProfileImage(msl_info->image[n],keyword,
4385 (const unsigned char *) NULL,0,&exception);
4389 Associate a profile with the image.
4391 profile_info=CloneImageInfo(msl_info->image_info[n]);
4392 profile=GetImageProfile(msl_info->image[n],"iptc");
4393 if (profile != (StringInfo *) NULL)
4394 profile_info->profile=(void *) CloneStringInfo(profile);
4395 profile_image=GetImageCache(profile_info,keyword,&exception);
4396 profile_info=DestroyImageInfo(profile_info);
4397 if (profile_image == (Image *) NULL)
4400 name[MaxTextExtent],
4401 filename[MaxTextExtent];
4409 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4410 (void) CopyMagickString(name,keyword,MaxTextExtent);
4411 for (p=filename; *p != '\0'; p++)
4412 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4413 (IsPathAccessible(keyword) == MagickFalse))
4419 Look for profile name (e.g. name:profile).
4421 (void) CopyMagickString(name,filename,(size_t)
4423 for (q=filename; *q != '\0'; q++)
4427 profile=FileToStringInfo(filename,~0UL,&exception);
4428 if (profile != (StringInfo *) NULL)
4430 (void) ProfileImage(msl_info->image[n],name,
4431 GetStringInfoDatum(profile),(size_t)
4432 GetStringInfoLength(profile),&exception);
4433 profile=DestroyStringInfo(profile);
4437 ResetImageProfileIterator(profile_image);
4438 name=GetNextImageProfile(profile_image);
4439 while (name != (const char *) NULL)
4441 profile=GetImageProfile(profile_image,name);
4442 if (profile != (StringInfo *) NULL)
4443 (void) ProfileImage(msl_info->image[n],name,
4444 GetStringInfoDatum(profile),(size_t)
4445 GetStringInfoLength(profile),&exception);
4446 name=GetNextImageProfile(profile_image);
4448 profile_image=DestroyImage(profile_image);
4452 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4457 if (LocaleCompare((const char *) tag,"quantize") == 0)
4465 if (msl_info->image[n] == (Image *) NULL)
4467 ThrowMSLException(OptionError,"NoImagesDefined",
4468 (const char *) tag);
4471 GetQuantizeInfo(&quantize_info);
4472 if (attributes != (const xmlChar **) NULL)
4473 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4475 keyword=(const char *) attributes[i++];
4476 attribute=InterpretImageProperties(msl_info->image_info[n],
4477 msl_info->attributes[n],(const char *) attributes[i],
4479 CloneString(&value,attribute);
4485 if (LocaleCompare(keyword,"colors") == 0)
4487 quantize_info.number_colors=StringToLong(value);
4490 if (LocaleCompare(keyword,"colorspace") == 0)
4492 option=ParseCommandOption(MagickColorspaceOptions,
4495 ThrowMSLException(OptionError,
4496 "UnrecognizedColorspaceType",value);
4497 quantize_info.colorspace=(ColorspaceType) option;
4500 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4507 if (LocaleCompare(keyword,"dither") == 0)
4509 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4512 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4514 quantize_info.dither_method=(DitherMethod) option;
4517 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4524 if (LocaleCompare(keyword,"measure") == 0)
4526 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4529 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4531 quantize_info.measure_error=(MagickBooleanType) option;
4534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4541 if (LocaleCompare(keyword,"treedepth") == 0)
4543 quantize_info.tree_depth=StringToLong(value);
4546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4552 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4558 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4561 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4564 text[MaxTextExtent];
4575 draw_info=CloneDrawInfo(msl_info->image_info[n],
4576 msl_info->draw_info[n]);
4578 current=draw_info->affine;
4579 GetAffineMatrix(&affine);
4580 if (attributes != (const xmlChar **) NULL)
4581 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4583 keyword=(const char *) attributes[i++];
4584 attribute=InterpretImageProperties(msl_info->image_info[n],
4585 msl_info->attributes[n],(const char *) attributes[i],
4587 CloneString(&value,attribute);
4593 if (LocaleCompare(keyword,"affine") == 0)
4599 draw_info->affine.sx=StringToDouble(p,&p);
4602 draw_info->affine.rx=StringToDouble(p,&p);
4605 draw_info->affine.ry=StringToDouble(p,&p);
4608 draw_info->affine.sy=StringToDouble(p,&p);
4611 draw_info->affine.tx=StringToDouble(p,&p);
4614 draw_info->affine.ty=StringToDouble(p,&p);
4617 if (LocaleCompare(keyword,"align") == 0)
4619 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4622 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4624 draw_info->align=(AlignType) option;
4627 if (LocaleCompare(keyword,"antialias") == 0)
4629 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4632 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4634 draw_info->stroke_antialias=(MagickBooleanType) option;
4635 draw_info->text_antialias=(MagickBooleanType) option;
4638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4645 if (LocaleCompare(keyword,"density") == 0)
4647 CloneString(&draw_info->density,value);
4650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4657 if (LocaleCompare(keyword,"encoding") == 0)
4659 CloneString(&draw_info->encoding,value);
4662 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4669 if (LocaleCompare(keyword, "fill") == 0)
4671 (void) QueryColorCompliance(value,AllCompliance,
4672 &draw_info->fill,&exception);
4675 if (LocaleCompare(keyword,"family") == 0)
4677 CloneString(&draw_info->family,value);
4680 if (LocaleCompare(keyword,"font") == 0)
4682 CloneString(&draw_info->font,value);
4685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4692 if (LocaleCompare(keyword,"geometry") == 0)
4694 flags=ParsePageGeometry(msl_info->image[n],value,
4695 &geometry,&exception);
4696 if ((flags & HeightValue) == 0)
4697 geometry.height=geometry.width;
4700 if (LocaleCompare(keyword,"gravity") == 0)
4702 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4705 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4707 draw_info->gravity=(GravityType) option;
4710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4717 if (LocaleCompare(keyword,"pointsize") == 0)
4719 draw_info->pointsize=StringToDouble(value,
4723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4730 if (LocaleCompare(keyword,"rotate") == 0)
4732 angle=StringToDouble(value,(char **) NULL);
4733 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4734 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4735 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4736 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(keyword,"scale") == 0)
4748 flags=ParseGeometry(value,&geometry_info);
4749 if ((flags & SigmaValue) == 0)
4750 geometry_info.sigma=1.0;
4751 affine.sx=geometry_info.rho;
4752 affine.sy=geometry_info.sigma;
4755 if (LocaleCompare(keyword,"skewX") == 0)
4757 angle=StringToDouble(value,(char **) NULL);
4758 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4761 if (LocaleCompare(keyword,"skewY") == 0)
4763 angle=StringToDouble(value,(char **) NULL);
4764 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4767 if (LocaleCompare(keyword,"stretch") == 0)
4769 option=ParseCommandOption(MagickStretchOptions,
4772 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4774 draw_info->stretch=(StretchType) option;
4777 if (LocaleCompare(keyword, "stroke") == 0)
4779 (void) QueryColorCompliance(value,AllCompliance,
4780 &draw_info->stroke,&exception);
4783 if (LocaleCompare(keyword,"strokewidth") == 0)
4785 draw_info->stroke_width=StringToLong(value);
4788 if (LocaleCompare(keyword,"style") == 0)
4790 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4793 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4795 draw_info->style=(StyleType) option;
4798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4805 if (LocaleCompare(keyword,"text") == 0)
4807 CloneString(&draw_info->text,value);
4810 if (LocaleCompare(keyword,"translate") == 0)
4812 flags=ParseGeometry(value,&geometry_info);
4813 if ((flags & SigmaValue) == 0)
4814 geometry_info.sigma=1.0;
4815 affine.tx=geometry_info.rho;
4816 affine.ty=geometry_info.sigma;
4819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4826 if (LocaleCompare(keyword, "undercolor") == 0)
4828 (void) QueryColorCompliance(value,AllCompliance,
4829 &draw_info->undercolor,&exception);
4832 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4839 if (LocaleCompare(keyword,"weight") == 0)
4841 draw_info->weight=StringToLong(value);
4844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4851 if (LocaleCompare(keyword,"x") == 0)
4853 geometry.x=StringToLong(value);
4856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4863 if (LocaleCompare(keyword,"y") == 0)
4865 geometry.y=StringToLong(value);
4868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4874 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4880 (void) FormatLocaleString(text,MaxTextExtent,
4881 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4882 geometry.height,(double) geometry.x,(double) geometry.y);
4883 CloneString(&draw_info->geometry,text);
4884 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4885 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4886 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4887 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4888 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4890 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4892 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4893 msl_info->exception);
4894 if (status != MagickFalse)
4899 image=msl_info->attributes[n];
4900 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4901 "%g",metrics.pixels_per_em.x);
4902 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4903 "%g",metrics.pixels_per_em.y);
4904 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4906 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4908 FormatImageProperty(image,"msl:font-metrics.width","%g",
4910 FormatImageProperty(image,"msl:font-metrics.height","%g",
4912 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4913 metrics.max_advance);
4914 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4916 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4918 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4920 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4922 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4924 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4927 draw_info=DestroyDrawInfo(draw_info);
4930 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4935 if (LocaleCompare((const char *) tag,"raise") == 0)
4943 if (msl_info->image[n] == (Image *) NULL)
4945 ThrowMSLException(OptionError,"NoImagesDefined",
4946 (const char *) tag);
4950 SetGeometry(msl_info->image[n],&geometry);
4951 if (attributes != (const xmlChar **) NULL)
4952 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4954 keyword=(const char *) attributes[i++];
4955 attribute=InterpretImageProperties(msl_info->image_info[n],
4956 msl_info->attributes[n],(const char *) attributes[i],
4958 CloneString(&value,attribute);
4964 if (LocaleCompare(keyword,"geometry") == 0)
4966 flags=ParsePageGeometry(msl_info->image[n],value,
4967 &geometry,&exception);
4968 if ((flags & HeightValue) == 0)
4969 geometry.height=geometry.width;
4972 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4979 if (LocaleCompare(keyword,"height") == 0)
4981 geometry.height=StringToLong(value);
4984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4991 if (LocaleCompare(keyword,"raise") == 0)
4993 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4996 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4998 raise=(MagickBooleanType) option;
5001 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5008 if (LocaleCompare(keyword,"width") == 0)
5010 geometry.width=StringToLong(value);
5013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5025 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5026 msl_info->exception);
5029 if (LocaleCompare((const char *) tag,"read") == 0)
5031 if (attributes == (const xmlChar **) NULL)
5033 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5035 keyword=(const char *) attributes[i++];
5036 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5037 msl_info->attributes[n],(const char *) attributes[i],&exception));
5043 if (LocaleCompare(keyword,"filename") == 0)
5048 (void) CopyMagickString(msl_info->image_info[n]->filename,
5049 value,MaxTextExtent);
5050 image=ReadImage(msl_info->image_info[n],&exception);
5051 CatchException(&exception);
5052 if (image == (Image *) NULL)
5054 AppendImageToList(&msl_info->image[n],image);
5057 (void) SetMSLAttributes(msl_info,keyword,value);
5062 (void) SetMSLAttributes(msl_info,keyword,value);
5069 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5077 if (msl_info->image[n] == (Image *) NULL)
5079 ThrowMSLException(OptionError,"NoImagesDefined",
5080 (const char *) tag);
5083 if (attributes != (const xmlChar **) NULL)
5084 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5086 keyword=(const char *) attributes[i++];
5087 attribute=InterpretImageProperties(msl_info->image_info[n],
5088 msl_info->attributes[n],(const char *) attributes[i],
5090 CloneString(&value,attribute);
5096 if (LocaleCompare(keyword,"geometry") == 0)
5098 flags=ParseGeometry(value,&geometry_info);
5099 if ((flags & SigmaValue) == 0)
5100 geometry_info.sigma=1.0;
5103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5110 if (LocaleCompare(keyword,"radius") == 0)
5112 geometry_info.rho=StringToDouble(value,
5116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5128 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5129 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5130 msl_info->exception);
5131 if (paint_image == (Image *) NULL)
5133 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5134 msl_info->image[n]=paint_image;
5137 else if (LocaleCompare((const char *) tag,"repage") == 0)
5139 /* init the values */
5140 width=msl_info->image[n]->page.width;
5141 height=msl_info->image[n]->page.height;
5142 x=msl_info->image[n]->page.x;
5143 y=msl_info->image[n]->page.y;
5145 if (msl_info->image[n] == (Image *) NULL)
5147 ThrowMSLException(OptionError,"NoImagesDefined",
5148 (const char *) tag);
5151 if (attributes == (const xmlChar **) NULL)
5153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5155 keyword=(const char *) attributes[i++];
5156 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5157 msl_info->attributes[n],(const char *) attributes[i],&exception));
5163 if (LocaleCompare(keyword,"geometry") == 0)
5171 flags=ParseAbsoluteGeometry(value,&geometry);
5172 if ((flags & WidthValue) != 0)
5174 if ((flags & HeightValue) == 0)
5175 geometry.height=geometry.width;
5176 width=geometry.width;
5177 height=geometry.height;
5179 if ((flags & AspectValue) != 0)
5181 if ((flags & XValue) != 0)
5183 if ((flags & YValue) != 0)
5188 if ((flags & XValue) != 0)
5191 if ((width == 0) && (geometry.x > 0))
5192 width=msl_info->image[n]->columns+geometry.x;
5194 if ((flags & YValue) != 0)
5197 if ((height == 0) && (geometry.y > 0))
5198 height=msl_info->image[n]->rows+geometry.y;
5203 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5209 if (LocaleCompare(keyword,"height") == 0)
5211 height = StringToLong( value );
5214 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5220 if (LocaleCompare(keyword,"width") == 0)
5222 width = StringToLong( value );
5225 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5231 if (LocaleCompare(keyword,"x") == 0)
5233 x = StringToLong( value );
5236 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5242 if (LocaleCompare(keyword,"y") == 0)
5244 y = StringToLong( value );
5247 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5252 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5258 msl_info->image[n]->page.width=width;
5259 msl_info->image[n]->page.height=height;
5260 msl_info->image[n]->page.x=x;
5261 msl_info->image[n]->page.y=y;
5264 else if (LocaleCompare((const char *) tag,"resample") == 0)
5270 if (msl_info->image[n] == (Image *) NULL)
5272 ThrowMSLException(OptionError,"NoImagesDefined",
5273 (const char *) tag);
5276 if (attributes == (const xmlChar **) NULL)
5278 x_resolution=DefaultResolution;
5279 y_resolution=DefaultResolution;
5280 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5282 keyword=(const char *) attributes[i++];
5283 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5284 msl_info->attributes[n],(const char *) attributes[i],&exception));
5290 if (LocaleCompare(keyword,"geometry") == 0)
5295 flags=ParseGeometry(value,&geometry_info);
5296 if ((flags & SigmaValue) == 0)
5297 geometry_info.sigma*=geometry_info.rho;
5298 x_resolution=geometry_info.rho;
5299 y_resolution=geometry_info.sigma;
5302 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5308 if (LocaleCompare(keyword,"x-resolution") == 0)
5310 x_resolution=StringToDouble(value,(char **) NULL);
5313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5319 if (LocaleCompare(keyword,"y-resolution") == 0)
5321 y_resolution=StringToDouble(value,(char **) NULL);
5324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5329 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5345 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5347 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5348 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5349 msl_info->image[n]->resolution.x))+0.5);
5350 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5351 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5352 msl_info->image[n]->resolution.y))+0.5);
5353 resample_image=ResizeImage(msl_info->image[n],width,height,
5354 msl_info->image[n]->filter,msl_info->exception);
5355 if (resample_image == (Image *) NULL)
5357 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5358 msl_info->image[n]=resample_image;
5362 if (LocaleCompare((const char *) tag,"resize") == 0)
5373 if (msl_info->image[n] == (Image *) NULL)
5375 ThrowMSLException(OptionError,"NoImagesDefined",
5376 (const char *) tag);
5379 filter=UndefinedFilter;
5380 if (attributes != (const xmlChar **) NULL)
5381 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5383 keyword=(const char *) attributes[i++];
5384 attribute=InterpretImageProperties(msl_info->image_info[n],
5385 msl_info->attributes[n],(const char *) attributes[i],
5387 CloneString(&value,attribute);
5393 if (LocaleCompare(keyword,"filter") == 0)
5395 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5398 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5400 filter=(FilterTypes) option;
5403 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5410 if (LocaleCompare(keyword,"geometry") == 0)
5412 flags=ParseRegionGeometry(msl_info->image[n],value,
5413 &geometry,&exception);
5416 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5423 if (LocaleCompare(keyword,"height") == 0)
5425 geometry.height=StringToUnsignedLong(value);
5428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5435 if (LocaleCompare(keyword,"width") == 0)
5437 geometry.width=StringToLong(value);
5440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5446 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5452 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5453 geometry.height,filter,msl_info->exception);
5454 if (resize_image == (Image *) NULL)
5456 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5457 msl_info->image[n]=resize_image;
5460 if (LocaleCompare((const char *) tag,"roll") == 0)
5468 if (msl_info->image[n] == (Image *) NULL)
5470 ThrowMSLException(OptionError,"NoImagesDefined",
5471 (const char *) tag);
5474 SetGeometry(msl_info->image[n],&geometry);
5475 if (attributes != (const xmlChar **) NULL)
5476 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5478 keyword=(const char *) attributes[i++];
5479 attribute=InterpretImageProperties(msl_info->image_info[n],
5480 msl_info->attributes[n],(const char *) attributes[i],
5482 CloneString(&value,attribute);
5488 if (LocaleCompare(keyword,"geometry") == 0)
5490 flags=ParsePageGeometry(msl_info->image[n],value,
5491 &geometry,&exception);
5492 if ((flags & HeightValue) == 0)
5493 geometry.height=geometry.width;
5496 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5503 if (LocaleCompare(keyword,"x") == 0)
5505 geometry.x=StringToLong(value);
5508 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5515 if (LocaleCompare(keyword,"y") == 0)
5517 geometry.y=StringToLong(value);
5520 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5526 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5532 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5533 msl_info->exception);
5534 if (roll_image == (Image *) NULL)
5536 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5537 msl_info->image[n]=roll_image;
5540 else if (LocaleCompare((const char *) tag,"roll") == 0)
5542 /* init the values */
5543 width=msl_info->image[n]->columns;
5544 height=msl_info->image[n]->rows;
5547 if (msl_info->image[n] == (Image *) NULL)
5549 ThrowMSLException(OptionError,"NoImagesDefined",
5550 (const char *) tag);
5553 if (attributes == (const xmlChar **) NULL)
5555 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5557 keyword=(const char *) attributes[i++];
5558 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5559 msl_info->attributes[n],(const char *) attributes[i],&exception));
5565 if (LocaleCompare(keyword,"geometry") == 0)
5567 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5570 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5576 if (LocaleCompare(keyword,"x") == 0)
5578 x = StringToLong( value );
5581 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5587 if (LocaleCompare(keyword,"y") == 0)
5589 y = StringToLong( value );
5592 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5597 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5610 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5611 if (newImage == (Image *) NULL)
5613 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5614 msl_info->image[n]=newImage;
5619 if (LocaleCompare((const char *) tag,"rotate") == 0)
5627 if (msl_info->image[n] == (Image *) NULL)
5629 ThrowMSLException(OptionError,"NoImagesDefined",
5630 (const char *) tag);
5633 if (attributes != (const xmlChar **) NULL)
5634 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5636 keyword=(const char *) attributes[i++];
5637 attribute=InterpretImageProperties(msl_info->image_info[n],
5638 msl_info->attributes[n],(const char *) attributes[i],
5640 CloneString(&value,attribute);
5646 if (LocaleCompare(keyword,"degrees") == 0)
5648 geometry_info.rho=StringToDouble(value,
5652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5659 if (LocaleCompare(keyword,"geometry") == 0)
5661 flags=ParseGeometry(value,&geometry_info);
5662 if ((flags & SigmaValue) == 0)
5663 geometry_info.sigma=1.0;
5666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5672 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5678 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5679 msl_info->exception);
5680 if (rotate_image == (Image *) NULL)
5682 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5683 msl_info->image[n]=rotate_image;
5686 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5688 /* init the values */
5691 if (msl_info->image[n] == (Image *) NULL)
5693 ThrowMSLException(OptionError,"NoImagesDefined",
5694 (const char *) tag);
5697 if (attributes == (const xmlChar **) NULL)
5699 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5701 keyword=(const char *) attributes[i++];
5702 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5703 msl_info->attributes[n],(const char *) attributes[i],&exception));
5709 if (LocaleCompare(keyword,"degrees") == 0)
5711 degrees = StringToDouble(value,(char **) NULL);
5714 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5719 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5732 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5733 if (newImage == (Image *) NULL)
5735 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5736 msl_info->image[n]=newImage;
5741 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5746 if (LocaleCompare((const char *) tag,"sample") == 0)
5754 if (msl_info->image[n] == (Image *) NULL)
5756 ThrowMSLException(OptionError,"NoImagesDefined",
5757 (const char *) tag);
5760 if (attributes != (const xmlChar **) NULL)
5761 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5763 keyword=(const char *) attributes[i++];
5764 attribute=InterpretImageProperties(msl_info->image_info[n],
5765 msl_info->attributes[n],(const char *) attributes[i],
5767 CloneString(&value,attribute);
5773 if (LocaleCompare(keyword,"geometry") == 0)
5775 flags=ParseRegionGeometry(msl_info->image[n],value,
5776 &geometry,&exception);
5779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5786 if (LocaleCompare(keyword,"height") == 0)
5788 geometry.height=StringToUnsignedLong(value);
5791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5798 if (LocaleCompare(keyword,"width") == 0)
5800 geometry.width=StringToLong(value);
5803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5815 sample_image=SampleImage(msl_info->image[n],geometry.width,
5816 geometry.height,msl_info->exception);
5817 if (sample_image == (Image *) NULL)
5819 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5820 msl_info->image[n]=sample_image;
5823 if (LocaleCompare((const char *) tag,"scale") == 0)
5831 if (msl_info->image[n] == (Image *) NULL)
5833 ThrowMSLException(OptionError,"NoImagesDefined",
5834 (const char *) tag);
5837 if (attributes != (const xmlChar **) NULL)
5838 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5840 keyword=(const char *) attributes[i++];
5841 attribute=InterpretImageProperties(msl_info->image_info[n],
5842 msl_info->attributes[n],(const char *) attributes[i],
5844 CloneString(&value,attribute);
5850 if (LocaleCompare(keyword,"geometry") == 0)
5852 flags=ParseRegionGeometry(msl_info->image[n],value,
5853 &geometry,&exception);
5856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5863 if (LocaleCompare(keyword,"height") == 0)
5865 geometry.height=StringToUnsignedLong(value);
5868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5875 if (LocaleCompare(keyword,"width") == 0)
5877 geometry.width=StringToLong(value);
5880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5886 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5892 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5893 geometry.height,msl_info->exception);
5894 if (scale_image == (Image *) NULL)
5896 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5897 msl_info->image[n]=scale_image;
5900 if (LocaleCompare((const char *) tag,"segment") == 0)
5911 if (msl_info->image[n] == (Image *) NULL)
5913 ThrowMSLException(OptionError,"NoImagesDefined",
5914 (const char *) tag);
5917 geometry_info.rho=1.0;
5918 geometry_info.sigma=1.5;
5919 colorspace=sRGBColorspace;
5920 verbose=MagickFalse;
5921 if (attributes != (const xmlChar **) NULL)
5922 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5924 keyword=(const char *) attributes[i++];
5925 attribute=InterpretImageProperties(msl_info->image_info[n],
5926 msl_info->attributes[n],(const char *) attributes[i],
5928 CloneString(&value,attribute);
5934 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5936 geometry_info.rho=StringToDouble(value,
5940 if (LocaleCompare(keyword,"colorspace") == 0)
5942 option=ParseCommandOption(MagickColorspaceOptions,
5945 ThrowMSLException(OptionError,
5946 "UnrecognizedColorspaceType",value);
5947 colorspace=(ColorspaceType) option;
5950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5957 if (LocaleCompare(keyword,"geometry") == 0)
5959 flags=ParseGeometry(value,&geometry_info);
5960 if ((flags & SigmaValue) == 0)
5961 geometry_info.sigma=1.5;
5964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5971 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5973 geometry_info.sigma=StringToDouble(value,
5977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5983 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5989 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5990 geometry_info.rho,geometry_info.sigma,&exception);
5993 else if (LocaleCompare((const char *) tag, "set") == 0)
5995 if (msl_info->image[n] == (Image *) NULL)
5997 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6001 if (attributes == (const xmlChar **) NULL)
6003 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6005 keyword=(const char *) attributes[i++];
6006 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6007 msl_info->attributes[n],(const char *) attributes[i],&exception));
6013 if (LocaleCompare(keyword,"clip-mask") == 0)
6015 for (j=0; j < msl_info->n; j++)
6020 property=GetImageProperty(msl_info->attributes[j],"id",
6022 if (LocaleCompare(property,value) == 0)
6024 SetImageMask(msl_info->image[n],msl_info->image[j],
6031 if (LocaleCompare(keyword,"clip-path") == 0)
6033 for (j=0; j < msl_info->n; j++)
6038 property=GetImageProperty(msl_info->attributes[j],"id",
6040 if (LocaleCompare(property,value) == 0)
6042 SetImageMask(msl_info->image[n],msl_info->image[j],
6049 if (LocaleCompare(keyword,"colorspace") == 0)
6054 colorspace=(ColorspaceType) ParseCommandOption(
6055 MagickColorspaceOptions,MagickFalse,value);
6057 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6059 (void) TransformImageColorspace(msl_info->image[n],
6060 (ColorspaceType) colorspace,&exception);
6063 (void) SetMSLAttributes(msl_info,keyword,value);
6064 (void) SetImageProperty(msl_info->image[n],keyword,value,
6071 if (LocaleCompare(keyword,"density") == 0)
6073 flags=ParseGeometry(value,&geometry_info);
6074 msl_info->image[n]->resolution.x=geometry_info.rho;
6075 msl_info->image[n]->resolution.y=geometry_info.sigma;
6076 if ((flags & SigmaValue) == 0)
6077 msl_info->image[n]->resolution.y=
6078 msl_info->image[n]->resolution.x;
6081 (void) SetMSLAttributes(msl_info,keyword,value);
6082 (void) SetImageProperty(msl_info->image[n],keyword,value,
6089 if (LocaleCompare(keyword, "opacity") == 0)
6091 ssize_t opac = OpaqueAlpha,
6092 len = (ssize_t) strlen( value );
6094 if (value[len-1] == '%') {
6096 (void) CopyMagickString(tmp,value,len);
6097 opac = StringToLong( tmp );
6098 opac = (int)(QuantumRange * ((float)opac/100));
6100 opac = StringToLong( value );
6101 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6105 (void) SetMSLAttributes(msl_info,keyword,value);
6106 (void) SetImageProperty(msl_info->image[n],keyword,value,
6107 msl_info->exception);
6113 if (LocaleCompare(keyword, "page") == 0)
6116 page[MaxTextExtent];
6127 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6128 image_option=GetImageArtifact(msl_info->image[n],"page");
6129 if (image_option != (const char *) NULL)
6130 flags=ParseAbsoluteGeometry(image_option,&geometry);
6131 flags=ParseAbsoluteGeometry(value,&geometry);
6132 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6133 (double) geometry.width,(double) geometry.height);
6134 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6135 (void) FormatLocaleString(page,MaxTextExtent,
6136 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6137 (double) geometry.height,(double) geometry.x,(double)
6139 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6140 msl_info->image_info[n]->page=GetPageGeometry(page);
6143 (void) SetMSLAttributes(msl_info,keyword,value);
6144 (void) SetImageProperty(msl_info->image[n],keyword,value,
6145 msl_info->exception);
6150 (void) SetMSLAttributes(msl_info,keyword,value);
6151 (void) SetImageProperty(msl_info->image[n],keyword,value,
6152 msl_info->exception);
6159 if (LocaleCompare((const char *) tag,"shade") == 0)
6170 if (msl_info->image[n] == (Image *) NULL)
6172 ThrowMSLException(OptionError,"NoImagesDefined",
6173 (const char *) tag);
6177 if (attributes != (const xmlChar **) NULL)
6178 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6180 keyword=(const char *) attributes[i++];
6181 attribute=InterpretImageProperties(msl_info->image_info[n],
6182 msl_info->attributes[n],(const char *) attributes[i],
6184 CloneString(&value,attribute);
6190 if (LocaleCompare(keyword,"azimuth") == 0)
6192 geometry_info.rho=StringToDouble(value,
6196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6203 if (LocaleCompare(keyword,"elevation") == 0)
6205 geometry_info.sigma=StringToDouble(value,
6209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6216 if (LocaleCompare(keyword,"geometry") == 0)
6218 flags=ParseGeometry(value,&geometry_info);
6219 if ((flags & SigmaValue) == 0)
6220 geometry_info.sigma=1.0;
6223 if (LocaleCompare(keyword,"gray") == 0)
6225 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6228 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6230 gray=(MagickBooleanType) option;
6233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6245 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6246 geometry_info.sigma,msl_info->exception);
6247 if (shade_image == (Image *) NULL)
6249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6250 msl_info->image[n]=shade_image;
6253 if (LocaleCompare((const char *) tag,"shadow") == 0)
6261 if (msl_info->image[n] == (Image *) NULL)
6263 ThrowMSLException(OptionError,"NoImagesDefined",
6264 (const char *) tag);
6267 if (attributes != (const xmlChar **) NULL)
6268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6270 keyword=(const char *) attributes[i++];
6271 attribute=InterpretImageProperties(msl_info->image_info[n],
6272 msl_info->attributes[n],(const char *) attributes[i],
6274 CloneString(&value,attribute);
6280 if (LocaleCompare(keyword,"geometry") == 0)
6282 flags=ParseGeometry(value,&geometry_info);
6283 if ((flags & SigmaValue) == 0)
6284 geometry_info.sigma=1.0;
6287 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6294 if (LocaleCompare(keyword,"opacity") == 0)
6296 geometry_info.rho=StringToLong(value);
6299 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6306 if (LocaleCompare(keyword,"sigma") == 0)
6308 geometry_info.sigma=StringToLong(value);
6316 if (LocaleCompare(keyword,"x") == 0)
6318 geometry_info.xi=StringToDouble(value,
6322 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6329 if (LocaleCompare(keyword,"y") == 0)
6331 geometry_info.psi=StringToLong(value);
6334 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6340 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6346 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6347 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6348 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6349 if (shadow_image == (Image *) NULL)
6351 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6352 msl_info->image[n]=shadow_image;
6355 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6361 if (msl_info->image[n] == (Image *) NULL)
6363 ThrowMSLException(OptionError,"NoImagesDefined",
6364 (const char *) tag);
6368 NOTE: sharpen can have no attributes, since we use all the defaults!
6370 if (attributes != (const xmlChar **) NULL)
6372 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6374 keyword=(const char *) attributes[i++];
6375 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6376 msl_info->attributes[n],(const char *) attributes[i],&exception));
6382 if (LocaleCompare(keyword, "radius") == 0)
6384 radius = StringToDouble(value,(char **) NULL);
6387 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6393 if (LocaleCompare(keyword,"sigma") == 0)
6395 sigma = StringToLong( value );
6398 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6403 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6417 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6418 msl_info->exception);
6419 if (newImage == (Image *) NULL)
6421 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6422 msl_info->image[n]=newImage;
6426 else if (LocaleCompare((const char *) tag,"shave") == 0)
6428 /* init the values */
6432 if (msl_info->image[n] == (Image *) NULL)
6434 ThrowMSLException(OptionError,"NoImagesDefined",
6435 (const char *) tag);
6438 if (attributes == (const xmlChar **) NULL)
6440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6442 keyword=(const char *) attributes[i++];
6443 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6444 msl_info->attributes[n],(const char *) attributes[i],&exception));
6450 if (LocaleCompare(keyword,"geometry") == 0)
6452 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6455 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6461 if (LocaleCompare(keyword,"height") == 0)
6463 height = StringToLong( value );
6466 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6472 if (LocaleCompare(keyword,"width") == 0)
6474 width = StringToLong( value );
6477 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6497 rectInfo.height = height;
6498 rectInfo.width = width;
6503 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6504 msl_info->exception);
6505 if (newImage == (Image *) NULL)
6507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6508 msl_info->image[n]=newImage;
6513 if (LocaleCompare((const char *) tag,"shear") == 0)
6521 if (msl_info->image[n] == (Image *) NULL)
6523 ThrowMSLException(OptionError,"NoImagesDefined",
6524 (const char *) tag);
6527 if (attributes != (const xmlChar **) NULL)
6528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6530 keyword=(const char *) attributes[i++];
6531 attribute=InterpretImageProperties(msl_info->image_info[n],
6532 msl_info->attributes[n],(const char *) attributes[i],
6534 CloneString(&value,attribute);
6540 if (LocaleCompare(keyword, "fill") == 0)
6542 (void) QueryColorCompliance(value,AllCompliance,
6543 &msl_info->image[n]->background_color,&exception);
6546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6553 if (LocaleCompare(keyword,"geometry") == 0)
6555 flags=ParseGeometry(value,&geometry_info);
6556 if ((flags & SigmaValue) == 0)
6557 geometry_info.sigma=1.0;
6560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6567 if (LocaleCompare(keyword,"x") == 0)
6569 geometry_info.rho=StringToDouble(value,
6573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6580 if (LocaleCompare(keyword,"y") == 0)
6582 geometry_info.sigma=StringToLong(value);
6585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6597 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6598 geometry_info.sigma,msl_info->exception);
6599 if (shear_image == (Image *) NULL)
6601 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6602 msl_info->image[n]=shear_image;
6605 if (LocaleCompare((const char *) tag,"signature") == 0)
6610 if (msl_info->image[n] == (Image *) NULL)
6612 ThrowMSLException(OptionError,"NoImagesDefined",
6613 (const char *) tag);
6616 if (attributes != (const xmlChar **) NULL)
6617 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6619 keyword=(const char *) attributes[i++];
6620 attribute=InterpretImageProperties(msl_info->image_info[n],
6621 msl_info->attributes[n],(const char *) attributes[i],
6623 CloneString(&value,attribute);
6628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6634 (void) SignatureImage(msl_info->image[n],&exception);
6637 if (LocaleCompare((const char *) tag,"solarize") == 0)
6642 if (msl_info->image[n] == (Image *) NULL)
6644 ThrowMSLException(OptionError,"NoImagesDefined",
6645 (const char *) tag);
6648 geometry_info.rho=QuantumRange/2.0;
6649 if (attributes != (const xmlChar **) NULL)
6650 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6652 keyword=(const char *) attributes[i++];
6653 attribute=InterpretImageProperties(msl_info->image_info[n],
6654 msl_info->attributes[n],(const char *) attributes[i],
6656 CloneString(&value,attribute);
6662 if (LocaleCompare(keyword,"geometry") == 0)
6664 flags=ParseGeometry(value,&geometry_info);
6667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6674 if (LocaleCompare(keyword,"threshold") == 0)
6676 geometry_info.rho=StringToDouble(value,
6680 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6692 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6693 msl_info->exception);
6696 if (LocaleCompare((const char *) tag,"spread") == 0)
6704 if (msl_info->image[n] == (Image *) NULL)
6706 ThrowMSLException(OptionError,"NoImagesDefined",
6707 (const char *) tag);
6710 if (attributes != (const xmlChar **) NULL)
6711 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6713 keyword=(const char *) attributes[i++];
6714 attribute=InterpretImageProperties(msl_info->image_info[n],
6715 msl_info->attributes[n],(const char *) attributes[i],
6717 CloneString(&value,attribute);
6723 if (LocaleCompare(keyword,"geometry") == 0)
6725 flags=ParseGeometry(value,&geometry_info);
6726 if ((flags & SigmaValue) == 0)
6727 geometry_info.sigma=1.0;
6730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6737 if (LocaleCompare(keyword,"radius") == 0)
6739 geometry_info.rho=StringToDouble(value,
6743 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6749 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6755 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6756 msl_info->image[n]->interpolate,msl_info->exception);
6757 if (spread_image == (Image *) NULL)
6759 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6760 msl_info->image[n]=spread_image;
6763 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6766 watermark = (Image*)NULL;
6768 if (msl_info->image[n] == (Image *) NULL)
6770 ThrowMSLException(OptionError,"NoImagesDefined",
6771 (const char *) tag);
6774 if (attributes == (const xmlChar **) NULL)
6776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6778 keyword=(const char *) attributes[i++];
6779 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6780 msl_info->attributes[n],(const char *) attributes[i],&exception));
6786 if (LocaleCompare(keyword,"image") == 0)
6788 for (j=0; j<msl_info->n;j++)
6791 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6793 if (theAttr && LocaleCompare(theAttr, value) == 0)
6795 watermark = msl_info->image[j];
6801 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6806 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6815 if ( watermark != (Image*) NULL )
6820 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6821 if (newImage == (Image *) NULL)
6823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6824 msl_info->image[n]=newImage;
6827 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6829 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6832 stereoImage = (Image*)NULL;
6834 if (msl_info->image[n] == (Image *) NULL)
6836 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6839 if (attributes == (const xmlChar **) NULL)
6841 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6843 keyword=(const char *) attributes[i++];
6844 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6845 msl_info->attributes[n],(const char *) attributes[i],&exception));
6851 if (LocaleCompare(keyword,"image") == 0)
6853 for (j=0; j<msl_info->n;j++)
6856 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6858 if (theAttr && LocaleCompare(theAttr, value) == 0)
6860 stereoImage = msl_info->image[j];
6866 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6871 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6880 if ( stereoImage != (Image*) NULL )
6885 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6886 if (newImage == (Image *) NULL)
6888 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6889 msl_info->image[n]=newImage;
6892 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6894 if (LocaleCompare((const char *) tag,"strip") == 0)
6899 if (msl_info->image[n] == (Image *) NULL)
6901 ThrowMSLException(OptionError,"NoImagesDefined",
6902 (const char *) tag);
6905 if (attributes != (const xmlChar **) NULL)
6906 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6908 keyword=(const char *) attributes[i++];
6909 attribute=InterpretImageProperties(msl_info->image_info[n],
6910 msl_info->attributes[n],(const char *) attributes[i],
6912 CloneString(&value,attribute);
6913 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6915 (void) StripImage(msl_info->image[n],msl_info->exception);
6918 if (LocaleCompare((const char *) tag,"swap") == 0)
6929 if (msl_info->image[n] == (Image *) NULL)
6931 ThrowMSLException(OptionError,"NoImagesDefined",
6932 (const char *) tag);
6937 if (attributes != (const xmlChar **) NULL)
6938 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6940 keyword=(const char *) attributes[i++];
6941 attribute=InterpretImageProperties(msl_info->image_info[n],
6942 msl_info->attributes[n],(const char *) attributes[i],
6944 CloneString(&value,attribute);
6950 if (LocaleCompare(keyword,"indexes") == 0)
6952 flags=ParseGeometry(value,&geometry_info);
6953 index=(ssize_t) geometry_info.rho;
6954 if ((flags & SigmaValue) == 0)
6955 swap_index=(ssize_t) geometry_info.sigma;
6958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6973 p=GetImageFromList(msl_info->image[n],index);
6974 q=GetImageFromList(msl_info->image[n],swap_index);
6975 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6977 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6980 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6981 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6982 msl_info->exception));
6983 ReplaceImageInList(&q,swap);
6984 msl_info->image[n]=GetFirstImageInList(q);
6987 if (LocaleCompare((const char *) tag,"swirl") == 0)
6995 if (msl_info->image[n] == (Image *) NULL)
6997 ThrowMSLException(OptionError,"NoImagesDefined",
6998 (const char *) tag);
7001 if (attributes != (const xmlChar **) NULL)
7002 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7004 keyword=(const char *) attributes[i++];
7005 attribute=InterpretImageProperties(msl_info->image_info[n],
7006 msl_info->attributes[n],(const char *) attributes[i],
7008 CloneString(&value,attribute);
7014 if (LocaleCompare(keyword,"degrees") == 0)
7016 geometry_info.rho=StringToDouble(value,
7020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7027 if (LocaleCompare(keyword,"geometry") == 0)
7029 flags=ParseGeometry(value,&geometry_info);
7030 if ((flags & SigmaValue) == 0)
7031 geometry_info.sigma=1.0;
7034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7046 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7047 msl_info->image[n]->interpolate,msl_info->exception);
7048 if (swirl_image == (Image *) NULL)
7050 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7051 msl_info->image[n]=swirl_image;
7054 if (LocaleCompare((const char *) tag,"sync") == 0)
7059 if (msl_info->image[n] == (Image *) NULL)
7061 ThrowMSLException(OptionError,"NoImagesDefined",
7062 (const char *) tag);
7065 if (attributes != (const xmlChar **) NULL)
7066 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7068 keyword=(const char *) attributes[i++];
7069 attribute=InterpretImageProperties(msl_info->image_info[n],
7070 msl_info->attributes[n],(const char *) attributes[i],
7072 CloneString(&value,attribute);
7077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7083 (void) SyncImage(msl_info->image[n],&exception);
7086 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7091 if (LocaleCompare((const char *) tag,"map") == 0)
7099 if (msl_info->image[n] == (Image *) NULL)
7101 ThrowMSLException(OptionError,"NoImagesDefined",
7102 (const char *) tag);
7105 texture_image=NewImageList();
7106 if (attributes != (const xmlChar **) NULL)
7107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7109 keyword=(const char *) attributes[i++];
7110 attribute=InterpretImageProperties(msl_info->image_info[n],
7111 msl_info->attributes[n],(const char *) attributes[i],
7113 CloneString(&value,attribute);
7119 if (LocaleCompare(keyword,"image") == 0)
7120 for (j=0; j < msl_info->n; j++)
7125 attribute=GetImageProperty(msl_info->attributes[j],"id",
7127 if ((attribute != (const char *) NULL) &&
7128 (LocaleCompare(attribute,value) == 0))
7130 texture_image=CloneImage(msl_info->image[j],0,0,
7131 MagickFalse,&exception);
7139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7145 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7146 texture_image=DestroyImage(texture_image);
7149 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7151 /* init the values */
7152 double threshold = 0;
7154 if (msl_info->image[n] == (Image *) NULL)
7156 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7159 if (attributes == (const xmlChar **) NULL)
7161 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7163 keyword=(const char *) attributes[i++];
7164 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7165 msl_info->attributes[n],(const char *) attributes[i],&exception));
7171 if (LocaleCompare(keyword,"threshold") == 0)
7173 threshold = StringToDouble(value,(char **) NULL);
7176 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7181 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7191 BilevelImage(msl_info->image[n],threshold,&exception);
7195 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7197 if (msl_info->image[n] == (Image *) NULL)
7199 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7202 if (attributes == (const xmlChar **) NULL)
7204 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7206 keyword=(const char *) attributes[i++];
7207 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7208 msl_info->attributes[n],(const char *) attributes[i],&exception));
7214 if (LocaleCompare(keyword,"color") == 0)
7219 (void) QueryColorCompliance(value,AllCompliance,&target,
7221 (void) TransparentPaintImage(msl_info->image[n],&target,
7222 TransparentAlpha,MagickFalse,msl_info->exception);
7225 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7237 else if (LocaleCompare((const char *) tag, "trim") == 0)
7239 if (msl_info->image[n] == (Image *) NULL)
7241 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7245 /* no attributes here */
7247 /* process the image */
7254 /* all zeros on a crop == trim edges! */
7255 rectInfo.height = rectInfo.width = 0;
7256 rectInfo.x = rectInfo.y = 0;
7258 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7259 if (newImage == (Image *) NULL)
7261 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7262 msl_info->image[n]=newImage;
7266 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7271 if (LocaleCompare((const char *) tag,"write") == 0)
7273 if (msl_info->image[n] == (Image *) NULL)
7275 ThrowMSLException(OptionError,"NoImagesDefined",
7276 (const char *) tag);
7279 if (attributes == (const xmlChar **) NULL)
7281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7283 keyword=(const char *) attributes[i++];
7284 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7285 msl_info->attributes[n],(const char *) attributes[i],&exception));
7291 if (LocaleCompare(keyword,"filename") == 0)
7293 (void) CopyMagickString(msl_info->image[n]->filename,value,
7297 (void) SetMSLAttributes(msl_info,keyword,value);
7301 (void) SetMSLAttributes(msl_info,keyword,value);
7309 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7310 msl_info->exception);
7314 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7318 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7322 if ( value != NULL )
7323 value=DestroyString(value);
7324 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7327 static void MSLEndElement(void *context,const xmlChar *tag)
7336 Called when the end of an element has been detected.
7338 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7340 msl_info=(MSLInfo *) context;
7347 if (LocaleCompare((const char *) tag,"comment") == 0 )
7349 (void) DeleteImageProperty(msl_info->image[n],"comment");
7350 if (msl_info->content == (char *) NULL)
7352 StripString(msl_info->content);
7353 (void) SetImageProperty(msl_info->image[n],"comment",
7354 msl_info->content,msl_info->exception);
7362 if (LocaleCompare((const char *) tag, "group") == 0 )
7364 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7366 ssize_t i = (ssize_t)
7367 (msl_info->group_info[msl_info->number_groups-1].numImages);
7370 if (msl_info->image[msl_info->n] != (Image *) NULL)
7371 msl_info->image[msl_info->n]=DestroyImage(
7372 msl_info->image[msl_info->n]);
7373 msl_info->attributes[msl_info->n]=DestroyImage(
7374 msl_info->attributes[msl_info->n]);
7375 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7376 msl_info->image_info[msl_info->n]);
7380 msl_info->number_groups--;
7387 if (LocaleCompare((const char *) tag, "image") == 0)
7388 MSLPopImage(msl_info);
7394 if (LocaleCompare((const char *) tag,"label") == 0 )
7396 (void) DeleteImageProperty(msl_info->image[n],"label");
7397 if (msl_info->content == (char *) NULL)
7399 StripString(msl_info->content);
7400 (void) SetImageProperty(msl_info->image[n],"label",
7401 msl_info->content,msl_info->exception);
7409 if (LocaleCompare((const char *) tag, "msl") == 0 )
7412 This our base element.
7413 at the moment we don't do anything special
7414 but someday we might!
7422 if (msl_info->content != (char *) NULL)
7423 msl_info->content=DestroyString(msl_info->content);
7426 static void MSLCharacters(void *context,const xmlChar *c,int length)
7438 Receiving some characters from the parser.
7440 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7441 " SAX.characters(%s,%d)",c,length);
7442 msl_info=(MSLInfo *) context;
7443 if (msl_info->content != (char *) NULL)
7444 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7445 strlen(msl_info->content)+length+MaxTextExtent,
7446 sizeof(*msl_info->content));
7449 msl_info->content=(char *) NULL;
7450 if (~length >= (MaxTextExtent-1))
7451 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7452 sizeof(*msl_info->content));
7453 if (msl_info->content != (char *) NULL)
7454 *msl_info->content='\0';
7456 if (msl_info->content == (char *) NULL)
7458 p=msl_info->content+strlen(msl_info->content);
7459 for (i=0; i < length; i++)
7464 static void MSLReference(void *context,const xmlChar *name)
7473 Called when an entity reference is detected.
7475 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7476 " SAX.reference(%s)",name);
7477 msl_info=(MSLInfo *) context;
7478 parser=msl_info->parser;
7480 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7482 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7485 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7491 Receiving some ignorable whitespaces from the parser.
7493 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7494 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7495 msl_info=(MSLInfo *) context;
7499 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7500 const xmlChar *data)
7506 A processing instruction has been parsed.
7508 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7509 " SAX.processingInstruction(%s, %s)",
7511 msl_info=(MSLInfo *) context;
7515 static void MSLComment(void *context,const xmlChar *value)
7521 A comment has been parsed.
7523 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7524 " SAX.comment(%s)",value);
7525 msl_info=(MSLInfo *) context;
7529 static void MSLWarning(void *context,const char *format,...)
7533 reason[MaxTextExtent];
7542 Display and format a warning messages, gives file, line, position and
7545 va_start(operands,format);
7546 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7547 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7548 msl_info=(MSLInfo *) context;
7550 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7551 (void) vsprintf(reason,format,operands);
7553 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7555 message=GetExceptionMessage(errno);
7556 ThrowMSLException(CoderError,reason,message);
7557 message=DestroyString(message);
7561 static void MSLError(void *context,const char *format,...)
7564 reason[MaxTextExtent];
7573 Display and format a error formats, gives file, line, position and
7576 va_start(operands,format);
7577 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7578 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7579 msl_info=(MSLInfo *) context;
7581 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7582 (void) vsprintf(reason,format,operands);
7584 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7586 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7590 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7602 Called when a pcdata block has been parsed.
7604 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7605 " SAX.pcdata(%s, %d)",value,length);
7606 msl_info=(MSLInfo *) context;
7608 parser=msl_info->parser;
7609 child=xmlGetLastChild(parser->node);
7610 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7612 xmlTextConcat(child,value,length);
7615 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7618 static void MSLExternalSubset(void *context,const xmlChar *name,
7619 const xmlChar *external_id,const xmlChar *system_id)
7634 Does this document has an external subset?
7636 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7637 " SAX.externalSubset(%s %s %s)",name,
7638 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7639 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7640 msl_info=(MSLInfo *) context;
7642 parser=msl_info->parser;
7643 if (((external_id == NULL) && (system_id == NULL)) ||
7644 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7645 (msl_info->document == 0)))
7647 input=MSLResolveEntity(context,external_id,system_id);
7650 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7651 parser_context=(*parser);
7652 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7653 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7655 parser->errNo=XML_ERR_NO_MEMORY;
7656 parser->input=parser_context.input;
7657 parser->inputNr=parser_context.inputNr;
7658 parser->inputMax=parser_context.inputMax;
7659 parser->inputTab=parser_context.inputTab;
7665 xmlPushInput(parser,input);
7666 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7667 if (input->filename == (char *) NULL)
7668 input->filename=(char *) xmlStrdup(system_id);
7671 input->base=parser->input->cur;
7672 input->cur=parser->input->cur;
7674 xmlParseExternalSubset(parser,external_id,system_id);
7675 while (parser->inputNr > 1)
7676 (void) xmlPopInput(parser);
7677 xmlFreeInputStream(parser->input);
7678 xmlFree(parser->inputTab);
7679 parser->input=parser_context.input;
7680 parser->inputNr=parser_context.inputNr;
7681 parser->inputMax=parser_context.inputMax;
7682 parser->inputTab=parser_context.inputTab;
7685 #if defined(__cplusplus) || defined(c_plusplus)
7689 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7690 Image **image,ExceptionInfo *exception)
7693 message[MaxTextExtent];
7716 assert(image_info != (const ImageInfo *) NULL);
7717 assert(image_info->signature == MagickSignature);
7718 if (image_info->debug != MagickFalse)
7719 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7720 image_info->filename);
7721 assert(image != (Image **) NULL);
7722 msl_image=AcquireImage(image_info,exception);
7723 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7724 if (status == MagickFalse)
7726 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7727 msl_image->filename);
7728 msl_image=DestroyImageList(msl_image);
7729 return(MagickFalse);
7731 msl_image->columns=1;
7736 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7737 msl_info.exception=exception;
7738 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7739 sizeof(*msl_info.image_info));
7740 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7741 sizeof(*msl_info.draw_info));
7742 /* top of the stack is the MSL file itself */
7743 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7744 msl_info.attributes=(Image **) AcquireMagickMemory(
7745 sizeof(*msl_info.attributes));
7746 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7747 sizeof(*msl_info.group_info));
7748 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7749 (msl_info.image == (Image **) NULL) ||
7750 (msl_info.attributes == (Image **) NULL) ||
7751 (msl_info.group_info == (MSLGroupInfo *) NULL))
7752 ThrowFatalException(ResourceLimitFatalError,
7753 "UnableToInterpretMSLImage");
7754 *msl_info.image_info=CloneImageInfo(image_info);
7755 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7756 *msl_info.attributes=AcquireImage(image_info,exception);
7757 msl_info.group_info[0].numImages=0;
7758 /* the first slot is used to point to the MSL file image */
7759 *msl_info.image=msl_image;
7760 if (*image != (Image *) NULL)
7761 MSLPushImage(&msl_info,*image);
7762 (void) xmlSubstituteEntitiesDefault(1);
7763 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7764 sax_modules.internalSubset=MSLInternalSubset;
7765 sax_modules.isStandalone=MSLIsStandalone;
7766 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7767 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7768 sax_modules.resolveEntity=MSLResolveEntity;
7769 sax_modules.getEntity=MSLGetEntity;
7770 sax_modules.entityDecl=MSLEntityDeclaration;
7771 sax_modules.notationDecl=MSLNotationDeclaration;
7772 sax_modules.attributeDecl=MSLAttributeDeclaration;
7773 sax_modules.elementDecl=MSLElementDeclaration;
7774 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7775 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7776 sax_modules.startDocument=MSLStartDocument;
7777 sax_modules.endDocument=MSLEndDocument;
7778 sax_modules.startElement=MSLStartElement;
7779 sax_modules.endElement=MSLEndElement;
7780 sax_modules.reference=MSLReference;
7781 sax_modules.characters=MSLCharacters;
7782 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7783 sax_modules.processingInstruction=MSLProcessingInstructions;
7784 sax_modules.comment=MSLComment;
7785 sax_modules.warning=MSLWarning;
7786 sax_modules.error=MSLError;
7787 sax_modules.fatalError=MSLError;
7788 sax_modules.getParameterEntity=MSLGetParameterEntity;
7789 sax_modules.cdataBlock=MSLCDataBlock;
7790 sax_modules.externalSubset=MSLExternalSubset;
7791 sax_handler=(&sax_modules);
7792 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7793 msl_image->filename);
7794 while (ReadBlobString(msl_image,message) != (char *) NULL)
7796 n=(ssize_t) strlen(message);
7799 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7802 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7803 if (msl_info.exception->severity >= ErrorException)
7806 if (msl_info.exception->severity == UndefinedException)
7807 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7808 xmlFreeParserCtxt(msl_info.parser);
7809 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7810 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7811 msl_info.group_info);
7812 if (*image == (Image *) NULL)
7813 *image=(*msl_info.image);
7814 if (msl_info.exception->severity != UndefinedException)
7815 return(MagickFalse);
7819 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7827 assert(image_info != (const ImageInfo *) NULL);
7828 assert(image_info->signature == MagickSignature);
7829 if (image_info->debug != MagickFalse)
7830 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7831 image_info->filename);
7832 assert(exception != (ExceptionInfo *) NULL);
7833 assert(exception->signature == MagickSignature);
7834 image=(Image *) NULL;
7835 (void) ProcessMSLScript(image_info,&image,exception);
7836 return(GetFirstImageInList(image));
7841 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7845 % R e g i s t e r M S L I m a g e %
7849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7851 % RegisterMSLImage() adds attributes for the MSL image format to
7852 % the list of supported formats. The attributes include the image format
7853 % tag, a method to read and/or write the format, whether the format
7854 % supports the saving of more than one frame to the same file or blob,
7855 % whether the format supports native in-memory I/O, and a brief
7856 % description of the format.
7858 % The format of the RegisterMSLImage method is:
7860 % size_t RegisterMSLImage(void)
7863 ModuleExport size_t RegisterMSLImage(void)
7868 #if defined(MAGICKCORE_XML_DELEGATE)
7871 entry=SetMagickInfo("MSL");
7872 #if defined(MAGICKCORE_XML_DELEGATE)
7873 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7874 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7876 entry->description=ConstantString("Magick Scripting Language");
7877 entry->module=ConstantString("MSL");
7878 (void) RegisterMagickInfo(entry);
7879 return(MagickImageCoderSignature);
7882 #if defined(MAGICKCORE_XML_DELEGATE)
7884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7888 % S e t M S L A t t r i b u t e s %
7892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7894 % SetMSLAttributes() ...
7896 % The format of the SetMSLAttributes method is:
7898 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7899 % const char *keyword,const char *value)
7901 % A description of each parameter follows:
7903 % o msl_info: the MSL info.
7905 % o keyword: the keyword.
7907 % o value: the value.
7910 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7937 assert(msl_info != (MSLInfo *) NULL);
7938 if (keyword == (const char *) NULL)
7940 if (value == (const char *) NULL)
7942 exception=msl_info->exception;
7944 attributes=msl_info->attributes[n];
7945 image_info=msl_info->image_info[n];
7946 draw_info=msl_info->draw_info[n];
7947 image=msl_info->image[n];
7953 if (LocaleCompare(keyword,"adjoin") == 0)
7958 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7960 ThrowMSLException(OptionError,"UnrecognizedType",value);
7961 image_info->adjoin=(MagickBooleanType) adjoin;
7964 if (LocaleCompare(keyword,"alpha") == 0)
7969 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
7971 ThrowMSLException(OptionError,"UnrecognizedType",value);
7972 if (image != (Image *) NULL)
7973 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
7977 if (LocaleCompare(keyword,"antialias") == 0)
7982 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7984 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7985 image_info->antialias=(MagickBooleanType) antialias;
7988 if (LocaleCompare(keyword,"area-limit") == 0)
7993 limit=MagickResourceInfinity;
7994 if (LocaleCompare(value,"unlimited") != 0)
7995 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7996 (void) SetMagickResourceLimit(AreaResource,limit);
7999 if (LocaleCompare(keyword,"attenuate") == 0)
8001 (void) SetImageOption(image_info,keyword,value);
8004 if (LocaleCompare(keyword,"authenticate") == 0)
8006 (void) CloneString(&image_info->density,value);
8009 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8015 if (LocaleCompare(keyword,"background") == 0)
8017 (void) QueryColorCompliance(value,AllCompliance,
8018 &image_info->background_color,exception);
8021 if (LocaleCompare(keyword,"blue-primary") == 0)
8023 if (image == (Image *) NULL)
8025 flags=ParseGeometry(value,&geometry_info);
8026 image->chromaticity.blue_primary.x=geometry_info.rho;
8027 image->chromaticity.blue_primary.y=geometry_info.sigma;
8028 if ((flags & SigmaValue) == 0)
8029 image->chromaticity.blue_primary.y=
8030 image->chromaticity.blue_primary.x;
8033 if (LocaleCompare(keyword,"bordercolor") == 0)
8035 (void) QueryColorCompliance(value,AllCompliance,
8036 &image_info->border_color,exception);
8039 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8045 if (LocaleCompare(keyword,"density") == 0)
8047 (void) CloneString(&image_info->density,value);
8048 (void) CloneString(&draw_info->density,value);
8051 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8057 if (LocaleCompare(keyword,"fill") == 0)
8059 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8061 (void) SetImageOption(image_info,keyword,value);
8064 if (LocaleCompare(keyword,"filename") == 0)
8066 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8069 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8075 if (LocaleCompare(keyword,"gravity") == 0)
8080 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8082 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8083 (void) SetImageOption(image_info,keyword,value);
8086 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8092 if (LocaleCompare(keyword,"id") == 0)
8094 (void) SetImageProperty(attributes,keyword,value,exception);
8097 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8103 if (LocaleCompare(keyword,"magick") == 0)
8105 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8108 if (LocaleCompare(keyword,"mattecolor") == 0)
8110 (void) QueryColorCompliance(value,AllCompliance,
8111 &image_info->matte_color,exception);
8114 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8120 if (LocaleCompare(keyword,"pointsize") == 0)
8122 image_info->pointsize=StringToDouble(value,(char **) NULL);
8123 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8126 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8132 if (LocaleCompare(keyword,"quality") == 0)
8134 image_info->quality=StringToLong(value);
8135 if (image == (Image *) NULL)
8137 image->quality=StringToLong(value);
8145 if (LocaleCompare(keyword,"size") == 0)
8147 (void) CloneString(&image_info->size,value);
8150 if (LocaleCompare(keyword,"stroke") == 0)
8152 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8154 (void) SetImageOption(image_info,keyword,value);
8157 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8162 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8175 % U n r e g i s t e r M S L I m a g e %
8179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8181 % UnregisterMSLImage() removes format registrations made by the
8182 % MSL module from the list of supported formats.
8184 % The format of the UnregisterMSLImage method is:
8186 % UnregisterMSLImage(void)
8189 ModuleExport void UnregisterMSLImage(void)
8191 (void) UnregisterMagickInfo("MSL");
8192 #if defined(MAGICKCORE_XML_DELEGATE)
8197 #if defined(MAGICKCORE_XML_DELEGATE)
8199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8203 % W r i t e M S L I m a g e %
8207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8209 % WriteMSLImage() writes an image to a file in MVG image format.
8211 % The format of the WriteMSLImage method is:
8213 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8214 % Image *image,ExceptionInfo *exception)
8216 % A description of each parameter follows.
8218 % o image_info: the image info.
8220 % o image: The image.
8222 % o exception: return any errors or warnings in this structure.
8225 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8226 ExceptionInfo *exception)
8228 assert(image_info != (const ImageInfo *) NULL);
8229 assert(image_info->signature == MagickSignature);
8230 assert(image != (Image *) NULL);
8231 assert(image->signature == MagickSignature);
8232 if (image->debug != MagickFalse)
8233 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8234 (void) ReferenceImage(image);
8235 (void) ProcessMSLScript(image_info,&image,exception);