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);
2539 if (LocaleCompare(keyword,"pointsize") == 0)
2541 draw_info->pointsize=StringToDouble(value,
2545 if (LocaleCompare(keyword,"primitive") == 0)
2547 CloneString(&draw_info->primitive,value);
2550 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2557 if (LocaleCompare(keyword,"rotate") == 0)
2559 angle=StringToDouble(value,(char **) NULL);
2560 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2561 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2562 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2563 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2566 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2573 if (LocaleCompare(keyword,"scale") == 0)
2575 flags=ParseGeometry(value,&geometry_info);
2576 if ((flags & SigmaValue) == 0)
2577 geometry_info.sigma=1.0;
2578 affine.sx=geometry_info.rho;
2579 affine.sy=geometry_info.sigma;
2582 if (LocaleCompare(keyword,"skewX") == 0)
2584 angle=StringToDouble(value,(char **) NULL);
2585 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2588 if (LocaleCompare(keyword,"skewY") == 0)
2590 angle=StringToDouble(value,(char **) NULL);
2591 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2594 if (LocaleCompare(keyword,"stretch") == 0)
2596 option=ParseCommandOption(MagickStretchOptions,
2599 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2601 draw_info->stretch=(StretchType) option;
2604 if (LocaleCompare(keyword, "stroke") == 0)
2606 (void) QueryColorCompliance(value,AllCompliance,
2607 &draw_info->stroke,&exception);
2610 if (LocaleCompare(keyword,"strokewidth") == 0)
2612 draw_info->stroke_width=StringToLong(value);
2615 if (LocaleCompare(keyword,"style") == 0)
2617 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2620 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2622 draw_info->style=(StyleType) option;
2625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2632 if (LocaleCompare(keyword,"text") == 0)
2634 CloneString(&draw_info->text,value);
2637 if (LocaleCompare(keyword,"translate") == 0)
2639 flags=ParseGeometry(value,&geometry_info);
2640 if ((flags & SigmaValue) == 0)
2641 geometry_info.sigma=1.0;
2642 affine.tx=geometry_info.rho;
2643 affine.ty=geometry_info.sigma;
2646 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2653 if (LocaleCompare(keyword, "undercolor") == 0)
2655 (void) QueryColorCompliance(value,AllCompliance,
2656 &draw_info->undercolor,&exception);
2659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2666 if (LocaleCompare(keyword,"weight") == 0)
2668 draw_info->weight=StringToLong(value);
2671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2678 if (LocaleCompare(keyword,"x") == 0)
2680 geometry.x=StringToLong(value);
2683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2690 if (LocaleCompare(keyword,"y") == 0)
2692 geometry.y=StringToLong(value);
2695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2701 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2707 (void) FormatLocaleString(text,MaxTextExtent,
2708 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2709 geometry.height,(double) geometry.x,(double) geometry.y);
2710 CloneString(&draw_info->geometry,text);
2711 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2712 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2713 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2714 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2715 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2717 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2719 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2720 draw_info=DestroyDrawInfo(draw_info);
2723 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2728 if (LocaleCompare((const char *) tag,"edge") == 0)
2736 if (msl_info->image[n] == (Image *) NULL)
2738 ThrowMSLException(OptionError,"NoImagesDefined",
2739 (const char *) tag);
2742 if (attributes != (const xmlChar **) NULL)
2743 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2745 keyword=(const char *) attributes[i++];
2746 attribute=InterpretImageProperties(msl_info->image_info[n],
2747 msl_info->attributes[n],(const char *) attributes[i],
2749 CloneString(&value,attribute);
2755 if (LocaleCompare(keyword,"geometry") == 0)
2757 flags=ParseGeometry(value,&geometry_info);
2758 if ((flags & SigmaValue) == 0)
2759 geometry_info.sigma=1.0;
2762 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2769 if (LocaleCompare(keyword,"radius") == 0)
2771 geometry_info.rho=StringToDouble(value,(char **) NULL);
2774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2786 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2787 msl_info->exception);
2788 if (edge_image == (Image *) NULL)
2790 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2791 msl_info->image[n]=edge_image;
2794 if (LocaleCompare((const char *) tag,"emboss") == 0)
2802 if (msl_info->image[n] == (Image *) NULL)
2804 ThrowMSLException(OptionError,"NoImagesDefined",
2805 (const char *) tag);
2808 if (attributes != (const xmlChar **) NULL)
2809 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2811 keyword=(const char *) attributes[i++];
2812 attribute=InterpretImageProperties(msl_info->image_info[n],
2813 msl_info->attributes[n],(const char *) attributes[i],
2815 CloneString(&value,attribute);
2821 if (LocaleCompare(keyword,"geometry") == 0)
2823 flags=ParseGeometry(value,&geometry_info);
2824 if ((flags & SigmaValue) == 0)
2825 geometry_info.sigma=1.0;
2828 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2835 if (LocaleCompare(keyword,"radius") == 0)
2837 geometry_info.rho=StringToDouble(value,
2841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2848 if (LocaleCompare(keyword,"sigma") == 0)
2850 geometry_info.sigma=StringToLong(value);
2853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2865 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2866 geometry_info.sigma,msl_info->exception);
2867 if (emboss_image == (Image *) NULL)
2869 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2870 msl_info->image[n]=emboss_image;
2873 if (LocaleCompare((const char *) tag,"enhance") == 0)
2881 if (msl_info->image[n] == (Image *) NULL)
2883 ThrowMSLException(OptionError,"NoImagesDefined",
2884 (const char *) tag);
2887 if (attributes != (const xmlChar **) NULL)
2888 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2890 keyword=(const char *) attributes[i++];
2891 attribute=InterpretImageProperties(msl_info->image_info[n],
2892 msl_info->attributes[n],(const char *) attributes[i],
2894 CloneString(&value,attribute);
2895 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2897 enhance_image=EnhanceImage(msl_info->image[n],
2898 msl_info->exception);
2899 if (enhance_image == (Image *) NULL)
2901 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2902 msl_info->image[n]=enhance_image;
2905 if (LocaleCompare((const char *) tag,"equalize") == 0)
2910 if (msl_info->image[n] == (Image *) NULL)
2912 ThrowMSLException(OptionError,"NoImagesDefined",
2913 (const char *) tag);
2916 if (attributes != (const xmlChar **) NULL)
2917 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2919 keyword=(const char *) attributes[i++];
2920 attribute=InterpretImageProperties(msl_info->image_info[n],
2921 msl_info->attributes[n],(const char *) attributes[i],
2923 CloneString(&value,attribute);
2928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2934 (void) EqualizeImage(msl_info->image[n],
2935 msl_info->exception);
2938 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2943 if (LocaleCompare((const char *) tag, "flatten") == 0)
2945 if (msl_info->image[n] == (Image *) NULL)
2947 ThrowMSLException(OptionError,"NoImagesDefined",
2948 (const char *) tag);
2952 /* no attributes here */
2954 /* process the image */
2959 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2960 msl_info->exception);
2961 if (newImage == (Image *) NULL)
2963 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2964 msl_info->image[n]=newImage;
2968 if (LocaleCompare((const char *) tag,"flip") == 0)
2976 if (msl_info->image[n] == (Image *) NULL)
2978 ThrowMSLException(OptionError,"NoImagesDefined",
2979 (const char *) tag);
2982 if (attributes != (const xmlChar **) NULL)
2983 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2985 keyword=(const char *) attributes[i++];
2986 attribute=InterpretImageProperties(msl_info->image_info[n],
2987 msl_info->attributes[n],(const char *) attributes[i],
2989 CloneString(&value,attribute);
2990 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2992 flip_image=FlipImage(msl_info->image[n],
2993 msl_info->exception);
2994 if (flip_image == (Image *) NULL)
2996 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2997 msl_info->image[n]=flip_image;
3000 if (LocaleCompare((const char *) tag,"flop") == 0)
3008 if (msl_info->image[n] == (Image *) NULL)
3010 ThrowMSLException(OptionError,"NoImagesDefined",
3011 (const char *) tag);
3014 if (attributes != (const xmlChar **) NULL)
3015 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3017 keyword=(const char *) attributes[i++];
3018 attribute=InterpretImageProperties(msl_info->image_info[n],
3019 msl_info->attributes[n],(const char *) attributes[i],
3021 CloneString(&value,attribute);
3022 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3024 flop_image=FlopImage(msl_info->image[n],
3025 msl_info->exception);
3026 if (flop_image == (Image *) NULL)
3028 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3029 msl_info->image[n]=flop_image;
3032 if (LocaleCompare((const char *) tag,"frame") == 0)
3043 if (msl_info->image[n] == (Image *) NULL)
3045 ThrowMSLException(OptionError,"NoImagesDefined",
3046 (const char *) tag);
3049 SetGeometry(msl_info->image[n],&geometry);
3050 if (attributes != (const xmlChar **) NULL)
3051 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3053 keyword=(const char *) attributes[i++];
3054 attribute=InterpretImageProperties(msl_info->image_info[n],
3055 msl_info->attributes[n],(const char *) attributes[i],
3057 CloneString(&value,attribute);
3063 if (LocaleCompare(keyword,"compose") == 0)
3065 option=ParseCommandOption(MagickComposeOptions,
3068 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3070 msl_info->image[n]->compose=(CompositeOperator) option;
3073 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3080 if (LocaleCompare(keyword, "fill") == 0)
3082 (void) QueryColorCompliance(value,AllCompliance,
3083 &msl_info->image[n]->matte_color,&exception);
3086 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3093 if (LocaleCompare(keyword,"geometry") == 0)
3095 flags=ParsePageGeometry(msl_info->image[n],value,
3096 &geometry,&exception);
3097 if ((flags & HeightValue) == 0)
3098 geometry.height=geometry.width;
3099 frame_info.width=geometry.width;
3100 frame_info.height=geometry.height;
3101 frame_info.outer_bevel=geometry.x;
3102 frame_info.inner_bevel=geometry.y;
3105 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3112 if (LocaleCompare(keyword,"height") == 0)
3114 frame_info.height=StringToLong(value);
3117 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3124 if (LocaleCompare(keyword,"inner") == 0)
3126 frame_info.inner_bevel=StringToLong(value);
3129 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3136 if (LocaleCompare(keyword,"outer") == 0)
3138 frame_info.outer_bevel=StringToLong(value);
3141 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3148 if (LocaleCompare(keyword,"width") == 0)
3150 frame_info.width=StringToLong(value);
3153 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3159 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3165 frame_info.x=(ssize_t) frame_info.width;
3166 frame_info.y=(ssize_t) frame_info.height;
3167 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3168 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3169 frame_image=FrameImage(msl_info->image[n],&frame_info,
3170 msl_info->image[n]->compose,msl_info->exception);
3171 if (frame_image == (Image *) NULL)
3173 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3174 msl_info->image[n]=frame_image;
3177 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3182 if (LocaleCompare((const char *) tag,"gamma") == 0)
3185 gamma[MaxTextExtent];
3193 if (msl_info->image[n] == (Image *) NULL)
3195 ThrowMSLException(OptionError,"NoImagesDefined",
3196 (const char *) tag);
3199 channel=UndefinedChannel;
3204 if (attributes != (const xmlChar **) NULL)
3205 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3207 keyword=(const char *) attributes[i++];
3208 attribute=InterpretImageProperties(msl_info->image_info[n],
3209 msl_info->attributes[n],(const char *) attributes[i],
3211 CloneString(&value,attribute);
3217 if (LocaleCompare(keyword,"blue") == 0)
3219 pixel.blue=StringToDouble(value,(char **) NULL);
3222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3229 if (LocaleCompare(keyword,"channel") == 0)
3231 option=ParseChannelOption(value);
3233 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3235 channel=(ChannelType) option;
3238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3245 if (LocaleCompare(keyword,"gamma") == 0)
3247 (void) CopyMagickString(gamma,value,MaxTextExtent);
3250 if (LocaleCompare(keyword,"green") == 0)
3252 pixel.green=StringToDouble(value,(char **) NULL);
3255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3262 if (LocaleCompare(keyword,"red") == 0)
3264 pixel.red=StringToDouble(value,(char **) NULL);
3267 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3273 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3280 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3281 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3282 (void) GammaImage(msl_info->image[n],atof(gamma),
3283 msl_info->exception);
3286 else if (LocaleCompare((const char *) tag,"get") == 0)
3288 if (msl_info->image[n] == (Image *) NULL)
3290 ThrowMSLException(OptionError,"NoImagesDefined",
3291 (const char *) tag);
3294 if (attributes == (const xmlChar **) NULL)
3296 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3298 keyword=(const char *) attributes[i++];
3299 CloneString(&value,(const char *) attributes[i]);
3300 (void) CopyMagickString(key,value,MaxTextExtent);
3306 if (LocaleCompare(keyword,"height") == 0)
3308 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3309 (double) msl_info->image[n]->rows);
3310 (void) SetImageProperty(msl_info->attributes[n],key,value,
3314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3319 if (LocaleCompare(keyword,"width") == 0)
3321 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3322 (double) msl_info->image[n]->columns);
3323 (void) SetImageProperty(msl_info->attributes[n],key,value,
3327 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3331 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3338 else if (LocaleCompare((const char *) tag, "group") == 0)
3340 msl_info->number_groups++;
3341 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3342 msl_info->group_info,msl_info->number_groups+1UL,
3343 sizeof(*msl_info->group_info));
3346 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3351 if (LocaleCompare((const char *) tag,"image") == 0)
3353 MSLPushImage(msl_info,(Image *) NULL);
3354 if (attributes == (const xmlChar **) NULL)
3356 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3358 keyword=(const char *) attributes[i++];
3359 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3360 msl_info->attributes[n],(const char *) attributes[i],&exception));
3366 if (LocaleCompare(keyword,"color") == 0)
3371 (void) CopyMagickString(msl_info->image_info[n]->filename,
3372 "xc:",MaxTextExtent);
3373 (void) ConcatenateMagickString(msl_info->image_info[n]->
3374 filename,value,MaxTextExtent);
3375 next_image=ReadImage(msl_info->image_info[n],&exception);
3376 CatchException(&exception);
3377 if (next_image == (Image *) NULL)
3379 if (msl_info->image[n] == (Image *) NULL)
3380 msl_info->image[n]=next_image;
3387 Link image into image list.
3389 p=msl_info->image[n];
3390 while (p->next != (Image *) NULL)
3391 p=GetNextImageInList(p);
3392 next_image->previous=p;
3397 (void) SetMSLAttributes(msl_info,keyword,value);
3402 (void) SetMSLAttributes(msl_info,keyword,value);
3409 if (LocaleCompare((const char *) tag,"implode") == 0)
3417 if (msl_info->image[n] == (Image *) NULL)
3419 ThrowMSLException(OptionError,"NoImagesDefined",
3420 (const char *) tag);
3423 if (attributes != (const xmlChar **) NULL)
3424 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3426 keyword=(const char *) attributes[i++];
3427 attribute=InterpretImageProperties(msl_info->image_info[n],
3428 msl_info->attributes[n],(const char *) attributes[i],
3430 CloneString(&value,attribute);
3436 if (LocaleCompare(keyword,"amount") == 0)
3438 geometry_info.rho=StringToDouble(value,
3442 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3449 if (LocaleCompare(keyword,"geometry") == 0)
3451 flags=ParseGeometry(value,&geometry_info);
3452 if ((flags & SigmaValue) == 0)
3453 geometry_info.sigma=1.0;
3456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3468 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3469 msl_info->image[n]->interpolate,msl_info->exception);
3470 if (implode_image == (Image *) NULL)
3472 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3473 msl_info->image[n]=implode_image;
3476 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3481 if (LocaleCompare((const char *) tag,"label") == 0)
3483 if (LocaleCompare((const char *) tag, "level") == 0)
3486 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3488 if (msl_info->image[n] == (Image *) NULL)
3490 ThrowMSLException(OptionError,"NoImagesDefined",
3491 (const char *) tag);
3494 if (attributes == (const xmlChar **) NULL)
3496 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3498 keyword=(const char *) attributes[i++];
3499 CloneString(&value,(const char *) attributes[i]);
3500 (void) CopyMagickString(key,value,MaxTextExtent);
3506 if (LocaleCompare(keyword,"black") == 0)
3508 levelBlack = StringToDouble(value,(char **) NULL);
3511 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3517 if (LocaleCompare(keyword,"gamma") == 0)
3519 levelGamma = StringToDouble(value,(char **) NULL);
3522 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3528 if (LocaleCompare(keyword,"white") == 0)
3530 levelWhite = StringToDouble(value,(char **) NULL);
3533 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3538 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3545 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3546 msl_info->exception);
3553 if (LocaleCompare((const char *) tag,"magnify") == 0)
3561 if (msl_info->image[n] == (Image *) NULL)
3563 ThrowMSLException(OptionError,"NoImagesDefined",
3564 (const char *) tag);
3567 if (attributes != (const xmlChar **) NULL)
3568 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3570 keyword=(const char *) attributes[i++];
3571 attribute=InterpretImageProperties(msl_info->image_info[n],
3572 msl_info->attributes[n],(const char *) attributes[i],
3574 CloneString(&value,attribute);
3575 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3577 magnify_image=MagnifyImage(msl_info->image[n],
3578 msl_info->exception);
3579 if (magnify_image == (Image *) NULL)
3581 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3582 msl_info->image[n]=magnify_image;
3585 if (LocaleCompare((const char *) tag,"map") == 0)
3599 if (msl_info->image[n] == (Image *) NULL)
3601 ThrowMSLException(OptionError,"NoImagesDefined",
3602 (const char *) tag);
3605 affinity_image=NewImageList();
3607 if (attributes != (const xmlChar **) NULL)
3608 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3610 keyword=(const char *) attributes[i++];
3611 attribute=InterpretImageProperties(msl_info->image_info[n],
3612 msl_info->attributes[n],(const char *) attributes[i],
3614 CloneString(&value,attribute);
3620 if (LocaleCompare(keyword,"dither") == 0)
3622 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3625 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3627 dither=(MagickBooleanType) option;
3630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3637 if (LocaleCompare(keyword,"image") == 0)
3638 for (j=0; j < msl_info->n; j++)
3643 attribute=GetImageProperty(msl_info->attributes[j],"id",
3645 if ((attribute != (const char *) NULL) &&
3646 (LocaleCompare(attribute,value) == 0))
3648 affinity_image=CloneImage(msl_info->image[j],0,0,
3649 MagickFalse,&exception);
3657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3663 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3664 quantize_info->dither_method=dither != MagickFalse ?
3665 RiemersmaDitherMethod : NoDitherMethod;
3666 (void) RemapImages(quantize_info,msl_info->image[n],
3667 affinity_image,&exception);
3668 quantize_info=DestroyQuantizeInfo(quantize_info);
3669 affinity_image=DestroyImage(affinity_image);
3672 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3684 Matte floodfill image.
3687 if (msl_info->image[n] == (Image *) NULL)
3689 ThrowMSLException(OptionError,"NoImagesDefined",
3690 (const char *) tag);
3693 SetGeometry(msl_info->image[n],&geometry);
3694 paint_method=FloodfillMethod;
3695 if (attributes != (const xmlChar **) NULL)
3696 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3698 keyword=(const char *) attributes[i++];
3699 attribute=InterpretImageProperties(msl_info->image_info[n],
3700 msl_info->attributes[n],(const char *) attributes[i],
3702 CloneString(&value,attribute);
3708 if (LocaleCompare(keyword,"bordercolor") == 0)
3710 (void) QueryColorCompliance(value,AllCompliance,
3711 &target,&exception);
3712 paint_method=FillToBorderMethod;
3715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3722 if (LocaleCompare(keyword,"fuzz") == 0)
3724 msl_info->image[n]->fuzz=StringToDouble(value,
3728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3735 if (LocaleCompare(keyword,"geometry") == 0)
3737 flags=ParsePageGeometry(msl_info->image[n],value,
3738 &geometry,&exception);
3739 if ((flags & HeightValue) == 0)
3740 geometry.height=geometry.width;
3741 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3742 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3753 if (LocaleCompare(keyword,"opacity") == 0)
3755 opacity=StringToDouble(value,(char **) NULL);
3758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3765 if (LocaleCompare(keyword,"x") == 0)
3767 geometry.x=StringToLong(value);
3768 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3769 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3780 if (LocaleCompare(keyword,"y") == 0)
3782 geometry.y=StringToLong(value);
3783 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3784 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3800 draw_info=CloneDrawInfo(msl_info->image_info[n],
3801 msl_info->draw_info[n]);
3802 draw_info->fill.alpha=ClampToQuantum(opacity);
3803 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3804 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3805 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3806 MagickFalse : MagickTrue,msl_info->exception);
3807 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3808 draw_info=DestroyDrawInfo(draw_info);
3811 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3817 Median-filter image.
3819 if (msl_info->image[n] == (Image *) NULL)
3821 ThrowMSLException(OptionError,"NoImagesDefined",
3822 (const char *) tag);
3825 if (attributes != (const xmlChar **) NULL)
3826 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3828 keyword=(const char *) attributes[i++];
3829 attribute=InterpretImageProperties(msl_info->image_info[n],
3830 msl_info->attributes[n],(const char *) attributes[i],
3832 CloneString(&value,attribute);
3838 if (LocaleCompare(keyword,"geometry") == 0)
3840 flags=ParseGeometry(value,&geometry_info);
3841 if ((flags & SigmaValue) == 0)
3842 geometry_info.sigma=1.0;
3845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3852 if (LocaleCompare(keyword,"radius") == 0)
3854 geometry_info.rho=StringToDouble(value,
3858 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3870 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3871 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3872 msl_info->exception);
3873 if (median_image == (Image *) NULL)
3875 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3876 msl_info->image[n]=median_image;
3879 if (LocaleCompare((const char *) tag,"minify") == 0)
3887 if (msl_info->image[n] == (Image *) NULL)
3889 ThrowMSLException(OptionError,"NoImagesDefined",
3890 (const char *) tag);
3893 if (attributes != (const xmlChar **) NULL)
3894 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3896 keyword=(const char *) attributes[i++];
3897 attribute=InterpretImageProperties(msl_info->image_info[n],
3898 msl_info->attributes[n],(const char *) attributes[i],
3900 CloneString(&value,attribute);
3901 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3903 minify_image=MinifyImage(msl_info->image[n],
3904 msl_info->exception);
3905 if (minify_image == (Image *) NULL)
3907 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3908 msl_info->image[n]=minify_image;
3911 if (LocaleCompare((const char *) tag,"msl") == 0 )
3913 if (LocaleCompare((const char *) tag,"modulate") == 0)
3916 modulate[MaxTextExtent];
3921 if (msl_info->image[n] == (Image *) NULL)
3923 ThrowMSLException(OptionError,"NoImagesDefined",
3924 (const char *) tag);
3927 geometry_info.rho=100.0;
3928 geometry_info.sigma=100.0;
3929 geometry_info.xi=100.0;
3930 if (attributes != (const xmlChar **) NULL)
3931 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3933 keyword=(const char *) attributes[i++];
3934 attribute=InterpretImageProperties(msl_info->image_info[n],
3935 msl_info->attributes[n],(const char *) attributes[i],
3937 CloneString(&value,attribute);
3943 if (LocaleCompare(keyword,"blackness") == 0)
3945 geometry_info.rho=StringToDouble(value,
3949 if (LocaleCompare(keyword,"brightness") == 0)
3951 geometry_info.rho=StringToDouble(value,
3955 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3962 if (LocaleCompare(keyword,"factor") == 0)
3964 flags=ParseGeometry(value,&geometry_info);
3967 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3974 if (LocaleCompare(keyword,"hue") == 0)
3976 geometry_info.xi=StringToDouble(value,
3980 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3987 if (LocaleCompare(keyword,"lightness") == 0)
3989 geometry_info.rho=StringToDouble(value,
3993 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4000 if (LocaleCompare(keyword,"saturation") == 0)
4002 geometry_info.sigma=StringToDouble(value,
4006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4013 if (LocaleCompare(keyword,"whiteness") == 0)
4015 geometry_info.sigma=StringToDouble(value,
4019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4031 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4032 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4033 (void) ModulateImage(msl_info->image[n],modulate,
4034 msl_info->exception);
4037 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4042 if (LocaleCompare((const char *) tag,"negate") == 0)
4050 if (msl_info->image[n] == (Image *) NULL)
4052 ThrowMSLException(OptionError,"NoImagesDefined",
4053 (const char *) tag);
4057 if (attributes != (const xmlChar **) NULL)
4058 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4060 keyword=(const char *) attributes[i++];
4061 attribute=InterpretImageProperties(msl_info->image_info[n],
4062 msl_info->attributes[n],(const char *) attributes[i],
4064 CloneString(&value,attribute);
4070 if (LocaleCompare(keyword,"channel") == 0)
4072 option=ParseChannelOption(value);
4074 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4076 channel=(ChannelType) option;
4079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4086 if (LocaleCompare(keyword,"gray") == 0)
4088 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4091 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4093 gray=(MagickBooleanType) option;
4096 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4102 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4108 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4109 (void) NegateImage(msl_info->image[n],gray,
4110 msl_info->exception);
4111 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4114 if (LocaleCompare((const char *) tag,"normalize") == 0)
4119 if (msl_info->image[n] == (Image *) NULL)
4121 ThrowMSLException(OptionError,"NoImagesDefined",
4122 (const char *) tag);
4125 if (attributes != (const xmlChar **) NULL)
4126 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4128 keyword=(const char *) attributes[i++];
4129 attribute=InterpretImageProperties(msl_info->image_info[n],
4130 msl_info->attributes[n],(const char *) attributes[i],
4132 CloneString(&value,attribute);
4138 if (LocaleCompare(keyword,"channel") == 0)
4140 option=ParseChannelOption(value);
4142 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4144 channel=(ChannelType) option;
4147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4153 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4159 (void) NormalizeImage(msl_info->image[n],
4160 msl_info->exception);
4163 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4168 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4176 if (msl_info->image[n] == (Image *) NULL)
4178 ThrowMSLException(OptionError,"NoImagesDefined",
4179 (const char *) tag);
4182 if (attributes != (const xmlChar **) NULL)
4183 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4185 keyword=(const char *) attributes[i++];
4186 attribute=InterpretImageProperties(msl_info->image_info[n],
4187 msl_info->attributes[n],(const char *) attributes[i],
4189 CloneString(&value,attribute);
4195 if (LocaleCompare(keyword,"geometry") == 0)
4197 flags=ParseGeometry(value,&geometry_info);
4198 if ((flags & SigmaValue) == 0)
4199 geometry_info.sigma=1.0;
4202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4209 if (LocaleCompare(keyword,"radius") == 0)
4211 geometry_info.rho=StringToDouble(value,
4215 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4227 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4228 geometry_info.sigma,msl_info->exception);
4229 if (paint_image == (Image *) NULL)
4231 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4232 msl_info->image[n]=paint_image;
4235 if (LocaleCompare((const char *) tag,"opaque") == 0)
4244 if (msl_info->image[n] == (Image *) NULL)
4246 ThrowMSLException(OptionError,"NoImagesDefined",
4247 (const char *) tag);
4250 (void) QueryColorCompliance("none",AllCompliance,&target,
4252 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4254 if (attributes != (const xmlChar **) NULL)
4255 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4257 keyword=(const char *) attributes[i++];
4258 attribute=InterpretImageProperties(msl_info->image_info[n],
4259 msl_info->attributes[n],(const char *) attributes[i],
4261 CloneString(&value,attribute);
4267 if (LocaleCompare(keyword,"channel") == 0)
4269 option=ParseChannelOption(value);
4271 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4273 channel=(ChannelType) option;
4276 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4283 if (LocaleCompare(keyword,"fill") == 0)
4285 (void) QueryColorCompliance(value,AllCompliance,
4286 &fill_color,&exception);
4289 if (LocaleCompare(keyword,"fuzz") == 0)
4291 msl_info->image[n]->fuzz=StringToDouble(value,
4295 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4301 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4307 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4308 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4309 MagickFalse,msl_info->exception);
4310 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4313 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4318 if (LocaleCompare((const char *) tag,"print") == 0)
4320 if (attributes == (const xmlChar **) NULL)
4322 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4324 keyword=(const char *) attributes[i++];
4325 attribute=InterpretImageProperties(msl_info->image_info[n],
4326 msl_info->attributes[n],(const char *) attributes[i],
4328 CloneString(&value,attribute);
4334 if (LocaleCompare(keyword,"output") == 0)
4336 (void) FormatLocaleFile(stdout,"%s",value);
4339 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4344 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4351 if (LocaleCompare((const char *) tag, "profile") == 0)
4353 if (msl_info->image[n] == (Image *) NULL)
4355 ThrowMSLException(OptionError,"NoImagesDefined",
4356 (const char *) tag);
4359 if (attributes == (const xmlChar **) NULL)
4361 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4375 keyword=(const char *) attributes[i++];
4376 attribute=InterpretImageProperties(msl_info->image_info[n],
4377 msl_info->attributes[n],(const char *) attributes[i],
4379 CloneString(&value,attribute);
4380 if (*keyword == '!')
4383 Remove a profile from the image.
4385 (void) ProfileImage(msl_info->image[n],keyword,
4386 (const unsigned char *) NULL,0,&exception);
4390 Associate a profile with the image.
4392 profile_info=CloneImageInfo(msl_info->image_info[n]);
4393 profile=GetImageProfile(msl_info->image[n],"iptc");
4394 if (profile != (StringInfo *) NULL)
4395 profile_info->profile=(void *) CloneStringInfo(profile);
4396 profile_image=GetImageCache(profile_info,keyword,&exception);
4397 profile_info=DestroyImageInfo(profile_info);
4398 if (profile_image == (Image *) NULL)
4401 name[MaxTextExtent],
4402 filename[MaxTextExtent];
4410 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4411 (void) CopyMagickString(name,keyword,MaxTextExtent);
4412 for (p=filename; *p != '\0'; p++)
4413 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4414 (IsPathAccessible(keyword) == MagickFalse))
4420 Look for profile name (e.g. name:profile).
4422 (void) CopyMagickString(name,filename,(size_t)
4424 for (q=filename; *q != '\0'; q++)
4428 profile=FileToStringInfo(filename,~0UL,&exception);
4429 if (profile != (StringInfo *) NULL)
4431 (void) ProfileImage(msl_info->image[n],name,
4432 GetStringInfoDatum(profile),(size_t)
4433 GetStringInfoLength(profile),&exception);
4434 profile=DestroyStringInfo(profile);
4438 ResetImageProfileIterator(profile_image);
4439 name=GetNextImageProfile(profile_image);
4440 while (name != (const char *) NULL)
4442 profile=GetImageProfile(profile_image,name);
4443 if (profile != (StringInfo *) NULL)
4444 (void) ProfileImage(msl_info->image[n],name,
4445 GetStringInfoDatum(profile),(size_t)
4446 GetStringInfoLength(profile),&exception);
4447 name=GetNextImageProfile(profile_image);
4449 profile_image=DestroyImage(profile_image);
4453 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4458 if (LocaleCompare((const char *) tag,"quantize") == 0)
4466 if (msl_info->image[n] == (Image *) NULL)
4468 ThrowMSLException(OptionError,"NoImagesDefined",
4469 (const char *) tag);
4472 GetQuantizeInfo(&quantize_info);
4473 if (attributes != (const xmlChar **) NULL)
4474 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4476 keyword=(const char *) attributes[i++];
4477 attribute=InterpretImageProperties(msl_info->image_info[n],
4478 msl_info->attributes[n],(const char *) attributes[i],
4480 CloneString(&value,attribute);
4486 if (LocaleCompare(keyword,"colors") == 0)
4488 quantize_info.number_colors=StringToLong(value);
4491 if (LocaleCompare(keyword,"colorspace") == 0)
4493 option=ParseCommandOption(MagickColorspaceOptions,
4496 ThrowMSLException(OptionError,
4497 "UnrecognizedColorspaceType",value);
4498 quantize_info.colorspace=(ColorspaceType) option;
4501 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4508 if (LocaleCompare(keyword,"dither") == 0)
4510 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4513 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4515 quantize_info.dither_method=(DitherMethod) option;
4518 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4525 if (LocaleCompare(keyword,"measure") == 0)
4527 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4530 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4532 quantize_info.measure_error=(MagickBooleanType) option;
4535 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4542 if (LocaleCompare(keyword,"treedepth") == 0)
4544 quantize_info.tree_depth=StringToLong(value);
4547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4553 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4559 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4562 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4565 text[MaxTextExtent];
4576 draw_info=CloneDrawInfo(msl_info->image_info[n],
4577 msl_info->draw_info[n]);
4579 current=draw_info->affine;
4580 GetAffineMatrix(&affine);
4581 if (attributes != (const xmlChar **) NULL)
4582 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4584 keyword=(const char *) attributes[i++];
4585 attribute=InterpretImageProperties(msl_info->image_info[n],
4586 msl_info->attributes[n],(const char *) attributes[i],
4588 CloneString(&value,attribute);
4594 if (LocaleCompare(keyword,"affine") == 0)
4600 draw_info->affine.sx=StringToDouble(p,&p);
4603 draw_info->affine.rx=StringToDouble(p,&p);
4606 draw_info->affine.ry=StringToDouble(p,&p);
4609 draw_info->affine.sy=StringToDouble(p,&p);
4612 draw_info->affine.tx=StringToDouble(p,&p);
4615 draw_info->affine.ty=StringToDouble(p,&p);
4618 if (LocaleCompare(keyword,"align") == 0)
4620 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4623 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4625 draw_info->align=(AlignType) option;
4628 if (LocaleCompare(keyword,"antialias") == 0)
4630 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4633 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4635 draw_info->stroke_antialias=(MagickBooleanType) option;
4636 draw_info->text_antialias=(MagickBooleanType) option;
4639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4646 if (LocaleCompare(keyword,"density") == 0)
4648 CloneString(&draw_info->density,value);
4651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4658 if (LocaleCompare(keyword,"encoding") == 0)
4660 CloneString(&draw_info->encoding,value);
4663 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4670 if (LocaleCompare(keyword, "fill") == 0)
4672 (void) QueryColorCompliance(value,AllCompliance,
4673 &draw_info->fill,&exception);
4676 if (LocaleCompare(keyword,"family") == 0)
4678 CloneString(&draw_info->family,value);
4681 if (LocaleCompare(keyword,"font") == 0)
4683 CloneString(&draw_info->font,value);
4686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4693 if (LocaleCompare(keyword,"geometry") == 0)
4695 flags=ParsePageGeometry(msl_info->image[n],value,
4696 &geometry,&exception);
4697 if ((flags & HeightValue) == 0)
4698 geometry.height=geometry.width;
4701 if (LocaleCompare(keyword,"gravity") == 0)
4703 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4706 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4708 draw_info->gravity=(GravityType) option;
4711 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4718 if (LocaleCompare(keyword,"pointsize") == 0)
4720 draw_info->pointsize=StringToDouble(value,
4724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4731 if (LocaleCompare(keyword,"rotate") == 0)
4733 angle=StringToDouble(value,(char **) NULL);
4734 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4735 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4736 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4737 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4747 if (LocaleCompare(keyword,"scale") == 0)
4749 flags=ParseGeometry(value,&geometry_info);
4750 if ((flags & SigmaValue) == 0)
4751 geometry_info.sigma=1.0;
4752 affine.sx=geometry_info.rho;
4753 affine.sy=geometry_info.sigma;
4756 if (LocaleCompare(keyword,"skewX") == 0)
4758 angle=StringToDouble(value,(char **) NULL);
4759 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4762 if (LocaleCompare(keyword,"skewY") == 0)
4764 angle=StringToDouble(value,(char **) NULL);
4765 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4768 if (LocaleCompare(keyword,"stretch") == 0)
4770 option=ParseCommandOption(MagickStretchOptions,
4773 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4775 draw_info->stretch=(StretchType) option;
4778 if (LocaleCompare(keyword, "stroke") == 0)
4780 (void) QueryColorCompliance(value,AllCompliance,
4781 &draw_info->stroke,&exception);
4784 if (LocaleCompare(keyword,"strokewidth") == 0)
4786 draw_info->stroke_width=StringToLong(value);
4789 if (LocaleCompare(keyword,"style") == 0)
4791 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4794 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4796 draw_info->style=(StyleType) option;
4799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4806 if (LocaleCompare(keyword,"text") == 0)
4808 CloneString(&draw_info->text,value);
4811 if (LocaleCompare(keyword,"translate") == 0)
4813 flags=ParseGeometry(value,&geometry_info);
4814 if ((flags & SigmaValue) == 0)
4815 geometry_info.sigma=1.0;
4816 affine.tx=geometry_info.rho;
4817 affine.ty=geometry_info.sigma;
4820 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4827 if (LocaleCompare(keyword, "undercolor") == 0)
4829 (void) QueryColorCompliance(value,AllCompliance,
4830 &draw_info->undercolor,&exception);
4833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4840 if (LocaleCompare(keyword,"weight") == 0)
4842 draw_info->weight=StringToLong(value);
4845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4852 if (LocaleCompare(keyword,"x") == 0)
4854 geometry.x=StringToLong(value);
4857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4864 if (LocaleCompare(keyword,"y") == 0)
4866 geometry.y=StringToLong(value);
4869 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4881 (void) FormatLocaleString(text,MaxTextExtent,
4882 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4883 geometry.height,(double) geometry.x,(double) geometry.y);
4884 CloneString(&draw_info->geometry,text);
4885 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4886 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4887 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4888 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4889 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4891 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4893 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4894 msl_info->exception);
4895 if (status != MagickFalse)
4900 image=msl_info->attributes[n];
4901 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4902 "%g",metrics.pixels_per_em.x);
4903 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4904 "%g",metrics.pixels_per_em.y);
4905 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4907 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4909 FormatImageProperty(image,"msl:font-metrics.width","%g",
4911 FormatImageProperty(image,"msl:font-metrics.height","%g",
4913 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4914 metrics.max_advance);
4915 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4917 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4919 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4921 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4923 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4925 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4928 draw_info=DestroyDrawInfo(draw_info);
4931 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4936 if (LocaleCompare((const char *) tag,"raise") == 0)
4944 if (msl_info->image[n] == (Image *) NULL)
4946 ThrowMSLException(OptionError,"NoImagesDefined",
4947 (const char *) tag);
4951 SetGeometry(msl_info->image[n],&geometry);
4952 if (attributes != (const xmlChar **) NULL)
4953 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4955 keyword=(const char *) attributes[i++];
4956 attribute=InterpretImageProperties(msl_info->image_info[n],
4957 msl_info->attributes[n],(const char *) attributes[i],
4959 CloneString(&value,attribute);
4965 if (LocaleCompare(keyword,"geometry") == 0)
4967 flags=ParsePageGeometry(msl_info->image[n],value,
4968 &geometry,&exception);
4969 if ((flags & HeightValue) == 0)
4970 geometry.height=geometry.width;
4973 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4980 if (LocaleCompare(keyword,"height") == 0)
4982 geometry.height=StringToLong(value);
4985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4992 if (LocaleCompare(keyword,"raise") == 0)
4994 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4997 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4999 raise=(MagickBooleanType) option;
5002 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5009 if (LocaleCompare(keyword,"width") == 0)
5011 geometry.width=StringToLong(value);
5014 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5026 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5027 msl_info->exception);
5030 if (LocaleCompare((const char *) tag,"read") == 0)
5032 if (attributes == (const xmlChar **) NULL)
5034 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5036 keyword=(const char *) attributes[i++];
5037 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5038 msl_info->attributes[n],(const char *) attributes[i],&exception));
5044 if (LocaleCompare(keyword,"filename") == 0)
5049 (void) CopyMagickString(msl_info->image_info[n]->filename,
5050 value,MaxTextExtent);
5051 image=ReadImage(msl_info->image_info[n],&exception);
5052 CatchException(&exception);
5053 if (image == (Image *) NULL)
5055 AppendImageToList(&msl_info->image[n],image);
5058 (void) SetMSLAttributes(msl_info,keyword,value);
5063 (void) SetMSLAttributes(msl_info,keyword,value);
5070 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5078 if (msl_info->image[n] == (Image *) NULL)
5080 ThrowMSLException(OptionError,"NoImagesDefined",
5081 (const char *) tag);
5084 if (attributes != (const xmlChar **) NULL)
5085 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5087 keyword=(const char *) attributes[i++];
5088 attribute=InterpretImageProperties(msl_info->image_info[n],
5089 msl_info->attributes[n],(const char *) attributes[i],
5091 CloneString(&value,attribute);
5097 if (LocaleCompare(keyword,"geometry") == 0)
5099 flags=ParseGeometry(value,&geometry_info);
5100 if ((flags & SigmaValue) == 0)
5101 geometry_info.sigma=1.0;
5104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5111 if (LocaleCompare(keyword,"radius") == 0)
5113 geometry_info.rho=StringToDouble(value,
5117 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5129 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5130 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5131 msl_info->exception);
5132 if (paint_image == (Image *) NULL)
5134 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5135 msl_info->image[n]=paint_image;
5138 else if (LocaleCompare((const char *) tag,"repage") == 0)
5140 /* init the values */
5141 width=msl_info->image[n]->page.width;
5142 height=msl_info->image[n]->page.height;
5143 x=msl_info->image[n]->page.x;
5144 y=msl_info->image[n]->page.y;
5146 if (msl_info->image[n] == (Image *) NULL)
5148 ThrowMSLException(OptionError,"NoImagesDefined",
5149 (const char *) tag);
5152 if (attributes == (const xmlChar **) NULL)
5154 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5156 keyword=(const char *) attributes[i++];
5157 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5158 msl_info->attributes[n],(const char *) attributes[i],&exception));
5164 if (LocaleCompare(keyword,"geometry") == 0)
5172 flags=ParseAbsoluteGeometry(value,&geometry);
5173 if ((flags & WidthValue) != 0)
5175 if ((flags & HeightValue) == 0)
5176 geometry.height=geometry.width;
5177 width=geometry.width;
5178 height=geometry.height;
5180 if ((flags & AspectValue) != 0)
5182 if ((flags & XValue) != 0)
5184 if ((flags & YValue) != 0)
5189 if ((flags & XValue) != 0)
5192 if ((width == 0) && (geometry.x > 0))
5193 width=msl_info->image[n]->columns+geometry.x;
5195 if ((flags & YValue) != 0)
5198 if ((height == 0) && (geometry.y > 0))
5199 height=msl_info->image[n]->rows+geometry.y;
5204 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5210 if (LocaleCompare(keyword,"height") == 0)
5212 height = StringToLong( value );
5215 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5221 if (LocaleCompare(keyword,"width") == 0)
5223 width = StringToLong( value );
5226 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5232 if (LocaleCompare(keyword,"x") == 0)
5234 x = StringToLong( value );
5237 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5243 if (LocaleCompare(keyword,"y") == 0)
5245 y = StringToLong( value );
5248 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5253 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5259 msl_info->image[n]->page.width=width;
5260 msl_info->image[n]->page.height=height;
5261 msl_info->image[n]->page.x=x;
5262 msl_info->image[n]->page.y=y;
5265 else if (LocaleCompare((const char *) tag,"resample") == 0)
5271 if (msl_info->image[n] == (Image *) NULL)
5273 ThrowMSLException(OptionError,"NoImagesDefined",
5274 (const char *) tag);
5277 if (attributes == (const xmlChar **) NULL)
5279 x_resolution=DefaultResolution;
5280 y_resolution=DefaultResolution;
5281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5283 keyword=(const char *) attributes[i++];
5284 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5285 msl_info->attributes[n],(const char *) attributes[i],&exception));
5291 if (LocaleCompare(keyword,"geometry") == 0)
5296 flags=ParseGeometry(value,&geometry_info);
5297 if ((flags & SigmaValue) == 0)
5298 geometry_info.sigma*=geometry_info.rho;
5299 x_resolution=geometry_info.rho;
5300 y_resolution=geometry_info.sigma;
5303 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5309 if (LocaleCompare(keyword,"x-resolution") == 0)
5311 x_resolution=StringToDouble(value,(char **) NULL);
5314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5320 if (LocaleCompare(keyword,"y-resolution") == 0)
5322 y_resolution=StringToDouble(value,(char **) NULL);
5325 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5330 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5346 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5348 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5349 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5350 msl_info->image[n]->resolution.x))+0.5);
5351 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5352 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5353 msl_info->image[n]->resolution.y))+0.5);
5354 resample_image=ResizeImage(msl_info->image[n],width,height,
5355 msl_info->image[n]->filter,msl_info->exception);
5356 if (resample_image == (Image *) NULL)
5358 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5359 msl_info->image[n]=resample_image;
5363 if (LocaleCompare((const char *) tag,"resize") == 0)
5374 if (msl_info->image[n] == (Image *) NULL)
5376 ThrowMSLException(OptionError,"NoImagesDefined",
5377 (const char *) tag);
5380 filter=UndefinedFilter;
5381 if (attributes != (const xmlChar **) NULL)
5382 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5384 keyword=(const char *) attributes[i++];
5385 attribute=InterpretImageProperties(msl_info->image_info[n],
5386 msl_info->attributes[n],(const char *) attributes[i],
5388 CloneString(&value,attribute);
5394 if (LocaleCompare(keyword,"filter") == 0)
5396 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5399 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5401 filter=(FilterTypes) option;
5404 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5411 if (LocaleCompare(keyword,"geometry") == 0)
5413 flags=ParseRegionGeometry(msl_info->image[n],value,
5414 &geometry,&exception);
5417 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5424 if (LocaleCompare(keyword,"height") == 0)
5426 geometry.height=StringToUnsignedLong(value);
5429 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5436 if (LocaleCompare(keyword,"width") == 0)
5438 geometry.width=StringToLong(value);
5441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5447 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5453 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5454 geometry.height,filter,msl_info->exception);
5455 if (resize_image == (Image *) NULL)
5457 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5458 msl_info->image[n]=resize_image;
5461 if (LocaleCompare((const char *) tag,"roll") == 0)
5469 if (msl_info->image[n] == (Image *) NULL)
5471 ThrowMSLException(OptionError,"NoImagesDefined",
5472 (const char *) tag);
5475 SetGeometry(msl_info->image[n],&geometry);
5476 if (attributes != (const xmlChar **) NULL)
5477 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5479 keyword=(const char *) attributes[i++];
5480 attribute=InterpretImageProperties(msl_info->image_info[n],
5481 msl_info->attributes[n],(const char *) attributes[i],
5483 CloneString(&value,attribute);
5489 if (LocaleCompare(keyword,"geometry") == 0)
5491 flags=ParsePageGeometry(msl_info->image[n],value,
5492 &geometry,&exception);
5493 if ((flags & HeightValue) == 0)
5494 geometry.height=geometry.width;
5497 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5504 if (LocaleCompare(keyword,"x") == 0)
5506 geometry.x=StringToLong(value);
5509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5516 if (LocaleCompare(keyword,"y") == 0)
5518 geometry.y=StringToLong(value);
5521 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5533 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5534 msl_info->exception);
5535 if (roll_image == (Image *) NULL)
5537 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5538 msl_info->image[n]=roll_image;
5541 else if (LocaleCompare((const char *) tag,"roll") == 0)
5543 /* init the values */
5544 width=msl_info->image[n]->columns;
5545 height=msl_info->image[n]->rows;
5548 if (msl_info->image[n] == (Image *) NULL)
5550 ThrowMSLException(OptionError,"NoImagesDefined",
5551 (const char *) tag);
5554 if (attributes == (const xmlChar **) NULL)
5556 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5558 keyword=(const char *) attributes[i++];
5559 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5560 msl_info->attributes[n],(const char *) attributes[i],&exception));
5566 if (LocaleCompare(keyword,"geometry") == 0)
5568 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5571 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5577 if (LocaleCompare(keyword,"x") == 0)
5579 x = StringToLong( value );
5582 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5588 if (LocaleCompare(keyword,"y") == 0)
5590 y = StringToLong( value );
5593 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5598 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5611 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5612 if (newImage == (Image *) NULL)
5614 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5615 msl_info->image[n]=newImage;
5620 if (LocaleCompare((const char *) tag,"rotate") == 0)
5628 if (msl_info->image[n] == (Image *) NULL)
5630 ThrowMSLException(OptionError,"NoImagesDefined",
5631 (const char *) tag);
5634 if (attributes != (const xmlChar **) NULL)
5635 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5637 keyword=(const char *) attributes[i++];
5638 attribute=InterpretImageProperties(msl_info->image_info[n],
5639 msl_info->attributes[n],(const char *) attributes[i],
5641 CloneString(&value,attribute);
5647 if (LocaleCompare(keyword,"degrees") == 0)
5649 geometry_info.rho=StringToDouble(value,
5653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5660 if (LocaleCompare(keyword,"geometry") == 0)
5662 flags=ParseGeometry(value,&geometry_info);
5663 if ((flags & SigmaValue) == 0)
5664 geometry_info.sigma=1.0;
5667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5673 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5679 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5680 msl_info->exception);
5681 if (rotate_image == (Image *) NULL)
5683 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5684 msl_info->image[n]=rotate_image;
5687 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5689 /* init the values */
5692 if (msl_info->image[n] == (Image *) NULL)
5694 ThrowMSLException(OptionError,"NoImagesDefined",
5695 (const char *) tag);
5698 if (attributes == (const xmlChar **) NULL)
5700 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5702 keyword=(const char *) attributes[i++];
5703 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5704 msl_info->attributes[n],(const char *) attributes[i],&exception));
5710 if (LocaleCompare(keyword,"degrees") == 0)
5712 degrees = StringToDouble(value,(char **) NULL);
5715 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5720 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5733 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5734 if (newImage == (Image *) NULL)
5736 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5737 msl_info->image[n]=newImage;
5742 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5747 if (LocaleCompare((const char *) tag,"sample") == 0)
5755 if (msl_info->image[n] == (Image *) NULL)
5757 ThrowMSLException(OptionError,"NoImagesDefined",
5758 (const char *) tag);
5761 if (attributes != (const xmlChar **) NULL)
5762 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5764 keyword=(const char *) attributes[i++];
5765 attribute=InterpretImageProperties(msl_info->image_info[n],
5766 msl_info->attributes[n],(const char *) attributes[i],
5768 CloneString(&value,attribute);
5774 if (LocaleCompare(keyword,"geometry") == 0)
5776 flags=ParseRegionGeometry(msl_info->image[n],value,
5777 &geometry,&exception);
5780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5787 if (LocaleCompare(keyword,"height") == 0)
5789 geometry.height=StringToUnsignedLong(value);
5792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5799 if (LocaleCompare(keyword,"width") == 0)
5801 geometry.width=StringToLong(value);
5804 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5816 sample_image=SampleImage(msl_info->image[n],geometry.width,
5817 geometry.height,msl_info->exception);
5818 if (sample_image == (Image *) NULL)
5820 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5821 msl_info->image[n]=sample_image;
5824 if (LocaleCompare((const char *) tag,"scale") == 0)
5832 if (msl_info->image[n] == (Image *) NULL)
5834 ThrowMSLException(OptionError,"NoImagesDefined",
5835 (const char *) tag);
5838 if (attributes != (const xmlChar **) NULL)
5839 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5841 keyword=(const char *) attributes[i++];
5842 attribute=InterpretImageProperties(msl_info->image_info[n],
5843 msl_info->attributes[n],(const char *) attributes[i],
5845 CloneString(&value,attribute);
5851 if (LocaleCompare(keyword,"geometry") == 0)
5853 flags=ParseRegionGeometry(msl_info->image[n],value,
5854 &geometry,&exception);
5857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5864 if (LocaleCompare(keyword,"height") == 0)
5866 geometry.height=StringToUnsignedLong(value);
5869 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5876 if (LocaleCompare(keyword,"width") == 0)
5878 geometry.width=StringToLong(value);
5881 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5893 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5894 geometry.height,msl_info->exception);
5895 if (scale_image == (Image *) NULL)
5897 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5898 msl_info->image[n]=scale_image;
5901 if (LocaleCompare((const char *) tag,"segment") == 0)
5912 if (msl_info->image[n] == (Image *) NULL)
5914 ThrowMSLException(OptionError,"NoImagesDefined",
5915 (const char *) tag);
5918 geometry_info.rho=1.0;
5919 geometry_info.sigma=1.5;
5920 colorspace=sRGBColorspace;
5921 verbose=MagickFalse;
5922 if (attributes != (const xmlChar **) NULL)
5923 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5925 keyword=(const char *) attributes[i++];
5926 attribute=InterpretImageProperties(msl_info->image_info[n],
5927 msl_info->attributes[n],(const char *) attributes[i],
5929 CloneString(&value,attribute);
5935 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5937 geometry_info.rho=StringToDouble(value,
5941 if (LocaleCompare(keyword,"colorspace") == 0)
5943 option=ParseCommandOption(MagickColorspaceOptions,
5946 ThrowMSLException(OptionError,
5947 "UnrecognizedColorspaceType",value);
5948 colorspace=(ColorspaceType) option;
5951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5958 if (LocaleCompare(keyword,"geometry") == 0)
5960 flags=ParseGeometry(value,&geometry_info);
5961 if ((flags & SigmaValue) == 0)
5962 geometry_info.sigma=1.5;
5965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5972 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5974 geometry_info.sigma=StringToDouble(value,
5978 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5990 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5991 geometry_info.rho,geometry_info.sigma,&exception);
5994 else if (LocaleCompare((const char *) tag, "set") == 0)
5996 if (msl_info->image[n] == (Image *) NULL)
5998 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6002 if (attributes == (const xmlChar **) NULL)
6004 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6006 keyword=(const char *) attributes[i++];
6007 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6008 msl_info->attributes[n],(const char *) attributes[i],&exception));
6014 if (LocaleCompare(keyword,"clip-mask") == 0)
6016 for (j=0; j < msl_info->n; j++)
6021 property=GetImageProperty(msl_info->attributes[j],"id",
6023 if (LocaleCompare(property,value) == 0)
6025 SetImageMask(msl_info->image[n],msl_info->image[j],
6032 if (LocaleCompare(keyword,"clip-path") == 0)
6034 for (j=0; j < msl_info->n; j++)
6039 property=GetImageProperty(msl_info->attributes[j],"id",
6041 if (LocaleCompare(property,value) == 0)
6043 SetImageMask(msl_info->image[n],msl_info->image[j],
6050 if (LocaleCompare(keyword,"colorspace") == 0)
6055 colorspace=(ColorspaceType) ParseCommandOption(
6056 MagickColorspaceOptions,MagickFalse,value);
6058 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6060 (void) TransformImageColorspace(msl_info->image[n],
6061 (ColorspaceType) colorspace,&exception);
6064 (void) SetMSLAttributes(msl_info,keyword,value);
6065 (void) SetImageProperty(msl_info->image[n],keyword,value,
6072 if (LocaleCompare(keyword,"density") == 0)
6074 flags=ParseGeometry(value,&geometry_info);
6075 msl_info->image[n]->resolution.x=geometry_info.rho;
6076 msl_info->image[n]->resolution.y=geometry_info.sigma;
6077 if ((flags & SigmaValue) == 0)
6078 msl_info->image[n]->resolution.y=
6079 msl_info->image[n]->resolution.x;
6082 (void) SetMSLAttributes(msl_info,keyword,value);
6083 (void) SetImageProperty(msl_info->image[n],keyword,value,
6090 if (LocaleCompare(keyword, "opacity") == 0)
6092 ssize_t opac = OpaqueAlpha,
6093 len = (ssize_t) strlen( value );
6095 if (value[len-1] == '%') {
6097 (void) CopyMagickString(tmp,value,len);
6098 opac = StringToLong( tmp );
6099 opac = (int)(QuantumRange * ((float)opac/100));
6101 opac = StringToLong( value );
6102 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6106 (void) SetMSLAttributes(msl_info,keyword,value);
6107 (void) SetImageProperty(msl_info->image[n],keyword,value,
6108 msl_info->exception);
6114 if (LocaleCompare(keyword, "page") == 0)
6117 page[MaxTextExtent];
6128 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6129 image_option=GetImageArtifact(msl_info->image[n],"page");
6130 if (image_option != (const char *) NULL)
6131 flags=ParseAbsoluteGeometry(image_option,&geometry);
6132 flags=ParseAbsoluteGeometry(value,&geometry);
6133 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6134 (double) geometry.width,(double) geometry.height);
6135 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6136 (void) FormatLocaleString(page,MaxTextExtent,
6137 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6138 (double) geometry.height,(double) geometry.x,(double)
6140 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6141 msl_info->image_info[n]->page=GetPageGeometry(page);
6144 (void) SetMSLAttributes(msl_info,keyword,value);
6145 (void) SetImageProperty(msl_info->image[n],keyword,value,
6146 msl_info->exception);
6151 (void) SetMSLAttributes(msl_info,keyword,value);
6152 (void) SetImageProperty(msl_info->image[n],keyword,value,
6153 msl_info->exception);
6160 if (LocaleCompare((const char *) tag,"shade") == 0)
6171 if (msl_info->image[n] == (Image *) NULL)
6173 ThrowMSLException(OptionError,"NoImagesDefined",
6174 (const char *) tag);
6178 if (attributes != (const xmlChar **) NULL)
6179 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6181 keyword=(const char *) attributes[i++];
6182 attribute=InterpretImageProperties(msl_info->image_info[n],
6183 msl_info->attributes[n],(const char *) attributes[i],
6185 CloneString(&value,attribute);
6191 if (LocaleCompare(keyword,"azimuth") == 0)
6193 geometry_info.rho=StringToDouble(value,
6197 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6204 if (LocaleCompare(keyword,"elevation") == 0)
6206 geometry_info.sigma=StringToDouble(value,
6210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6217 if (LocaleCompare(keyword,"geometry") == 0)
6219 flags=ParseGeometry(value,&geometry_info);
6220 if ((flags & SigmaValue) == 0)
6221 geometry_info.sigma=1.0;
6224 if (LocaleCompare(keyword,"gray") == 0)
6226 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6229 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6231 gray=(MagickBooleanType) option;
6234 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6246 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6247 geometry_info.sigma,msl_info->exception);
6248 if (shade_image == (Image *) NULL)
6250 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6251 msl_info->image[n]=shade_image;
6254 if (LocaleCompare((const char *) tag,"shadow") == 0)
6262 if (msl_info->image[n] == (Image *) NULL)
6264 ThrowMSLException(OptionError,"NoImagesDefined",
6265 (const char *) tag);
6268 if (attributes != (const xmlChar **) NULL)
6269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6271 keyword=(const char *) attributes[i++];
6272 attribute=InterpretImageProperties(msl_info->image_info[n],
6273 msl_info->attributes[n],(const char *) attributes[i],
6275 CloneString(&value,attribute);
6281 if (LocaleCompare(keyword,"geometry") == 0)
6283 flags=ParseGeometry(value,&geometry_info);
6284 if ((flags & SigmaValue) == 0)
6285 geometry_info.sigma=1.0;
6288 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6295 if (LocaleCompare(keyword,"opacity") == 0)
6297 geometry_info.rho=StringToLong(value);
6300 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6307 if (LocaleCompare(keyword,"sigma") == 0)
6309 geometry_info.sigma=StringToLong(value);
6317 if (LocaleCompare(keyword,"x") == 0)
6319 geometry_info.xi=StringToDouble(value,
6323 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6330 if (LocaleCompare(keyword,"y") == 0)
6332 geometry_info.psi=StringToLong(value);
6335 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6341 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6347 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6348 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6349 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6350 if (shadow_image == (Image *) NULL)
6352 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6353 msl_info->image[n]=shadow_image;
6356 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6362 if (msl_info->image[n] == (Image *) NULL)
6364 ThrowMSLException(OptionError,"NoImagesDefined",
6365 (const char *) tag);
6369 NOTE: sharpen can have no attributes, since we use all the defaults!
6371 if (attributes != (const xmlChar **) NULL)
6373 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6375 keyword=(const char *) attributes[i++];
6376 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6377 msl_info->attributes[n],(const char *) attributes[i],&exception));
6383 if (LocaleCompare(keyword, "radius") == 0)
6385 radius = StringToDouble(value,(char **) NULL);
6388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6394 if (LocaleCompare(keyword,"sigma") == 0)
6396 sigma = StringToLong( value );
6399 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6404 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6418 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6419 msl_info->exception);
6420 if (newImage == (Image *) NULL)
6422 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6423 msl_info->image[n]=newImage;
6427 else if (LocaleCompare((const char *) tag,"shave") == 0)
6429 /* init the values */
6433 if (msl_info->image[n] == (Image *) NULL)
6435 ThrowMSLException(OptionError,"NoImagesDefined",
6436 (const char *) tag);
6439 if (attributes == (const xmlChar **) NULL)
6441 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6443 keyword=(const char *) attributes[i++];
6444 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6445 msl_info->attributes[n],(const char *) attributes[i],&exception));
6451 if (LocaleCompare(keyword,"geometry") == 0)
6453 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6456 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6462 if (LocaleCompare(keyword,"height") == 0)
6464 height = StringToLong( value );
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6473 if (LocaleCompare(keyword,"width") == 0)
6475 width = StringToLong( value );
6478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6483 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6498 rectInfo.height = height;
6499 rectInfo.width = width;
6504 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6505 msl_info->exception);
6506 if (newImage == (Image *) NULL)
6508 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6509 msl_info->image[n]=newImage;
6514 if (LocaleCompare((const char *) tag,"shear") == 0)
6522 if (msl_info->image[n] == (Image *) NULL)
6524 ThrowMSLException(OptionError,"NoImagesDefined",
6525 (const char *) tag);
6528 if (attributes != (const xmlChar **) NULL)
6529 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6531 keyword=(const char *) attributes[i++];
6532 attribute=InterpretImageProperties(msl_info->image_info[n],
6533 msl_info->attributes[n],(const char *) attributes[i],
6535 CloneString(&value,attribute);
6541 if (LocaleCompare(keyword, "fill") == 0)
6543 (void) QueryColorCompliance(value,AllCompliance,
6544 &msl_info->image[n]->background_color,&exception);
6547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6554 if (LocaleCompare(keyword,"geometry") == 0)
6556 flags=ParseGeometry(value,&geometry_info);
6557 if ((flags & SigmaValue) == 0)
6558 geometry_info.sigma=1.0;
6561 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6568 if (LocaleCompare(keyword,"x") == 0)
6570 geometry_info.rho=StringToDouble(value,
6574 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6581 if (LocaleCompare(keyword,"y") == 0)
6583 geometry_info.sigma=StringToLong(value);
6586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6592 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6598 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6599 geometry_info.sigma,msl_info->exception);
6600 if (shear_image == (Image *) NULL)
6602 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6603 msl_info->image[n]=shear_image;
6606 if (LocaleCompare((const char *) tag,"signature") == 0)
6611 if (msl_info->image[n] == (Image *) NULL)
6613 ThrowMSLException(OptionError,"NoImagesDefined",
6614 (const char *) tag);
6617 if (attributes != (const xmlChar **) NULL)
6618 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6620 keyword=(const char *) attributes[i++];
6621 attribute=InterpretImageProperties(msl_info->image_info[n],
6622 msl_info->attributes[n],(const char *) attributes[i],
6624 CloneString(&value,attribute);
6629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6635 (void) SignatureImage(msl_info->image[n],&exception);
6638 if (LocaleCompare((const char *) tag,"solarize") == 0)
6643 if (msl_info->image[n] == (Image *) NULL)
6645 ThrowMSLException(OptionError,"NoImagesDefined",
6646 (const char *) tag);
6649 geometry_info.rho=QuantumRange/2.0;
6650 if (attributes != (const xmlChar **) NULL)
6651 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6653 keyword=(const char *) attributes[i++];
6654 attribute=InterpretImageProperties(msl_info->image_info[n],
6655 msl_info->attributes[n],(const char *) attributes[i],
6657 CloneString(&value,attribute);
6663 if (LocaleCompare(keyword,"geometry") == 0)
6665 flags=ParseGeometry(value,&geometry_info);
6668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6675 if (LocaleCompare(keyword,"threshold") == 0)
6677 geometry_info.rho=StringToDouble(value,
6681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6687 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6693 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6694 msl_info->exception);
6697 if (LocaleCompare((const char *) tag,"spread") == 0)
6705 if (msl_info->image[n] == (Image *) NULL)
6707 ThrowMSLException(OptionError,"NoImagesDefined",
6708 (const char *) tag);
6711 if (attributes != (const xmlChar **) NULL)
6712 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6714 keyword=(const char *) attributes[i++];
6715 attribute=InterpretImageProperties(msl_info->image_info[n],
6716 msl_info->attributes[n],(const char *) attributes[i],
6718 CloneString(&value,attribute);
6724 if (LocaleCompare(keyword,"geometry") == 0)
6726 flags=ParseGeometry(value,&geometry_info);
6727 if ((flags & SigmaValue) == 0)
6728 geometry_info.sigma=1.0;
6731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6738 if (LocaleCompare(keyword,"radius") == 0)
6740 geometry_info.rho=StringToDouble(value,
6744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6750 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6756 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6757 msl_info->image[n]->interpolate,msl_info->exception);
6758 if (spread_image == (Image *) NULL)
6760 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6761 msl_info->image[n]=spread_image;
6764 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6767 watermark = (Image*)NULL;
6769 if (msl_info->image[n] == (Image *) NULL)
6771 ThrowMSLException(OptionError,"NoImagesDefined",
6772 (const char *) tag);
6775 if (attributes == (const xmlChar **) NULL)
6777 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6779 keyword=(const char *) attributes[i++];
6780 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6781 msl_info->attributes[n],(const char *) attributes[i],&exception));
6787 if (LocaleCompare(keyword,"image") == 0)
6789 for (j=0; j<msl_info->n;j++)
6792 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6794 if (theAttr && LocaleCompare(theAttr, value) == 0)
6796 watermark = msl_info->image[j];
6802 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6807 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6816 if ( watermark != (Image*) NULL )
6821 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6822 if (newImage == (Image *) NULL)
6824 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6825 msl_info->image[n]=newImage;
6828 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6830 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6833 stereoImage = (Image*)NULL;
6835 if (msl_info->image[n] == (Image *) NULL)
6837 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6840 if (attributes == (const xmlChar **) NULL)
6842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6844 keyword=(const char *) attributes[i++];
6845 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6846 msl_info->attributes[n],(const char *) attributes[i],&exception));
6852 if (LocaleCompare(keyword,"image") == 0)
6854 for (j=0; j<msl_info->n;j++)
6857 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6859 if (theAttr && LocaleCompare(theAttr, value) == 0)
6861 stereoImage = msl_info->image[j];
6867 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6872 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6881 if ( stereoImage != (Image*) NULL )
6886 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6887 if (newImage == (Image *) NULL)
6889 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6890 msl_info->image[n]=newImage;
6893 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6895 if (LocaleCompare((const char *) tag,"strip") == 0)
6900 if (msl_info->image[n] == (Image *) NULL)
6902 ThrowMSLException(OptionError,"NoImagesDefined",
6903 (const char *) tag);
6906 if (attributes != (const xmlChar **) NULL)
6907 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6909 keyword=(const char *) attributes[i++];
6910 attribute=InterpretImageProperties(msl_info->image_info[n],
6911 msl_info->attributes[n],(const char *) attributes[i],
6913 CloneString(&value,attribute);
6914 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6916 (void) StripImage(msl_info->image[n],msl_info->exception);
6919 if (LocaleCompare((const char *) tag,"swap") == 0)
6930 if (msl_info->image[n] == (Image *) NULL)
6932 ThrowMSLException(OptionError,"NoImagesDefined",
6933 (const char *) tag);
6938 if (attributes != (const xmlChar **) NULL)
6939 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6941 keyword=(const char *) attributes[i++];
6942 attribute=InterpretImageProperties(msl_info->image_info[n],
6943 msl_info->attributes[n],(const char *) attributes[i],
6945 CloneString(&value,attribute);
6951 if (LocaleCompare(keyword,"indexes") == 0)
6953 flags=ParseGeometry(value,&geometry_info);
6954 index=(ssize_t) geometry_info.rho;
6955 if ((flags & SigmaValue) == 0)
6956 swap_index=(ssize_t) geometry_info.sigma;
6959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6974 p=GetImageFromList(msl_info->image[n],index);
6975 q=GetImageFromList(msl_info->image[n],swap_index);
6976 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6978 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6981 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6982 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6983 msl_info->exception));
6984 ReplaceImageInList(&q,swap);
6985 msl_info->image[n]=GetFirstImageInList(q);
6988 if (LocaleCompare((const char *) tag,"swirl") == 0)
6996 if (msl_info->image[n] == (Image *) NULL)
6998 ThrowMSLException(OptionError,"NoImagesDefined",
6999 (const char *) tag);
7002 if (attributes != (const xmlChar **) NULL)
7003 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7005 keyword=(const char *) attributes[i++];
7006 attribute=InterpretImageProperties(msl_info->image_info[n],
7007 msl_info->attributes[n],(const char *) attributes[i],
7009 CloneString(&value,attribute);
7015 if (LocaleCompare(keyword,"degrees") == 0)
7017 geometry_info.rho=StringToDouble(value,
7021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7028 if (LocaleCompare(keyword,"geometry") == 0)
7030 flags=ParseGeometry(value,&geometry_info);
7031 if ((flags & SigmaValue) == 0)
7032 geometry_info.sigma=1.0;
7035 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7041 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7047 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7048 msl_info->image[n]->interpolate,msl_info->exception);
7049 if (swirl_image == (Image *) NULL)
7051 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7052 msl_info->image[n]=swirl_image;
7055 if (LocaleCompare((const char *) tag,"sync") == 0)
7060 if (msl_info->image[n] == (Image *) NULL)
7062 ThrowMSLException(OptionError,"NoImagesDefined",
7063 (const char *) tag);
7066 if (attributes != (const xmlChar **) NULL)
7067 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7069 keyword=(const char *) attributes[i++];
7070 attribute=InterpretImageProperties(msl_info->image_info[n],
7071 msl_info->attributes[n],(const char *) attributes[i],
7073 CloneString(&value,attribute);
7078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7084 (void) SyncImage(msl_info->image[n],&exception);
7087 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7092 if (LocaleCompare((const char *) tag,"map") == 0)
7100 if (msl_info->image[n] == (Image *) NULL)
7102 ThrowMSLException(OptionError,"NoImagesDefined",
7103 (const char *) tag);
7106 texture_image=NewImageList();
7107 if (attributes != (const xmlChar **) NULL)
7108 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7110 keyword=(const char *) attributes[i++];
7111 attribute=InterpretImageProperties(msl_info->image_info[n],
7112 msl_info->attributes[n],(const char *) attributes[i],
7114 CloneString(&value,attribute);
7120 if (LocaleCompare(keyword,"image") == 0)
7121 for (j=0; j < msl_info->n; j++)
7126 attribute=GetImageProperty(msl_info->attributes[j],"id",
7128 if ((attribute != (const char *) NULL) &&
7129 (LocaleCompare(attribute,value) == 0))
7131 texture_image=CloneImage(msl_info->image[j],0,0,
7132 MagickFalse,&exception);
7140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7146 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7147 texture_image=DestroyImage(texture_image);
7150 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7152 /* init the values */
7153 double threshold = 0;
7155 if (msl_info->image[n] == (Image *) NULL)
7157 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7160 if (attributes == (const xmlChar **) NULL)
7162 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7164 keyword=(const char *) attributes[i++];
7165 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7166 msl_info->attributes[n],(const char *) attributes[i],&exception));
7172 if (LocaleCompare(keyword,"threshold") == 0)
7174 threshold = StringToDouble(value,(char **) NULL);
7177 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7182 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7192 BilevelImage(msl_info->image[n],threshold,&exception);
7196 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7198 if (msl_info->image[n] == (Image *) NULL)
7200 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7203 if (attributes == (const xmlChar **) NULL)
7205 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7207 keyword=(const char *) attributes[i++];
7208 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7209 msl_info->attributes[n],(const char *) attributes[i],&exception));
7215 if (LocaleCompare(keyword,"color") == 0)
7220 (void) QueryColorCompliance(value,AllCompliance,&target,
7222 (void) TransparentPaintImage(msl_info->image[n],&target,
7223 TransparentAlpha,MagickFalse,msl_info->exception);
7226 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7231 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7238 else if (LocaleCompare((const char *) tag, "trim") == 0)
7240 if (msl_info->image[n] == (Image *) NULL)
7242 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7246 /* no attributes here */
7248 /* process the image */
7255 /* all zeros on a crop == trim edges! */
7256 rectInfo.height = rectInfo.width = 0;
7257 rectInfo.x = rectInfo.y = 0;
7259 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7260 if (newImage == (Image *) NULL)
7262 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7263 msl_info->image[n]=newImage;
7267 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7272 if (LocaleCompare((const char *) tag,"write") == 0)
7274 if (msl_info->image[n] == (Image *) NULL)
7276 ThrowMSLException(OptionError,"NoImagesDefined",
7277 (const char *) tag);
7280 if (attributes == (const xmlChar **) NULL)
7282 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7284 keyword=(const char *) attributes[i++];
7285 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7286 msl_info->attributes[n],(const char *) attributes[i],&exception));
7292 if (LocaleCompare(keyword,"filename") == 0)
7294 (void) CopyMagickString(msl_info->image[n]->filename,value,
7298 (void) SetMSLAttributes(msl_info,keyword,value);
7302 (void) SetMSLAttributes(msl_info,keyword,value);
7310 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7311 msl_info->exception);
7315 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7319 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7323 if ( value != NULL )
7324 value=DestroyString(value);
7325 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7328 static void MSLEndElement(void *context,const xmlChar *tag)
7337 Called when the end of an element has been detected.
7339 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7341 msl_info=(MSLInfo *) context;
7348 if (LocaleCompare((const char *) tag,"comment") == 0 )
7350 (void) DeleteImageProperty(msl_info->image[n],"comment");
7351 if (msl_info->content == (char *) NULL)
7353 StripString(msl_info->content);
7354 (void) SetImageProperty(msl_info->image[n],"comment",
7355 msl_info->content,msl_info->exception);
7363 if (LocaleCompare((const char *) tag, "group") == 0 )
7365 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7367 ssize_t i = (ssize_t)
7368 (msl_info->group_info[msl_info->number_groups-1].numImages);
7371 if (msl_info->image[msl_info->n] != (Image *) NULL)
7372 msl_info->image[msl_info->n]=DestroyImage(
7373 msl_info->image[msl_info->n]);
7374 msl_info->attributes[msl_info->n]=DestroyImage(
7375 msl_info->attributes[msl_info->n]);
7376 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7377 msl_info->image_info[msl_info->n]);
7381 msl_info->number_groups--;
7388 if (LocaleCompare((const char *) tag, "image") == 0)
7389 MSLPopImage(msl_info);
7395 if (LocaleCompare((const char *) tag,"label") == 0 )
7397 (void) DeleteImageProperty(msl_info->image[n],"label");
7398 if (msl_info->content == (char *) NULL)
7400 StripString(msl_info->content);
7401 (void) SetImageProperty(msl_info->image[n],"label",
7402 msl_info->content,msl_info->exception);
7410 if (LocaleCompare((const char *) tag, "msl") == 0 )
7413 This our base element.
7414 at the moment we don't do anything special
7415 but someday we might!
7423 if (msl_info->content != (char *) NULL)
7424 msl_info->content=DestroyString(msl_info->content);
7427 static void MSLCharacters(void *context,const xmlChar *c,int length)
7439 Receiving some characters from the parser.
7441 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7442 " SAX.characters(%s,%d)",c,length);
7443 msl_info=(MSLInfo *) context;
7444 if (msl_info->content != (char *) NULL)
7445 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7446 strlen(msl_info->content)+length+MaxTextExtent,
7447 sizeof(*msl_info->content));
7450 msl_info->content=(char *) NULL;
7451 if (~length >= (MaxTextExtent-1))
7452 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7453 sizeof(*msl_info->content));
7454 if (msl_info->content != (char *) NULL)
7455 *msl_info->content='\0';
7457 if (msl_info->content == (char *) NULL)
7459 p=msl_info->content+strlen(msl_info->content);
7460 for (i=0; i < length; i++)
7465 static void MSLReference(void *context,const xmlChar *name)
7474 Called when an entity reference is detected.
7476 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7477 " SAX.reference(%s)",name);
7478 msl_info=(MSLInfo *) context;
7479 parser=msl_info->parser;
7481 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7483 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7486 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7492 Receiving some ignorable whitespaces from the parser.
7494 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7495 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7496 msl_info=(MSLInfo *) context;
7500 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7501 const xmlChar *data)
7507 A processing instruction has been parsed.
7509 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7510 " SAX.processingInstruction(%s, %s)",
7512 msl_info=(MSLInfo *) context;
7516 static void MSLComment(void *context,const xmlChar *value)
7522 A comment has been parsed.
7524 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7525 " SAX.comment(%s)",value);
7526 msl_info=(MSLInfo *) context;
7530 static void MSLWarning(void *context,const char *format,...)
7534 reason[MaxTextExtent];
7543 Display and format a warning messages, gives file, line, position and
7546 va_start(operands,format);
7547 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7548 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7549 msl_info=(MSLInfo *) context;
7551 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7552 (void) vsprintf(reason,format,operands);
7554 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7556 message=GetExceptionMessage(errno);
7557 ThrowMSLException(CoderError,reason,message);
7558 message=DestroyString(message);
7562 static void MSLError(void *context,const char *format,...)
7565 reason[MaxTextExtent];
7574 Display and format a error formats, gives file, line, position and
7577 va_start(operands,format);
7578 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7579 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7580 msl_info=(MSLInfo *) context;
7582 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7583 (void) vsprintf(reason,format,operands);
7585 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7587 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7591 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7603 Called when a pcdata block has been parsed.
7605 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7606 " SAX.pcdata(%s, %d)",value,length);
7607 msl_info=(MSLInfo *) context;
7609 parser=msl_info->parser;
7610 child=xmlGetLastChild(parser->node);
7611 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7613 xmlTextConcat(child,value,length);
7616 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7619 static void MSLExternalSubset(void *context,const xmlChar *name,
7620 const xmlChar *external_id,const xmlChar *system_id)
7635 Does this document has an external subset?
7637 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7638 " SAX.externalSubset(%s %s %s)",name,
7639 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7640 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7641 msl_info=(MSLInfo *) context;
7643 parser=msl_info->parser;
7644 if (((external_id == NULL) && (system_id == NULL)) ||
7645 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7646 (msl_info->document == 0)))
7648 input=MSLResolveEntity(context,external_id,system_id);
7651 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7652 parser_context=(*parser);
7653 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7654 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7656 parser->errNo=XML_ERR_NO_MEMORY;
7657 parser->input=parser_context.input;
7658 parser->inputNr=parser_context.inputNr;
7659 parser->inputMax=parser_context.inputMax;
7660 parser->inputTab=parser_context.inputTab;
7666 xmlPushInput(parser,input);
7667 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7668 if (input->filename == (char *) NULL)
7669 input->filename=(char *) xmlStrdup(system_id);
7672 input->base=parser->input->cur;
7673 input->cur=parser->input->cur;
7675 xmlParseExternalSubset(parser,external_id,system_id);
7676 while (parser->inputNr > 1)
7677 (void) xmlPopInput(parser);
7678 xmlFreeInputStream(parser->input);
7679 xmlFree(parser->inputTab);
7680 parser->input=parser_context.input;
7681 parser->inputNr=parser_context.inputNr;
7682 parser->inputMax=parser_context.inputMax;
7683 parser->inputTab=parser_context.inputTab;
7686 #if defined(__cplusplus) || defined(c_plusplus)
7690 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7691 Image **image,ExceptionInfo *exception)
7694 message[MaxTextExtent];
7717 assert(image_info != (const ImageInfo *) NULL);
7718 assert(image_info->signature == MagickSignature);
7719 if (image_info->debug != MagickFalse)
7720 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7721 image_info->filename);
7722 assert(image != (Image **) NULL);
7723 msl_image=AcquireImage(image_info,exception);
7724 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7725 if (status == MagickFalse)
7727 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7728 msl_image->filename);
7729 msl_image=DestroyImageList(msl_image);
7730 return(MagickFalse);
7732 msl_image->columns=1;
7737 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7738 msl_info.exception=exception;
7739 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7740 sizeof(*msl_info.image_info));
7741 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7742 sizeof(*msl_info.draw_info));
7743 /* top of the stack is the MSL file itself */
7744 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7745 msl_info.attributes=(Image **) AcquireMagickMemory(
7746 sizeof(*msl_info.attributes));
7747 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7748 sizeof(*msl_info.group_info));
7749 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7750 (msl_info.image == (Image **) NULL) ||
7751 (msl_info.attributes == (Image **) NULL) ||
7752 (msl_info.group_info == (MSLGroupInfo *) NULL))
7753 ThrowFatalException(ResourceLimitFatalError,
7754 "UnableToInterpretMSLImage");
7755 *msl_info.image_info=CloneImageInfo(image_info);
7756 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7757 *msl_info.attributes=AcquireImage(image_info,exception);
7758 msl_info.group_info[0].numImages=0;
7759 /* the first slot is used to point to the MSL file image */
7760 *msl_info.image=msl_image;
7761 if (*image != (Image *) NULL)
7762 MSLPushImage(&msl_info,*image);
7763 (void) xmlSubstituteEntitiesDefault(1);
7764 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7765 sax_modules.internalSubset=MSLInternalSubset;
7766 sax_modules.isStandalone=MSLIsStandalone;
7767 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7768 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7769 sax_modules.resolveEntity=MSLResolveEntity;
7770 sax_modules.getEntity=MSLGetEntity;
7771 sax_modules.entityDecl=MSLEntityDeclaration;
7772 sax_modules.notationDecl=MSLNotationDeclaration;
7773 sax_modules.attributeDecl=MSLAttributeDeclaration;
7774 sax_modules.elementDecl=MSLElementDeclaration;
7775 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7776 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7777 sax_modules.startDocument=MSLStartDocument;
7778 sax_modules.endDocument=MSLEndDocument;
7779 sax_modules.startElement=MSLStartElement;
7780 sax_modules.endElement=MSLEndElement;
7781 sax_modules.reference=MSLReference;
7782 sax_modules.characters=MSLCharacters;
7783 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7784 sax_modules.processingInstruction=MSLProcessingInstructions;
7785 sax_modules.comment=MSLComment;
7786 sax_modules.warning=MSLWarning;
7787 sax_modules.error=MSLError;
7788 sax_modules.fatalError=MSLError;
7789 sax_modules.getParameterEntity=MSLGetParameterEntity;
7790 sax_modules.cdataBlock=MSLCDataBlock;
7791 sax_modules.externalSubset=MSLExternalSubset;
7792 sax_handler=(&sax_modules);
7793 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7794 msl_image->filename);
7795 while (ReadBlobString(msl_image,message) != (char *) NULL)
7797 n=(ssize_t) strlen(message);
7800 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7803 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7804 if (msl_info.exception->severity >= ErrorException)
7807 if (msl_info.exception->severity == UndefinedException)
7808 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7809 xmlFreeParserCtxt(msl_info.parser);
7810 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7811 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7812 msl_info.group_info);
7813 if (*image == (Image *) NULL)
7814 *image=(*msl_info.image);
7815 if (msl_info.exception->severity != UndefinedException)
7816 return(MagickFalse);
7820 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7828 assert(image_info != (const ImageInfo *) NULL);
7829 assert(image_info->signature == MagickSignature);
7830 if (image_info->debug != MagickFalse)
7831 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7832 image_info->filename);
7833 assert(exception != (ExceptionInfo *) NULL);
7834 assert(exception->signature == MagickSignature);
7835 image=(Image *) NULL;
7836 (void) ProcessMSLScript(image_info,&image,exception);
7837 return(GetFirstImageInList(image));
7842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7846 % R e g i s t e r M S L I m a g e %
7850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7852 % RegisterMSLImage() adds attributes for the MSL image format to
7853 % the list of supported formats. The attributes include the image format
7854 % tag, a method to read and/or write the format, whether the format
7855 % supports the saving of more than one frame to the same file or blob,
7856 % whether the format supports native in-memory I/O, and a brief
7857 % description of the format.
7859 % The format of the RegisterMSLImage method is:
7861 % size_t RegisterMSLImage(void)
7864 ModuleExport size_t RegisterMSLImage(void)
7869 #if defined(MAGICKCORE_XML_DELEGATE)
7872 entry=SetMagickInfo("MSL");
7873 #if defined(MAGICKCORE_XML_DELEGATE)
7874 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7875 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7877 entry->description=ConstantString("Magick Scripting Language");
7878 entry->module=ConstantString("MSL");
7879 (void) RegisterMagickInfo(entry);
7880 return(MagickImageCoderSignature);
7883 #if defined(MAGICKCORE_XML_DELEGATE)
7885 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7889 % S e t M S L A t t r i b u t e s %
7893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7895 % SetMSLAttributes() ...
7897 % The format of the SetMSLAttributes method is:
7899 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7900 % const char *keyword,const char *value)
7902 % A description of each parameter follows:
7904 % o msl_info: the MSL info.
7906 % o keyword: the keyword.
7908 % o value: the value.
7911 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7938 assert(msl_info != (MSLInfo *) NULL);
7939 if (keyword == (const char *) NULL)
7941 if (value == (const char *) NULL)
7943 exception=msl_info->exception;
7945 attributes=msl_info->attributes[n];
7946 image_info=msl_info->image_info[n];
7947 draw_info=msl_info->draw_info[n];
7948 image=msl_info->image[n];
7954 if (LocaleCompare(keyword,"adjoin") == 0)
7959 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7961 ThrowMSLException(OptionError,"UnrecognizedType",value);
7962 image_info->adjoin=(MagickBooleanType) adjoin;
7965 if (LocaleCompare(keyword,"alpha") == 0)
7970 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
7972 ThrowMSLException(OptionError,"UnrecognizedType",value);
7973 if (image != (Image *) NULL)
7974 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
7978 if (LocaleCompare(keyword,"antialias") == 0)
7983 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7985 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7986 image_info->antialias=(MagickBooleanType) antialias;
7989 if (LocaleCompare(keyword,"area-limit") == 0)
7994 limit=MagickResourceInfinity;
7995 if (LocaleCompare(value,"unlimited") != 0)
7996 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7997 (void) SetMagickResourceLimit(AreaResource,limit);
8000 if (LocaleCompare(keyword,"attenuate") == 0)
8002 (void) SetImageOption(image_info,keyword,value);
8005 if (LocaleCompare(keyword,"authenticate") == 0)
8007 (void) CloneString(&image_info->density,value);
8010 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8016 if (LocaleCompare(keyword,"background") == 0)
8018 (void) QueryColorCompliance(value,AllCompliance,
8019 &image_info->background_color,exception);
8022 if (LocaleCompare(keyword,"blue-primary") == 0)
8024 if (image == (Image *) NULL)
8026 flags=ParseGeometry(value,&geometry_info);
8027 image->chromaticity.blue_primary.x=geometry_info.rho;
8028 image->chromaticity.blue_primary.y=geometry_info.sigma;
8029 if ((flags & SigmaValue) == 0)
8030 image->chromaticity.blue_primary.y=
8031 image->chromaticity.blue_primary.x;
8034 if (LocaleCompare(keyword,"bordercolor") == 0)
8036 (void) QueryColorCompliance(value,AllCompliance,
8037 &image_info->border_color,exception);
8040 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8046 if (LocaleCompare(keyword,"density") == 0)
8048 (void) CloneString(&image_info->density,value);
8049 (void) CloneString(&draw_info->density,value);
8052 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8058 if (LocaleCompare(keyword,"fill") == 0)
8060 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8062 (void) SetImageOption(image_info,keyword,value);
8065 if (LocaleCompare(keyword,"filename") == 0)
8067 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8070 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8076 if (LocaleCompare(keyword,"gravity") == 0)
8081 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8083 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8084 (void) SetImageOption(image_info,keyword,value);
8087 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8093 if (LocaleCompare(keyword,"id") == 0)
8095 (void) SetImageProperty(attributes,keyword,value,exception);
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"magick") == 0)
8106 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8109 if (LocaleCompare(keyword,"mattecolor") == 0)
8111 (void) QueryColorCompliance(value,AllCompliance,
8112 &image_info->matte_color,exception);
8115 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8121 if (LocaleCompare(keyword,"pointsize") == 0)
8123 image_info->pointsize=StringToDouble(value,(char **) NULL);
8124 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8133 if (LocaleCompare(keyword,"quality") == 0)
8135 image_info->quality=StringToLong(value);
8136 if (image == (Image *) NULL)
8138 image->quality=StringToLong(value);
8146 if (LocaleCompare(keyword,"size") == 0)
8148 (void) CloneString(&image_info->size,value);
8151 if (LocaleCompare(keyword,"stroke") == 0)
8153 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8155 (void) SetImageOption(image_info,keyword,value);
8158 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8163 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8176 % U n r e g i s t e r M S L I m a g e %
8180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8182 % UnregisterMSLImage() removes format registrations made by the
8183 % MSL module from the list of supported formats.
8185 % The format of the UnregisterMSLImage method is:
8187 % UnregisterMSLImage(void)
8190 ModuleExport void UnregisterMSLImage(void)
8192 (void) UnregisterMagickInfo("MSL");
8193 #if defined(MAGICKCORE_XML_DELEGATE)
8198 #if defined(MAGICKCORE_XML_DELEGATE)
8200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8204 % W r i t e M S L I m a g e %
8208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8210 % WriteMSLImage() writes an image to a file in MVG image format.
8212 % The format of the WriteMSLImage method is:
8214 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8215 % Image *image,ExceptionInfo *exception)
8217 % A description of each parameter follows.
8219 % o image_info: the image info.
8221 % o image: The image.
8223 % o exception: return any errors or warnings in this structure.
8226 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8227 ExceptionInfo *exception)
8229 assert(image_info != (const ImageInfo *) NULL);
8230 assert(image_info->signature == MagickSignature);
8231 assert(image != (Image *) NULL);
8232 assert(image->signature == MagickSignature);
8233 if (image->debug != MagickFalse)
8234 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8235 (void) ReferenceImage(image);
8236 (void) ProcessMSLScript(image_info,&image,exception);