2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/color-private.h"
53 #include "MagickCore/colormap.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/distort.h"
59 #include "MagickCore/draw.h"
60 #include "MagickCore/effect.h"
61 #include "MagickCore/enhance.h"
62 #include "MagickCore/exception.h"
63 #include "MagickCore/exception-private.h"
64 #include "MagickCore/fx.h"
65 #include "MagickCore/geometry.h"
66 #include "MagickCore/image.h"
67 #include "MagickCore/image-private.h"
68 #include "MagickCore/list.h"
69 #include "MagickCore/log.h"
70 #include "MagickCore/magick.h"
71 #include "MagickCore/memory_.h"
72 #include "MagickCore/module.h"
73 #include "MagickCore/option.h"
74 #include "MagickCore/paint.h"
75 #include "MagickCore/pixel-accessor.h"
76 #include "MagickCore/profile.h"
77 #include "MagickCore/property.h"
78 #include "MagickCore/quantize.h"
79 #include "MagickCore/quantum-private.h"
80 #include "MagickCore/registry.h"
81 #include "MagickCore/resize.h"
82 #include "MagickCore/resource_.h"
83 #include "MagickCore/segment.h"
84 #include "MagickCore/shear.h"
85 #include "MagickCore/signature.h"
86 #include "MagickCore/static.h"
87 #include "MagickCore/string_.h"
88 #include "MagickCore/string-private.h"
89 #include "MagickCore/transform.h"
90 #include "MagickCore/threshold.h"
91 #include "MagickCore/utility.h"
92 #if defined(MAGICKCORE_XML_DELEGATE)
93 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
94 # if defined(__MINGW32__)
97 # include <win32config.h>
100 # include <libxml/parser.h>
101 # include <libxml/xmlmemory.h>
102 # include <libxml/parserInternals.h>
103 # include <libxml/xmlerror.h>
109 #define ThrowMSLException(severity,tag,reason) \
110 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
114 Typedef declaractions.
116 typedef struct _MSLGroupInfo
119 numImages; /* how many images are in this group */
122 typedef struct _MSLInfo
147 #if defined(MAGICKCORE_XML_DELEGATE)
157 Forward declarations.
159 #if defined(MAGICKCORE_XML_DELEGATE)
160 static MagickBooleanType
161 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
163 static MagickBooleanType
164 SetMSLAttributes(MSLInfo *,const char *,const char *);
167 #if defined(MAGICKCORE_XML_DELEGATE)
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 % R e a d M S L I m a g e %
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
181 % It allocates the memory necessary for the new Image structure and returns a
182 % pointer to the new image.
184 % The format of the ReadMSLImage method is:
186 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
188 % A description of each parameter follows:
190 % o image_info: the image info.
192 % o exception: return any errors or warnings in this structure.
196 #if defined(__cplusplus) || defined(c_plusplus)
200 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
201 ExceptionInfo *exception)
215 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
216 sans_exception=AcquireExceptionInfo();
217 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
218 sans_exception=DestroyExceptionInfo(sans_exception);
219 if (image != (Image *) NULL)
221 read_info=CloneImageInfo(image_info);
222 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
223 image=ReadImage(read_info,exception);
224 read_info=DestroyImageInfo(read_info);
225 if (image != (Image *) NULL)
226 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
230 static int IsPathDirectory(const char *path)
238 if ((path == (const char *) NULL) || (*path == '\0'))
240 status=GetPathAttributes(path,&attributes);
241 if (status == MagickFalse)
243 if (S_ISDIR(attributes.st_mode) == 0)
248 static int MSLIsStandalone(void *context)
254 Is this document tagged standalone?
256 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
257 msl_info=(MSLInfo *) context;
258 return(msl_info->document->standalone == 1);
261 static int MSLHasInternalSubset(void *context)
267 Does this document has an internal subset?
269 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
270 " SAX.MSLHasInternalSubset()");
271 msl_info=(MSLInfo *) context;
272 return(msl_info->document->intSubset != NULL);
275 static int MSLHasExternalSubset(void *context)
281 Does this document has an external subset?
283 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
284 " SAX.MSLHasExternalSubset()");
285 msl_info=(MSLInfo *) context;
286 return(msl_info->document->extSubset != NULL);
289 static void MSLInternalSubset(void *context,const xmlChar *name,
290 const xmlChar *external_id,const xmlChar *system_id)
296 Does this document has an internal subset?
298 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
299 " SAX.internalSubset(%s %s %s)",name,
300 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
301 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
302 msl_info=(MSLInfo *) context;
303 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
306 static xmlParserInputPtr MSLResolveEntity(void *context,
307 const xmlChar *public_id,const xmlChar *system_id)
316 Special entity resolver, better left to the parser, it has more
317 context than the application layer. The default behaviour is to
318 not resolve the entities, in that case the ENTITY_REF nodes are
319 built in the structure (and the parameter values).
321 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
322 " SAX.resolveEntity(%s, %s)",
323 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
324 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
325 msl_info=(MSLInfo *) context;
326 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
327 public_id,msl_info->parser);
331 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
337 Get an entity by name.
339 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
340 " SAX.MSLGetEntity(%s)",(const char *) name);
341 msl_info=(MSLInfo *) context;
342 return(xmlGetDocEntity(msl_info->document,name));
345 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
351 Get a parameter entity by name.
353 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
354 " SAX.getParameterEntity(%s)",(const char *) name);
355 msl_info=(MSLInfo *) context;
356 return(xmlGetParameterEntity(msl_info->document,name));
359 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
360 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
366 An entity definition has been parsed.
368 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
369 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
370 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
371 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
373 msl_info=(MSLInfo *) context;
374 if (msl_info->parser->inSubset == 1)
375 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
378 if (msl_info->parser->inSubset == 2)
379 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
383 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
384 const xmlChar *name,int type,int value,const xmlChar *default_value,
385 xmlEnumerationPtr tree)
398 An attribute definition has been parsed.
400 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
401 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
403 msl_info=(MSLInfo *) context;
404 fullname=(xmlChar *) NULL;
405 prefix=(xmlChar *) NULL;
406 parser=msl_info->parser;
407 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
408 if (parser->inSubset == 1)
409 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
410 element,fullname,prefix,(xmlAttributeType) type,
411 (xmlAttributeDefault) value,default_value,tree);
413 if (parser->inSubset == 2)
414 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
415 element,fullname,prefix,(xmlAttributeType) type,
416 (xmlAttributeDefault) value,default_value,tree);
417 if (prefix != (xmlChar *) NULL)
419 if (fullname != (xmlChar *) NULL)
423 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
424 xmlElementContentPtr content)
433 An element definition has been parsed.
435 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
436 " SAX.elementDecl(%s, %d, ...)",name,type);
437 msl_info=(MSLInfo *) context;
438 parser=msl_info->parser;
439 if (parser->inSubset == 1)
440 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
441 name,(xmlElementTypeVal) type,content);
443 if (parser->inSubset == 2)
444 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
445 name,(xmlElementTypeVal) type,content);
448 static void MSLNotationDeclaration(void *context,const xmlChar *name,
449 const xmlChar *public_id,const xmlChar *system_id)
458 What to do when a notation declaration has been parsed.
460 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
461 " SAX.notationDecl(%s, %s, %s)",name,
462 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
463 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
464 msl_info=(MSLInfo *) context;
465 parser=msl_info->parser;
466 if (parser->inSubset == 1)
467 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
468 name,public_id,system_id);
470 if (parser->inSubset == 2)
471 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
472 name,public_id,system_id);
475 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
476 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
482 What to do when an unparsed entity declaration is parsed.
484 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
485 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
486 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
487 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
489 msl_info=(MSLInfo *) context;
490 (void) xmlAddDocEntity(msl_info->document,name,
491 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
495 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
501 Receive the document locator at startup, actually xmlDefaultSAXLocator.
503 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
504 " SAX.setDocumentLocator()\n");
506 msl_info=(MSLInfo *) context;
510 static void MSLStartDocument(void *context)
519 Called when the document start being processed.
521 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
522 " SAX.startDocument()");
523 msl_info=(MSLInfo *) context;
524 parser=msl_info->parser;
525 msl_info->document=xmlNewDoc(parser->version);
526 if (msl_info->document == (xmlDocPtr) NULL)
528 if (parser->encoding == NULL)
529 msl_info->document->encoding=NULL;
531 msl_info->document->encoding=xmlStrdup(parser->encoding);
532 msl_info->document->standalone=parser->standalone;
535 static void MSLEndDocument(void *context)
541 Called when the document end has been detected.
543 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
544 msl_info=(MSLInfo *) context;
545 if (msl_info->content != (char *) NULL)
546 msl_info->content=DestroyString(msl_info->content);
549 static void MSLPushImage(MSLInfo *msl_info,Image *image)
554 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
555 assert(msl_info != (MSLInfo *) NULL);
558 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
559 (n+1),sizeof(*msl_info->image_info));
560 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
561 (n+1),sizeof(*msl_info->draw_info));
562 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
563 (n+1),sizeof(*msl_info->attributes));
564 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
565 sizeof(*msl_info->image));
566 if ((msl_info->image_info == (ImageInfo **) NULL) ||
567 (msl_info->draw_info == (DrawInfo **) NULL) ||
568 (msl_info->attributes == (Image **) NULL) ||
569 (msl_info->image == (Image **) NULL))
570 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
571 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
572 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
573 msl_info->draw_info[n-1]);
574 if (image == (Image *) NULL)
575 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
576 msl_info->exception);
578 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
579 msl_info->exception);
580 msl_info->image[n]=(Image *) image;
581 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
582 (msl_info->attributes[n] == (Image *) NULL))
583 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
584 if (msl_info->number_groups != 0)
585 msl_info->group_info[msl_info->number_groups-1].numImages++;
588 static void MSLPopImage(MSLInfo *msl_info)
590 if (msl_info->number_groups != 0)
592 if (msl_info->image[msl_info->n] != (Image *) NULL)
593 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
594 msl_info->attributes[msl_info->n]=DestroyImage(
595 msl_info->attributes[msl_info->n]);
596 msl_info->image_info[msl_info->n]=DestroyImageInfo(
597 msl_info->image_info[msl_info->n]);
601 static void MSLStartElement(void *context,const xmlChar *tag,
602 const xmlChar **attributes)
661 Called when an opening tag has been processed.
663 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
664 " SAX.startElement(%s",tag);
665 GetExceptionInfo(&exception);
666 msl_info=(MSLInfo *) context;
668 keyword=(const char *) NULL;
670 SetGeometryInfo(&geometry_info);
671 channel=DefaultChannels;
677 if (LocaleCompare((const char *) tag,"add-noise") == 0)
688 if (msl_info->image[n] == (Image *) NULL)
690 ThrowMSLException(OptionError,"NoImagesDefined",
695 if (attributes != (const xmlChar **) NULL)
696 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
698 keyword=(const char *) attributes[i++];
699 attribute=InterpretImageProperties(msl_info->image_info[n],
700 msl_info->attributes[n],(const char *) attributes[i],
702 CloneString(&value,attribute);
708 if (LocaleCompare(keyword,"channel") == 0)
710 option=ParseChannelOption(value);
712 ThrowMSLException(OptionError,"UnrecognizedChannelType",
714 channel=(ChannelType) option;
717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
724 if (LocaleCompare(keyword,"noise") == 0)
726 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
729 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
731 noise=(NoiseType) option;
734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
746 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
747 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
748 msl_info->exception);
749 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
750 if (noise_image == (Image *) NULL)
752 msl_info->image[n]=DestroyImage(msl_info->image[n]);
753 msl_info->image[n]=noise_image;
756 if (LocaleCompare((const char *) tag,"annotate") == 0)
764 if (msl_info->image[n] == (Image *) NULL)
766 ThrowMSLException(OptionError,"NoImagesDefined",
770 draw_info=CloneDrawInfo(msl_info->image_info[n],
771 msl_info->draw_info[n]);
773 current=draw_info->affine;
774 GetAffineMatrix(&affine);
775 if (attributes != (const xmlChar **) NULL)
776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
778 keyword=(const char *) attributes[i++];
779 attribute=InterpretImageProperties(msl_info->image_info[n],
780 msl_info->attributes[n],(const char *) attributes[i],
782 CloneString(&value,attribute);
788 if (LocaleCompare(keyword,"affine") == 0)
794 draw_info->affine.sx=StringToDouble(p,&p);
797 draw_info->affine.rx=StringToDouble(p,&p);
800 draw_info->affine.ry=StringToDouble(p,&p);
803 draw_info->affine.sy=StringToDouble(p,&p);
806 draw_info->affine.tx=StringToDouble(p,&p);
809 draw_info->affine.ty=StringToDouble(p,&p);
812 if (LocaleCompare(keyword,"align") == 0)
814 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
817 ThrowMSLException(OptionError,"UnrecognizedAlignType",
819 draw_info->align=(AlignType) option;
822 if (LocaleCompare(keyword,"antialias") == 0)
824 option=ParseCommandOption(MagickBooleanOptions,
827 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
829 draw_info->stroke_antialias=(MagickBooleanType) option;
830 draw_info->text_antialias=(MagickBooleanType) option;
833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
840 if (LocaleCompare(keyword,"density") == 0)
842 CloneString(&draw_info->density,value);
845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
852 if (LocaleCompare(keyword,"encoding") == 0)
854 CloneString(&draw_info->encoding,value);
857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
864 if (LocaleCompare(keyword, "fill") == 0)
866 (void) QueryColorCompliance(value,AllCompliance,
867 &draw_info->fill,&exception);
870 if (LocaleCompare(keyword,"family") == 0)
872 CloneString(&draw_info->family,value);
875 if (LocaleCompare(keyword,"font") == 0)
877 CloneString(&draw_info->font,value);
880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
887 if (LocaleCompare(keyword,"geometry") == 0)
889 flags=ParseGravityGeometry(msl_info->image[n],value,
890 &geometry,&exception);
893 if (LocaleCompare(keyword,"gravity") == 0)
895 option=ParseCommandOption(MagickGravityOptions,
898 ThrowMSLException(OptionError,"UnrecognizedGravityType",
900 draw_info->gravity=(GravityType) option;
903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
910 if (LocaleCompare(keyword,"pointsize") == 0)
912 draw_info->pointsize=StringToDouble(value,(char **) NULL);
915 ThrowMSLException(OptionError,"UnrecognizedAttribute",
922 if (LocaleCompare(keyword,"rotate") == 0)
924 angle=StringToDouble(value,(char **) NULL);
925 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
926 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
927 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
928 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
931 ThrowMSLException(OptionError,"UnrecognizedAttribute",
938 if (LocaleCompare(keyword,"scale") == 0)
940 flags=ParseGeometry(value,&geometry_info);
941 if ((flags & SigmaValue) == 0)
942 geometry_info.sigma=1.0;
943 affine.sx=geometry_info.rho;
944 affine.sy=geometry_info.sigma;
947 if (LocaleCompare(keyword,"skewX") == 0)
949 angle=StringToDouble(value,(char **) NULL);
950 affine.ry=tan(DegreesToRadians(fmod((double) angle,
954 if (LocaleCompare(keyword,"skewY") == 0)
956 angle=StringToDouble(value,(char **) NULL);
957 affine.rx=tan(DegreesToRadians(fmod((double) angle,
961 if (LocaleCompare(keyword,"stretch") == 0)
963 option=ParseCommandOption(MagickStretchOptions,
966 ThrowMSLException(OptionError,"UnrecognizedStretchType",
968 draw_info->stretch=(StretchType) option;
971 if (LocaleCompare(keyword, "stroke") == 0)
973 (void) QueryColorCompliance(value,AllCompliance,
974 &draw_info->stroke,&exception);
977 if (LocaleCompare(keyword,"strokewidth") == 0)
979 draw_info->stroke_width=StringToLong(value);
982 if (LocaleCompare(keyword,"style") == 0)
984 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
987 ThrowMSLException(OptionError,"UnrecognizedStyleType",
989 draw_info->style=(StyleType) option;
992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
999 if (LocaleCompare(keyword,"text") == 0)
1001 CloneString(&draw_info->text,value);
1004 if (LocaleCompare(keyword,"translate") == 0)
1006 flags=ParseGeometry(value,&geometry_info);
1007 if ((flags & SigmaValue) == 0)
1008 geometry_info.sigma=1.0;
1009 affine.tx=geometry_info.rho;
1010 affine.ty=geometry_info.sigma;
1013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1020 if (LocaleCompare(keyword, "undercolor") == 0)
1022 (void) QueryColorCompliance(value,AllCompliance,
1023 &draw_info->undercolor,&exception);
1026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1033 if (LocaleCompare(keyword,"weight") == 0)
1035 draw_info->weight=StringToLong(value);
1038 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1045 if (LocaleCompare(keyword,"x") == 0)
1047 geometry.x=StringToLong(value);
1050 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1057 if (LocaleCompare(keyword,"y") == 0)
1059 geometry.y=StringToLong(value);
1062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1068 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1074 (void) FormatLocaleString(text,MaxTextExtent,
1075 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1076 geometry.height,(double) geometry.x,(double) geometry.y);
1077 CloneString(&draw_info->geometry,text);
1078 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1079 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1080 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1081 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1082 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1084 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1086 (void) AnnotateImage(msl_info->image[n],draw_info,
1087 msl_info->exception);
1088 draw_info=DestroyDrawInfo(draw_info);
1091 if (LocaleCompare((const char *) tag,"append") == 0)
1099 if (msl_info->image[n] == (Image *) NULL)
1101 ThrowMSLException(OptionError,"NoImagesDefined",
1102 (const char *) tag);
1106 if (attributes != (const xmlChar **) NULL)
1107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1109 keyword=(const char *) attributes[i++];
1110 attribute=InterpretImageProperties(msl_info->image_info[n],
1111 msl_info->attributes[n],(const char *) attributes[i],
1113 CloneString(&value,attribute);
1119 if (LocaleCompare(keyword,"stack") == 0)
1121 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1124 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1126 stack=(MagickBooleanType) option;
1129 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1135 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1141 append_image=AppendImages(msl_info->image[n],stack,
1142 msl_info->exception);
1143 if (append_image == (Image *) NULL)
1145 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1146 msl_info->image[n]=append_image;
1149 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1155 if (LocaleCompare((const char *) tag,"blur") == 0)
1163 if (msl_info->image[n] == (Image *) NULL)
1165 ThrowMSLException(OptionError,"NoImagesDefined",
1166 (const char *) tag);
1169 if (attributes != (const xmlChar **) NULL)
1170 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1172 keyword=(const char *) attributes[i++];
1173 attribute=InterpretImageProperties(msl_info->image_info[n],
1174 msl_info->attributes[n],(const char *) attributes[i],
1176 CloneString(&value,attribute);
1182 if (LocaleCompare(keyword,"channel") == 0)
1184 option=ParseChannelOption(value);
1186 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1188 channel=(ChannelType) option;
1191 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1198 if (LocaleCompare(keyword,"geometry") == 0)
1200 flags=ParseGeometry(value,&geometry_info);
1201 if ((flags & SigmaValue) == 0)
1202 geometry_info.sigma=1.0;
1205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1212 if (LocaleCompare(keyword,"radius") == 0)
1214 geometry_info.rho=StringToDouble(value,(char **) NULL);
1217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1224 if (LocaleCompare(keyword,"sigma") == 0)
1226 geometry_info.sigma=StringToLong(value);
1229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1235 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1241 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1242 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1243 geometry_info.sigma,geometry_info.xi,
1244 msl_info->exception);
1245 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
1246 if (blur_image == (Image *) NULL)
1248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1249 msl_info->image[n]=blur_image;
1252 if (LocaleCompare((const char *) tag,"border") == 0)
1260 if (msl_info->image[n] == (Image *) NULL)
1262 ThrowMSLException(OptionError,"NoImagesDefined",
1263 (const char *) tag);
1266 SetGeometry(msl_info->image[n],&geometry);
1267 if (attributes != (const xmlChar **) NULL)
1268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1270 keyword=(const char *) attributes[i++];
1271 attribute=InterpretImageProperties(msl_info->image_info[n],
1272 msl_info->attributes[n],(const char *) attributes[i],
1274 CloneString(&value,attribute);
1280 if (LocaleCompare(keyword,"compose") == 0)
1282 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1285 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1287 msl_info->image[n]->compose=(CompositeOperator) option;
1290 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1297 if (LocaleCompare(keyword, "fill") == 0)
1299 (void) QueryColorCompliance(value,AllCompliance,
1300 &msl_info->image[n]->border_color,&exception);
1303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1310 if (LocaleCompare(keyword,"geometry") == 0)
1312 flags=ParsePageGeometry(msl_info->image[n],value,
1313 &geometry,&exception);
1314 if ((flags & HeightValue) == 0)
1315 geometry.height=geometry.width;
1318 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1325 if (LocaleCompare(keyword,"height") == 0)
1327 geometry.height=StringToLong(value);
1330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1337 if (LocaleCompare(keyword,"width") == 0)
1339 geometry.width=StringToLong(value);
1342 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1348 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1354 border_image=BorderImage(msl_info->image[n],&geometry,
1355 msl_info->image[n]->compose,msl_info->exception);
1356 if (border_image == (Image *) NULL)
1358 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1359 msl_info->image[n]=border_image;
1362 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1367 if (LocaleCompare((const char *) tag,"colorize") == 0)
1370 blend[MaxTextExtent];
1381 if (msl_info->image[n] == (Image *) NULL)
1383 ThrowMSLException(OptionError,"NoImagesDefined",
1384 (const char *) tag);
1387 GetPixelInfo(msl_info->image[n],&target);
1388 (void) CopyMagickString(blend,"100",MaxTextExtent);
1389 if (attributes != (const xmlChar **) NULL)
1390 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1392 keyword=(const char *) attributes[i++];
1393 attribute=InterpretImageProperties(msl_info->image_info[n],
1394 msl_info->attributes[n],(const char *) attributes[i],
1396 CloneString(&value,attribute);
1402 if (LocaleCompare(keyword,"blend") == 0)
1404 (void) CopyMagickString(blend,value,MaxTextExtent);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 if (LocaleCompare(keyword,"fill") == 0)
1416 (void) QueryColorCompliance(value,AllCompliance,
1417 &target,msl_info->exception);
1420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1432 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1433 msl_info->exception);
1434 if (colorize_image == (Image *) NULL)
1436 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1437 msl_info->image[n]=colorize_image;
1440 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1446 if (msl_info->image[n] == (Image *) NULL)
1448 ThrowMSLException(OptionError,"NoImagesDefined",
1449 (const char *) tag);
1453 NOTE: charcoal can have no attributes, since we use all the defaults!
1455 if (attributes != (const xmlChar **) NULL)
1457 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1459 keyword=(const char *) attributes[i++];
1460 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1461 msl_info->attributes[n],(const char *) attributes[i],&exception));
1467 if (LocaleCompare(keyword, "bias") == 0)
1469 bias=StringToDouble(value,(char **) NULL);
1472 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1478 if (LocaleCompare(keyword,"radius") == 0)
1480 radius=StringToDouble(value,(char **) NULL);
1483 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 if (LocaleCompare(keyword,"sigma") == 0)
1491 sigma = StringToLong( value );
1494 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1499 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1513 newImage=CharcoalImage(msl_info->image[n],radius,sigma,bias,
1514 msl_info->exception);
1515 if (newImage == (Image *) NULL)
1517 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1518 msl_info->image[n]=newImage;
1522 if (LocaleCompare((const char *) tag,"chop") == 0)
1530 if (msl_info->image[n] == (Image *) NULL)
1532 ThrowMSLException(OptionError,"NoImagesDefined",
1533 (const char *) tag);
1536 SetGeometry(msl_info->image[n],&geometry);
1537 if (attributes != (const xmlChar **) NULL)
1538 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1540 keyword=(const char *) attributes[i++];
1541 attribute=InterpretImageProperties(msl_info->image_info[n],
1542 msl_info->attributes[n],(const char *) attributes[i],
1544 CloneString(&value,attribute);
1550 if (LocaleCompare(keyword,"geometry") == 0)
1552 flags=ParsePageGeometry(msl_info->image[n],value,
1553 &geometry,&exception);
1554 if ((flags & HeightValue) == 0)
1555 geometry.height=geometry.width;
1558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1565 if (LocaleCompare(keyword,"height") == 0)
1567 geometry.height=StringToLong(value);
1570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1577 if (LocaleCompare(keyword,"width") == 0)
1579 geometry.width=StringToLong(value);
1582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1589 if (LocaleCompare(keyword,"x") == 0)
1591 geometry.x=StringToLong(value);
1594 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1601 if (LocaleCompare(keyword,"y") == 0)
1603 geometry.y=StringToLong(value);
1606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1618 chop_image=ChopImage(msl_info->image[n],&geometry,
1619 msl_info->exception);
1620 if (chop_image == (Image *) NULL)
1622 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1623 msl_info->image[n]=chop_image;
1626 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1635 Color floodfill image.
1637 if (msl_info->image[n] == (Image *) NULL)
1639 ThrowMSLException(OptionError,"NoImagesDefined",
1640 (const char *) tag);
1643 draw_info=CloneDrawInfo(msl_info->image_info[n],
1644 msl_info->draw_info[n]);
1645 SetGeometry(msl_info->image[n],&geometry);
1646 paint_method=FloodfillMethod;
1647 if (attributes != (const xmlChar **) NULL)
1648 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1650 keyword=(const char *) attributes[i++];
1651 attribute=InterpretImageProperties(msl_info->image_info[n],
1652 msl_info->attributes[n],(const char *) attributes[i],
1654 CloneString(&value,attribute);
1660 if (LocaleCompare(keyword,"bordercolor") == 0)
1662 (void) QueryColorCompliance(value,AllCompliance,
1663 &target,&exception);
1664 paint_method=FillToBorderMethod;
1667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1674 if (LocaleCompare(keyword,"fill") == 0)
1676 (void) QueryColorCompliance(value,AllCompliance,
1677 &draw_info->fill,&exception);
1680 if (LocaleCompare(keyword,"fuzz") == 0)
1682 msl_info->image[n]->fuzz=StringToDouble(value,
1686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1693 if (LocaleCompare(keyword,"geometry") == 0)
1695 flags=ParsePageGeometry(msl_info->image[n],value,
1696 &geometry,&exception);
1697 if ((flags & HeightValue) == 0)
1698 geometry.height=geometry.width;
1699 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1700 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1711 if (LocaleCompare(keyword,"x") == 0)
1713 geometry.x=StringToLong(value);
1714 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1715 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1726 if (LocaleCompare(keyword,"y") == 0)
1728 geometry.y=StringToLong(value);
1729 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1730 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1746 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1747 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1748 MagickFalse : MagickTrue,msl_info->exception);
1749 draw_info=DestroyDrawInfo(draw_info);
1752 if (LocaleCompare((const char *) tag,"comment") == 0)
1754 if (LocaleCompare((const char *) tag,"composite") == 0)
1757 composite_geometry[MaxTextExtent];
1769 if (msl_info->image[n] == (Image *) NULL)
1771 ThrowMSLException(OptionError,"NoImagesDefined",
1772 (const char *) tag);
1775 composite_image=NewImageList();
1776 compose=OverCompositeOp;
1777 if (attributes != (const xmlChar **) NULL)
1778 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1780 keyword=(const char *) attributes[i++];
1781 attribute=InterpretImageProperties(msl_info->image_info[n],
1782 msl_info->attributes[n],(const char *) attributes[i],
1784 CloneString(&value,attribute);
1790 if (LocaleCompare(keyword,"compose") == 0)
1792 option=ParseCommandOption(MagickComposeOptions,
1795 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1797 compose=(CompositeOperator) option;
1805 if (LocaleCompare(keyword,"image") == 0)
1806 for (j=0; j < msl_info->n; j++)
1811 attribute=GetImageProperty(msl_info->attributes[j],"id",
1813 if ((attribute != (const char *) NULL) &&
1814 (LocaleCompare(attribute,value) == 0))
1816 composite_image=CloneImage(msl_info->image[j],0,0,
1817 MagickFalse,&exception);
1827 if (composite_image == (Image *) NULL)
1829 rotate_image=NewImageList();
1830 SetGeometry(msl_info->image[n],&geometry);
1831 if (attributes != (const xmlChar **) NULL)
1832 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1834 keyword=(const char *) attributes[i++];
1835 attribute=InterpretImageProperties(msl_info->image_info[n],
1836 msl_info->attributes[n],(const char *) attributes[i],
1838 CloneString(&value,attribute);
1844 if (LocaleCompare(keyword,"blend") == 0)
1846 (void) SetImageArtifact(composite_image,
1847 "compose:args",value);
1850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1857 if (LocaleCompare(keyword,"channel") == 0)
1859 option=ParseChannelOption(value);
1861 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1863 channel=(ChannelType) option;
1866 if (LocaleCompare(keyword, "color") == 0)
1868 (void) QueryColorCompliance(value,AllCompliance,
1869 &composite_image->background_color,&exception);
1872 if (LocaleCompare(keyword,"compose") == 0)
1874 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1881 if (LocaleCompare(keyword,"geometry") == 0)
1883 flags=ParsePageGeometry(msl_info->image[n],value,
1884 &geometry,&exception);
1885 if ((flags & HeightValue) == 0)
1886 geometry.height=geometry.width;
1889 if (LocaleCompare(keyword,"gravity") == 0)
1891 option=ParseCommandOption(MagickGravityOptions,
1894 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1896 msl_info->image[n]->gravity=(GravityType) option;
1899 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1906 if (LocaleCompare(keyword,"image") == 0)
1908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1915 if (LocaleCompare(keyword,"mask") == 0)
1916 for (j=0; j < msl_info->n; j++)
1921 attribute=GetImageProperty(msl_info->attributes[j],"id",
1923 if ((attribute != (const char *) NULL) &&
1924 (LocaleCompare(value,value) == 0))
1926 SetImageType(composite_image,TrueColorMatteType,
1928 (void) CompositeImage(composite_image,
1929 CopyOpacityCompositeOp,msl_info->image[j],0,0,
1934 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1941 if (LocaleCompare(keyword,"opacity") == 0)
1956 opacity=StringToLong(value);
1957 if (compose != DissolveCompositeOp)
1959 (void) SetImageAlpha(composite_image,(Quantum)
1960 opacity,&exception);
1963 (void) SetImageArtifact(msl_info->image[n],
1964 "compose:args",value);
1965 if (composite_image->matte != MagickTrue)
1966 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1968 composite_view=AcquireCacheView(composite_image);
1969 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1971 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1972 (ssize_t) composite_image->columns,1,&exception);
1973 for (x=0; x < (ssize_t) composite_image->columns; x++)
1975 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1976 SetPixelAlpha(composite_image,
1977 ClampToQuantum(opacity),q);
1978 q+=GetPixelChannels(composite_image);
1980 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1983 composite_view=DestroyCacheView(composite_view);
1986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1993 if (LocaleCompare(keyword,"rotate") == 0)
1995 rotate_image=RotateImage(composite_image,
1996 StringToDouble(value,(char **) NULL),&exception);
1999 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2006 if (LocaleCompare(keyword,"tile") == 0)
2011 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2014 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2016 tile=(MagickBooleanType) option;
2018 if (rotate_image != (Image *) NULL)
2019 (void) SetImageArtifact(rotate_image,
2020 "compose:outside-overlay","false");
2022 (void) SetImageArtifact(composite_image,
2023 "compose:outside-overlay","false");
2024 image=msl_info->image[n];
2025 height=composite_image->rows;
2026 width=composite_image->columns;
2027 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2028 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2030 if (rotate_image != (Image *) NULL)
2031 (void) CompositeImage(image,compose,rotate_image,
2034 (void) CompositeImage(image,compose,
2035 composite_image,x,y,&exception);
2037 if (rotate_image != (Image *) NULL)
2038 rotate_image=DestroyImage(rotate_image);
2041 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2048 if (LocaleCompare(keyword,"x") == 0)
2050 geometry.x=StringToLong(value);
2053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2060 if (LocaleCompare(keyword,"y") == 0)
2062 geometry.y=StringToLong(value);
2065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2071 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2077 image=msl_info->image[n];
2078 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2079 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2080 (double) composite_image->rows,(double) geometry.x,(double)
2082 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2084 channel_mask=SetPixelChannelMask(image,channel);
2085 if (rotate_image == (Image *) NULL)
2086 CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
2093 geometry.x-=(ssize_t) (rotate_image->columns-
2094 composite_image->columns)/2;
2095 geometry.y-=(ssize_t) (rotate_image->rows-
2096 composite_image->rows)/2;
2097 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
2099 rotate_image=DestroyImage(rotate_image);
2101 (void) SetPixelChannelMask(image,channel_mask);
2102 composite_image=DestroyImage(composite_image);
2105 if (LocaleCompare((const char *) tag,"contrast") == 0)
2113 if (msl_info->image[n] == (Image *) NULL)
2115 ThrowMSLException(OptionError,"NoImagesDefined",
2116 (const char *) tag);
2119 sharpen=MagickFalse;
2120 if (attributes != (const xmlChar **) NULL)
2121 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2123 keyword=(const char *) attributes[i++];
2124 attribute=InterpretImageProperties(msl_info->image_info[n],
2125 msl_info->attributes[n],(const char *) attributes[i],
2127 CloneString(&value,attribute);
2133 if (LocaleCompare(keyword,"sharpen") == 0)
2135 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2138 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2140 sharpen=(MagickBooleanType) option;
2143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2155 (void) ContrastImage(msl_info->image[n],sharpen,
2156 msl_info->exception);
2159 if (LocaleCompare((const char *) tag,"crop") == 0)
2167 if (msl_info->image[n] == (Image *) NULL)
2169 ThrowMSLException(OptionError,"NoImagesDefined",
2170 (const char *) tag);
2173 SetGeometry(msl_info->image[n],&geometry);
2174 if (attributes != (const xmlChar **) NULL)
2175 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2177 keyword=(const char *) attributes[i++];
2178 attribute=InterpretImageProperties(msl_info->image_info[n],
2179 msl_info->attributes[n],(const char *) attributes[i],
2181 CloneString(&value,attribute);
2187 if (LocaleCompare(keyword,"geometry") == 0)
2189 flags=ParseGravityGeometry(msl_info->image[n],value,
2190 &geometry,&exception);
2193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2200 if (LocaleCompare(keyword,"height") == 0)
2202 geometry.height=StringToLong(value);
2205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2212 if (LocaleCompare(keyword,"width") == 0)
2214 geometry.width=StringToLong(value);
2217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2224 if (LocaleCompare(keyword,"x") == 0)
2226 geometry.x=StringToLong(value);
2229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2236 if (LocaleCompare(keyword,"y") == 0)
2238 geometry.y=StringToLong(value);
2241 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2247 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2253 crop_image=CropImage(msl_info->image[n],&geometry,
2254 msl_info->exception);
2255 if (crop_image == (Image *) NULL)
2257 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2258 msl_info->image[n]=crop_image;
2261 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2267 Cycle-colormap image.
2269 if (msl_info->image[n] == (Image *) NULL)
2271 ThrowMSLException(OptionError,"NoImagesDefined",
2272 (const char *) tag);
2276 if (attributes != (const xmlChar **) NULL)
2277 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2279 keyword=(const char *) attributes[i++];
2280 attribute=InterpretImageProperties(msl_info->image_info[n],
2281 msl_info->attributes[n],(const char *) attributes[i],
2283 CloneString(&value,attribute);
2289 if (LocaleCompare(keyword,"display") == 0)
2291 display=StringToLong(value);
2294 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2300 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2306 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2309 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2314 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2322 if (msl_info->image[n] == (Image *) NULL)
2324 ThrowMSLException(OptionError,"NoImagesDefined",
2325 (const char *) tag);
2328 if (attributes != (const xmlChar **) NULL)
2329 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2331 keyword=(const char *) attributes[i++];
2332 attribute=InterpretImageProperties(msl_info->image_info[n],
2333 msl_info->attributes[n],(const char *) attributes[i],
2335 CloneString(&value,attribute);
2336 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2338 despeckle_image=DespeckleImage(msl_info->image[n],
2339 msl_info->exception);
2340 if (despeckle_image == (Image *) NULL)
2342 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2343 msl_info->image[n]=despeckle_image;
2346 if (LocaleCompare((const char *) tag,"display") == 0)
2348 if (msl_info->image[n] == (Image *) NULL)
2350 ThrowMSLException(OptionError,"NoImagesDefined",
2351 (const char *) tag);
2354 if (attributes != (const xmlChar **) NULL)
2355 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2357 keyword=(const char *) attributes[i++];
2358 attribute=InterpretImageProperties(msl_info->image_info[n],
2359 msl_info->attributes[n],(const char *) attributes[i],
2361 CloneString(&value,attribute);
2366 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2372 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2373 msl_info->exception);
2376 if (LocaleCompare((const char *) tag,"draw") == 0)
2379 text[MaxTextExtent];
2384 if (msl_info->image[n] == (Image *) NULL)
2386 ThrowMSLException(OptionError,"NoImagesDefined",
2387 (const char *) tag);
2390 draw_info=CloneDrawInfo(msl_info->image_info[n],
2391 msl_info->draw_info[n]);
2393 current=draw_info->affine;
2394 GetAffineMatrix(&affine);
2395 if (attributes != (const xmlChar **) NULL)
2396 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2398 keyword=(const char *) attributes[i++];
2399 attribute=InterpretImageProperties(msl_info->image_info[n],
2400 msl_info->attributes[n],(const char *) attributes[i],
2402 CloneString(&value,attribute);
2408 if (LocaleCompare(keyword,"affine") == 0)
2414 draw_info->affine.sx=StringToDouble(p,&p);
2417 draw_info->affine.rx=StringToDouble(p,&p);
2420 draw_info->affine.ry=StringToDouble(p,&p);
2423 draw_info->affine.sy=StringToDouble(p,&p);
2426 draw_info->affine.tx=StringToDouble(p,&p);
2429 draw_info->affine.ty=StringToDouble(p,&p);
2432 if (LocaleCompare(keyword,"align") == 0)
2434 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2437 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2439 draw_info->align=(AlignType) option;
2442 if (LocaleCompare(keyword,"antialias") == 0)
2444 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2447 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2449 draw_info->stroke_antialias=(MagickBooleanType) option;
2450 draw_info->text_antialias=(MagickBooleanType) option;
2453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2460 if (LocaleCompare(keyword,"density") == 0)
2462 CloneString(&draw_info->density,value);
2465 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2472 if (LocaleCompare(keyword,"encoding") == 0)
2474 CloneString(&draw_info->encoding,value);
2477 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2484 if (LocaleCompare(keyword, "fill") == 0)
2486 (void) QueryColorCompliance(value,AllCompliance,
2487 &draw_info->fill,&exception);
2490 if (LocaleCompare(keyword,"family") == 0)
2492 CloneString(&draw_info->family,value);
2495 if (LocaleCompare(keyword,"font") == 0)
2497 CloneString(&draw_info->font,value);
2500 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2507 if (LocaleCompare(keyword,"geometry") == 0)
2509 flags=ParsePageGeometry(msl_info->image[n],value,
2510 &geometry,&exception);
2511 if ((flags & HeightValue) == 0)
2512 geometry.height=geometry.width;
2515 if (LocaleCompare(keyword,"gravity") == 0)
2517 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2520 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2522 draw_info->gravity=(GravityType) option;
2525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2532 if (LocaleCompare(keyword,"primitive") == 0)
2534 CloneString(&draw_info->primitive,value);
2537 if (LocaleCompare(keyword,"pointsize") == 0)
2539 draw_info->pointsize=StringToDouble(value,
2543 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2550 if (LocaleCompare(keyword,"rotate") == 0)
2552 angle=StringToDouble(value,(char **) NULL);
2553 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2554 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2555 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2556 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2566 if (LocaleCompare(keyword,"scale") == 0)
2568 flags=ParseGeometry(value,&geometry_info);
2569 if ((flags & SigmaValue) == 0)
2570 geometry_info.sigma=1.0;
2571 affine.sx=geometry_info.rho;
2572 affine.sy=geometry_info.sigma;
2575 if (LocaleCompare(keyword,"skewX") == 0)
2577 angle=StringToDouble(value,(char **) NULL);
2578 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2581 if (LocaleCompare(keyword,"skewY") == 0)
2583 angle=StringToDouble(value,(char **) NULL);
2584 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2587 if (LocaleCompare(keyword,"stretch") == 0)
2589 option=ParseCommandOption(MagickStretchOptions,
2592 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2594 draw_info->stretch=(StretchType) option;
2597 if (LocaleCompare(keyword, "stroke") == 0)
2599 (void) QueryColorCompliance(value,AllCompliance,
2600 &draw_info->stroke,&exception);
2603 if (LocaleCompare(keyword,"strokewidth") == 0)
2605 draw_info->stroke_width=StringToLong(value);
2608 if (LocaleCompare(keyword,"style") == 0)
2610 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2613 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2615 draw_info->style=(StyleType) option;
2618 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2625 if (LocaleCompare(keyword,"text") == 0)
2627 CloneString(&draw_info->text,value);
2630 if (LocaleCompare(keyword,"translate") == 0)
2632 flags=ParseGeometry(value,&geometry_info);
2633 if ((flags & SigmaValue) == 0)
2634 geometry_info.sigma=1.0;
2635 affine.tx=geometry_info.rho;
2636 affine.ty=geometry_info.sigma;
2639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2646 if (LocaleCompare(keyword, "undercolor") == 0)
2648 (void) QueryColorCompliance(value,AllCompliance,
2649 &draw_info->undercolor,&exception);
2652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2659 if (LocaleCompare(keyword,"weight") == 0)
2661 draw_info->weight=StringToLong(value);
2664 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2671 if (LocaleCompare(keyword,"x") == 0)
2673 geometry.x=StringToLong(value);
2676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2683 if (LocaleCompare(keyword,"y") == 0)
2685 geometry.y=StringToLong(value);
2688 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2700 (void) FormatLocaleString(text,MaxTextExtent,
2701 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2702 geometry.height,(double) geometry.x,(double) geometry.y);
2703 CloneString(&draw_info->geometry,text);
2704 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2705 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2706 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2707 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2708 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2710 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2712 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2713 draw_info=DestroyDrawInfo(draw_info);
2716 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2721 if (LocaleCompare((const char *) tag,"edge") == 0)
2729 if (msl_info->image[n] == (Image *) NULL)
2731 ThrowMSLException(OptionError,"NoImagesDefined",
2732 (const char *) tag);
2735 if (attributes != (const xmlChar **) NULL)
2736 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2738 keyword=(const char *) attributes[i++];
2739 attribute=InterpretImageProperties(msl_info->image_info[n],
2740 msl_info->attributes[n],(const char *) attributes[i],
2742 CloneString(&value,attribute);
2748 if (LocaleCompare(keyword,"geometry") == 0)
2750 flags=ParseGeometry(value,&geometry_info);
2751 if ((flags & SigmaValue) == 0)
2752 geometry_info.sigma=1.0;
2755 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2762 if (LocaleCompare(keyword,"radius") == 0)
2764 geometry_info.rho=StringToDouble(value,(char **) NULL);
2767 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2779 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2780 geometry_info.sigma,msl_info->exception);
2781 if (edge_image == (Image *) NULL)
2783 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2784 msl_info->image[n]=edge_image;
2787 if (LocaleCompare((const char *) tag,"emboss") == 0)
2795 if (msl_info->image[n] == (Image *) NULL)
2797 ThrowMSLException(OptionError,"NoImagesDefined",
2798 (const char *) tag);
2801 if (attributes != (const xmlChar **) NULL)
2802 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2804 keyword=(const char *) attributes[i++];
2805 attribute=InterpretImageProperties(msl_info->image_info[n],
2806 msl_info->attributes[n],(const char *) attributes[i],
2808 CloneString(&value,attribute);
2814 if (LocaleCompare(keyword,"geometry") == 0)
2816 flags=ParseGeometry(value,&geometry_info);
2817 if ((flags & SigmaValue) == 0)
2818 geometry_info.sigma=1.0;
2821 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2828 if (LocaleCompare(keyword,"radius") == 0)
2830 geometry_info.rho=StringToDouble(value,
2834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2841 if (LocaleCompare(keyword,"sigma") == 0)
2843 geometry_info.sigma=StringToLong(value);
2846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2852 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2858 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2859 geometry_info.sigma,msl_info->exception);
2860 if (emboss_image == (Image *) NULL)
2862 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2863 msl_info->image[n]=emboss_image;
2866 if (LocaleCompare((const char *) tag,"enhance") == 0)
2874 if (msl_info->image[n] == (Image *) NULL)
2876 ThrowMSLException(OptionError,"NoImagesDefined",
2877 (const char *) tag);
2880 if (attributes != (const xmlChar **) NULL)
2881 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2883 keyword=(const char *) attributes[i++];
2884 attribute=InterpretImageProperties(msl_info->image_info[n],
2885 msl_info->attributes[n],(const char *) attributes[i],
2887 CloneString(&value,attribute);
2888 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2890 enhance_image=EnhanceImage(msl_info->image[n],
2891 msl_info->exception);
2892 if (enhance_image == (Image *) NULL)
2894 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2895 msl_info->image[n]=enhance_image;
2898 if (LocaleCompare((const char *) tag,"equalize") == 0)
2903 if (msl_info->image[n] == (Image *) NULL)
2905 ThrowMSLException(OptionError,"NoImagesDefined",
2906 (const char *) tag);
2909 if (attributes != (const xmlChar **) NULL)
2910 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2912 keyword=(const char *) attributes[i++];
2913 attribute=InterpretImageProperties(msl_info->image_info[n],
2914 msl_info->attributes[n],(const char *) attributes[i],
2916 CloneString(&value,attribute);
2921 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2927 (void) EqualizeImage(msl_info->image[n],
2928 msl_info->exception);
2931 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2936 if (LocaleCompare((const char *) tag, "flatten") == 0)
2938 if (msl_info->image[n] == (Image *) NULL)
2940 ThrowMSLException(OptionError,"NoImagesDefined",
2941 (const char *) tag);
2945 /* no attributes here */
2947 /* process the image */
2952 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2953 msl_info->exception);
2954 if (newImage == (Image *) NULL)
2956 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2957 msl_info->image[n]=newImage;
2961 if (LocaleCompare((const char *) tag,"flip") == 0)
2969 if (msl_info->image[n] == (Image *) NULL)
2971 ThrowMSLException(OptionError,"NoImagesDefined",
2972 (const char *) tag);
2975 if (attributes != (const xmlChar **) NULL)
2976 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2978 keyword=(const char *) attributes[i++];
2979 attribute=InterpretImageProperties(msl_info->image_info[n],
2980 msl_info->attributes[n],(const char *) attributes[i],
2982 CloneString(&value,attribute);
2983 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2985 flip_image=FlipImage(msl_info->image[n],
2986 msl_info->exception);
2987 if (flip_image == (Image *) NULL)
2989 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2990 msl_info->image[n]=flip_image;
2993 if (LocaleCompare((const char *) tag,"flop") == 0)
3001 if (msl_info->image[n] == (Image *) NULL)
3003 ThrowMSLException(OptionError,"NoImagesDefined",
3004 (const char *) tag);
3007 if (attributes != (const xmlChar **) NULL)
3008 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3010 keyword=(const char *) attributes[i++];
3011 attribute=InterpretImageProperties(msl_info->image_info[n],
3012 msl_info->attributes[n],(const char *) attributes[i],
3014 CloneString(&value,attribute);
3015 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3017 flop_image=FlopImage(msl_info->image[n],
3018 msl_info->exception);
3019 if (flop_image == (Image *) NULL)
3021 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3022 msl_info->image[n]=flop_image;
3025 if (LocaleCompare((const char *) tag,"frame") == 0)
3036 if (msl_info->image[n] == (Image *) NULL)
3038 ThrowMSLException(OptionError,"NoImagesDefined",
3039 (const char *) tag);
3042 SetGeometry(msl_info->image[n],&geometry);
3043 if (attributes != (const xmlChar **) NULL)
3044 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3046 keyword=(const char *) attributes[i++];
3047 attribute=InterpretImageProperties(msl_info->image_info[n],
3048 msl_info->attributes[n],(const char *) attributes[i],
3050 CloneString(&value,attribute);
3056 if (LocaleCompare(keyword,"compose") == 0)
3058 option=ParseCommandOption(MagickComposeOptions,
3061 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3063 msl_info->image[n]->compose=(CompositeOperator) option;
3066 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3073 if (LocaleCompare(keyword, "fill") == 0)
3075 (void) QueryColorCompliance(value,AllCompliance,
3076 &msl_info->image[n]->matte_color,&exception);
3079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3086 if (LocaleCompare(keyword,"geometry") == 0)
3088 flags=ParsePageGeometry(msl_info->image[n],value,
3089 &geometry,&exception);
3090 if ((flags & HeightValue) == 0)
3091 geometry.height=geometry.width;
3092 frame_info.width=geometry.width;
3093 frame_info.height=geometry.height;
3094 frame_info.outer_bevel=geometry.x;
3095 frame_info.inner_bevel=geometry.y;
3098 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3105 if (LocaleCompare(keyword,"height") == 0)
3107 frame_info.height=StringToLong(value);
3110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3117 if (LocaleCompare(keyword,"inner") == 0)
3119 frame_info.inner_bevel=StringToLong(value);
3122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3129 if (LocaleCompare(keyword,"outer") == 0)
3131 frame_info.outer_bevel=StringToLong(value);
3134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3141 if (LocaleCompare(keyword,"width") == 0)
3143 frame_info.width=StringToLong(value);
3146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3158 frame_info.x=(ssize_t) frame_info.width;
3159 frame_info.y=(ssize_t) frame_info.height;
3160 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3161 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3162 frame_image=FrameImage(msl_info->image[n],&frame_info,
3163 msl_info->image[n]->compose,msl_info->exception);
3164 if (frame_image == (Image *) NULL)
3166 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3167 msl_info->image[n]=frame_image;
3170 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3175 if (LocaleCompare((const char *) tag,"gamma") == 0)
3178 gamma[MaxTextExtent];
3186 if (msl_info->image[n] == (Image *) NULL)
3188 ThrowMSLException(OptionError,"NoImagesDefined",
3189 (const char *) tag);
3192 channel=UndefinedChannel;
3197 if (attributes != (const xmlChar **) NULL)
3198 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3200 keyword=(const char *) attributes[i++];
3201 attribute=InterpretImageProperties(msl_info->image_info[n],
3202 msl_info->attributes[n],(const char *) attributes[i],
3204 CloneString(&value,attribute);
3210 if (LocaleCompare(keyword,"blue") == 0)
3212 pixel.blue=StringToDouble(value,(char **) NULL);
3215 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3222 if (LocaleCompare(keyword,"channel") == 0)
3224 option=ParseChannelOption(value);
3226 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3228 channel=(ChannelType) option;
3231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3238 if (LocaleCompare(keyword,"gamma") == 0)
3240 (void) CopyMagickString(gamma,value,MaxTextExtent);
3243 if (LocaleCompare(keyword,"green") == 0)
3245 pixel.green=StringToDouble(value,(char **) NULL);
3248 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3255 if (LocaleCompare(keyword,"red") == 0)
3257 pixel.red=StringToDouble(value,(char **) NULL);
3260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3273 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3274 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3275 (void) GammaImage(msl_info->image[n],atof(gamma),
3276 msl_info->exception);
3279 else if (LocaleCompare((const char *) tag,"get") == 0)
3281 if (msl_info->image[n] == (Image *) NULL)
3283 ThrowMSLException(OptionError,"NoImagesDefined",
3284 (const char *) tag);
3287 if (attributes == (const xmlChar **) NULL)
3289 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3291 keyword=(const char *) attributes[i++];
3292 CloneString(&value,(const char *) attributes[i]);
3293 (void) CopyMagickString(key,value,MaxTextExtent);
3299 if (LocaleCompare(keyword,"height") == 0)
3301 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3302 (double) msl_info->image[n]->rows);
3303 (void) SetImageProperty(msl_info->attributes[n],key,value,
3307 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3312 if (LocaleCompare(keyword,"width") == 0)
3314 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3315 (double) msl_info->image[n]->columns);
3316 (void) SetImageProperty(msl_info->attributes[n],key,value,
3320 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3331 else if (LocaleCompare((const char *) tag, "group") == 0)
3333 msl_info->number_groups++;
3334 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3335 msl_info->group_info,msl_info->number_groups+1UL,
3336 sizeof(*msl_info->group_info));
3339 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3344 if (LocaleCompare((const char *) tag,"image") == 0)
3346 MSLPushImage(msl_info,(Image *) NULL);
3347 if (attributes == (const xmlChar **) NULL)
3349 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3351 keyword=(const char *) attributes[i++];
3352 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3353 msl_info->attributes[n],(const char *) attributes[i],&exception));
3359 if (LocaleCompare(keyword,"color") == 0)
3364 (void) CopyMagickString(msl_info->image_info[n]->filename,
3365 "xc:",MaxTextExtent);
3366 (void) ConcatenateMagickString(msl_info->image_info[n]->
3367 filename,value,MaxTextExtent);
3368 next_image=ReadImage(msl_info->image_info[n],&exception);
3369 CatchException(&exception);
3370 if (next_image == (Image *) NULL)
3372 if (msl_info->image[n] == (Image *) NULL)
3373 msl_info->image[n]=next_image;
3380 Link image into image list.
3382 p=msl_info->image[n];
3383 while (p->next != (Image *) NULL)
3384 p=GetNextImageInList(p);
3385 next_image->previous=p;
3390 (void) SetMSLAttributes(msl_info,keyword,value);
3395 (void) SetMSLAttributes(msl_info,keyword,value);
3402 if (LocaleCompare((const char *) tag,"implode") == 0)
3410 if (msl_info->image[n] == (Image *) NULL)
3412 ThrowMSLException(OptionError,"NoImagesDefined",
3413 (const char *) tag);
3416 if (attributes != (const xmlChar **) NULL)
3417 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3419 keyword=(const char *) attributes[i++];
3420 attribute=InterpretImageProperties(msl_info->image_info[n],
3421 msl_info->attributes[n],(const char *) attributes[i],
3423 CloneString(&value,attribute);
3429 if (LocaleCompare(keyword,"amount") == 0)
3431 geometry_info.rho=StringToDouble(value,
3435 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3442 if (LocaleCompare(keyword,"geometry") == 0)
3444 flags=ParseGeometry(value,&geometry_info);
3445 if ((flags & SigmaValue) == 0)
3446 geometry_info.sigma=1.0;
3449 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3461 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3462 msl_info->image[n]->interpolate,msl_info->exception);
3463 if (implode_image == (Image *) NULL)
3465 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3466 msl_info->image[n]=implode_image;
3469 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3474 if (LocaleCompare((const char *) tag,"label") == 0)
3476 if (LocaleCompare((const char *) tag, "level") == 0)
3479 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3481 if (msl_info->image[n] == (Image *) NULL)
3483 ThrowMSLException(OptionError,"NoImagesDefined",
3484 (const char *) tag);
3487 if (attributes == (const xmlChar **) NULL)
3489 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3491 keyword=(const char *) attributes[i++];
3492 CloneString(&value,(const char *) attributes[i]);
3493 (void) CopyMagickString(key,value,MaxTextExtent);
3499 if (LocaleCompare(keyword,"black") == 0)
3501 levelBlack = StringToDouble(value,(char **) NULL);
3504 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3510 if (LocaleCompare(keyword,"gamma") == 0)
3512 levelGamma = StringToDouble(value,(char **) NULL);
3515 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3521 if (LocaleCompare(keyword,"white") == 0)
3523 levelWhite = StringToDouble(value,(char **) NULL);
3526 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3531 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3538 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3539 msl_info->exception);
3546 if (LocaleCompare((const char *) tag,"magnify") == 0)
3554 if (msl_info->image[n] == (Image *) NULL)
3556 ThrowMSLException(OptionError,"NoImagesDefined",
3557 (const char *) tag);
3560 if (attributes != (const xmlChar **) NULL)
3561 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3563 keyword=(const char *) attributes[i++];
3564 attribute=InterpretImageProperties(msl_info->image_info[n],
3565 msl_info->attributes[n],(const char *) attributes[i],
3567 CloneString(&value,attribute);
3568 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3570 magnify_image=MagnifyImage(msl_info->image[n],
3571 msl_info->exception);
3572 if (magnify_image == (Image *) NULL)
3574 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3575 msl_info->image[n]=magnify_image;
3578 if (LocaleCompare((const char *) tag,"map") == 0)
3592 if (msl_info->image[n] == (Image *) NULL)
3594 ThrowMSLException(OptionError,"NoImagesDefined",
3595 (const char *) tag);
3598 affinity_image=NewImageList();
3600 if (attributes != (const xmlChar **) NULL)
3601 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3603 keyword=(const char *) attributes[i++];
3604 attribute=InterpretImageProperties(msl_info->image_info[n],
3605 msl_info->attributes[n],(const char *) attributes[i],
3607 CloneString(&value,attribute);
3613 if (LocaleCompare(keyword,"dither") == 0)
3615 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3618 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3620 dither=(MagickBooleanType) option;
3623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3630 if (LocaleCompare(keyword,"image") == 0)
3631 for (j=0; j < msl_info->n; j++)
3636 attribute=GetImageProperty(msl_info->attributes[j],"id",
3638 if ((attribute != (const char *) NULL) &&
3639 (LocaleCompare(attribute,value) == 0))
3641 affinity_image=CloneImage(msl_info->image[j],0,0,
3642 MagickFalse,&exception);
3650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3656 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3657 quantize_info->dither=dither;
3658 (void) RemapImages(quantize_info,msl_info->image[n],
3659 affinity_image,&exception);
3660 quantize_info=DestroyQuantizeInfo(quantize_info);
3661 affinity_image=DestroyImage(affinity_image);
3664 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3676 Matte floodfill image.
3679 if (msl_info->image[n] == (Image *) NULL)
3681 ThrowMSLException(OptionError,"NoImagesDefined",
3682 (const char *) tag);
3685 SetGeometry(msl_info->image[n],&geometry);
3686 paint_method=FloodfillMethod;
3687 if (attributes != (const xmlChar **) NULL)
3688 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3690 keyword=(const char *) attributes[i++];
3691 attribute=InterpretImageProperties(msl_info->image_info[n],
3692 msl_info->attributes[n],(const char *) attributes[i],
3694 CloneString(&value,attribute);
3700 if (LocaleCompare(keyword,"bordercolor") == 0)
3702 (void) QueryColorCompliance(value,AllCompliance,
3703 &target,&exception);
3704 paint_method=FillToBorderMethod;
3707 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3714 if (LocaleCompare(keyword,"fuzz") == 0)
3716 msl_info->image[n]->fuzz=StringToDouble(value,
3720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3727 if (LocaleCompare(keyword,"geometry") == 0)
3729 flags=ParsePageGeometry(msl_info->image[n],value,
3730 &geometry,&exception);
3731 if ((flags & HeightValue) == 0)
3732 geometry.height=geometry.width;
3733 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3734 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3745 if (LocaleCompare(keyword,"opacity") == 0)
3747 opacity=StringToDouble(value,(char **) NULL);
3750 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3757 if (LocaleCompare(keyword,"x") == 0)
3759 geometry.x=StringToLong(value);
3760 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3761 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3772 if (LocaleCompare(keyword,"y") == 0)
3774 geometry.y=StringToLong(value);
3775 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3776 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3786 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3792 draw_info=CloneDrawInfo(msl_info->image_info[n],
3793 msl_info->draw_info[n]);
3794 draw_info->fill.alpha=ClampToQuantum(opacity);
3795 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3796 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3797 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3798 MagickFalse : MagickTrue,msl_info->exception);
3799 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
3800 draw_info=DestroyDrawInfo(draw_info);
3803 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3809 Median-filter image.
3811 if (msl_info->image[n] == (Image *) NULL)
3813 ThrowMSLException(OptionError,"NoImagesDefined",
3814 (const char *) tag);
3817 if (attributes != (const xmlChar **) NULL)
3818 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3820 keyword=(const char *) attributes[i++];
3821 attribute=InterpretImageProperties(msl_info->image_info[n],
3822 msl_info->attributes[n],(const char *) attributes[i],
3824 CloneString(&value,attribute);
3830 if (LocaleCompare(keyword,"geometry") == 0)
3832 flags=ParseGeometry(value,&geometry_info);
3833 if ((flags & SigmaValue) == 0)
3834 geometry_info.sigma=1.0;
3837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3844 if (LocaleCompare(keyword,"radius") == 0)
3846 geometry_info.rho=StringToDouble(value,
3850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3862 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3863 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3864 msl_info->exception);
3865 if (median_image == (Image *) NULL)
3867 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3868 msl_info->image[n]=median_image;
3871 if (LocaleCompare((const char *) tag,"minify") == 0)
3879 if (msl_info->image[n] == (Image *) NULL)
3881 ThrowMSLException(OptionError,"NoImagesDefined",
3882 (const char *) tag);
3885 if (attributes != (const xmlChar **) NULL)
3886 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3888 keyword=(const char *) attributes[i++];
3889 attribute=InterpretImageProperties(msl_info->image_info[n],
3890 msl_info->attributes[n],(const char *) attributes[i],
3892 CloneString(&value,attribute);
3893 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3895 minify_image=MinifyImage(msl_info->image[n],
3896 msl_info->exception);
3897 if (minify_image == (Image *) NULL)
3899 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3900 msl_info->image[n]=minify_image;
3903 if (LocaleCompare((const char *) tag,"msl") == 0 )
3905 if (LocaleCompare((const char *) tag,"modulate") == 0)
3908 modulate[MaxTextExtent];
3913 if (msl_info->image[n] == (Image *) NULL)
3915 ThrowMSLException(OptionError,"NoImagesDefined",
3916 (const char *) tag);
3919 geometry_info.rho=100.0;
3920 geometry_info.sigma=100.0;
3921 geometry_info.xi=100.0;
3922 if (attributes != (const xmlChar **) NULL)
3923 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3925 keyword=(const char *) attributes[i++];
3926 attribute=InterpretImageProperties(msl_info->image_info[n],
3927 msl_info->attributes[n],(const char *) attributes[i],
3929 CloneString(&value,attribute);
3935 if (LocaleCompare(keyword,"blackness") == 0)
3937 geometry_info.rho=StringToDouble(value,
3941 if (LocaleCompare(keyword,"brightness") == 0)
3943 geometry_info.rho=StringToDouble(value,
3947 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3954 if (LocaleCompare(keyword,"factor") == 0)
3956 flags=ParseGeometry(value,&geometry_info);
3959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3966 if (LocaleCompare(keyword,"hue") == 0)
3968 geometry_info.xi=StringToDouble(value,
3972 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3979 if (LocaleCompare(keyword,"lightness") == 0)
3981 geometry_info.rho=StringToDouble(value,
3985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3992 if (LocaleCompare(keyword,"saturation") == 0)
3994 geometry_info.sigma=StringToDouble(value,
3998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4005 if (LocaleCompare(keyword,"whiteness") == 0)
4007 geometry_info.sigma=StringToDouble(value,
4011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4023 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4024 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4025 (void) ModulateImage(msl_info->image[n],modulate,
4026 msl_info->exception);
4029 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4034 if (LocaleCompare((const char *) tag,"negate") == 0)
4042 if (msl_info->image[n] == (Image *) NULL)
4044 ThrowMSLException(OptionError,"NoImagesDefined",
4045 (const char *) tag);
4049 if (attributes != (const xmlChar **) NULL)
4050 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4052 keyword=(const char *) attributes[i++];
4053 attribute=InterpretImageProperties(msl_info->image_info[n],
4054 msl_info->attributes[n],(const char *) attributes[i],
4056 CloneString(&value,attribute);
4062 if (LocaleCompare(keyword,"channel") == 0)
4064 option=ParseChannelOption(value);
4066 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4068 channel=(ChannelType) option;
4071 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4078 if (LocaleCompare(keyword,"gray") == 0)
4080 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4083 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4085 gray=(MagickBooleanType) option;
4088 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4094 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4100 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4101 (void) NegateImage(msl_info->image[n],gray,
4102 msl_info->exception);
4103 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4106 if (LocaleCompare((const char *) tag,"normalize") == 0)
4111 if (msl_info->image[n] == (Image *) NULL)
4113 ThrowMSLException(OptionError,"NoImagesDefined",
4114 (const char *) tag);
4117 if (attributes != (const xmlChar **) NULL)
4118 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4120 keyword=(const char *) attributes[i++];
4121 attribute=InterpretImageProperties(msl_info->image_info[n],
4122 msl_info->attributes[n],(const char *) attributes[i],
4124 CloneString(&value,attribute);
4130 if (LocaleCompare(keyword,"channel") == 0)
4132 option=ParseChannelOption(value);
4134 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4136 channel=(ChannelType) option;
4139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4145 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4151 (void) NormalizeImage(msl_info->image[n],
4152 msl_info->exception);
4155 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4160 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4168 if (msl_info->image[n] == (Image *) NULL)
4170 ThrowMSLException(OptionError,"NoImagesDefined",
4171 (const char *) tag);
4174 if (attributes != (const xmlChar **) NULL)
4175 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4177 keyword=(const char *) attributes[i++];
4178 attribute=InterpretImageProperties(msl_info->image_info[n],
4179 msl_info->attributes[n],(const char *) attributes[i],
4181 CloneString(&value,attribute);
4187 if (LocaleCompare(keyword,"geometry") == 0)
4189 flags=ParseGeometry(value,&geometry_info);
4190 if ((flags & SigmaValue) == 0)
4191 geometry_info.sigma=1.0;
4194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4201 if (LocaleCompare(keyword,"radius") == 0)
4203 geometry_info.rho=StringToDouble(value,
4207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4219 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4220 geometry_info.sigma,msl_info->exception);
4221 if (paint_image == (Image *) NULL)
4223 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4224 msl_info->image[n]=paint_image;
4227 if (LocaleCompare((const char *) tag,"opaque") == 0)
4236 if (msl_info->image[n] == (Image *) NULL)
4238 ThrowMSLException(OptionError,"NoImagesDefined",
4239 (const char *) tag);
4242 (void) QueryColorCompliance("none",AllCompliance,&target,
4244 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4246 if (attributes != (const xmlChar **) NULL)
4247 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4249 keyword=(const char *) attributes[i++];
4250 attribute=InterpretImageProperties(msl_info->image_info[n],
4251 msl_info->attributes[n],(const char *) attributes[i],
4253 CloneString(&value,attribute);
4259 if (LocaleCompare(keyword,"channel") == 0)
4261 option=ParseChannelOption(value);
4263 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4265 channel=(ChannelType) option;
4268 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4275 if (LocaleCompare(keyword,"fill") == 0)
4277 (void) QueryColorCompliance(value,AllCompliance,
4278 &fill_color,&exception);
4281 if (LocaleCompare(keyword,"fuzz") == 0)
4283 msl_info->image[n]->fuzz=StringToDouble(value,
4287 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4293 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4299 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4300 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4301 MagickFalse,msl_info->exception);
4302 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4305 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4310 if (LocaleCompare((const char *) tag,"print") == 0)
4312 if (attributes == (const xmlChar **) NULL)
4314 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4316 keyword=(const char *) attributes[i++];
4317 attribute=InterpretImageProperties(msl_info->image_info[n],
4318 msl_info->attributes[n],(const char *) attributes[i],
4320 CloneString(&value,attribute);
4326 if (LocaleCompare(keyword,"output") == 0)
4328 (void) FormatLocaleFile(stdout,"%s",value);
4331 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4336 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4343 if (LocaleCompare((const char *) tag, "profile") == 0)
4345 if (msl_info->image[n] == (Image *) NULL)
4347 ThrowMSLException(OptionError,"NoImagesDefined",
4348 (const char *) tag);
4351 if (attributes == (const xmlChar **) NULL)
4353 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4367 keyword=(const char *) attributes[i++];
4368 attribute=InterpretImageProperties(msl_info->image_info[n],
4369 msl_info->attributes[n],(const char *) attributes[i],
4371 CloneString(&value,attribute);
4372 if (*keyword == '+')
4375 Remove a profile from the image.
4377 (void) ProfileImage(msl_info->image[n],keyword,
4378 (const unsigned char *) NULL,0,&exception);
4382 Associate a profile with the image.
4384 profile_info=CloneImageInfo(msl_info->image_info[n]);
4385 profile=GetImageProfile(msl_info->image[n],"iptc");
4386 if (profile != (StringInfo *) NULL)
4387 profile_info->profile=(void *) CloneStringInfo(profile);
4388 profile_image=GetImageCache(profile_info,keyword,&exception);
4389 profile_info=DestroyImageInfo(profile_info);
4390 if (profile_image == (Image *) NULL)
4393 name[MaxTextExtent],
4394 filename[MaxTextExtent];
4402 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4403 (void) CopyMagickString(name,keyword,MaxTextExtent);
4404 for (p=filename; *p != '\0'; p++)
4405 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4406 (IsPathAccessible(keyword) == MagickFalse))
4412 Look for profile name (e.g. name:profile).
4414 (void) CopyMagickString(name,filename,(size_t)
4416 for (q=filename; *q != '\0'; q++)
4420 profile=FileToStringInfo(filename,~0UL,&exception);
4421 if (profile != (StringInfo *) NULL)
4423 (void) ProfileImage(msl_info->image[n],name,
4424 GetStringInfoDatum(profile),(size_t)
4425 GetStringInfoLength(profile),&exception);
4426 profile=DestroyStringInfo(profile);
4430 ResetImageProfileIterator(profile_image);
4431 name=GetNextImageProfile(profile_image);
4432 while (name != (const char *) NULL)
4434 profile=GetImageProfile(profile_image,name);
4435 if (profile != (StringInfo *) NULL)
4436 (void) ProfileImage(msl_info->image[n],name,
4437 GetStringInfoDatum(profile),(size_t)
4438 GetStringInfoLength(profile),&exception);
4439 name=GetNextImageProfile(profile_image);
4441 profile_image=DestroyImage(profile_image);
4445 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4450 if (LocaleCompare((const char *) tag,"quantize") == 0)
4458 if (msl_info->image[n] == (Image *) NULL)
4460 ThrowMSLException(OptionError,"NoImagesDefined",
4461 (const char *) tag);
4464 GetQuantizeInfo(&quantize_info);
4465 if (attributes != (const xmlChar **) NULL)
4466 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4468 keyword=(const char *) attributes[i++];
4469 attribute=InterpretImageProperties(msl_info->image_info[n],
4470 msl_info->attributes[n],(const char *) attributes[i],
4472 CloneString(&value,attribute);
4478 if (LocaleCompare(keyword,"colors") == 0)
4480 quantize_info.number_colors=StringToLong(value);
4483 if (LocaleCompare(keyword,"colorspace") == 0)
4485 option=ParseCommandOption(MagickColorspaceOptions,
4488 ThrowMSLException(OptionError,
4489 "UnrecognizedColorspaceType",value);
4490 quantize_info.colorspace=(ColorspaceType) option;
4493 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4500 if (LocaleCompare(keyword,"dither") == 0)
4502 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4505 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4507 quantize_info.dither=(MagickBooleanType) option;
4510 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4517 if (LocaleCompare(keyword,"measure") == 0)
4519 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4522 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4524 quantize_info.measure_error=(MagickBooleanType) option;
4527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4534 if (LocaleCompare(keyword,"treedepth") == 0)
4536 quantize_info.tree_depth=StringToLong(value);
4539 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4545 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4551 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4554 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4557 text[MaxTextExtent];
4568 draw_info=CloneDrawInfo(msl_info->image_info[n],
4569 msl_info->draw_info[n]);
4571 current=draw_info->affine;
4572 GetAffineMatrix(&affine);
4573 if (attributes != (const xmlChar **) NULL)
4574 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4576 keyword=(const char *) attributes[i++];
4577 attribute=InterpretImageProperties(msl_info->image_info[n],
4578 msl_info->attributes[n],(const char *) attributes[i],
4580 CloneString(&value,attribute);
4586 if (LocaleCompare(keyword,"affine") == 0)
4592 draw_info->affine.sx=StringToDouble(p,&p);
4595 draw_info->affine.rx=StringToDouble(p,&p);
4598 draw_info->affine.ry=StringToDouble(p,&p);
4601 draw_info->affine.sy=StringToDouble(p,&p);
4604 draw_info->affine.tx=StringToDouble(p,&p);
4607 draw_info->affine.ty=StringToDouble(p,&p);
4610 if (LocaleCompare(keyword,"align") == 0)
4612 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4615 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4617 draw_info->align=(AlignType) option;
4620 if (LocaleCompare(keyword,"antialias") == 0)
4622 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4625 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4627 draw_info->stroke_antialias=(MagickBooleanType) option;
4628 draw_info->text_antialias=(MagickBooleanType) option;
4631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(keyword,"density") == 0)
4640 CloneString(&draw_info->density,value);
4643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4650 if (LocaleCompare(keyword,"encoding") == 0)
4652 CloneString(&draw_info->encoding,value);
4655 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4662 if (LocaleCompare(keyword, "fill") == 0)
4664 (void) QueryColorCompliance(value,AllCompliance,
4665 &draw_info->fill,&exception);
4668 if (LocaleCompare(keyword,"family") == 0)
4670 CloneString(&draw_info->family,value);
4673 if (LocaleCompare(keyword,"font") == 0)
4675 CloneString(&draw_info->font,value);
4678 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4685 if (LocaleCompare(keyword,"geometry") == 0)
4687 flags=ParsePageGeometry(msl_info->image[n],value,
4688 &geometry,&exception);
4689 if ((flags & HeightValue) == 0)
4690 geometry.height=geometry.width;
4693 if (LocaleCompare(keyword,"gravity") == 0)
4695 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4698 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4700 draw_info->gravity=(GravityType) option;
4703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4710 if (LocaleCompare(keyword,"pointsize") == 0)
4712 draw_info->pointsize=StringToDouble(value,
4716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4723 if (LocaleCompare(keyword,"rotate") == 0)
4725 angle=StringToDouble(value,(char **) NULL);
4726 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4727 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4728 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4729 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4739 if (LocaleCompare(keyword,"scale") == 0)
4741 flags=ParseGeometry(value,&geometry_info);
4742 if ((flags & SigmaValue) == 0)
4743 geometry_info.sigma=1.0;
4744 affine.sx=geometry_info.rho;
4745 affine.sy=geometry_info.sigma;
4748 if (LocaleCompare(keyword,"skewX") == 0)
4750 angle=StringToDouble(value,(char **) NULL);
4751 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4754 if (LocaleCompare(keyword,"skewY") == 0)
4756 angle=StringToDouble(value,(char **) NULL);
4757 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4760 if (LocaleCompare(keyword,"stretch") == 0)
4762 option=ParseCommandOption(MagickStretchOptions,
4765 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4767 draw_info->stretch=(StretchType) option;
4770 if (LocaleCompare(keyword, "stroke") == 0)
4772 (void) QueryColorCompliance(value,AllCompliance,
4773 &draw_info->stroke,&exception);
4776 if (LocaleCompare(keyword,"strokewidth") == 0)
4778 draw_info->stroke_width=StringToLong(value);
4781 if (LocaleCompare(keyword,"style") == 0)
4783 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4786 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4788 draw_info->style=(StyleType) option;
4791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4798 if (LocaleCompare(keyword,"text") == 0)
4800 CloneString(&draw_info->text,value);
4803 if (LocaleCompare(keyword,"translate") == 0)
4805 flags=ParseGeometry(value,&geometry_info);
4806 if ((flags & SigmaValue) == 0)
4807 geometry_info.sigma=1.0;
4808 affine.tx=geometry_info.rho;
4809 affine.ty=geometry_info.sigma;
4812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4819 if (LocaleCompare(keyword, "undercolor") == 0)
4821 (void) QueryColorCompliance(value,AllCompliance,
4822 &draw_info->undercolor,&exception);
4825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4832 if (LocaleCompare(keyword,"weight") == 0)
4834 draw_info->weight=StringToLong(value);
4837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4844 if (LocaleCompare(keyword,"x") == 0)
4846 geometry.x=StringToLong(value);
4849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4856 if (LocaleCompare(keyword,"y") == 0)
4858 geometry.y=StringToLong(value);
4861 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4867 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4873 (void) FormatLocaleString(text,MaxTextExtent,
4874 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4875 geometry.height,(double) geometry.x,(double) geometry.y);
4876 CloneString(&draw_info->geometry,text);
4877 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4878 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4879 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4880 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4881 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4883 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4885 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4886 msl_info->exception);
4887 if (status != MagickFalse)
4892 image=msl_info->attributes[n];
4893 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4894 "%g",metrics.pixels_per_em.x);
4895 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4896 "%g",metrics.pixels_per_em.y);
4897 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4899 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4901 FormatImageProperty(image,"msl:font-metrics.width","%g",
4903 FormatImageProperty(image,"msl:font-metrics.height","%g",
4905 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4906 metrics.max_advance);
4907 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4909 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4911 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4913 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4915 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4917 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4920 draw_info=DestroyDrawInfo(draw_info);
4923 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4928 if (LocaleCompare((const char *) tag,"raise") == 0)
4936 if (msl_info->image[n] == (Image *) NULL)
4938 ThrowMSLException(OptionError,"NoImagesDefined",
4939 (const char *) tag);
4943 SetGeometry(msl_info->image[n],&geometry);
4944 if (attributes != (const xmlChar **) NULL)
4945 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4947 keyword=(const char *) attributes[i++];
4948 attribute=InterpretImageProperties(msl_info->image_info[n],
4949 msl_info->attributes[n],(const char *) attributes[i],
4951 CloneString(&value,attribute);
4957 if (LocaleCompare(keyword,"geometry") == 0)
4959 flags=ParsePageGeometry(msl_info->image[n],value,
4960 &geometry,&exception);
4961 if ((flags & HeightValue) == 0)
4962 geometry.height=geometry.width;
4965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4972 if (LocaleCompare(keyword,"height") == 0)
4974 geometry.height=StringToLong(value);
4977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4984 if (LocaleCompare(keyword,"raise") == 0)
4986 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4989 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4991 raise=(MagickBooleanType) option;
4994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5001 if (LocaleCompare(keyword,"width") == 0)
5003 geometry.width=StringToLong(value);
5006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5018 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5019 msl_info->exception);
5022 if (LocaleCompare((const char *) tag,"read") == 0)
5024 if (attributes == (const xmlChar **) NULL)
5026 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5028 keyword=(const char *) attributes[i++];
5029 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5030 msl_info->attributes[n],(const char *) attributes[i],&exception));
5036 if (LocaleCompare(keyword,"filename") == 0)
5041 (void) CopyMagickString(msl_info->image_info[n]->filename,
5042 value,MaxTextExtent);
5043 image=ReadImage(msl_info->image_info[n],&exception);
5044 CatchException(&exception);
5045 if (image == (Image *) NULL)
5047 AppendImageToList(&msl_info->image[n],image);
5050 (void) SetMSLAttributes(msl_info,keyword,value);
5055 (void) SetMSLAttributes(msl_info,keyword,value);
5062 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5070 if (msl_info->image[n] == (Image *) NULL)
5072 ThrowMSLException(OptionError,"NoImagesDefined",
5073 (const char *) tag);
5076 if (attributes != (const xmlChar **) NULL)
5077 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5079 keyword=(const char *) attributes[i++];
5080 attribute=InterpretImageProperties(msl_info->image_info[n],
5081 msl_info->attributes[n],(const char *) attributes[i],
5083 CloneString(&value,attribute);
5089 if (LocaleCompare(keyword,"geometry") == 0)
5091 flags=ParseGeometry(value,&geometry_info);
5092 if ((flags & SigmaValue) == 0)
5093 geometry_info.sigma=1.0;
5096 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5103 if (LocaleCompare(keyword,"radius") == 0)
5105 geometry_info.rho=StringToDouble(value,
5109 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5115 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5121 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5122 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5123 msl_info->exception);
5124 if (paint_image == (Image *) NULL)
5126 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5127 msl_info->image[n]=paint_image;
5130 else if (LocaleCompare((const char *) tag,"repage") == 0)
5132 /* init the values */
5133 width=msl_info->image[n]->page.width;
5134 height=msl_info->image[n]->page.height;
5135 x=msl_info->image[n]->page.x;
5136 y=msl_info->image[n]->page.y;
5138 if (msl_info->image[n] == (Image *) NULL)
5140 ThrowMSLException(OptionError,"NoImagesDefined",
5141 (const char *) tag);
5144 if (attributes == (const xmlChar **) NULL)
5146 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5148 keyword=(const char *) attributes[i++];
5149 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5150 msl_info->attributes[n],(const char *) attributes[i],&exception));
5156 if (LocaleCompare(keyword,"geometry") == 0)
5164 flags=ParseAbsoluteGeometry(value,&geometry);
5165 if ((flags & WidthValue) != 0)
5167 if ((flags & HeightValue) == 0)
5168 geometry.height=geometry.width;
5169 width=geometry.width;
5170 height=geometry.height;
5172 if ((flags & AspectValue) != 0)
5174 if ((flags & XValue) != 0)
5176 if ((flags & YValue) != 0)
5181 if ((flags & XValue) != 0)
5184 if ((width == 0) && (geometry.x > 0))
5185 width=msl_info->image[n]->columns+geometry.x;
5187 if ((flags & YValue) != 0)
5190 if ((height == 0) && (geometry.y > 0))
5191 height=msl_info->image[n]->rows+geometry.y;
5196 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5202 if (LocaleCompare(keyword,"height") == 0)
5204 height = StringToLong( value );
5207 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5213 if (LocaleCompare(keyword,"width") == 0)
5215 width = StringToLong( value );
5218 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5224 if (LocaleCompare(keyword,"x") == 0)
5226 x = StringToLong( value );
5229 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5235 if (LocaleCompare(keyword,"y") == 0)
5237 y = StringToLong( value );
5240 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5245 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5251 msl_info->image[n]->page.width=width;
5252 msl_info->image[n]->page.height=height;
5253 msl_info->image[n]->page.x=x;
5254 msl_info->image[n]->page.y=y;
5257 else if (LocaleCompare((const char *) tag,"resample") == 0)
5263 if (msl_info->image[n] == (Image *) NULL)
5265 ThrowMSLException(OptionError,"NoImagesDefined",
5266 (const char *) tag);
5269 if (attributes == (const xmlChar **) NULL)
5271 x_resolution=DefaultResolution;
5272 y_resolution=DefaultResolution;
5273 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5275 keyword=(const char *) attributes[i++];
5276 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5277 msl_info->attributes[n],(const char *) attributes[i],&exception));
5282 if (LocaleCompare(keyword,"blur") == 0)
5284 msl_info->image[n]->blur=StringToDouble(value,
5288 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5294 if (LocaleCompare(keyword,"geometry") == 0)
5299 flags=ParseGeometry(value,&geometry_info);
5300 if ((flags & SigmaValue) == 0)
5301 geometry_info.sigma*=geometry_info.rho;
5302 x_resolution=geometry_info.rho;
5303 y_resolution=geometry_info.sigma;
5306 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5312 if (LocaleCompare(keyword,"x-resolution") == 0)
5314 x_resolution=StringToDouble(value,(char **) NULL);
5317 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5323 if (LocaleCompare(keyword,"y-resolution") == 0)
5325 y_resolution=StringToDouble(value,(char **) NULL);
5328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5333 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5349 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5351 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5352 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5353 msl_info->image[n]->resolution.x))+0.5);
5354 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5355 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5356 msl_info->image[n]->resolution.y))+0.5);
5357 resample_image=ResizeImage(msl_info->image[n],width,height,
5358 msl_info->image[n]->filter,msl_info->image[n]->blur,
5359 msl_info->exception);
5360 if (resample_image == (Image *) NULL)
5362 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5363 msl_info->image[n]=resample_image;
5367 if (LocaleCompare((const char *) tag,"resize") == 0)
5381 if (msl_info->image[n] == (Image *) NULL)
5383 ThrowMSLException(OptionError,"NoImagesDefined",
5384 (const char *) tag);
5387 filter=UndefinedFilter;
5389 if (attributes != (const xmlChar **) NULL)
5390 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5392 keyword=(const char *) attributes[i++];
5393 attribute=InterpretImageProperties(msl_info->image_info[n],
5394 msl_info->attributes[n],(const char *) attributes[i],
5396 CloneString(&value,attribute);
5402 if (LocaleCompare(keyword,"filter") == 0)
5404 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5407 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5409 filter=(FilterTypes) option;
5412 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5419 if (LocaleCompare(keyword,"geometry") == 0)
5421 flags=ParseRegionGeometry(msl_info->image[n],value,
5422 &geometry,&exception);
5425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5432 if (LocaleCompare(keyword,"height") == 0)
5434 geometry.height=StringToUnsignedLong(value);
5437 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5444 if (LocaleCompare(keyword,"support") == 0)
5446 blur=StringToDouble(value,(char **) NULL);
5449 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5456 if (LocaleCompare(keyword,"width") == 0)
5458 geometry.width=StringToLong(value);
5461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5473 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5474 geometry.height,filter,blur,msl_info->exception);
5475 if (resize_image == (Image *) NULL)
5477 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5478 msl_info->image[n]=resize_image;
5481 if (LocaleCompare((const char *) tag,"roll") == 0)
5489 if (msl_info->image[n] == (Image *) NULL)
5491 ThrowMSLException(OptionError,"NoImagesDefined",
5492 (const char *) tag);
5495 SetGeometry(msl_info->image[n],&geometry);
5496 if (attributes != (const xmlChar **) NULL)
5497 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5499 keyword=(const char *) attributes[i++];
5500 attribute=InterpretImageProperties(msl_info->image_info[n],
5501 msl_info->attributes[n],(const char *) attributes[i],
5503 CloneString(&value,attribute);
5509 if (LocaleCompare(keyword,"geometry") == 0)
5511 flags=ParsePageGeometry(msl_info->image[n],value,
5512 &geometry,&exception);
5513 if ((flags & HeightValue) == 0)
5514 geometry.height=geometry.width;
5517 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5524 if (LocaleCompare(keyword,"x") == 0)
5526 geometry.x=StringToLong(value);
5529 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5536 if (LocaleCompare(keyword,"y") == 0)
5538 geometry.y=StringToLong(value);
5541 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5553 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5554 msl_info->exception);
5555 if (roll_image == (Image *) NULL)
5557 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5558 msl_info->image[n]=roll_image;
5561 else if (LocaleCompare((const char *) tag,"roll") == 0)
5563 /* init the values */
5564 width=msl_info->image[n]->columns;
5565 height=msl_info->image[n]->rows;
5568 if (msl_info->image[n] == (Image *) NULL)
5570 ThrowMSLException(OptionError,"NoImagesDefined",
5571 (const char *) tag);
5574 if (attributes == (const xmlChar **) NULL)
5576 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5578 keyword=(const char *) attributes[i++];
5579 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5580 msl_info->attributes[n],(const char *) attributes[i],&exception));
5586 if (LocaleCompare(keyword,"geometry") == 0)
5588 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5591 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5597 if (LocaleCompare(keyword,"x") == 0)
5599 x = StringToLong( value );
5602 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5608 if (LocaleCompare(keyword,"y") == 0)
5610 y = StringToLong( value );
5613 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5618 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5631 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5632 if (newImage == (Image *) NULL)
5634 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5635 msl_info->image[n]=newImage;
5640 if (LocaleCompare((const char *) tag,"rotate") == 0)
5648 if (msl_info->image[n] == (Image *) NULL)
5650 ThrowMSLException(OptionError,"NoImagesDefined",
5651 (const char *) tag);
5654 if (attributes != (const xmlChar **) NULL)
5655 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5657 keyword=(const char *) attributes[i++];
5658 attribute=InterpretImageProperties(msl_info->image_info[n],
5659 msl_info->attributes[n],(const char *) attributes[i],
5661 CloneString(&value,attribute);
5667 if (LocaleCompare(keyword,"degrees") == 0)
5669 geometry_info.rho=StringToDouble(value,
5673 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5680 if (LocaleCompare(keyword,"geometry") == 0)
5682 flags=ParseGeometry(value,&geometry_info);
5683 if ((flags & SigmaValue) == 0)
5684 geometry_info.sigma=1.0;
5687 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5699 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5700 msl_info->exception);
5701 if (rotate_image == (Image *) NULL)
5703 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5704 msl_info->image[n]=rotate_image;
5707 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5709 /* init the values */
5712 if (msl_info->image[n] == (Image *) NULL)
5714 ThrowMSLException(OptionError,"NoImagesDefined",
5715 (const char *) tag);
5718 if (attributes == (const xmlChar **) NULL)
5720 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5722 keyword=(const char *) attributes[i++];
5723 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5724 msl_info->attributes[n],(const char *) attributes[i],&exception));
5730 if (LocaleCompare(keyword,"degrees") == 0)
5732 degrees = StringToDouble(value,(char **) NULL);
5735 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5740 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5753 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5754 if (newImage == (Image *) NULL)
5756 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5757 msl_info->image[n]=newImage;
5762 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5767 if (LocaleCompare((const char *) tag,"sample") == 0)
5775 if (msl_info->image[n] == (Image *) NULL)
5777 ThrowMSLException(OptionError,"NoImagesDefined",
5778 (const char *) tag);
5781 if (attributes != (const xmlChar **) NULL)
5782 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5784 keyword=(const char *) attributes[i++];
5785 attribute=InterpretImageProperties(msl_info->image_info[n],
5786 msl_info->attributes[n],(const char *) attributes[i],
5788 CloneString(&value,attribute);
5794 if (LocaleCompare(keyword,"geometry") == 0)
5796 flags=ParseRegionGeometry(msl_info->image[n],value,
5797 &geometry,&exception);
5800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5807 if (LocaleCompare(keyword,"height") == 0)
5809 geometry.height=StringToUnsignedLong(value);
5812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5819 if (LocaleCompare(keyword,"width") == 0)
5821 geometry.width=StringToLong(value);
5824 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5830 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5836 sample_image=SampleImage(msl_info->image[n],geometry.width,
5837 geometry.height,msl_info->exception);
5838 if (sample_image == (Image *) NULL)
5840 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5841 msl_info->image[n]=sample_image;
5844 if (LocaleCompare((const char *) tag,"scale") == 0)
5852 if (msl_info->image[n] == (Image *) NULL)
5854 ThrowMSLException(OptionError,"NoImagesDefined",
5855 (const char *) tag);
5858 if (attributes != (const xmlChar **) NULL)
5859 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5861 keyword=(const char *) attributes[i++];
5862 attribute=InterpretImageProperties(msl_info->image_info[n],
5863 msl_info->attributes[n],(const char *) attributes[i],
5865 CloneString(&value,attribute);
5871 if (LocaleCompare(keyword,"geometry") == 0)
5873 flags=ParseRegionGeometry(msl_info->image[n],value,
5874 &geometry,&exception);
5877 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5884 if (LocaleCompare(keyword,"height") == 0)
5886 geometry.height=StringToUnsignedLong(value);
5889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5896 if (LocaleCompare(keyword,"width") == 0)
5898 geometry.width=StringToLong(value);
5901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5907 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5913 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5914 geometry.height,msl_info->exception);
5915 if (scale_image == (Image *) NULL)
5917 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5918 msl_info->image[n]=scale_image;
5921 if (LocaleCompare((const char *) tag,"segment") == 0)
5932 if (msl_info->image[n] == (Image *) NULL)
5934 ThrowMSLException(OptionError,"NoImagesDefined",
5935 (const char *) tag);
5938 geometry_info.rho=1.0;
5939 geometry_info.sigma=1.5;
5940 colorspace=RGBColorspace;
5941 verbose=MagickFalse;
5942 if (attributes != (const xmlChar **) NULL)
5943 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5945 keyword=(const char *) attributes[i++];
5946 attribute=InterpretImageProperties(msl_info->image_info[n],
5947 msl_info->attributes[n],(const char *) attributes[i],
5949 CloneString(&value,attribute);
5955 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5957 geometry_info.rho=StringToDouble(value,
5961 if (LocaleCompare(keyword,"colorspace") == 0)
5963 option=ParseCommandOption(MagickColorspaceOptions,
5966 ThrowMSLException(OptionError,
5967 "UnrecognizedColorspaceType",value);
5968 colorspace=(ColorspaceType) option;
5971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5978 if (LocaleCompare(keyword,"geometry") == 0)
5980 flags=ParseGeometry(value,&geometry_info);
5981 if ((flags & SigmaValue) == 0)
5982 geometry_info.sigma=1.5;
5985 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5992 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5994 geometry_info.sigma=StringToDouble(value,
5998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6010 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
6011 geometry_info.rho,geometry_info.sigma,&exception);
6014 else if (LocaleCompare((const char *) tag, "set") == 0)
6016 if (msl_info->image[n] == (Image *) NULL)
6018 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6022 if (attributes == (const xmlChar **) NULL)
6024 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6026 keyword=(const char *) attributes[i++];
6027 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6028 msl_info->attributes[n],(const char *) attributes[i],&exception));
6034 if (LocaleCompare(keyword,"clip-mask") == 0)
6036 for (j=0; j < msl_info->n; j++)
6041 property=GetImageProperty(msl_info->attributes[j],"id",
6043 if (LocaleCompare(property,value) == 0)
6045 SetImageMask(msl_info->image[n],msl_info->image[j],
6052 if (LocaleCompare(keyword,"clip-path") == 0)
6054 for (j=0; j < msl_info->n; j++)
6059 property=GetImageProperty(msl_info->attributes[j],"id",
6061 if (LocaleCompare(property,value) == 0)
6063 SetImageClipMask(msl_info->image[n],msl_info->image[j],
6070 if (LocaleCompare(keyword,"colorspace") == 0)
6075 colorspace=(ColorspaceType) ParseCommandOption(
6076 MagickColorspaceOptions,MagickFalse,value);
6078 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6080 (void) TransformImageColorspace(msl_info->image[n],
6081 (ColorspaceType) colorspace,&exception);
6084 (void) SetMSLAttributes(msl_info,keyword,value);
6085 (void) SetImageProperty(msl_info->image[n],keyword,value,
6092 if (LocaleCompare(keyword,"density") == 0)
6094 flags=ParseGeometry(value,&geometry_info);
6095 msl_info->image[n]->resolution.x=geometry_info.rho;
6096 msl_info->image[n]->resolution.y=geometry_info.sigma;
6097 if ((flags & SigmaValue) == 0)
6098 msl_info->image[n]->resolution.y=
6099 msl_info->image[n]->resolution.x;
6102 (void) SetMSLAttributes(msl_info,keyword,value);
6103 (void) SetImageProperty(msl_info->image[n],keyword,value,
6110 if (LocaleCompare(keyword, "opacity") == 0)
6112 ssize_t opac = OpaqueAlpha,
6113 len = (ssize_t) strlen( value );
6115 if (value[len-1] == '%') {
6117 (void) CopyMagickString(tmp,value,len);
6118 opac = StringToLong( tmp );
6119 opac = (int)(QuantumRange * ((float)opac/100));
6121 opac = StringToLong( value );
6122 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6126 (void) SetMSLAttributes(msl_info,keyword,value);
6127 (void) SetImageProperty(msl_info->image[n],keyword,value,
6128 msl_info->exception);
6134 if (LocaleCompare(keyword, "page") == 0)
6137 page[MaxTextExtent];
6148 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6149 image_option=GetImageOption(msl_info->image_info[n],"page");
6150 if (image_option != (const char *) NULL)
6151 flags=ParseAbsoluteGeometry(image_option,&geometry);
6152 flags=ParseAbsoluteGeometry(value,&geometry);
6153 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6154 (double) geometry.width,(double) geometry.height);
6155 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6156 (void) FormatLocaleString(page,MaxTextExtent,
6157 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6158 (double) geometry.height,(double) geometry.x,(double)
6160 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6161 msl_info->image_info[n]->page=GetPageGeometry(page);
6164 (void) SetMSLAttributes(msl_info,keyword,value);
6165 (void) SetImageProperty(msl_info->image[n],keyword,value,
6166 msl_info->exception);
6171 (void) SetMSLAttributes(msl_info,keyword,value);
6172 (void) SetImageProperty(msl_info->image[n],keyword,value,
6173 msl_info->exception);
6180 if (LocaleCompare((const char *) tag,"shade") == 0)
6191 if (msl_info->image[n] == (Image *) NULL)
6193 ThrowMSLException(OptionError,"NoImagesDefined",
6194 (const char *) tag);
6198 if (attributes != (const xmlChar **) NULL)
6199 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6201 keyword=(const char *) attributes[i++];
6202 attribute=InterpretImageProperties(msl_info->image_info[n],
6203 msl_info->attributes[n],(const char *) attributes[i],
6205 CloneString(&value,attribute);
6211 if (LocaleCompare(keyword,"azimuth") == 0)
6213 geometry_info.rho=StringToDouble(value,
6217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6224 if (LocaleCompare(keyword,"elevation") == 0)
6226 geometry_info.sigma=StringToDouble(value,
6230 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6237 if (LocaleCompare(keyword,"geometry") == 0)
6239 flags=ParseGeometry(value,&geometry_info);
6240 if ((flags & SigmaValue) == 0)
6241 geometry_info.sigma=1.0;
6244 if (LocaleCompare(keyword,"gray") == 0)
6246 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6249 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6251 gray=(MagickBooleanType) option;
6254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6260 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6266 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6267 geometry_info.sigma,msl_info->exception);
6268 if (shade_image == (Image *) NULL)
6270 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6271 msl_info->image[n]=shade_image;
6274 if (LocaleCompare((const char *) tag,"shadow") == 0)
6282 if (msl_info->image[n] == (Image *) NULL)
6284 ThrowMSLException(OptionError,"NoImagesDefined",
6285 (const char *) tag);
6288 if (attributes != (const xmlChar **) NULL)
6289 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6291 keyword=(const char *) attributes[i++];
6292 attribute=InterpretImageProperties(msl_info->image_info[n],
6293 msl_info->attributes[n],(const char *) attributes[i],
6295 CloneString(&value,attribute);
6301 if (LocaleCompare(keyword,"geometry") == 0)
6303 flags=ParseGeometry(value,&geometry_info);
6304 if ((flags & SigmaValue) == 0)
6305 geometry_info.sigma=1.0;
6308 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6315 if (LocaleCompare(keyword,"opacity") == 0)
6317 geometry_info.rho=StringToLong(value);
6320 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6327 if (LocaleCompare(keyword,"sigma") == 0)
6329 geometry_info.sigma=StringToLong(value);
6337 if (LocaleCompare(keyword,"x") == 0)
6339 geometry_info.xi=StringToDouble(value,
6343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6350 if (LocaleCompare(keyword,"y") == 0)
6352 geometry_info.psi=StringToLong(value);
6355 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6361 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6367 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6368 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6369 ceil(geometry_info.psi-0.5),msl_info->exception);
6370 if (shadow_image == (Image *) NULL)
6372 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6373 msl_info->image[n]=shadow_image;
6376 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6382 if (msl_info->image[n] == (Image *) NULL)
6384 ThrowMSLException(OptionError,"NoImagesDefined",
6385 (const char *) tag);
6389 NOTE: sharpen can have no attributes, since we use all the defaults!
6391 if (attributes != (const xmlChar **) NULL)
6393 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6395 keyword=(const char *) attributes[i++];
6396 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6397 msl_info->attributes[n],(const char *) attributes[i],&exception));
6403 if (LocaleCompare(keyword, "bias") == 0)
6405 bias = StringToDouble(value,(char **) NULL);
6408 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6414 if (LocaleCompare(keyword, "radius") == 0)
6416 radius = StringToDouble(value,(char **) NULL);
6419 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6425 if (LocaleCompare(keyword,"sigma") == 0)
6427 sigma = StringToLong( value );
6430 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6435 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6449 newImage=SharpenImage(msl_info->image[n],radius,sigma,bias,
6450 msl_info->exception);
6451 if (newImage == (Image *) NULL)
6453 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6454 msl_info->image[n]=newImage;
6458 else if (LocaleCompare((const char *) tag,"shave") == 0)
6460 /* init the values */
6464 if (msl_info->image[n] == (Image *) NULL)
6466 ThrowMSLException(OptionError,"NoImagesDefined",
6467 (const char *) tag);
6470 if (attributes == (const xmlChar **) NULL)
6472 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6474 keyword=(const char *) attributes[i++];
6475 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6476 msl_info->attributes[n],(const char *) attributes[i],&exception));
6482 if (LocaleCompare(keyword,"geometry") == 0)
6484 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6487 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6493 if (LocaleCompare(keyword,"height") == 0)
6495 height = StringToLong( value );
6498 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6504 if (LocaleCompare(keyword,"width") == 0)
6506 width = StringToLong( value );
6509 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6514 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6529 rectInfo.height = height;
6530 rectInfo.width = width;
6535 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6536 msl_info->exception);
6537 if (newImage == (Image *) NULL)
6539 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6540 msl_info->image[n]=newImage;
6545 if (LocaleCompare((const char *) tag,"shear") == 0)
6553 if (msl_info->image[n] == (Image *) NULL)
6555 ThrowMSLException(OptionError,"NoImagesDefined",
6556 (const char *) tag);
6559 if (attributes != (const xmlChar **) NULL)
6560 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6562 keyword=(const char *) attributes[i++];
6563 attribute=InterpretImageProperties(msl_info->image_info[n],
6564 msl_info->attributes[n],(const char *) attributes[i],
6566 CloneString(&value,attribute);
6572 if (LocaleCompare(keyword, "fill") == 0)
6574 (void) QueryColorCompliance(value,AllCompliance,
6575 &msl_info->image[n]->background_color,&exception);
6578 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6585 if (LocaleCompare(keyword,"geometry") == 0)
6587 flags=ParseGeometry(value,&geometry_info);
6588 if ((flags & SigmaValue) == 0)
6589 geometry_info.sigma=1.0;
6592 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6599 if (LocaleCompare(keyword,"x") == 0)
6601 geometry_info.rho=StringToDouble(value,
6605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6612 if (LocaleCompare(keyword,"y") == 0)
6614 geometry_info.sigma=StringToLong(value);
6617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6629 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6630 geometry_info.sigma,msl_info->exception);
6631 if (shear_image == (Image *) NULL)
6633 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6634 msl_info->image[n]=shear_image;
6637 if (LocaleCompare((const char *) tag,"signature") == 0)
6642 if (msl_info->image[n] == (Image *) NULL)
6644 ThrowMSLException(OptionError,"NoImagesDefined",
6645 (const char *) tag);
6648 if (attributes != (const xmlChar **) NULL)
6649 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6651 keyword=(const char *) attributes[i++];
6652 attribute=InterpretImageProperties(msl_info->image_info[n],
6653 msl_info->attributes[n],(const char *) attributes[i],
6655 CloneString(&value,attribute);
6660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6666 (void) SignatureImage(msl_info->image[n],&exception);
6669 if (LocaleCompare((const char *) tag,"solarize") == 0)
6674 if (msl_info->image[n] == (Image *) NULL)
6676 ThrowMSLException(OptionError,"NoImagesDefined",
6677 (const char *) tag);
6680 geometry_info.rho=QuantumRange/2.0;
6681 if (attributes != (const xmlChar **) NULL)
6682 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6684 keyword=(const char *) attributes[i++];
6685 attribute=InterpretImageProperties(msl_info->image_info[n],
6686 msl_info->attributes[n],(const char *) attributes[i],
6688 CloneString(&value,attribute);
6694 if (LocaleCompare(keyword,"geometry") == 0)
6696 flags=ParseGeometry(value,&geometry_info);
6699 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6706 if (LocaleCompare(keyword,"threshold") == 0)
6708 geometry_info.rho=StringToDouble(value,
6712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6724 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6725 msl_info->exception);
6728 if (LocaleCompare((const char *) tag,"spread") == 0)
6736 if (msl_info->image[n] == (Image *) NULL)
6738 ThrowMSLException(OptionError,"NoImagesDefined",
6739 (const char *) tag);
6742 if (attributes != (const xmlChar **) NULL)
6743 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6745 keyword=(const char *) attributes[i++];
6746 attribute=InterpretImageProperties(msl_info->image_info[n],
6747 msl_info->attributes[n],(const char *) attributes[i],
6749 CloneString(&value,attribute);
6755 if (LocaleCompare(keyword,"geometry") == 0)
6757 flags=ParseGeometry(value,&geometry_info);
6758 if ((flags & SigmaValue) == 0)
6759 geometry_info.sigma=1.0;
6762 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6769 if (LocaleCompare(keyword,"radius") == 0)
6771 geometry_info.rho=StringToDouble(value,
6775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6781 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6787 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6788 msl_info->image[n]->interpolate,msl_info->exception);
6789 if (spread_image == (Image *) NULL)
6791 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6792 msl_info->image[n]=spread_image;
6795 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6798 watermark = (Image*)NULL;
6800 if (msl_info->image[n] == (Image *) NULL)
6802 ThrowMSLException(OptionError,"NoImagesDefined",
6803 (const char *) tag);
6806 if (attributes == (const xmlChar **) NULL)
6808 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6810 keyword=(const char *) attributes[i++];
6811 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6812 msl_info->attributes[n],(const char *) attributes[i],&exception));
6818 if (LocaleCompare(keyword,"image") == 0)
6820 for (j=0; j<msl_info->n;j++)
6823 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6825 if (theAttr && LocaleCompare(theAttr, value) == 0)
6827 watermark = msl_info->image[j];
6833 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6838 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6847 if ( watermark != (Image*) NULL )
6852 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6853 if (newImage == (Image *) NULL)
6855 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6856 msl_info->image[n]=newImage;
6859 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6861 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6864 stereoImage = (Image*)NULL;
6866 if (msl_info->image[n] == (Image *) NULL)
6868 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6871 if (attributes == (const xmlChar **) NULL)
6873 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6875 keyword=(const char *) attributes[i++];
6876 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6877 msl_info->attributes[n],(const char *) attributes[i],&exception));
6883 if (LocaleCompare(keyword,"image") == 0)
6885 for (j=0; j<msl_info->n;j++)
6888 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6890 if (theAttr && LocaleCompare(theAttr, value) == 0)
6892 stereoImage = msl_info->image[j];
6898 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6903 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6912 if ( stereoImage != (Image*) NULL )
6917 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6918 if (newImage == (Image *) NULL)
6920 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6921 msl_info->image[n]=newImage;
6924 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6926 if (LocaleCompare((const char *) tag,"swap") == 0)
6937 if (msl_info->image[n] == (Image *) NULL)
6939 ThrowMSLException(OptionError,"NoImagesDefined",
6940 (const char *) tag);
6945 if (attributes != (const xmlChar **) NULL)
6946 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6948 keyword=(const char *) attributes[i++];
6949 attribute=InterpretImageProperties(msl_info->image_info[n],
6950 msl_info->attributes[n],(const char *) attributes[i],
6952 CloneString(&value,attribute);
6958 if (LocaleCompare(keyword,"indexes") == 0)
6960 flags=ParseGeometry(value,&geometry_info);
6961 index=(ssize_t) geometry_info.rho;
6962 if ((flags & SigmaValue) == 0)
6963 swap_index=(ssize_t) geometry_info.sigma;
6966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6972 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6981 p=GetImageFromList(msl_info->image[n],index);
6982 q=GetImageFromList(msl_info->image[n],swap_index);
6983 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6985 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6988 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6989 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6990 msl_info->exception));
6991 ReplaceImageInList(&q,swap);
6992 msl_info->image[n]=GetFirstImageInList(q);
6995 if (LocaleCompare((const char *) tag,"swirl") == 0)
7003 if (msl_info->image[n] == (Image *) NULL)
7005 ThrowMSLException(OptionError,"NoImagesDefined",
7006 (const char *) tag);
7009 if (attributes != (const xmlChar **) NULL)
7010 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7012 keyword=(const char *) attributes[i++];
7013 attribute=InterpretImageProperties(msl_info->image_info[n],
7014 msl_info->attributes[n],(const char *) attributes[i],
7016 CloneString(&value,attribute);
7022 if (LocaleCompare(keyword,"degrees") == 0)
7024 geometry_info.rho=StringToDouble(value,
7028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7035 if (LocaleCompare(keyword,"geometry") == 0)
7037 flags=ParseGeometry(value,&geometry_info);
7038 if ((flags & SigmaValue) == 0)
7039 geometry_info.sigma=1.0;
7042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7048 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7054 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7055 msl_info->image[n]->interpolate,msl_info->exception);
7056 if (swirl_image == (Image *) NULL)
7058 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7059 msl_info->image[n]=swirl_image;
7062 if (LocaleCompare((const char *) tag,"sync") == 0)
7067 if (msl_info->image[n] == (Image *) NULL)
7069 ThrowMSLException(OptionError,"NoImagesDefined",
7070 (const char *) tag);
7073 if (attributes != (const xmlChar **) NULL)
7074 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7076 keyword=(const char *) attributes[i++];
7077 attribute=InterpretImageProperties(msl_info->image_info[n],
7078 msl_info->attributes[n],(const char *) attributes[i],
7080 CloneString(&value,attribute);
7085 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7091 (void) SyncImage(msl_info->image[n],&exception);
7094 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7099 if (LocaleCompare((const char *) tag,"map") == 0)
7107 if (msl_info->image[n] == (Image *) NULL)
7109 ThrowMSLException(OptionError,"NoImagesDefined",
7110 (const char *) tag);
7113 texture_image=NewImageList();
7114 if (attributes != (const xmlChar **) NULL)
7115 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7117 keyword=(const char *) attributes[i++];
7118 attribute=InterpretImageProperties(msl_info->image_info[n],
7119 msl_info->attributes[n],(const char *) attributes[i],
7121 CloneString(&value,attribute);
7127 if (LocaleCompare(keyword,"image") == 0)
7128 for (j=0; j < msl_info->n; j++)
7133 attribute=GetImageProperty(msl_info->attributes[j],"id",
7135 if ((attribute != (const char *) NULL) &&
7136 (LocaleCompare(attribute,value) == 0))
7138 texture_image=CloneImage(msl_info->image[j],0,0,
7139 MagickFalse,&exception);
7147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7153 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7154 texture_image=DestroyImage(texture_image);
7157 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7159 /* init the values */
7160 double threshold = 0;
7162 if (msl_info->image[n] == (Image *) NULL)
7164 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7167 if (attributes == (const xmlChar **) NULL)
7169 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7171 keyword=(const char *) attributes[i++];
7172 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7173 msl_info->attributes[n],(const char *) attributes[i],&exception));
7179 if (LocaleCompare(keyword,"threshold") == 0)
7181 threshold = StringToDouble(value,(char **) NULL);
7184 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7189 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7199 BilevelImage(msl_info->image[n],threshold,&exception);
7203 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7205 if (msl_info->image[n] == (Image *) NULL)
7207 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7210 if (attributes == (const xmlChar **) NULL)
7212 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7214 keyword=(const char *) attributes[i++];
7215 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7216 msl_info->attributes[n],(const char *) attributes[i],&exception));
7222 if (LocaleCompare(keyword,"color") == 0)
7227 (void) QueryColorCompliance(value,AllCompliance,&target,
7229 (void) TransparentPaintImage(msl_info->image[n],&target,
7230 TransparentAlpha,MagickFalse,msl_info->exception);
7233 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7238 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7245 else if (LocaleCompare((const char *) tag, "trim") == 0)
7247 if (msl_info->image[n] == (Image *) NULL)
7249 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7253 /* no attributes here */
7255 /* process the image */
7262 /* all zeros on a crop == trim edges! */
7263 rectInfo.height = rectInfo.width = 0;
7264 rectInfo.x = rectInfo.y = 0;
7266 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7267 if (newImage == (Image *) NULL)
7269 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7270 msl_info->image[n]=newImage;
7274 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7279 if (LocaleCompare((const char *) tag,"write") == 0)
7281 if (msl_info->image[n] == (Image *) NULL)
7283 ThrowMSLException(OptionError,"NoImagesDefined",
7284 (const char *) tag);
7287 if (attributes == (const xmlChar **) NULL)
7289 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7291 keyword=(const char *) attributes[i++];
7292 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7293 msl_info->attributes[n],(const char *) attributes[i],&exception));
7299 if (LocaleCompare(keyword,"filename") == 0)
7301 (void) CopyMagickString(msl_info->image[n]->filename,value,
7305 (void) SetMSLAttributes(msl_info,keyword,value);
7309 (void) SetMSLAttributes(msl_info,keyword,value);
7317 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7318 msl_info->exception);
7322 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7326 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7330 if ( value != NULL )
7331 value=DestroyString(value);
7332 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7335 static void MSLEndElement(void *context,const xmlChar *tag)
7344 Called when the end of an element has been detected.
7346 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7348 msl_info=(MSLInfo *) context;
7355 if (LocaleCompare((const char *) tag,"comment") == 0 )
7357 (void) DeleteImageProperty(msl_info->image[n],"comment");
7358 if (msl_info->content == (char *) NULL)
7360 StripString(msl_info->content);
7361 (void) SetImageProperty(msl_info->image[n],"comment",
7362 msl_info->content,msl_info->exception);
7370 if (LocaleCompare((const char *) tag, "group") == 0 )
7372 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7374 ssize_t i = (ssize_t)
7375 (msl_info->group_info[msl_info->number_groups-1].numImages);
7378 if (msl_info->image[msl_info->n] != (Image *) NULL)
7379 msl_info->image[msl_info->n]=DestroyImage(
7380 msl_info->image[msl_info->n]);
7381 msl_info->attributes[msl_info->n]=DestroyImage(
7382 msl_info->attributes[msl_info->n]);
7383 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7384 msl_info->image_info[msl_info->n]);
7388 msl_info->number_groups--;
7395 if (LocaleCompare((const char *) tag, "image") == 0)
7396 MSLPopImage(msl_info);
7402 if (LocaleCompare((const char *) tag,"label") == 0 )
7404 (void) DeleteImageProperty(msl_info->image[n],"label");
7405 if (msl_info->content == (char *) NULL)
7407 StripString(msl_info->content);
7408 (void) SetImageProperty(msl_info->image[n],"label",
7409 msl_info->content,msl_info->exception);
7417 if (LocaleCompare((const char *) tag, "msl") == 0 )
7420 This our base element.
7421 at the moment we don't do anything special
7422 but someday we might!
7430 if (msl_info->content != (char *) NULL)
7431 msl_info->content=DestroyString(msl_info->content);
7434 static void MSLCharacters(void *context,const xmlChar *c,int length)
7446 Receiving some characters from the parser.
7448 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7449 " SAX.characters(%s,%d)",c,length);
7450 msl_info=(MSLInfo *) context;
7451 if (msl_info->content != (char *) NULL)
7452 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7453 strlen(msl_info->content)+length+MaxTextExtent,
7454 sizeof(*msl_info->content));
7457 msl_info->content=(char *) NULL;
7458 if (~length >= (MaxTextExtent-1))
7459 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7460 sizeof(*msl_info->content));
7461 if (msl_info->content != (char *) NULL)
7462 *msl_info->content='\0';
7464 if (msl_info->content == (char *) NULL)
7466 p=msl_info->content+strlen(msl_info->content);
7467 for (i=0; i < length; i++)
7472 static void MSLReference(void *context,const xmlChar *name)
7481 Called when an entity reference is detected.
7483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7484 " SAX.reference(%s)",name);
7485 msl_info=(MSLInfo *) context;
7486 parser=msl_info->parser;
7488 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7490 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7493 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7499 Receiving some ignorable whitespaces from the parser.
7501 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7502 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7503 msl_info=(MSLInfo *) context;
7507 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7508 const xmlChar *data)
7514 A processing instruction has been parsed.
7516 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7517 " SAX.processingInstruction(%s, %s)",
7519 msl_info=(MSLInfo *) context;
7523 static void MSLComment(void *context,const xmlChar *value)
7529 A comment has been parsed.
7531 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7532 " SAX.comment(%s)",value);
7533 msl_info=(MSLInfo *) context;
7537 static void MSLWarning(void *context,const char *format,...)
7541 reason[MaxTextExtent];
7550 Display and format a warning messages, gives file, line, position and
7553 va_start(operands,format);
7554 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7555 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7556 msl_info=(MSLInfo *) context;
7558 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7559 (void) vsprintf(reason,format,operands);
7561 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7563 message=GetExceptionMessage(errno);
7564 ThrowMSLException(CoderError,reason,message);
7565 message=DestroyString(message);
7569 static void MSLError(void *context,const char *format,...)
7572 reason[MaxTextExtent];
7581 Display and format a error formats, gives file, line, position and
7584 va_start(operands,format);
7585 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7586 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7587 msl_info=(MSLInfo *) context;
7589 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7590 (void) vsprintf(reason,format,operands);
7592 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7594 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7598 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7610 Called when a pcdata block has been parsed.
7612 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7613 " SAX.pcdata(%s, %d)",value,length);
7614 msl_info=(MSLInfo *) context;
7616 parser=msl_info->parser;
7617 child=xmlGetLastChild(parser->node);
7618 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7620 xmlTextConcat(child,value,length);
7623 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7626 static void MSLExternalSubset(void *context,const xmlChar *name,
7627 const xmlChar *external_id,const xmlChar *system_id)
7642 Does this document has an external subset?
7644 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7645 " SAX.externalSubset(%s %s %s)",name,
7646 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7647 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7648 msl_info=(MSLInfo *) context;
7650 parser=msl_info->parser;
7651 if (((external_id == NULL) && (system_id == NULL)) ||
7652 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7653 (msl_info->document == 0)))
7655 input=MSLResolveEntity(context,external_id,system_id);
7658 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7659 parser_context=(*parser);
7660 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7661 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7663 parser->errNo=XML_ERR_NO_MEMORY;
7664 parser->input=parser_context.input;
7665 parser->inputNr=parser_context.inputNr;
7666 parser->inputMax=parser_context.inputMax;
7667 parser->inputTab=parser_context.inputTab;
7673 xmlPushInput(parser,input);
7674 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7675 if (input->filename == (char *) NULL)
7676 input->filename=(char *) xmlStrdup(system_id);
7679 input->base=parser->input->cur;
7680 input->cur=parser->input->cur;
7682 xmlParseExternalSubset(parser,external_id,system_id);
7683 while (parser->inputNr > 1)
7684 (void) xmlPopInput(parser);
7685 xmlFreeInputStream(parser->input);
7686 xmlFree(parser->inputTab);
7687 parser->input=parser_context.input;
7688 parser->inputNr=parser_context.inputNr;
7689 parser->inputMax=parser_context.inputMax;
7690 parser->inputTab=parser_context.inputTab;
7693 #if defined(__cplusplus) || defined(c_plusplus)
7697 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7698 ExceptionInfo *exception)
7701 message[MaxTextExtent];
7724 assert(image_info != (const ImageInfo *) NULL);
7725 assert(image_info->signature == MagickSignature);
7726 if (image_info->debug != MagickFalse)
7727 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7728 image_info->filename);
7729 assert(image != (Image **) NULL);
7730 msl_image=AcquireImage(image_info,exception);
7731 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7732 if (status == MagickFalse)
7734 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7735 msl_image->filename);
7736 msl_image=DestroyImageList(msl_image);
7737 return(MagickFalse);
7739 msl_image->columns=1;
7744 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7745 msl_info.exception=exception;
7746 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7747 sizeof(*msl_info.image_info));
7748 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7749 sizeof(*msl_info.draw_info));
7750 /* top of the stack is the MSL file itself */
7751 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7752 msl_info.attributes=(Image **) AcquireMagickMemory(
7753 sizeof(*msl_info.attributes));
7754 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7755 sizeof(*msl_info.group_info));
7756 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7757 (msl_info.image == (Image **) NULL) ||
7758 (msl_info.attributes == (Image **) NULL) ||
7759 (msl_info.group_info == (MSLGroupInfo *) NULL))
7760 ThrowFatalException(ResourceLimitFatalError,
7761 "UnableToInterpretMSLImage");
7762 *msl_info.image_info=CloneImageInfo(image_info);
7763 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7764 *msl_info.attributes=AcquireImage(image_info,exception);
7765 msl_info.group_info[0].numImages=0;
7766 /* the first slot is used to point to the MSL file image */
7767 *msl_info.image=msl_image;
7768 if (*image != (Image *) NULL)
7769 MSLPushImage(&msl_info,*image);
7770 (void) xmlSubstituteEntitiesDefault(1);
7771 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7772 sax_modules.internalSubset=MSLInternalSubset;
7773 sax_modules.isStandalone=MSLIsStandalone;
7774 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7775 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7776 sax_modules.resolveEntity=MSLResolveEntity;
7777 sax_modules.getEntity=MSLGetEntity;
7778 sax_modules.entityDecl=MSLEntityDeclaration;
7779 sax_modules.notationDecl=MSLNotationDeclaration;
7780 sax_modules.attributeDecl=MSLAttributeDeclaration;
7781 sax_modules.elementDecl=MSLElementDeclaration;
7782 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7783 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7784 sax_modules.startDocument=MSLStartDocument;
7785 sax_modules.endDocument=MSLEndDocument;
7786 sax_modules.startElement=MSLStartElement;
7787 sax_modules.endElement=MSLEndElement;
7788 sax_modules.reference=MSLReference;
7789 sax_modules.characters=MSLCharacters;
7790 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7791 sax_modules.processingInstruction=MSLProcessingInstructions;
7792 sax_modules.comment=MSLComment;
7793 sax_modules.warning=MSLWarning;
7794 sax_modules.error=MSLError;
7795 sax_modules.fatalError=MSLError;
7796 sax_modules.getParameterEntity=MSLGetParameterEntity;
7797 sax_modules.cdataBlock=MSLCDataBlock;
7798 sax_modules.externalSubset=MSLExternalSubset;
7799 sax_handler=(&sax_modules);
7800 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7801 msl_image->filename);
7802 while (ReadBlobString(msl_image,message) != (char *) NULL)
7804 n=(ssize_t) strlen(message);
7807 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7810 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7811 if (msl_info.exception->severity >= ErrorException)
7814 if (msl_info.exception->severity == UndefinedException)
7815 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7816 xmlFreeParserCtxt(msl_info.parser);
7817 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7819 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7820 msl_info.group_info);
7821 if (*image == (Image *) NULL)
7822 *image=(*msl_info.image);
7823 if (msl_info.exception->severity != UndefinedException)
7824 return(MagickFalse);
7828 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7836 assert(image_info != (const ImageInfo *) NULL);
7837 assert(image_info->signature == MagickSignature);
7838 if (image_info->debug != MagickFalse)
7839 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7840 image_info->filename);
7841 assert(exception != (ExceptionInfo *) NULL);
7842 assert(exception->signature == MagickSignature);
7843 image=(Image *) NULL;
7844 (void) ProcessMSLScript(image_info,&image,exception);
7845 return(GetFirstImageInList(image));
7850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7854 % R e g i s t e r M S L I m a g e %
7858 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7860 % RegisterMSLImage() adds attributes for the MSL image format to
7861 % the list of supported formats. The attributes include the image format
7862 % tag, a method to read and/or write the format, whether the format
7863 % supports the saving of more than one frame to the same file or blob,
7864 % whether the format supports native in-memory I/O, and a brief
7865 % description of the format.
7867 % The format of the RegisterMSLImage method is:
7869 % size_t RegisterMSLImage(void)
7872 ModuleExport size_t RegisterMSLImage(void)
7877 entry=SetMagickInfo("MSL");
7878 #if defined(MAGICKCORE_XML_DELEGATE)
7879 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7880 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7882 entry->description=ConstantString("Magick Scripting Language");
7883 entry->module=ConstantString("MSL");
7884 (void) RegisterMagickInfo(entry);
7885 return(MagickImageCoderSignature);
7888 #if defined(MAGICKCORE_XML_DELEGATE)
7890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7894 % S e t M S L A t t r i b u t e s %
7898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7900 % SetMSLAttributes() ...
7902 % The format of the SetMSLAttributes method is:
7904 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7905 % const char *keyword,const char *value)
7907 % A description of each parameter follows:
7909 % o msl_info: the MSL info.
7911 % o keyword: the keyword.
7913 % o value: the value.
7916 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7943 assert(msl_info != (MSLInfo *) NULL);
7944 if (keyword == (const char *) NULL)
7946 if (value == (const char *) NULL)
7948 exception=msl_info->exception;
7950 attributes=msl_info->attributes[n];
7951 image_info=msl_info->image_info[n];
7952 draw_info=msl_info->draw_info[n];
7953 image=msl_info->image[n];
7959 if (LocaleCompare(keyword,"adjoin") == 0)
7964 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7966 ThrowMSLException(OptionError,"UnrecognizedType",value);
7967 image_info->adjoin=(MagickBooleanType) adjoin;
7970 if (LocaleCompare(keyword,"alpha") == 0)
7975 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7977 ThrowMSLException(OptionError,"UnrecognizedType",value);
7978 if (image != (Image *) NULL)
7979 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7983 if (LocaleCompare(keyword,"antialias") == 0)
7988 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7990 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7991 image_info->antialias=(MagickBooleanType) antialias;
7994 if (LocaleCompare(keyword,"area-limit") == 0)
7999 limit=MagickResourceInfinity;
8000 if (LocaleCompare(value,"unlimited") != 0)
8001 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
8002 (void) SetMagickResourceLimit(AreaResource,limit);
8005 if (LocaleCompare(keyword,"attenuate") == 0)
8007 (void) SetImageOption(image_info,keyword,value);
8010 if (LocaleCompare(keyword,"authenticate") == 0)
8012 (void) CloneString(&image_info->density,value);
8015 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8021 if (LocaleCompare(keyword,"background") == 0)
8023 (void) QueryColorCompliance(value,AllCompliance,
8024 &image_info->background_color,exception);
8027 if (LocaleCompare(keyword,"bias") == 0)
8029 if (image == (Image *) NULL)
8031 image->bias=StringToDoubleInterval(value,QuantumRange);
8034 if (LocaleCompare(keyword,"blue-primary") == 0)
8036 if (image == (Image *) NULL)
8038 flags=ParseGeometry(value,&geometry_info);
8039 image->chromaticity.blue_primary.x=geometry_info.rho;
8040 image->chromaticity.blue_primary.y=geometry_info.sigma;
8041 if ((flags & SigmaValue) == 0)
8042 image->chromaticity.blue_primary.y=
8043 image->chromaticity.blue_primary.x;
8046 if (LocaleCompare(keyword,"bordercolor") == 0)
8048 (void) QueryColorCompliance(value,AllCompliance,
8049 &image_info->border_color,exception);
8052 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8058 if (LocaleCompare(keyword,"density") == 0)
8060 (void) CloneString(&image_info->density,value);
8061 (void) CloneString(&draw_info->density,value);
8064 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8070 if (LocaleCompare(keyword,"fill") == 0)
8072 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8074 (void) SetImageOption(image_info,keyword,value);
8077 if (LocaleCompare(keyword,"filename") == 0)
8079 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8082 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8088 if (LocaleCompare(keyword,"gravity") == 0)
8093 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8095 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8096 (void) SetImageOption(image_info,keyword,value);
8099 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8105 if (LocaleCompare(keyword,"id") == 0)
8107 (void) SetImageProperty(attributes,keyword,value,exception);
8110 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8116 if (LocaleCompare(keyword,"magick") == 0)
8118 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8121 if (LocaleCompare(keyword,"mattecolor") == 0)
8123 (void) QueryColorCompliance(value,AllCompliance,
8124 &image_info->matte_color,exception);
8127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8133 if (LocaleCompare(keyword,"pointsize") == 0)
8135 image_info->pointsize=StringToDouble(value,(char **) NULL);
8136 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8139 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8145 if (LocaleCompare(keyword,"quality") == 0)
8147 image_info->quality=StringToLong(value);
8148 if (image == (Image *) NULL)
8150 image->quality=StringToLong(value);
8158 if (LocaleCompare(keyword,"size") == 0)
8160 (void) CloneString(&image_info->size,value);
8163 if (LocaleCompare(keyword,"stroke") == 0)
8165 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8167 (void) SetImageOption(image_info,keyword,value);
8170 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8175 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8188 % U n r e g i s t e r M S L I m a g e %
8192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8194 % UnregisterMSLImage() removes format registrations made by the
8195 % MSL module from the list of supported formats.
8197 % The format of the UnregisterMSLImage method is:
8199 % UnregisterMSLImage(void)
8202 ModuleExport void UnregisterMSLImage(void)
8204 (void) UnregisterMagickInfo("MSL");
8207 #if defined(MAGICKCORE_XML_DELEGATE)
8209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8213 % W r i t e M S L I m a g e %
8217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8219 % WriteMSLImage() writes an image to a file in MVG image format.
8221 % The format of the WriteMSLImage method is:
8223 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8224 % Image *image,ExceptionInfo *exception)
8226 % A description of each parameter follows.
8228 % o image_info: the image info.
8230 % o image: The image.
8232 % o exception: return any errors or warnings in this structure.
8235 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8236 ExceptionInfo *exception)
8238 assert(image_info != (const ImageInfo *) NULL);
8239 assert(image_info->signature == MagickSignature);
8240 assert(image != (Image *) NULL);
8241 assert(image->signature == MagickSignature);
8242 if (image->debug != MagickFalse)
8243 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8244 (void) ReferenceImage(image);
8245 (void) ProcessMSLScript(image_info,&image,exception);