2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2018 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 % https://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__)
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)
205 key[MagickPathExtent];
216 (void) FormatLocaleString(key,MagickPathExtent,"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,MagickPathExtent);
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 if (image != (Image *) NULL)
556 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
557 assert(msl_info != (MSLInfo *) NULL);
560 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
561 (n+1),sizeof(*msl_info->image_info));
562 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
563 (n+1),sizeof(*msl_info->draw_info));
564 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
565 (n+1),sizeof(*msl_info->attributes));
566 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
567 sizeof(*msl_info->image));
568 if ((msl_info->image_info == (ImageInfo **) NULL) ||
569 (msl_info->draw_info == (DrawInfo **) NULL) ||
570 (msl_info->attributes == (Image **) NULL) ||
571 (msl_info->image == (Image **) NULL))
572 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
573 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
574 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
575 msl_info->draw_info[n-1]);
576 if (image == (Image *) NULL)
577 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
578 msl_info->exception);
580 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
581 msl_info->exception);
582 msl_info->image[n]=(Image *) image;
583 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
584 (msl_info->attributes[n] == (Image *) NULL))
585 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
586 if (msl_info->number_groups != 0)
587 msl_info->group_info[msl_info->number_groups-1].numImages++;
590 static void MSLPopImage(MSLInfo *msl_info)
592 if (msl_info->number_groups != 0)
594 if (msl_info->image[msl_info->n] != (Image *) NULL)
595 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
596 msl_info->attributes[msl_info->n]=DestroyImage(
597 msl_info->attributes[msl_info->n]);
598 msl_info->draw_info[msl_info->n]=DestroyDrawInfo(
599 msl_info->draw_info[msl_info->n]);
600 msl_info->image_info[msl_info->n]=DestroyImageInfo(
601 msl_info->image_info[msl_info->n]);
605 static void MSLStartElement(void *context,const xmlChar *tag,
606 const xmlChar **attributes)
620 key[MagickPathExtent],
665 Called when an opening tag has been processed.
667 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
668 " SAX.startElement(%s",tag);
669 exception=AcquireExceptionInfo();
670 msl_info=(MSLInfo *) context;
672 keyword=(const char *) NULL;
674 SetGeometryInfo(&geometry_info);
675 (void) memset(&geometry,0,sizeof(geometry));
676 channel=DefaultChannels;
682 if (LocaleCompare((const char *) tag,"add-noise") == 0)
693 if (msl_info->image[n] == (Image *) NULL)
695 ThrowMSLException(OptionError,"NoImagesDefined",
700 if (attributes != (const xmlChar **) NULL)
701 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
703 keyword=(const char *) attributes[i++];
704 attribute=InterpretImageProperties(msl_info->image_info[n],
705 msl_info->attributes[n],(const char *) attributes[i],
707 CloneString(&value,attribute);
708 attribute=DestroyString(attribute);
714 if (LocaleCompare(keyword,"channel") == 0)
716 option=ParseChannelOption(value);
718 ThrowMSLException(OptionError,"UnrecognizedChannelType",
720 channel=(ChannelType) option;
723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
730 if (LocaleCompare(keyword,"noise") == 0)
732 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
735 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
737 noise=(NoiseType) option;
740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
752 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
753 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
754 msl_info->exception);
755 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
756 if (noise_image == (Image *) NULL)
758 msl_info->image[n]=DestroyImage(msl_info->image[n]);
759 msl_info->image[n]=noise_image;
762 if (LocaleCompare((const char *) tag,"annotate") == 0)
765 text[MagickPathExtent];
770 if (msl_info->image[n] == (Image *) NULL)
772 ThrowMSLException(OptionError,"NoImagesDefined",
776 draw_info=CloneDrawInfo(msl_info->image_info[n],
777 msl_info->draw_info[n]);
779 current=draw_info->affine;
780 GetAffineMatrix(&affine);
781 if (attributes != (const xmlChar **) NULL)
782 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
784 keyword=(const char *) attributes[i++];
785 attribute=InterpretImageProperties(msl_info->image_info[n],
786 msl_info->attributes[n],(const char *) attributes[i],
788 CloneString(&value,attribute);
789 attribute=DestroyString(attribute);
795 if (LocaleCompare(keyword,"affine") == 0)
801 draw_info->affine.sx=StringToDouble(p,&p);
804 draw_info->affine.rx=StringToDouble(p,&p);
807 draw_info->affine.ry=StringToDouble(p,&p);
810 draw_info->affine.sy=StringToDouble(p,&p);
813 draw_info->affine.tx=StringToDouble(p,&p);
816 draw_info->affine.ty=StringToDouble(p,&p);
819 if (LocaleCompare(keyword,"align") == 0)
821 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
824 ThrowMSLException(OptionError,"UnrecognizedAlignType",
826 draw_info->align=(AlignType) option;
829 if (LocaleCompare(keyword,"antialias") == 0)
831 option=ParseCommandOption(MagickBooleanOptions,
834 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
836 draw_info->stroke_antialias=(MagickBooleanType) option;
837 draw_info->text_antialias=(MagickBooleanType) option;
840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
847 if (LocaleCompare(keyword,"density") == 0)
849 CloneString(&draw_info->density,value);
852 ThrowMSLException(OptionError,"UnrecognizedAttribute",
859 if (LocaleCompare(keyword,"encoding") == 0)
861 CloneString(&draw_info->encoding,value);
864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
871 if (LocaleCompare(keyword, "fill") == 0)
873 (void) QueryColorCompliance(value,AllCompliance,
874 &draw_info->fill,exception);
877 if (LocaleCompare(keyword,"family") == 0)
879 CloneString(&draw_info->family,value);
882 if (LocaleCompare(keyword,"font") == 0)
884 CloneString(&draw_info->font,value);
887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
894 if (LocaleCompare(keyword,"geometry") == 0)
896 flags=ParseGravityGeometry(msl_info->image[n],value,
897 &geometry,exception);
900 if (LocaleCompare(keyword,"gravity") == 0)
902 option=ParseCommandOption(MagickGravityOptions,
905 ThrowMSLException(OptionError,"UnrecognizedGravityType",
907 draw_info->gravity=(GravityType) option;
910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
917 if (LocaleCompare(keyword,"pointsize") == 0)
919 draw_info->pointsize=StringToDouble(value,(char **) NULL);
922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
929 if (LocaleCompare(keyword,"rotate") == 0)
931 angle=StringToDouble(value,(char **) NULL);
932 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
933 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
934 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
935 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
945 if (LocaleCompare(keyword,"scale") == 0)
947 flags=ParseGeometry(value,&geometry_info);
948 if ((flags & SigmaValue) == 0)
949 geometry_info.sigma=1.0;
950 affine.sx=geometry_info.rho;
951 affine.sy=geometry_info.sigma;
954 if (LocaleCompare(keyword,"skewX") == 0)
956 angle=StringToDouble(value,(char **) NULL);
957 affine.ry=tan(DegreesToRadians(fmod((double) angle,
961 if (LocaleCompare(keyword,"skewY") == 0)
963 angle=StringToDouble(value,(char **) NULL);
964 affine.rx=tan(DegreesToRadians(fmod((double) angle,
968 if (LocaleCompare(keyword,"stretch") == 0)
970 option=ParseCommandOption(MagickStretchOptions,
973 ThrowMSLException(OptionError,"UnrecognizedStretchType",
975 draw_info->stretch=(StretchType) option;
978 if (LocaleCompare(keyword, "stroke") == 0)
980 (void) QueryColorCompliance(value,AllCompliance,
981 &draw_info->stroke,exception);
984 if (LocaleCompare(keyword,"strokewidth") == 0)
986 draw_info->stroke_width=StringToLong(value);
989 if (LocaleCompare(keyword,"style") == 0)
991 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
994 ThrowMSLException(OptionError,"UnrecognizedStyleType",
996 draw_info->style=(StyleType) option;
999 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1006 if (LocaleCompare(keyword,"text") == 0)
1008 CloneString(&draw_info->text,value);
1011 if (LocaleCompare(keyword,"translate") == 0)
1013 flags=ParseGeometry(value,&geometry_info);
1014 if ((flags & SigmaValue) == 0)
1015 geometry_info.sigma=1.0;
1016 affine.tx=geometry_info.rho;
1017 affine.ty=geometry_info.sigma;
1020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1027 if (LocaleCompare(keyword, "undercolor") == 0)
1029 (void) QueryColorCompliance(value,AllCompliance,
1030 &draw_info->undercolor,exception);
1033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1040 if (LocaleCompare(keyword,"weight") == 0)
1042 draw_info->weight=StringToLong(value);
1045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1052 if (LocaleCompare(keyword,"x") == 0)
1054 geometry.x=StringToLong(value);
1057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1064 if (LocaleCompare(keyword,"y") == 0)
1066 geometry.y=StringToLong(value);
1069 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1075 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1081 (void) FormatLocaleString(text,MagickPathExtent,
1082 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1083 geometry.height,(double) geometry.x,(double) geometry.y);
1084 CloneString(&draw_info->geometry,text);
1085 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1086 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1087 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1088 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1089 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1091 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1093 (void) AnnotateImage(msl_info->image[n],draw_info,
1094 msl_info->exception);
1095 draw_info=DestroyDrawInfo(draw_info);
1098 if (LocaleCompare((const char *) tag,"append") == 0)
1106 if (msl_info->image[n] == (Image *) NULL)
1108 ThrowMSLException(OptionError,"NoImagesDefined",
1109 (const char *) tag);
1113 if (attributes != (const xmlChar **) NULL)
1114 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1116 keyword=(const char *) attributes[i++];
1117 attribute=InterpretImageProperties(msl_info->image_info[n],
1118 msl_info->attributes[n],(const char *) attributes[i],
1120 CloneString(&value,attribute);
1121 attribute=DestroyString(attribute);
1127 if (LocaleCompare(keyword,"stack") == 0)
1129 option=ParseCommandOption(MagickBooleanOptions,
1132 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1134 stack=(MagickBooleanType) option;
1137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1149 append_image=AppendImages(msl_info->image[n],stack,
1150 msl_info->exception);
1151 if (append_image == (Image *) NULL)
1153 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1154 msl_info->image[n]=append_image;
1157 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1163 if (LocaleCompare((const char *) tag,"blur") == 0)
1171 if (msl_info->image[n] == (Image *) NULL)
1173 ThrowMSLException(OptionError,"NoImagesDefined",
1174 (const char *) tag);
1177 if (attributes != (const xmlChar **) NULL)
1178 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1180 keyword=(const char *) attributes[i++];
1181 attribute=InterpretImageProperties(msl_info->image_info[n],
1182 msl_info->attributes[n],(const char *) attributes[i],
1184 CloneString(&value,attribute);
1185 attribute=DestroyString(attribute);
1191 if (LocaleCompare(keyword,"channel") == 0)
1193 option=ParseChannelOption(value);
1195 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1197 channel=(ChannelType) option;
1200 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1207 if (LocaleCompare(keyword,"geometry") == 0)
1209 flags=ParseGeometry(value,&geometry_info);
1210 if ((flags & SigmaValue) == 0)
1211 geometry_info.sigma=1.0;
1214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1221 if (LocaleCompare(keyword,"radius") == 0)
1223 geometry_info.rho=StringToDouble(value,(char **) NULL);
1226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1233 if (LocaleCompare(keyword,"sigma") == 0)
1235 geometry_info.sigma=StringToLong(value);
1238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1250 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
1251 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1252 geometry_info.sigma,msl_info->exception);
1253 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
1254 if (blur_image == (Image *) NULL)
1256 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1257 msl_info->image[n]=blur_image;
1260 if (LocaleCompare((const char *) tag,"border") == 0)
1268 if (msl_info->image[n] == (Image *) NULL)
1270 ThrowMSLException(OptionError,"NoImagesDefined",
1271 (const char *) tag);
1274 SetGeometry(msl_info->image[n],&geometry);
1275 if (attributes != (const xmlChar **) NULL)
1276 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1278 keyword=(const char *) attributes[i++];
1279 attribute=InterpretImageProperties(msl_info->image_info[n],
1280 msl_info->attributes[n],(const char *) attributes[i],
1282 CloneString(&value,attribute);
1283 attribute=DestroyString(attribute);
1289 if (LocaleCompare(keyword,"compose") == 0)
1291 option=ParseCommandOption(MagickComposeOptions,
1294 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1296 msl_info->image[n]->compose=(CompositeOperator) option;
1299 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1306 if (LocaleCompare(keyword, "fill") == 0)
1308 (void) QueryColorCompliance(value,AllCompliance,
1309 &msl_info->image[n]->border_color,exception);
1312 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1319 if (LocaleCompare(keyword,"geometry") == 0)
1321 flags=ParsePageGeometry(msl_info->image[n],value,
1322 &geometry,exception);
1323 if ((flags & HeightValue) == 0)
1324 geometry.height=geometry.width;
1327 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1334 if (LocaleCompare(keyword,"height") == 0)
1336 geometry.height=StringToLong(value);
1339 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1346 if (LocaleCompare(keyword,"width") == 0)
1348 geometry.width=StringToLong(value);
1351 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1357 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1363 border_image=BorderImage(msl_info->image[n],&geometry,
1364 msl_info->image[n]->compose,msl_info->exception);
1365 if (border_image == (Image *) NULL)
1367 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1368 msl_info->image[n]=border_image;
1371 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1376 if (LocaleCompare((const char *) tag,"colorize") == 0)
1379 blend[MagickPathExtent];
1390 if (msl_info->image[n] == (Image *) NULL)
1392 ThrowMSLException(OptionError,"NoImagesDefined",
1393 (const char *) tag);
1396 GetPixelInfo(msl_info->image[n],&target);
1397 (void) CopyMagickString(blend,"100",MagickPathExtent);
1398 if (attributes != (const xmlChar **) NULL)
1399 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1401 keyword=(const char *) attributes[i++];
1402 attribute=InterpretImageProperties(msl_info->image_info[n],
1403 msl_info->attributes[n],(const char *) attributes[i],
1405 CloneString(&value,attribute);
1406 attribute=DestroyString(attribute);
1412 if (LocaleCompare(keyword,"blend") == 0)
1414 (void) CopyMagickString(blend,value,MagickPathExtent);
1417 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1424 if (LocaleCompare(keyword,"fill") == 0)
1426 (void) QueryColorCompliance(value,AllCompliance,
1427 &target,msl_info->exception);
1430 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1442 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1443 msl_info->exception);
1444 if (colorize_image == (Image *) NULL)
1446 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1447 msl_info->image[n]=colorize_image;
1450 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1456 if (msl_info->image[n] == (Image *) NULL)
1458 ThrowMSLException(OptionError,"NoImagesDefined",
1459 (const char *) tag);
1463 NOTE: charcoal can have no attributes, since we use all the defaults!
1465 if (attributes != (const xmlChar **) NULL)
1467 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1469 keyword=(const char *) attributes[i++];
1470 attribute=InterpretImageProperties(msl_info->image_info[n],
1471 msl_info->attributes[n],(const char *) attributes[i],exception);
1472 CloneString(&value,attribute);
1473 attribute=DestroyString(attribute);
1479 if (LocaleCompare(keyword,"radius") == 0)
1481 radius=StringToDouble(value,(char **) NULL);
1484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1490 if (LocaleCompare(keyword,"sigma") == 0)
1492 sigma = StringToLong( value );
1495 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1500 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1514 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1515 msl_info->exception);
1516 if (newImage == (Image *) NULL)
1518 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1519 msl_info->image[n]=newImage;
1523 if (LocaleCompare((const char *) tag,"chop") == 0)
1531 if (msl_info->image[n] == (Image *) NULL)
1533 ThrowMSLException(OptionError,"NoImagesDefined",
1534 (const char *) tag);
1537 SetGeometry(msl_info->image[n],&geometry);
1538 if (attributes != (const xmlChar **) NULL)
1539 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1541 keyword=(const char *) attributes[i++];
1542 attribute=InterpretImageProperties(msl_info->image_info[n],
1543 msl_info->attributes[n],(const char *) attributes[i],
1545 CloneString(&value,attribute);
1546 attribute=DestroyString(attribute);
1552 if (LocaleCompare(keyword,"geometry") == 0)
1554 flags=ParsePageGeometry(msl_info->image[n],value,
1555 &geometry,exception);
1556 if ((flags & HeightValue) == 0)
1557 geometry.height=geometry.width;
1560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1567 if (LocaleCompare(keyword,"height") == 0)
1569 geometry.height=StringToLong(value);
1572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 if (LocaleCompare(keyword,"width") == 0)
1581 geometry.width=StringToLong(value);
1584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1591 if (LocaleCompare(keyword,"x") == 0)
1593 geometry.x=StringToLong(value);
1596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1603 if (LocaleCompare(keyword,"y") == 0)
1605 geometry.y=StringToLong(value);
1608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1620 chop_image=ChopImage(msl_info->image[n],&geometry,
1621 msl_info->exception);
1622 if (chop_image == (Image *) NULL)
1624 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1625 msl_info->image[n]=chop_image;
1628 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1637 Color floodfill image.
1639 if (msl_info->image[n] == (Image *) NULL)
1641 ThrowMSLException(OptionError,"NoImagesDefined",
1642 (const char *) tag);
1645 draw_info=CloneDrawInfo(msl_info->image_info[n],
1646 msl_info->draw_info[n]);
1647 SetGeometry(msl_info->image[n],&geometry);
1648 paint_method=FloodfillMethod;
1649 if (attributes != (const xmlChar **) NULL)
1650 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1652 keyword=(const char *) attributes[i++];
1653 attribute=InterpretImageProperties(msl_info->image_info[n],
1654 msl_info->attributes[n],(const char *) attributes[i],
1656 CloneString(&value,attribute);
1657 attribute=DestroyString(attribute);
1663 if (LocaleCompare(keyword,"bordercolor") == 0)
1665 (void) QueryColorCompliance(value,AllCompliance,
1667 paint_method=FillToBorderMethod;
1670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1677 if (LocaleCompare(keyword,"fill") == 0)
1679 (void) QueryColorCompliance(value,AllCompliance,
1680 &draw_info->fill,exception);
1683 if (LocaleCompare(keyword,"fuzz") == 0)
1685 msl_info->image[n]->fuzz=StringToDouble(value,
1689 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1696 if (LocaleCompare(keyword,"geometry") == 0)
1698 flags=ParsePageGeometry(msl_info->image[n],value,
1699 &geometry,exception);
1700 if ((flags & HeightValue) == 0)
1701 geometry.height=geometry.width;
1702 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1703 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1707 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1714 if (LocaleCompare(keyword,"x") == 0)
1716 geometry.x=StringToLong(value);
1717 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1718 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1722 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1729 if (LocaleCompare(keyword,"y") == 0)
1731 geometry.y=StringToLong(value);
1732 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1733 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1743 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1749 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1750 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1751 MagickFalse : MagickTrue,msl_info->exception);
1752 draw_info=DestroyDrawInfo(draw_info);
1755 if (LocaleCompare((const char *) tag,"comment") == 0)
1757 if (LocaleCompare((const char *) tag,"composite") == 0)
1760 composite_geometry[MagickPathExtent];
1772 if (msl_info->image[n] == (Image *) NULL)
1774 ThrowMSLException(OptionError,"NoImagesDefined",
1775 (const char *) tag);
1778 composite_image=NewImageList();
1779 compose=OverCompositeOp;
1780 if (attributes != (const xmlChar **) NULL)
1781 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1783 keyword=(const char *) attributes[i++];
1784 attribute=InterpretImageProperties(msl_info->image_info[n],
1785 msl_info->attributes[n],(const char *) attributes[i],
1787 CloneString(&value,attribute);
1788 attribute=DestroyString(attribute);
1794 if (LocaleCompare(keyword,"compose") == 0)
1796 option=ParseCommandOption(MagickComposeOptions,
1799 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1801 compose=(CompositeOperator) option;
1809 if (LocaleCompare(keyword,"image") == 0)
1810 for (j=0; j < msl_info->n; j++)
1815 attribute=GetImageProperty(msl_info->attributes[j],"id",
1817 if ((attribute != (const char *) NULL) &&
1818 (LocaleCompare(attribute,value) == 0))
1820 composite_image=CloneImage(msl_info->image[j],0,0,
1821 MagickFalse,exception);
1831 if (composite_image == (Image *) NULL)
1833 rotate_image=NewImageList();
1834 SetGeometry(msl_info->image[n],&geometry);
1835 if (attributes != (const xmlChar **) NULL)
1836 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1838 keyword=(const char *) attributes[i++];
1839 attribute=InterpretImageProperties(msl_info->image_info[n],
1840 msl_info->attributes[n],(const char *) attributes[i],
1842 CloneString(&value,attribute);
1843 attribute=DestroyString(attribute);
1849 if (LocaleCompare(keyword,"blend") == 0)
1851 (void) SetImageArtifact(composite_image,
1852 "compose:args",value);
1855 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1862 if (LocaleCompare(keyword,"channel") == 0)
1864 option=ParseChannelOption(value);
1866 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1868 channel=(ChannelType) option;
1871 if (LocaleCompare(keyword, "color") == 0)
1873 (void) QueryColorCompliance(value,AllCompliance,
1874 &composite_image->background_color,exception);
1877 if (LocaleCompare(keyword,"compose") == 0)
1879 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1886 if (LocaleCompare(keyword,"geometry") == 0)
1888 flags=ParsePageGeometry(msl_info->image[n],value,
1889 &geometry,exception);
1890 if ((flags & HeightValue) == 0)
1891 geometry.height=geometry.width;
1894 if (LocaleCompare(keyword,"gravity") == 0)
1896 option=ParseCommandOption(MagickGravityOptions,
1899 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1901 msl_info->image[n]->gravity=(GravityType) option;
1904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1911 if (LocaleCompare(keyword,"image") == 0)
1913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1920 if (LocaleCompare(keyword,"mask") == 0)
1921 for (j=0; j < msl_info->n; j++)
1926 attribute=GetImageProperty(msl_info->attributes[j],"id",
1928 if ((attribute != (const char *) NULL) &&
1929 (LocaleCompare(value,value) == 0))
1931 SetImageType(composite_image,TrueColorAlphaType,
1933 (void) CompositeImage(composite_image,
1934 msl_info->image[j],CopyAlphaCompositeOp,MagickTrue,
1939 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1946 if (LocaleCompare(keyword,"opacity") == 0)
1961 opacity=StringToLong(value);
1962 if (compose != DissolveCompositeOp)
1964 (void) SetImageAlpha(composite_image,(Quantum)
1968 (void) SetImageArtifact(msl_info->image[n],
1969 "compose:args",value);
1970 if (composite_image->alpha_trait == UndefinedPixelTrait)
1971 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1973 composite_view=AcquireAuthenticCacheView(composite_image,exception);
1974 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1976 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1977 (ssize_t) composite_image->columns,1,exception);
1978 for (x=0; x < (ssize_t) composite_image->columns; x++)
1980 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1981 SetPixelAlpha(composite_image,
1982 ClampToQuantum(opacity),q);
1983 q+=GetPixelChannels(composite_image);
1985 if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
1988 composite_view=DestroyCacheView(composite_view);
1991 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1998 if (LocaleCompare(keyword,"rotate") == 0)
2000 rotate_image=RotateImage(composite_image,
2001 StringToDouble(value,(char **) NULL),exception);
2004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2011 if (LocaleCompare(keyword,"tile") == 0)
2016 option=ParseCommandOption(MagickBooleanOptions,
2019 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2021 tile=(MagickBooleanType) option;
2023 if (rotate_image != (Image *) NULL)
2024 (void) SetImageArtifact(rotate_image,
2025 "compose:outside-overlay","false");
2027 (void) SetImageArtifact(composite_image,
2028 "compose:outside-overlay","false");
2029 image=msl_info->image[n];
2030 height=composite_image->rows;
2031 width=composite_image->columns;
2032 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2033 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2035 if (rotate_image != (Image *) NULL)
2036 (void) CompositeImage(image,rotate_image,compose,
2037 MagickTrue,x,y,exception);
2039 (void) CompositeImage(image,composite_image,
2040 compose,MagickTrue,x,y,exception);
2042 if (rotate_image != (Image *) NULL)
2043 rotate_image=DestroyImage(rotate_image);
2046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2053 if (LocaleCompare(keyword,"x") == 0)
2055 geometry.x=StringToLong(value);
2058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2065 if (LocaleCompare(keyword,"y") == 0)
2067 geometry.y=StringToLong(value);
2070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2076 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2082 image=msl_info->image[n];
2083 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
2084 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2085 (double) composite_image->rows,(double) geometry.x,(double)
2087 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2089 channel_mask=SetImageChannelMask(image,channel);
2090 if (rotate_image == (Image *) NULL)
2091 CompositeImage(image,composite_image,compose,MagickTrue,geometry.x,
2092 geometry.y,exception);
2098 geometry.x-=(ssize_t) (rotate_image->columns-
2099 composite_image->columns)/2;
2100 geometry.y-=(ssize_t) (rotate_image->rows-
2101 composite_image->rows)/2;
2102 CompositeImage(image,rotate_image,compose,MagickTrue,geometry.x,
2103 geometry.y,exception);
2104 rotate_image=DestroyImage(rotate_image);
2106 (void) SetImageChannelMask(image,channel_mask);
2107 composite_image=DestroyImage(composite_image);
2110 if (LocaleCompare((const char *) tag,"contrast") == 0)
2118 if (msl_info->image[n] == (Image *) NULL)
2120 ThrowMSLException(OptionError,"NoImagesDefined",
2121 (const char *) tag);
2124 sharpen=MagickFalse;
2125 if (attributes != (const xmlChar **) NULL)
2126 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2128 keyword=(const char *) attributes[i++];
2129 attribute=InterpretImageProperties(msl_info->image_info[n],
2130 msl_info->attributes[n],(const char *) attributes[i],
2132 CloneString(&value,attribute);
2133 attribute=DestroyString(attribute);
2139 if (LocaleCompare(keyword,"sharpen") == 0)
2141 option=ParseCommandOption(MagickBooleanOptions,
2144 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2146 sharpen=(MagickBooleanType) option;
2149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2161 (void) ContrastImage(msl_info->image[n],sharpen,
2162 msl_info->exception);
2165 if (LocaleCompare((const char *) tag,"crop") == 0)
2173 if (msl_info->image[n] == (Image *) NULL)
2175 ThrowMSLException(OptionError,"NoImagesDefined",
2176 (const char *) tag);
2179 SetGeometry(msl_info->image[n],&geometry);
2180 if (attributes != (const xmlChar **) NULL)
2181 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2183 keyword=(const char *) attributes[i++];
2184 attribute=InterpretImageProperties(msl_info->image_info[n],
2185 msl_info->attributes[n],(const char *) attributes[i],
2187 CloneString(&value,attribute);
2188 attribute=DestroyString(attribute);
2194 if (LocaleCompare(keyword,"geometry") == 0)
2196 flags=ParseGravityGeometry(msl_info->image[n],value,
2197 &geometry,exception);
2200 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2207 if (LocaleCompare(keyword,"height") == 0)
2209 geometry.height=StringToLong(value);
2212 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2219 if (LocaleCompare(keyword,"width") == 0)
2221 geometry.width=StringToLong(value);
2224 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2231 if (LocaleCompare(keyword,"x") == 0)
2233 geometry.x=StringToLong(value);
2236 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2243 if (LocaleCompare(keyword,"y") == 0)
2245 geometry.y=StringToLong(value);
2248 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2260 crop_image=CropImage(msl_info->image[n],&geometry,
2261 msl_info->exception);
2262 if (crop_image == (Image *) NULL)
2264 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2265 msl_info->image[n]=crop_image;
2268 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2274 Cycle-colormap image.
2276 if (msl_info->image[n] == (Image *) NULL)
2278 ThrowMSLException(OptionError,"NoImagesDefined",
2279 (const char *) tag);
2283 if (attributes != (const xmlChar **) NULL)
2284 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2286 keyword=(const char *) attributes[i++];
2287 attribute=InterpretImageProperties(msl_info->image_info[n],
2288 msl_info->attributes[n],(const char *) attributes[i],
2290 CloneString(&value,attribute);
2291 attribute=DestroyString(attribute);
2297 if (LocaleCompare(keyword,"display") == 0)
2299 display=StringToLong(value);
2302 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2308 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2314 (void) CycleColormapImage(msl_info->image[n],display,exception);
2317 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2322 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2330 if (msl_info->image[n] == (Image *) NULL)
2332 ThrowMSLException(OptionError,"NoImagesDefined",
2333 (const char *) tag);
2336 if (attributes != (const xmlChar **) NULL)
2337 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2339 keyword=(const char *) attributes[i++];
2340 attribute=InterpretImageProperties(msl_info->image_info[n],
2341 msl_info->attributes[n],(const char *) attributes[i],
2343 CloneString(&value,attribute);
2344 attribute=DestroyString(attribute);
2345 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2347 despeckle_image=DespeckleImage(msl_info->image[n],
2348 msl_info->exception);
2349 if (despeckle_image == (Image *) NULL)
2351 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2352 msl_info->image[n]=despeckle_image;
2355 if (LocaleCompare((const char *) tag,"display") == 0)
2357 if (msl_info->image[n] == (Image *) NULL)
2359 ThrowMSLException(OptionError,"NoImagesDefined",
2360 (const char *) tag);
2363 if (attributes != (const xmlChar **) NULL)
2364 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2366 keyword=(const char *) attributes[i++];
2367 attribute=InterpretImageProperties(msl_info->image_info[n],
2368 msl_info->attributes[n],(const char *) attributes[i],
2370 CloneString(&value,attribute);
2371 attribute=DestroyString(attribute);
2376 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2382 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2383 msl_info->exception);
2386 if (LocaleCompare((const char *) tag,"draw") == 0)
2389 text[MagickPathExtent];
2394 if (msl_info->image[n] == (Image *) NULL)
2396 ThrowMSLException(OptionError,"NoImagesDefined",
2397 (const char *) tag);
2400 draw_info=CloneDrawInfo(msl_info->image_info[n],
2401 msl_info->draw_info[n]);
2403 current=draw_info->affine;
2404 GetAffineMatrix(&affine);
2405 if (attributes != (const xmlChar **) NULL)
2406 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2408 keyword=(const char *) attributes[i++];
2409 attribute=InterpretImageProperties(msl_info->image_info[n],
2410 msl_info->attributes[n],(const char *) attributes[i],
2412 CloneString(&value,attribute);
2413 attribute=DestroyString(attribute);
2419 if (LocaleCompare(keyword,"affine") == 0)
2425 draw_info->affine.sx=StringToDouble(p,&p);
2428 draw_info->affine.rx=StringToDouble(p,&p);
2431 draw_info->affine.ry=StringToDouble(p,&p);
2434 draw_info->affine.sy=StringToDouble(p,&p);
2437 draw_info->affine.tx=StringToDouble(p,&p);
2440 draw_info->affine.ty=StringToDouble(p,&p);
2443 if (LocaleCompare(keyword,"align") == 0)
2445 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2448 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2450 draw_info->align=(AlignType) option;
2453 if (LocaleCompare(keyword,"antialias") == 0)
2455 option=ParseCommandOption(MagickBooleanOptions,
2458 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2460 draw_info->stroke_antialias=(MagickBooleanType) option;
2461 draw_info->text_antialias=(MagickBooleanType) option;
2464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2471 if (LocaleCompare(keyword,"density") == 0)
2473 CloneString(&draw_info->density,value);
2476 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2483 if (LocaleCompare(keyword,"encoding") == 0)
2485 CloneString(&draw_info->encoding,value);
2488 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2495 if (LocaleCompare(keyword, "fill") == 0)
2497 (void) QueryColorCompliance(value,AllCompliance,
2498 &draw_info->fill,exception);
2501 if (LocaleCompare(keyword,"family") == 0)
2503 CloneString(&draw_info->family,value);
2506 if (LocaleCompare(keyword,"font") == 0)
2508 CloneString(&draw_info->font,value);
2511 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2518 if (LocaleCompare(keyword,"geometry") == 0)
2520 flags=ParsePageGeometry(msl_info->image[n],value,
2521 &geometry,exception);
2522 if ((flags & HeightValue) == 0)
2523 geometry.height=geometry.width;
2526 if (LocaleCompare(keyword,"gravity") == 0)
2528 option=ParseCommandOption(MagickGravityOptions,
2531 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2533 draw_info->gravity=(GravityType) option;
2536 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2543 if (LocaleCompare(keyword,"points") == 0)
2545 if (LocaleCompare(draw_info->primitive,"path") == 0)
2547 (void) ConcatenateString(&draw_info->primitive," '");
2548 ConcatenateString(&draw_info->primitive,value);
2549 (void) ConcatenateString(&draw_info->primitive,"'");
2553 (void) ConcatenateString(&draw_info->primitive," ");
2554 ConcatenateString(&draw_info->primitive,value);
2558 if (LocaleCompare(keyword,"pointsize") == 0)
2560 draw_info->pointsize=StringToDouble(value,
2564 if (LocaleCompare(keyword,"primitive") == 0)
2566 CloneString(&draw_info->primitive,value);
2569 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2576 if (LocaleCompare(keyword,"rotate") == 0)
2578 angle=StringToDouble(value,(char **) NULL);
2579 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2580 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2581 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2582 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2592 if (LocaleCompare(keyword,"scale") == 0)
2594 flags=ParseGeometry(value,&geometry_info);
2595 if ((flags & SigmaValue) == 0)
2596 geometry_info.sigma=1.0;
2597 affine.sx=geometry_info.rho;
2598 affine.sy=geometry_info.sigma;
2601 if (LocaleCompare(keyword,"skewX") == 0)
2603 angle=StringToDouble(value,(char **) NULL);
2604 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2607 if (LocaleCompare(keyword,"skewY") == 0)
2609 angle=StringToDouble(value,(char **) NULL);
2610 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2613 if (LocaleCompare(keyword,"stretch") == 0)
2615 option=ParseCommandOption(MagickStretchOptions,
2618 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2620 draw_info->stretch=(StretchType) option;
2623 if (LocaleCompare(keyword, "stroke") == 0)
2625 (void) QueryColorCompliance(value,AllCompliance,
2626 &draw_info->stroke,exception);
2629 if (LocaleCompare(keyword,"strokewidth") == 0)
2631 draw_info->stroke_width=StringToLong(value);
2634 if (LocaleCompare(keyword,"style") == 0)
2636 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2639 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2641 draw_info->style=(StyleType) option;
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2651 if (LocaleCompare(keyword,"text") == 0)
2653 (void) ConcatenateString(&draw_info->primitive," '");
2654 (void) ConcatenateString(&draw_info->primitive,value);
2655 (void) ConcatenateString(&draw_info->primitive,"'");
2658 if (LocaleCompare(keyword,"translate") == 0)
2660 flags=ParseGeometry(value,&geometry_info);
2661 if ((flags & SigmaValue) == 0)
2662 geometry_info.sigma=1.0;
2663 affine.tx=geometry_info.rho;
2664 affine.ty=geometry_info.sigma;
2667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2674 if (LocaleCompare(keyword, "undercolor") == 0)
2676 (void) QueryColorCompliance(value,AllCompliance,
2677 &draw_info->undercolor,exception);
2680 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2687 if (LocaleCompare(keyword,"weight") == 0)
2689 draw_info->weight=StringToLong(value);
2692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2699 if (LocaleCompare(keyword,"x") == 0)
2701 geometry.x=StringToLong(value);
2704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2711 if (LocaleCompare(keyword,"y") == 0)
2713 geometry.y=StringToLong(value);
2716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2722 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2728 (void) FormatLocaleString(text,MagickPathExtent,
2729 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2730 geometry.height,(double) geometry.x,(double) geometry.y);
2731 CloneString(&draw_info->geometry,text);
2732 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2733 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2734 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2735 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2736 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2738 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2740 (void) DrawImage(msl_info->image[n],draw_info,exception);
2741 draw_info=DestroyDrawInfo(draw_info);
2744 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2749 if (LocaleCompare((const char *) tag,"edge") == 0)
2757 if (msl_info->image[n] == (Image *) NULL)
2759 ThrowMSLException(OptionError,"NoImagesDefined",
2760 (const char *) tag);
2763 if (attributes != (const xmlChar **) NULL)
2764 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2766 keyword=(const char *) attributes[i++];
2767 attribute=InterpretImageProperties(msl_info->image_info[n],
2768 msl_info->attributes[n],(const char *) attributes[i],
2770 CloneString(&value,attribute);
2771 attribute=DestroyString(attribute);
2777 if (LocaleCompare(keyword,"geometry") == 0)
2779 flags=ParseGeometry(value,&geometry_info);
2780 if ((flags & SigmaValue) == 0)
2781 geometry_info.sigma=1.0;
2784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2791 if (LocaleCompare(keyword,"radius") == 0)
2793 geometry_info.rho=StringToDouble(value,(char **) NULL);
2796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2802 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2808 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2809 msl_info->exception);
2810 if (edge_image == (Image *) NULL)
2812 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2813 msl_info->image[n]=edge_image;
2816 if (LocaleCompare((const char *) tag,"emboss") == 0)
2824 if (msl_info->image[n] == (Image *) NULL)
2826 ThrowMSLException(OptionError,"NoImagesDefined",
2827 (const char *) tag);
2830 if (attributes != (const xmlChar **) NULL)
2831 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2833 keyword=(const char *) attributes[i++];
2834 attribute=InterpretImageProperties(msl_info->image_info[n],
2835 msl_info->attributes[n],(const char *) attributes[i],
2837 CloneString(&value,attribute);
2838 attribute=DestroyString(attribute);
2844 if (LocaleCompare(keyword,"geometry") == 0)
2846 flags=ParseGeometry(value,&geometry_info);
2847 if ((flags & SigmaValue) == 0)
2848 geometry_info.sigma=1.0;
2851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2858 if (LocaleCompare(keyword,"radius") == 0)
2860 geometry_info.rho=StringToDouble(value,
2864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2871 if (LocaleCompare(keyword,"sigma") == 0)
2873 geometry_info.sigma=StringToLong(value);
2876 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2888 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2889 geometry_info.sigma,msl_info->exception);
2890 if (emboss_image == (Image *) NULL)
2892 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2893 msl_info->image[n]=emboss_image;
2896 if (LocaleCompare((const char *) tag,"enhance") == 0)
2904 if (msl_info->image[n] == (Image *) NULL)
2906 ThrowMSLException(OptionError,"NoImagesDefined",
2907 (const char *) tag);
2910 if (attributes != (const xmlChar **) NULL)
2911 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2913 keyword=(const char *) attributes[i++];
2914 attribute=InterpretImageProperties(msl_info->image_info[n],
2915 msl_info->attributes[n],(const char *) attributes[i],
2917 CloneString(&value,attribute);
2918 attribute=DestroyString(attribute);
2919 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2921 enhance_image=EnhanceImage(msl_info->image[n],
2922 msl_info->exception);
2923 if (enhance_image == (Image *) NULL)
2925 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2926 msl_info->image[n]=enhance_image;
2929 if (LocaleCompare((const char *) tag,"equalize") == 0)
2934 if (msl_info->image[n] == (Image *) NULL)
2936 ThrowMSLException(OptionError,"NoImagesDefined",
2937 (const char *) tag);
2940 if (attributes != (const xmlChar **) NULL)
2941 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2943 keyword=(const char *) attributes[i++];
2944 attribute=InterpretImageProperties(msl_info->image_info[n],
2945 msl_info->attributes[n],(const char *) attributes[i],
2947 CloneString(&value,attribute);
2948 attribute=DestroyString(attribute);
2953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2959 (void) EqualizeImage(msl_info->image[n],
2960 msl_info->exception);
2963 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2968 if (LocaleCompare((const char *) tag, "flatten") == 0)
2970 if (msl_info->image[n] == (Image *) NULL)
2972 ThrowMSLException(OptionError,"NoImagesDefined",
2973 (const char *) tag);
2977 /* no attributes here */
2979 /* process the image */
2984 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2985 msl_info->exception);
2986 if (newImage == (Image *) NULL)
2988 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2989 msl_info->image[n]=newImage;
2993 if (LocaleCompare((const char *) tag,"flip") == 0)
3001 if (msl_info->image[n] == (Image *) NULL)
3003 ThrowMSLException(OptionError,"NoImagesDefined",
3004 (const char *) tag);
3007 if (attributes != (const xmlChar **) NULL)
3008 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3010 keyword=(const char *) attributes[i++];
3011 attribute=InterpretImageProperties(msl_info->image_info[n],
3012 msl_info->attributes[n],(const char *) attributes[i],
3014 CloneString(&value,attribute);
3015 attribute=DestroyString(attribute);
3016 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3018 flip_image=FlipImage(msl_info->image[n],
3019 msl_info->exception);
3020 if (flip_image == (Image *) NULL)
3022 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3023 msl_info->image[n]=flip_image;
3026 if (LocaleCompare((const char *) tag,"flop") == 0)
3034 if (msl_info->image[n] == (Image *) NULL)
3036 ThrowMSLException(OptionError,"NoImagesDefined",
3037 (const char *) tag);
3040 if (attributes != (const xmlChar **) NULL)
3041 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3043 keyword=(const char *) attributes[i++];
3044 attribute=InterpretImageProperties(msl_info->image_info[n],
3045 msl_info->attributes[n],(const char *) attributes[i],
3047 CloneString(&value,attribute);
3048 attribute=DestroyString(attribute);
3049 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3051 flop_image=FlopImage(msl_info->image[n],
3052 msl_info->exception);
3053 if (flop_image == (Image *) NULL)
3055 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3056 msl_info->image[n]=flop_image;
3059 if (LocaleCompare((const char *) tag,"frame") == 0)
3070 if (msl_info->image[n] == (Image *) NULL)
3072 ThrowMSLException(OptionError,"NoImagesDefined",
3073 (const char *) tag);
3076 (void) memset(&frame_info,0,sizeof(frame_info));
3077 SetGeometry(msl_info->image[n],&geometry);
3078 if (attributes != (const xmlChar **) NULL)
3079 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3081 keyword=(const char *) attributes[i++];
3082 attribute=InterpretImageProperties(msl_info->image_info[n],
3083 msl_info->attributes[n],(const char *) attributes[i],
3085 CloneString(&value,attribute);
3086 attribute=DestroyString(attribute);
3092 if (LocaleCompare(keyword,"compose") == 0)
3094 option=ParseCommandOption(MagickComposeOptions,
3097 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3099 msl_info->image[n]->compose=(CompositeOperator) option;
3102 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3109 if (LocaleCompare(keyword, "fill") == 0)
3111 (void) QueryColorCompliance(value,AllCompliance,
3112 &msl_info->image[n]->matte_color,exception);
3115 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3122 if (LocaleCompare(keyword,"geometry") == 0)
3124 flags=ParsePageGeometry(msl_info->image[n],value,
3125 &geometry,exception);
3126 if ((flags & HeightValue) == 0)
3127 geometry.height=geometry.width;
3128 frame_info.width=geometry.width;
3129 frame_info.height=geometry.height;
3130 frame_info.outer_bevel=geometry.x;
3131 frame_info.inner_bevel=geometry.y;
3134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3141 if (LocaleCompare(keyword,"height") == 0)
3143 frame_info.height=StringToLong(value);
3146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3153 if (LocaleCompare(keyword,"inner") == 0)
3155 frame_info.inner_bevel=StringToLong(value);
3158 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3165 if (LocaleCompare(keyword,"outer") == 0)
3167 frame_info.outer_bevel=StringToLong(value);
3170 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3177 if (LocaleCompare(keyword,"width") == 0)
3179 frame_info.width=StringToLong(value);
3182 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3188 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3194 frame_info.x=(ssize_t) frame_info.width;
3195 frame_info.y=(ssize_t) frame_info.height;
3196 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3197 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3198 frame_image=FrameImage(msl_info->image[n],&frame_info,
3199 msl_info->image[n]->compose,msl_info->exception);
3200 if (frame_image == (Image *) NULL)
3202 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3203 msl_info->image[n]=frame_image;
3206 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3211 if (LocaleCompare((const char *) tag,"gamma") == 0)
3214 gamma[MagickPathExtent];
3222 if (msl_info->image[n] == (Image *) NULL)
3224 ThrowMSLException(OptionError,"NoImagesDefined",
3225 (const char *) tag);
3228 channel=UndefinedChannel;
3233 if (attributes != (const xmlChar **) NULL)
3234 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3236 keyword=(const char *) attributes[i++];
3237 attribute=InterpretImageProperties(msl_info->image_info[n],
3238 msl_info->attributes[n],(const char *) attributes[i],
3240 CloneString(&value,attribute);
3241 attribute=DestroyString(attribute);
3247 if (LocaleCompare(keyword,"blue") == 0)
3249 pixel.blue=StringToDouble(value,(char **) NULL);
3252 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3259 if (LocaleCompare(keyword,"channel") == 0)
3261 option=ParseChannelOption(value);
3263 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3265 channel=(ChannelType) option;
3268 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3275 if (LocaleCompare(keyword,"gamma") == 0)
3277 (void) CopyMagickString(gamma,value,MagickPathExtent);
3280 if (LocaleCompare(keyword,"green") == 0)
3282 pixel.green=StringToDouble(value,(char **) NULL);
3285 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3292 if (LocaleCompare(keyword,"red") == 0)
3294 pixel.red=StringToDouble(value,(char **) NULL);
3297 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3310 (void) FormatLocaleString(gamma,MagickPathExtent,"%g,%g,%g",
3311 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3312 (void) GammaImage(msl_info->image[n],strtod(gamma,(char **) NULL),
3313 msl_info->exception);
3316 else if (LocaleCompare((const char *) tag,"get") == 0)
3318 if (msl_info->image[n] == (Image *) NULL)
3320 ThrowMSLException(OptionError,"NoImagesDefined",
3321 (const char *) tag);
3324 if (attributes == (const xmlChar **) NULL)
3326 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3328 keyword=(const char *) attributes[i++];
3329 CloneString(&value,(const char *) attributes[i]);
3330 (void) CopyMagickString(key,value,MagickPathExtent);
3336 if (LocaleCompare(keyword,"height") == 0)
3338 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
3339 (double) msl_info->image[n]->rows);
3340 (void) SetImageProperty(msl_info->attributes[n],key,value,
3344 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3349 if (LocaleCompare(keyword,"width") == 0)
3351 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
3352 (double) msl_info->image[n]->columns);
3353 (void) SetImageProperty(msl_info->attributes[n],key,value,
3357 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3361 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3368 else if (LocaleCompare((const char *) tag, "group") == 0)
3370 msl_info->number_groups++;
3371 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3372 msl_info->group_info,msl_info->number_groups+1UL,
3373 sizeof(*msl_info->group_info));
3376 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3381 if (LocaleCompare((const char *) tag,"image") == 0)
3383 MSLPushImage(msl_info,(Image *) NULL);
3384 if (attributes == (const xmlChar **) NULL)
3386 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3388 keyword=(const char *) attributes[i++];
3389 attribute=InterpretImageProperties(msl_info->image_info[n],
3390 msl_info->attributes[n],(const char *) attributes[i],exception);
3391 CloneString(&value,attribute);
3392 attribute=DestroyString(attribute);
3398 if (LocaleCompare(keyword,"color") == 0)
3403 (void) CopyMagickString(msl_info->image_info[n]->filename,
3404 "xc:",MagickPathExtent);
3405 (void) ConcatenateMagickString(msl_info->image_info[n]->
3406 filename,value,MagickPathExtent);
3407 next_image=ReadImage(msl_info->image_info[n],exception);
3408 CatchException(exception);
3409 if (next_image == (Image *) NULL)
3411 if (msl_info->image[n] == (Image *) NULL)
3412 msl_info->image[n]=next_image;
3419 Link image into image list.
3421 p=msl_info->image[n];
3422 while (p->next != (Image *) NULL)
3423 p=GetNextImageInList(p);
3424 next_image->previous=p;
3429 (void) SetMSLAttributes(msl_info,keyword,value);
3434 (void) SetMSLAttributes(msl_info,keyword,value);
3441 if (LocaleCompare((const char *) tag,"implode") == 0)
3449 if (msl_info->image[n] == (Image *) NULL)
3451 ThrowMSLException(OptionError,"NoImagesDefined",
3452 (const char *) tag);
3455 if (attributes != (const xmlChar **) NULL)
3456 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3458 keyword=(const char *) attributes[i++];
3459 attribute=InterpretImageProperties(msl_info->image_info[n],
3460 msl_info->attributes[n],(const char *) attributes[i],
3462 CloneString(&value,attribute);
3463 attribute=DestroyString(attribute);
3469 if (LocaleCompare(keyword,"amount") == 0)
3471 geometry_info.rho=StringToDouble(value,
3475 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3482 if (LocaleCompare(keyword,"geometry") == 0)
3484 flags=ParseGeometry(value,&geometry_info);
3485 if ((flags & SigmaValue) == 0)
3486 geometry_info.sigma=1.0;
3489 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3495 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3501 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3502 msl_info->image[n]->interpolate,msl_info->exception);
3503 if (implode_image == (Image *) NULL)
3505 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3506 msl_info->image[n]=implode_image;
3509 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3514 if (LocaleCompare((const char *) tag,"label") == 0)
3516 if (LocaleCompare((const char *) tag, "level") == 0)
3519 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3521 if (msl_info->image[n] == (Image *) NULL)
3523 ThrowMSLException(OptionError,"NoImagesDefined",
3524 (const char *) tag);
3527 if (attributes == (const xmlChar **) NULL)
3529 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3531 keyword=(const char *) attributes[i++];
3532 CloneString(&value,(const char *) attributes[i]);
3533 (void) CopyMagickString(key,value,MagickPathExtent);
3539 if (LocaleCompare(keyword,"black") == 0)
3541 levelBlack = StringToDouble(value,(char **) NULL);
3544 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3550 if (LocaleCompare(keyword,"gamma") == 0)
3552 levelGamma = StringToDouble(value,(char **) NULL);
3555 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3561 if (LocaleCompare(keyword,"white") == 0)
3563 levelWhite = StringToDouble(value,(char **) NULL);
3566 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3571 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3578 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3579 msl_info->exception);
3586 if (LocaleCompare((const char *) tag,"magnify") == 0)
3594 if (msl_info->image[n] == (Image *) NULL)
3596 ThrowMSLException(OptionError,"NoImagesDefined",
3597 (const char *) tag);
3600 if (attributes != (const xmlChar **) NULL)
3601 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3603 keyword=(const char *) attributes[i++];
3604 attribute=InterpretImageProperties(msl_info->image_info[n],
3605 msl_info->attributes[n],(const char *) attributes[i],
3607 CloneString(&value,attribute);
3608 attribute=DestroyString(attribute);
3609 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3611 magnify_image=MagnifyImage(msl_info->image[n],
3612 msl_info->exception);
3613 if (magnify_image == (Image *) NULL)
3615 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3616 msl_info->image[n]=magnify_image;
3619 if (LocaleCompare((const char *) tag,"map") == 0)
3633 if (msl_info->image[n] == (Image *) NULL)
3635 ThrowMSLException(OptionError,"NoImagesDefined",
3636 (const char *) tag);
3639 affinity_image=NewImageList();
3641 if (attributes != (const xmlChar **) NULL)
3642 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3644 keyword=(const char *) attributes[i++];
3645 attribute=InterpretImageProperties(msl_info->image_info[n],
3646 msl_info->attributes[n],(const char *) attributes[i],
3648 CloneString(&value,attribute);
3649 attribute=DestroyString(attribute);
3655 if (LocaleCompare(keyword,"dither") == 0)
3657 option=ParseCommandOption(MagickBooleanOptions,
3660 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3662 dither=(MagickBooleanType) option;
3665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3672 if (LocaleCompare(keyword,"image") == 0)
3673 for (j=0; j < msl_info->n; j++)
3678 attribute=GetImageProperty(msl_info->attributes[j],"id",
3680 if ((attribute != (const char *) NULL) &&
3681 (LocaleCompare(attribute,value) == 0))
3683 affinity_image=CloneImage(msl_info->image[j],0,0,
3684 MagickFalse,exception);
3692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3698 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3699 quantize_info->dither_method=dither != MagickFalse ?
3700 RiemersmaDitherMethod : NoDitherMethod;
3701 (void) RemapImages(quantize_info,msl_info->image[n],
3702 affinity_image,exception);
3703 quantize_info=DestroyQuantizeInfo(quantize_info);
3704 affinity_image=DestroyImage(affinity_image);
3707 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3719 Matte floodfill image.
3722 if (msl_info->image[n] == (Image *) NULL)
3724 ThrowMSLException(OptionError,"NoImagesDefined",
3725 (const char *) tag);
3728 SetGeometry(msl_info->image[n],&geometry);
3729 paint_method=FloodfillMethod;
3730 if (attributes != (const xmlChar **) NULL)
3731 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3733 keyword=(const char *) attributes[i++];
3734 attribute=InterpretImageProperties(msl_info->image_info[n],
3735 msl_info->attributes[n],(const char *) attributes[i],
3737 CloneString(&value,attribute);
3738 attribute=DestroyString(attribute);
3744 if (LocaleCompare(keyword,"bordercolor") == 0)
3746 (void) QueryColorCompliance(value,AllCompliance,
3748 paint_method=FillToBorderMethod;
3751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3758 if (LocaleCompare(keyword,"fuzz") == 0)
3760 msl_info->image[n]->fuzz=StringToDouble(value,
3764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3771 if (LocaleCompare(keyword,"geometry") == 0)
3773 flags=ParsePageGeometry(msl_info->image[n],value,
3774 &geometry,exception);
3775 if ((flags & HeightValue) == 0)
3776 geometry.height=geometry.width;
3777 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3778 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3789 if (LocaleCompare(keyword,"opacity") == 0)
3791 opacity=StringToDouble(value,(char **) NULL);
3794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3801 if (LocaleCompare(keyword,"x") == 0)
3803 geometry.x=StringToLong(value);
3804 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3805 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3816 if (LocaleCompare(keyword,"y") == 0)
3818 geometry.y=StringToLong(value);
3819 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3820 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3824 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3830 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3836 draw_info=CloneDrawInfo(msl_info->image_info[n],
3837 msl_info->draw_info[n]);
3838 draw_info->fill.alpha=ClampToQuantum(opacity);
3839 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3840 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3841 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3842 MagickFalse : MagickTrue,msl_info->exception);
3843 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3844 draw_info=DestroyDrawInfo(draw_info);
3847 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3853 Median-filter image.
3855 if (msl_info->image[n] == (Image *) NULL)
3857 ThrowMSLException(OptionError,"NoImagesDefined",
3858 (const char *) tag);
3861 if (attributes != (const xmlChar **) NULL)
3862 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3864 keyword=(const char *) attributes[i++];
3865 attribute=InterpretImageProperties(msl_info->image_info[n],
3866 msl_info->attributes[n],(const char *) attributes[i],
3868 CloneString(&value,attribute);
3869 attribute=DestroyString(attribute);
3875 if (LocaleCompare(keyword,"geometry") == 0)
3877 flags=ParseGeometry(value,&geometry_info);
3878 if ((flags & SigmaValue) == 0)
3879 geometry_info.sigma=1.0;
3882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3889 if (LocaleCompare(keyword,"radius") == 0)
3891 geometry_info.rho=StringToDouble(value,
3895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3907 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3908 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3909 msl_info->exception);
3910 if (median_image == (Image *) NULL)
3912 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3913 msl_info->image[n]=median_image;
3916 if (LocaleCompare((const char *) tag,"minify") == 0)
3924 if (msl_info->image[n] == (Image *) NULL)
3926 ThrowMSLException(OptionError,"NoImagesDefined",
3927 (const char *) tag);
3930 if (attributes != (const xmlChar **) NULL)
3931 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3933 keyword=(const char *) attributes[i++];
3934 attribute=InterpretImageProperties(msl_info->image_info[n],
3935 msl_info->attributes[n],(const char *) attributes[i],
3937 CloneString(&value,attribute);
3938 attribute=DestroyString(attribute);
3939 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3941 minify_image=MinifyImage(msl_info->image[n],
3942 msl_info->exception);
3943 if (minify_image == (Image *) NULL)
3945 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3946 msl_info->image[n]=minify_image;
3949 if (LocaleCompare((const char *) tag,"msl") == 0 )
3951 if (LocaleCompare((const char *) tag,"modulate") == 0)
3954 modulate[MagickPathExtent];
3959 if (msl_info->image[n] == (Image *) NULL)
3961 ThrowMSLException(OptionError,"NoImagesDefined",
3962 (const char *) tag);
3965 geometry_info.rho=100.0;
3966 geometry_info.sigma=100.0;
3967 geometry_info.xi=100.0;
3968 if (attributes != (const xmlChar **) NULL)
3969 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3971 keyword=(const char *) attributes[i++];
3972 attribute=InterpretImageProperties(msl_info->image_info[n],
3973 msl_info->attributes[n],(const char *) attributes[i],
3975 CloneString(&value,attribute);
3976 attribute=DestroyString(attribute);
3982 if (LocaleCompare(keyword,"blackness") == 0)
3984 geometry_info.rho=StringToDouble(value,
3988 if (LocaleCompare(keyword,"brightness") == 0)
3990 geometry_info.rho=StringToDouble(value,
3994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4001 if (LocaleCompare(keyword,"factor") == 0)
4003 flags=ParseGeometry(value,&geometry_info);
4006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4013 if (LocaleCompare(keyword,"hue") == 0)
4015 geometry_info.xi=StringToDouble(value,
4019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4026 if (LocaleCompare(keyword,"lightness") == 0)
4028 geometry_info.rho=StringToDouble(value,
4032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4039 if (LocaleCompare(keyword,"saturation") == 0)
4041 geometry_info.sigma=StringToDouble(value,
4045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4052 if (LocaleCompare(keyword,"whiteness") == 0)
4054 geometry_info.sigma=StringToDouble(value,
4058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4070 (void) FormatLocaleString(modulate,MagickPathExtent,"%g,%g,%g",
4071 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4072 (void) ModulateImage(msl_info->image[n],modulate,
4073 msl_info->exception);
4076 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4081 if (LocaleCompare((const char *) tag,"negate") == 0)
4089 if (msl_info->image[n] == (Image *) NULL)
4091 ThrowMSLException(OptionError,"NoImagesDefined",
4092 (const char *) tag);
4096 if (attributes != (const xmlChar **) NULL)
4097 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4099 keyword=(const char *) attributes[i++];
4100 attribute=InterpretImageProperties(msl_info->image_info[n],
4101 msl_info->attributes[n],(const char *) attributes[i],
4103 CloneString(&value,attribute);
4104 attribute=DestroyString(attribute);
4110 if (LocaleCompare(keyword,"channel") == 0)
4112 option=ParseChannelOption(value);
4114 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4116 channel=(ChannelType) option;
4119 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4126 if (LocaleCompare(keyword,"gray") == 0)
4128 option=ParseCommandOption(MagickBooleanOptions,
4131 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4133 gray=(MagickBooleanType) option;
4136 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4142 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4148 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4149 (void) NegateImage(msl_info->image[n],gray,
4150 msl_info->exception);
4151 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4154 if (LocaleCompare((const char *) tag,"normalize") == 0)
4159 if (msl_info->image[n] == (Image *) NULL)
4161 ThrowMSLException(OptionError,"NoImagesDefined",
4162 (const char *) tag);
4165 if (attributes != (const xmlChar **) NULL)
4166 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4168 keyword=(const char *) attributes[i++];
4169 attribute=InterpretImageProperties(msl_info->image_info[n],
4170 msl_info->attributes[n],(const char *) attributes[i],
4172 CloneString(&value,attribute);
4173 attribute=DestroyString(attribute);
4179 if (LocaleCompare(keyword,"channel") == 0)
4181 option=ParseChannelOption(value);
4183 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4185 channel=(ChannelType) option;
4188 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4200 (void) NormalizeImage(msl_info->image[n],
4201 msl_info->exception);
4204 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4209 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4217 if (msl_info->image[n] == (Image *) NULL)
4219 ThrowMSLException(OptionError,"NoImagesDefined",
4220 (const char *) tag);
4223 if (attributes != (const xmlChar **) NULL)
4224 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4226 keyword=(const char *) attributes[i++];
4227 attribute=InterpretImageProperties(msl_info->image_info[n],
4228 msl_info->attributes[n],(const char *) attributes[i],
4230 CloneString(&value,attribute);
4231 attribute=DestroyString(attribute);
4237 if (LocaleCompare(keyword,"geometry") == 0)
4239 flags=ParseGeometry(value,&geometry_info);
4240 if ((flags & SigmaValue) == 0)
4241 geometry_info.sigma=1.0;
4244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4251 if (LocaleCompare(keyword,"radius") == 0)
4253 geometry_info.rho=StringToDouble(value,
4257 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4263 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4269 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4270 geometry_info.sigma,msl_info->exception);
4271 if (paint_image == (Image *) NULL)
4273 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4274 msl_info->image[n]=paint_image;
4277 if (LocaleCompare((const char *) tag,"opaque") == 0)
4286 if (msl_info->image[n] == (Image *) NULL)
4288 ThrowMSLException(OptionError,"NoImagesDefined",
4289 (const char *) tag);
4292 (void) QueryColorCompliance("none",AllCompliance,&target,
4294 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4296 if (attributes != (const xmlChar **) NULL)
4297 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4299 keyword=(const char *) attributes[i++];
4300 attribute=InterpretImageProperties(msl_info->image_info[n],
4301 msl_info->attributes[n],(const char *) attributes[i],
4303 CloneString(&value,attribute);
4304 attribute=DestroyString(attribute);
4310 if (LocaleCompare(keyword,"channel") == 0)
4312 option=ParseChannelOption(value);
4314 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4316 channel=(ChannelType) option;
4319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4326 if (LocaleCompare(keyword,"fill") == 0)
4328 (void) QueryColorCompliance(value,AllCompliance,
4329 &fill_color,exception);
4332 if (LocaleCompare(keyword,"fuzz") == 0)
4334 msl_info->image[n]->fuzz=StringToDouble(value,
4338 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4344 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4350 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4351 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4352 MagickFalse,msl_info->exception);
4353 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4356 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4361 if (LocaleCompare((const char *) tag,"print") == 0)
4363 if (attributes == (const xmlChar **) NULL)
4365 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4367 keyword=(const char *) attributes[i++];
4368 attribute=InterpretImageProperties(msl_info->image_info[n],
4369 msl_info->attributes[n],(const char *) attributes[i],
4371 CloneString(&value,attribute);
4372 attribute=DestroyString(attribute);
4378 if (LocaleCompare(keyword,"output") == 0)
4380 (void) FormatLocaleFile(stdout,"%s",value);
4383 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4395 if (LocaleCompare((const char *) tag, "profile") == 0)
4397 if (msl_info->image[n] == (Image *) NULL)
4399 ThrowMSLException(OptionError,"NoImagesDefined",
4400 (const char *) tag);
4403 if (attributes == (const xmlChar **) NULL)
4405 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4419 keyword=(const char *) attributes[i++];
4420 attribute=InterpretImageProperties(msl_info->image_info[n],
4421 msl_info->attributes[n],(const char *) attributes[i],
4423 CloneString(&value,attribute);
4424 attribute=DestroyString(attribute);
4425 if (*keyword == '!')
4428 Remove a profile from the image.
4430 (void) ProfileImage(msl_info->image[n],keyword,
4431 (const unsigned char *) NULL,0,exception);
4435 Associate a profile with the image.
4437 profile_info=CloneImageInfo(msl_info->image_info[n]);
4438 profile=GetImageProfile(msl_info->image[n],"iptc");
4439 if (profile != (StringInfo *) NULL)
4440 profile_info->profile=(void *) CloneStringInfo(profile);
4441 profile_image=GetImageCache(profile_info,keyword,exception);
4442 profile_info=DestroyImageInfo(profile_info);
4443 if (profile_image == (Image *) NULL)
4446 name[MagickPathExtent],
4447 filename[MagickPathExtent];
4455 (void) CopyMagickString(filename,keyword,MagickPathExtent);
4456 (void) CopyMagickString(name,keyword,MagickPathExtent);
4457 for (p=filename; *p != '\0'; p++)
4458 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4459 (IsPathAccessible(keyword) == MagickFalse))
4465 Look for profile name (e.g. name:profile).
4467 (void) CopyMagickString(name,filename,(size_t)
4469 for (q=filename; *q != '\0'; q++)
4473 profile=FileToStringInfo(filename,~0UL,exception);
4474 if (profile != (StringInfo *) NULL)
4476 (void) ProfileImage(msl_info->image[n],name,
4477 GetStringInfoDatum(profile),(size_t)
4478 GetStringInfoLength(profile),exception);
4479 profile=DestroyStringInfo(profile);
4483 ResetImageProfileIterator(profile_image);
4484 name=GetNextImageProfile(profile_image);
4485 while (name != (const char *) NULL)
4487 profile=GetImageProfile(profile_image,name);
4488 if (profile != (StringInfo *) NULL)
4489 (void) ProfileImage(msl_info->image[n],name,
4490 GetStringInfoDatum(profile),(size_t)
4491 GetStringInfoLength(profile),exception);
4492 name=GetNextImageProfile(profile_image);
4494 profile_image=DestroyImage(profile_image);
4498 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4503 if (LocaleCompare((const char *) tag,"quantize") == 0)
4511 if (msl_info->image[n] == (Image *) NULL)
4513 ThrowMSLException(OptionError,"NoImagesDefined",
4514 (const char *) tag);
4517 GetQuantizeInfo(&quantize_info);
4518 if (attributes != (const xmlChar **) NULL)
4519 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4521 keyword=(const char *) attributes[i++];
4522 attribute=InterpretImageProperties(msl_info->image_info[n],
4523 msl_info->attributes[n],(const char *) attributes[i],
4525 CloneString(&value,attribute);
4526 attribute=DestroyString(attribute);
4532 if (LocaleCompare(keyword,"colors") == 0)
4534 quantize_info.number_colors=StringToLong(value);
4537 if (LocaleCompare(keyword,"colorspace") == 0)
4539 option=ParseCommandOption(MagickColorspaceOptions,
4542 ThrowMSLException(OptionError,
4543 "UnrecognizedColorspaceType",value);
4544 quantize_info.colorspace=(ColorspaceType) option;
4547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4554 if (LocaleCompare(keyword,"dither") == 0)
4556 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4559 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4561 quantize_info.dither_method=(DitherMethod) option;
4564 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4571 if (LocaleCompare(keyword,"measure") == 0)
4573 option=ParseCommandOption(MagickBooleanOptions,
4576 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4578 quantize_info.measure_error=(MagickBooleanType) option;
4581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4588 if (LocaleCompare(keyword,"treedepth") == 0)
4590 quantize_info.tree_depth=StringToLong(value);
4593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4599 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4605 (void) QuantizeImage(&quantize_info,msl_info->image[n],exception);
4608 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4611 text[MagickPathExtent];
4622 draw_info=CloneDrawInfo(msl_info->image_info[n],
4623 msl_info->draw_info[n]);
4625 current=draw_info->affine;
4626 GetAffineMatrix(&affine);
4627 if (attributes != (const xmlChar **) NULL)
4628 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4630 keyword=(const char *) attributes[i++];
4631 attribute=InterpretImageProperties(msl_info->image_info[n],
4632 msl_info->attributes[n],(const char *) attributes[i],
4634 CloneString(&value,attribute);
4635 attribute=DestroyString(attribute);
4641 if (LocaleCompare(keyword,"affine") == 0)
4647 draw_info->affine.sx=StringToDouble(p,&p);
4650 draw_info->affine.rx=StringToDouble(p,&p);
4653 draw_info->affine.ry=StringToDouble(p,&p);
4656 draw_info->affine.sy=StringToDouble(p,&p);
4659 draw_info->affine.tx=StringToDouble(p,&p);
4662 draw_info->affine.ty=StringToDouble(p,&p);
4665 if (LocaleCompare(keyword,"align") == 0)
4667 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4670 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4672 draw_info->align=(AlignType) option;
4675 if (LocaleCompare(keyword,"antialias") == 0)
4677 option=ParseCommandOption(MagickBooleanOptions,
4680 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4682 draw_info->stroke_antialias=(MagickBooleanType) option;
4683 draw_info->text_antialias=(MagickBooleanType) option;
4686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4693 if (LocaleCompare(keyword,"density") == 0)
4695 CloneString(&draw_info->density,value);
4698 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4705 if (LocaleCompare(keyword,"encoding") == 0)
4707 CloneString(&draw_info->encoding,value);
4710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4717 if (LocaleCompare(keyword, "fill") == 0)
4719 (void) QueryColorCompliance(value,AllCompliance,
4720 &draw_info->fill,exception);
4723 if (LocaleCompare(keyword,"family") == 0)
4725 CloneString(&draw_info->family,value);
4728 if (LocaleCompare(keyword,"font") == 0)
4730 CloneString(&draw_info->font,value);
4733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4740 if (LocaleCompare(keyword,"geometry") == 0)
4742 flags=ParsePageGeometry(msl_info->image[n],value,
4743 &geometry,exception);
4744 if ((flags & HeightValue) == 0)
4745 geometry.height=geometry.width;
4748 if (LocaleCompare(keyword,"gravity") == 0)
4750 option=ParseCommandOption(MagickGravityOptions,
4753 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4755 draw_info->gravity=(GravityType) option;
4758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4765 if (LocaleCompare(keyword,"pointsize") == 0)
4767 draw_info->pointsize=StringToDouble(value,
4771 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4778 if (LocaleCompare(keyword,"rotate") == 0)
4780 angle=StringToDouble(value,(char **) NULL);
4781 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4782 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4783 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4784 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4794 if (LocaleCompare(keyword,"scale") == 0)
4796 flags=ParseGeometry(value,&geometry_info);
4797 if ((flags & SigmaValue) == 0)
4798 geometry_info.sigma=1.0;
4799 affine.sx=geometry_info.rho;
4800 affine.sy=geometry_info.sigma;
4803 if (LocaleCompare(keyword,"skewX") == 0)
4805 angle=StringToDouble(value,(char **) NULL);
4806 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4809 if (LocaleCompare(keyword,"skewY") == 0)
4811 angle=StringToDouble(value,(char **) NULL);
4812 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4815 if (LocaleCompare(keyword,"stretch") == 0)
4817 option=ParseCommandOption(MagickStretchOptions,
4820 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4822 draw_info->stretch=(StretchType) option;
4825 if (LocaleCompare(keyword, "stroke") == 0)
4827 (void) QueryColorCompliance(value,AllCompliance,
4828 &draw_info->stroke,exception);
4831 if (LocaleCompare(keyword,"strokewidth") == 0)
4833 draw_info->stroke_width=StringToLong(value);
4836 if (LocaleCompare(keyword,"style") == 0)
4838 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4841 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4843 draw_info->style=(StyleType) option;
4846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4853 if (LocaleCompare(keyword,"text") == 0)
4855 CloneString(&draw_info->text,value);
4858 if (LocaleCompare(keyword,"translate") == 0)
4860 flags=ParseGeometry(value,&geometry_info);
4861 if ((flags & SigmaValue) == 0)
4862 geometry_info.sigma=1.0;
4863 affine.tx=geometry_info.rho;
4864 affine.ty=geometry_info.sigma;
4867 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4874 if (LocaleCompare(keyword, "undercolor") == 0)
4876 (void) QueryColorCompliance(value,AllCompliance,
4877 &draw_info->undercolor,exception);
4880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4887 if (LocaleCompare(keyword,"weight") == 0)
4889 draw_info->weight=StringToLong(value);
4892 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4899 if (LocaleCompare(keyword,"x") == 0)
4901 geometry.x=StringToLong(value);
4904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4911 if (LocaleCompare(keyword,"y") == 0)
4913 geometry.y=StringToLong(value);
4916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4928 (void) FormatLocaleString(text,MagickPathExtent,
4929 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4930 geometry.height,(double) geometry.x,(double) geometry.y);
4931 CloneString(&draw_info->geometry,text);
4932 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4933 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4934 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4935 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4936 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4938 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4940 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4941 msl_info->exception);
4942 if (status != MagickFalse)
4947 image=msl_info->attributes[n];
4948 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4949 "%g",metrics.pixels_per_em.x);
4950 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4951 "%g",metrics.pixels_per_em.y);
4952 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4954 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4956 FormatImageProperty(image,"msl:font-metrics.width","%g",
4958 FormatImageProperty(image,"msl:font-metrics.height","%g",
4960 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4961 metrics.max_advance);
4962 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4964 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4966 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4968 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4970 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4972 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4975 draw_info=DestroyDrawInfo(draw_info);
4978 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4983 if (LocaleCompare((const char *) tag,"raise") == 0)
4991 if (msl_info->image[n] == (Image *) NULL)
4993 ThrowMSLException(OptionError,"NoImagesDefined",
4994 (const char *) tag);
4998 SetGeometry(msl_info->image[n],&geometry);
4999 if (attributes != (const xmlChar **) NULL)
5000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5002 keyword=(const char *) attributes[i++];
5003 attribute=InterpretImageProperties(msl_info->image_info[n],
5004 msl_info->attributes[n],(const char *) attributes[i],
5006 CloneString(&value,attribute);
5007 attribute=DestroyString(attribute);
5013 if (LocaleCompare(keyword,"geometry") == 0)
5015 flags=ParsePageGeometry(msl_info->image[n],value,
5016 &geometry,exception);
5017 if ((flags & HeightValue) == 0)
5018 geometry.height=geometry.width;
5021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5028 if (LocaleCompare(keyword,"height") == 0)
5030 geometry.height=StringToLong(value);
5033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5040 if (LocaleCompare(keyword,"raise") == 0)
5042 option=ParseCommandOption(MagickBooleanOptions,
5045 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5047 raise=(MagickBooleanType) option;
5050 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5057 if (LocaleCompare(keyword,"width") == 0)
5059 geometry.width=StringToLong(value);
5062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5068 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5074 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5075 msl_info->exception);
5078 if (LocaleCompare((const char *) tag,"read") == 0)
5080 if (attributes == (const xmlChar **) NULL)
5082 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5084 keyword=(const char *) attributes[i++];
5085 attribute=InterpretImageProperties(msl_info->image_info[n],
5086 msl_info->attributes[n],(const char *) attributes[i],exception);
5087 CloneString(&value,attribute);
5088 attribute=DestroyString(attribute);
5094 if (LocaleCompare(keyword,"filename") == 0)
5099 if (value == (char *) NULL)
5101 (void) CopyMagickString(msl_info->image_info[n]->filename,
5102 value,MagickPathExtent);
5103 image=ReadImage(msl_info->image_info[n],exception);
5104 CatchException(exception);
5105 if (image == (Image *) NULL)
5107 AppendImageToList(&msl_info->image[n],image);
5110 (void) SetMSLAttributes(msl_info,keyword,value);
5115 (void) SetMSLAttributes(msl_info,keyword,value);
5122 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5130 if (msl_info->image[n] == (Image *) NULL)
5132 ThrowMSLException(OptionError,"NoImagesDefined",
5133 (const char *) tag);
5136 if (attributes != (const xmlChar **) NULL)
5137 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5139 keyword=(const char *) attributes[i++];
5140 attribute=InterpretImageProperties(msl_info->image_info[n],
5141 msl_info->attributes[n],(const char *) attributes[i],
5143 CloneString(&value,attribute);
5144 attribute=DestroyString(attribute);
5150 if (LocaleCompare(keyword,"geometry") == 0)
5152 flags=ParseGeometry(value,&geometry_info);
5153 if ((flags & SigmaValue) == 0)
5154 geometry_info.sigma=1.0;
5157 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5164 if (LocaleCompare(keyword,"radius") == 0)
5166 geometry_info.rho=StringToDouble(value,
5170 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5176 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5182 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5183 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5184 msl_info->exception);
5185 if (paint_image == (Image *) NULL)
5187 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5188 msl_info->image[n]=paint_image;
5191 else if (LocaleCompare((const char *) tag,"repage") == 0)
5193 /* init the values */
5194 width=msl_info->image[n]->page.width;
5195 height=msl_info->image[n]->page.height;
5196 x=msl_info->image[n]->page.x;
5197 y=msl_info->image[n]->page.y;
5199 if (msl_info->image[n] == (Image *) NULL)
5201 ThrowMSLException(OptionError,"NoImagesDefined",
5202 (const char *) tag);
5205 if (attributes == (const xmlChar **) NULL)
5207 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5209 keyword=(const char *) attributes[i++];
5210 attribute=InterpretImageProperties(msl_info->image_info[n],
5211 msl_info->attributes[n],(const char *) attributes[i],exception);
5212 CloneString(&value,attribute);
5213 attribute=DestroyString(attribute);
5219 if (LocaleCompare(keyword,"geometry") == 0)
5227 flags=ParseAbsoluteGeometry(value,&geometry);
5228 if ((flags & WidthValue) != 0)
5230 if ((flags & HeightValue) == 0)
5231 geometry.height=geometry.width;
5232 width=geometry.width;
5233 height=geometry.height;
5235 if ((flags & AspectValue) != 0)
5237 if ((flags & XValue) != 0)
5239 if ((flags & YValue) != 0)
5244 if ((flags & XValue) != 0)
5247 if ((width == 0) && (geometry.x > 0))
5248 width=msl_info->image[n]->columns+geometry.x;
5250 if ((flags & YValue) != 0)
5253 if ((height == 0) && (geometry.y > 0))
5254 height=msl_info->image[n]->rows+geometry.y;
5259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5265 if (LocaleCompare(keyword,"height") == 0)
5267 height = StringToLong( value );
5270 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5276 if (LocaleCompare(keyword,"width") == 0)
5278 width = StringToLong( value );
5281 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5287 if (LocaleCompare(keyword,"x") == 0)
5289 x = StringToLong( value );
5292 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5298 if (LocaleCompare(keyword,"y") == 0)
5300 y = StringToLong( value );
5303 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5308 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5314 msl_info->image[n]->page.width=width;
5315 msl_info->image[n]->page.height=height;
5316 msl_info->image[n]->page.x=x;
5317 msl_info->image[n]->page.y=y;
5320 else if (LocaleCompare((const char *) tag,"resample") == 0)
5326 if (msl_info->image[n] == (Image *) NULL)
5328 ThrowMSLException(OptionError,"NoImagesDefined",
5329 (const char *) tag);
5332 if (attributes == (const xmlChar **) NULL)
5334 x_resolution=DefaultResolution;
5335 y_resolution=DefaultResolution;
5336 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5338 keyword=(const char *) attributes[i++];
5339 attribute=InterpretImageProperties(msl_info->image_info[n],
5340 msl_info->attributes[n],(const char *) attributes[i],exception);
5341 CloneString(&value,attribute);
5342 attribute=DestroyString(attribute);
5348 if (LocaleCompare(keyword,"geometry") == 0)
5353 flags=ParseGeometry(value,&geometry_info);
5354 if ((flags & SigmaValue) == 0)
5355 geometry_info.sigma*=geometry_info.rho;
5356 x_resolution=geometry_info.rho;
5357 y_resolution=geometry_info.sigma;
5360 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5366 if (LocaleCompare(keyword,"x-resolution") == 0)
5368 x_resolution=StringToDouble(value,(char **) NULL);
5371 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5377 if (LocaleCompare(keyword,"y-resolution") == 0)
5379 y_resolution=StringToDouble(value,(char **) NULL);
5382 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5387 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5403 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5405 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5406 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5407 msl_info->image[n]->resolution.x))+0.5);
5408 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5409 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5410 msl_info->image[n]->resolution.y))+0.5);
5411 resample_image=ResizeImage(msl_info->image[n],width,height,
5412 msl_info->image[n]->filter,msl_info->exception);
5413 if (resample_image == (Image *) NULL)
5415 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5416 msl_info->image[n]=resample_image;
5420 if (LocaleCompare((const char *) tag,"resize") == 0)
5431 if (msl_info->image[n] == (Image *) NULL)
5433 ThrowMSLException(OptionError,"NoImagesDefined",
5434 (const char *) tag);
5437 filter=UndefinedFilter;
5438 if (attributes != (const xmlChar **) NULL)
5439 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5441 keyword=(const char *) attributes[i++];
5442 attribute=InterpretImageProperties(msl_info->image_info[n],
5443 msl_info->attributes[n],(const char *) attributes[i],
5445 CloneString(&value,attribute);
5446 attribute=DestroyString(attribute);
5452 if (LocaleCompare(keyword,"filter") == 0)
5454 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5457 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5459 filter=(FilterType) option;
5462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5469 if (LocaleCompare(keyword,"geometry") == 0)
5471 flags=ParseRegionGeometry(msl_info->image[n],value,
5472 &geometry,exception);
5475 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5482 if (LocaleCompare(keyword,"height") == 0)
5484 geometry.height=StringToUnsignedLong(value);
5487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5494 if (LocaleCompare(keyword,"width") == 0)
5496 geometry.width=StringToLong(value);
5499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5511 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5512 geometry.height,filter,msl_info->exception);
5513 if (resize_image == (Image *) NULL)
5515 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5516 msl_info->image[n]=resize_image;
5519 if (LocaleCompare((const char *) tag,"roll") == 0)
5527 if (msl_info->image[n] == (Image *) NULL)
5529 ThrowMSLException(OptionError,"NoImagesDefined",
5530 (const char *) tag);
5533 SetGeometry(msl_info->image[n],&geometry);
5534 if (attributes != (const xmlChar **) NULL)
5535 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5537 keyword=(const char *) attributes[i++];
5538 attribute=InterpretImageProperties(msl_info->image_info[n],
5539 msl_info->attributes[n],(const char *) attributes[i],
5541 CloneString(&value,attribute);
5542 attribute=DestroyString(attribute);
5548 if (LocaleCompare(keyword,"geometry") == 0)
5550 flags=ParsePageGeometry(msl_info->image[n],value,
5551 &geometry,exception);
5552 if ((flags & HeightValue) == 0)
5553 geometry.height=geometry.width;
5556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5563 if (LocaleCompare(keyword,"x") == 0)
5565 geometry.x=StringToLong(value);
5568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5575 if (LocaleCompare(keyword,"y") == 0)
5577 geometry.y=StringToLong(value);
5580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5592 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5593 msl_info->exception);
5594 if (roll_image == (Image *) NULL)
5596 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5597 msl_info->image[n]=roll_image;
5600 else if (LocaleCompare((const char *) tag,"roll") == 0)
5602 /* init the values */
5603 width=msl_info->image[n]->columns;
5604 height=msl_info->image[n]->rows;
5607 if (msl_info->image[n] == (Image *) NULL)
5609 ThrowMSLException(OptionError,"NoImagesDefined",
5610 (const char *) tag);
5613 if (attributes == (const xmlChar **) NULL)
5615 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5617 keyword=(const char *) attributes[i++];
5618 attribute=InterpretImageProperties(msl_info->image_info[n],
5619 msl_info->attributes[n],(const char *) attributes[i],exception);
5620 CloneString(&value,attribute);
5621 attribute=DestroyString(attribute);
5627 if (LocaleCompare(keyword,"geometry") == 0)
5629 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5632 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5638 if (LocaleCompare(keyword,"x") == 0)
5640 x = StringToLong( value );
5643 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5649 if (LocaleCompare(keyword,"y") == 0)
5651 y = StringToLong( value );
5654 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5659 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5672 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5673 if (newImage == (Image *) NULL)
5675 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5676 msl_info->image[n]=newImage;
5681 if (LocaleCompare((const char *) tag,"rotate") == 0)
5689 if (msl_info->image[n] == (Image *) NULL)
5691 ThrowMSLException(OptionError,"NoImagesDefined",
5692 (const char *) tag);
5695 if (attributes != (const xmlChar **) NULL)
5696 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5698 keyword=(const char *) attributes[i++];
5699 attribute=InterpretImageProperties(msl_info->image_info[n],
5700 msl_info->attributes[n],(const char *) attributes[i],
5702 CloneString(&value,attribute);
5703 attribute=DestroyString(attribute);
5709 if (LocaleCompare(keyword,"degrees") == 0)
5711 geometry_info.rho=StringToDouble(value,
5715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5722 if (LocaleCompare(keyword,"geometry") == 0)
5724 flags=ParseGeometry(value,&geometry_info);
5725 if ((flags & SigmaValue) == 0)
5726 geometry_info.sigma=1.0;
5729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5741 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5742 msl_info->exception);
5743 if (rotate_image == (Image *) NULL)
5745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5746 msl_info->image[n]=rotate_image;
5749 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5751 /* init the values */
5754 if (msl_info->image[n] == (Image *) NULL)
5756 ThrowMSLException(OptionError,"NoImagesDefined",
5757 (const char *) tag);
5760 if (attributes == (const xmlChar **) NULL)
5762 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5764 keyword=(const char *) attributes[i++];
5765 attribute=InterpretImageProperties(msl_info->image_info[n],
5766 msl_info->attributes[n],(const char *) attributes[i],exception);
5767 CloneString(&value,attribute);
5768 attribute=DestroyString(attribute);
5774 if (LocaleCompare(keyword,"degrees") == 0)
5776 degrees = StringToDouble(value,(char **) NULL);
5779 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5784 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5797 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5798 if (newImage == (Image *) NULL)
5800 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5801 msl_info->image[n]=newImage;
5806 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5811 if (LocaleCompare((const char *) tag,"sample") == 0)
5819 if (msl_info->image[n] == (Image *) NULL)
5821 ThrowMSLException(OptionError,"NoImagesDefined",
5822 (const char *) tag);
5825 if (attributes != (const xmlChar **) NULL)
5826 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5828 keyword=(const char *) attributes[i++];
5829 attribute=InterpretImageProperties(msl_info->image_info[n],
5830 msl_info->attributes[n],(const char *) attributes[i],
5832 CloneString(&value,attribute);
5833 attribute=DestroyString(attribute);
5839 if (LocaleCompare(keyword,"geometry") == 0)
5841 flags=ParseRegionGeometry(msl_info->image[n],value,
5842 &geometry,exception);
5845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5852 if (LocaleCompare(keyword,"height") == 0)
5854 geometry.height=StringToUnsignedLong(value);
5857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5864 if (LocaleCompare(keyword,"width") == 0)
5866 geometry.width=StringToLong(value);
5869 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5881 sample_image=SampleImage(msl_info->image[n],geometry.width,
5882 geometry.height,msl_info->exception);
5883 if (sample_image == (Image *) NULL)
5885 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5886 msl_info->image[n]=sample_image;
5889 if (LocaleCompare((const char *) tag,"scale") == 0)
5897 if (msl_info->image[n] == (Image *) NULL)
5899 ThrowMSLException(OptionError,"NoImagesDefined",
5900 (const char *) tag);
5903 if (attributes != (const xmlChar **) NULL)
5904 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5906 keyword=(const char *) attributes[i++];
5907 attribute=InterpretImageProperties(msl_info->image_info[n],
5908 msl_info->attributes[n],(const char *) attributes[i],
5910 CloneString(&value,attribute);
5911 attribute=DestroyString(attribute);
5917 if (LocaleCompare(keyword,"geometry") == 0)
5919 flags=ParseRegionGeometry(msl_info->image[n],value,
5920 &geometry,exception);
5923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5930 if (LocaleCompare(keyword,"height") == 0)
5932 geometry.height=StringToUnsignedLong(value);
5935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5942 if (LocaleCompare(keyword,"width") == 0)
5944 geometry.width=StringToLong(value);
5947 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5959 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5960 geometry.height,msl_info->exception);
5961 if (scale_image == (Image *) NULL)
5963 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5964 msl_info->image[n]=scale_image;
5967 if (LocaleCompare((const char *) tag,"segment") == 0)
5978 if (msl_info->image[n] == (Image *) NULL)
5980 ThrowMSLException(OptionError,"NoImagesDefined",
5981 (const char *) tag);
5984 geometry_info.rho=1.0;
5985 geometry_info.sigma=1.5;
5986 colorspace=sRGBColorspace;
5987 verbose=MagickFalse;
5988 if (attributes != (const xmlChar **) NULL)
5989 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5991 keyword=(const char *) attributes[i++];
5992 attribute=InterpretImageProperties(msl_info->image_info[n],
5993 msl_info->attributes[n],(const char *) attributes[i],
5995 CloneString(&value,attribute);
5996 attribute=DestroyString(attribute);
6002 if (LocaleCompare(keyword,"cluster-threshold") == 0)
6004 geometry_info.rho=StringToDouble(value,
6008 if (LocaleCompare(keyword,"colorspace") == 0)
6010 option=ParseCommandOption(MagickColorspaceOptions,
6013 ThrowMSLException(OptionError,
6014 "UnrecognizedColorspaceType",value);
6015 colorspace=(ColorspaceType) option;
6018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6025 if (LocaleCompare(keyword,"geometry") == 0)
6027 flags=ParseGeometry(value,&geometry_info);
6028 if ((flags & SigmaValue) == 0)
6029 geometry_info.sigma=1.5;
6032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6039 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
6041 geometry_info.sigma=StringToDouble(value,
6045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6051 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6057 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
6058 geometry_info.rho,geometry_info.sigma,exception);
6061 else if (LocaleCompare((const char *) tag, "set") == 0)
6063 if (msl_info->image[n] == (Image *) NULL)
6065 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6069 if (attributes == (const xmlChar **) NULL)
6071 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6073 keyword=(const char *) attributes[i++];
6074 attribute=InterpretImageProperties(msl_info->image_info[n],
6075 msl_info->attributes[n],(const char *) attributes[i],exception);
6076 CloneString(&value,attribute);
6077 attribute=DestroyString(attribute);
6083 if (LocaleCompare(keyword,"clip-mask") == 0)
6085 for (j=0; j < msl_info->n; j++)
6090 property=GetImageProperty(msl_info->attributes[j],"id",
6092 if (LocaleCompare(property,value) == 0)
6094 SetImageMask(msl_info->image[n],ReadPixelMask,
6095 msl_info->image[j],exception);
6101 if (LocaleCompare(keyword,"clip-path") == 0)
6103 for (j=0; j < msl_info->n; j++)
6108 property=GetImageProperty(msl_info->attributes[j],"id",
6110 if (LocaleCompare(property,value) == 0)
6112 SetImageMask(msl_info->image[n],ReadPixelMask,
6113 msl_info->image[j],exception);
6119 if (LocaleCompare(keyword,"colorspace") == 0)
6124 colorspace=(ColorspaceType) ParseCommandOption(
6125 MagickColorspaceOptions,MagickFalse,value);
6127 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6129 (void) TransformImageColorspace(msl_info->image[n],
6130 (ColorspaceType) colorspace,exception);
6133 (void) SetMSLAttributes(msl_info,keyword,value);
6134 (void) SetImageProperty(msl_info->image[n],keyword,value,
6141 if (LocaleCompare(keyword,"density") == 0)
6143 flags=ParseGeometry(value,&geometry_info);
6144 msl_info->image[n]->resolution.x=geometry_info.rho;
6145 msl_info->image[n]->resolution.y=geometry_info.sigma;
6146 if ((flags & SigmaValue) == 0)
6147 msl_info->image[n]->resolution.y=
6148 msl_info->image[n]->resolution.x;
6151 (void) SetMSLAttributes(msl_info,keyword,value);
6152 (void) SetImageProperty(msl_info->image[n],keyword,value,
6159 if (LocaleCompare(keyword, "opacity") == 0)
6161 ssize_t opac = OpaqueAlpha,
6162 len = (ssize_t) strlen( value );
6164 if (value[len-1] == '%') {
6166 (void) CopyMagickString(tmp,value,len);
6167 opac = StringToLong( tmp );
6168 opac = (int)(QuantumRange * ((float)opac/100));
6170 opac = StringToLong( value );
6171 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6175 (void) SetMSLAttributes(msl_info,keyword,value);
6176 (void) SetImageProperty(msl_info->image[n],keyword,value,
6177 msl_info->exception);
6183 if (LocaleCompare(keyword, "page") == 0)
6186 page[MagickPathExtent];
6197 (void) memset(&geometry,0,sizeof(geometry));
6198 image_option=GetImageArtifact(msl_info->image[n],"page");
6199 if (image_option != (const char *) NULL)
6200 flags=ParseAbsoluteGeometry(image_option,&geometry);
6201 flags=ParseAbsoluteGeometry(value,&geometry);
6202 (void) FormatLocaleString(page,MagickPathExtent,"%.20gx%.20g",
6203 (double) geometry.width,(double) geometry.height);
6204 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6205 (void) FormatLocaleString(page,MagickPathExtent,
6206 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6207 (double) geometry.height,(double) geometry.x,(double)
6209 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6210 msl_info->image_info[n]->page=GetPageGeometry(page);
6213 (void) SetMSLAttributes(msl_info,keyword,value);
6214 (void) SetImageProperty(msl_info->image[n],keyword,value,
6215 msl_info->exception);
6220 (void) SetMSLAttributes(msl_info,keyword,value);
6221 (void) SetImageProperty(msl_info->image[n],keyword,value,
6222 msl_info->exception);
6229 if (LocaleCompare((const char *) tag,"shade") == 0)
6240 if (msl_info->image[n] == (Image *) NULL)
6242 ThrowMSLException(OptionError,"NoImagesDefined",
6243 (const char *) tag);
6247 if (attributes != (const xmlChar **) NULL)
6248 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6250 keyword=(const char *) attributes[i++];
6251 attribute=InterpretImageProperties(msl_info->image_info[n],
6252 msl_info->attributes[n],(const char *) attributes[i],
6254 CloneString(&value,attribute);
6255 attribute=DestroyString(attribute);
6261 if (LocaleCompare(keyword,"azimuth") == 0)
6263 geometry_info.rho=StringToDouble(value,
6267 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6274 if (LocaleCompare(keyword,"elevation") == 0)
6276 geometry_info.sigma=StringToDouble(value,
6280 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6287 if (LocaleCompare(keyword,"geometry") == 0)
6289 flags=ParseGeometry(value,&geometry_info);
6290 if ((flags & SigmaValue) == 0)
6291 geometry_info.sigma=1.0;
6294 if (LocaleCompare(keyword,"gray") == 0)
6296 option=ParseCommandOption(MagickBooleanOptions,
6299 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6301 gray=(MagickBooleanType) option;
6304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6310 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6316 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6317 geometry_info.sigma,msl_info->exception);
6318 if (shade_image == (Image *) NULL)
6320 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6321 msl_info->image[n]=shade_image;
6324 if (LocaleCompare((const char *) tag,"shadow") == 0)
6332 if (msl_info->image[n] == (Image *) NULL)
6334 ThrowMSLException(OptionError,"NoImagesDefined",
6335 (const char *) tag);
6338 if (attributes != (const xmlChar **) NULL)
6339 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6341 keyword=(const char *) attributes[i++];
6342 attribute=InterpretImageProperties(msl_info->image_info[n],
6343 msl_info->attributes[n],(const char *) attributes[i],
6345 CloneString(&value,attribute);
6346 attribute=DestroyString(attribute);
6352 if (LocaleCompare(keyword,"geometry") == 0)
6354 flags=ParseGeometry(value,&geometry_info);
6355 if ((flags & SigmaValue) == 0)
6356 geometry_info.sigma=1.0;
6359 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6366 if (LocaleCompare(keyword,"opacity") == 0)
6368 geometry_info.rho=StringToLong(value);
6371 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6378 if (LocaleCompare(keyword,"sigma") == 0)
6380 geometry_info.sigma=StringToLong(value);
6388 if (LocaleCompare(keyword,"x") == 0)
6390 geometry_info.xi=StringToDouble(value,
6394 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6401 if (LocaleCompare(keyword,"y") == 0)
6403 geometry_info.psi=StringToLong(value);
6406 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6412 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6418 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6419 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6420 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6421 if (shadow_image == (Image *) NULL)
6423 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6424 msl_info->image[n]=shadow_image;
6427 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6433 if (msl_info->image[n] == (Image *) NULL)
6435 ThrowMSLException(OptionError,"NoImagesDefined",
6436 (const char *) tag);
6440 NOTE: sharpen can have no attributes, since we use all the defaults!
6442 if (attributes != (const xmlChar **) NULL)
6444 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6446 keyword=(const char *) attributes[i++];
6447 attribute=InterpretImageProperties(msl_info->image_info[n],
6448 msl_info->attributes[n],(const char *) attributes[i],exception);
6449 CloneString(&value,attribute);
6450 attribute=DestroyString(attribute);
6456 if (LocaleCompare(keyword, "radius") == 0)
6458 radius = StringToDouble(value,(char **) NULL);
6461 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6467 if (LocaleCompare(keyword,"sigma") == 0)
6469 sigma = StringToLong( value );
6472 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6477 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6491 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6492 msl_info->exception);
6493 if (newImage == (Image *) NULL)
6495 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6496 msl_info->image[n]=newImage;
6500 else if (LocaleCompare((const char *) tag,"shave") == 0)
6502 /* init the values */
6506 if (msl_info->image[n] == (Image *) NULL)
6508 ThrowMSLException(OptionError,"NoImagesDefined",
6509 (const char *) tag);
6512 if (attributes == (const xmlChar **) NULL)
6514 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6516 keyword=(const char *) attributes[i++];
6517 attribute=InterpretImageProperties(msl_info->image_info[n],
6518 msl_info->attributes[n],(const char *) attributes[i],exception);
6519 CloneString(&value,attribute);
6520 attribute=DestroyString(attribute);
6526 if (LocaleCompare(keyword,"geometry") == 0)
6528 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6531 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6537 if (LocaleCompare(keyword,"height") == 0)
6539 height = StringToLong( value );
6542 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6548 if (LocaleCompare(keyword,"width") == 0)
6550 width = StringToLong( value );
6553 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6558 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6573 rectInfo.height = height;
6574 rectInfo.width = width;
6579 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6580 msl_info->exception);
6581 if (newImage == (Image *) NULL)
6583 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6584 msl_info->image[n]=newImage;
6589 if (LocaleCompare((const char *) tag,"shear") == 0)
6597 if (msl_info->image[n] == (Image *) NULL)
6599 ThrowMSLException(OptionError,"NoImagesDefined",
6600 (const char *) tag);
6603 if (attributes != (const xmlChar **) NULL)
6604 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6606 keyword=(const char *) attributes[i++];
6607 attribute=InterpretImageProperties(msl_info->image_info[n],
6608 msl_info->attributes[n],(const char *) attributes[i],
6610 CloneString(&value,attribute);
6611 attribute=DestroyString(attribute);
6617 if (LocaleCompare(keyword, "fill") == 0)
6619 (void) QueryColorCompliance(value,AllCompliance,
6620 &msl_info->image[n]->background_color,exception);
6623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6630 if (LocaleCompare(keyword,"geometry") == 0)
6632 flags=ParseGeometry(value,&geometry_info);
6633 if ((flags & SigmaValue) == 0)
6634 geometry_info.sigma=1.0;
6637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6644 if (LocaleCompare(keyword,"x") == 0)
6646 geometry_info.rho=StringToDouble(value,
6650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6657 if (LocaleCompare(keyword,"y") == 0)
6659 geometry_info.sigma=StringToLong(value);
6662 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6674 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6675 geometry_info.sigma,msl_info->exception);
6676 if (shear_image == (Image *) NULL)
6678 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6679 msl_info->image[n]=shear_image;
6682 if (LocaleCompare((const char *) tag,"signature") == 0)
6687 if (msl_info->image[n] == (Image *) NULL)
6689 ThrowMSLException(OptionError,"NoImagesDefined",
6690 (const char *) tag);
6693 if (attributes != (const xmlChar **) NULL)
6694 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6696 keyword=(const char *) attributes[i++];
6697 attribute=InterpretImageProperties(msl_info->image_info[n],
6698 msl_info->attributes[n],(const char *) attributes[i],
6700 CloneString(&value,attribute);
6701 attribute=DestroyString(attribute);
6706 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6712 (void) SignatureImage(msl_info->image[n],exception);
6715 if (LocaleCompare((const char *) tag,"solarize") == 0)
6720 if (msl_info->image[n] == (Image *) NULL)
6722 ThrowMSLException(OptionError,"NoImagesDefined",
6723 (const char *) tag);
6726 geometry_info.rho=QuantumRange/2.0;
6727 if (attributes != (const xmlChar **) NULL)
6728 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6730 keyword=(const char *) attributes[i++];
6731 attribute=InterpretImageProperties(msl_info->image_info[n],
6732 msl_info->attributes[n],(const char *) attributes[i],
6734 CloneString(&value,attribute);
6735 attribute=DestroyString(attribute);
6741 if (LocaleCompare(keyword,"geometry") == 0)
6743 flags=ParseGeometry(value,&geometry_info);
6746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6753 if (LocaleCompare(keyword,"threshold") == 0)
6755 geometry_info.rho=StringToDouble(value,
6759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6771 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6772 msl_info->exception);
6775 if (LocaleCompare((const char *) tag,"spread") == 0)
6783 if (msl_info->image[n] == (Image *) NULL)
6785 ThrowMSLException(OptionError,"NoImagesDefined",
6786 (const char *) tag);
6789 if (attributes != (const xmlChar **) NULL)
6790 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6792 keyword=(const char *) attributes[i++];
6793 attribute=InterpretImageProperties(msl_info->image_info[n],
6794 msl_info->attributes[n],(const char *) attributes[i],
6796 CloneString(&value,attribute);
6797 attribute=DestroyString(attribute);
6803 if (LocaleCompare(keyword,"geometry") == 0)
6805 flags=ParseGeometry(value,&geometry_info);
6806 if ((flags & SigmaValue) == 0)
6807 geometry_info.sigma=1.0;
6810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6817 if (LocaleCompare(keyword,"radius") == 0)
6819 geometry_info.rho=StringToDouble(value,
6823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6829 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6835 spread_image=SpreadImage(msl_info->image[n],
6836 msl_info->image[n]->interpolate,geometry_info.rho,
6837 msl_info->exception);
6838 if (spread_image == (Image *) NULL)
6840 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6841 msl_info->image[n]=spread_image;
6844 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6847 watermark = (Image*) NULL;
6849 if (msl_info->image[n] == (Image *) NULL)
6851 ThrowMSLException(OptionError,"NoImagesDefined",
6852 (const char *) tag);
6855 if (attributes == (const xmlChar **) NULL)
6857 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6859 keyword=(const char *) attributes[i++];
6860 attribute=InterpretImageProperties(msl_info->image_info[n],
6861 msl_info->attributes[n],(const char *) attributes[i],exception);
6862 CloneString(&value,attribute);
6863 attribute=DestroyString(attribute);
6869 if (LocaleCompare(keyword,"image") == 0)
6871 for (j=0; j<msl_info->n;j++)
6874 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6876 if (theAttr && LocaleCompare(theAttr, value) == 0)
6878 watermark = msl_info->image[j];
6884 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6889 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6898 if ( watermark != (Image*) NULL )
6903 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6904 if (newImage == (Image *) NULL)
6906 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6907 msl_info->image[n]=newImage;
6910 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6912 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6915 stereoImage = (Image*) NULL;
6917 if (msl_info->image[n] == (Image *) NULL)
6919 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6922 if (attributes == (const xmlChar **) NULL)
6924 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6926 keyword=(const char *) attributes[i++];
6927 attribute=InterpretImageProperties(msl_info->image_info[n],
6928 msl_info->attributes[n],(const char *) attributes[i],exception);
6929 CloneString(&value,attribute);
6930 attribute=DestroyString(attribute);
6936 if (LocaleCompare(keyword,"image") == 0)
6938 for (j=0; j<msl_info->n;j++)
6941 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6943 if (theAttr && LocaleCompare(theAttr, value) == 0)
6945 stereoImage = msl_info->image[j];
6951 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6956 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6965 if ( stereoImage != (Image*) NULL )
6970 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6971 if (newImage == (Image *) NULL)
6973 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6974 msl_info->image[n]=newImage;
6977 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6979 if (LocaleCompare((const char *) tag,"strip") == 0)
6984 if (msl_info->image[n] == (Image *) NULL)
6986 ThrowMSLException(OptionError,"NoImagesDefined",
6987 (const char *) tag);
6990 if (attributes != (const xmlChar **) NULL)
6991 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6993 keyword=(const char *) attributes[i++];
6994 attribute=InterpretImageProperties(msl_info->image_info[n],
6995 msl_info->attributes[n],(const char *) attributes[i],
6997 CloneString(&value,attribute);
6998 attribute=DestroyString(attribute);
6999 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7001 (void) StripImage(msl_info->image[n],msl_info->exception);
7004 if (LocaleCompare((const char *) tag,"swap") == 0)
7015 if (msl_info->image[n] == (Image *) NULL)
7017 ThrowMSLException(OptionError,"NoImagesDefined",
7018 (const char *) tag);
7023 if (attributes != (const xmlChar **) NULL)
7024 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7026 keyword=(const char *) attributes[i++];
7027 attribute=InterpretImageProperties(msl_info->image_info[n],
7028 msl_info->attributes[n],(const char *) attributes[i],
7030 CloneString(&value,attribute);
7031 attribute=DestroyString(attribute);
7037 if (LocaleCompare(keyword,"indexes") == 0)
7039 flags=ParseGeometry(value,&geometry_info);
7040 index=(ssize_t) geometry_info.rho;
7041 if ((flags & SigmaValue) == 0)
7042 swap_index=(ssize_t) geometry_info.sigma;
7045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7051 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7060 p=GetImageFromList(msl_info->image[n],index);
7061 q=GetImageFromList(msl_info->image[n],swap_index);
7062 if ((p == (Image *) NULL) || (q == (Image *) NULL))
7064 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
7067 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
7068 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
7069 msl_info->exception));
7070 ReplaceImageInList(&q,swap);
7071 msl_info->image[n]=GetFirstImageInList(q);
7074 if (LocaleCompare((const char *) tag,"swirl") == 0)
7082 if (msl_info->image[n] == (Image *) NULL)
7084 ThrowMSLException(OptionError,"NoImagesDefined",
7085 (const char *) tag);
7088 if (attributes != (const xmlChar **) NULL)
7089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7091 keyword=(const char *) attributes[i++];
7092 attribute=InterpretImageProperties(msl_info->image_info[n],
7093 msl_info->attributes[n],(const char *) attributes[i],
7095 CloneString(&value,attribute);
7096 attribute=DestroyString(attribute);
7102 if (LocaleCompare(keyword,"degrees") == 0)
7104 geometry_info.rho=StringToDouble(value,
7108 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7115 if (LocaleCompare(keyword,"geometry") == 0)
7117 flags=ParseGeometry(value,&geometry_info);
7118 if ((flags & SigmaValue) == 0)
7119 geometry_info.sigma=1.0;
7122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7134 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7135 msl_info->image[n]->interpolate,msl_info->exception);
7136 if (swirl_image == (Image *) NULL)
7138 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7139 msl_info->image[n]=swirl_image;
7142 if (LocaleCompare((const char *) tag,"sync") == 0)
7147 if (msl_info->image[n] == (Image *) NULL)
7149 ThrowMSLException(OptionError,"NoImagesDefined",
7150 (const char *) tag);
7153 if (attributes != (const xmlChar **) NULL)
7154 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7156 keyword=(const char *) attributes[i++];
7157 attribute=InterpretImageProperties(msl_info->image_info[n],
7158 msl_info->attributes[n],(const char *) attributes[i],
7160 CloneString(&value,attribute);
7161 attribute=DestroyString(attribute);
7166 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7172 (void) SyncImage(msl_info->image[n],exception);
7175 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7180 if (LocaleCompare((const char *) tag,"map") == 0)
7188 if (msl_info->image[n] == (Image *) NULL)
7190 ThrowMSLException(OptionError,"NoImagesDefined",
7191 (const char *) tag);
7194 texture_image=NewImageList();
7195 if (attributes != (const xmlChar **) NULL)
7196 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7198 keyword=(const char *) attributes[i++];
7199 attribute=InterpretImageProperties(msl_info->image_info[n],
7200 msl_info->attributes[n],(const char *) attributes[i],
7202 CloneString(&value,attribute);
7203 attribute=DestroyString(attribute);
7209 if (LocaleCompare(keyword,"image") == 0)
7210 for (j=0; j < msl_info->n; j++)
7215 attribute=GetImageProperty(msl_info->attributes[j],"id",
7217 if ((attribute != (const char *) NULL) &&
7218 (LocaleCompare(attribute,value) == 0))
7220 texture_image=CloneImage(msl_info->image[j],0,0,
7221 MagickFalse,exception);
7229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7235 (void) TextureImage(msl_info->image[n],texture_image,exception);
7236 texture_image=DestroyImage(texture_image);
7239 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7241 /* init the values */
7242 double threshold = 0;
7244 if (msl_info->image[n] == (Image *) NULL)
7246 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7249 if (attributes == (const xmlChar **) NULL)
7251 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7253 keyword=(const char *) attributes[i++];
7254 attribute=InterpretImageProperties(msl_info->image_info[n],
7255 msl_info->attributes[n],(const char *) attributes[i],exception);
7256 CloneString(&value,attribute);
7257 attribute=DestroyString(attribute);
7263 if (LocaleCompare(keyword,"threshold") == 0)
7265 threshold = StringToDouble(value,(char **) NULL);
7268 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7273 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7283 BilevelImage(msl_info->image[n],threshold,exception);
7287 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7289 if (msl_info->image[n] == (Image *) NULL)
7291 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7294 if (attributes == (const xmlChar **) NULL)
7296 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7298 keyword=(const char *) attributes[i++];
7299 attribute=InterpretImageProperties(msl_info->image_info[n],
7300 msl_info->attributes[n],(const char *) attributes[i],exception);
7301 CloneString(&value,attribute);
7302 attribute=DestroyString(attribute);
7308 if (LocaleCompare(keyword,"color") == 0)
7313 (void) QueryColorCompliance(value,AllCompliance,&target,
7315 (void) TransparentPaintImage(msl_info->image[n],&target,
7316 TransparentAlpha,MagickFalse,msl_info->exception);
7319 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7331 else if (LocaleCompare((const char *) tag, "trim") == 0)
7333 if (msl_info->image[n] == (Image *) NULL)
7335 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7339 /* no attributes here */
7341 /* process the image */
7348 /* all zeros on a crop == trim edges! */
7349 rectInfo.height = rectInfo.width = 0;
7350 rectInfo.x = rectInfo.y = 0;
7352 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7353 if (newImage == (Image *) NULL)
7355 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7356 msl_info->image[n]=newImage;
7360 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7365 if (LocaleCompare((const char *) tag,"write") == 0)
7367 if (msl_info->image[n] == (Image *) NULL)
7369 ThrowMSLException(OptionError,"NoImagesDefined",
7370 (const char *) tag);
7373 if (attributes == (const xmlChar **) NULL)
7375 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7377 keyword=(const char *) attributes[i++];
7378 attribute=InterpretImageProperties(msl_info->image_info[n],
7379 msl_info->attributes[n],(const char *) attributes[i],exception);
7380 CloneString(&value,attribute);
7381 attribute=DestroyString(attribute);
7387 if (LocaleCompare(keyword,"filename") == 0)
7389 (void) CopyMagickString(msl_info->image[n]->filename,value,
7393 (void) SetMSLAttributes(msl_info,keyword,value);
7397 (void) SetMSLAttributes(msl_info,keyword,value);
7405 *msl_info->image_info[n]->magick='\0';
7406 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7407 msl_info->exception);
7411 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7415 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7419 if (value != (char *) NULL)
7420 value=DestroyString(value);
7421 (void) DestroyExceptionInfo(exception);
7422 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7425 static void MSLEndElement(void *context,const xmlChar *tag)
7434 Called when the end of an element has been detected.
7436 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7438 msl_info=(MSLInfo *) context;
7445 if (LocaleCompare((const char *) tag,"comment") == 0 )
7447 (void) DeleteImageProperty(msl_info->image[n],"comment");
7448 if (msl_info->content == (char *) NULL)
7450 StripString(msl_info->content);
7451 (void) SetImageProperty(msl_info->image[n],"comment",
7452 msl_info->content,msl_info->exception);
7460 if (LocaleCompare((const char *) tag, "group") == 0 )
7462 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7464 ssize_t i = (ssize_t)
7465 (msl_info->group_info[msl_info->number_groups-1].numImages);
7468 if (msl_info->image[msl_info->n] != (Image *) NULL)
7469 msl_info->image[msl_info->n]=DestroyImage(
7470 msl_info->image[msl_info->n]);
7471 msl_info->attributes[msl_info->n]=DestroyImage(
7472 msl_info->attributes[msl_info->n]);
7473 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7474 msl_info->image_info[msl_info->n]);
7478 msl_info->number_groups--;
7485 if (LocaleCompare((const char *) tag, "image") == 0)
7486 MSLPopImage(msl_info);
7492 if (LocaleCompare((const char *) tag,"label") == 0 )
7494 (void) DeleteImageProperty(msl_info->image[n],"label");
7495 if (msl_info->content == (char *) NULL)
7497 StripString(msl_info->content);
7498 (void) SetImageProperty(msl_info->image[n],"label",
7499 msl_info->content,msl_info->exception);
7507 if (LocaleCompare((const char *) tag, "msl") == 0 )
7510 This our base element.
7511 at the moment we don't do anything special
7512 but someday we might!
7520 if (msl_info->content != (char *) NULL)
7521 msl_info->content=DestroyString(msl_info->content);
7524 static void MSLCharacters(void *context,const xmlChar *c,int length)
7536 Receiving some characters from the parser.
7538 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7539 " SAX.characters(%s,%d)",c,length);
7540 msl_info=(MSLInfo *) context;
7541 if (msl_info->content != (char *) NULL)
7542 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7543 strlen(msl_info->content)+length+MagickPathExtent,
7544 sizeof(*msl_info->content));
7547 msl_info->content=(char *) NULL;
7548 if (~(size_t) length >= (MagickPathExtent-1))
7549 msl_info->content=(char *) AcquireQuantumMemory(length+MagickPathExtent,
7550 sizeof(*msl_info->content));
7551 if (msl_info->content != (char *) NULL)
7552 *msl_info->content='\0';
7554 if (msl_info->content == (char *) NULL)
7556 p=msl_info->content+strlen(msl_info->content);
7557 for (i=0; i < length; i++)
7562 static void MSLReference(void *context,const xmlChar *name)
7571 Called when an entity reference is detected.
7573 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7574 " SAX.reference(%s)",name);
7575 msl_info=(MSLInfo *) context;
7576 parser=msl_info->parser;
7578 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7580 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7583 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7589 Receiving some ignorable whitespaces from the parser.
7591 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7592 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7593 msl_info=(MSLInfo *) context;
7597 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7598 const xmlChar *data)
7604 A processing instruction has been parsed.
7606 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7607 " SAX.processingInstruction(%s, %s)",
7609 msl_info=(MSLInfo *) context;
7613 static void MSLComment(void *context,const xmlChar *value)
7619 A comment has been parsed.
7621 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7622 " SAX.comment(%s)",value);
7623 msl_info=(MSLInfo *) context;
7627 static void MSLWarning(void *context,const char *format,...)
7631 reason[MagickPathExtent];
7640 Display and format a warning messages, gives file, line, position and
7643 va_start(operands,format);
7644 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7645 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7646 msl_info=(MSLInfo *) context;
7648 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7649 (void) vsprintf(reason,format,operands);
7651 (void) vsnprintf(reason,MagickPathExtent,format,operands);
7653 message=GetExceptionMessage(errno);
7654 ThrowMSLException(CoderError,reason,message);
7655 message=DestroyString(message);
7659 static void MSLError(void *context,const char *format,...)
7662 reason[MagickPathExtent];
7671 Display and format a error formats, gives file, line, position and
7674 va_start(operands,format);
7675 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7676 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7677 msl_info=(MSLInfo *) context;
7679 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7680 (void) vsprintf(reason,format,operands);
7682 (void) vsnprintf(reason,MagickPathExtent,format,operands);
7684 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7688 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7700 Called when a pcdata block has been parsed.
7702 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7703 " SAX.pcdata(%s, %d)",value,length);
7704 msl_info=(MSLInfo *) context;
7706 parser=msl_info->parser;
7707 child=xmlGetLastChild(parser->node);
7708 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7710 xmlTextConcat(child,value,length);
7713 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7716 static void MSLExternalSubset(void *context,const xmlChar *name,
7717 const xmlChar *external_id,const xmlChar *system_id)
7732 Does this document has an external subset?
7734 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7735 " SAX.externalSubset(%s %s %s)",name,
7736 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7737 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7738 msl_info=(MSLInfo *) context;
7740 parser=msl_info->parser;
7741 if (((external_id == NULL) && (system_id == NULL)) ||
7742 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7743 (msl_info->document == 0)))
7745 input=MSLResolveEntity(context,external_id,system_id);
7748 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7749 parser_context=(*parser);
7750 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7751 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7753 parser->errNo=XML_ERR_NO_MEMORY;
7754 parser->input=parser_context.input;
7755 parser->inputNr=parser_context.inputNr;
7756 parser->inputMax=parser_context.inputMax;
7757 parser->inputTab=parser_context.inputTab;
7763 xmlPushInput(parser,input);
7764 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7765 if (input->filename == (char *) NULL)
7766 input->filename=(char *) xmlStrdup(system_id);
7769 input->base=parser->input->cur;
7770 input->cur=parser->input->cur;
7772 xmlParseExternalSubset(parser,external_id,system_id);
7773 while (parser->inputNr > 1)
7774 (void) xmlPopInput(parser);
7775 xmlFreeInputStream(parser->input);
7776 xmlFree(parser->inputTab);
7777 parser->input=parser_context.input;
7778 parser->inputNr=parser_context.inputNr;
7779 parser->inputMax=parser_context.inputMax;
7780 parser->inputTab=parser_context.inputTab;
7783 #if defined(__cplusplus) || defined(c_plusplus)
7787 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7788 Image **image,ExceptionInfo *exception)
7791 message[MagickPathExtent];
7814 assert(image_info != (const ImageInfo *) NULL);
7815 assert(image_info->signature == MagickCoreSignature);
7816 if (image_info->debug != MagickFalse)
7817 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7818 image_info->filename);
7819 assert(image != (Image **) NULL);
7820 msl_image=AcquireImage(image_info,exception);
7821 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7822 if (status == MagickFalse)
7824 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7825 msl_image->filename);
7826 msl_image=DestroyImageList(msl_image);
7827 return(MagickFalse);
7829 msl_image->columns=1;
7834 (void) memset(&msl_info,0,sizeof(msl_info));
7835 msl_info.exception=exception;
7836 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7837 sizeof(*msl_info.image_info));
7838 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7839 sizeof(*msl_info.draw_info));
7840 /* top of the stack is the MSL file itself */
7841 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7842 msl_info.attributes=(Image **) AcquireMagickMemory(
7843 sizeof(*msl_info.attributes));
7844 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7845 sizeof(*msl_info.group_info));
7846 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7847 (msl_info.draw_info == (DrawInfo **) NULL) ||
7848 (msl_info.image == (Image **) NULL) ||
7849 (msl_info.attributes == (Image **) NULL) ||
7850 (msl_info.group_info == (MSLGroupInfo *) NULL))
7851 ThrowFatalException(ResourceLimitFatalError,"UnableToInterpretMSLImage");
7852 *msl_info.image_info=CloneImageInfo(image_info);
7853 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7854 *msl_info.attributes=AcquireImage(image_info,exception);
7855 msl_info.group_info[0].numImages=0;
7856 /* the first slot is used to point to the MSL file image */
7857 *msl_info.image=msl_image;
7858 if (*image != (Image *) NULL)
7859 MSLPushImage(&msl_info,*image);
7860 (void) xmlSubstituteEntitiesDefault(1);
7861 (void) memset(&sax_modules,0,sizeof(sax_modules));
7862 sax_modules.internalSubset=MSLInternalSubset;
7863 sax_modules.isStandalone=MSLIsStandalone;
7864 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7865 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7866 sax_modules.resolveEntity=MSLResolveEntity;
7867 sax_modules.getEntity=MSLGetEntity;
7868 sax_modules.entityDecl=MSLEntityDeclaration;
7869 sax_modules.notationDecl=MSLNotationDeclaration;
7870 sax_modules.attributeDecl=MSLAttributeDeclaration;
7871 sax_modules.elementDecl=MSLElementDeclaration;
7872 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7873 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7874 sax_modules.startDocument=MSLStartDocument;
7875 sax_modules.endDocument=MSLEndDocument;
7876 sax_modules.startElement=MSLStartElement;
7877 sax_modules.endElement=MSLEndElement;
7878 sax_modules.reference=MSLReference;
7879 sax_modules.characters=MSLCharacters;
7880 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7881 sax_modules.processingInstruction=MSLProcessingInstructions;
7882 sax_modules.comment=MSLComment;
7883 sax_modules.warning=MSLWarning;
7884 sax_modules.error=MSLError;
7885 sax_modules.fatalError=MSLError;
7886 sax_modules.getParameterEntity=MSLGetParameterEntity;
7887 sax_modules.cdataBlock=MSLCDataBlock;
7888 sax_modules.externalSubset=MSLExternalSubset;
7889 sax_handler=(&sax_modules);
7890 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7891 msl_image->filename);
7892 while (ReadBlobString(msl_image,message) != (char *) NULL)
7894 n=(ssize_t) strlen(message);
7897 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7900 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7901 if (msl_info.exception->severity >= ErrorException)
7904 if (msl_info.exception->severity == UndefinedException)
7905 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7909 xmlFreeParserCtxt(msl_info.parser);
7910 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7911 if (*image == (Image *) NULL)
7912 *image=CloneImage(*msl_info.image,0,0,MagickTrue,exception);
7913 while (msl_info.n >= 0)
7915 msl_info.image[msl_info.n]=DestroyImage(msl_info.image[msl_info.n]);
7916 msl_info.attributes[msl_info.n]=DestroyImage(
7917 msl_info.attributes[msl_info.n]);
7918 msl_info.draw_info[msl_info.n]=DestroyDrawInfo(
7919 msl_info.draw_info[msl_info.n]);
7920 msl_info.image_info[msl_info.n]=DestroyImageInfo(
7921 msl_info.image_info[msl_info.n]);
7924 msl_info.draw_info=(DrawInfo **) RelinquishMagickMemory(msl_info.draw_info);
7925 msl_info.image=(Image **) RelinquishMagickMemory(msl_info.image);
7926 msl_info.attributes=(Image **) RelinquishMagickMemory(msl_info.attributes);
7927 msl_info.image_info=(ImageInfo **) RelinquishMagickMemory(
7928 msl_info.image_info);
7929 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7930 msl_info.group_info);
7931 if (msl_info.exception->severity != UndefinedException)
7932 return(MagickFalse);
7936 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7944 assert(image_info != (const ImageInfo *) NULL);
7945 assert(image_info->signature == MagickCoreSignature);
7946 if (image_info->debug != MagickFalse)
7947 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7948 image_info->filename);
7949 assert(exception != (ExceptionInfo *) NULL);
7950 assert(exception->signature == MagickCoreSignature);
7951 image=(Image *) NULL;
7952 (void) ProcessMSLScript(image_info,&image,exception);
7953 return(GetFirstImageInList(image));
7958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7962 % R e g i s t e r M S L I m a g e %
7966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7968 % RegisterMSLImage() adds attributes for the MSL image format to
7969 % the list of supported formats. The attributes include the image format
7970 % tag, a method to read and/or write the format, whether the format
7971 % supports the saving of more than one frame to the same file or blob,
7972 % whether the format supports native in-memory I/O, and a brief
7973 % description of the format.
7975 % The format of the RegisterMSLImage method is:
7977 % size_t RegisterMSLImage(void)
7980 ModuleExport size_t RegisterMSLImage(void)
7985 #if defined(MAGICKCORE_XML_DELEGATE)
7988 entry=AcquireMagickInfo("MSL","MSL","Magick Scripting Language");
7989 #if defined(MAGICKCORE_XML_DELEGATE)
7990 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7991 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7993 entry->format_type=ImplicitFormatType;
7994 (void) RegisterMagickInfo(entry);
7995 return(MagickImageCoderSignature);
7998 #if defined(MAGICKCORE_XML_DELEGATE)
8000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8004 % S e t M S L A t t r i b u t e s %
8008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8010 % SetMSLAttributes() ...
8012 % The format of the SetMSLAttributes method is:
8014 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
8015 % const char *keyword,const char *value)
8017 % A description of each parameter follows:
8019 % o msl_info: the MSL info.
8021 % o keyword: the keyword.
8023 % o value: the value.
8026 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
8053 assert(msl_info != (MSLInfo *) NULL);
8054 if (keyword == (const char *) NULL)
8056 if (value == (const char *) NULL)
8058 exception=msl_info->exception;
8060 attributes=msl_info->attributes[n];
8061 image_info=msl_info->image_info[n];
8062 draw_info=msl_info->draw_info[n];
8063 image=msl_info->image[n];
8069 if (LocaleCompare(keyword,"adjoin") == 0)
8074 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
8076 ThrowMSLException(OptionError,"UnrecognizedType",value);
8077 image_info->adjoin=(MagickBooleanType) adjoin;
8080 if (LocaleCompare(keyword,"alpha") == 0)
8085 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
8087 ThrowMSLException(OptionError,"UnrecognizedType",value);
8088 if (image != (Image *) NULL)
8089 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
8093 if (LocaleCompare(keyword,"antialias") == 0)
8098 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
8100 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8101 image_info->antialias=(MagickBooleanType) antialias;
8104 if (LocaleCompare(keyword,"area-limit") == 0)
8109 limit=MagickResourceInfinity;
8110 if (LocaleCompare(value,"unlimited") != 0)
8111 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
8112 (void) SetMagickResourceLimit(AreaResource,limit);
8115 if (LocaleCompare(keyword,"attenuate") == 0)
8117 (void) SetImageOption(image_info,keyword,value);
8120 if (LocaleCompare(keyword,"authenticate") == 0)
8122 (void) CloneString(&image_info->density,value);
8125 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8131 if (LocaleCompare(keyword,"background") == 0)
8133 (void) QueryColorCompliance(value,AllCompliance,
8134 &image_info->background_color,exception);
8137 if (LocaleCompare(keyword,"blue-primary") == 0)
8139 if (image == (Image *) NULL)
8141 flags=ParseGeometry(value,&geometry_info);
8142 image->chromaticity.blue_primary.x=geometry_info.rho;
8143 image->chromaticity.blue_primary.y=geometry_info.sigma;
8144 if ((flags & SigmaValue) == 0)
8145 image->chromaticity.blue_primary.y=
8146 image->chromaticity.blue_primary.x;
8149 if (LocaleCompare(keyword,"bordercolor") == 0)
8151 (void) QueryColorCompliance(value,AllCompliance,
8152 &image_info->border_color,exception);
8155 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8161 if (LocaleCompare(keyword,"density") == 0)
8163 (void) CloneString(&image_info->density,value);
8164 (void) CloneString(&draw_info->density,value);
8167 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8173 if (LocaleCompare(keyword,"fill") == 0)
8175 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8177 (void) SetImageOption(image_info,keyword,value);
8180 if (LocaleCompare(keyword,"filename") == 0)
8182 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
8185 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8191 if (LocaleCompare(keyword,"gravity") == 0)
8196 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8198 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8199 (void) SetImageOption(image_info,keyword,value);
8202 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8208 if (LocaleCompare(keyword,"id") == 0)
8210 (void) SetImageProperty(attributes,keyword,value,exception);
8213 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8219 if (LocaleCompare(keyword,"magick") == 0)
8221 (void) CopyMagickString(image_info->magick,value,MagickPathExtent);
8224 if (LocaleCompare(keyword,"mattecolor") == 0)
8226 (void) QueryColorCompliance(value,AllCompliance,
8227 &image_info->matte_color,exception);
8230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8236 if (LocaleCompare(keyword,"pointsize") == 0)
8238 image_info->pointsize=StringToDouble(value,(char **) NULL);
8239 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8242 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8248 if (LocaleCompare(keyword,"quality") == 0)
8250 image_info->quality=StringToLong(value);
8251 if (image == (Image *) NULL)
8253 image->quality=StringToLong(value);
8261 if (LocaleCompare(keyword,"size") == 0)
8263 (void) CloneString(&image_info->size,value);
8266 if (LocaleCompare(keyword,"stroke") == 0)
8268 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8270 (void) SetImageOption(image_info,keyword,value);
8273 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8278 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8291 % U n r e g i s t e r M S L I m a g e %
8295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8297 % UnregisterMSLImage() removes format registrations made by the
8298 % MSL module from the list of supported formats.
8300 % The format of the UnregisterMSLImage method is:
8302 % UnregisterMSLImage(void)
8305 ModuleExport void UnregisterMSLImage(void)
8307 (void) UnregisterMagickInfo("MSL");
8308 #if defined(MAGICKCORE_XML_DELEGATE)
8313 #if defined(MAGICKCORE_XML_DELEGATE)
8315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8319 % W r i t e M S L I m a g e %
8323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8325 % WriteMSLImage() writes an image to a file in MVG image format.
8327 % The format of the WriteMSLImage method is:
8329 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8330 % Image *image,ExceptionInfo *exception)
8332 % A description of each parameter follows.
8334 % o image_info: the image info.
8336 % o image: The image.
8338 % o exception: return any errors or warnings in this structure.
8341 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8342 ExceptionInfo *exception)
8347 assert(image_info != (const ImageInfo *) NULL);
8348 assert(image_info->signature == MagickCoreSignature);
8349 assert(image != (Image *) NULL);
8350 assert(image->signature == MagickCoreSignature);
8351 if (image->debug != MagickFalse)
8352 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8353 msl_image=CloneImage(image,0,0,MagickTrue,exception);
8354 return(ProcessMSLScript(image_info,&msl_image,exception));