2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/color-private.h"
53 #include "MagickCore/colormap.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/enhance.h"
61 #include "MagickCore/exception.h"
62 #include "MagickCore/exception-private.h"
63 #include "MagickCore/fx.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/image.h"
66 #include "MagickCore/image-private.h"
67 #include "MagickCore/list.h"
68 #include "MagickCore/log.h"
69 #include "MagickCore/magick.h"
70 #include "MagickCore/memory_.h"
71 #include "MagickCore/module.h"
72 #include "MagickCore/option.h"
73 #include "MagickCore/paint.h"
74 #include "MagickCore/pixel-accessor.h"
75 #include "MagickCore/profile.h"
76 #include "MagickCore/property.h"
77 #include "MagickCore/quantize.h"
78 #include "MagickCore/quantum-private.h"
79 #include "MagickCore/registry.h"
80 #include "MagickCore/resize.h"
81 #include "MagickCore/resource_.h"
82 #include "MagickCore/segment.h"
83 #include "MagickCore/shear.h"
84 #include "MagickCore/signature.h"
85 #include "MagickCore/static.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/string-private.h"
88 #include "MagickCore/transform.h"
89 #include "MagickCore/threshold.h"
90 #include "MagickCore/utility.h"
91 #if defined(MAGICKCORE_XML_DELEGATE)
92 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
93 # if defined(__MINGW32__)
96 # include <win32config.h>
99 # include <libxml/parser.h>
100 # include <libxml/xmlmemory.h>
101 # include <libxml/parserInternals.h>
102 # include <libxml/xmlerror.h>
108 #define ThrowMSLException(severity,tag,reason) \
109 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
113 Typedef declaractions.
115 typedef struct _MSLGroupInfo
118 numImages; /* how many images are in this group */
121 typedef struct _MSLInfo
146 #if defined(MAGICKCORE_XML_DELEGATE)
156 Forward declarations.
158 #if defined(MAGICKCORE_XML_DELEGATE)
159 static MagickBooleanType
160 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
162 static MagickBooleanType
163 SetMSLAttributes(MSLInfo *,const char *,const char *);
166 #if defined(MAGICKCORE_XML_DELEGATE)
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % R e a d M S L I m a g e %
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
180 % It allocates the memory necessary for the new Image structure and returns a
181 % pointer to the new image.
183 % The format of the ReadMSLImage method is:
185 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
187 % A description of each parameter follows:
189 % o image_info: the image info.
191 % o exception: return any errors or warnings in this structure.
195 #if defined(__cplusplus) || defined(c_plusplus)
199 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
200 ExceptionInfo *exception)
214 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
215 sans_exception=AcquireExceptionInfo();
216 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
217 sans_exception=DestroyExceptionInfo(sans_exception);
218 if (image != (Image *) NULL)
220 read_info=CloneImageInfo(image_info);
221 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
222 image=ReadImage(read_info,exception);
223 read_info=DestroyImageInfo(read_info);
224 if (image != (Image *) NULL)
225 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
229 static int IsPathDirectory(const char *path)
237 if ((path == (const char *) NULL) || (*path == '\0'))
239 status=GetPathAttributes(path,&attributes);
240 if (status == MagickFalse)
242 if (S_ISDIR(attributes.st_mode) == 0)
247 static int MSLIsStandalone(void *context)
253 Is this document tagged standalone?
255 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
256 msl_info=(MSLInfo *) context;
257 return(msl_info->document->standalone == 1);
260 static int MSLHasInternalSubset(void *context)
266 Does this document has an internal subset?
268 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
269 " SAX.MSLHasInternalSubset()");
270 msl_info=(MSLInfo *) context;
271 return(msl_info->document->intSubset != NULL);
274 static int MSLHasExternalSubset(void *context)
280 Does this document has an external subset?
282 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
283 " SAX.MSLHasExternalSubset()");
284 msl_info=(MSLInfo *) context;
285 return(msl_info->document->extSubset != NULL);
288 static void MSLInternalSubset(void *context,const xmlChar *name,
289 const xmlChar *external_id,const xmlChar *system_id)
295 Does this document has an internal subset?
297 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
298 " SAX.internalSubset(%s %s %s)",name,
299 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
300 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
301 msl_info=(MSLInfo *) context;
302 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
305 static xmlParserInputPtr MSLResolveEntity(void *context,
306 const xmlChar *public_id,const xmlChar *system_id)
315 Special entity resolver, better left to the parser, it has more
316 context than the application layer. The default behaviour is to
317 not resolve the entities, in that case the ENTITY_REF nodes are
318 built in the structure (and the parameter values).
320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
321 " SAX.resolveEntity(%s, %s)",
322 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
323 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
324 msl_info=(MSLInfo *) context;
325 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
326 public_id,msl_info->parser);
330 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
336 Get an entity by name.
338 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
339 " SAX.MSLGetEntity(%s)",(const char *) name);
340 msl_info=(MSLInfo *) context;
341 return(xmlGetDocEntity(msl_info->document,name));
344 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
350 Get a parameter entity by name.
352 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
353 " SAX.getParameterEntity(%s)",(const char *) name);
354 msl_info=(MSLInfo *) context;
355 return(xmlGetParameterEntity(msl_info->document,name));
358 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
359 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
365 An entity definition has been parsed.
367 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
368 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
369 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
370 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
372 msl_info=(MSLInfo *) context;
373 if (msl_info->parser->inSubset == 1)
374 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
377 if (msl_info->parser->inSubset == 2)
378 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
382 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
383 const xmlChar *name,int type,int value,const xmlChar *default_value,
384 xmlEnumerationPtr tree)
397 An attribute definition has been parsed.
399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
400 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
402 msl_info=(MSLInfo *) context;
403 fullname=(xmlChar *) NULL;
404 prefix=(xmlChar *) NULL;
405 parser=msl_info->parser;
406 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
407 if (parser->inSubset == 1)
408 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
409 element,fullname,prefix,(xmlAttributeType) type,
410 (xmlAttributeDefault) value,default_value,tree);
412 if (parser->inSubset == 2)
413 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
414 element,fullname,prefix,(xmlAttributeType) type,
415 (xmlAttributeDefault) value,default_value,tree);
416 if (prefix != (xmlChar *) NULL)
418 if (fullname != (xmlChar *) NULL)
422 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
423 xmlElementContentPtr content)
432 An element definition has been parsed.
434 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
435 " SAX.elementDecl(%s, %d, ...)",name,type);
436 msl_info=(MSLInfo *) context;
437 parser=msl_info->parser;
438 if (parser->inSubset == 1)
439 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
440 name,(xmlElementTypeVal) type,content);
442 if (parser->inSubset == 2)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
444 name,(xmlElementTypeVal) type,content);
447 static void MSLNotationDeclaration(void *context,const xmlChar *name,
448 const xmlChar *public_id,const xmlChar *system_id)
457 What to do when a notation declaration has been parsed.
459 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
460 " SAX.notationDecl(%s, %s, %s)",name,
461 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
462 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
463 msl_info=(MSLInfo *) context;
464 parser=msl_info->parser;
465 if (parser->inSubset == 1)
466 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
467 name,public_id,system_id);
469 if (parser->inSubset == 2)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
474 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
475 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
481 What to do when an unparsed entity declaration is parsed.
483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
484 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
485 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
486 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
488 msl_info=(MSLInfo *) context;
489 (void) xmlAddDocEntity(msl_info->document,name,
490 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
494 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
500 Receive the document locator at startup, actually xmlDefaultSAXLocator.
502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
503 " SAX.setDocumentLocator()\n");
505 msl_info=(MSLInfo *) context;
509 static void MSLStartDocument(void *context)
518 Called when the document start being processed.
520 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521 " SAX.startDocument()");
522 msl_info=(MSLInfo *) context;
523 parser=msl_info->parser;
524 msl_info->document=xmlNewDoc(parser->version);
525 if (msl_info->document == (xmlDocPtr) NULL)
527 if (parser->encoding == NULL)
528 msl_info->document->encoding=NULL;
530 msl_info->document->encoding=xmlStrdup(parser->encoding);
531 msl_info->document->standalone=parser->standalone;
534 static void MSLEndDocument(void *context)
540 Called when the document end has been detected.
542 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
543 msl_info=(MSLInfo *) context;
544 if (msl_info->content != (char *) NULL)
545 msl_info->content=DestroyString(msl_info->content);
548 static void MSLPushImage(MSLInfo *msl_info,Image *image)
553 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
554 assert(msl_info != (MSLInfo *) NULL);
557 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
558 (n+1),sizeof(*msl_info->image_info));
559 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
560 (n+1),sizeof(*msl_info->draw_info));
561 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
562 (n+1),sizeof(*msl_info->attributes));
563 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
564 sizeof(*msl_info->image));
565 if ((msl_info->image_info == (ImageInfo **) NULL) ||
566 (msl_info->draw_info == (DrawInfo **) NULL) ||
567 (msl_info->attributes == (Image **) NULL) ||
568 (msl_info->image == (Image **) NULL))
569 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
570 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
571 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
572 msl_info->draw_info[n-1]);
573 if (image == (Image *) NULL)
574 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
577 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
578 msl_info->image[n]=(Image *) image;
579 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
580 (msl_info->attributes[n] == (Image *) NULL))
581 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
582 if (msl_info->number_groups != 0)
583 msl_info->group_info[msl_info->number_groups-1].numImages++;
586 static void MSLPopImage(MSLInfo *msl_info)
588 if (msl_info->number_groups != 0)
590 if (msl_info->image[msl_info->n] != (Image *) NULL)
591 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
592 msl_info->attributes[msl_info->n]=DestroyImage(
593 msl_info->attributes[msl_info->n]);
594 msl_info->image_info[msl_info->n]=DestroyImageInfo(
595 msl_info->image_info[msl_info->n]);
599 static void MSLStartElement(void *context,const xmlChar *tag,
600 const xmlChar **attributes)
659 Called when an opening tag has been processed.
661 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
662 " SAX.startElement(%s",tag);
663 GetExceptionInfo(&exception);
664 msl_info=(MSLInfo *) context;
666 keyword=(const char *) NULL;
668 SetGeometryInfo(&geometry_info);
669 channel=DefaultChannels;
675 if (LocaleCompare((const char *) tag,"add-noise") == 0)
686 if (msl_info->image[n] == (Image *) NULL)
688 ThrowMSLException(OptionError,"NoImagesDefined",
693 if (attributes != (const xmlChar **) NULL)
694 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
696 keyword=(const char *) attributes[i++];
697 attribute=InterpretImageProperties(msl_info->image_info[n],
698 msl_info->attributes[n],(const char *) attributes[i],
700 CloneString(&value,attribute);
706 if (LocaleCompare(keyword,"channel") == 0)
708 option=ParseChannelOption(value);
710 ThrowMSLException(OptionError,"UnrecognizedChannelType",
712 channel=(ChannelType) option;
715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
722 if (LocaleCompare(keyword,"noise") == 0)
724 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
727 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
729 noise=(NoiseType) option;
732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
744 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
745 noise_image=AddNoiseImage(msl_info->image[n],noise,
746 &msl_info->image[n]->exception);
747 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
748 if (noise_image == (Image *) NULL)
750 msl_info->image[n]=DestroyImage(msl_info->image[n]);
751 msl_info->image[n]=noise_image;
754 if (LocaleCompare((const char *) tag,"annotate") == 0)
762 if (msl_info->image[n] == (Image *) NULL)
764 ThrowMSLException(OptionError,"NoImagesDefined",
768 draw_info=CloneDrawInfo(msl_info->image_info[n],
769 msl_info->draw_info[n]);
771 current=draw_info->affine;
772 GetAffineMatrix(&affine);
773 if (attributes != (const xmlChar **) NULL)
774 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
776 keyword=(const char *) attributes[i++];
777 attribute=InterpretImageProperties(msl_info->image_info[n],
778 msl_info->attributes[n],(const char *) attributes[i],
780 CloneString(&value,attribute);
786 if (LocaleCompare(keyword,"affine") == 0)
792 draw_info->affine.sx=InterpretLocaleValue(p,&p);
795 draw_info->affine.rx=InterpretLocaleValue(p,&p);
798 draw_info->affine.ry=InterpretLocaleValue(p,&p);
801 draw_info->affine.sy=InterpretLocaleValue(p,&p);
804 draw_info->affine.tx=InterpretLocaleValue(p,&p);
807 draw_info->affine.ty=InterpretLocaleValue(p,&p);
810 if (LocaleCompare(keyword,"align") == 0)
812 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
815 ThrowMSLException(OptionError,"UnrecognizedAlignType",
817 draw_info->align=(AlignType) option;
820 if (LocaleCompare(keyword,"antialias") == 0)
822 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
825 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
827 draw_info->stroke_antialias=(MagickBooleanType) option;
828 draw_info->text_antialias=(MagickBooleanType) option;
831 ThrowMSLException(OptionError,"UnrecognizedAttribute",
838 if (LocaleCompare(keyword,"density") == 0)
840 CloneString(&draw_info->density,value);
843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
850 if (LocaleCompare(keyword,"encoding") == 0)
852 CloneString(&draw_info->encoding,value);
855 ThrowMSLException(OptionError,"UnrecognizedAttribute",
862 if (LocaleCompare(keyword, "fill") == 0)
864 (void) QueryColorCompliance(value,AllCompliance,
865 &draw_info->fill,&exception);
868 if (LocaleCompare(keyword,"family") == 0)
870 CloneString(&draw_info->family,value);
873 if (LocaleCompare(keyword,"font") == 0)
875 CloneString(&draw_info->font,value);
878 ThrowMSLException(OptionError,"UnrecognizedAttribute",
885 if (LocaleCompare(keyword,"geometry") == 0)
887 flags=ParseGravityGeometry(msl_info->image[n],value,
888 &geometry,&exception);
891 if (LocaleCompare(keyword,"gravity") == 0)
893 option=ParseCommandOption(MagickGravityOptions,
896 ThrowMSLException(OptionError,"UnrecognizedGravityType",
898 draw_info->gravity=(GravityType) option;
901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
908 if (LocaleCompare(keyword,"pointsize") == 0)
910 draw_info->pointsize=InterpretLocaleValue(value,
914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
921 if (LocaleCompare(keyword,"rotate") == 0)
923 angle=InterpretLocaleValue(value,(char **) NULL);
924 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
925 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
926 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
927 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
937 if (LocaleCompare(keyword,"scale") == 0)
939 flags=ParseGeometry(value,&geometry_info);
940 if ((flags & SigmaValue) == 0)
941 geometry_info.sigma=1.0;
942 affine.sx=geometry_info.rho;
943 affine.sy=geometry_info.sigma;
946 if (LocaleCompare(keyword,"skewX") == 0)
948 angle=InterpretLocaleValue(value,(char **) NULL);
949 affine.ry=tan(DegreesToRadians(fmod((double) angle,
953 if (LocaleCompare(keyword,"skewY") == 0)
955 angle=InterpretLocaleValue(value,(char **) NULL);
956 affine.rx=tan(DegreesToRadians(fmod((double) angle,
960 if (LocaleCompare(keyword,"stretch") == 0)
962 option=ParseCommandOption(MagickStretchOptions,
965 ThrowMSLException(OptionError,"UnrecognizedStretchType",
967 draw_info->stretch=(StretchType) option;
970 if (LocaleCompare(keyword, "stroke") == 0)
972 (void) QueryColorCompliance(value,AllCompliance,
973 &draw_info->stroke,&exception);
976 if (LocaleCompare(keyword,"strokewidth") == 0)
978 draw_info->stroke_width=StringToLong(value);
981 if (LocaleCompare(keyword,"style") == 0)
983 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
986 ThrowMSLException(OptionError,"UnrecognizedStyleType",
988 draw_info->style=(StyleType) option;
991 ThrowMSLException(OptionError,"UnrecognizedAttribute",
998 if (LocaleCompare(keyword,"text") == 0)
1000 CloneString(&draw_info->text,value);
1003 if (LocaleCompare(keyword,"translate") == 0)
1005 flags=ParseGeometry(value,&geometry_info);
1006 if ((flags & SigmaValue) == 0)
1007 geometry_info.sigma=1.0;
1008 affine.tx=geometry_info.rho;
1009 affine.ty=geometry_info.sigma;
1012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1019 if (LocaleCompare(keyword, "undercolor") == 0)
1021 (void) QueryColorCompliance(value,AllCompliance,
1022 &draw_info->undercolor,&exception);
1025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1032 if (LocaleCompare(keyword,"weight") == 0)
1034 draw_info->weight=StringToLong(value);
1037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1044 if (LocaleCompare(keyword,"x") == 0)
1046 geometry.x=StringToLong(value);
1049 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1056 if (LocaleCompare(keyword,"y") == 0)
1058 geometry.y=StringToLong(value);
1061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1067 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1073 (void) FormatLocaleString(text,MaxTextExtent,
1074 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1075 geometry.height,(double) geometry.x,(double) geometry.y);
1076 CloneString(&draw_info->geometry,text);
1077 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1078 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1079 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1080 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1081 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1083 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1085 (void) AnnotateImage(msl_info->image[n],draw_info,
1086 &msl_info->image[n]->exception);
1087 draw_info=DestroyDrawInfo(draw_info);
1090 if (LocaleCompare((const char *) tag,"append") == 0)
1098 if (msl_info->image[n] == (Image *) NULL)
1100 ThrowMSLException(OptionError,"NoImagesDefined",
1101 (const char *) tag);
1105 if (attributes != (const xmlChar **) NULL)
1106 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1108 keyword=(const char *) attributes[i++];
1109 attribute=InterpretImageProperties(msl_info->image_info[n],
1110 msl_info->attributes[n],(const char *) attributes[i],
1112 CloneString(&value,attribute);
1118 if (LocaleCompare(keyword,"stack") == 0)
1120 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1123 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1125 stack=(MagickBooleanType) option;
1128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1140 append_image=AppendImages(msl_info->image[n],stack,
1141 &msl_info->image[n]->exception);
1142 if (append_image == (Image *) NULL)
1144 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1145 msl_info->image[n]=append_image;
1148 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1154 if (LocaleCompare((const char *) tag,"blur") == 0)
1162 if (msl_info->image[n] == (Image *) NULL)
1164 ThrowMSLException(OptionError,"NoImagesDefined",
1165 (const char *) tag);
1168 if (attributes != (const xmlChar **) NULL)
1169 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1171 keyword=(const char *) attributes[i++];
1172 attribute=InterpretImageProperties(msl_info->image_info[n],
1173 msl_info->attributes[n],(const char *) attributes[i],
1175 CloneString(&value,attribute);
1181 if (LocaleCompare(keyword,"channel") == 0)
1183 option=ParseChannelOption(value);
1185 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1187 channel=(ChannelType) option;
1190 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1197 if (LocaleCompare(keyword,"geometry") == 0)
1199 flags=ParseGeometry(value,&geometry_info);
1200 if ((flags & SigmaValue) == 0)
1201 geometry_info.sigma=1.0;
1204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1211 if (LocaleCompare(keyword,"radius") == 0)
1213 geometry_info.rho=InterpretLocaleValue(value,
1217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1224 if (LocaleCompare(keyword,"sigma") == 0)
1226 geometry_info.sigma=StringToLong(value);
1229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1235 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1241 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1242 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1243 geometry_info.sigma,geometry_info.xi,
1244 &msl_info->image[n]->exception);
1245 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
1246 if (blur_image == (Image *) NULL)
1248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1249 msl_info->image[n]=blur_image;
1252 if (LocaleCompare((const char *) tag,"border") == 0)
1260 if (msl_info->image[n] == (Image *) NULL)
1262 ThrowMSLException(OptionError,"NoImagesDefined",
1263 (const char *) tag);
1266 SetGeometry(msl_info->image[n],&geometry);
1267 if (attributes != (const xmlChar **) NULL)
1268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1270 keyword=(const char *) attributes[i++];
1271 attribute=InterpretImageProperties(msl_info->image_info[n],
1272 msl_info->attributes[n],(const char *) attributes[i],
1274 CloneString(&value,attribute);
1280 if (LocaleCompare(keyword,"compose") == 0)
1282 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1285 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1287 msl_info->image[n]->compose=(CompositeOperator) option;
1290 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1297 if (LocaleCompare(keyword, "fill") == 0)
1299 (void) QueryColorCompliance(value,AllCompliance,
1300 &msl_info->image[n]->border_color,&exception);
1303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1310 if (LocaleCompare(keyword,"geometry") == 0)
1312 flags=ParsePageGeometry(msl_info->image[n],value,
1313 &geometry,&exception);
1314 if ((flags & HeightValue) == 0)
1315 geometry.height=geometry.width;
1318 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1325 if (LocaleCompare(keyword,"height") == 0)
1327 geometry.height=StringToLong(value);
1330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1337 if (LocaleCompare(keyword,"width") == 0)
1339 geometry.width=StringToLong(value);
1342 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1348 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1354 border_image=BorderImage(msl_info->image[n],&geometry,
1355 msl_info->image[n]->compose,&msl_info->image[n]->exception);
1356 if (border_image == (Image *) NULL)
1358 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1359 msl_info->image[n]=border_image;
1362 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1367 if (LocaleCompare((const char *) tag,"colorize") == 0)
1370 blend[MaxTextExtent];
1381 if (msl_info->image[n] == (Image *) NULL)
1383 ThrowMSLException(OptionError,"NoImagesDefined",
1384 (const char *) tag);
1387 GetPixelInfo(msl_info->image[n],&target);
1388 (void) CopyMagickString(blend,"100",MaxTextExtent);
1389 if (attributes != (const xmlChar **) NULL)
1390 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1392 keyword=(const char *) attributes[i++];
1393 attribute=InterpretImageProperties(msl_info->image_info[n],
1394 msl_info->attributes[n],(const char *) attributes[i],
1396 CloneString(&value,attribute);
1402 if (LocaleCompare(keyword,"blend") == 0)
1404 (void) CopyMagickString(blend,value,MaxTextExtent);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 if (LocaleCompare(keyword,"fill") == 0)
1416 (void) QueryMagickColorCompliance(value,AllCompliance,
1417 &target,&msl_info->image[n]->exception);
1420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1432 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1433 &msl_info->image[n]->exception);
1434 if (colorize_image == (Image *) NULL)
1436 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1437 msl_info->image[n]=colorize_image;
1440 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1446 if (msl_info->image[n] == (Image *) NULL)
1448 ThrowMSLException(OptionError,"NoImagesDefined",
1449 (const char *) tag);
1453 NOTE: charcoal can have no attributes, since we use all the defaults!
1455 if (attributes != (const xmlChar **) NULL)
1457 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1459 keyword=(const char *) attributes[i++];
1460 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1461 msl_info->attributes[n],(const char *) attributes[i],&exception));
1467 if (LocaleCompare(keyword, "bias") == 0)
1469 bias = InterpretLocaleValue(value,(char **) NULL);
1472 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1478 if (LocaleCompare(keyword, "radius") == 0)
1480 radius = InterpretLocaleValue(value,(char **) NULL);
1483 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 if (LocaleCompare(keyword,"sigma") == 0)
1491 sigma = StringToLong( value );
1494 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1499 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1513 newImage=CharcoalImage(msl_info->image[n],radius,sigma,bias,
1514 &msl_info->image[n]->exception);
1515 if (newImage == (Image *) NULL)
1517 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1518 msl_info->image[n]=newImage;
1522 if (LocaleCompare((const char *) tag,"chop") == 0)
1530 if (msl_info->image[n] == (Image *) NULL)
1532 ThrowMSLException(OptionError,"NoImagesDefined",
1533 (const char *) tag);
1536 SetGeometry(msl_info->image[n],&geometry);
1537 if (attributes != (const xmlChar **) NULL)
1538 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1540 keyword=(const char *) attributes[i++];
1541 attribute=InterpretImageProperties(msl_info->image_info[n],
1542 msl_info->attributes[n],(const char *) attributes[i],
1544 CloneString(&value,attribute);
1550 if (LocaleCompare(keyword,"geometry") == 0)
1552 flags=ParsePageGeometry(msl_info->image[n],value,
1553 &geometry,&exception);
1554 if ((flags & HeightValue) == 0)
1555 geometry.height=geometry.width;
1558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1565 if (LocaleCompare(keyword,"height") == 0)
1567 geometry.height=StringToLong(value);
1570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1577 if (LocaleCompare(keyword,"width") == 0)
1579 geometry.width=StringToLong(value);
1582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1589 if (LocaleCompare(keyword,"x") == 0)
1591 geometry.x=StringToLong(value);
1594 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1601 if (LocaleCompare(keyword,"y") == 0)
1603 geometry.y=StringToLong(value);
1606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1618 chop_image=ChopImage(msl_info->image[n],&geometry,
1619 &msl_info->image[n]->exception);
1620 if (chop_image == (Image *) NULL)
1622 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1623 msl_info->image[n]=chop_image;
1626 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1635 Color floodfill image.
1637 if (msl_info->image[n] == (Image *) NULL)
1639 ThrowMSLException(OptionError,"NoImagesDefined",
1640 (const char *) tag);
1643 draw_info=CloneDrawInfo(msl_info->image_info[n],
1644 msl_info->draw_info[n]);
1645 SetGeometry(msl_info->image[n],&geometry);
1646 paint_method=FloodfillMethod;
1647 if (attributes != (const xmlChar **) NULL)
1648 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1650 keyword=(const char *) attributes[i++];
1651 attribute=InterpretImageProperties(msl_info->image_info[n],
1652 msl_info->attributes[n],(const char *) attributes[i],
1654 CloneString(&value,attribute);
1660 if (LocaleCompare(keyword,"bordercolor") == 0)
1662 (void) QueryMagickColorCompliance(value,AllCompliance,
1663 &target,&exception);
1664 paint_method=FillToBorderMethod;
1667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1674 if (LocaleCompare(keyword,"fill") == 0)
1676 (void) QueryColorCompliance(value,AllCompliance,
1677 &draw_info->fill,&exception);
1680 if (LocaleCompare(keyword,"fuzz") == 0)
1682 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1686 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1693 if (LocaleCompare(keyword,"geometry") == 0)
1695 flags=ParsePageGeometry(msl_info->image[n],value,
1696 &geometry,&exception);
1697 if ((flags & HeightValue) == 0)
1698 geometry.height=geometry.width;
1699 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1700 geometry.x,geometry.y,&target,&exception);
1703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1710 if (LocaleCompare(keyword,"x") == 0)
1712 geometry.x=StringToLong(value);
1713 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1714 geometry.x,geometry.y,&target,&exception);
1717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1724 if (LocaleCompare(keyword,"y") == 0)
1726 geometry.y=StringToLong(value);
1727 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1728 geometry.x,geometry.y,&target,&exception);
1731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1743 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1744 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1745 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
1746 draw_info=DestroyDrawInfo(draw_info);
1749 if (LocaleCompare((const char *) tag,"comment") == 0)
1751 if (LocaleCompare((const char *) tag,"composite") == 0)
1754 composite_geometry[MaxTextExtent];
1766 if (msl_info->image[n] == (Image *) NULL)
1768 ThrowMSLException(OptionError,"NoImagesDefined",
1769 (const char *) tag);
1772 composite_image=NewImageList();
1773 compose=OverCompositeOp;
1774 if (attributes != (const xmlChar **) NULL)
1775 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1777 keyword=(const char *) attributes[i++];
1778 attribute=InterpretImageProperties(msl_info->image_info[n],
1779 msl_info->attributes[n],(const char *) attributes[i],
1781 CloneString(&value,attribute);
1787 if (LocaleCompare(keyword,"compose") == 0)
1789 option=ParseCommandOption(MagickComposeOptions,
1792 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1794 compose=(CompositeOperator) option;
1802 if (LocaleCompare(keyword,"image") == 0)
1803 for (j=0; j < msl_info->n; j++)
1808 attribute=GetImageProperty(msl_info->attributes[j],"id");
1809 if ((attribute != (const char *) NULL) &&
1810 (LocaleCompare(attribute,value) == 0))
1812 composite_image=CloneImage(msl_info->image[j],0,0,
1813 MagickFalse,&exception);
1823 if (composite_image == (Image *) NULL)
1825 rotate_image=NewImageList();
1826 SetGeometry(msl_info->image[n],&geometry);
1827 if (attributes != (const xmlChar **) NULL)
1828 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1830 keyword=(const char *) attributes[i++];
1831 attribute=InterpretImageProperties(msl_info->image_info[n],
1832 msl_info->attributes[n],(const char *) attributes[i],
1834 CloneString(&value,attribute);
1840 if (LocaleCompare(keyword,"blend") == 0)
1842 (void) SetImageArtifact(composite_image,
1843 "compose:args",value);
1846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1853 if (LocaleCompare(keyword,"channel") == 0)
1855 option=ParseChannelOption(value);
1857 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1859 channel=(ChannelType) option;
1862 if (LocaleCompare(keyword, "color") == 0)
1864 (void) QueryColorCompliance(value,AllCompliance,
1865 &composite_image->background_color,&exception);
1868 if (LocaleCompare(keyword,"compose") == 0)
1870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1877 if (LocaleCompare(keyword,"geometry") == 0)
1879 flags=ParsePageGeometry(msl_info->image[n],value,
1880 &geometry,&exception);
1881 if ((flags & HeightValue) == 0)
1882 geometry.height=geometry.width;
1885 if (LocaleCompare(keyword,"gravity") == 0)
1887 option=ParseCommandOption(MagickGravityOptions,
1890 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1892 msl_info->image[n]->gravity=(GravityType) option;
1895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1902 if (LocaleCompare(keyword,"image") == 0)
1904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1911 if (LocaleCompare(keyword,"mask") == 0)
1912 for (j=0; j < msl_info->n; j++)
1917 attribute=GetImageProperty(msl_info->attributes[j],"id");
1918 if ((attribute != (const char *) NULL) &&
1919 (LocaleCompare(value,value) == 0))
1921 SetImageType(composite_image,TrueColorMatteType,
1923 (void) CompositeImage(composite_image,
1924 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1935 if (LocaleCompare(keyword,"opacity") == 0)
1950 opacity=StringToLong(value);
1951 if (compose != DissolveCompositeOp)
1953 (void) SetImageAlpha(composite_image,(Quantum)
1957 (void) SetImageArtifact(msl_info->image[n],
1958 "compose:args",value);
1959 if (composite_image->matte != MagickTrue)
1960 (void) SetImageAlpha(composite_image,OpaqueAlpha);
1961 composite_view=AcquireCacheView(composite_image);
1962 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1964 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1965 (ssize_t) composite_image->columns,1,&exception);
1966 for (x=0; x < (ssize_t) composite_image->columns; x++)
1968 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1969 SetPixelAlpha(composite_image,
1970 ClampToQuantum(opacity),q);
1971 q+=GetPixelChannels(composite_image);
1973 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1976 composite_view=DestroyCacheView(composite_view);
1979 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1986 if (LocaleCompare(keyword,"rotate") == 0)
1988 rotate_image=RotateImage(composite_image,
1989 InterpretLocaleValue(value,(char **) NULL),&exception);
1992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1999 if (LocaleCompare(keyword,"tile") == 0)
2004 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2007 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2009 tile=(MagickBooleanType) option;
2011 if (rotate_image != (Image *) NULL)
2012 (void) SetImageArtifact(rotate_image,
2013 "compose:outside-overlay","false");
2015 (void) SetImageArtifact(composite_image,
2016 "compose:outside-overlay","false");
2017 image=msl_info->image[n];
2018 height=composite_image->rows;
2019 width=composite_image->columns;
2020 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2021 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2023 if (rotate_image != (Image *) NULL)
2024 (void) CompositeImage(image,compose,rotate_image,
2027 (void) CompositeImage(image,compose,
2028 composite_image,x,y);
2030 if (rotate_image != (Image *) NULL)
2031 rotate_image=DestroyImage(rotate_image);
2034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2041 if (LocaleCompare(keyword,"x") == 0)
2043 geometry.x=StringToLong(value);
2046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2053 if (LocaleCompare(keyword,"y") == 0)
2055 geometry.y=StringToLong(value);
2058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2070 image=msl_info->image[n];
2071 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2072 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2073 (double) composite_image->rows,(double) geometry.x,(double)
2075 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2077 channel_mask=SetPixelChannelMask(image,channel);
2078 if (rotate_image == (Image *) NULL)
2079 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
2085 geometry.x-=(ssize_t) (rotate_image->columns-
2086 composite_image->columns)/2;
2087 geometry.y-=(ssize_t) (rotate_image->rows-
2088 composite_image->rows)/2;
2089 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
2090 rotate_image=DestroyImage(rotate_image);
2092 (void) SetPixelChannelMask(image,channel_mask);
2093 composite_image=DestroyImage(composite_image);
2096 if (LocaleCompare((const char *) tag,"contrast") == 0)
2104 if (msl_info->image[n] == (Image *) NULL)
2106 ThrowMSLException(OptionError,"NoImagesDefined",
2107 (const char *) tag);
2110 sharpen=MagickFalse;
2111 if (attributes != (const xmlChar **) NULL)
2112 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2114 keyword=(const char *) attributes[i++];
2115 attribute=InterpretImageProperties(msl_info->image_info[n],
2116 msl_info->attributes[n],(const char *) attributes[i],
2118 CloneString(&value,attribute);
2124 if (LocaleCompare(keyword,"sharpen") == 0)
2126 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2129 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2131 sharpen=(MagickBooleanType) option;
2134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2146 (void) ContrastImage(msl_info->image[n],sharpen,
2147 &msl_info->image[n]->exception);
2150 if (LocaleCompare((const char *) tag,"crop") == 0)
2158 if (msl_info->image[n] == (Image *) NULL)
2160 ThrowMSLException(OptionError,"NoImagesDefined",
2161 (const char *) tag);
2164 SetGeometry(msl_info->image[n],&geometry);
2165 if (attributes != (const xmlChar **) NULL)
2166 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2168 keyword=(const char *) attributes[i++];
2169 attribute=InterpretImageProperties(msl_info->image_info[n],
2170 msl_info->attributes[n],(const char *) attributes[i],
2172 CloneString(&value,attribute);
2178 if (LocaleCompare(keyword,"geometry") == 0)
2180 flags=ParseGravityGeometry(msl_info->image[n],value,
2181 &geometry,&exception);
2184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2191 if (LocaleCompare(keyword,"height") == 0)
2193 geometry.height=StringToLong(value);
2196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 if (LocaleCompare(keyword,"width") == 0)
2205 geometry.width=StringToLong(value);
2208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2215 if (LocaleCompare(keyword,"x") == 0)
2217 geometry.x=StringToLong(value);
2220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2227 if (LocaleCompare(keyword,"y") == 0)
2229 geometry.y=StringToLong(value);
2232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2244 crop_image=CropImage(msl_info->image[n],&geometry,
2245 &msl_info->image[n]->exception);
2246 if (crop_image == (Image *) NULL)
2248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2249 msl_info->image[n]=crop_image;
2252 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2258 Cycle-colormap image.
2260 if (msl_info->image[n] == (Image *) NULL)
2262 ThrowMSLException(OptionError,"NoImagesDefined",
2263 (const char *) tag);
2267 if (attributes != (const xmlChar **) NULL)
2268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2270 keyword=(const char *) attributes[i++];
2271 attribute=InterpretImageProperties(msl_info->image_info[n],
2272 msl_info->attributes[n],(const char *) attributes[i],
2274 CloneString(&value,attribute);
2280 if (LocaleCompare(keyword,"display") == 0)
2282 display=StringToLong(value);
2285 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2297 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2300 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2305 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2313 if (msl_info->image[n] == (Image *) NULL)
2315 ThrowMSLException(OptionError,"NoImagesDefined",
2316 (const char *) tag);
2319 if (attributes != (const xmlChar **) NULL)
2320 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2322 keyword=(const char *) attributes[i++];
2323 attribute=InterpretImageProperties(msl_info->image_info[n],
2324 msl_info->attributes[n],(const char *) attributes[i],
2326 CloneString(&value,attribute);
2327 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2329 despeckle_image=DespeckleImage(msl_info->image[n],
2330 &msl_info->image[n]->exception);
2331 if (despeckle_image == (Image *) NULL)
2333 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2334 msl_info->image[n]=despeckle_image;
2337 if (LocaleCompare((const char *) tag,"display") == 0)
2339 if (msl_info->image[n] == (Image *) NULL)
2341 ThrowMSLException(OptionError,"NoImagesDefined",
2342 (const char *) tag);
2345 if (attributes != (const xmlChar **) NULL)
2346 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2348 keyword=(const char *) attributes[i++];
2349 attribute=InterpretImageProperties(msl_info->image_info[n],
2350 msl_info->attributes[n],(const char *) attributes[i],
2352 CloneString(&value,attribute);
2357 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2363 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2364 &msl_info->image[n]->exception);
2367 if (LocaleCompare((const char *) tag,"draw") == 0)
2370 text[MaxTextExtent];
2375 if (msl_info->image[n] == (Image *) NULL)
2377 ThrowMSLException(OptionError,"NoImagesDefined",
2378 (const char *) tag);
2381 draw_info=CloneDrawInfo(msl_info->image_info[n],
2382 msl_info->draw_info[n]);
2384 current=draw_info->affine;
2385 GetAffineMatrix(&affine);
2386 if (attributes != (const xmlChar **) NULL)
2387 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2389 keyword=(const char *) attributes[i++];
2390 attribute=InterpretImageProperties(msl_info->image_info[n],
2391 msl_info->attributes[n],(const char *) attributes[i],
2393 CloneString(&value,attribute);
2399 if (LocaleCompare(keyword,"affine") == 0)
2405 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2408 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2411 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2414 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2417 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2420 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2423 if (LocaleCompare(keyword,"align") == 0)
2425 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2428 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2430 draw_info->align=(AlignType) option;
2433 if (LocaleCompare(keyword,"antialias") == 0)
2435 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2438 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2440 draw_info->stroke_antialias=(MagickBooleanType) option;
2441 draw_info->text_antialias=(MagickBooleanType) option;
2444 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2451 if (LocaleCompare(keyword,"density") == 0)
2453 CloneString(&draw_info->density,value);
2456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2463 if (LocaleCompare(keyword,"encoding") == 0)
2465 CloneString(&draw_info->encoding,value);
2468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2475 if (LocaleCompare(keyword, "fill") == 0)
2477 (void) QueryColorCompliance(value,AllCompliance,
2478 &draw_info->fill,&exception);
2481 if (LocaleCompare(keyword,"family") == 0)
2483 CloneString(&draw_info->family,value);
2486 if (LocaleCompare(keyword,"font") == 0)
2488 CloneString(&draw_info->font,value);
2491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2498 if (LocaleCompare(keyword,"geometry") == 0)
2500 flags=ParsePageGeometry(msl_info->image[n],value,
2501 &geometry,&exception);
2502 if ((flags & HeightValue) == 0)
2503 geometry.height=geometry.width;
2506 if (LocaleCompare(keyword,"gravity") == 0)
2508 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2511 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2513 draw_info->gravity=(GravityType) option;
2516 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2523 if (LocaleCompare(keyword,"primitive") == 0)
2525 CloneString(&draw_info->primitive,value);
2528 if (LocaleCompare(keyword,"pointsize") == 0)
2530 draw_info->pointsize=InterpretLocaleValue(value,
2534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2541 if (LocaleCompare(keyword,"rotate") == 0)
2543 angle=InterpretLocaleValue(value,(char **) NULL);
2544 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2545 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2546 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2547 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2550 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2557 if (LocaleCompare(keyword,"scale") == 0)
2559 flags=ParseGeometry(value,&geometry_info);
2560 if ((flags & SigmaValue) == 0)
2561 geometry_info.sigma=1.0;
2562 affine.sx=geometry_info.rho;
2563 affine.sy=geometry_info.sigma;
2566 if (LocaleCompare(keyword,"skewX") == 0)
2568 angle=InterpretLocaleValue(value,(char **) NULL);
2569 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2572 if (LocaleCompare(keyword,"skewY") == 0)
2574 angle=InterpretLocaleValue(value,(char **) NULL);
2575 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2578 if (LocaleCompare(keyword,"stretch") == 0)
2580 option=ParseCommandOption(MagickStretchOptions,
2583 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2585 draw_info->stretch=(StretchType) option;
2588 if (LocaleCompare(keyword, "stroke") == 0)
2590 (void) QueryColorCompliance(value,AllCompliance,
2591 &draw_info->stroke,&exception);
2594 if (LocaleCompare(keyword,"strokewidth") == 0)
2596 draw_info->stroke_width=StringToLong(value);
2599 if (LocaleCompare(keyword,"style") == 0)
2601 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2604 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2606 draw_info->style=(StyleType) option;
2609 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2616 if (LocaleCompare(keyword,"text") == 0)
2618 CloneString(&draw_info->text,value);
2621 if (LocaleCompare(keyword,"translate") == 0)
2623 flags=ParseGeometry(value,&geometry_info);
2624 if ((flags & SigmaValue) == 0)
2625 geometry_info.sigma=1.0;
2626 affine.tx=geometry_info.rho;
2627 affine.ty=geometry_info.sigma;
2630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2637 if (LocaleCompare(keyword, "undercolor") == 0)
2639 (void) QueryColorCompliance(value,AllCompliance,
2640 &draw_info->undercolor,&exception);
2643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2650 if (LocaleCompare(keyword,"weight") == 0)
2652 draw_info->weight=StringToLong(value);
2655 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2662 if (LocaleCompare(keyword,"x") == 0)
2664 geometry.x=StringToLong(value);
2667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2674 if (LocaleCompare(keyword,"y") == 0)
2676 geometry.y=StringToLong(value);
2679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2691 (void) FormatLocaleString(text,MaxTextExtent,
2692 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2693 geometry.height,(double) geometry.x,(double) geometry.y);
2694 CloneString(&draw_info->geometry,text);
2695 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2696 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2697 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2698 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2699 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2701 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2703 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2704 draw_info=DestroyDrawInfo(draw_info);
2707 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2712 if (LocaleCompare((const char *) tag,"edge") == 0)
2720 if (msl_info->image[n] == (Image *) NULL)
2722 ThrowMSLException(OptionError,"NoImagesDefined",
2723 (const char *) tag);
2726 if (attributes != (const xmlChar **) NULL)
2727 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2729 keyword=(const char *) attributes[i++];
2730 attribute=InterpretImageProperties(msl_info->image_info[n],
2731 msl_info->attributes[n],(const char *) attributes[i],
2733 CloneString(&value,attribute);
2739 if (LocaleCompare(keyword,"geometry") == 0)
2741 flags=ParseGeometry(value,&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=1.0;
2746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2753 if (LocaleCompare(keyword,"radius") == 0)
2755 geometry_info.rho=InterpretLocaleValue(value,
2759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2771 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2772 geometry_info.sigma,&msl_info->image[n]->exception);
2773 if (edge_image == (Image *) NULL)
2775 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2776 msl_info->image[n]=edge_image;
2779 if (LocaleCompare((const char *) tag,"emboss") == 0)
2787 if (msl_info->image[n] == (Image *) NULL)
2789 ThrowMSLException(OptionError,"NoImagesDefined",
2790 (const char *) tag);
2793 if (attributes != (const xmlChar **) NULL)
2794 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2796 keyword=(const char *) attributes[i++];
2797 attribute=InterpretImageProperties(msl_info->image_info[n],
2798 msl_info->attributes[n],(const char *) attributes[i],
2800 CloneString(&value,attribute);
2806 if (LocaleCompare(keyword,"geometry") == 0)
2808 flags=ParseGeometry(value,&geometry_info);
2809 if ((flags & SigmaValue) == 0)
2810 geometry_info.sigma=1.0;
2813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2820 if (LocaleCompare(keyword,"radius") == 0)
2822 geometry_info.rho=InterpretLocaleValue(value,
2826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2833 if (LocaleCompare(keyword,"sigma") == 0)
2835 geometry_info.sigma=StringToLong(value);
2838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2850 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2851 geometry_info.sigma,&msl_info->image[n]->exception);
2852 if (emboss_image == (Image *) NULL)
2854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2855 msl_info->image[n]=emboss_image;
2858 if (LocaleCompare((const char *) tag,"enhance") == 0)
2866 if (msl_info->image[n] == (Image *) NULL)
2868 ThrowMSLException(OptionError,"NoImagesDefined",
2869 (const char *) tag);
2872 if (attributes != (const xmlChar **) NULL)
2873 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2875 keyword=(const char *) attributes[i++];
2876 attribute=InterpretImageProperties(msl_info->image_info[n],
2877 msl_info->attributes[n],(const char *) attributes[i],
2879 CloneString(&value,attribute);
2880 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2882 enhance_image=EnhanceImage(msl_info->image[n],
2883 &msl_info->image[n]->exception);
2884 if (enhance_image == (Image *) NULL)
2886 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2887 msl_info->image[n]=enhance_image;
2890 if (LocaleCompare((const char *) tag,"equalize") == 0)
2895 if (msl_info->image[n] == (Image *) NULL)
2897 ThrowMSLException(OptionError,"NoImagesDefined",
2898 (const char *) tag);
2901 if (attributes != (const xmlChar **) NULL)
2902 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2904 keyword=(const char *) attributes[i++];
2905 attribute=InterpretImageProperties(msl_info->image_info[n],
2906 msl_info->attributes[n],(const char *) attributes[i],
2908 CloneString(&value,attribute);
2913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2919 (void) EqualizeImage(msl_info->image[n],
2920 &msl_info->image[n]->exception);
2923 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2928 if (LocaleCompare((const char *) tag, "flatten") == 0)
2930 if (msl_info->image[n] == (Image *) NULL)
2932 ThrowMSLException(OptionError,"NoImagesDefined",
2933 (const char *) tag);
2937 /* no attributes here */
2939 /* process the image */
2944 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2945 &msl_info->image[n]->exception);
2946 if (newImage == (Image *) NULL)
2948 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2949 msl_info->image[n]=newImage;
2953 if (LocaleCompare((const char *) tag,"flip") == 0)
2961 if (msl_info->image[n] == (Image *) NULL)
2963 ThrowMSLException(OptionError,"NoImagesDefined",
2964 (const char *) tag);
2967 if (attributes != (const xmlChar **) NULL)
2968 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2970 keyword=(const char *) attributes[i++];
2971 attribute=InterpretImageProperties(msl_info->image_info[n],
2972 msl_info->attributes[n],(const char *) attributes[i],
2974 CloneString(&value,attribute);
2975 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2977 flip_image=FlipImage(msl_info->image[n],
2978 &msl_info->image[n]->exception);
2979 if (flip_image == (Image *) NULL)
2981 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2982 msl_info->image[n]=flip_image;
2985 if (LocaleCompare((const char *) tag,"flop") == 0)
2993 if (msl_info->image[n] == (Image *) NULL)
2995 ThrowMSLException(OptionError,"NoImagesDefined",
2996 (const char *) tag);
2999 if (attributes != (const xmlChar **) NULL)
3000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3002 keyword=(const char *) attributes[i++];
3003 attribute=InterpretImageProperties(msl_info->image_info[n],
3004 msl_info->attributes[n],(const char *) attributes[i],
3006 CloneString(&value,attribute);
3007 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3009 flop_image=FlopImage(msl_info->image[n],
3010 &msl_info->image[n]->exception);
3011 if (flop_image == (Image *) NULL)
3013 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3014 msl_info->image[n]=flop_image;
3017 if (LocaleCompare((const char *) tag,"frame") == 0)
3028 if (msl_info->image[n] == (Image *) NULL)
3030 ThrowMSLException(OptionError,"NoImagesDefined",
3031 (const char *) tag);
3034 SetGeometry(msl_info->image[n],&geometry);
3035 if (attributes != (const xmlChar **) NULL)
3036 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3038 keyword=(const char *) attributes[i++];
3039 attribute=InterpretImageProperties(msl_info->image_info[n],
3040 msl_info->attributes[n],(const char *) attributes[i],
3042 CloneString(&value,attribute);
3048 if (LocaleCompare(keyword,"compose") == 0)
3050 option=ParseCommandOption(MagickComposeOptions,
3053 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3055 msl_info->image[n]->compose=(CompositeOperator) option;
3058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3065 if (LocaleCompare(keyword, "fill") == 0)
3067 (void) QueryColorCompliance(value,AllCompliance,
3068 &msl_info->image[n]->matte_color,&exception);
3071 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3078 if (LocaleCompare(keyword,"geometry") == 0)
3080 flags=ParsePageGeometry(msl_info->image[n],value,
3081 &geometry,&exception);
3082 if ((flags & HeightValue) == 0)
3083 geometry.height=geometry.width;
3084 frame_info.width=geometry.width;
3085 frame_info.height=geometry.height;
3086 frame_info.outer_bevel=geometry.x;
3087 frame_info.inner_bevel=geometry.y;
3090 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3097 if (LocaleCompare(keyword,"height") == 0)
3099 frame_info.height=StringToLong(value);
3102 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3109 if (LocaleCompare(keyword,"inner") == 0)
3111 frame_info.inner_bevel=StringToLong(value);
3114 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3121 if (LocaleCompare(keyword,"outer") == 0)
3123 frame_info.outer_bevel=StringToLong(value);
3126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3133 if (LocaleCompare(keyword,"width") == 0)
3135 frame_info.width=StringToLong(value);
3138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3150 frame_info.x=(ssize_t) frame_info.width;
3151 frame_info.y=(ssize_t) frame_info.height;
3152 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3153 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3154 frame_image=FrameImage(msl_info->image[n],&frame_info,
3155 msl_info->image[n]->compose,&msl_info->image[n]->exception);
3156 if (frame_image == (Image *) NULL)
3158 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3159 msl_info->image[n]=frame_image;
3162 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3167 if (LocaleCompare((const char *) tag,"gamma") == 0)
3170 gamma[MaxTextExtent];
3178 if (msl_info->image[n] == (Image *) NULL)
3180 ThrowMSLException(OptionError,"NoImagesDefined",
3181 (const char *) tag);
3184 channel=UndefinedChannel;
3189 if (attributes != (const xmlChar **) NULL)
3190 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3192 keyword=(const char *) attributes[i++];
3193 attribute=InterpretImageProperties(msl_info->image_info[n],
3194 msl_info->attributes[n],(const char *) attributes[i],
3196 CloneString(&value,attribute);
3202 if (LocaleCompare(keyword,"blue") == 0)
3204 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3214 if (LocaleCompare(keyword,"channel") == 0)
3216 option=ParseChannelOption(value);
3218 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3220 channel=(ChannelType) option;
3223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3230 if (LocaleCompare(keyword,"gamma") == 0)
3232 (void) CopyMagickString(gamma,value,MaxTextExtent);
3235 if (LocaleCompare(keyword,"green") == 0)
3237 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3247 if (LocaleCompare(keyword,"red") == 0)
3249 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3252 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3258 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3265 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3266 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3267 (void) GammaImage(msl_info->image[n],atof(gamma),
3268 &msl_info->image[n]->exception);
3271 else if (LocaleCompare((const char *) tag,"get") == 0)
3273 if (msl_info->image[n] == (Image *) NULL)
3275 ThrowMSLException(OptionError,"NoImagesDefined",
3276 (const char *) tag);
3279 if (attributes == (const xmlChar **) NULL)
3281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3283 keyword=(const char *) attributes[i++];
3284 CloneString(&value,(const char *) attributes[i]);
3285 (void) CopyMagickString(key,value,MaxTextExtent);
3291 if (LocaleCompare(keyword,"height") == 0)
3293 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3294 (double) msl_info->image[n]->rows);
3295 (void) SetImageProperty(msl_info->attributes[n],key,value);
3298 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3303 if (LocaleCompare(keyword,"width") == 0)
3305 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3306 (double) msl_info->image[n]->columns);
3307 (void) SetImageProperty(msl_info->attributes[n],key,value);
3310 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3321 else if (LocaleCompare((const char *) tag, "group") == 0)
3323 msl_info->number_groups++;
3324 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3325 msl_info->group_info,msl_info->number_groups+1UL,
3326 sizeof(*msl_info->group_info));
3329 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3334 if (LocaleCompare((const char *) tag,"image") == 0)
3336 MSLPushImage(msl_info,(Image *) NULL);
3337 if (attributes == (const xmlChar **) NULL)
3339 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3341 keyword=(const char *) attributes[i++];
3342 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3343 msl_info->attributes[n],(const char *) attributes[i],&exception));
3349 if (LocaleCompare(keyword,"color") == 0)
3354 (void) CopyMagickString(msl_info->image_info[n]->filename,
3355 "xc:",MaxTextExtent);
3356 (void) ConcatenateMagickString(msl_info->image_info[n]->
3357 filename,value,MaxTextExtent);
3358 next_image=ReadImage(msl_info->image_info[n],&exception);
3359 CatchException(&exception);
3360 if (next_image == (Image *) NULL)
3362 if (msl_info->image[n] == (Image *) NULL)
3363 msl_info->image[n]=next_image;
3370 Link image into image list.
3372 p=msl_info->image[n];
3373 while (p->next != (Image *) NULL)
3374 p=GetNextImageInList(p);
3375 next_image->previous=p;
3380 (void) SetMSLAttributes(msl_info,keyword,value);
3385 (void) SetMSLAttributes(msl_info,keyword,value);
3392 if (LocaleCompare((const char *) tag,"implode") == 0)
3400 if (msl_info->image[n] == (Image *) NULL)
3402 ThrowMSLException(OptionError,"NoImagesDefined",
3403 (const char *) tag);
3406 if (attributes != (const xmlChar **) NULL)
3407 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3409 keyword=(const char *) attributes[i++];
3410 attribute=InterpretImageProperties(msl_info->image_info[n],
3411 msl_info->attributes[n],(const char *) attributes[i],
3413 CloneString(&value,attribute);
3419 if (LocaleCompare(keyword,"amount") == 0)
3421 geometry_info.rho=InterpretLocaleValue(value,
3425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3432 if (LocaleCompare(keyword,"geometry") == 0)
3434 flags=ParseGeometry(value,&geometry_info);
3435 if ((flags & SigmaValue) == 0)
3436 geometry_info.sigma=1.0;
3439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3445 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3451 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3452 msl_info->image[n]->interpolate,&msl_info->image[n]->exception);
3453 if (implode_image == (Image *) NULL)
3455 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3456 msl_info->image[n]=implode_image;
3459 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3464 if (LocaleCompare((const char *) tag,"label") == 0)
3466 if (LocaleCompare((const char *) tag, "level") == 0)
3469 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3471 if (msl_info->image[n] == (Image *) NULL)
3473 ThrowMSLException(OptionError,"NoImagesDefined",
3474 (const char *) tag);
3477 if (attributes == (const xmlChar **) NULL)
3479 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3481 keyword=(const char *) attributes[i++];
3482 CloneString(&value,(const char *) attributes[i]);
3483 (void) CopyMagickString(key,value,MaxTextExtent);
3489 if (LocaleCompare(keyword,"black") == 0)
3491 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3494 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3500 if (LocaleCompare(keyword,"gamma") == 0)
3502 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3505 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3511 if (LocaleCompare(keyword,"white") == 0)
3513 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3516 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3521 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3528 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3529 &msl_info->image[n]->exception);
3536 if (LocaleCompare((const char *) tag,"magnify") == 0)
3544 if (msl_info->image[n] == (Image *) NULL)
3546 ThrowMSLException(OptionError,"NoImagesDefined",
3547 (const char *) tag);
3550 if (attributes != (const xmlChar **) NULL)
3551 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3553 keyword=(const char *) attributes[i++];
3554 attribute=InterpretImageProperties(msl_info->image_info[n],
3555 msl_info->attributes[n],(const char *) attributes[i],
3557 CloneString(&value,attribute);
3558 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3560 magnify_image=MagnifyImage(msl_info->image[n],
3561 &msl_info->image[n]->exception);
3562 if (magnify_image == (Image *) NULL)
3564 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3565 msl_info->image[n]=magnify_image;
3568 if (LocaleCompare((const char *) tag,"map") == 0)
3582 if (msl_info->image[n] == (Image *) NULL)
3584 ThrowMSLException(OptionError,"NoImagesDefined",
3585 (const char *) tag);
3588 affinity_image=NewImageList();
3590 if (attributes != (const xmlChar **) NULL)
3591 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3593 keyword=(const char *) attributes[i++];
3594 attribute=InterpretImageProperties(msl_info->image_info[n],
3595 msl_info->attributes[n],(const char *) attributes[i],
3597 CloneString(&value,attribute);
3603 if (LocaleCompare(keyword,"dither") == 0)
3605 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3608 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3610 dither=(MagickBooleanType) option;
3613 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3620 if (LocaleCompare(keyword,"image") == 0)
3621 for (j=0; j < msl_info->n; j++)
3626 attribute=GetImageProperty(msl_info->attributes[j],"id");
3627 if ((attribute != (const char *) NULL) &&
3628 (LocaleCompare(attribute,value) == 0))
3630 affinity_image=CloneImage(msl_info->image[j],0,0,
3631 MagickFalse,&exception);
3639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3645 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3646 quantize_info->dither=dither;
3647 (void) RemapImages(quantize_info,msl_info->image[n],
3648 affinity_image,&exception);
3649 quantize_info=DestroyQuantizeInfo(quantize_info);
3650 affinity_image=DestroyImage(affinity_image);
3653 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3665 Matte floodfill image.
3668 if (msl_info->image[n] == (Image *) NULL)
3670 ThrowMSLException(OptionError,"NoImagesDefined",
3671 (const char *) tag);
3674 SetGeometry(msl_info->image[n],&geometry);
3675 paint_method=FloodfillMethod;
3676 if (attributes != (const xmlChar **) NULL)
3677 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3679 keyword=(const char *) attributes[i++];
3680 attribute=InterpretImageProperties(msl_info->image_info[n],
3681 msl_info->attributes[n],(const char *) attributes[i],
3683 CloneString(&value,attribute);
3689 if (LocaleCompare(keyword,"bordercolor") == 0)
3691 (void) QueryMagickColorCompliance(value,AllCompliance,
3692 &target,&exception);
3693 paint_method=FillToBorderMethod;
3696 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3703 if (LocaleCompare(keyword,"fuzz") == 0)
3705 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3716 if (LocaleCompare(keyword,"geometry") == 0)
3718 flags=ParsePageGeometry(msl_info->image[n],value,
3719 &geometry,&exception);
3720 if ((flags & HeightValue) == 0)
3721 geometry.height=geometry.width;
3722 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3723 geometry.x,geometry.y,&target,&exception);
3726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3733 if (LocaleCompare(keyword,"opacity") == 0)
3735 opacity=InterpretLocaleValue(value,(char **) NULL);
3738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3745 if (LocaleCompare(keyword,"x") == 0)
3747 geometry.x=StringToLong(value);
3748 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3749 geometry.x,geometry.y,&target,&exception);
3752 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3759 if (LocaleCompare(keyword,"y") == 0)
3761 geometry.y=StringToLong(value);
3762 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3763 geometry.x,geometry.y,&target,&exception);
3766 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3778 draw_info=CloneDrawInfo(msl_info->image_info[n],
3779 msl_info->draw_info[n]);
3780 draw_info->fill.alpha=ClampToQuantum(opacity);
3781 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3782 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3783 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3784 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
3785 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
3786 draw_info=DestroyDrawInfo(draw_info);
3789 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3795 Median-filter image.
3797 if (msl_info->image[n] == (Image *) NULL)
3799 ThrowMSLException(OptionError,"NoImagesDefined",
3800 (const char *) tag);
3803 if (attributes != (const xmlChar **) NULL)
3804 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3806 keyword=(const char *) attributes[i++];
3807 attribute=InterpretImageProperties(msl_info->image_info[n],
3808 msl_info->attributes[n],(const char *) attributes[i],
3810 CloneString(&value,attribute);
3816 if (LocaleCompare(keyword,"geometry") == 0)
3818 flags=ParseGeometry(value,&geometry_info);
3819 if ((flags & SigmaValue) == 0)
3820 geometry_info.sigma=1.0;
3823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3830 if (LocaleCompare(keyword,"radius") == 0)
3832 geometry_info.rho=InterpretLocaleValue(value,
3836 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3848 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3849 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3850 &msl_info->image[n]->exception);
3851 if (median_image == (Image *) NULL)
3853 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3854 msl_info->image[n]=median_image;
3857 if (LocaleCompare((const char *) tag,"minify") == 0)
3865 if (msl_info->image[n] == (Image *) NULL)
3867 ThrowMSLException(OptionError,"NoImagesDefined",
3868 (const char *) tag);
3871 if (attributes != (const xmlChar **) NULL)
3872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3874 keyword=(const char *) attributes[i++];
3875 attribute=InterpretImageProperties(msl_info->image_info[n],
3876 msl_info->attributes[n],(const char *) attributes[i],
3878 CloneString(&value,attribute);
3879 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3881 minify_image=MinifyImage(msl_info->image[n],
3882 &msl_info->image[n]->exception);
3883 if (minify_image == (Image *) NULL)
3885 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3886 msl_info->image[n]=minify_image;
3889 if (LocaleCompare((const char *) tag,"msl") == 0 )
3891 if (LocaleCompare((const char *) tag,"modulate") == 0)
3894 modulate[MaxTextExtent];
3899 if (msl_info->image[n] == (Image *) NULL)
3901 ThrowMSLException(OptionError,"NoImagesDefined",
3902 (const char *) tag);
3905 geometry_info.rho=100.0;
3906 geometry_info.sigma=100.0;
3907 geometry_info.xi=100.0;
3908 if (attributes != (const xmlChar **) NULL)
3909 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3911 keyword=(const char *) attributes[i++];
3912 attribute=InterpretImageProperties(msl_info->image_info[n],
3913 msl_info->attributes[n],(const char *) attributes[i],
3915 CloneString(&value,attribute);
3921 if (LocaleCompare(keyword,"blackness") == 0)
3923 geometry_info.rho=InterpretLocaleValue(value,
3927 if (LocaleCompare(keyword,"brightness") == 0)
3929 geometry_info.rho=InterpretLocaleValue(value,
3933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3940 if (LocaleCompare(keyword,"factor") == 0)
3942 flags=ParseGeometry(value,&geometry_info);
3945 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3952 if (LocaleCompare(keyword,"hue") == 0)
3954 geometry_info.xi=InterpretLocaleValue(value,
3958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 if (LocaleCompare(keyword,"lightness") == 0)
3967 geometry_info.rho=InterpretLocaleValue(value,
3971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3978 if (LocaleCompare(keyword,"saturation") == 0)
3980 geometry_info.sigma=InterpretLocaleValue(value,
3984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3991 if (LocaleCompare(keyword,"whiteness") == 0)
3993 geometry_info.sigma=InterpretLocaleValue(value,
3997 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4009 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4010 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4011 (void) ModulateImage(msl_info->image[n],modulate,
4012 &msl_info->image[n]->exception);
4015 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4020 if (LocaleCompare((const char *) tag,"negate") == 0)
4028 if (msl_info->image[n] == (Image *) NULL)
4030 ThrowMSLException(OptionError,"NoImagesDefined",
4031 (const char *) tag);
4035 if (attributes != (const xmlChar **) NULL)
4036 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4038 keyword=(const char *) attributes[i++];
4039 attribute=InterpretImageProperties(msl_info->image_info[n],
4040 msl_info->attributes[n],(const char *) attributes[i],
4042 CloneString(&value,attribute);
4048 if (LocaleCompare(keyword,"channel") == 0)
4050 option=ParseChannelOption(value);
4052 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4054 channel=(ChannelType) option;
4057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4064 if (LocaleCompare(keyword,"gray") == 0)
4066 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4069 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4071 gray=(MagickBooleanType) option;
4074 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4086 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4087 (void) NegateImage(msl_info->image[n],gray,
4088 &msl_info->image[n]->exception);
4089 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4092 if (LocaleCompare((const char *) tag,"normalize") == 0)
4097 if (msl_info->image[n] == (Image *) NULL)
4099 ThrowMSLException(OptionError,"NoImagesDefined",
4100 (const char *) tag);
4103 if (attributes != (const xmlChar **) NULL)
4104 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4106 keyword=(const char *) attributes[i++];
4107 attribute=InterpretImageProperties(msl_info->image_info[n],
4108 msl_info->attributes[n],(const char *) attributes[i],
4110 CloneString(&value,attribute);
4116 if (LocaleCompare(keyword,"channel") == 0)
4118 option=ParseChannelOption(value);
4120 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4122 channel=(ChannelType) option;
4125 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4137 (void) NormalizeImage(msl_info->image[n],
4138 &msl_info->image[n]->exception);
4141 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4146 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4154 if (msl_info->image[n] == (Image *) NULL)
4156 ThrowMSLException(OptionError,"NoImagesDefined",
4157 (const char *) tag);
4160 if (attributes != (const xmlChar **) NULL)
4161 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4163 keyword=(const char *) attributes[i++];
4164 attribute=InterpretImageProperties(msl_info->image_info[n],
4165 msl_info->attributes[n],(const char *) attributes[i],
4167 CloneString(&value,attribute);
4173 if (LocaleCompare(keyword,"geometry") == 0)
4175 flags=ParseGeometry(value,&geometry_info);
4176 if ((flags & SigmaValue) == 0)
4177 geometry_info.sigma=1.0;
4180 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4187 if (LocaleCompare(keyword,"radius") == 0)
4189 geometry_info.rho=InterpretLocaleValue(value,
4193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4205 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4206 geometry_info.sigma,&msl_info->image[n]->exception);
4207 if (paint_image == (Image *) NULL)
4209 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4210 msl_info->image[n]=paint_image;
4213 if (LocaleCompare((const char *) tag,"opaque") == 0)
4222 if (msl_info->image[n] == (Image *) NULL)
4224 ThrowMSLException(OptionError,"NoImagesDefined",
4225 (const char *) tag);
4228 (void) QueryMagickColorCompliance("none",AllCompliance,&target,
4230 (void) QueryMagickColorCompliance("none",AllCompliance,&fill_color,
4232 if (attributes != (const xmlChar **) NULL)
4233 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4235 keyword=(const char *) attributes[i++];
4236 attribute=InterpretImageProperties(msl_info->image_info[n],
4237 msl_info->attributes[n],(const char *) attributes[i],
4239 CloneString(&value,attribute);
4245 if (LocaleCompare(keyword,"channel") == 0)
4247 option=ParseChannelOption(value);
4249 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4251 channel=(ChannelType) option;
4254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4261 if (LocaleCompare(keyword,"fill") == 0)
4263 (void) QueryMagickColorCompliance(value,AllCompliance,
4264 &fill_color,&exception);
4267 if (LocaleCompare(keyword,"fuzz") == 0)
4269 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4273 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4279 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4285 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4286 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4287 MagickFalse,&msl_info->image[n]->exception);
4288 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4291 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4296 if (LocaleCompare((const char *) tag,"print") == 0)
4298 if (attributes == (const xmlChar **) NULL)
4300 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4302 keyword=(const char *) attributes[i++];
4303 attribute=InterpretImageProperties(msl_info->image_info[n],
4304 msl_info->attributes[n],(const char *) attributes[i],
4306 CloneString(&value,attribute);
4312 if (LocaleCompare(keyword,"output") == 0)
4314 (void) FormatLocaleFile(stdout,"%s",value);
4317 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4322 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4329 if (LocaleCompare((const char *) tag, "profile") == 0)
4331 if (msl_info->image[n] == (Image *) NULL)
4333 ThrowMSLException(OptionError,"NoImagesDefined",
4334 (const char *) tag);
4337 if (attributes == (const xmlChar **) NULL)
4339 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4353 keyword=(const char *) attributes[i++];
4354 attribute=InterpretImageProperties(msl_info->image_info[n],
4355 msl_info->attributes[n],(const char *) attributes[i],
4357 CloneString(&value,attribute);
4358 if (*keyword == '+')
4361 Remove a profile from the image.
4363 (void) ProfileImage(msl_info->image[n],keyword,
4364 (const unsigned char *) NULL,0,MagickTrue);
4368 Associate a profile with the image.
4370 profile_info=CloneImageInfo(msl_info->image_info[n]);
4371 profile=GetImageProfile(msl_info->image[n],"iptc");
4372 if (profile != (StringInfo *) NULL)
4373 profile_info->profile=(void *) CloneStringInfo(profile);
4374 profile_image=GetImageCache(profile_info,keyword,&exception);
4375 profile_info=DestroyImageInfo(profile_info);
4376 if (profile_image == (Image *) NULL)
4379 name[MaxTextExtent],
4380 filename[MaxTextExtent];
4388 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4389 (void) CopyMagickString(name,keyword,MaxTextExtent);
4390 for (p=filename; *p != '\0'; p++)
4391 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4392 (IsPathAccessible(keyword) == MagickFalse))
4398 Look for profile name (e.g. name:profile).
4400 (void) CopyMagickString(name,filename,(size_t)
4402 for (q=filename; *q != '\0'; q++)
4406 profile=FileToStringInfo(filename,~0UL,&exception);
4407 if (profile != (StringInfo *) NULL)
4409 (void) ProfileImage(msl_info->image[n],name,
4410 GetStringInfoDatum(profile),(size_t)
4411 GetStringInfoLength(profile),MagickFalse);
4412 profile=DestroyStringInfo(profile);
4416 ResetImageProfileIterator(profile_image);
4417 name=GetNextImageProfile(profile_image);
4418 while (name != (const char *) NULL)
4420 profile=GetImageProfile(profile_image,name);
4421 if (profile != (StringInfo *) NULL)
4422 (void) ProfileImage(msl_info->image[n],name,
4423 GetStringInfoDatum(profile),(size_t)
4424 GetStringInfoLength(profile),MagickFalse);
4425 name=GetNextImageProfile(profile_image);
4427 profile_image=DestroyImage(profile_image);
4431 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4436 if (LocaleCompare((const char *) tag,"quantize") == 0)
4444 if (msl_info->image[n] == (Image *) NULL)
4446 ThrowMSLException(OptionError,"NoImagesDefined",
4447 (const char *) tag);
4450 GetQuantizeInfo(&quantize_info);
4451 if (attributes != (const xmlChar **) NULL)
4452 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4454 keyword=(const char *) attributes[i++];
4455 attribute=InterpretImageProperties(msl_info->image_info[n],
4456 msl_info->attributes[n],(const char *) attributes[i],
4458 CloneString(&value,attribute);
4464 if (LocaleCompare(keyword,"colors") == 0)
4466 quantize_info.number_colors=StringToLong(value);
4469 if (LocaleCompare(keyword,"colorspace") == 0)
4471 option=ParseCommandOption(MagickColorspaceOptions,
4474 ThrowMSLException(OptionError,
4475 "UnrecognizedColorspaceType",value);
4476 quantize_info.colorspace=(ColorspaceType) option;
4479 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4486 if (LocaleCompare(keyword,"dither") == 0)
4488 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4491 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4493 quantize_info.dither=(MagickBooleanType) option;
4496 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4503 if (LocaleCompare(keyword,"measure") == 0)
4505 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4508 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4510 quantize_info.measure_error=(MagickBooleanType) option;
4513 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4520 if (LocaleCompare(keyword,"treedepth") == 0)
4522 quantize_info.tree_depth=StringToLong(value);
4525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4531 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4537 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4540 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4543 text[MaxTextExtent];
4554 draw_info=CloneDrawInfo(msl_info->image_info[n],
4555 msl_info->draw_info[n]);
4557 current=draw_info->affine;
4558 GetAffineMatrix(&affine);
4559 if (attributes != (const xmlChar **) NULL)
4560 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4562 keyword=(const char *) attributes[i++];
4563 attribute=InterpretImageProperties(msl_info->image_info[n],
4564 msl_info->attributes[n],(const char *) attributes[i],
4566 CloneString(&value,attribute);
4572 if (LocaleCompare(keyword,"affine") == 0)
4578 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4581 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4584 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4587 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4590 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4593 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4596 if (LocaleCompare(keyword,"align") == 0)
4598 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4601 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4603 draw_info->align=(AlignType) option;
4606 if (LocaleCompare(keyword,"antialias") == 0)
4608 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4611 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4613 draw_info->stroke_antialias=(MagickBooleanType) option;
4614 draw_info->text_antialias=(MagickBooleanType) option;
4617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4624 if (LocaleCompare(keyword,"density") == 0)
4626 CloneString(&draw_info->density,value);
4629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4636 if (LocaleCompare(keyword,"encoding") == 0)
4638 CloneString(&draw_info->encoding,value);
4641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4648 if (LocaleCompare(keyword, "fill") == 0)
4650 (void) QueryColorCompliance(value,AllCompliance,
4651 &draw_info->fill,&exception);
4654 if (LocaleCompare(keyword,"family") == 0)
4656 CloneString(&draw_info->family,value);
4659 if (LocaleCompare(keyword,"font") == 0)
4661 CloneString(&draw_info->font,value);
4664 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4671 if (LocaleCompare(keyword,"geometry") == 0)
4673 flags=ParsePageGeometry(msl_info->image[n],value,
4674 &geometry,&exception);
4675 if ((flags & HeightValue) == 0)
4676 geometry.height=geometry.width;
4679 if (LocaleCompare(keyword,"gravity") == 0)
4681 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4684 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4686 draw_info->gravity=(GravityType) option;
4689 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4696 if (LocaleCompare(keyword,"pointsize") == 0)
4698 draw_info->pointsize=InterpretLocaleValue(value,
4702 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4709 if (LocaleCompare(keyword,"rotate") == 0)
4711 angle=InterpretLocaleValue(value,(char **) NULL);
4712 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4713 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4714 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4715 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4725 if (LocaleCompare(keyword,"scale") == 0)
4727 flags=ParseGeometry(value,&geometry_info);
4728 if ((flags & SigmaValue) == 0)
4729 geometry_info.sigma=1.0;
4730 affine.sx=geometry_info.rho;
4731 affine.sy=geometry_info.sigma;
4734 if (LocaleCompare(keyword,"skewX") == 0)
4736 angle=InterpretLocaleValue(value,(char **) NULL);
4737 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4740 if (LocaleCompare(keyword,"skewY") == 0)
4742 angle=InterpretLocaleValue(value,(char **) NULL);
4743 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4746 if (LocaleCompare(keyword,"stretch") == 0)
4748 option=ParseCommandOption(MagickStretchOptions,
4751 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4753 draw_info->stretch=(StretchType) option;
4756 if (LocaleCompare(keyword, "stroke") == 0)
4758 (void) QueryColorCompliance(value,AllCompliance,
4759 &draw_info->stroke,&exception);
4762 if (LocaleCompare(keyword,"strokewidth") == 0)
4764 draw_info->stroke_width=StringToLong(value);
4767 if (LocaleCompare(keyword,"style") == 0)
4769 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4772 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4774 draw_info->style=(StyleType) option;
4777 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4784 if (LocaleCompare(keyword,"text") == 0)
4786 CloneString(&draw_info->text,value);
4789 if (LocaleCompare(keyword,"translate") == 0)
4791 flags=ParseGeometry(value,&geometry_info);
4792 if ((flags & SigmaValue) == 0)
4793 geometry_info.sigma=1.0;
4794 affine.tx=geometry_info.rho;
4795 affine.ty=geometry_info.sigma;
4798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4805 if (LocaleCompare(keyword, "undercolor") == 0)
4807 (void) QueryColorCompliance(value,AllCompliance,
4808 &draw_info->undercolor,&exception);
4811 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4818 if (LocaleCompare(keyword,"weight") == 0)
4820 draw_info->weight=StringToLong(value);
4823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4830 if (LocaleCompare(keyword,"x") == 0)
4832 geometry.x=StringToLong(value);
4835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4842 if (LocaleCompare(keyword,"y") == 0)
4844 geometry.y=StringToLong(value);
4847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4859 (void) FormatLocaleString(text,MaxTextExtent,
4860 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4861 geometry.height,(double) geometry.x,(double) geometry.y);
4862 CloneString(&draw_info->geometry,text);
4863 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4864 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4865 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4866 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4867 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4869 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4871 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4872 &msl_info->image[n]->exception);
4873 if (status != MagickFalse)
4878 image=msl_info->attributes[n];
4879 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4880 "%g",metrics.pixels_per_em.x);
4881 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4882 "%g",metrics.pixels_per_em.y);
4883 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4885 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4887 FormatImageProperty(image,"msl:font-metrics.width","%g",
4889 FormatImageProperty(image,"msl:font-metrics.height","%g",
4891 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4892 metrics.max_advance);
4893 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4895 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4897 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4899 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4901 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4903 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4906 draw_info=DestroyDrawInfo(draw_info);
4909 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4914 if (LocaleCompare((const char *) tag,"raise") == 0)
4922 if (msl_info->image[n] == (Image *) NULL)
4924 ThrowMSLException(OptionError,"NoImagesDefined",
4925 (const char *) tag);
4929 SetGeometry(msl_info->image[n],&geometry);
4930 if (attributes != (const xmlChar **) NULL)
4931 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4933 keyword=(const char *) attributes[i++];
4934 attribute=InterpretImageProperties(msl_info->image_info[n],
4935 msl_info->attributes[n],(const char *) attributes[i],
4937 CloneString(&value,attribute);
4943 if (LocaleCompare(keyword,"geometry") == 0)
4945 flags=ParsePageGeometry(msl_info->image[n],value,
4946 &geometry,&exception);
4947 if ((flags & HeightValue) == 0)
4948 geometry.height=geometry.width;
4951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4958 if (LocaleCompare(keyword,"height") == 0)
4960 geometry.height=StringToLong(value);
4963 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4970 if (LocaleCompare(keyword,"raise") == 0)
4972 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4975 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4977 raise=(MagickBooleanType) option;
4980 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4987 if (LocaleCompare(keyword,"width") == 0)
4989 geometry.width=StringToLong(value);
4992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5004 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5005 &msl_info->image[n]->exception);
5008 if (LocaleCompare((const char *) tag,"read") == 0)
5010 if (attributes == (const xmlChar **) NULL)
5012 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5014 keyword=(const char *) attributes[i++];
5015 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5016 msl_info->attributes[n],(const char *) attributes[i],&exception));
5022 if (LocaleCompare(keyword,"filename") == 0)
5027 (void) CopyMagickString(msl_info->image_info[n]->filename,
5028 value,MaxTextExtent);
5029 image=ReadImage(msl_info->image_info[n],&exception);
5030 CatchException(&exception);
5031 if (image == (Image *) NULL)
5033 AppendImageToList(&msl_info->image[n],image);
5036 (void) SetMSLAttributes(msl_info,keyword,value);
5041 (void) SetMSLAttributes(msl_info,keyword,value);
5048 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5056 if (msl_info->image[n] == (Image *) NULL)
5058 ThrowMSLException(OptionError,"NoImagesDefined",
5059 (const char *) tag);
5062 if (attributes != (const xmlChar **) NULL)
5063 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5065 keyword=(const char *) attributes[i++];
5066 attribute=InterpretImageProperties(msl_info->image_info[n],
5067 msl_info->attributes[n],(const char *) attributes[i],
5069 CloneString(&value,attribute);
5075 if (LocaleCompare(keyword,"geometry") == 0)
5077 flags=ParseGeometry(value,&geometry_info);
5078 if ((flags & SigmaValue) == 0)
5079 geometry_info.sigma=1.0;
5082 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5089 if (LocaleCompare(keyword,"radius") == 0)
5091 geometry_info.rho=InterpretLocaleValue(value,
5095 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5107 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5108 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5109 &msl_info->image[n]->exception);
5110 if (paint_image == (Image *) NULL)
5112 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5113 msl_info->image[n]=paint_image;
5116 else if (LocaleCompare((const char *) tag,"repage") == 0)
5118 /* init the values */
5119 width=msl_info->image[n]->page.width;
5120 height=msl_info->image[n]->page.height;
5121 x=msl_info->image[n]->page.x;
5122 y=msl_info->image[n]->page.y;
5124 if (msl_info->image[n] == (Image *) NULL)
5126 ThrowMSLException(OptionError,"NoImagesDefined",
5127 (const char *) tag);
5130 if (attributes == (const xmlChar **) NULL)
5132 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5134 keyword=(const char *) attributes[i++];
5135 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5136 msl_info->attributes[n],(const char *) attributes[i],&exception));
5142 if (LocaleCompare(keyword,"geometry") == 0)
5150 flags=ParseAbsoluteGeometry(value,&geometry);
5151 if ((flags & WidthValue) != 0)
5153 if ((flags & HeightValue) == 0)
5154 geometry.height=geometry.width;
5155 width=geometry.width;
5156 height=geometry.height;
5158 if ((flags & AspectValue) != 0)
5160 if ((flags & XValue) != 0)
5162 if ((flags & YValue) != 0)
5167 if ((flags & XValue) != 0)
5170 if ((width == 0) && (geometry.x > 0))
5171 width=msl_info->image[n]->columns+geometry.x;
5173 if ((flags & YValue) != 0)
5176 if ((height == 0) && (geometry.y > 0))
5177 height=msl_info->image[n]->rows+geometry.y;
5182 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5188 if (LocaleCompare(keyword,"height") == 0)
5190 height = StringToLong( value );
5193 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5199 if (LocaleCompare(keyword,"width") == 0)
5201 width = StringToLong( value );
5204 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5210 if (LocaleCompare(keyword,"x") == 0)
5212 x = StringToLong( value );
5215 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5221 if (LocaleCompare(keyword,"y") == 0)
5223 y = StringToLong( value );
5226 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5231 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5237 msl_info->image[n]->page.width=width;
5238 msl_info->image[n]->page.height=height;
5239 msl_info->image[n]->page.x=x;
5240 msl_info->image[n]->page.y=y;
5243 else if (LocaleCompare((const char *) tag,"resample") == 0)
5249 if (msl_info->image[n] == (Image *) NULL)
5251 ThrowMSLException(OptionError,"NoImagesDefined",
5252 (const char *) tag);
5255 if (attributes == (const xmlChar **) NULL)
5257 x_resolution=DefaultResolution;
5258 y_resolution=DefaultResolution;
5259 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5261 keyword=(const char *) attributes[i++];
5262 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5263 msl_info->attributes[n],(const char *) attributes[i],&exception));
5268 if (LocaleCompare(keyword,"blur") == 0)
5270 msl_info->image[n]->blur=InterpretLocaleValue(value,
5274 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5280 if (LocaleCompare(keyword,"geometry") == 0)
5285 flags=ParseGeometry(value,&geometry_info);
5286 if ((flags & SigmaValue) == 0)
5287 geometry_info.sigma*=geometry_info.rho;
5288 x_resolution=geometry_info.rho;
5289 y_resolution=geometry_info.sigma;
5292 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5298 if (LocaleCompare(keyword,"x-resolution") == 0)
5300 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5303 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5309 if (LocaleCompare(keyword,"y-resolution") == 0)
5311 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5319 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5335 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5337 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5338 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5339 msl_info->image[n]->x_resolution))+0.5);
5340 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5341 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5342 msl_info->image[n]->y_resolution))+0.5);
5343 resample_image=ResizeImage(msl_info->image[n],width,height,
5344 msl_info->image[n]->filter,msl_info->image[n]->blur,
5345 &msl_info->image[n]->exception);
5346 if (resample_image == (Image *) NULL)
5348 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5349 msl_info->image[n]=resample_image;
5353 if (LocaleCompare((const char *) tag,"resize") == 0)
5367 if (msl_info->image[n] == (Image *) NULL)
5369 ThrowMSLException(OptionError,"NoImagesDefined",
5370 (const char *) tag);
5373 filter=UndefinedFilter;
5375 if (attributes != (const xmlChar **) NULL)
5376 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5378 keyword=(const char *) attributes[i++];
5379 attribute=InterpretImageProperties(msl_info->image_info[n],
5380 msl_info->attributes[n],(const char *) attributes[i],
5382 CloneString(&value,attribute);
5388 if (LocaleCompare(keyword,"filter") == 0)
5390 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5393 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5395 filter=(FilterTypes) option;
5398 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5405 if (LocaleCompare(keyword,"geometry") == 0)
5407 flags=ParseRegionGeometry(msl_info->image[n],value,
5408 &geometry,&exception);
5411 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5418 if (LocaleCompare(keyword,"height") == 0)
5420 geometry.height=StringToUnsignedLong(value);
5423 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5430 if (LocaleCompare(keyword,"support") == 0)
5432 blur=InterpretLocaleValue(value,(char **) NULL);
5435 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5442 if (LocaleCompare(keyword,"width") == 0)
5444 geometry.width=StringToLong(value);
5447 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5459 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5460 geometry.height,filter,blur,&msl_info->image[n]->exception);
5461 if (resize_image == (Image *) NULL)
5463 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5464 msl_info->image[n]=resize_image;
5467 if (LocaleCompare((const char *) tag,"roll") == 0)
5475 if (msl_info->image[n] == (Image *) NULL)
5477 ThrowMSLException(OptionError,"NoImagesDefined",
5478 (const char *) tag);
5481 SetGeometry(msl_info->image[n],&geometry);
5482 if (attributes != (const xmlChar **) NULL)
5483 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5485 keyword=(const char *) attributes[i++];
5486 attribute=InterpretImageProperties(msl_info->image_info[n],
5487 msl_info->attributes[n],(const char *) attributes[i],
5489 CloneString(&value,attribute);
5495 if (LocaleCompare(keyword,"geometry") == 0)
5497 flags=ParsePageGeometry(msl_info->image[n],value,
5498 &geometry,&exception);
5499 if ((flags & HeightValue) == 0)
5500 geometry.height=geometry.width;
5503 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5510 if (LocaleCompare(keyword,"x") == 0)
5512 geometry.x=StringToLong(value);
5515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5522 if (LocaleCompare(keyword,"y") == 0)
5524 geometry.y=StringToLong(value);
5527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5533 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5539 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5540 &msl_info->image[n]->exception);
5541 if (roll_image == (Image *) NULL)
5543 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5544 msl_info->image[n]=roll_image;
5547 else if (LocaleCompare((const char *) tag,"roll") == 0)
5549 /* init the values */
5550 width=msl_info->image[n]->columns;
5551 height=msl_info->image[n]->rows;
5554 if (msl_info->image[n] == (Image *) NULL)
5556 ThrowMSLException(OptionError,"NoImagesDefined",
5557 (const char *) tag);
5560 if (attributes == (const xmlChar **) NULL)
5562 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5564 keyword=(const char *) attributes[i++];
5565 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5566 msl_info->attributes[n],(const char *) attributes[i],&exception));
5572 if (LocaleCompare(keyword,"geometry") == 0)
5574 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5577 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5583 if (LocaleCompare(keyword,"x") == 0)
5585 x = StringToLong( value );
5588 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5594 if (LocaleCompare(keyword,"y") == 0)
5596 y = StringToLong( value );
5599 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5604 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5617 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5618 if (newImage == (Image *) NULL)
5620 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5621 msl_info->image[n]=newImage;
5626 if (LocaleCompare((const char *) tag,"rotate") == 0)
5634 if (msl_info->image[n] == (Image *) NULL)
5636 ThrowMSLException(OptionError,"NoImagesDefined",
5637 (const char *) tag);
5640 if (attributes != (const xmlChar **) NULL)
5641 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5643 keyword=(const char *) attributes[i++];
5644 attribute=InterpretImageProperties(msl_info->image_info[n],
5645 msl_info->attributes[n],(const char *) attributes[i],
5647 CloneString(&value,attribute);
5653 if (LocaleCompare(keyword,"degrees") == 0)
5655 geometry_info.rho=InterpretLocaleValue(value,
5659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5666 if (LocaleCompare(keyword,"geometry") == 0)
5668 flags=ParseGeometry(value,&geometry_info);
5669 if ((flags & SigmaValue) == 0)
5670 geometry_info.sigma=1.0;
5673 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5685 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5686 &msl_info->image[n]->exception);
5687 if (rotate_image == (Image *) NULL)
5689 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5690 msl_info->image[n]=rotate_image;
5693 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5695 /* init the values */
5698 if (msl_info->image[n] == (Image *) NULL)
5700 ThrowMSLException(OptionError,"NoImagesDefined",
5701 (const char *) tag);
5704 if (attributes == (const xmlChar **) NULL)
5706 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5708 keyword=(const char *) attributes[i++];
5709 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5710 msl_info->attributes[n],(const char *) attributes[i],&exception));
5716 if (LocaleCompare(keyword,"degrees") == 0)
5718 degrees = InterpretLocaleValue(value,(char **) NULL);
5721 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5726 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5739 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5740 if (newImage == (Image *) NULL)
5742 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5743 msl_info->image[n]=newImage;
5748 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5753 if (LocaleCompare((const char *) tag,"sample") == 0)
5761 if (msl_info->image[n] == (Image *) NULL)
5763 ThrowMSLException(OptionError,"NoImagesDefined",
5764 (const char *) tag);
5767 if (attributes != (const xmlChar **) NULL)
5768 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5770 keyword=(const char *) attributes[i++];
5771 attribute=InterpretImageProperties(msl_info->image_info[n],
5772 msl_info->attributes[n],(const char *) attributes[i],
5774 CloneString(&value,attribute);
5780 if (LocaleCompare(keyword,"geometry") == 0)
5782 flags=ParseRegionGeometry(msl_info->image[n],value,
5783 &geometry,&exception);
5786 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5793 if (LocaleCompare(keyword,"height") == 0)
5795 geometry.height=StringToUnsignedLong(value);
5798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5805 if (LocaleCompare(keyword,"width") == 0)
5807 geometry.width=StringToLong(value);
5810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5816 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5822 sample_image=SampleImage(msl_info->image[n],geometry.width,
5823 geometry.height,&msl_info->image[n]->exception);
5824 if (sample_image == (Image *) NULL)
5826 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5827 msl_info->image[n]=sample_image;
5830 if (LocaleCompare((const char *) tag,"scale") == 0)
5838 if (msl_info->image[n] == (Image *) NULL)
5840 ThrowMSLException(OptionError,"NoImagesDefined",
5841 (const char *) tag);
5844 if (attributes != (const xmlChar **) NULL)
5845 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5847 keyword=(const char *) attributes[i++];
5848 attribute=InterpretImageProperties(msl_info->image_info[n],
5849 msl_info->attributes[n],(const char *) attributes[i],
5851 CloneString(&value,attribute);
5857 if (LocaleCompare(keyword,"geometry") == 0)
5859 flags=ParseRegionGeometry(msl_info->image[n],value,
5860 &geometry,&exception);
5863 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5870 if (LocaleCompare(keyword,"height") == 0)
5872 geometry.height=StringToUnsignedLong(value);
5875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5882 if (LocaleCompare(keyword,"width") == 0)
5884 geometry.width=StringToLong(value);
5887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5893 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5899 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5900 geometry.height,&msl_info->image[n]->exception);
5901 if (scale_image == (Image *) NULL)
5903 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5904 msl_info->image[n]=scale_image;
5907 if (LocaleCompare((const char *) tag,"segment") == 0)
5918 if (msl_info->image[n] == (Image *) NULL)
5920 ThrowMSLException(OptionError,"NoImagesDefined",
5921 (const char *) tag);
5924 geometry_info.rho=1.0;
5925 geometry_info.sigma=1.5;
5926 colorspace=RGBColorspace;
5927 verbose=MagickFalse;
5928 if (attributes != (const xmlChar **) NULL)
5929 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5931 keyword=(const char *) attributes[i++];
5932 attribute=InterpretImageProperties(msl_info->image_info[n],
5933 msl_info->attributes[n],(const char *) attributes[i],
5935 CloneString(&value,attribute);
5941 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5943 geometry_info.rho=InterpretLocaleValue(value,
5947 if (LocaleCompare(keyword,"colorspace") == 0)
5949 option=ParseCommandOption(MagickColorspaceOptions,
5952 ThrowMSLException(OptionError,
5953 "UnrecognizedColorspaceType",value);
5954 colorspace=(ColorspaceType) option;
5957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5964 if (LocaleCompare(keyword,"geometry") == 0)
5966 flags=ParseGeometry(value,&geometry_info);
5967 if ((flags & SigmaValue) == 0)
5968 geometry_info.sigma=1.5;
5971 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5978 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5980 geometry_info.sigma=InterpretLocaleValue(value,
5984 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5990 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5996 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5997 geometry_info.rho,geometry_info.sigma,&exception);
6000 else if (LocaleCompare((const char *) tag, "set") == 0)
6002 if (msl_info->image[n] == (Image *) NULL)
6004 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6008 if (attributes == (const xmlChar **) NULL)
6010 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6012 keyword=(const char *) attributes[i++];
6013 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6014 msl_info->attributes[n],(const char *) attributes[i],&exception));
6020 if (LocaleCompare(keyword,"clip-mask") == 0)
6022 for (j=0; j < msl_info->n; j++)
6027 property=GetImageProperty(msl_info->attributes[j],"id");
6028 if (LocaleCompare(property,value) == 0)
6030 SetImageMask(msl_info->image[n],msl_info->image[j],
6037 if (LocaleCompare(keyword,"clip-path") == 0)
6039 for (j=0; j < msl_info->n; j++)
6044 property=GetImageProperty(msl_info->attributes[j],"id");
6045 if (LocaleCompare(property,value) == 0)
6047 SetImageClipMask(msl_info->image[n],msl_info->image[j],
6054 if (LocaleCompare(keyword,"colorspace") == 0)
6059 colorspace=(ColorspaceType) ParseCommandOption(
6060 MagickColorspaceOptions,MagickFalse,value);
6062 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6064 (void) TransformImageColorspace(msl_info->image[n],
6065 (ColorspaceType) colorspace);
6068 (void) SetMSLAttributes(msl_info,keyword,value);
6069 (void) SetImageProperty(msl_info->image[n],keyword,value);
6075 if (LocaleCompare(keyword,"density") == 0)
6077 flags=ParseGeometry(value,&geometry_info);
6078 msl_info->image[n]->x_resolution=geometry_info.rho;
6079 msl_info->image[n]->y_resolution=geometry_info.sigma;
6080 if ((flags & SigmaValue) == 0)
6081 msl_info->image[n]->y_resolution=
6082 msl_info->image[n]->x_resolution;
6085 (void) SetMSLAttributes(msl_info,keyword,value);
6086 (void) SetImageProperty(msl_info->image[n],keyword,value);
6092 if (LocaleCompare(keyword, "opacity") == 0)
6094 ssize_t opac = OpaqueAlpha,
6095 len = (ssize_t) strlen( value );
6097 if (value[len-1] == '%') {
6099 (void) CopyMagickString(tmp,value,len);
6100 opac = StringToLong( tmp );
6101 opac = (int)(QuantumRange * ((float)opac/100));
6103 opac = StringToLong( value );
6104 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac );
6107 (void) SetMSLAttributes(msl_info,keyword,value);
6108 (void) SetImageProperty(msl_info->image[n],keyword,value);
6114 if (LocaleCompare(keyword, "page") == 0)
6117 page[MaxTextExtent];
6128 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6129 image_option=GetImageOption(msl_info->image_info[n],"page");
6130 if (image_option != (const char *) NULL)
6131 flags=ParseAbsoluteGeometry(image_option,&geometry);
6132 flags=ParseAbsoluteGeometry(value,&geometry);
6133 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6134 (double) geometry.width,(double) geometry.height);
6135 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6136 (void) FormatLocaleString(page,MaxTextExtent,
6137 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6138 (double) geometry.height,(double) geometry.x,(double)
6140 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6141 msl_info->image_info[n]->page=GetPageGeometry(page);
6144 (void) SetMSLAttributes(msl_info,keyword,value);
6145 (void) SetImageProperty(msl_info->image[n],keyword,value);
6150 (void) SetMSLAttributes(msl_info,keyword,value);
6151 (void) SetImageProperty(msl_info->image[n],keyword,value);
6158 if (LocaleCompare((const char *) tag,"shade") == 0)
6169 if (msl_info->image[n] == (Image *) NULL)
6171 ThrowMSLException(OptionError,"NoImagesDefined",
6172 (const char *) tag);
6176 if (attributes != (const xmlChar **) NULL)
6177 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6179 keyword=(const char *) attributes[i++];
6180 attribute=InterpretImageProperties(msl_info->image_info[n],
6181 msl_info->attributes[n],(const char *) attributes[i],
6183 CloneString(&value,attribute);
6189 if (LocaleCompare(keyword,"azimuth") == 0)
6191 geometry_info.rho=InterpretLocaleValue(value,
6195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6202 if (LocaleCompare(keyword,"elevation") == 0)
6204 geometry_info.sigma=InterpretLocaleValue(value,
6208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6215 if (LocaleCompare(keyword,"geometry") == 0)
6217 flags=ParseGeometry(value,&geometry_info);
6218 if ((flags & SigmaValue) == 0)
6219 geometry_info.sigma=1.0;
6222 if (LocaleCompare(keyword,"gray") == 0)
6224 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6227 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6229 gray=(MagickBooleanType) option;
6232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6244 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6245 geometry_info.sigma,&msl_info->image[n]->exception);
6246 if (shade_image == (Image *) NULL)
6248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6249 msl_info->image[n]=shade_image;
6252 if (LocaleCompare((const char *) tag,"shadow") == 0)
6260 if (msl_info->image[n] == (Image *) NULL)
6262 ThrowMSLException(OptionError,"NoImagesDefined",
6263 (const char *) tag);
6266 if (attributes != (const xmlChar **) NULL)
6267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6269 keyword=(const char *) attributes[i++];
6270 attribute=InterpretImageProperties(msl_info->image_info[n],
6271 msl_info->attributes[n],(const char *) attributes[i],
6273 CloneString(&value,attribute);
6279 if (LocaleCompare(keyword,"geometry") == 0)
6281 flags=ParseGeometry(value,&geometry_info);
6282 if ((flags & SigmaValue) == 0)
6283 geometry_info.sigma=1.0;
6286 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6293 if (LocaleCompare(keyword,"opacity") == 0)
6295 geometry_info.rho=StringToLong(value);
6298 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6305 if (LocaleCompare(keyword,"sigma") == 0)
6307 geometry_info.sigma=StringToLong(value);
6315 if (LocaleCompare(keyword,"x") == 0)
6317 geometry_info.xi=InterpretLocaleValue(value,
6321 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6328 if (LocaleCompare(keyword,"y") == 0)
6330 geometry_info.psi=StringToLong(value);
6333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6339 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6345 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6346 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6347 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6348 if (shadow_image == (Image *) NULL)
6350 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6351 msl_info->image[n]=shadow_image;
6354 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6360 if (msl_info->image[n] == (Image *) NULL)
6362 ThrowMSLException(OptionError,"NoImagesDefined",
6363 (const char *) tag);
6367 NOTE: sharpen can have no attributes, since we use all the defaults!
6369 if (attributes != (const xmlChar **) NULL)
6371 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6373 keyword=(const char *) attributes[i++];
6374 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6375 msl_info->attributes[n],(const char *) attributes[i],&exception));
6381 if (LocaleCompare(keyword, "bias") == 0)
6383 bias = InterpretLocaleValue(value,(char **) NULL);
6386 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6392 if (LocaleCompare(keyword, "radius") == 0)
6394 radius = InterpretLocaleValue(value,(char **) NULL);
6397 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6403 if (LocaleCompare(keyword,"sigma") == 0)
6405 sigma = StringToLong( value );
6408 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6413 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6427 newImage=SharpenImage(msl_info->image[n],radius,sigma,bias,
6428 &msl_info->image[n]->exception);
6429 if (newImage == (Image *) NULL)
6431 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6432 msl_info->image[n]=newImage;
6436 else if (LocaleCompare((const char *) tag,"shave") == 0)
6438 /* init the values */
6442 if (msl_info->image[n] == (Image *) NULL)
6444 ThrowMSLException(OptionError,"NoImagesDefined",
6445 (const char *) tag);
6448 if (attributes == (const xmlChar **) NULL)
6450 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6452 keyword=(const char *) attributes[i++];
6453 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6454 msl_info->attributes[n],(const char *) attributes[i],&exception));
6460 if (LocaleCompare(keyword,"geometry") == 0)
6462 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6465 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6471 if (LocaleCompare(keyword,"height") == 0)
6473 height = StringToLong( value );
6476 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6482 if (LocaleCompare(keyword,"width") == 0)
6484 width = StringToLong( value );
6487 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6492 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6507 rectInfo.height = height;
6508 rectInfo.width = width;
6513 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6514 &msl_info->image[n]->exception);
6515 if (newImage == (Image *) NULL)
6517 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6518 msl_info->image[n]=newImage;
6523 if (LocaleCompare((const char *) tag,"shear") == 0)
6531 if (msl_info->image[n] == (Image *) NULL)
6533 ThrowMSLException(OptionError,"NoImagesDefined",
6534 (const char *) tag);
6537 if (attributes != (const xmlChar **) NULL)
6538 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6540 keyword=(const char *) attributes[i++];
6541 attribute=InterpretImageProperties(msl_info->image_info[n],
6542 msl_info->attributes[n],(const char *) attributes[i],
6544 CloneString(&value,attribute);
6550 if (LocaleCompare(keyword, "fill") == 0)
6552 (void) QueryColorCompliance(value,AllCompliance,
6553 &msl_info->image[n]->background_color,&exception);
6556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6563 if (LocaleCompare(keyword,"geometry") == 0)
6565 flags=ParseGeometry(value,&geometry_info);
6566 if ((flags & SigmaValue) == 0)
6567 geometry_info.sigma=1.0;
6570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6577 if (LocaleCompare(keyword,"x") == 0)
6579 geometry_info.rho=InterpretLocaleValue(value,
6583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6590 if (LocaleCompare(keyword,"y") == 0)
6592 geometry_info.sigma=StringToLong(value);
6595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6607 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6608 geometry_info.sigma,&msl_info->image[n]->exception);
6609 if (shear_image == (Image *) NULL)
6611 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6612 msl_info->image[n]=shear_image;
6615 if (LocaleCompare((const char *) tag,"signature") == 0)
6620 if (msl_info->image[n] == (Image *) NULL)
6622 ThrowMSLException(OptionError,"NoImagesDefined",
6623 (const char *) tag);
6626 if (attributes != (const xmlChar **) NULL)
6627 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6629 keyword=(const char *) attributes[i++];
6630 attribute=InterpretImageProperties(msl_info->image_info[n],
6631 msl_info->attributes[n],(const char *) attributes[i],
6633 CloneString(&value,attribute);
6638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6644 (void) SignatureImage(msl_info->image[n],&exception);
6647 if (LocaleCompare((const char *) tag,"solarize") == 0)
6652 if (msl_info->image[n] == (Image *) NULL)
6654 ThrowMSLException(OptionError,"NoImagesDefined",
6655 (const char *) tag);
6658 geometry_info.rho=QuantumRange/2.0;
6659 if (attributes != (const xmlChar **) NULL)
6660 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6662 keyword=(const char *) attributes[i++];
6663 attribute=InterpretImageProperties(msl_info->image_info[n],
6664 msl_info->attributes[n],(const char *) attributes[i],
6666 CloneString(&value,attribute);
6672 if (LocaleCompare(keyword,"geometry") == 0)
6674 flags=ParseGeometry(value,&geometry_info);
6677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6684 if (LocaleCompare(keyword,"threshold") == 0)
6686 geometry_info.rho=InterpretLocaleValue(value,
6690 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6696 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6702 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6703 &msl_info->image[n]->exception);
6706 if (LocaleCompare((const char *) tag,"spread") == 0)
6714 if (msl_info->image[n] == (Image *) NULL)
6716 ThrowMSLException(OptionError,"NoImagesDefined",
6717 (const char *) tag);
6720 if (attributes != (const xmlChar **) NULL)
6721 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6723 keyword=(const char *) attributes[i++];
6724 attribute=InterpretImageProperties(msl_info->image_info[n],
6725 msl_info->attributes[n],(const char *) attributes[i],
6727 CloneString(&value,attribute);
6733 if (LocaleCompare(keyword,"geometry") == 0)
6735 flags=ParseGeometry(value,&geometry_info);
6736 if ((flags & SigmaValue) == 0)
6737 geometry_info.sigma=1.0;
6740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6747 if (LocaleCompare(keyword,"radius") == 0)
6749 geometry_info.rho=InterpretLocaleValue(value,
6753 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6765 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6766 msl_info->image[n]->interpolate,&msl_info->image[n]->exception);
6767 if (spread_image == (Image *) NULL)
6769 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6770 msl_info->image[n]=spread_image;
6773 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6776 watermark = (Image*)NULL;
6778 if (msl_info->image[n] == (Image *) NULL)
6780 ThrowMSLException(OptionError,"NoImagesDefined",
6781 (const char *) tag);
6784 if (attributes == (const xmlChar **) NULL)
6786 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6788 keyword=(const char *) attributes[i++];
6789 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6790 msl_info->attributes[n],(const char *) attributes[i],&exception));
6796 if (LocaleCompare(keyword,"image") == 0)
6798 for (j=0; j<msl_info->n;j++)
6801 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6802 if (theAttr && LocaleCompare(theAttr, value) == 0)
6804 watermark = msl_info->image[j];
6810 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6815 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6824 if ( watermark != (Image*) NULL )
6829 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6830 if (newImage == (Image *) NULL)
6832 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6833 msl_info->image[n]=newImage;
6836 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6838 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6841 stereoImage = (Image*)NULL;
6843 if (msl_info->image[n] == (Image *) NULL)
6845 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6848 if (attributes == (const xmlChar **) NULL)
6850 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6852 keyword=(const char *) attributes[i++];
6853 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6854 msl_info->attributes[n],(const char *) attributes[i],&exception));
6860 if (LocaleCompare(keyword,"image") == 0)
6862 for (j=0; j<msl_info->n;j++)
6865 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6866 if (theAttr && LocaleCompare(theAttr, value) == 0)
6868 stereoImage = msl_info->image[j];
6874 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6879 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6888 if ( stereoImage != (Image*) NULL )
6893 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6894 if (newImage == (Image *) NULL)
6896 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6897 msl_info->image[n]=newImage;
6900 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6902 if (LocaleCompare((const char *) tag,"swap") == 0)
6913 if (msl_info->image[n] == (Image *) NULL)
6915 ThrowMSLException(OptionError,"NoImagesDefined",
6916 (const char *) tag);
6921 if (attributes != (const xmlChar **) NULL)
6922 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6924 keyword=(const char *) attributes[i++];
6925 attribute=InterpretImageProperties(msl_info->image_info[n],
6926 msl_info->attributes[n],(const char *) attributes[i],
6928 CloneString(&value,attribute);
6934 if (LocaleCompare(keyword,"indexes") == 0)
6936 flags=ParseGeometry(value,&geometry_info);
6937 index=(ssize_t) geometry_info.rho;
6938 if ((flags & SigmaValue) == 0)
6939 swap_index=(ssize_t) geometry_info.sigma;
6942 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6957 p=GetImageFromList(msl_info->image[n],index);
6958 q=GetImageFromList(msl_info->image[n],swap_index);
6959 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6961 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6964 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6965 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6966 ReplaceImageInList(&q,swap);
6967 msl_info->image[n]=GetFirstImageInList(q);
6970 if (LocaleCompare((const char *) tag,"swirl") == 0)
6978 if (msl_info->image[n] == (Image *) NULL)
6980 ThrowMSLException(OptionError,"NoImagesDefined",
6981 (const char *) tag);
6984 if (attributes != (const xmlChar **) NULL)
6985 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6987 keyword=(const char *) attributes[i++];
6988 attribute=InterpretImageProperties(msl_info->image_info[n],
6989 msl_info->attributes[n],(const char *) attributes[i],
6991 CloneString(&value,attribute);
6997 if (LocaleCompare(keyword,"degrees") == 0)
6999 geometry_info.rho=InterpretLocaleValue(value,
7003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7010 if (LocaleCompare(keyword,"geometry") == 0)
7012 flags=ParseGeometry(value,&geometry_info);
7013 if ((flags & SigmaValue) == 0)
7014 geometry_info.sigma=1.0;
7017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7023 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7029 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7030 msl_info->image[n]->interpolate,&msl_info->image[n]->exception);
7031 if (swirl_image == (Image *) NULL)
7033 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7034 msl_info->image[n]=swirl_image;
7037 if (LocaleCompare((const char *) tag,"sync") == 0)
7042 if (msl_info->image[n] == (Image *) NULL)
7044 ThrowMSLException(OptionError,"NoImagesDefined",
7045 (const char *) tag);
7048 if (attributes != (const xmlChar **) NULL)
7049 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7051 keyword=(const char *) attributes[i++];
7052 attribute=InterpretImageProperties(msl_info->image_info[n],
7053 msl_info->attributes[n],(const char *) attributes[i],
7055 CloneString(&value,attribute);
7060 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7066 (void) SyncImage(msl_info->image[n]);
7069 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7074 if (LocaleCompare((const char *) tag,"map") == 0)
7082 if (msl_info->image[n] == (Image *) NULL)
7084 ThrowMSLException(OptionError,"NoImagesDefined",
7085 (const char *) tag);
7088 texture_image=NewImageList();
7089 if (attributes != (const xmlChar **) NULL)
7090 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7092 keyword=(const char *) attributes[i++];
7093 attribute=InterpretImageProperties(msl_info->image_info[n],
7094 msl_info->attributes[n],(const char *) attributes[i],
7096 CloneString(&value,attribute);
7102 if (LocaleCompare(keyword,"image") == 0)
7103 for (j=0; j < msl_info->n; j++)
7108 attribute=GetImageProperty(msl_info->attributes[j],"id");
7109 if ((attribute != (const char *) NULL) &&
7110 (LocaleCompare(attribute,value) == 0))
7112 texture_image=CloneImage(msl_info->image[j],0,0,
7113 MagickFalse,&exception);
7121 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7127 (void) TextureImage(msl_info->image[n],texture_image);
7128 texture_image=DestroyImage(texture_image);
7131 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7133 /* init the values */
7134 double threshold = 0;
7136 if (msl_info->image[n] == (Image *) NULL)
7138 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7141 if (attributes == (const xmlChar **) NULL)
7143 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7145 keyword=(const char *) attributes[i++];
7146 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7147 msl_info->attributes[n],(const char *) attributes[i],&exception));
7153 if (LocaleCompare(keyword,"threshold") == 0)
7155 threshold = InterpretLocaleValue(value,(char **) NULL);
7158 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7163 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7173 BilevelImage(msl_info->image[n],threshold);
7177 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7179 if (msl_info->image[n] == (Image *) NULL)
7181 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7184 if (attributes == (const xmlChar **) NULL)
7186 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7188 keyword=(const char *) attributes[i++];
7189 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7190 msl_info->attributes[n],(const char *) attributes[i],&exception));
7196 if (LocaleCompare(keyword,"color") == 0)
7201 (void) QueryMagickColorCompliance(value,AllCompliance,&target,
7203 (void) TransparentPaintImage(msl_info->image[n],&target,
7204 TransparentAlpha,MagickFalse,&msl_info->image[n]->exception);
7207 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7212 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7219 else if (LocaleCompare((const char *) tag, "trim") == 0)
7221 if (msl_info->image[n] == (Image *) NULL)
7223 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7227 /* no attributes here */
7229 /* process the image */
7236 /* all zeros on a crop == trim edges! */
7237 rectInfo.height = rectInfo.width = 0;
7238 rectInfo.x = rectInfo.y = 0;
7240 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7241 if (newImage == (Image *) NULL)
7243 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7244 msl_info->image[n]=newImage;
7248 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7253 if (LocaleCompare((const char *) tag,"write") == 0)
7255 if (msl_info->image[n] == (Image *) NULL)
7257 ThrowMSLException(OptionError,"NoImagesDefined",
7258 (const char *) tag);
7261 if (attributes == (const xmlChar **) NULL)
7263 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7265 keyword=(const char *) attributes[i++];
7266 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7267 msl_info->attributes[n],(const char *) attributes[i],&exception));
7273 if (LocaleCompare(keyword,"filename") == 0)
7275 (void) CopyMagickString(msl_info->image[n]->filename,value,
7279 (void) SetMSLAttributes(msl_info,keyword,value);
7283 (void) SetMSLAttributes(msl_info,keyword,value);
7291 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7292 &msl_info->image[n]->exception);
7296 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7300 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7304 if ( value != NULL )
7305 value=DestroyString(value);
7306 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7309 static void MSLEndElement(void *context,const xmlChar *tag)
7318 Called when the end of an element has been detected.
7320 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7322 msl_info=(MSLInfo *) context;
7329 if (LocaleCompare((const char *) tag,"comment") == 0 )
7331 (void) DeleteImageProperty(msl_info->image[n],"comment");
7332 if (msl_info->content == (char *) NULL)
7334 StripString(msl_info->content);
7335 (void) SetImageProperty(msl_info->image[n],"comment",
7344 if (LocaleCompare((const char *) tag, "group") == 0 )
7346 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7348 ssize_t i = (ssize_t)
7349 (msl_info->group_info[msl_info->number_groups-1].numImages);
7352 if (msl_info->image[msl_info->n] != (Image *) NULL)
7353 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7354 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7355 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7359 msl_info->number_groups--;
7366 if (LocaleCompare((const char *) tag, "image") == 0)
7367 MSLPopImage(msl_info);
7373 if (LocaleCompare((const char *) tag,"label") == 0 )
7375 (void) DeleteImageProperty(msl_info->image[n],"label");
7376 if (msl_info->content == (char *) NULL)
7378 StripString(msl_info->content);
7379 (void) SetImageProperty(msl_info->image[n],"label",
7388 if (LocaleCompare((const char *) tag, "msl") == 0 )
7391 This our base element.
7392 at the moment we don't do anything special
7393 but someday we might!
7401 if (msl_info->content != (char *) NULL)
7402 msl_info->content=DestroyString(msl_info->content);
7405 static void MSLCharacters(void *context,const xmlChar *c,int length)
7417 Receiving some characters from the parser.
7419 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7420 " SAX.characters(%s,%d)",c,length);
7421 msl_info=(MSLInfo *) context;
7422 if (msl_info->content != (char *) NULL)
7423 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7424 strlen(msl_info->content)+length+MaxTextExtent,
7425 sizeof(*msl_info->content));
7428 msl_info->content=(char *) NULL;
7429 if (~length >= (MaxTextExtent-1))
7430 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7431 sizeof(*msl_info->content));
7432 if (msl_info->content != (char *) NULL)
7433 *msl_info->content='\0';
7435 if (msl_info->content == (char *) NULL)
7437 p=msl_info->content+strlen(msl_info->content);
7438 for (i=0; i < length; i++)
7443 static void MSLReference(void *context,const xmlChar *name)
7452 Called when an entity reference is detected.
7454 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7455 " SAX.reference(%s)",name);
7456 msl_info=(MSLInfo *) context;
7457 parser=msl_info->parser;
7459 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7461 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7464 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7470 Receiving some ignorable whitespaces from the parser.
7472 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7473 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7474 msl_info=(MSLInfo *) context;
7478 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7479 const xmlChar *data)
7485 A processing instruction has been parsed.
7487 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7488 " SAX.processingInstruction(%s, %s)",
7490 msl_info=(MSLInfo *) context;
7494 static void MSLComment(void *context,const xmlChar *value)
7500 A comment has been parsed.
7502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7503 " SAX.comment(%s)",value);
7504 msl_info=(MSLInfo *) context;
7508 static void MSLWarning(void *context,const char *format,...)
7512 reason[MaxTextExtent];
7521 Display and format a warning messages, gives file, line, position and
7524 va_start(operands,format);
7525 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7526 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7527 msl_info=(MSLInfo *) context;
7529 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7530 (void) vsprintf(reason,format,operands);
7532 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7534 message=GetExceptionMessage(errno);
7535 ThrowMSLException(CoderError,reason,message);
7536 message=DestroyString(message);
7540 static void MSLError(void *context,const char *format,...)
7543 reason[MaxTextExtent];
7552 Display and format a error formats, gives file, line, position and
7555 va_start(operands,format);
7556 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7557 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7558 msl_info=(MSLInfo *) context;
7560 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7561 (void) vsprintf(reason,format,operands);
7563 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7565 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7569 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7581 Called when a pcdata block has been parsed.
7583 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7584 " SAX.pcdata(%s, %d)",value,length);
7585 msl_info=(MSLInfo *) context;
7587 parser=msl_info->parser;
7588 child=xmlGetLastChild(parser->node);
7589 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7591 xmlTextConcat(child,value,length);
7594 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7597 static void MSLExternalSubset(void *context,const xmlChar *name,
7598 const xmlChar *external_id,const xmlChar *system_id)
7613 Does this document has an external subset?
7615 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7616 " SAX.externalSubset(%s %s %s)",name,
7617 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7618 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7619 msl_info=(MSLInfo *) context;
7621 parser=msl_info->parser;
7622 if (((external_id == NULL) && (system_id == NULL)) ||
7623 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7624 (msl_info->document == 0)))
7626 input=MSLResolveEntity(context,external_id,system_id);
7629 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7630 parser_context=(*parser);
7631 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7632 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7634 parser->errNo=XML_ERR_NO_MEMORY;
7635 parser->input=parser_context.input;
7636 parser->inputNr=parser_context.inputNr;
7637 parser->inputMax=parser_context.inputMax;
7638 parser->inputTab=parser_context.inputTab;
7644 xmlPushInput(parser,input);
7645 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7646 if (input->filename == (char *) NULL)
7647 input->filename=(char *) xmlStrdup(system_id);
7650 input->base=parser->input->cur;
7651 input->cur=parser->input->cur;
7653 xmlParseExternalSubset(parser,external_id,system_id);
7654 while (parser->inputNr > 1)
7655 (void) xmlPopInput(parser);
7656 xmlFreeInputStream(parser->input);
7657 xmlFree(parser->inputTab);
7658 parser->input=parser_context.input;
7659 parser->inputNr=parser_context.inputNr;
7660 parser->inputMax=parser_context.inputMax;
7661 parser->inputTab=parser_context.inputTab;
7664 #if defined(__cplusplus) || defined(c_plusplus)
7668 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7669 ExceptionInfo *exception)
7672 message[MaxTextExtent];
7695 assert(image_info != (const ImageInfo *) NULL);
7696 assert(image_info->signature == MagickSignature);
7697 if (image_info->debug != MagickFalse)
7698 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7699 image_info->filename);
7700 assert(image != (Image **) NULL);
7701 msl_image=AcquireImage(image_info,exception);
7702 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7703 if (status == MagickFalse)
7705 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7706 msl_image->filename);
7707 msl_image=DestroyImageList(msl_image);
7708 return(MagickFalse);
7710 msl_image->columns=1;
7715 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7716 msl_info.exception=exception;
7717 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7718 sizeof(*msl_info.image_info));
7719 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7720 sizeof(*msl_info.draw_info));
7721 /* top of the stack is the MSL file itself */
7722 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7723 msl_info.attributes=(Image **) AcquireMagickMemory(
7724 sizeof(*msl_info.attributes));
7725 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7726 sizeof(*msl_info.group_info));
7727 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7728 (msl_info.image == (Image **) NULL) ||
7729 (msl_info.attributes == (Image **) NULL) ||
7730 (msl_info.group_info == (MSLGroupInfo *) NULL))
7731 ThrowFatalException(ResourceLimitFatalError,
7732 "UnableToInterpretMSLImage");
7733 *msl_info.image_info=CloneImageInfo(image_info);
7734 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7735 *msl_info.attributes=AcquireImage(image_info,exception);
7736 msl_info.group_info[0].numImages=0;
7737 /* the first slot is used to point to the MSL file image */
7738 *msl_info.image=msl_image;
7739 if (*image != (Image *) NULL)
7740 MSLPushImage(&msl_info,*image);
7741 (void) xmlSubstituteEntitiesDefault(1);
7742 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7743 sax_modules.internalSubset=MSLInternalSubset;
7744 sax_modules.isStandalone=MSLIsStandalone;
7745 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7746 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7747 sax_modules.resolveEntity=MSLResolveEntity;
7748 sax_modules.getEntity=MSLGetEntity;
7749 sax_modules.entityDecl=MSLEntityDeclaration;
7750 sax_modules.notationDecl=MSLNotationDeclaration;
7751 sax_modules.attributeDecl=MSLAttributeDeclaration;
7752 sax_modules.elementDecl=MSLElementDeclaration;
7753 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7754 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7755 sax_modules.startDocument=MSLStartDocument;
7756 sax_modules.endDocument=MSLEndDocument;
7757 sax_modules.startElement=MSLStartElement;
7758 sax_modules.endElement=MSLEndElement;
7759 sax_modules.reference=MSLReference;
7760 sax_modules.characters=MSLCharacters;
7761 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7762 sax_modules.processingInstruction=MSLProcessingInstructions;
7763 sax_modules.comment=MSLComment;
7764 sax_modules.warning=MSLWarning;
7765 sax_modules.error=MSLError;
7766 sax_modules.fatalError=MSLError;
7767 sax_modules.getParameterEntity=MSLGetParameterEntity;
7768 sax_modules.cdataBlock=MSLCDataBlock;
7769 sax_modules.externalSubset=MSLExternalSubset;
7770 sax_handler=(&sax_modules);
7771 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7772 msl_image->filename);
7773 while (ReadBlobString(msl_image,message) != (char *) NULL)
7775 n=(ssize_t) strlen(message);
7778 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7781 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7782 if (msl_info.exception->severity >= ErrorException)
7785 if (msl_info.exception->severity == UndefinedException)
7786 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7787 xmlFreeParserCtxt(msl_info.parser);
7788 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7790 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7791 msl_info.group_info);
7792 if (*image == (Image *) NULL)
7793 *image=(*msl_info.image);
7794 if ((*msl_info.image)->exception.severity != UndefinedException)
7795 return(MagickFalse);
7799 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7807 assert(image_info != (const ImageInfo *) NULL);
7808 assert(image_info->signature == MagickSignature);
7809 if (image_info->debug != MagickFalse)
7810 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7811 image_info->filename);
7812 assert(exception != (ExceptionInfo *) NULL);
7813 assert(exception->signature == MagickSignature);
7814 image=(Image *) NULL;
7815 (void) ProcessMSLScript(image_info,&image,exception);
7816 return(GetFirstImageInList(image));
7821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7825 % R e g i s t e r M S L I m a g e %
7829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7831 % RegisterMSLImage() adds attributes for the MSL image format to
7832 % the list of supported formats. The attributes include the image format
7833 % tag, a method to read and/or write the format, whether the format
7834 % supports the saving of more than one frame to the same file or blob,
7835 % whether the format supports native in-memory I/O, and a brief
7836 % description of the format.
7838 % The format of the RegisterMSLImage method is:
7840 % size_t RegisterMSLImage(void)
7843 ModuleExport size_t RegisterMSLImage(void)
7848 entry=SetMagickInfo("MSL");
7849 #if defined(MAGICKCORE_XML_DELEGATE)
7850 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7851 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7853 entry->description=ConstantString("Magick Scripting Language");
7854 entry->module=ConstantString("MSL");
7855 (void) RegisterMagickInfo(entry);
7856 return(MagickImageCoderSignature);
7859 #if defined(MAGICKCORE_XML_DELEGATE)
7861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7865 % S e t M S L A t t r i b u t e s %
7869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7871 % SetMSLAttributes() ...
7873 % The format of the SetMSLAttributes method is:
7875 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7876 % const char *keyword,const char *value)
7878 % A description of each parameter follows:
7880 % o msl_info: the MSL info.
7882 % o keyword: the keyword.
7884 % o value: the value.
7887 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7914 assert(msl_info != (MSLInfo *) NULL);
7915 if (keyword == (const char *) NULL)
7917 if (value == (const char *) NULL)
7919 exception=msl_info->exception;
7921 attributes=msl_info->attributes[n];
7922 image_info=msl_info->image_info[n];
7923 draw_info=msl_info->draw_info[n];
7924 image=msl_info->image[n];
7930 if (LocaleCompare(keyword,"adjoin") == 0)
7935 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7937 ThrowMSLException(OptionError,"UnrecognizedType",value);
7938 image_info->adjoin=(MagickBooleanType) adjoin;
7941 if (LocaleCompare(keyword,"alpha") == 0)
7946 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7948 ThrowMSLException(OptionError,"UnrecognizedType",value);
7949 if (image != (Image *) NULL)
7950 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7954 if (LocaleCompare(keyword,"antialias") == 0)
7959 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7961 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7962 image_info->antialias=(MagickBooleanType) antialias;
7965 if (LocaleCompare(keyword,"area-limit") == 0)
7970 limit=MagickResourceInfinity;
7971 if (LocaleCompare(value,"unlimited") != 0)
7972 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7973 (void) SetMagickResourceLimit(AreaResource,limit);
7976 if (LocaleCompare(keyword,"attenuate") == 0)
7978 (void) SetImageOption(image_info,keyword,value);
7981 if (LocaleCompare(keyword,"authenticate") == 0)
7983 (void) CloneString(&image_info->density,value);
7986 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7992 if (LocaleCompare(keyword,"background") == 0)
7994 (void) QueryColorCompliance(value,AllCompliance,
7995 &image_info->background_color,exception);
7998 if (LocaleCompare(keyword,"bias") == 0)
8000 if (image == (Image *) NULL)
8002 image->bias=SiPrefixToDouble(value,QuantumRange);
8005 if (LocaleCompare(keyword,"blue-primary") == 0)
8007 if (image == (Image *) NULL)
8009 flags=ParseGeometry(value,&geometry_info);
8010 image->chromaticity.blue_primary.x=geometry_info.rho;
8011 image->chromaticity.blue_primary.y=geometry_info.sigma;
8012 if ((flags & SigmaValue) == 0)
8013 image->chromaticity.blue_primary.y=
8014 image->chromaticity.blue_primary.x;
8017 if (LocaleCompare(keyword,"bordercolor") == 0)
8019 (void) QueryColorCompliance(value,AllCompliance,
8020 &image_info->border_color,exception);
8023 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8029 if (LocaleCompare(keyword,"density") == 0)
8031 (void) CloneString(&image_info->density,value);
8032 (void) CloneString(&draw_info->density,value);
8035 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8041 if (LocaleCompare(keyword,"fill") == 0)
8043 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8045 (void) SetImageOption(image_info,keyword,value);
8048 if (LocaleCompare(keyword,"filename") == 0)
8050 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8053 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8059 if (LocaleCompare(keyword,"gravity") == 0)
8064 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8066 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8067 (void) SetImageOption(image_info,keyword,value);
8070 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8076 if (LocaleCompare(keyword,"id") == 0)
8078 (void) SetImageProperty(attributes,keyword,value);
8081 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8087 if (LocaleCompare(keyword,"magick") == 0)
8089 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8092 if (LocaleCompare(keyword,"mattecolor") == 0)
8094 (void) QueryColorCompliance(value,AllCompliance,
8095 &image_info->matte_color,exception);
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"pointsize") == 0)
8106 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8107 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8110 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8116 if (LocaleCompare(keyword,"quality") == 0)
8118 image_info->quality=StringToLong(value);
8119 if (image == (Image *) NULL)
8121 image->quality=StringToLong(value);
8129 if (LocaleCompare(keyword,"size") == 0)
8131 (void) CloneString(&image_info->size,value);
8134 if (LocaleCompare(keyword,"stroke") == 0)
8136 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8138 (void) SetImageOption(image_info,keyword,value);
8141 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8146 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8159 % U n r e g i s t e r M S L I m a g e %
8163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8165 % UnregisterMSLImage() removes format registrations made by the
8166 % MSL module from the list of supported formats.
8168 % The format of the UnregisterMSLImage method is:
8170 % UnregisterMSLImage(void)
8173 ModuleExport void UnregisterMSLImage(void)
8175 (void) UnregisterMagickInfo("MSL");
8178 #if defined(MAGICKCORE_XML_DELEGATE)
8180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8184 % W r i t e M S L I m a g e %
8188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8190 % WriteMSLImage() writes an image to a file in MVG image format.
8192 % The format of the WriteMSLImage method is:
8194 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8195 % Image *image,ExceptionInfo *exception)
8197 % A description of each parameter follows.
8199 % o image_info: the image info.
8201 % o image: The image.
8203 % o exception: return any errors or warnings in this structure.
8206 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8207 ExceptionInfo *exception)
8209 assert(image_info != (const ImageInfo *) NULL);
8210 assert(image_info->signature == MagickSignature);
8211 assert(image != (Image *) NULL);
8212 assert(image->signature == MagickSignature);
8213 if (image->debug != MagickFalse)
8214 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8215 (void) ReferenceImage(image);
8216 (void) ProcessMSLScript(image_info,&image,exception);