2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/attribute.h"
48 #include "MagickCore/blob.h"
49 #include "MagickCore/blob-private.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/cache-view.h"
52 #include "MagickCore/channel.h"
53 #include "MagickCore/color.h"
54 #include "MagickCore/color-private.h"
55 #include "MagickCore/colormap.h"
56 #include "MagickCore/composite.h"
57 #include "MagickCore/constitute.h"
58 #include "MagickCore/decorate.h"
59 #include "MagickCore/display.h"
60 #include "MagickCore/distort.h"
61 #include "MagickCore/draw.h"
62 #include "MagickCore/effect.h"
63 #include "MagickCore/enhance.h"
64 #include "MagickCore/exception.h"
65 #include "MagickCore/exception-private.h"
66 #include "MagickCore/fx.h"
67 #include "MagickCore/geometry.h"
68 #include "MagickCore/image.h"
69 #include "MagickCore/image-private.h"
70 #include "MagickCore/list.h"
71 #include "MagickCore/log.h"
72 #include "MagickCore/magick.h"
73 #include "MagickCore/memory_.h"
74 #include "MagickCore/module.h"
75 #include "MagickCore/option.h"
76 #include "MagickCore/paint.h"
77 #include "MagickCore/pixel-accessor.h"
78 #include "MagickCore/profile.h"
79 #include "MagickCore/property.h"
80 #include "MagickCore/quantize.h"
81 #include "MagickCore/quantum-private.h"
82 #include "MagickCore/registry.h"
83 #include "MagickCore/resize.h"
84 #include "MagickCore/resource_.h"
85 #include "MagickCore/segment.h"
86 #include "MagickCore/shear.h"
87 #include "MagickCore/signature.h"
88 #include "MagickCore/statistic.h"
89 #include "MagickCore/static.h"
90 #include "MagickCore/string_.h"
91 #include "MagickCore/string-private.h"
92 #include "MagickCore/transform.h"
93 #include "MagickCore/threshold.h"
94 #include "MagickCore/utility.h"
95 #if defined(MAGICKCORE_XML_DELEGATE)
96 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
97 # if !defined(__MINGW32__) && !defined(__MINGW64__)
98 # include <win32config.h>
101 # include <libxml/parser.h>
102 # include <libxml/xmlmemory.h>
103 # include <libxml/parserInternals.h>
104 # include <libxml/xmlerror.h>
110 #define ThrowMSLException(severity,tag,reason) \
111 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
115 Typedef declaractions.
117 typedef struct _MSLGroupInfo
120 numImages; /* how many images are in this group */
123 typedef struct _MSLInfo
148 #if defined(MAGICKCORE_XML_DELEGATE)
158 Forward declarations.
160 #if defined(MAGICKCORE_XML_DELEGATE)
161 static MagickBooleanType
162 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
164 static MagickBooleanType
165 SetMSLAttributes(MSLInfo *,const char *,const char *);
168 #if defined(MAGICKCORE_XML_DELEGATE)
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 % R e a d M S L I m a g e %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
182 % It allocates the memory necessary for the new Image structure and returns a
183 % pointer to the new image.
185 % The format of the ReadMSLImage method is:
187 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
189 % A description of each parameter follows:
191 % o image_info: the image info.
193 % o exception: return any errors or warnings in this structure.
197 #if defined(__cplusplus) || defined(c_plusplus)
201 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
202 ExceptionInfo *exception)
216 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
217 sans_exception=AcquireExceptionInfo();
218 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
219 sans_exception=DestroyExceptionInfo(sans_exception);
220 if (image != (Image *) NULL)
222 read_info=CloneImageInfo(image_info);
223 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
224 image=ReadImage(read_info,exception);
225 read_info=DestroyImageInfo(read_info);
226 if (image != (Image *) NULL)
227 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
231 static int IsPathDirectory(const char *path)
239 if ((path == (const char *) NULL) || (*path == '\0'))
241 status=GetPathAttributes(path,&attributes);
242 if (status == MagickFalse)
244 if (S_ISDIR(attributes.st_mode) == 0)
249 static int MSLIsStandalone(void *context)
255 Is this document tagged standalone?
257 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
258 msl_info=(MSLInfo *) context;
259 return(msl_info->document->standalone == 1);
262 static int MSLHasInternalSubset(void *context)
268 Does this document has an internal subset?
270 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
271 " SAX.MSLHasInternalSubset()");
272 msl_info=(MSLInfo *) context;
273 return(msl_info->document->intSubset != NULL);
276 static int MSLHasExternalSubset(void *context)
282 Does this document has an external subset?
284 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
285 " SAX.MSLHasExternalSubset()");
286 msl_info=(MSLInfo *) context;
287 return(msl_info->document->extSubset != NULL);
290 static void MSLInternalSubset(void *context,const xmlChar *name,
291 const xmlChar *external_id,const xmlChar *system_id)
297 Does this document has an internal subset?
299 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
300 " SAX.internalSubset(%s %s %s)",name,
301 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
302 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
303 msl_info=(MSLInfo *) context;
304 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
307 static xmlParserInputPtr MSLResolveEntity(void *context,
308 const xmlChar *public_id,const xmlChar *system_id)
317 Special entity resolver, better left to the parser, it has more
318 context than the application layer. The default behaviour is to
319 not resolve the entities, in that case the ENTITY_REF nodes are
320 built in the structure (and the parameter values).
322 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
323 " SAX.resolveEntity(%s, %s)",
324 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
325 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
326 msl_info=(MSLInfo *) context;
327 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
328 public_id,msl_info->parser);
332 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
338 Get an entity by name.
340 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
341 " SAX.MSLGetEntity(%s)",(const char *) name);
342 msl_info=(MSLInfo *) context;
343 return(xmlGetDocEntity(msl_info->document,name));
346 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
352 Get a parameter entity by name.
354 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
355 " SAX.getParameterEntity(%s)",(const char *) name);
356 msl_info=(MSLInfo *) context;
357 return(xmlGetParameterEntity(msl_info->document,name));
360 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
361 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
367 An entity definition has been parsed.
369 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
370 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
371 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
372 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
374 msl_info=(MSLInfo *) context;
375 if (msl_info->parser->inSubset == 1)
376 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
379 if (msl_info->parser->inSubset == 2)
380 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
384 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
385 const xmlChar *name,int type,int value,const xmlChar *default_value,
386 xmlEnumerationPtr tree)
399 An attribute definition has been parsed.
401 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
402 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
404 msl_info=(MSLInfo *) context;
405 fullname=(xmlChar *) NULL;
406 prefix=(xmlChar *) NULL;
407 parser=msl_info->parser;
408 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
409 if (parser->inSubset == 1)
410 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
411 element,fullname,prefix,(xmlAttributeType) type,
412 (xmlAttributeDefault) value,default_value,tree);
414 if (parser->inSubset == 2)
415 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
416 element,fullname,prefix,(xmlAttributeType) type,
417 (xmlAttributeDefault) value,default_value,tree);
418 if (prefix != (xmlChar *) NULL)
420 if (fullname != (xmlChar *) NULL)
424 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
425 xmlElementContentPtr content)
434 An element definition has been parsed.
436 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
437 " SAX.elementDecl(%s, %d, ...)",name,type);
438 msl_info=(MSLInfo *) context;
439 parser=msl_info->parser;
440 if (parser->inSubset == 1)
441 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
442 name,(xmlElementTypeVal) type,content);
444 if (parser->inSubset == 2)
445 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
446 name,(xmlElementTypeVal) type,content);
449 static void MSLNotationDeclaration(void *context,const xmlChar *name,
450 const xmlChar *public_id,const xmlChar *system_id)
459 What to do when a notation declaration has been parsed.
461 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
462 " SAX.notationDecl(%s, %s, %s)",name,
463 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
464 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
465 msl_info=(MSLInfo *) context;
466 parser=msl_info->parser;
467 if (parser->inSubset == 1)
468 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
469 name,public_id,system_id);
471 if (parser->inSubset == 2)
472 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
473 name,public_id,system_id);
476 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
477 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
483 What to do when an unparsed entity declaration is parsed.
485 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
486 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
487 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
488 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
490 msl_info=(MSLInfo *) context;
491 (void) xmlAddDocEntity(msl_info->document,name,
492 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
496 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
502 Receive the document locator at startup, actually xmlDefaultSAXLocator.
504 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
505 " SAX.setDocumentLocator()\n");
507 msl_info=(MSLInfo *) context;
511 static void MSLStartDocument(void *context)
520 Called when the document start being processed.
522 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
523 " SAX.startDocument()");
524 msl_info=(MSLInfo *) context;
525 parser=msl_info->parser;
526 msl_info->document=xmlNewDoc(parser->version);
527 if (msl_info->document == (xmlDocPtr) NULL)
529 if (parser->encoding == NULL)
530 msl_info->document->encoding=NULL;
532 msl_info->document->encoding=xmlStrdup(parser->encoding);
533 msl_info->document->standalone=parser->standalone;
536 static void MSLEndDocument(void *context)
542 Called when the document end has been detected.
544 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
545 msl_info=(MSLInfo *) context;
546 if (msl_info->content != (char *) NULL)
547 msl_info->content=DestroyString(msl_info->content);
550 static void MSLPushImage(MSLInfo *msl_info,Image *image)
555 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
556 assert(msl_info != (MSLInfo *) NULL);
559 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
560 (n+1),sizeof(*msl_info->image_info));
561 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
562 (n+1),sizeof(*msl_info->draw_info));
563 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
564 (n+1),sizeof(*msl_info->attributes));
565 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
566 sizeof(*msl_info->image));
567 if ((msl_info->image_info == (ImageInfo **) NULL) ||
568 (msl_info->draw_info == (DrawInfo **) NULL) ||
569 (msl_info->attributes == (Image **) NULL) ||
570 (msl_info->image == (Image **) NULL))
571 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
572 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
573 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
574 msl_info->draw_info[n-1]);
575 if (image == (Image *) NULL)
576 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
577 msl_info->exception);
579 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
580 msl_info->exception);
581 msl_info->image[n]=(Image *) image;
582 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
583 (msl_info->attributes[n] == (Image *) NULL))
584 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
585 if (msl_info->number_groups != 0)
586 msl_info->group_info[msl_info->number_groups-1].numImages++;
589 static void MSLPopImage(MSLInfo *msl_info)
591 if (msl_info->number_groups != 0)
593 if (msl_info->image[msl_info->n] != (Image *) NULL)
594 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
595 msl_info->attributes[msl_info->n]=DestroyImage(
596 msl_info->attributes[msl_info->n]);
597 msl_info->image_info[msl_info->n]=DestroyImageInfo(
598 msl_info->image_info[msl_info->n]);
602 static void MSLStartElement(void *context,const xmlChar *tag,
603 const xmlChar **attributes)
662 Called when an opening tag has been processed.
664 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
665 " SAX.startElement(%s",tag);
666 exception=AcquireExceptionInfo();
667 msl_info=(MSLInfo *) context;
669 keyword=(const char *) NULL;
671 SetGeometryInfo(&geometry_info);
672 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
673 channel=DefaultChannels;
679 if (LocaleCompare((const char *) tag,"add-noise") == 0)
690 if (msl_info->image[n] == (Image *) NULL)
692 ThrowMSLException(OptionError,"NoImagesDefined",
697 if (attributes != (const xmlChar **) NULL)
698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
700 keyword=(const char *) attributes[i++];
701 attribute=InterpretImageProperties(msl_info->image_info[n],
702 msl_info->attributes[n],(const char *) attributes[i],
704 CloneString(&value,attribute);
710 if (LocaleCompare(keyword,"channel") == 0)
712 option=ParseChannelOption(value);
714 ThrowMSLException(OptionError,"UnrecognizedChannelType",
716 channel=(ChannelType) option;
719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
726 if (LocaleCompare(keyword,"noise") == 0)
728 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
731 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
733 noise=(NoiseType) option;
736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
748 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
749 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
750 msl_info->exception);
751 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
752 if (noise_image == (Image *) NULL)
754 msl_info->image[n]=DestroyImage(msl_info->image[n]);
755 msl_info->image[n]=noise_image;
758 if (LocaleCompare((const char *) tag,"annotate") == 0)
766 if (msl_info->image[n] == (Image *) NULL)
768 ThrowMSLException(OptionError,"NoImagesDefined",
772 draw_info=CloneDrawInfo(msl_info->image_info[n],
773 msl_info->draw_info[n]);
775 current=draw_info->affine;
776 GetAffineMatrix(&affine);
777 if (attributes != (const xmlChar **) NULL)
778 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
780 keyword=(const char *) attributes[i++];
781 attribute=InterpretImageProperties(msl_info->image_info[n],
782 msl_info->attributes[n],(const char *) attributes[i],
784 CloneString(&value,attribute);
790 if (LocaleCompare(keyword,"affine") == 0)
796 draw_info->affine.sx=StringToDouble(p,&p);
799 draw_info->affine.rx=StringToDouble(p,&p);
802 draw_info->affine.ry=StringToDouble(p,&p);
805 draw_info->affine.sy=StringToDouble(p,&p);
808 draw_info->affine.tx=StringToDouble(p,&p);
811 draw_info->affine.ty=StringToDouble(p,&p);
814 if (LocaleCompare(keyword,"align") == 0)
816 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
819 ThrowMSLException(OptionError,"UnrecognizedAlignType",
821 draw_info->align=(AlignType) option;
824 if (LocaleCompare(keyword,"antialias") == 0)
826 option=ParseCommandOption(MagickBooleanOptions,
829 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
831 draw_info->stroke_antialias=(MagickBooleanType) option;
832 draw_info->text_antialias=(MagickBooleanType) option;
835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
842 if (LocaleCompare(keyword,"density") == 0)
844 CloneString(&draw_info->density,value);
847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
854 if (LocaleCompare(keyword,"encoding") == 0)
856 CloneString(&draw_info->encoding,value);
859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
866 if (LocaleCompare(keyword, "fill") == 0)
868 (void) QueryColorCompliance(value,AllCompliance,
869 &draw_info->fill,exception);
872 if (LocaleCompare(keyword,"family") == 0)
874 CloneString(&draw_info->family,value);
877 if (LocaleCompare(keyword,"font") == 0)
879 CloneString(&draw_info->font,value);
882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
889 if (LocaleCompare(keyword,"geometry") == 0)
891 flags=ParseGravityGeometry(msl_info->image[n],value,
892 &geometry,exception);
895 if (LocaleCompare(keyword,"gravity") == 0)
897 option=ParseCommandOption(MagickGravityOptions,
900 ThrowMSLException(OptionError,"UnrecognizedGravityType",
902 draw_info->gravity=(GravityType) option;
905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
912 if (LocaleCompare(keyword,"pointsize") == 0)
914 draw_info->pointsize=StringToDouble(value,(char **) NULL);
917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
924 if (LocaleCompare(keyword,"rotate") == 0)
926 angle=StringToDouble(value,(char **) NULL);
927 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
928 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
929 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
930 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
940 if (LocaleCompare(keyword,"scale") == 0)
942 flags=ParseGeometry(value,&geometry_info);
943 if ((flags & SigmaValue) == 0)
944 geometry_info.sigma=1.0;
945 affine.sx=geometry_info.rho;
946 affine.sy=geometry_info.sigma;
949 if (LocaleCompare(keyword,"skewX") == 0)
951 angle=StringToDouble(value,(char **) NULL);
952 affine.ry=tan(DegreesToRadians(fmod((double) angle,
956 if (LocaleCompare(keyword,"skewY") == 0)
958 angle=StringToDouble(value,(char **) NULL);
959 affine.rx=tan(DegreesToRadians(fmod((double) angle,
963 if (LocaleCompare(keyword,"stretch") == 0)
965 option=ParseCommandOption(MagickStretchOptions,
968 ThrowMSLException(OptionError,"UnrecognizedStretchType",
970 draw_info->stretch=(StretchType) option;
973 if (LocaleCompare(keyword, "stroke") == 0)
975 (void) QueryColorCompliance(value,AllCompliance,
976 &draw_info->stroke,exception);
979 if (LocaleCompare(keyword,"strokewidth") == 0)
981 draw_info->stroke_width=StringToLong(value);
984 if (LocaleCompare(keyword,"style") == 0)
986 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
989 ThrowMSLException(OptionError,"UnrecognizedStyleType",
991 draw_info->style=(StyleType) option;
994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1001 if (LocaleCompare(keyword,"text") == 0)
1003 CloneString(&draw_info->text,value);
1006 if (LocaleCompare(keyword,"translate") == 0)
1008 flags=ParseGeometry(value,&geometry_info);
1009 if ((flags & SigmaValue) == 0)
1010 geometry_info.sigma=1.0;
1011 affine.tx=geometry_info.rho;
1012 affine.ty=geometry_info.sigma;
1015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1022 if (LocaleCompare(keyword, "undercolor") == 0)
1024 (void) QueryColorCompliance(value,AllCompliance,
1025 &draw_info->undercolor,exception);
1028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1035 if (LocaleCompare(keyword,"weight") == 0)
1037 draw_info->weight=StringToLong(value);
1040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1047 if (LocaleCompare(keyword,"x") == 0)
1049 geometry.x=StringToLong(value);
1052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1059 if (LocaleCompare(keyword,"y") == 0)
1061 geometry.y=StringToLong(value);
1064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1076 (void) FormatLocaleString(text,MaxTextExtent,
1077 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1078 geometry.height,(double) geometry.x,(double) geometry.y);
1079 CloneString(&draw_info->geometry,text);
1080 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1081 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1082 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1083 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1084 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1086 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1088 (void) AnnotateImage(msl_info->image[n],draw_info,
1089 msl_info->exception);
1090 draw_info=DestroyDrawInfo(draw_info);
1093 if (LocaleCompare((const char *) tag,"append") == 0)
1101 if (msl_info->image[n] == (Image *) NULL)
1103 ThrowMSLException(OptionError,"NoImagesDefined",
1104 (const char *) tag);
1108 if (attributes != (const xmlChar **) NULL)
1109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1111 keyword=(const char *) attributes[i++];
1112 attribute=InterpretImageProperties(msl_info->image_info[n],
1113 msl_info->attributes[n],(const char *) attributes[i],
1115 CloneString(&value,attribute);
1121 if (LocaleCompare(keyword,"stack") == 0)
1123 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1126 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1128 stack=(MagickBooleanType) option;
1131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1143 append_image=AppendImages(msl_info->image[n],stack,
1144 msl_info->exception);
1145 if (append_image == (Image *) NULL)
1147 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1148 msl_info->image[n]=append_image;
1151 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1157 if (LocaleCompare((const char *) tag,"blur") == 0)
1165 if (msl_info->image[n] == (Image *) NULL)
1167 ThrowMSLException(OptionError,"NoImagesDefined",
1168 (const char *) tag);
1171 if (attributes != (const xmlChar **) NULL)
1172 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1174 keyword=(const char *) attributes[i++];
1175 attribute=InterpretImageProperties(msl_info->image_info[n],
1176 msl_info->attributes[n],(const char *) attributes[i],
1178 CloneString(&value,attribute);
1184 if (LocaleCompare(keyword,"channel") == 0)
1186 option=ParseChannelOption(value);
1188 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1190 channel=(ChannelType) option;
1193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1200 if (LocaleCompare(keyword,"geometry") == 0)
1202 flags=ParseGeometry(value,&geometry_info);
1203 if ((flags & SigmaValue) == 0)
1204 geometry_info.sigma=1.0;
1207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1214 if (LocaleCompare(keyword,"radius") == 0)
1216 geometry_info.rho=StringToDouble(value,(char **) NULL);
1219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1226 if (LocaleCompare(keyword,"sigma") == 0)
1228 geometry_info.sigma=StringToLong(value);
1231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1243 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
1244 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1245 geometry_info.sigma,msl_info->exception);
1246 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
1247 if (blur_image == (Image *) NULL)
1249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1250 msl_info->image[n]=blur_image;
1253 if (LocaleCompare((const char *) tag,"border") == 0)
1261 if (msl_info->image[n] == (Image *) NULL)
1263 ThrowMSLException(OptionError,"NoImagesDefined",
1264 (const char *) tag);
1267 SetGeometry(msl_info->image[n],&geometry);
1268 if (attributes != (const xmlChar **) NULL)
1269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1271 keyword=(const char *) attributes[i++];
1272 attribute=InterpretImageProperties(msl_info->image_info[n],
1273 msl_info->attributes[n],(const char *) attributes[i],
1275 CloneString(&value,attribute);
1281 if (LocaleCompare(keyword,"compose") == 0)
1283 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1286 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1288 msl_info->image[n]->compose=(CompositeOperator) option;
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword, "fill") == 0)
1300 (void) QueryColorCompliance(value,AllCompliance,
1301 &msl_info->image[n]->border_color,exception);
1304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1311 if (LocaleCompare(keyword,"geometry") == 0)
1313 flags=ParsePageGeometry(msl_info->image[n],value,
1314 &geometry,exception);
1315 if ((flags & HeightValue) == 0)
1316 geometry.height=geometry.width;
1319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1326 if (LocaleCompare(keyword,"height") == 0)
1328 geometry.height=StringToLong(value);
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 if (LocaleCompare(keyword,"width") == 0)
1340 geometry.width=StringToLong(value);
1343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1355 border_image=BorderImage(msl_info->image[n],&geometry,
1356 msl_info->image[n]->compose,msl_info->exception);
1357 if (border_image == (Image *) NULL)
1359 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1360 msl_info->image[n]=border_image;
1363 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1368 if (LocaleCompare((const char *) tag,"colorize") == 0)
1371 blend[MaxTextExtent];
1382 if (msl_info->image[n] == (Image *) NULL)
1384 ThrowMSLException(OptionError,"NoImagesDefined",
1385 (const char *) tag);
1388 GetPixelInfo(msl_info->image[n],&target);
1389 (void) CopyMagickString(blend,"100",MaxTextExtent);
1390 if (attributes != (const xmlChar **) NULL)
1391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1393 keyword=(const char *) attributes[i++];
1394 attribute=InterpretImageProperties(msl_info->image_info[n],
1395 msl_info->attributes[n],(const char *) attributes[i],
1397 CloneString(&value,attribute);
1403 if (LocaleCompare(keyword,"blend") == 0)
1405 (void) CopyMagickString(blend,value,MaxTextExtent);
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 if (LocaleCompare(keyword,"fill") == 0)
1417 (void) QueryColorCompliance(value,AllCompliance,
1418 &target,msl_info->exception);
1421 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1433 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1434 msl_info->exception);
1435 if (colorize_image == (Image *) NULL)
1437 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1438 msl_info->image[n]=colorize_image;
1441 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1447 if (msl_info->image[n] == (Image *) NULL)
1449 ThrowMSLException(OptionError,"NoImagesDefined",
1450 (const char *) tag);
1454 NOTE: charcoal can have no attributes, since we use all the defaults!
1456 if (attributes != (const xmlChar **) NULL)
1458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1460 keyword=(const char *) attributes[i++];
1461 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1462 msl_info->attributes[n],(const char *) attributes[i],exception));
1468 if (LocaleCompare(keyword,"radius") == 0)
1470 radius=StringToDouble(value,(char **) NULL);
1473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1479 if (LocaleCompare(keyword,"sigma") == 0)
1481 sigma = StringToLong( value );
1484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1503 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1504 msl_info->exception);
1505 if (newImage == (Image *) NULL)
1507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1508 msl_info->image[n]=newImage;
1512 if (LocaleCompare((const char *) tag,"chop") == 0)
1520 if (msl_info->image[n] == (Image *) NULL)
1522 ThrowMSLException(OptionError,"NoImagesDefined",
1523 (const char *) tag);
1526 SetGeometry(msl_info->image[n],&geometry);
1527 if (attributes != (const xmlChar **) NULL)
1528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1530 keyword=(const char *) attributes[i++];
1531 attribute=InterpretImageProperties(msl_info->image_info[n],
1532 msl_info->attributes[n],(const char *) attributes[i],
1534 CloneString(&value,attribute);
1540 if (LocaleCompare(keyword,"geometry") == 0)
1542 flags=ParsePageGeometry(msl_info->image[n],value,
1543 &geometry,exception);
1544 if ((flags & HeightValue) == 0)
1545 geometry.height=geometry.width;
1548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1555 if (LocaleCompare(keyword,"height") == 0)
1557 geometry.height=StringToLong(value);
1560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1567 if (LocaleCompare(keyword,"width") == 0)
1569 geometry.width=StringToLong(value);
1572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 if (LocaleCompare(keyword,"x") == 0)
1581 geometry.x=StringToLong(value);
1584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1591 if (LocaleCompare(keyword,"y") == 0)
1593 geometry.y=StringToLong(value);
1596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1608 chop_image=ChopImage(msl_info->image[n],&geometry,
1609 msl_info->exception);
1610 if (chop_image == (Image *) NULL)
1612 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1613 msl_info->image[n]=chop_image;
1616 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1625 Color floodfill image.
1627 if (msl_info->image[n] == (Image *) NULL)
1629 ThrowMSLException(OptionError,"NoImagesDefined",
1630 (const char *) tag);
1633 draw_info=CloneDrawInfo(msl_info->image_info[n],
1634 msl_info->draw_info[n]);
1635 SetGeometry(msl_info->image[n],&geometry);
1636 paint_method=FloodfillMethod;
1637 if (attributes != (const xmlChar **) NULL)
1638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1640 keyword=(const char *) attributes[i++];
1641 attribute=InterpretImageProperties(msl_info->image_info[n],
1642 msl_info->attributes[n],(const char *) attributes[i],
1644 CloneString(&value,attribute);
1650 if (LocaleCompare(keyword,"bordercolor") == 0)
1652 (void) QueryColorCompliance(value,AllCompliance,
1654 paint_method=FillToBorderMethod;
1657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1664 if (LocaleCompare(keyword,"fill") == 0)
1666 (void) QueryColorCompliance(value,AllCompliance,
1667 &draw_info->fill,exception);
1670 if (LocaleCompare(keyword,"fuzz") == 0)
1672 msl_info->image[n]->fuzz=StringToDouble(value,
1676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1683 if (LocaleCompare(keyword,"geometry") == 0)
1685 flags=ParsePageGeometry(msl_info->image[n],value,
1686 &geometry,exception);
1687 if ((flags & HeightValue) == 0)
1688 geometry.height=geometry.width;
1689 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1690 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1701 if (LocaleCompare(keyword,"x") == 0)
1703 geometry.x=StringToLong(value);
1704 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1705 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1716 if (LocaleCompare(keyword,"y") == 0)
1718 geometry.y=StringToLong(value);
1719 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1720 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1736 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1737 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1738 MagickFalse : MagickTrue,msl_info->exception);
1739 draw_info=DestroyDrawInfo(draw_info);
1742 if (LocaleCompare((const char *) tag,"comment") == 0)
1744 if (LocaleCompare((const char *) tag,"composite") == 0)
1747 composite_geometry[MaxTextExtent];
1759 if (msl_info->image[n] == (Image *) NULL)
1761 ThrowMSLException(OptionError,"NoImagesDefined",
1762 (const char *) tag);
1765 composite_image=NewImageList();
1766 compose=OverCompositeOp;
1767 if (attributes != (const xmlChar **) NULL)
1768 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1770 keyword=(const char *) attributes[i++];
1771 attribute=InterpretImageProperties(msl_info->image_info[n],
1772 msl_info->attributes[n],(const char *) attributes[i],
1774 CloneString(&value,attribute);
1780 if (LocaleCompare(keyword,"compose") == 0)
1782 option=ParseCommandOption(MagickComposeOptions,
1785 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1787 compose=(CompositeOperator) option;
1795 if (LocaleCompare(keyword,"image") == 0)
1796 for (j=0; j < msl_info->n; j++)
1801 attribute=GetImageProperty(msl_info->attributes[j],"id",
1803 if ((attribute != (const char *) NULL) &&
1804 (LocaleCompare(attribute,value) == 0))
1806 composite_image=CloneImage(msl_info->image[j],0,0,
1807 MagickFalse,exception);
1817 if (composite_image == (Image *) NULL)
1819 rotate_image=NewImageList();
1820 SetGeometry(msl_info->image[n],&geometry);
1821 if (attributes != (const xmlChar **) NULL)
1822 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1824 keyword=(const char *) attributes[i++];
1825 attribute=InterpretImageProperties(msl_info->image_info[n],
1826 msl_info->attributes[n],(const char *) attributes[i],
1828 CloneString(&value,attribute);
1834 if (LocaleCompare(keyword,"blend") == 0)
1836 (void) SetImageArtifact(composite_image,
1837 "compose:args",value);
1840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1847 if (LocaleCompare(keyword,"channel") == 0)
1849 option=ParseChannelOption(value);
1851 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1853 channel=(ChannelType) option;
1856 if (LocaleCompare(keyword, "color") == 0)
1858 (void) QueryColorCompliance(value,AllCompliance,
1859 &composite_image->background_color,exception);
1862 if (LocaleCompare(keyword,"compose") == 0)
1864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1871 if (LocaleCompare(keyword,"geometry") == 0)
1873 flags=ParsePageGeometry(msl_info->image[n],value,
1874 &geometry,exception);
1875 if ((flags & HeightValue) == 0)
1876 geometry.height=geometry.width;
1879 if (LocaleCompare(keyword,"gravity") == 0)
1881 option=ParseCommandOption(MagickGravityOptions,
1884 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1886 msl_info->image[n]->gravity=(GravityType) option;
1889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1896 if (LocaleCompare(keyword,"image") == 0)
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"mask") == 0)
1906 for (j=0; j < msl_info->n; j++)
1911 attribute=GetImageProperty(msl_info->attributes[j],"id",
1913 if ((attribute != (const char *) NULL) &&
1914 (LocaleCompare(value,value) == 0))
1916 SetImageType(composite_image,TrueColorMatteType,
1918 (void) CompositeImage(composite_image,
1919 msl_info->image[j],CopyAlphaCompositeOp,MagickTrue,
1924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1931 if (LocaleCompare(keyword,"opacity") == 0)
1946 opacity=StringToLong(value);
1947 if (compose != DissolveCompositeOp)
1949 (void) SetImageAlpha(composite_image,(Quantum)
1953 (void) SetImageArtifact(msl_info->image[n],
1954 "compose:args",value);
1955 if (composite_image->alpha_trait != BlendPixelTrait)
1956 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1958 composite_view=AcquireAuthenticCacheView(composite_image,exception);
1959 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1961 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1962 (ssize_t) composite_image->columns,1,exception);
1963 for (x=0; x < (ssize_t) composite_image->columns; x++)
1965 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1966 SetPixelAlpha(composite_image,
1967 ClampToQuantum(opacity),q);
1968 q+=GetPixelChannels(composite_image);
1970 if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
1973 composite_view=DestroyCacheView(composite_view);
1976 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1983 if (LocaleCompare(keyword,"rotate") == 0)
1985 rotate_image=RotateImage(composite_image,
1986 StringToDouble(value,(char **) NULL),exception);
1989 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1996 if (LocaleCompare(keyword,"tile") == 0)
2001 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2004 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2006 tile=(MagickBooleanType) option;
2008 if (rotate_image != (Image *) NULL)
2009 (void) SetImageArtifact(rotate_image,
2010 "compose:outside-overlay","false");
2012 (void) SetImageArtifact(composite_image,
2013 "compose:outside-overlay","false");
2014 image=msl_info->image[n];
2015 height=composite_image->rows;
2016 width=composite_image->columns;
2017 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2018 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2020 if (rotate_image != (Image *) NULL)
2021 (void) CompositeImage(image,rotate_image,compose,
2022 MagickTrue,x,y,exception);
2024 (void) CompositeImage(image,composite_image,
2025 compose,MagickTrue,x,y,exception);
2027 if (rotate_image != (Image *) NULL)
2028 rotate_image=DestroyImage(rotate_image);
2031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2038 if (LocaleCompare(keyword,"x") == 0)
2040 geometry.x=StringToLong(value);
2043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2050 if (LocaleCompare(keyword,"y") == 0)
2052 geometry.y=StringToLong(value);
2055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2067 image=msl_info->image[n];
2068 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2069 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2070 (double) composite_image->rows,(double) geometry.x,(double)
2072 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2074 channel_mask=SetImageChannelMask(image,channel);
2075 if (rotate_image == (Image *) NULL)
2076 CompositeImage(image,composite_image,compose,MagickTrue,geometry.x,
2077 geometry.y,exception);
2083 geometry.x-=(ssize_t) (rotate_image->columns-
2084 composite_image->columns)/2;
2085 geometry.y-=(ssize_t) (rotate_image->rows-
2086 composite_image->rows)/2;
2087 CompositeImage(image,rotate_image,compose,MagickTrue,geometry.x,
2088 geometry.y,exception);
2089 rotate_image=DestroyImage(rotate_image);
2091 (void) SetImageChannelMask(image,channel_mask);
2092 composite_image=DestroyImage(composite_image);
2095 if (LocaleCompare((const char *) tag,"contrast") == 0)
2103 if (msl_info->image[n] == (Image *) NULL)
2105 ThrowMSLException(OptionError,"NoImagesDefined",
2106 (const char *) tag);
2109 sharpen=MagickFalse;
2110 if (attributes != (const xmlChar **) NULL)
2111 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2113 keyword=(const char *) attributes[i++];
2114 attribute=InterpretImageProperties(msl_info->image_info[n],
2115 msl_info->attributes[n],(const char *) attributes[i],
2117 CloneString(&value,attribute);
2123 if (LocaleCompare(keyword,"sharpen") == 0)
2125 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2128 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2130 sharpen=(MagickBooleanType) option;
2133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2145 (void) ContrastImage(msl_info->image[n],sharpen,
2146 msl_info->exception);
2149 if (LocaleCompare((const char *) tag,"crop") == 0)
2157 if (msl_info->image[n] == (Image *) NULL)
2159 ThrowMSLException(OptionError,"NoImagesDefined",
2160 (const char *) tag);
2163 SetGeometry(msl_info->image[n],&geometry);
2164 if (attributes != (const xmlChar **) NULL)
2165 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2167 keyword=(const char *) attributes[i++];
2168 attribute=InterpretImageProperties(msl_info->image_info[n],
2169 msl_info->attributes[n],(const char *) attributes[i],
2171 CloneString(&value,attribute);
2177 if (LocaleCompare(keyword,"geometry") == 0)
2179 flags=ParseGravityGeometry(msl_info->image[n],value,
2180 &geometry,exception);
2183 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2190 if (LocaleCompare(keyword,"height") == 0)
2192 geometry.height=StringToLong(value);
2195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2202 if (LocaleCompare(keyword,"width") == 0)
2204 geometry.width=StringToLong(value);
2207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2214 if (LocaleCompare(keyword,"x") == 0)
2216 geometry.x=StringToLong(value);
2219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2226 if (LocaleCompare(keyword,"y") == 0)
2228 geometry.y=StringToLong(value);
2231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2243 crop_image=CropImage(msl_info->image[n],&geometry,
2244 msl_info->exception);
2245 if (crop_image == (Image *) NULL)
2247 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2248 msl_info->image[n]=crop_image;
2251 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2257 Cycle-colormap image.
2259 if (msl_info->image[n] == (Image *) NULL)
2261 ThrowMSLException(OptionError,"NoImagesDefined",
2262 (const char *) tag);
2266 if (attributes != (const xmlChar **) NULL)
2267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2269 keyword=(const char *) attributes[i++];
2270 attribute=InterpretImageProperties(msl_info->image_info[n],
2271 msl_info->attributes[n],(const char *) attributes[i],
2273 CloneString(&value,attribute);
2279 if (LocaleCompare(keyword,"display") == 0)
2281 display=StringToLong(value);
2284 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2290 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2296 (void) CycleColormapImage(msl_info->image[n],display,exception);
2299 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2304 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2312 if (msl_info->image[n] == (Image *) NULL)
2314 ThrowMSLException(OptionError,"NoImagesDefined",
2315 (const char *) tag);
2318 if (attributes != (const xmlChar **) NULL)
2319 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2321 keyword=(const char *) attributes[i++];
2322 attribute=InterpretImageProperties(msl_info->image_info[n],
2323 msl_info->attributes[n],(const char *) attributes[i],
2325 CloneString(&value,attribute);
2326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2328 despeckle_image=DespeckleImage(msl_info->image[n],
2329 msl_info->exception);
2330 if (despeckle_image == (Image *) NULL)
2332 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2333 msl_info->image[n]=despeckle_image;
2336 if (LocaleCompare((const char *) tag,"display") == 0)
2338 if (msl_info->image[n] == (Image *) NULL)
2340 ThrowMSLException(OptionError,"NoImagesDefined",
2341 (const char *) tag);
2344 if (attributes != (const xmlChar **) NULL)
2345 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2347 keyword=(const char *) attributes[i++];
2348 attribute=InterpretImageProperties(msl_info->image_info[n],
2349 msl_info->attributes[n],(const char *) attributes[i],
2351 CloneString(&value,attribute);
2356 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2362 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2363 msl_info->exception);
2366 if (LocaleCompare((const char *) tag,"draw") == 0)
2369 text[MaxTextExtent];
2374 if (msl_info->image[n] == (Image *) NULL)
2376 ThrowMSLException(OptionError,"NoImagesDefined",
2377 (const char *) tag);
2380 draw_info=CloneDrawInfo(msl_info->image_info[n],
2381 msl_info->draw_info[n]);
2383 current=draw_info->affine;
2384 GetAffineMatrix(&affine);
2385 if (attributes != (const xmlChar **) NULL)
2386 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2388 keyword=(const char *) attributes[i++];
2389 attribute=InterpretImageProperties(msl_info->image_info[n],
2390 msl_info->attributes[n],(const char *) attributes[i],
2392 CloneString(&value,attribute);
2398 if (LocaleCompare(keyword,"affine") == 0)
2404 draw_info->affine.sx=StringToDouble(p,&p);
2407 draw_info->affine.rx=StringToDouble(p,&p);
2410 draw_info->affine.ry=StringToDouble(p,&p);
2413 draw_info->affine.sy=StringToDouble(p,&p);
2416 draw_info->affine.tx=StringToDouble(p,&p);
2419 draw_info->affine.ty=StringToDouble(p,&p);
2422 if (LocaleCompare(keyword,"align") == 0)
2424 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2427 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2429 draw_info->align=(AlignType) option;
2432 if (LocaleCompare(keyword,"antialias") == 0)
2434 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2437 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2439 draw_info->stroke_antialias=(MagickBooleanType) option;
2440 draw_info->text_antialias=(MagickBooleanType) option;
2443 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2450 if (LocaleCompare(keyword,"density") == 0)
2452 CloneString(&draw_info->density,value);
2455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2462 if (LocaleCompare(keyword,"encoding") == 0)
2464 CloneString(&draw_info->encoding,value);
2467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2474 if (LocaleCompare(keyword, "fill") == 0)
2476 (void) QueryColorCompliance(value,AllCompliance,
2477 &draw_info->fill,exception);
2480 if (LocaleCompare(keyword,"family") == 0)
2482 CloneString(&draw_info->family,value);
2485 if (LocaleCompare(keyword,"font") == 0)
2487 CloneString(&draw_info->font,value);
2490 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2497 if (LocaleCompare(keyword,"geometry") == 0)
2499 flags=ParsePageGeometry(msl_info->image[n],value,
2500 &geometry,exception);
2501 if ((flags & HeightValue) == 0)
2502 geometry.height=geometry.width;
2505 if (LocaleCompare(keyword,"gravity") == 0)
2507 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2510 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2512 draw_info->gravity=(GravityType) option;
2515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2522 if (LocaleCompare(keyword,"points") == 0)
2524 if (LocaleCompare(draw_info->primitive,"path") == 0)
2526 (void) ConcatenateString(&draw_info->primitive," '");
2527 ConcatenateString(&draw_info->primitive,value);
2528 (void) ConcatenateString(&draw_info->primitive,"'");
2532 (void) ConcatenateString(&draw_info->primitive," ");
2533 ConcatenateString(&draw_info->primitive,value);
2537 if (LocaleCompare(keyword,"pointsize") == 0)
2539 draw_info->pointsize=StringToDouble(value,
2543 if (LocaleCompare(keyword,"primitive") == 0)
2545 CloneString(&draw_info->primitive,value);
2548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2555 if (LocaleCompare(keyword,"rotate") == 0)
2557 angle=StringToDouble(value,(char **) NULL);
2558 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2559 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2560 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2561 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2564 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2571 if (LocaleCompare(keyword,"scale") == 0)
2573 flags=ParseGeometry(value,&geometry_info);
2574 if ((flags & SigmaValue) == 0)
2575 geometry_info.sigma=1.0;
2576 affine.sx=geometry_info.rho;
2577 affine.sy=geometry_info.sigma;
2580 if (LocaleCompare(keyword,"skewX") == 0)
2582 angle=StringToDouble(value,(char **) NULL);
2583 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2586 if (LocaleCompare(keyword,"skewY") == 0)
2588 angle=StringToDouble(value,(char **) NULL);
2589 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2592 if (LocaleCompare(keyword,"stretch") == 0)
2594 option=ParseCommandOption(MagickStretchOptions,
2597 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2599 draw_info->stretch=(StretchType) option;
2602 if (LocaleCompare(keyword, "stroke") == 0)
2604 (void) QueryColorCompliance(value,AllCompliance,
2605 &draw_info->stroke,exception);
2608 if (LocaleCompare(keyword,"strokewidth") == 0)
2610 draw_info->stroke_width=StringToLong(value);
2613 if (LocaleCompare(keyword,"style") == 0)
2615 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2618 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2620 draw_info->style=(StyleType) option;
2623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2630 if (LocaleCompare(keyword,"text") == 0)
2632 CloneString(&draw_info->text,value);
2635 if (LocaleCompare(keyword,"translate") == 0)
2637 flags=ParseGeometry(value,&geometry_info);
2638 if ((flags & SigmaValue) == 0)
2639 geometry_info.sigma=1.0;
2640 affine.tx=geometry_info.rho;
2641 affine.ty=geometry_info.sigma;
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2651 if (LocaleCompare(keyword, "undercolor") == 0)
2653 (void) QueryColorCompliance(value,AllCompliance,
2654 &draw_info->undercolor,exception);
2657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2664 if (LocaleCompare(keyword,"weight") == 0)
2666 draw_info->weight=StringToLong(value);
2669 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2676 if (LocaleCompare(keyword,"x") == 0)
2678 geometry.x=StringToLong(value);
2681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2688 if (LocaleCompare(keyword,"y") == 0)
2690 geometry.y=StringToLong(value);
2693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2699 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2705 (void) FormatLocaleString(text,MaxTextExtent,
2706 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2707 geometry.height,(double) geometry.x,(double) geometry.y);
2708 CloneString(&draw_info->geometry,text);
2709 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2710 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2711 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2712 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2713 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2715 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2717 (void) DrawImage(msl_info->image[n],draw_info,exception);
2718 draw_info=DestroyDrawInfo(draw_info);
2721 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2726 if (LocaleCompare((const char *) tag,"edge") == 0)
2734 if (msl_info->image[n] == (Image *) NULL)
2736 ThrowMSLException(OptionError,"NoImagesDefined",
2737 (const char *) tag);
2740 if (attributes != (const xmlChar **) NULL)
2741 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2743 keyword=(const char *) attributes[i++];
2744 attribute=InterpretImageProperties(msl_info->image_info[n],
2745 msl_info->attributes[n],(const char *) attributes[i],
2747 CloneString(&value,attribute);
2753 if (LocaleCompare(keyword,"geometry") == 0)
2755 flags=ParseGeometry(value,&geometry_info);
2756 if ((flags & SigmaValue) == 0)
2757 geometry_info.sigma=1.0;
2760 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2767 if (LocaleCompare(keyword,"radius") == 0)
2769 geometry_info.rho=StringToDouble(value,(char **) NULL);
2772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2778 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2784 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2785 msl_info->exception);
2786 if (edge_image == (Image *) NULL)
2788 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2789 msl_info->image[n]=edge_image;
2792 if (LocaleCompare((const char *) tag,"emboss") == 0)
2800 if (msl_info->image[n] == (Image *) NULL)
2802 ThrowMSLException(OptionError,"NoImagesDefined",
2803 (const char *) tag);
2806 if (attributes != (const xmlChar **) NULL)
2807 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2809 keyword=(const char *) attributes[i++];
2810 attribute=InterpretImageProperties(msl_info->image_info[n],
2811 msl_info->attributes[n],(const char *) attributes[i],
2813 CloneString(&value,attribute);
2819 if (LocaleCompare(keyword,"geometry") == 0)
2821 flags=ParseGeometry(value,&geometry_info);
2822 if ((flags & SigmaValue) == 0)
2823 geometry_info.sigma=1.0;
2826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2833 if (LocaleCompare(keyword,"radius") == 0)
2835 geometry_info.rho=StringToDouble(value,
2839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2846 if (LocaleCompare(keyword,"sigma") == 0)
2848 geometry_info.sigma=StringToLong(value);
2851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2863 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2864 geometry_info.sigma,msl_info->exception);
2865 if (emboss_image == (Image *) NULL)
2867 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2868 msl_info->image[n]=emboss_image;
2871 if (LocaleCompare((const char *) tag,"enhance") == 0)
2879 if (msl_info->image[n] == (Image *) NULL)
2881 ThrowMSLException(OptionError,"NoImagesDefined",
2882 (const char *) tag);
2885 if (attributes != (const xmlChar **) NULL)
2886 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2888 keyword=(const char *) attributes[i++];
2889 attribute=InterpretImageProperties(msl_info->image_info[n],
2890 msl_info->attributes[n],(const char *) attributes[i],
2892 CloneString(&value,attribute);
2893 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2895 enhance_image=EnhanceImage(msl_info->image[n],
2896 msl_info->exception);
2897 if (enhance_image == (Image *) NULL)
2899 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2900 msl_info->image[n]=enhance_image;
2903 if (LocaleCompare((const char *) tag,"equalize") == 0)
2908 if (msl_info->image[n] == (Image *) NULL)
2910 ThrowMSLException(OptionError,"NoImagesDefined",
2911 (const char *) tag);
2914 if (attributes != (const xmlChar **) NULL)
2915 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2917 keyword=(const char *) attributes[i++];
2918 attribute=InterpretImageProperties(msl_info->image_info[n],
2919 msl_info->attributes[n],(const char *) attributes[i],
2921 CloneString(&value,attribute);
2926 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2932 (void) EqualizeImage(msl_info->image[n],
2933 msl_info->exception);
2936 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2941 if (LocaleCompare((const char *) tag, "flatten") == 0)
2943 if (msl_info->image[n] == (Image *) NULL)
2945 ThrowMSLException(OptionError,"NoImagesDefined",
2946 (const char *) tag);
2950 /* no attributes here */
2952 /* process the image */
2957 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2958 msl_info->exception);
2959 if (newImage == (Image *) NULL)
2961 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2962 msl_info->image[n]=newImage;
2966 if (LocaleCompare((const char *) tag,"flip") == 0)
2974 if (msl_info->image[n] == (Image *) NULL)
2976 ThrowMSLException(OptionError,"NoImagesDefined",
2977 (const char *) tag);
2980 if (attributes != (const xmlChar **) NULL)
2981 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2983 keyword=(const char *) attributes[i++];
2984 attribute=InterpretImageProperties(msl_info->image_info[n],
2985 msl_info->attributes[n],(const char *) attributes[i],
2987 CloneString(&value,attribute);
2988 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2990 flip_image=FlipImage(msl_info->image[n],
2991 msl_info->exception);
2992 if (flip_image == (Image *) NULL)
2994 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2995 msl_info->image[n]=flip_image;
2998 if (LocaleCompare((const char *) tag,"flop") == 0)
3006 if (msl_info->image[n] == (Image *) NULL)
3008 ThrowMSLException(OptionError,"NoImagesDefined",
3009 (const char *) tag);
3012 if (attributes != (const xmlChar **) NULL)
3013 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3015 keyword=(const char *) attributes[i++];
3016 attribute=InterpretImageProperties(msl_info->image_info[n],
3017 msl_info->attributes[n],(const char *) attributes[i],
3019 CloneString(&value,attribute);
3020 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3022 flop_image=FlopImage(msl_info->image[n],
3023 msl_info->exception);
3024 if (flop_image == (Image *) NULL)
3026 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3027 msl_info->image[n]=flop_image;
3030 if (LocaleCompare((const char *) tag,"frame") == 0)
3041 if (msl_info->image[n] == (Image *) NULL)
3043 ThrowMSLException(OptionError,"NoImagesDefined",
3044 (const char *) tag);
3047 (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info));
3048 SetGeometry(msl_info->image[n],&geometry);
3049 if (attributes != (const xmlChar **) NULL)
3050 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3052 keyword=(const char *) attributes[i++];
3053 attribute=InterpretImageProperties(msl_info->image_info[n],
3054 msl_info->attributes[n],(const char *) attributes[i],
3056 CloneString(&value,attribute);
3062 if (LocaleCompare(keyword,"compose") == 0)
3064 option=ParseCommandOption(MagickComposeOptions,
3067 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3069 msl_info->image[n]->compose=(CompositeOperator) option;
3072 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3079 if (LocaleCompare(keyword, "fill") == 0)
3081 (void) QueryColorCompliance(value,AllCompliance,
3082 &msl_info->image[n]->matte_color,exception);
3085 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3092 if (LocaleCompare(keyword,"geometry") == 0)
3094 flags=ParsePageGeometry(msl_info->image[n],value,
3095 &geometry,exception);
3096 if ((flags & HeightValue) == 0)
3097 geometry.height=geometry.width;
3098 frame_info.width=geometry.width;
3099 frame_info.height=geometry.height;
3100 frame_info.outer_bevel=geometry.x;
3101 frame_info.inner_bevel=geometry.y;
3104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3111 if (LocaleCompare(keyword,"height") == 0)
3113 frame_info.height=StringToLong(value);
3116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3123 if (LocaleCompare(keyword,"inner") == 0)
3125 frame_info.inner_bevel=StringToLong(value);
3128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3135 if (LocaleCompare(keyword,"outer") == 0)
3137 frame_info.outer_bevel=StringToLong(value);
3140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3147 if (LocaleCompare(keyword,"width") == 0)
3149 frame_info.width=StringToLong(value);
3152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3158 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3164 frame_info.x=(ssize_t) frame_info.width;
3165 frame_info.y=(ssize_t) frame_info.height;
3166 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3167 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3168 frame_image=FrameImage(msl_info->image[n],&frame_info,
3169 msl_info->image[n]->compose,msl_info->exception);
3170 if (frame_image == (Image *) NULL)
3172 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3173 msl_info->image[n]=frame_image;
3176 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3181 if (LocaleCompare((const char *) tag,"gamma") == 0)
3184 gamma[MaxTextExtent];
3192 if (msl_info->image[n] == (Image *) NULL)
3194 ThrowMSLException(OptionError,"NoImagesDefined",
3195 (const char *) tag);
3198 channel=UndefinedChannel;
3203 if (attributes != (const xmlChar **) NULL)
3204 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3206 keyword=(const char *) attributes[i++];
3207 attribute=InterpretImageProperties(msl_info->image_info[n],
3208 msl_info->attributes[n],(const char *) attributes[i],
3210 CloneString(&value,attribute);
3216 if (LocaleCompare(keyword,"blue") == 0)
3218 pixel.blue=StringToDouble(value,(char **) NULL);
3221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3228 if (LocaleCompare(keyword,"channel") == 0)
3230 option=ParseChannelOption(value);
3232 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3234 channel=(ChannelType) option;
3237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3244 if (LocaleCompare(keyword,"gamma") == 0)
3246 (void) CopyMagickString(gamma,value,MaxTextExtent);
3249 if (LocaleCompare(keyword,"green") == 0)
3251 pixel.green=StringToDouble(value,(char **) NULL);
3254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3261 if (LocaleCompare(keyword,"red") == 0)
3263 pixel.red=StringToDouble(value,(char **) NULL);
3266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3272 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3279 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3280 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3281 (void) GammaImage(msl_info->image[n],atof(gamma),
3282 msl_info->exception);
3285 else if (LocaleCompare((const char *) tag,"get") == 0)
3287 if (msl_info->image[n] == (Image *) NULL)
3289 ThrowMSLException(OptionError,"NoImagesDefined",
3290 (const char *) tag);
3293 if (attributes == (const xmlChar **) NULL)
3295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3297 keyword=(const char *) attributes[i++];
3298 CloneString(&value,(const char *) attributes[i]);
3299 (void) CopyMagickString(key,value,MaxTextExtent);
3305 if (LocaleCompare(keyword,"height") == 0)
3307 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3308 (double) msl_info->image[n]->rows);
3309 (void) SetImageProperty(msl_info->attributes[n],key,value,
3313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3318 if (LocaleCompare(keyword,"width") == 0)
3320 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3321 (double) msl_info->image[n]->columns);
3322 (void) SetImageProperty(msl_info->attributes[n],key,value,
3326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3330 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3337 else if (LocaleCompare((const char *) tag, "group") == 0)
3339 msl_info->number_groups++;
3340 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3341 msl_info->group_info,msl_info->number_groups+1UL,
3342 sizeof(*msl_info->group_info));
3345 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3350 if (LocaleCompare((const char *) tag,"image") == 0)
3352 MSLPushImage(msl_info,(Image *) NULL);
3353 if (attributes == (const xmlChar **) NULL)
3355 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3357 keyword=(const char *) attributes[i++];
3358 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3359 msl_info->attributes[n],(const char *) attributes[i],exception));
3365 if (LocaleCompare(keyword,"color") == 0)
3370 (void) CopyMagickString(msl_info->image_info[n]->filename,
3371 "xc:",MaxTextExtent);
3372 (void) ConcatenateMagickString(msl_info->image_info[n]->
3373 filename,value,MaxTextExtent);
3374 next_image=ReadImage(msl_info->image_info[n],exception);
3375 CatchException(exception);
3376 if (next_image == (Image *) NULL)
3378 if (msl_info->image[n] == (Image *) NULL)
3379 msl_info->image[n]=next_image;
3386 Link image into image list.
3388 p=msl_info->image[n];
3389 while (p->next != (Image *) NULL)
3390 p=GetNextImageInList(p);
3391 next_image->previous=p;
3396 (void) SetMSLAttributes(msl_info,keyword,value);
3401 (void) SetMSLAttributes(msl_info,keyword,value);
3408 if (LocaleCompare((const char *) tag,"implode") == 0)
3416 if (msl_info->image[n] == (Image *) NULL)
3418 ThrowMSLException(OptionError,"NoImagesDefined",
3419 (const char *) tag);
3422 if (attributes != (const xmlChar **) NULL)
3423 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3425 keyword=(const char *) attributes[i++];
3426 attribute=InterpretImageProperties(msl_info->image_info[n],
3427 msl_info->attributes[n],(const char *) attributes[i],
3429 CloneString(&value,attribute);
3435 if (LocaleCompare(keyword,"amount") == 0)
3437 geometry_info.rho=StringToDouble(value,
3441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3448 if (LocaleCompare(keyword,"geometry") == 0)
3450 flags=ParseGeometry(value,&geometry_info);
3451 if ((flags & SigmaValue) == 0)
3452 geometry_info.sigma=1.0;
3455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3467 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3468 msl_info->image[n]->interpolate,msl_info->exception);
3469 if (implode_image == (Image *) NULL)
3471 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3472 msl_info->image[n]=implode_image;
3475 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3480 if (LocaleCompare((const char *) tag,"label") == 0)
3482 if (LocaleCompare((const char *) tag, "level") == 0)
3485 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3487 if (msl_info->image[n] == (Image *) NULL)
3489 ThrowMSLException(OptionError,"NoImagesDefined",
3490 (const char *) tag);
3493 if (attributes == (const xmlChar **) NULL)
3495 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3497 keyword=(const char *) attributes[i++];
3498 CloneString(&value,(const char *) attributes[i]);
3499 (void) CopyMagickString(key,value,MaxTextExtent);
3505 if (LocaleCompare(keyword,"black") == 0)
3507 levelBlack = StringToDouble(value,(char **) NULL);
3510 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3516 if (LocaleCompare(keyword,"gamma") == 0)
3518 levelGamma = StringToDouble(value,(char **) NULL);
3521 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3527 if (LocaleCompare(keyword,"white") == 0)
3529 levelWhite = StringToDouble(value,(char **) NULL);
3532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3537 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3544 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3545 msl_info->exception);
3552 if (LocaleCompare((const char *) tag,"magnify") == 0)
3560 if (msl_info->image[n] == (Image *) NULL)
3562 ThrowMSLException(OptionError,"NoImagesDefined",
3563 (const char *) tag);
3566 if (attributes != (const xmlChar **) NULL)
3567 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3569 keyword=(const char *) attributes[i++];
3570 attribute=InterpretImageProperties(msl_info->image_info[n],
3571 msl_info->attributes[n],(const char *) attributes[i],
3573 CloneString(&value,attribute);
3574 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3576 magnify_image=MagnifyImage(msl_info->image[n],
3577 msl_info->exception);
3578 if (magnify_image == (Image *) NULL)
3580 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3581 msl_info->image[n]=magnify_image;
3584 if (LocaleCompare((const char *) tag,"map") == 0)
3598 if (msl_info->image[n] == (Image *) NULL)
3600 ThrowMSLException(OptionError,"NoImagesDefined",
3601 (const char *) tag);
3604 affinity_image=NewImageList();
3606 if (attributes != (const xmlChar **) NULL)
3607 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3609 keyword=(const char *) attributes[i++];
3610 attribute=InterpretImageProperties(msl_info->image_info[n],
3611 msl_info->attributes[n],(const char *) attributes[i],
3613 CloneString(&value,attribute);
3619 if (LocaleCompare(keyword,"dither") == 0)
3621 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3624 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3626 dither=(MagickBooleanType) option;
3629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3636 if (LocaleCompare(keyword,"image") == 0)
3637 for (j=0; j < msl_info->n; j++)
3642 attribute=GetImageProperty(msl_info->attributes[j],"id",
3644 if ((attribute != (const char *) NULL) &&
3645 (LocaleCompare(attribute,value) == 0))
3647 affinity_image=CloneImage(msl_info->image[j],0,0,
3648 MagickFalse,exception);
3656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3662 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3663 quantize_info->dither_method=dither != MagickFalse ?
3664 RiemersmaDitherMethod : NoDitherMethod;
3665 (void) RemapImages(quantize_info,msl_info->image[n],
3666 affinity_image,exception);
3667 quantize_info=DestroyQuantizeInfo(quantize_info);
3668 affinity_image=DestroyImage(affinity_image);
3671 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3683 Matte floodfill image.
3686 if (msl_info->image[n] == (Image *) NULL)
3688 ThrowMSLException(OptionError,"NoImagesDefined",
3689 (const char *) tag);
3692 SetGeometry(msl_info->image[n],&geometry);
3693 paint_method=FloodfillMethod;
3694 if (attributes != (const xmlChar **) NULL)
3695 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3697 keyword=(const char *) attributes[i++];
3698 attribute=InterpretImageProperties(msl_info->image_info[n],
3699 msl_info->attributes[n],(const char *) attributes[i],
3701 CloneString(&value,attribute);
3707 if (LocaleCompare(keyword,"bordercolor") == 0)
3709 (void) QueryColorCompliance(value,AllCompliance,
3711 paint_method=FillToBorderMethod;
3714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3721 if (LocaleCompare(keyword,"fuzz") == 0)
3723 msl_info->image[n]->fuzz=StringToDouble(value,
3727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3734 if (LocaleCompare(keyword,"geometry") == 0)
3736 flags=ParsePageGeometry(msl_info->image[n],value,
3737 &geometry,exception);
3738 if ((flags & HeightValue) == 0)
3739 geometry.height=geometry.width;
3740 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3741 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3745 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3752 if (LocaleCompare(keyword,"opacity") == 0)
3754 opacity=StringToDouble(value,(char **) NULL);
3757 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3764 if (LocaleCompare(keyword,"x") == 0)
3766 geometry.x=StringToLong(value);
3767 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3768 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3779 if (LocaleCompare(keyword,"y") == 0)
3781 geometry.y=StringToLong(value);
3782 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3783 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3793 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3799 draw_info=CloneDrawInfo(msl_info->image_info[n],
3800 msl_info->draw_info[n]);
3801 draw_info->fill.alpha=ClampToQuantum(opacity);
3802 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3803 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3804 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3805 MagickFalse : MagickTrue,msl_info->exception);
3806 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3807 draw_info=DestroyDrawInfo(draw_info);
3810 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3816 Median-filter image.
3818 if (msl_info->image[n] == (Image *) NULL)
3820 ThrowMSLException(OptionError,"NoImagesDefined",
3821 (const char *) tag);
3824 if (attributes != (const xmlChar **) NULL)
3825 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3827 keyword=(const char *) attributes[i++];
3828 attribute=InterpretImageProperties(msl_info->image_info[n],
3829 msl_info->attributes[n],(const char *) attributes[i],
3831 CloneString(&value,attribute);
3837 if (LocaleCompare(keyword,"geometry") == 0)
3839 flags=ParseGeometry(value,&geometry_info);
3840 if ((flags & SigmaValue) == 0)
3841 geometry_info.sigma=1.0;
3844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3851 if (LocaleCompare(keyword,"radius") == 0)
3853 geometry_info.rho=StringToDouble(value,
3857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3863 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3869 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3870 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3871 msl_info->exception);
3872 if (median_image == (Image *) NULL)
3874 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3875 msl_info->image[n]=median_image;
3878 if (LocaleCompare((const char *) tag,"minify") == 0)
3886 if (msl_info->image[n] == (Image *) NULL)
3888 ThrowMSLException(OptionError,"NoImagesDefined",
3889 (const char *) tag);
3892 if (attributes != (const xmlChar **) NULL)
3893 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3895 keyword=(const char *) attributes[i++];
3896 attribute=InterpretImageProperties(msl_info->image_info[n],
3897 msl_info->attributes[n],(const char *) attributes[i],
3899 CloneString(&value,attribute);
3900 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3902 minify_image=MinifyImage(msl_info->image[n],
3903 msl_info->exception);
3904 if (minify_image == (Image *) NULL)
3906 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3907 msl_info->image[n]=minify_image;
3910 if (LocaleCompare((const char *) tag,"msl") == 0 )
3912 if (LocaleCompare((const char *) tag,"modulate") == 0)
3915 modulate[MaxTextExtent];
3920 if (msl_info->image[n] == (Image *) NULL)
3922 ThrowMSLException(OptionError,"NoImagesDefined",
3923 (const char *) tag);
3926 geometry_info.rho=100.0;
3927 geometry_info.sigma=100.0;
3928 geometry_info.xi=100.0;
3929 if (attributes != (const xmlChar **) NULL)
3930 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3932 keyword=(const char *) attributes[i++];
3933 attribute=InterpretImageProperties(msl_info->image_info[n],
3934 msl_info->attributes[n],(const char *) attributes[i],
3936 CloneString(&value,attribute);
3942 if (LocaleCompare(keyword,"blackness") == 0)
3944 geometry_info.rho=StringToDouble(value,
3948 if (LocaleCompare(keyword,"brightness") == 0)
3950 geometry_info.rho=StringToDouble(value,
3954 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3961 if (LocaleCompare(keyword,"factor") == 0)
3963 flags=ParseGeometry(value,&geometry_info);
3966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3973 if (LocaleCompare(keyword,"hue") == 0)
3975 geometry_info.xi=StringToDouble(value,
3979 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3986 if (LocaleCompare(keyword,"lightness") == 0)
3988 geometry_info.rho=StringToDouble(value,
3992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3999 if (LocaleCompare(keyword,"saturation") == 0)
4001 geometry_info.sigma=StringToDouble(value,
4005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4012 if (LocaleCompare(keyword,"whiteness") == 0)
4014 geometry_info.sigma=StringToDouble(value,
4018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4030 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4031 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4032 (void) ModulateImage(msl_info->image[n],modulate,
4033 msl_info->exception);
4036 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4041 if (LocaleCompare((const char *) tag,"negate") == 0)
4049 if (msl_info->image[n] == (Image *) NULL)
4051 ThrowMSLException(OptionError,"NoImagesDefined",
4052 (const char *) tag);
4056 if (attributes != (const xmlChar **) NULL)
4057 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4059 keyword=(const char *) attributes[i++];
4060 attribute=InterpretImageProperties(msl_info->image_info[n],
4061 msl_info->attributes[n],(const char *) attributes[i],
4063 CloneString(&value,attribute);
4069 if (LocaleCompare(keyword,"channel") == 0)
4071 option=ParseChannelOption(value);
4073 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4075 channel=(ChannelType) option;
4078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4085 if (LocaleCompare(keyword,"gray") == 0)
4087 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4090 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4092 gray=(MagickBooleanType) option;
4095 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4107 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4108 (void) NegateImage(msl_info->image[n],gray,
4109 msl_info->exception);
4110 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4113 if (LocaleCompare((const char *) tag,"normalize") == 0)
4118 if (msl_info->image[n] == (Image *) NULL)
4120 ThrowMSLException(OptionError,"NoImagesDefined",
4121 (const char *) tag);
4124 if (attributes != (const xmlChar **) NULL)
4125 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4127 keyword=(const char *) attributes[i++];
4128 attribute=InterpretImageProperties(msl_info->image_info[n],
4129 msl_info->attributes[n],(const char *) attributes[i],
4131 CloneString(&value,attribute);
4137 if (LocaleCompare(keyword,"channel") == 0)
4139 option=ParseChannelOption(value);
4141 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4143 channel=(ChannelType) option;
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4158 (void) NormalizeImage(msl_info->image[n],
4159 msl_info->exception);
4162 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4167 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4175 if (msl_info->image[n] == (Image *) NULL)
4177 ThrowMSLException(OptionError,"NoImagesDefined",
4178 (const char *) tag);
4181 if (attributes != (const xmlChar **) NULL)
4182 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4184 keyword=(const char *) attributes[i++];
4185 attribute=InterpretImageProperties(msl_info->image_info[n],
4186 msl_info->attributes[n],(const char *) attributes[i],
4188 CloneString(&value,attribute);
4194 if (LocaleCompare(keyword,"geometry") == 0)
4196 flags=ParseGeometry(value,&geometry_info);
4197 if ((flags & SigmaValue) == 0)
4198 geometry_info.sigma=1.0;
4201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4208 if (LocaleCompare(keyword,"radius") == 0)
4210 geometry_info.rho=StringToDouble(value,
4214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4226 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4227 geometry_info.sigma,msl_info->exception);
4228 if (paint_image == (Image *) NULL)
4230 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4231 msl_info->image[n]=paint_image;
4234 if (LocaleCompare((const char *) tag,"opaque") == 0)
4243 if (msl_info->image[n] == (Image *) NULL)
4245 ThrowMSLException(OptionError,"NoImagesDefined",
4246 (const char *) tag);
4249 (void) QueryColorCompliance("none",AllCompliance,&target,
4251 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4253 if (attributes != (const xmlChar **) NULL)
4254 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4256 keyword=(const char *) attributes[i++];
4257 attribute=InterpretImageProperties(msl_info->image_info[n],
4258 msl_info->attributes[n],(const char *) attributes[i],
4260 CloneString(&value,attribute);
4266 if (LocaleCompare(keyword,"channel") == 0)
4268 option=ParseChannelOption(value);
4270 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4272 channel=(ChannelType) option;
4275 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4282 if (LocaleCompare(keyword,"fill") == 0)
4284 (void) QueryColorCompliance(value,AllCompliance,
4285 &fill_color,exception);
4288 if (LocaleCompare(keyword,"fuzz") == 0)
4290 msl_info->image[n]->fuzz=StringToDouble(value,
4294 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4300 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4306 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4307 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4308 MagickFalse,msl_info->exception);
4309 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4312 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4317 if (LocaleCompare((const char *) tag,"print") == 0)
4319 if (attributes == (const xmlChar **) NULL)
4321 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4323 keyword=(const char *) attributes[i++];
4324 attribute=InterpretImageProperties(msl_info->image_info[n],
4325 msl_info->attributes[n],(const char *) attributes[i],
4327 CloneString(&value,attribute);
4333 if (LocaleCompare(keyword,"output") == 0)
4335 (void) FormatLocaleFile(stdout,"%s",value);
4338 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4343 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4350 if (LocaleCompare((const char *) tag, "profile") == 0)
4352 if (msl_info->image[n] == (Image *) NULL)
4354 ThrowMSLException(OptionError,"NoImagesDefined",
4355 (const char *) tag);
4358 if (attributes == (const xmlChar **) NULL)
4360 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4374 keyword=(const char *) attributes[i++];
4375 attribute=InterpretImageProperties(msl_info->image_info[n],
4376 msl_info->attributes[n],(const char *) attributes[i],
4378 CloneString(&value,attribute);
4379 if (*keyword == '!')
4382 Remove a profile from the image.
4384 (void) ProfileImage(msl_info->image[n],keyword,
4385 (const unsigned char *) NULL,0,exception);
4389 Associate a profile with the image.
4391 profile_info=CloneImageInfo(msl_info->image_info[n]);
4392 profile=GetImageProfile(msl_info->image[n],"iptc");
4393 if (profile != (StringInfo *) NULL)
4394 profile_info->profile=(void *) CloneStringInfo(profile);
4395 profile_image=GetImageCache(profile_info,keyword,exception);
4396 profile_info=DestroyImageInfo(profile_info);
4397 if (profile_image == (Image *) NULL)
4400 name[MaxTextExtent],
4401 filename[MaxTextExtent];
4409 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4410 (void) CopyMagickString(name,keyword,MaxTextExtent);
4411 for (p=filename; *p != '\0'; p++)
4412 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4413 (IsPathAccessible(keyword) == MagickFalse))
4419 Look for profile name (e.g. name:profile).
4421 (void) CopyMagickString(name,filename,(size_t)
4423 for (q=filename; *q != '\0'; q++)
4427 profile=FileToStringInfo(filename,~0UL,exception);
4428 if (profile != (StringInfo *) NULL)
4430 (void) ProfileImage(msl_info->image[n],name,
4431 GetStringInfoDatum(profile),(size_t)
4432 GetStringInfoLength(profile),exception);
4433 profile=DestroyStringInfo(profile);
4437 ResetImageProfileIterator(profile_image);
4438 name=GetNextImageProfile(profile_image);
4439 while (name != (const char *) NULL)
4441 profile=GetImageProfile(profile_image,name);
4442 if (profile != (StringInfo *) NULL)
4443 (void) ProfileImage(msl_info->image[n],name,
4444 GetStringInfoDatum(profile),(size_t)
4445 GetStringInfoLength(profile),exception);
4446 name=GetNextImageProfile(profile_image);
4448 profile_image=DestroyImage(profile_image);
4452 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4457 if (LocaleCompare((const char *) tag,"quantize") == 0)
4465 if (msl_info->image[n] == (Image *) NULL)
4467 ThrowMSLException(OptionError,"NoImagesDefined",
4468 (const char *) tag);
4471 GetQuantizeInfo(&quantize_info);
4472 if (attributes != (const xmlChar **) NULL)
4473 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4475 keyword=(const char *) attributes[i++];
4476 attribute=InterpretImageProperties(msl_info->image_info[n],
4477 msl_info->attributes[n],(const char *) attributes[i],
4479 CloneString(&value,attribute);
4485 if (LocaleCompare(keyword,"colors") == 0)
4487 quantize_info.number_colors=StringToLong(value);
4490 if (LocaleCompare(keyword,"colorspace") == 0)
4492 option=ParseCommandOption(MagickColorspaceOptions,
4495 ThrowMSLException(OptionError,
4496 "UnrecognizedColorspaceType",value);
4497 quantize_info.colorspace=(ColorspaceType) option;
4500 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4507 if (LocaleCompare(keyword,"dither") == 0)
4509 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4512 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4514 quantize_info.dither_method=(DitherMethod) option;
4517 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4524 if (LocaleCompare(keyword,"measure") == 0)
4526 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4529 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4531 quantize_info.measure_error=(MagickBooleanType) option;
4534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4541 if (LocaleCompare(keyword,"treedepth") == 0)
4543 quantize_info.tree_depth=StringToLong(value);
4546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4552 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4558 (void) QuantizeImage(&quantize_info,msl_info->image[n],exception);
4561 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4564 text[MaxTextExtent];
4575 draw_info=CloneDrawInfo(msl_info->image_info[n],
4576 msl_info->draw_info[n]);
4578 current=draw_info->affine;
4579 GetAffineMatrix(&affine);
4580 if (attributes != (const xmlChar **) NULL)
4581 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4583 keyword=(const char *) attributes[i++];
4584 attribute=InterpretImageProperties(msl_info->image_info[n],
4585 msl_info->attributes[n],(const char *) attributes[i],
4587 CloneString(&value,attribute);
4593 if (LocaleCompare(keyword,"affine") == 0)
4599 draw_info->affine.sx=StringToDouble(p,&p);
4602 draw_info->affine.rx=StringToDouble(p,&p);
4605 draw_info->affine.ry=StringToDouble(p,&p);
4608 draw_info->affine.sy=StringToDouble(p,&p);
4611 draw_info->affine.tx=StringToDouble(p,&p);
4614 draw_info->affine.ty=StringToDouble(p,&p);
4617 if (LocaleCompare(keyword,"align") == 0)
4619 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4622 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4624 draw_info->align=(AlignType) option;
4627 if (LocaleCompare(keyword,"antialias") == 0)
4629 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4632 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4634 draw_info->stroke_antialias=(MagickBooleanType) option;
4635 draw_info->text_antialias=(MagickBooleanType) option;
4638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4645 if (LocaleCompare(keyword,"density") == 0)
4647 CloneString(&draw_info->density,value);
4650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4657 if (LocaleCompare(keyword,"encoding") == 0)
4659 CloneString(&draw_info->encoding,value);
4662 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4669 if (LocaleCompare(keyword, "fill") == 0)
4671 (void) QueryColorCompliance(value,AllCompliance,
4672 &draw_info->fill,exception);
4675 if (LocaleCompare(keyword,"family") == 0)
4677 CloneString(&draw_info->family,value);
4680 if (LocaleCompare(keyword,"font") == 0)
4682 CloneString(&draw_info->font,value);
4685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4692 if (LocaleCompare(keyword,"geometry") == 0)
4694 flags=ParsePageGeometry(msl_info->image[n],value,
4695 &geometry,exception);
4696 if ((flags & HeightValue) == 0)
4697 geometry.height=geometry.width;
4700 if (LocaleCompare(keyword,"gravity") == 0)
4702 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4705 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4707 draw_info->gravity=(GravityType) option;
4710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4717 if (LocaleCompare(keyword,"pointsize") == 0)
4719 draw_info->pointsize=StringToDouble(value,
4723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4730 if (LocaleCompare(keyword,"rotate") == 0)
4732 angle=StringToDouble(value,(char **) NULL);
4733 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4734 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4735 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4736 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(keyword,"scale") == 0)
4748 flags=ParseGeometry(value,&geometry_info);
4749 if ((flags & SigmaValue) == 0)
4750 geometry_info.sigma=1.0;
4751 affine.sx=geometry_info.rho;
4752 affine.sy=geometry_info.sigma;
4755 if (LocaleCompare(keyword,"skewX") == 0)
4757 angle=StringToDouble(value,(char **) NULL);
4758 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4761 if (LocaleCompare(keyword,"skewY") == 0)
4763 angle=StringToDouble(value,(char **) NULL);
4764 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4767 if (LocaleCompare(keyword,"stretch") == 0)
4769 option=ParseCommandOption(MagickStretchOptions,
4772 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4774 draw_info->stretch=(StretchType) option;
4777 if (LocaleCompare(keyword, "stroke") == 0)
4779 (void) QueryColorCompliance(value,AllCompliance,
4780 &draw_info->stroke,exception);
4783 if (LocaleCompare(keyword,"strokewidth") == 0)
4785 draw_info->stroke_width=StringToLong(value);
4788 if (LocaleCompare(keyword,"style") == 0)
4790 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4793 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4795 draw_info->style=(StyleType) option;
4798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4805 if (LocaleCompare(keyword,"text") == 0)
4807 CloneString(&draw_info->text,value);
4810 if (LocaleCompare(keyword,"translate") == 0)
4812 flags=ParseGeometry(value,&geometry_info);
4813 if ((flags & SigmaValue) == 0)
4814 geometry_info.sigma=1.0;
4815 affine.tx=geometry_info.rho;
4816 affine.ty=geometry_info.sigma;
4819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4826 if (LocaleCompare(keyword, "undercolor") == 0)
4828 (void) QueryColorCompliance(value,AllCompliance,
4829 &draw_info->undercolor,exception);
4832 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4839 if (LocaleCompare(keyword,"weight") == 0)
4841 draw_info->weight=StringToLong(value);
4844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4851 if (LocaleCompare(keyword,"x") == 0)
4853 geometry.x=StringToLong(value);
4856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4863 if (LocaleCompare(keyword,"y") == 0)
4865 geometry.y=StringToLong(value);
4868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4874 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4880 (void) FormatLocaleString(text,MaxTextExtent,
4881 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4882 geometry.height,(double) geometry.x,(double) geometry.y);
4883 CloneString(&draw_info->geometry,text);
4884 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4885 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4886 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4887 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4888 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4890 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4892 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4893 msl_info->exception);
4894 if (status != MagickFalse)
4899 image=msl_info->attributes[n];
4900 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4901 "%g",metrics.pixels_per_em.x);
4902 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4903 "%g",metrics.pixels_per_em.y);
4904 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4906 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4908 FormatImageProperty(image,"msl:font-metrics.width","%g",
4910 FormatImageProperty(image,"msl:font-metrics.height","%g",
4912 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4913 metrics.max_advance);
4914 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4916 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4918 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4920 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4922 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4924 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4927 draw_info=DestroyDrawInfo(draw_info);
4930 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4935 if (LocaleCompare((const char *) tag,"raise") == 0)
4943 if (msl_info->image[n] == (Image *) NULL)
4945 ThrowMSLException(OptionError,"NoImagesDefined",
4946 (const char *) tag);
4950 SetGeometry(msl_info->image[n],&geometry);
4951 if (attributes != (const xmlChar **) NULL)
4952 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4954 keyword=(const char *) attributes[i++];
4955 attribute=InterpretImageProperties(msl_info->image_info[n],
4956 msl_info->attributes[n],(const char *) attributes[i],
4958 CloneString(&value,attribute);
4964 if (LocaleCompare(keyword,"geometry") == 0)
4966 flags=ParsePageGeometry(msl_info->image[n],value,
4967 &geometry,exception);
4968 if ((flags & HeightValue) == 0)
4969 geometry.height=geometry.width;
4972 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4979 if (LocaleCompare(keyword,"height") == 0)
4981 geometry.height=StringToLong(value);
4984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4991 if (LocaleCompare(keyword,"raise") == 0)
4993 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4996 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4998 raise=(MagickBooleanType) option;
5001 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5008 if (LocaleCompare(keyword,"width") == 0)
5010 geometry.width=StringToLong(value);
5013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5025 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5026 msl_info->exception);
5029 if (LocaleCompare((const char *) tag,"read") == 0)
5031 if (attributes == (const xmlChar **) NULL)
5033 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5035 keyword=(const char *) attributes[i++];
5036 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5037 msl_info->attributes[n],(const char *) attributes[i],exception));
5043 if (LocaleCompare(keyword,"filename") == 0)
5048 (void) CopyMagickString(msl_info->image_info[n]->filename,
5049 value,MaxTextExtent);
5050 image=ReadImage(msl_info->image_info[n],exception);
5051 CatchException(exception);
5052 if (image == (Image *) NULL)
5054 AppendImageToList(&msl_info->image[n],image);
5057 (void) SetMSLAttributes(msl_info,keyword,value);
5062 (void) SetMSLAttributes(msl_info,keyword,value);
5069 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5077 if (msl_info->image[n] == (Image *) NULL)
5079 ThrowMSLException(OptionError,"NoImagesDefined",
5080 (const char *) tag);
5083 if (attributes != (const xmlChar **) NULL)
5084 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5086 keyword=(const char *) attributes[i++];
5087 attribute=InterpretImageProperties(msl_info->image_info[n],
5088 msl_info->attributes[n],(const char *) attributes[i],
5090 CloneString(&value,attribute);
5096 if (LocaleCompare(keyword,"geometry") == 0)
5098 flags=ParseGeometry(value,&geometry_info);
5099 if ((flags & SigmaValue) == 0)
5100 geometry_info.sigma=1.0;
5103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5110 if (LocaleCompare(keyword,"radius") == 0)
5112 geometry_info.rho=StringToDouble(value,
5116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5128 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5129 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5130 msl_info->exception);
5131 if (paint_image == (Image *) NULL)
5133 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5134 msl_info->image[n]=paint_image;
5137 else if (LocaleCompare((const char *) tag,"repage") == 0)
5139 /* init the values */
5140 width=msl_info->image[n]->page.width;
5141 height=msl_info->image[n]->page.height;
5142 x=msl_info->image[n]->page.x;
5143 y=msl_info->image[n]->page.y;
5145 if (msl_info->image[n] == (Image *) NULL)
5147 ThrowMSLException(OptionError,"NoImagesDefined",
5148 (const char *) tag);
5151 if (attributes == (const xmlChar **) NULL)
5153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5155 keyword=(const char *) attributes[i++];
5156 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5157 msl_info->attributes[n],(const char *) attributes[i],exception));
5163 if (LocaleCompare(keyword,"geometry") == 0)
5171 flags=ParseAbsoluteGeometry(value,&geometry);
5172 if ((flags & WidthValue) != 0)
5174 if ((flags & HeightValue) == 0)
5175 geometry.height=geometry.width;
5176 width=geometry.width;
5177 height=geometry.height;
5179 if ((flags & AspectValue) != 0)
5181 if ((flags & XValue) != 0)
5183 if ((flags & YValue) != 0)
5188 if ((flags & XValue) != 0)
5191 if ((width == 0) && (geometry.x > 0))
5192 width=msl_info->image[n]->columns+geometry.x;
5194 if ((flags & YValue) != 0)
5197 if ((height == 0) && (geometry.y > 0))
5198 height=msl_info->image[n]->rows+geometry.y;
5203 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5209 if (LocaleCompare(keyword,"height") == 0)
5211 height = StringToLong( value );
5214 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5220 if (LocaleCompare(keyword,"width") == 0)
5222 width = StringToLong( value );
5225 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5231 if (LocaleCompare(keyword,"x") == 0)
5233 x = StringToLong( value );
5236 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5242 if (LocaleCompare(keyword,"y") == 0)
5244 y = StringToLong( value );
5247 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5252 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5258 msl_info->image[n]->page.width=width;
5259 msl_info->image[n]->page.height=height;
5260 msl_info->image[n]->page.x=x;
5261 msl_info->image[n]->page.y=y;
5264 else if (LocaleCompare((const char *) tag,"resample") == 0)
5270 if (msl_info->image[n] == (Image *) NULL)
5272 ThrowMSLException(OptionError,"NoImagesDefined",
5273 (const char *) tag);
5276 if (attributes == (const xmlChar **) NULL)
5278 x_resolution=DefaultResolution;
5279 y_resolution=DefaultResolution;
5280 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5282 keyword=(const char *) attributes[i++];
5283 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5284 msl_info->attributes[n],(const char *) attributes[i],exception));
5290 if (LocaleCompare(keyword,"geometry") == 0)
5295 flags=ParseGeometry(value,&geometry_info);
5296 if ((flags & SigmaValue) == 0)
5297 geometry_info.sigma*=geometry_info.rho;
5298 x_resolution=geometry_info.rho;
5299 y_resolution=geometry_info.sigma;
5302 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5308 if (LocaleCompare(keyword,"x-resolution") == 0)
5310 x_resolution=StringToDouble(value,(char **) NULL);
5313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5319 if (LocaleCompare(keyword,"y-resolution") == 0)
5321 y_resolution=StringToDouble(value,(char **) NULL);
5324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5329 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5345 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5347 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5348 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5349 msl_info->image[n]->resolution.x))+0.5);
5350 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5351 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5352 msl_info->image[n]->resolution.y))+0.5);
5353 resample_image=ResizeImage(msl_info->image[n],width,height,
5354 msl_info->image[n]->filter,msl_info->exception);
5355 if (resample_image == (Image *) NULL)
5357 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5358 msl_info->image[n]=resample_image;
5362 if (LocaleCompare((const char *) tag,"resize") == 0)
5373 if (msl_info->image[n] == (Image *) NULL)
5375 ThrowMSLException(OptionError,"NoImagesDefined",
5376 (const char *) tag);
5379 filter=UndefinedFilter;
5380 if (attributes != (const xmlChar **) NULL)
5381 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5383 keyword=(const char *) attributes[i++];
5384 attribute=InterpretImageProperties(msl_info->image_info[n],
5385 msl_info->attributes[n],(const char *) attributes[i],
5387 CloneString(&value,attribute);
5393 if (LocaleCompare(keyword,"filter") == 0)
5395 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5398 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5400 filter=(FilterTypes) option;
5403 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5410 if (LocaleCompare(keyword,"geometry") == 0)
5412 flags=ParseRegionGeometry(msl_info->image[n],value,
5413 &geometry,exception);
5416 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5423 if (LocaleCompare(keyword,"height") == 0)
5425 geometry.height=StringToUnsignedLong(value);
5428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5435 if (LocaleCompare(keyword,"width") == 0)
5437 geometry.width=StringToLong(value);
5440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5446 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5452 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5453 geometry.height,filter,msl_info->exception);
5454 if (resize_image == (Image *) NULL)
5456 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5457 msl_info->image[n]=resize_image;
5460 if (LocaleCompare((const char *) tag,"roll") == 0)
5468 if (msl_info->image[n] == (Image *) NULL)
5470 ThrowMSLException(OptionError,"NoImagesDefined",
5471 (const char *) tag);
5474 SetGeometry(msl_info->image[n],&geometry);
5475 if (attributes != (const xmlChar **) NULL)
5476 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5478 keyword=(const char *) attributes[i++];
5479 attribute=InterpretImageProperties(msl_info->image_info[n],
5480 msl_info->attributes[n],(const char *) attributes[i],
5482 CloneString(&value,attribute);
5488 if (LocaleCompare(keyword,"geometry") == 0)
5490 flags=ParsePageGeometry(msl_info->image[n],value,
5491 &geometry,exception);
5492 if ((flags & HeightValue) == 0)
5493 geometry.height=geometry.width;
5496 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5503 if (LocaleCompare(keyword,"x") == 0)
5505 geometry.x=StringToLong(value);
5508 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5515 if (LocaleCompare(keyword,"y") == 0)
5517 geometry.y=StringToLong(value);
5520 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5526 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5532 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5533 msl_info->exception);
5534 if (roll_image == (Image *) NULL)
5536 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5537 msl_info->image[n]=roll_image;
5540 else if (LocaleCompare((const char *) tag,"roll") == 0)
5542 /* init the values */
5543 width=msl_info->image[n]->columns;
5544 height=msl_info->image[n]->rows;
5547 if (msl_info->image[n] == (Image *) NULL)
5549 ThrowMSLException(OptionError,"NoImagesDefined",
5550 (const char *) tag);
5553 if (attributes == (const xmlChar **) NULL)
5555 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5557 keyword=(const char *) attributes[i++];
5558 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5559 msl_info->attributes[n],(const char *) attributes[i],exception));
5565 if (LocaleCompare(keyword,"geometry") == 0)
5567 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5570 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5576 if (LocaleCompare(keyword,"x") == 0)
5578 x = StringToLong( value );
5581 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5587 if (LocaleCompare(keyword,"y") == 0)
5589 y = StringToLong( value );
5592 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5597 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5610 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5611 if (newImage == (Image *) NULL)
5613 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5614 msl_info->image[n]=newImage;
5619 if (LocaleCompare((const char *) tag,"rotate") == 0)
5627 if (msl_info->image[n] == (Image *) NULL)
5629 ThrowMSLException(OptionError,"NoImagesDefined",
5630 (const char *) tag);
5633 if (attributes != (const xmlChar **) NULL)
5634 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5636 keyword=(const char *) attributes[i++];
5637 attribute=InterpretImageProperties(msl_info->image_info[n],
5638 msl_info->attributes[n],(const char *) attributes[i],
5640 CloneString(&value,attribute);
5646 if (LocaleCompare(keyword,"degrees") == 0)
5648 geometry_info.rho=StringToDouble(value,
5652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5659 if (LocaleCompare(keyword,"geometry") == 0)
5661 flags=ParseGeometry(value,&geometry_info);
5662 if ((flags & SigmaValue) == 0)
5663 geometry_info.sigma=1.0;
5666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5672 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5678 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5679 msl_info->exception);
5680 if (rotate_image == (Image *) NULL)
5682 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5683 msl_info->image[n]=rotate_image;
5686 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5688 /* init the values */
5691 if (msl_info->image[n] == (Image *) NULL)
5693 ThrowMSLException(OptionError,"NoImagesDefined",
5694 (const char *) tag);
5697 if (attributes == (const xmlChar **) NULL)
5699 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5701 keyword=(const char *) attributes[i++];
5702 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5703 msl_info->attributes[n],(const char *) attributes[i],exception));
5709 if (LocaleCompare(keyword,"degrees") == 0)
5711 degrees = StringToDouble(value,(char **) NULL);
5714 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5719 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5732 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5733 if (newImage == (Image *) NULL)
5735 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5736 msl_info->image[n]=newImage;
5741 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5746 if (LocaleCompare((const char *) tag,"sample") == 0)
5754 if (msl_info->image[n] == (Image *) NULL)
5756 ThrowMSLException(OptionError,"NoImagesDefined",
5757 (const char *) tag);
5760 if (attributes != (const xmlChar **) NULL)
5761 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5763 keyword=(const char *) attributes[i++];
5764 attribute=InterpretImageProperties(msl_info->image_info[n],
5765 msl_info->attributes[n],(const char *) attributes[i],
5767 CloneString(&value,attribute);
5773 if (LocaleCompare(keyword,"geometry") == 0)
5775 flags=ParseRegionGeometry(msl_info->image[n],value,
5776 &geometry,exception);
5779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5786 if (LocaleCompare(keyword,"height") == 0)
5788 geometry.height=StringToUnsignedLong(value);
5791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5798 if (LocaleCompare(keyword,"width") == 0)
5800 geometry.width=StringToLong(value);
5803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5815 sample_image=SampleImage(msl_info->image[n],geometry.width,
5816 geometry.height,msl_info->exception);
5817 if (sample_image == (Image *) NULL)
5819 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5820 msl_info->image[n]=sample_image;
5823 if (LocaleCompare((const char *) tag,"scale") == 0)
5831 if (msl_info->image[n] == (Image *) NULL)
5833 ThrowMSLException(OptionError,"NoImagesDefined",
5834 (const char *) tag);
5837 if (attributes != (const xmlChar **) NULL)
5838 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5840 keyword=(const char *) attributes[i++];
5841 attribute=InterpretImageProperties(msl_info->image_info[n],
5842 msl_info->attributes[n],(const char *) attributes[i],
5844 CloneString(&value,attribute);
5850 if (LocaleCompare(keyword,"geometry") == 0)
5852 flags=ParseRegionGeometry(msl_info->image[n],value,
5853 &geometry,exception);
5856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5863 if (LocaleCompare(keyword,"height") == 0)
5865 geometry.height=StringToUnsignedLong(value);
5868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5875 if (LocaleCompare(keyword,"width") == 0)
5877 geometry.width=StringToLong(value);
5880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5886 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5892 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5893 geometry.height,msl_info->exception);
5894 if (scale_image == (Image *) NULL)
5896 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5897 msl_info->image[n]=scale_image;
5900 if (LocaleCompare((const char *) tag,"segment") == 0)
5911 if (msl_info->image[n] == (Image *) NULL)
5913 ThrowMSLException(OptionError,"NoImagesDefined",
5914 (const char *) tag);
5917 geometry_info.rho=1.0;
5918 geometry_info.sigma=1.5;
5919 colorspace=sRGBColorspace;
5920 verbose=MagickFalse;
5921 if (attributes != (const xmlChar **) NULL)
5922 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5924 keyword=(const char *) attributes[i++];
5925 attribute=InterpretImageProperties(msl_info->image_info[n],
5926 msl_info->attributes[n],(const char *) attributes[i],
5928 CloneString(&value,attribute);
5934 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5936 geometry_info.rho=StringToDouble(value,
5940 if (LocaleCompare(keyword,"colorspace") == 0)
5942 option=ParseCommandOption(MagickColorspaceOptions,
5945 ThrowMSLException(OptionError,
5946 "UnrecognizedColorspaceType",value);
5947 colorspace=(ColorspaceType) option;
5950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5957 if (LocaleCompare(keyword,"geometry") == 0)
5959 flags=ParseGeometry(value,&geometry_info);
5960 if ((flags & SigmaValue) == 0)
5961 geometry_info.sigma=1.5;
5964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5971 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5973 geometry_info.sigma=StringToDouble(value,
5977 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5983 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5989 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5990 geometry_info.rho,geometry_info.sigma,exception);
5993 else if (LocaleCompare((const char *) tag, "set") == 0)
5995 if (msl_info->image[n] == (Image *) NULL)
5997 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6001 if (attributes == (const xmlChar **) NULL)
6003 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6005 keyword=(const char *) attributes[i++];
6006 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6007 msl_info->attributes[n],(const char *) attributes[i],exception));
6013 if (LocaleCompare(keyword,"clip-mask") == 0)
6015 for (j=0; j < msl_info->n; j++)
6020 property=GetImageProperty(msl_info->attributes[j],"id",
6022 if (LocaleCompare(property,value) == 0)
6024 SetImageMask(msl_info->image[n],msl_info->image[j],
6031 if (LocaleCompare(keyword,"clip-path") == 0)
6033 for (j=0; j < msl_info->n; j++)
6038 property=GetImageProperty(msl_info->attributes[j],"id",
6040 if (LocaleCompare(property,value) == 0)
6042 SetImageMask(msl_info->image[n],msl_info->image[j],
6049 if (LocaleCompare(keyword,"colorspace") == 0)
6054 colorspace=(ColorspaceType) ParseCommandOption(
6055 MagickColorspaceOptions,MagickFalse,value);
6057 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6059 (void) TransformImageColorspace(msl_info->image[n],
6060 (ColorspaceType) colorspace,exception);
6063 (void) SetMSLAttributes(msl_info,keyword,value);
6064 (void) SetImageProperty(msl_info->image[n],keyword,value,
6071 if (LocaleCompare(keyword,"density") == 0)
6073 flags=ParseGeometry(value,&geometry_info);
6074 msl_info->image[n]->resolution.x=geometry_info.rho;
6075 msl_info->image[n]->resolution.y=geometry_info.sigma;
6076 if ((flags & SigmaValue) == 0)
6077 msl_info->image[n]->resolution.y=
6078 msl_info->image[n]->resolution.x;
6081 (void) SetMSLAttributes(msl_info,keyword,value);
6082 (void) SetImageProperty(msl_info->image[n],keyword,value,
6089 if (LocaleCompare(keyword, "opacity") == 0)
6091 ssize_t opac = OpaqueAlpha,
6092 len = (ssize_t) strlen( value );
6094 if (value[len-1] == '%') {
6096 (void) CopyMagickString(tmp,value,len);
6097 opac = StringToLong( tmp );
6098 opac = (int)(QuantumRange * ((float)opac/100));
6100 opac = StringToLong( value );
6101 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6105 (void) SetMSLAttributes(msl_info,keyword,value);
6106 (void) SetImageProperty(msl_info->image[n],keyword,value,
6107 msl_info->exception);
6113 if (LocaleCompare(keyword, "page") == 0)
6116 page[MaxTextExtent];
6127 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6128 image_option=GetImageArtifact(msl_info->image[n],"page");
6129 if (image_option != (const char *) NULL)
6130 flags=ParseAbsoluteGeometry(image_option,&geometry);
6131 flags=ParseAbsoluteGeometry(value,&geometry);
6132 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6133 (double) geometry.width,(double) geometry.height);
6134 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6135 (void) FormatLocaleString(page,MaxTextExtent,
6136 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6137 (double) geometry.height,(double) geometry.x,(double)
6139 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6140 msl_info->image_info[n]->page=GetPageGeometry(page);
6143 (void) SetMSLAttributes(msl_info,keyword,value);
6144 (void) SetImageProperty(msl_info->image[n],keyword,value,
6145 msl_info->exception);
6150 (void) SetMSLAttributes(msl_info,keyword,value);
6151 (void) SetImageProperty(msl_info->image[n],keyword,value,
6152 msl_info->exception);
6159 if (LocaleCompare((const char *) tag,"shade") == 0)
6170 if (msl_info->image[n] == (Image *) NULL)
6172 ThrowMSLException(OptionError,"NoImagesDefined",
6173 (const char *) tag);
6177 if (attributes != (const xmlChar **) NULL)
6178 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6180 keyword=(const char *) attributes[i++];
6181 attribute=InterpretImageProperties(msl_info->image_info[n],
6182 msl_info->attributes[n],(const char *) attributes[i],
6184 CloneString(&value,attribute);
6190 if (LocaleCompare(keyword,"azimuth") == 0)
6192 geometry_info.rho=StringToDouble(value,
6196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6203 if (LocaleCompare(keyword,"elevation") == 0)
6205 geometry_info.sigma=StringToDouble(value,
6209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6216 if (LocaleCompare(keyword,"geometry") == 0)
6218 flags=ParseGeometry(value,&geometry_info);
6219 if ((flags & SigmaValue) == 0)
6220 geometry_info.sigma=1.0;
6223 if (LocaleCompare(keyword,"gray") == 0)
6225 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6228 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6230 gray=(MagickBooleanType) option;
6233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6245 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6246 geometry_info.sigma,msl_info->exception);
6247 if (shade_image == (Image *) NULL)
6249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6250 msl_info->image[n]=shade_image;
6253 if (LocaleCompare((const char *) tag,"shadow") == 0)
6261 if (msl_info->image[n] == (Image *) NULL)
6263 ThrowMSLException(OptionError,"NoImagesDefined",
6264 (const char *) tag);
6267 if (attributes != (const xmlChar **) NULL)
6268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6270 keyword=(const char *) attributes[i++];
6271 attribute=InterpretImageProperties(msl_info->image_info[n],
6272 msl_info->attributes[n],(const char *) attributes[i],
6274 CloneString(&value,attribute);
6280 if (LocaleCompare(keyword,"geometry") == 0)
6282 flags=ParseGeometry(value,&geometry_info);
6283 if ((flags & SigmaValue) == 0)
6284 geometry_info.sigma=1.0;
6287 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6294 if (LocaleCompare(keyword,"opacity") == 0)
6296 geometry_info.rho=StringToLong(value);
6299 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6306 if (LocaleCompare(keyword,"sigma") == 0)
6308 geometry_info.sigma=StringToLong(value);
6316 if (LocaleCompare(keyword,"x") == 0)
6318 geometry_info.xi=StringToDouble(value,
6322 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6329 if (LocaleCompare(keyword,"y") == 0)
6331 geometry_info.psi=StringToLong(value);
6334 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6340 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6346 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6347 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6348 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6349 if (shadow_image == (Image *) NULL)
6351 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6352 msl_info->image[n]=shadow_image;
6355 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6361 if (msl_info->image[n] == (Image *) NULL)
6363 ThrowMSLException(OptionError,"NoImagesDefined",
6364 (const char *) tag);
6368 NOTE: sharpen can have no attributes, since we use all the defaults!
6370 if (attributes != (const xmlChar **) NULL)
6372 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6374 keyword=(const char *) attributes[i++];
6375 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6376 msl_info->attributes[n],(const char *) attributes[i],exception));
6382 if (LocaleCompare(keyword, "radius") == 0)
6384 radius = StringToDouble(value,(char **) NULL);
6387 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6393 if (LocaleCompare(keyword,"sigma") == 0)
6395 sigma = StringToLong( value );
6398 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6403 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6417 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6418 msl_info->exception);
6419 if (newImage == (Image *) NULL)
6421 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6422 msl_info->image[n]=newImage;
6426 else if (LocaleCompare((const char *) tag,"shave") == 0)
6428 /* init the values */
6432 if (msl_info->image[n] == (Image *) NULL)
6434 ThrowMSLException(OptionError,"NoImagesDefined",
6435 (const char *) tag);
6438 if (attributes == (const xmlChar **) NULL)
6440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6442 keyword=(const char *) attributes[i++];
6443 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6444 msl_info->attributes[n],(const char *) attributes[i],exception));
6450 if (LocaleCompare(keyword,"geometry") == 0)
6452 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6455 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6461 if (LocaleCompare(keyword,"height") == 0)
6463 height = StringToLong( value );
6466 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6472 if (LocaleCompare(keyword,"width") == 0)
6474 width = StringToLong( value );
6477 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6497 rectInfo.height = height;
6498 rectInfo.width = width;
6503 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6504 msl_info->exception);
6505 if (newImage == (Image *) NULL)
6507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6508 msl_info->image[n]=newImage;
6513 if (LocaleCompare((const char *) tag,"shear") == 0)
6521 if (msl_info->image[n] == (Image *) NULL)
6523 ThrowMSLException(OptionError,"NoImagesDefined",
6524 (const char *) tag);
6527 if (attributes != (const xmlChar **) NULL)
6528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6530 keyword=(const char *) attributes[i++];
6531 attribute=InterpretImageProperties(msl_info->image_info[n],
6532 msl_info->attributes[n],(const char *) attributes[i],
6534 CloneString(&value,attribute);
6540 if (LocaleCompare(keyword, "fill") == 0)
6542 (void) QueryColorCompliance(value,AllCompliance,
6543 &msl_info->image[n]->background_color,exception);
6546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6553 if (LocaleCompare(keyword,"geometry") == 0)
6555 flags=ParseGeometry(value,&geometry_info);
6556 if ((flags & SigmaValue) == 0)
6557 geometry_info.sigma=1.0;
6560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6567 if (LocaleCompare(keyword,"x") == 0)
6569 geometry_info.rho=StringToDouble(value,
6573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6580 if (LocaleCompare(keyword,"y") == 0)
6582 geometry_info.sigma=StringToLong(value);
6585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6597 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6598 geometry_info.sigma,msl_info->exception);
6599 if (shear_image == (Image *) NULL)
6601 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6602 msl_info->image[n]=shear_image;
6605 if (LocaleCompare((const char *) tag,"signature") == 0)
6610 if (msl_info->image[n] == (Image *) NULL)
6612 ThrowMSLException(OptionError,"NoImagesDefined",
6613 (const char *) tag);
6616 if (attributes != (const xmlChar **) NULL)
6617 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6619 keyword=(const char *) attributes[i++];
6620 attribute=InterpretImageProperties(msl_info->image_info[n],
6621 msl_info->attributes[n],(const char *) attributes[i],
6623 CloneString(&value,attribute);
6628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6634 (void) SignatureImage(msl_info->image[n],exception);
6637 if (LocaleCompare((const char *) tag,"solarize") == 0)
6642 if (msl_info->image[n] == (Image *) NULL)
6644 ThrowMSLException(OptionError,"NoImagesDefined",
6645 (const char *) tag);
6648 geometry_info.rho=QuantumRange/2.0;
6649 if (attributes != (const xmlChar **) NULL)
6650 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6652 keyword=(const char *) attributes[i++];
6653 attribute=InterpretImageProperties(msl_info->image_info[n],
6654 msl_info->attributes[n],(const char *) attributes[i],
6656 CloneString(&value,attribute);
6662 if (LocaleCompare(keyword,"geometry") == 0)
6664 flags=ParseGeometry(value,&geometry_info);
6667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6674 if (LocaleCompare(keyword,"threshold") == 0)
6676 geometry_info.rho=StringToDouble(value,
6680 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6692 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6693 msl_info->exception);
6696 if (LocaleCompare((const char *) tag,"spread") == 0)
6704 if (msl_info->image[n] == (Image *) NULL)
6706 ThrowMSLException(OptionError,"NoImagesDefined",
6707 (const char *) tag);
6710 if (attributes != (const xmlChar **) NULL)
6711 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6713 keyword=(const char *) attributes[i++];
6714 attribute=InterpretImageProperties(msl_info->image_info[n],
6715 msl_info->attributes[n],(const char *) attributes[i],
6717 CloneString(&value,attribute);
6723 if (LocaleCompare(keyword,"geometry") == 0)
6725 flags=ParseGeometry(value,&geometry_info);
6726 if ((flags & SigmaValue) == 0)
6727 geometry_info.sigma=1.0;
6730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6737 if (LocaleCompare(keyword,"radius") == 0)
6739 geometry_info.rho=StringToDouble(value,
6743 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6749 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6755 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6756 msl_info->image[n]->interpolate,msl_info->exception);
6757 if (spread_image == (Image *) NULL)
6759 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6760 msl_info->image[n]=spread_image;
6763 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6766 watermark = (Image*) NULL;
6768 if (msl_info->image[n] == (Image *) NULL)
6770 ThrowMSLException(OptionError,"NoImagesDefined",
6771 (const char *) tag);
6774 if (attributes == (const xmlChar **) NULL)
6776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6778 keyword=(const char *) attributes[i++];
6779 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6780 msl_info->attributes[n],(const char *) attributes[i],exception));
6786 if (LocaleCompare(keyword,"image") == 0)
6788 for (j=0; j<msl_info->n;j++)
6791 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6793 if (theAttr && LocaleCompare(theAttr, value) == 0)
6795 watermark = msl_info->image[j];
6801 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6806 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6815 if ( watermark != (Image*) NULL )
6820 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6821 if (newImage == (Image *) NULL)
6823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6824 msl_info->image[n]=newImage;
6827 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6829 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6832 stereoImage = (Image*) NULL;
6834 if (msl_info->image[n] == (Image *) NULL)
6836 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6839 if (attributes == (const xmlChar **) NULL)
6841 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6843 keyword=(const char *) attributes[i++];
6844 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6845 msl_info->attributes[n],(const char *) attributes[i],exception));
6851 if (LocaleCompare(keyword,"image") == 0)
6853 for (j=0; j<msl_info->n;j++)
6856 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6858 if (theAttr && LocaleCompare(theAttr, value) == 0)
6860 stereoImage = msl_info->image[j];
6866 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6871 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6880 if ( stereoImage != (Image*) NULL )
6885 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6886 if (newImage == (Image *) NULL)
6888 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6889 msl_info->image[n]=newImage;
6892 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6894 if (LocaleCompare((const char *) tag,"strip") == 0)
6899 if (msl_info->image[n] == (Image *) NULL)
6901 ThrowMSLException(OptionError,"NoImagesDefined",
6902 (const char *) tag);
6905 if (attributes != (const xmlChar **) NULL)
6906 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6908 keyword=(const char *) attributes[i++];
6909 attribute=InterpretImageProperties(msl_info->image_info[n],
6910 msl_info->attributes[n],(const char *) attributes[i],
6912 CloneString(&value,attribute);
6913 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6915 (void) StripImage(msl_info->image[n],msl_info->exception);
6918 if (LocaleCompare((const char *) tag,"swap") == 0)
6929 if (msl_info->image[n] == (Image *) NULL)
6931 ThrowMSLException(OptionError,"NoImagesDefined",
6932 (const char *) tag);
6937 if (attributes != (const xmlChar **) NULL)
6938 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6940 keyword=(const char *) attributes[i++];
6941 attribute=InterpretImageProperties(msl_info->image_info[n],
6942 msl_info->attributes[n],(const char *) attributes[i],
6944 CloneString(&value,attribute);
6950 if (LocaleCompare(keyword,"indexes") == 0)
6952 flags=ParseGeometry(value,&geometry_info);
6953 index=(ssize_t) geometry_info.rho;
6954 if ((flags & SigmaValue) == 0)
6955 swap_index=(ssize_t) geometry_info.sigma;
6958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6973 p=GetImageFromList(msl_info->image[n],index);
6974 q=GetImageFromList(msl_info->image[n],swap_index);
6975 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6977 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6980 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6981 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6982 msl_info->exception));
6983 ReplaceImageInList(&q,swap);
6984 msl_info->image[n]=GetFirstImageInList(q);
6987 if (LocaleCompare((const char *) tag,"swirl") == 0)
6995 if (msl_info->image[n] == (Image *) NULL)
6997 ThrowMSLException(OptionError,"NoImagesDefined",
6998 (const char *) tag);
7001 if (attributes != (const xmlChar **) NULL)
7002 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7004 keyword=(const char *) attributes[i++];
7005 attribute=InterpretImageProperties(msl_info->image_info[n],
7006 msl_info->attributes[n],(const char *) attributes[i],
7008 CloneString(&value,attribute);
7014 if (LocaleCompare(keyword,"degrees") == 0)
7016 geometry_info.rho=StringToDouble(value,
7020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7027 if (LocaleCompare(keyword,"geometry") == 0)
7029 flags=ParseGeometry(value,&geometry_info);
7030 if ((flags & SigmaValue) == 0)
7031 geometry_info.sigma=1.0;
7034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7046 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7047 msl_info->image[n]->interpolate,msl_info->exception);
7048 if (swirl_image == (Image *) NULL)
7050 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7051 msl_info->image[n]=swirl_image;
7054 if (LocaleCompare((const char *) tag,"sync") == 0)
7059 if (msl_info->image[n] == (Image *) NULL)
7061 ThrowMSLException(OptionError,"NoImagesDefined",
7062 (const char *) tag);
7065 if (attributes != (const xmlChar **) NULL)
7066 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7068 keyword=(const char *) attributes[i++];
7069 attribute=InterpretImageProperties(msl_info->image_info[n],
7070 msl_info->attributes[n],(const char *) attributes[i],
7072 CloneString(&value,attribute);
7077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7083 (void) SyncImage(msl_info->image[n],exception);
7086 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7091 if (LocaleCompare((const char *) tag,"map") == 0)
7099 if (msl_info->image[n] == (Image *) NULL)
7101 ThrowMSLException(OptionError,"NoImagesDefined",
7102 (const char *) tag);
7105 texture_image=NewImageList();
7106 if (attributes != (const xmlChar **) NULL)
7107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7109 keyword=(const char *) attributes[i++];
7110 attribute=InterpretImageProperties(msl_info->image_info[n],
7111 msl_info->attributes[n],(const char *) attributes[i],
7113 CloneString(&value,attribute);
7119 if (LocaleCompare(keyword,"image") == 0)
7120 for (j=0; j < msl_info->n; j++)
7125 attribute=GetImageProperty(msl_info->attributes[j],"id",
7127 if ((attribute != (const char *) NULL) &&
7128 (LocaleCompare(attribute,value) == 0))
7130 texture_image=CloneImage(msl_info->image[j],0,0,
7131 MagickFalse,exception);
7139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7145 (void) TextureImage(msl_info->image[n],texture_image,exception);
7146 texture_image=DestroyImage(texture_image);
7149 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7151 /* init the values */
7152 double threshold = 0;
7154 if (msl_info->image[n] == (Image *) NULL)
7156 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7159 if (attributes == (const xmlChar **) NULL)
7161 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7163 keyword=(const char *) attributes[i++];
7164 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7165 msl_info->attributes[n],(const char *) attributes[i],exception));
7171 if (LocaleCompare(keyword,"threshold") == 0)
7173 threshold = StringToDouble(value,(char **) NULL);
7176 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7181 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7191 BilevelImage(msl_info->image[n],threshold,exception);
7195 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7197 if (msl_info->image[n] == (Image *) NULL)
7199 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7202 if (attributes == (const xmlChar **) NULL)
7204 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7206 keyword=(const char *) attributes[i++];
7207 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7208 msl_info->attributes[n],(const char *) attributes[i],exception));
7214 if (LocaleCompare(keyword,"color") == 0)
7219 (void) QueryColorCompliance(value,AllCompliance,&target,
7221 (void) TransparentPaintImage(msl_info->image[n],&target,
7222 TransparentAlpha,MagickFalse,msl_info->exception);
7225 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7237 else if (LocaleCompare((const char *) tag, "trim") == 0)
7239 if (msl_info->image[n] == (Image *) NULL)
7241 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7245 /* no attributes here */
7247 /* process the image */
7254 /* all zeros on a crop == trim edges! */
7255 rectInfo.height = rectInfo.width = 0;
7256 rectInfo.x = rectInfo.y = 0;
7258 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7259 if (newImage == (Image *) NULL)
7261 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7262 msl_info->image[n]=newImage;
7266 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7271 if (LocaleCompare((const char *) tag,"write") == 0)
7273 if (msl_info->image[n] == (Image *) NULL)
7275 ThrowMSLException(OptionError,"NoImagesDefined",
7276 (const char *) tag);
7279 if (attributes == (const xmlChar **) NULL)
7281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7283 keyword=(const char *) attributes[i++];
7284 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7285 msl_info->attributes[n],(const char *) attributes[i],exception));
7291 if (LocaleCompare(keyword,"filename") == 0)
7293 (void) CopyMagickString(msl_info->image[n]->filename,value,
7297 (void) SetMSLAttributes(msl_info,keyword,value);
7301 (void) SetMSLAttributes(msl_info,keyword,value);
7309 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7310 msl_info->exception);
7314 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7318 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7322 if ( value != NULL )
7323 value=DestroyString(value);
7324 (void) DestroyExceptionInfo(exception);
7325 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7328 static void MSLEndElement(void *context,const xmlChar *tag)
7337 Called when the end of an element has been detected.
7339 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7341 msl_info=(MSLInfo *) context;
7348 if (LocaleCompare((const char *) tag,"comment") == 0 )
7350 (void) DeleteImageProperty(msl_info->image[n],"comment");
7351 if (msl_info->content == (char *) NULL)
7353 StripString(msl_info->content);
7354 (void) SetImageProperty(msl_info->image[n],"comment",
7355 msl_info->content,msl_info->exception);
7363 if (LocaleCompare((const char *) tag, "group") == 0 )
7365 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7367 ssize_t i = (ssize_t)
7368 (msl_info->group_info[msl_info->number_groups-1].numImages);
7371 if (msl_info->image[msl_info->n] != (Image *) NULL)
7372 msl_info->image[msl_info->n]=DestroyImage(
7373 msl_info->image[msl_info->n]);
7374 msl_info->attributes[msl_info->n]=DestroyImage(
7375 msl_info->attributes[msl_info->n]);
7376 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7377 msl_info->image_info[msl_info->n]);
7381 msl_info->number_groups--;
7388 if (LocaleCompare((const char *) tag, "image") == 0)
7389 MSLPopImage(msl_info);
7395 if (LocaleCompare((const char *) tag,"label") == 0 )
7397 (void) DeleteImageProperty(msl_info->image[n],"label");
7398 if (msl_info->content == (char *) NULL)
7400 StripString(msl_info->content);
7401 (void) SetImageProperty(msl_info->image[n],"label",
7402 msl_info->content,msl_info->exception);
7410 if (LocaleCompare((const char *) tag, "msl") == 0 )
7413 This our base element.
7414 at the moment we don't do anything special
7415 but someday we might!
7423 if (msl_info->content != (char *) NULL)
7424 msl_info->content=DestroyString(msl_info->content);
7427 static void MSLCharacters(void *context,const xmlChar *c,int length)
7439 Receiving some characters from the parser.
7441 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7442 " SAX.characters(%s,%d)",c,length);
7443 msl_info=(MSLInfo *) context;
7444 if (msl_info->content != (char *) NULL)
7445 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7446 strlen(msl_info->content)+length+MaxTextExtent,
7447 sizeof(*msl_info->content));
7450 msl_info->content=(char *) NULL;
7451 if (~length >= (MaxTextExtent-1))
7452 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7453 sizeof(*msl_info->content));
7454 if (msl_info->content != (char *) NULL)
7455 *msl_info->content='\0';
7457 if (msl_info->content == (char *) NULL)
7459 p=msl_info->content+strlen(msl_info->content);
7460 for (i=0; i < length; i++)
7465 static void MSLReference(void *context,const xmlChar *name)
7474 Called when an entity reference is detected.
7476 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7477 " SAX.reference(%s)",name);
7478 msl_info=(MSLInfo *) context;
7479 parser=msl_info->parser;
7481 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7483 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7486 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7492 Receiving some ignorable whitespaces from the parser.
7494 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7495 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7496 msl_info=(MSLInfo *) context;
7500 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7501 const xmlChar *data)
7507 A processing instruction has been parsed.
7509 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7510 " SAX.processingInstruction(%s, %s)",
7512 msl_info=(MSLInfo *) context;
7516 static void MSLComment(void *context,const xmlChar *value)
7522 A comment has been parsed.
7524 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7525 " SAX.comment(%s)",value);
7526 msl_info=(MSLInfo *) context;
7530 static void MSLWarning(void *context,const char *format,...)
7534 reason[MaxTextExtent];
7543 Display and format a warning messages, gives file, line, position and
7546 va_start(operands,format);
7547 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7548 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7549 msl_info=(MSLInfo *) context;
7551 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7552 (void) vsprintf(reason,format,operands);
7554 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7556 message=GetExceptionMessage(errno);
7557 ThrowMSLException(CoderError,reason,message);
7558 message=DestroyString(message);
7562 static void MSLError(void *context,const char *format,...)
7565 reason[MaxTextExtent];
7574 Display and format a error formats, gives file, line, position and
7577 va_start(operands,format);
7578 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7579 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7580 msl_info=(MSLInfo *) context;
7582 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7583 (void) vsprintf(reason,format,operands);
7585 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7587 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7591 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7603 Called when a pcdata block has been parsed.
7605 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7606 " SAX.pcdata(%s, %d)",value,length);
7607 msl_info=(MSLInfo *) context;
7609 parser=msl_info->parser;
7610 child=xmlGetLastChild(parser->node);
7611 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7613 xmlTextConcat(child,value,length);
7616 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7619 static void MSLExternalSubset(void *context,const xmlChar *name,
7620 const xmlChar *external_id,const xmlChar *system_id)
7635 Does this document has an external subset?
7637 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7638 " SAX.externalSubset(%s %s %s)",name,
7639 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7640 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7641 msl_info=(MSLInfo *) context;
7643 parser=msl_info->parser;
7644 if (((external_id == NULL) && (system_id == NULL)) ||
7645 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7646 (msl_info->document == 0)))
7648 input=MSLResolveEntity(context,external_id,system_id);
7651 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7652 parser_context=(*parser);
7653 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7654 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7656 parser->errNo=XML_ERR_NO_MEMORY;
7657 parser->input=parser_context.input;
7658 parser->inputNr=parser_context.inputNr;
7659 parser->inputMax=parser_context.inputMax;
7660 parser->inputTab=parser_context.inputTab;
7666 xmlPushInput(parser,input);
7667 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7668 if (input->filename == (char *) NULL)
7669 input->filename=(char *) xmlStrdup(system_id);
7672 input->base=parser->input->cur;
7673 input->cur=parser->input->cur;
7675 xmlParseExternalSubset(parser,external_id,system_id);
7676 while (parser->inputNr > 1)
7677 (void) xmlPopInput(parser);
7678 xmlFreeInputStream(parser->input);
7679 xmlFree(parser->inputTab);
7680 parser->input=parser_context.input;
7681 parser->inputNr=parser_context.inputNr;
7682 parser->inputMax=parser_context.inputMax;
7683 parser->inputTab=parser_context.inputTab;
7686 #if defined(__cplusplus) || defined(c_plusplus)
7690 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7691 Image **image,ExceptionInfo *exception)
7694 message[MaxTextExtent];
7717 assert(image_info != (const ImageInfo *) NULL);
7718 assert(image_info->signature == MagickSignature);
7719 if (image_info->debug != MagickFalse)
7720 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7721 image_info->filename);
7722 assert(image != (Image **) NULL);
7723 msl_image=AcquireImage(image_info,exception);
7724 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7725 if (status == MagickFalse)
7727 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7728 msl_image->filename);
7729 msl_image=DestroyImageList(msl_image);
7730 return(MagickFalse);
7732 msl_image->columns=1;
7737 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7738 msl_info.exception=exception;
7739 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7740 sizeof(*msl_info.image_info));
7741 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7742 sizeof(*msl_info.draw_info));
7743 /* top of the stack is the MSL file itself */
7744 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7745 msl_info.attributes=(Image **) AcquireMagickMemory(
7746 sizeof(*msl_info.attributes));
7747 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7748 sizeof(*msl_info.group_info));
7749 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7750 (msl_info.image == (Image **) NULL) ||
7751 (msl_info.attributes == (Image **) NULL) ||
7752 (msl_info.group_info == (MSLGroupInfo *) NULL))
7753 ThrowFatalException(ResourceLimitFatalError,
7754 "UnableToInterpretMSLImage");
7755 *msl_info.image_info=CloneImageInfo(image_info);
7756 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7757 *msl_info.attributes=AcquireImage(image_info,exception);
7758 msl_info.group_info[0].numImages=0;
7759 /* the first slot is used to point to the MSL file image */
7760 *msl_info.image=msl_image;
7761 if (*image != (Image *) NULL)
7762 MSLPushImage(&msl_info,*image);
7763 (void) xmlSubstituteEntitiesDefault(1);
7764 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7765 sax_modules.internalSubset=MSLInternalSubset;
7766 sax_modules.isStandalone=MSLIsStandalone;
7767 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7768 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7769 sax_modules.resolveEntity=MSLResolveEntity;
7770 sax_modules.getEntity=MSLGetEntity;
7771 sax_modules.entityDecl=MSLEntityDeclaration;
7772 sax_modules.notationDecl=MSLNotationDeclaration;
7773 sax_modules.attributeDecl=MSLAttributeDeclaration;
7774 sax_modules.elementDecl=MSLElementDeclaration;
7775 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7776 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7777 sax_modules.startDocument=MSLStartDocument;
7778 sax_modules.endDocument=MSLEndDocument;
7779 sax_modules.startElement=MSLStartElement;
7780 sax_modules.endElement=MSLEndElement;
7781 sax_modules.reference=MSLReference;
7782 sax_modules.characters=MSLCharacters;
7783 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7784 sax_modules.processingInstruction=MSLProcessingInstructions;
7785 sax_modules.comment=MSLComment;
7786 sax_modules.warning=MSLWarning;
7787 sax_modules.error=MSLError;
7788 sax_modules.fatalError=MSLError;
7789 sax_modules.getParameterEntity=MSLGetParameterEntity;
7790 sax_modules.cdataBlock=MSLCDataBlock;
7791 sax_modules.externalSubset=MSLExternalSubset;
7792 sax_handler=(&sax_modules);
7793 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7794 msl_image->filename);
7795 while (ReadBlobString(msl_image,message) != (char *) NULL)
7797 n=(ssize_t) strlen(message);
7800 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7803 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7804 if (msl_info.exception->severity >= ErrorException)
7807 if (msl_info.exception->severity == UndefinedException)
7808 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7809 xmlFreeParserCtxt(msl_info.parser);
7810 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7811 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7812 msl_info.group_info);
7813 if (*image == (Image *) NULL)
7814 *image=(*msl_info.image);
7815 if (msl_info.exception->severity != UndefinedException)
7816 return(MagickFalse);
7820 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7828 assert(image_info != (const ImageInfo *) NULL);
7829 assert(image_info->signature == MagickSignature);
7830 if (image_info->debug != MagickFalse)
7831 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7832 image_info->filename);
7833 assert(exception != (ExceptionInfo *) NULL);
7834 assert(exception->signature == MagickSignature);
7835 image=(Image *) NULL;
7836 (void) ProcessMSLScript(image_info,&image,exception);
7837 return(GetFirstImageInList(image));
7842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7846 % R e g i s t e r M S L I m a g e %
7850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7852 % RegisterMSLImage() adds attributes for the MSL image format to
7853 % the list of supported formats. The attributes include the image format
7854 % tag, a method to read and/or write the format, whether the format
7855 % supports the saving of more than one frame to the same file or blob,
7856 % whether the format supports native in-memory I/O, and a brief
7857 % description of the format.
7859 % The format of the RegisterMSLImage method is:
7861 % size_t RegisterMSLImage(void)
7864 ModuleExport size_t RegisterMSLImage(void)
7869 #if defined(MAGICKCORE_XML_DELEGATE)
7872 entry=SetMagickInfo("MSL");
7873 #if defined(MAGICKCORE_XML_DELEGATE)
7874 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7875 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7877 entry->description=ConstantString("Magick Scripting Language");
7878 entry->module=ConstantString("MSL");
7879 (void) RegisterMagickInfo(entry);
7880 return(MagickImageCoderSignature);
7883 #if defined(MAGICKCORE_XML_DELEGATE)
7885 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7889 % S e t M S L A t t r i b u t e s %
7893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7895 % SetMSLAttributes() ...
7897 % The format of the SetMSLAttributes method is:
7899 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7900 % const char *keyword,const char *value)
7902 % A description of each parameter follows:
7904 % o msl_info: the MSL info.
7906 % o keyword: the keyword.
7908 % o value: the value.
7911 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7938 assert(msl_info != (MSLInfo *) NULL);
7939 if (keyword == (const char *) NULL)
7941 if (value == (const char *) NULL)
7943 exception=msl_info->exception;
7945 attributes=msl_info->attributes[n];
7946 image_info=msl_info->image_info[n];
7947 draw_info=msl_info->draw_info[n];
7948 image=msl_info->image[n];
7954 if (LocaleCompare(keyword,"adjoin") == 0)
7959 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7961 ThrowMSLException(OptionError,"UnrecognizedType",value);
7962 image_info->adjoin=(MagickBooleanType) adjoin;
7965 if (LocaleCompare(keyword,"alpha") == 0)
7970 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
7972 ThrowMSLException(OptionError,"UnrecognizedType",value);
7973 if (image != (Image *) NULL)
7974 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
7978 if (LocaleCompare(keyword,"antialias") == 0)
7983 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7985 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7986 image_info->antialias=(MagickBooleanType) antialias;
7989 if (LocaleCompare(keyword,"area-limit") == 0)
7994 limit=MagickResourceInfinity;
7995 if (LocaleCompare(value,"unlimited") != 0)
7996 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7997 (void) SetMagickResourceLimit(AreaResource,limit);
8000 if (LocaleCompare(keyword,"attenuate") == 0)
8002 (void) SetImageOption(image_info,keyword,value);
8005 if (LocaleCompare(keyword,"authenticate") == 0)
8007 (void) CloneString(&image_info->density,value);
8010 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8016 if (LocaleCompare(keyword,"background") == 0)
8018 (void) QueryColorCompliance(value,AllCompliance,
8019 &image_info->background_color,exception);
8022 if (LocaleCompare(keyword,"blue-primary") == 0)
8024 if (image == (Image *) NULL)
8026 flags=ParseGeometry(value,&geometry_info);
8027 image->chromaticity.blue_primary.x=geometry_info.rho;
8028 image->chromaticity.blue_primary.y=geometry_info.sigma;
8029 if ((flags & SigmaValue) == 0)
8030 image->chromaticity.blue_primary.y=
8031 image->chromaticity.blue_primary.x;
8034 if (LocaleCompare(keyword,"bordercolor") == 0)
8036 (void) QueryColorCompliance(value,AllCompliance,
8037 &image_info->border_color,exception);
8040 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8046 if (LocaleCompare(keyword,"density") == 0)
8048 (void) CloneString(&image_info->density,value);
8049 (void) CloneString(&draw_info->density,value);
8052 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8058 if (LocaleCompare(keyword,"fill") == 0)
8060 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8062 (void) SetImageOption(image_info,keyword,value);
8065 if (LocaleCompare(keyword,"filename") == 0)
8067 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8070 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8076 if (LocaleCompare(keyword,"gravity") == 0)
8081 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8083 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8084 (void) SetImageOption(image_info,keyword,value);
8087 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8093 if (LocaleCompare(keyword,"id") == 0)
8095 (void) SetImageProperty(attributes,keyword,value,exception);
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"magick") == 0)
8106 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8109 if (LocaleCompare(keyword,"mattecolor") == 0)
8111 (void) QueryColorCompliance(value,AllCompliance,
8112 &image_info->matte_color,exception);
8115 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8121 if (LocaleCompare(keyword,"pointsize") == 0)
8123 image_info->pointsize=StringToDouble(value,(char **) NULL);
8124 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8133 if (LocaleCompare(keyword,"quality") == 0)
8135 image_info->quality=StringToLong(value);
8136 if (image == (Image *) NULL)
8138 image->quality=StringToLong(value);
8146 if (LocaleCompare(keyword,"size") == 0)
8148 (void) CloneString(&image_info->size,value);
8151 if (LocaleCompare(keyword,"stroke") == 0)
8153 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8155 (void) SetImageOption(image_info,keyword,value);
8158 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8163 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8176 % U n r e g i s t e r M S L I m a g e %
8180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8182 % UnregisterMSLImage() removes format registrations made by the
8183 % MSL module from the list of supported formats.
8185 % The format of the UnregisterMSLImage method is:
8187 % UnregisterMSLImage(void)
8190 ModuleExport void UnregisterMSLImage(void)
8192 (void) UnregisterMagickInfo("MSL");
8193 #if defined(MAGICKCORE_XML_DELEGATE)
8198 #if defined(MAGICKCORE_XML_DELEGATE)
8200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8204 % W r i t e M S L I m a g e %
8208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8210 % WriteMSLImage() writes an image to a file in MVG image format.
8212 % The format of the WriteMSLImage method is:
8214 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8215 % Image *image,ExceptionInfo *exception)
8217 % A description of each parameter follows.
8219 % o image_info: the image info.
8221 % o image: The image.
8223 % o exception: return any errors or warnings in this structure.
8226 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8227 ExceptionInfo *exception)
8229 assert(image_info != (const ImageInfo *) NULL);
8230 assert(image_info->signature == MagickSignature);
8231 assert(image != (Image *) NULL);
8232 assert(image->signature == MagickSignature);
8233 if (image->debug != MagickFalse)
8234 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8235 (void) ReferenceImage(image);
8236 (void) ProcessMSLScript(image_info,&image,exception);