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/colormap.h"
53 #include "MagickCore/color-private.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 *);
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]);
576 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
577 msl_info->image[n]=(Image *) image;
578 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
579 (msl_info->attributes[n] == (Image *) NULL))
580 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
581 if (msl_info->number_groups != 0)
582 msl_info->group_info[msl_info->number_groups-1].numImages++;
585 static void MSLPopImage(MSLInfo *msl_info)
587 if (msl_info->number_groups != 0)
589 if (msl_info->image[msl_info->n] != (Image *) NULL)
590 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
591 msl_info->attributes[msl_info->n]=DestroyImage(
592 msl_info->attributes[msl_info->n]);
593 msl_info->image_info[msl_info->n]=DestroyImageInfo(
594 msl_info->image_info[msl_info->n]);
598 static void MSLStartElement(void *context,const xmlChar *tag,
599 const xmlChar **attributes)
655 Called when an opening tag has been processed.
657 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
658 " SAX.startElement(%s",tag);
659 GetExceptionInfo(&exception);
660 msl_info=(MSLInfo *) context;
662 keyword=(const char *) NULL;
664 SetGeometryInfo(&geometry_info);
665 channel=DefaultChannels;
671 if (LocaleCompare((const char *) tag,"add-noise") == 0)
682 if (msl_info->image[n] == (Image *) NULL)
684 ThrowMSLException(OptionError,"NoImagesDefined",
689 if (attributes != (const xmlChar **) NULL)
690 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
692 keyword=(const char *) attributes[i++];
693 attribute=InterpretImageProperties(msl_info->image_info[n],
694 msl_info->attributes[n],(const char *) attributes[i]);
695 CloneString(&value,attribute);
701 if (LocaleCompare(keyword,"channel") == 0)
703 option=ParseChannelOption(value);
705 ThrowMSLException(OptionError,"UnrecognizedChannelType",
707 channel=(ChannelType) option;
710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
717 if (LocaleCompare(keyword,"noise") == 0)
719 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
722 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
724 noise=(NoiseType) option;
727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
739 PushPixelChannelMap(msl_info->image[n],channel);
740 noise_image=AddNoiseImage(msl_info->image[n],noise,
741 &msl_info->image[n]->exception);
742 PopPixelChannelMap(msl_info->image[n]);
743 if (noise_image == (Image *) NULL)
745 msl_info->image[n]=DestroyImage(msl_info->image[n]);
746 msl_info->image[n]=noise_image;
749 if (LocaleCompare((const char *) tag,"annotate") == 0)
757 if (msl_info->image[n] == (Image *) NULL)
759 ThrowMSLException(OptionError,"NoImagesDefined",
763 draw_info=CloneDrawInfo(msl_info->image_info[n],
764 msl_info->draw_info[n]);
766 current=draw_info->affine;
767 GetAffineMatrix(&affine);
768 if (attributes != (const xmlChar **) NULL)
769 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
771 keyword=(const char *) attributes[i++];
772 attribute=InterpretImageProperties(msl_info->image_info[n],
773 msl_info->attributes[n],(const char *) attributes[i]);
774 CloneString(&value,attribute);
780 if (LocaleCompare(keyword,"affine") == 0)
786 draw_info->affine.sx=InterpretLocaleValue(p,&p);
789 draw_info->affine.rx=InterpretLocaleValue(p,&p);
792 draw_info->affine.ry=InterpretLocaleValue(p,&p);
795 draw_info->affine.sy=InterpretLocaleValue(p,&p);
798 draw_info->affine.tx=InterpretLocaleValue(p,&p);
801 draw_info->affine.ty=InterpretLocaleValue(p,&p);
804 if (LocaleCompare(keyword,"align") == 0)
806 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
809 ThrowMSLException(OptionError,"UnrecognizedAlignType",
811 draw_info->align=(AlignType) option;
814 if (LocaleCompare(keyword,"antialias") == 0)
816 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
819 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
821 draw_info->stroke_antialias=(MagickBooleanType) option;
822 draw_info->text_antialias=(MagickBooleanType) option;
825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
832 if (LocaleCompare(keyword,"density") == 0)
834 CloneString(&draw_info->density,value);
837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
844 if (LocaleCompare(keyword,"encoding") == 0)
846 CloneString(&draw_info->encoding,value);
849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
856 if (LocaleCompare(keyword, "fill") == 0)
858 (void) QueryColorDatabase(value,&draw_info->fill,
862 if (LocaleCompare(keyword,"family") == 0)
864 CloneString(&draw_info->family,value);
867 if (LocaleCompare(keyword,"font") == 0)
869 CloneString(&draw_info->font,value);
872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
879 if (LocaleCompare(keyword,"geometry") == 0)
881 flags=ParsePageGeometry(msl_info->image[n],value,
882 &geometry,&exception);
883 if ((flags & HeightValue) == 0)
884 geometry.height=geometry.width;
887 if (LocaleCompare(keyword,"gravity") == 0)
889 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
892 ThrowMSLException(OptionError,"UnrecognizedGravityType",
894 draw_info->gravity=(GravityType) option;
897 ThrowMSLException(OptionError,"UnrecognizedAttribute",
904 if (LocaleCompare(keyword,"pointsize") == 0)
906 draw_info->pointsize=InterpretLocaleValue(value,
910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
917 if (LocaleCompare(keyword,"rotate") == 0)
919 angle=InterpretLocaleValue(value,(char **) NULL);
920 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
921 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
922 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
923 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
926 ThrowMSLException(OptionError,"UnrecognizedAttribute",
933 if (LocaleCompare(keyword,"scale") == 0)
935 flags=ParseGeometry(value,&geometry_info);
936 if ((flags & SigmaValue) == 0)
937 geometry_info.sigma=1.0;
938 affine.sx=geometry_info.rho;
939 affine.sy=geometry_info.sigma;
942 if (LocaleCompare(keyword,"skewX") == 0)
944 angle=InterpretLocaleValue(value,(char **) NULL);
945 affine.ry=tan(DegreesToRadians(fmod((double) angle,
949 if (LocaleCompare(keyword,"skewY") == 0)
951 angle=InterpretLocaleValue(value,(char **) NULL);
952 affine.rx=tan(DegreesToRadians(fmod((double) angle,
956 if (LocaleCompare(keyword,"stretch") == 0)
958 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
961 ThrowMSLException(OptionError,"UnrecognizedStretchType",
963 draw_info->stretch=(StretchType) option;
966 if (LocaleCompare(keyword, "stroke") == 0)
968 (void) QueryColorDatabase(value,&draw_info->stroke,
972 if (LocaleCompare(keyword,"strokewidth") == 0)
974 draw_info->stroke_width=StringToLong(value);
977 if (LocaleCompare(keyword,"style") == 0)
979 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
982 ThrowMSLException(OptionError,"UnrecognizedStyleType",
984 draw_info->style=(StyleType) option;
987 ThrowMSLException(OptionError,"UnrecognizedAttribute",
994 if (LocaleCompare(keyword,"text") == 0)
996 CloneString(&draw_info->text,value);
999 if (LocaleCompare(keyword,"translate") == 0)
1001 flags=ParseGeometry(value,&geometry_info);
1002 if ((flags & SigmaValue) == 0)
1003 geometry_info.sigma=1.0;
1004 affine.tx=geometry_info.rho;
1005 affine.ty=geometry_info.sigma;
1008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1015 if (LocaleCompare(keyword, "undercolor") == 0)
1017 (void) QueryColorDatabase(value,&draw_info->undercolor,
1021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1028 if (LocaleCompare(keyword,"weight") == 0)
1030 draw_info->weight=StringToLong(value);
1033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1040 if (LocaleCompare(keyword,"x") == 0)
1042 geometry.x=StringToLong(value);
1045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1052 if (LocaleCompare(keyword,"y") == 0)
1054 geometry.y=StringToLong(value);
1057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1063 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1069 (void) FormatLocaleString(text,MaxTextExtent,
1070 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1071 geometry.height,(double) geometry.x,(double) geometry.y);
1072 CloneString(&draw_info->geometry,text);
1073 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1074 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1075 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1076 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1077 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1079 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1081 (void) AnnotateImage(msl_info->image[n],draw_info);
1082 draw_info=DestroyDrawInfo(draw_info);
1085 if (LocaleCompare((const char *) tag,"append") == 0)
1093 if (msl_info->image[n] == (Image *) NULL)
1095 ThrowMSLException(OptionError,"NoImagesDefined",
1096 (const char *) tag);
1100 if (attributes != (const xmlChar **) NULL)
1101 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1103 keyword=(const char *) attributes[i++];
1104 attribute=InterpretImageProperties(msl_info->image_info[n],
1105 msl_info->attributes[n],(const char *) attributes[i]);
1106 CloneString(&value,attribute);
1112 if (LocaleCompare(keyword,"stack") == 0)
1114 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1117 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1119 stack=(MagickBooleanType) option;
1122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1134 append_image=AppendImages(msl_info->image[n],stack,
1135 &msl_info->image[n]->exception);
1136 if (append_image == (Image *) NULL)
1138 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1139 msl_info->image[n]=append_image;
1142 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1148 if (LocaleCompare((const char *) tag,"blur") == 0)
1156 if (msl_info->image[n] == (Image *) NULL)
1158 ThrowMSLException(OptionError,"NoImagesDefined",
1159 (const char *) tag);
1162 if (attributes != (const xmlChar **) NULL)
1163 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1165 keyword=(const char *) attributes[i++];
1166 attribute=InterpretImageProperties(msl_info->image_info[n],
1167 msl_info->attributes[n],(const char *) attributes[i]);
1168 CloneString(&value,attribute);
1174 if (LocaleCompare(keyword,"channel") == 0)
1176 option=ParseChannelOption(value);
1178 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1180 channel=(ChannelType) option;
1183 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1190 if (LocaleCompare(keyword,"geometry") == 0)
1192 flags=ParseGeometry(value,&geometry_info);
1193 if ((flags & SigmaValue) == 0)
1194 geometry_info.sigma=1.0;
1197 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1204 if (LocaleCompare(keyword,"radius") == 0)
1206 geometry_info.rho=InterpretLocaleValue(value,
1210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1217 if (LocaleCompare(keyword,"sigma") == 0)
1219 geometry_info.sigma=StringToLong(value);
1222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1228 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1234 PushPixelChannelMap(msl_info->image[n],channel);
1235 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1236 geometry_info.sigma,&msl_info->image[n]->exception);
1237 PopPixelChannelMap(msl_info->image[n]);
1238 if (blur_image == (Image *) NULL)
1240 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1241 msl_info->image[n]=blur_image;
1244 if (LocaleCompare((const char *) tag,"border") == 0)
1252 if (msl_info->image[n] == (Image *) NULL)
1254 ThrowMSLException(OptionError,"NoImagesDefined",
1255 (const char *) tag);
1258 SetGeometry(msl_info->image[n],&geometry);
1259 if (attributes != (const xmlChar **) NULL)
1260 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1262 keyword=(const char *) attributes[i++];
1263 attribute=InterpretImageProperties(msl_info->image_info[n],
1264 msl_info->attributes[n],(const char *) attributes[i]);
1265 CloneString(&value,attribute);
1271 if (LocaleCompare(keyword,"compose") == 0)
1273 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1276 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1278 msl_info->image[n]->compose=(CompositeOperator) option;
1281 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1288 if (LocaleCompare(keyword, "fill") == 0)
1290 (void) QueryColorDatabase(value,
1291 &msl_info->image[n]->border_color,&exception);
1294 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1301 if (LocaleCompare(keyword,"geometry") == 0)
1303 flags=ParsePageGeometry(msl_info->image[n],value,
1304 &geometry,&exception);
1305 if ((flags & HeightValue) == 0)
1306 geometry.height=geometry.width;
1309 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1316 if (LocaleCompare(keyword,"height") == 0)
1318 geometry.height=StringToLong(value);
1321 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1328 if (LocaleCompare(keyword,"width") == 0)
1330 geometry.width=StringToLong(value);
1333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1339 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1345 border_image=BorderImage(msl_info->image[n],&geometry,
1346 &msl_info->image[n]->exception);
1347 if (border_image == (Image *) NULL)
1349 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1350 msl_info->image[n]=border_image;
1353 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1358 if (LocaleCompare((const char *) tag,"colorize") == 0)
1361 opacity[MaxTextExtent];
1372 if (msl_info->image[n] == (Image *) NULL)
1374 ThrowMSLException(OptionError,"NoImagesDefined",
1375 (const char *) tag);
1378 target=msl_info->image[n]->background_color;
1379 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1380 if (attributes != (const xmlChar **) NULL)
1381 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1383 keyword=(const char *) attributes[i++];
1384 attribute=InterpretImageProperties(msl_info->image_info[n],
1385 msl_info->attributes[n],(const char *) attributes[i]);
1386 CloneString(&value,attribute);
1392 if (LocaleCompare(keyword,"fill") == 0)
1394 (void) QueryColorDatabase(value,&target,
1395 &msl_info->image[n]->exception);
1398 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1405 if (LocaleCompare(keyword,"opacity") == 0)
1407 (void) CopyMagickString(opacity,value,MaxTextExtent);
1410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1416 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1422 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1423 &msl_info->image[n]->exception);
1424 if (colorize_image == (Image *) NULL)
1426 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1427 msl_info->image[n]=colorize_image;
1430 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1432 double radius = 0.0,
1435 if (msl_info->image[n] == (Image *) NULL)
1437 ThrowMSLException(OptionError,"NoImagesDefined",
1438 (const char *) tag);
1442 NOTE: charcoal can have no attributes, since we use all the defaults!
1444 if (attributes != (const xmlChar **) NULL)
1446 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1448 keyword=(const char *) attributes[i++];
1449 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1450 msl_info->attributes[n],(const char *) attributes[i]));
1456 if (LocaleCompare(keyword, "radius") == 0)
1458 radius = InterpretLocaleValue(value,(char **) NULL);
1461 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1467 if (LocaleCompare(keyword,"sigma") == 0)
1469 sigma = StringToLong( value );
1472 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1477 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1491 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1492 &msl_info->image[n]->exception);
1493 if (newImage == (Image *) NULL)
1495 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1496 msl_info->image[n]=newImage;
1500 if (LocaleCompare((const char *) tag,"chop") == 0)
1508 if (msl_info->image[n] == (Image *) NULL)
1510 ThrowMSLException(OptionError,"NoImagesDefined",
1511 (const char *) tag);
1514 SetGeometry(msl_info->image[n],&geometry);
1515 if (attributes != (const xmlChar **) NULL)
1516 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1518 keyword=(const char *) attributes[i++];
1519 attribute=InterpretImageProperties(msl_info->image_info[n],
1520 msl_info->attributes[n],(const char *) attributes[i]);
1521 CloneString(&value,attribute);
1527 if (LocaleCompare(keyword,"geometry") == 0)
1529 flags=ParsePageGeometry(msl_info->image[n],value,
1530 &geometry,&exception);
1531 if ((flags & HeightValue) == 0)
1532 geometry.height=geometry.width;
1535 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1542 if (LocaleCompare(keyword,"height") == 0)
1544 geometry.height=StringToLong(value);
1547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1554 if (LocaleCompare(keyword,"width") == 0)
1556 geometry.width=StringToLong(value);
1559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1566 if (LocaleCompare(keyword,"x") == 0)
1568 geometry.x=StringToLong(value);
1571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1578 if (LocaleCompare(keyword,"y") == 0)
1580 geometry.y=StringToLong(value);
1583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1595 chop_image=ChopImage(msl_info->image[n],&geometry,
1596 &msl_info->image[n]->exception);
1597 if (chop_image == (Image *) NULL)
1599 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1600 msl_info->image[n]=chop_image;
1603 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1612 Color floodfill image.
1614 if (msl_info->image[n] == (Image *) NULL)
1616 ThrowMSLException(OptionError,"NoImagesDefined",
1617 (const char *) tag);
1620 draw_info=CloneDrawInfo(msl_info->image_info[n],
1621 msl_info->draw_info[n]);
1622 SetGeometry(msl_info->image[n],&geometry);
1623 paint_method=FloodfillMethod;
1624 if (attributes != (const xmlChar **) NULL)
1625 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1627 keyword=(const char *) attributes[i++];
1628 attribute=InterpretImageProperties(msl_info->image_info[n],
1629 msl_info->attributes[n],(const char *) attributes[i]);
1630 CloneString(&value,attribute);
1636 if (LocaleCompare(keyword,"bordercolor") == 0)
1638 (void) QueryMagickColor(value,&target,&exception);
1639 paint_method=FillToBorderMethod;
1642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1649 if (LocaleCompare(keyword,"fill") == 0)
1651 (void) QueryColorDatabase(value,&draw_info->fill,
1655 if (LocaleCompare(keyword,"fuzz") == 0)
1657 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1661 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1668 if (LocaleCompare(keyword,"geometry") == 0)
1670 flags=ParsePageGeometry(msl_info->image[n],value,
1671 &geometry,&exception);
1672 if ((flags & HeightValue) == 0)
1673 geometry.height=geometry.width;
1674 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1675 geometry.x,geometry.y,&target,&exception);
1678 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1685 if (LocaleCompare(keyword,"x") == 0)
1687 geometry.x=StringToLong(value);
1688 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1689 geometry.x,geometry.y,&target,&exception);
1692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1699 if (LocaleCompare(keyword,"y") == 0)
1701 geometry.y=StringToLong(value);
1702 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1703 geometry.x,geometry.y,&target,&exception);
1706 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1718 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1719 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1720 MagickFalse : MagickTrue);
1721 draw_info=DestroyDrawInfo(draw_info);
1724 if (LocaleCompare((const char *) tag,"comment") == 0)
1726 if (LocaleCompare((const char *) tag,"composite") == 0)
1729 composite_geometry[MaxTextExtent];
1744 if (msl_info->image[n] == (Image *) NULL)
1746 ThrowMSLException(OptionError,"NoImagesDefined",
1747 (const char *) tag);
1750 composite_image=NewImageList();
1751 compose=OverCompositeOp;
1752 if (attributes != (const xmlChar **) NULL)
1753 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1755 keyword=(const char *) attributes[i++];
1756 attribute=InterpretImageProperties(msl_info->image_info[n],
1757 msl_info->attributes[n],(const char *) attributes[i]);
1758 CloneString(&value,attribute);
1764 if (LocaleCompare(keyword,"compose") == 0)
1766 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1769 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1771 compose=(CompositeOperator) option;
1779 if (LocaleCompare(keyword,"image") == 0)
1780 for (j=0; j < msl_info->n; j++)
1785 attribute=GetImageProperty(msl_info->attributes[j],"id");
1786 if ((attribute != (const char *) NULL) &&
1787 (LocaleCompare(attribute,value) == 0))
1789 composite_image=CloneImage(msl_info->image[j],0,0,
1790 MagickFalse,&exception);
1800 if (composite_image == (Image *) NULL)
1802 rotate_image=NewImageList();
1803 SetGeometry(msl_info->image[n],&geometry);
1804 if (attributes != (const xmlChar **) NULL)
1805 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1807 keyword=(const char *) attributes[i++];
1808 attribute=InterpretImageProperties(msl_info->image_info[n],
1809 msl_info->attributes[n],(const char *) attributes[i]);
1810 CloneString(&value,attribute);
1816 if (LocaleCompare(keyword,"blend") == 0)
1818 (void) SetImageArtifact(composite_image,
1819 "compose:args",value);
1822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1829 if (LocaleCompare(keyword,"channel") == 0)
1831 option=ParseChannelOption(value);
1833 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1835 channel=(ChannelType) option;
1838 if (LocaleCompare(keyword, "color") == 0)
1840 (void) QueryColorDatabase(value,
1841 &composite_image->background_color,&exception);
1844 if (LocaleCompare(keyword,"compose") == 0)
1846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1853 if (LocaleCompare(keyword,"geometry") == 0)
1855 flags=ParsePageGeometry(msl_info->image[n],value,
1856 &geometry,&exception);
1857 if ((flags & HeightValue) == 0)
1858 geometry.height=geometry.width;
1859 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1860 geometry.y,&target,&exception);
1863 if (LocaleCompare(keyword,"gravity") == 0)
1865 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1868 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1870 msl_info->image[n]->gravity=(GravityType) option;
1873 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1880 if (LocaleCompare(keyword,"image") == 0)
1882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1889 if (LocaleCompare(keyword,"mask") == 0)
1890 for (j=0; j < msl_info->n; j++)
1895 attribute=GetImageProperty(msl_info->attributes[j],"id");
1896 if ((attribute != (const char *) NULL) &&
1897 (LocaleCompare(value,value) == 0))
1899 SetImageType(composite_image,TrueColorMatteType);
1900 (void) CompositeImage(composite_image,
1901 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1912 if (LocaleCompare(keyword,"opacity") == 0)
1927 opacity=StringToLong(value);
1928 if (compose != DissolveCompositeOp)
1930 (void) SetImageOpacity(composite_image,(Quantum)
1934 (void) SetImageArtifact(msl_info->image[n],
1935 "compose:args",value);
1936 if (composite_image->matte != MagickTrue)
1937 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1938 composite_view=AcquireCacheView(composite_image);
1939 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1941 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1942 (ssize_t) composite_image->columns,1,&exception);
1943 for (x=0; x < (ssize_t) composite_image->columns; x++)
1945 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1946 SetPixelAlpha(composite_image,
1947 ClampToQuantum(opacity),q);
1948 q+=GetPixelChannels(composite_image);
1950 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1953 composite_view=DestroyCacheView(composite_view);
1956 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1963 if (LocaleCompare(keyword,"rotate") == 0)
1965 rotate_image=RotateImage(composite_image,
1966 InterpretLocaleValue(value,(char **) NULL),&exception);
1969 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1976 if (LocaleCompare(keyword,"tile") == 0)
1981 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1984 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1986 tile=(MagickBooleanType) option;
1988 if (rotate_image != (Image *) NULL)
1989 (void) SetImageArtifact(rotate_image,
1990 "compose:outside-overlay","false");
1992 (void) SetImageArtifact(composite_image,
1993 "compose:outside-overlay","false");
1994 image=msl_info->image[n];
1995 height=composite_image->rows;
1996 width=composite_image->columns;
1997 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1998 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2000 if (rotate_image != (Image *) NULL)
2001 (void) CompositeImage(image,compose,rotate_image,
2004 (void) CompositeImage(image,compose,
2005 composite_image,x,y);
2007 if (rotate_image != (Image *) NULL)
2008 rotate_image=DestroyImage(rotate_image);
2011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2018 if (LocaleCompare(keyword,"x") == 0)
2020 geometry.x=StringToLong(value);
2021 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2022 geometry.y,&target,&exception);
2025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2032 if (LocaleCompare(keyword,"y") == 0)
2034 geometry.y=StringToLong(value);
2035 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2036 geometry.y,&target,&exception);
2039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2051 image=msl_info->image[n];
2052 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2053 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2054 (double) composite_image->rows,(double) geometry.x,(double)
2056 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2058 PushPixelChannelMap(image,channel);
2059 if (rotate_image == (Image *) NULL)
2060 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
2066 geometry.x-=(ssize_t) (rotate_image->columns-
2067 composite_image->columns)/2;
2068 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2069 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
2070 rotate_image=DestroyImage(rotate_image);
2072 PopPixelChannelMap(image);
2073 composite_image=DestroyImage(composite_image);
2076 if (LocaleCompare((const char *) tag,"contrast") == 0)
2084 if (msl_info->image[n] == (Image *) NULL)
2086 ThrowMSLException(OptionError,"NoImagesDefined",
2087 (const char *) tag);
2090 sharpen=MagickFalse;
2091 if (attributes != (const xmlChar **) NULL)
2092 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2094 keyword=(const char *) attributes[i++];
2095 attribute=InterpretImageProperties(msl_info->image_info[n],
2096 msl_info->attributes[n],(const char *) attributes[i]);
2097 CloneString(&value,attribute);
2103 if (LocaleCompare(keyword,"sharpen") == 0)
2105 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2108 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2110 sharpen=(MagickBooleanType) option;
2113 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2119 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2125 (void) ContrastImage(msl_info->image[n],sharpen);
2128 if (LocaleCompare((const char *) tag,"crop") == 0)
2136 if (msl_info->image[n] == (Image *) NULL)
2138 ThrowMSLException(OptionError,"NoImagesDefined",
2139 (const char *) tag);
2142 SetGeometry(msl_info->image[n],&geometry);
2143 if (attributes != (const xmlChar **) NULL)
2144 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2146 keyword=(const char *) attributes[i++];
2147 attribute=InterpretImageProperties(msl_info->image_info[n],
2148 msl_info->attributes[n],(const char *) attributes[i]);
2149 CloneString(&value,attribute);
2155 if (LocaleCompare(keyword,"geometry") == 0)
2157 flags=ParsePageGeometry(msl_info->image[n],value,
2158 &geometry,&exception);
2159 if ((flags & HeightValue) == 0)
2160 geometry.height=geometry.width;
2163 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2170 if (LocaleCompare(keyword,"height") == 0)
2172 geometry.height=StringToLong(value);
2175 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2182 if (LocaleCompare(keyword,"width") == 0)
2184 geometry.width=StringToLong(value);
2187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2194 if (LocaleCompare(keyword,"x") == 0)
2196 geometry.x=StringToLong(value);
2199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2206 if (LocaleCompare(keyword,"y") == 0)
2208 geometry.y=StringToLong(value);
2211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2223 crop_image=CropImage(msl_info->image[n],&geometry,
2224 &msl_info->image[n]->exception);
2225 if (crop_image == (Image *) NULL)
2227 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2228 msl_info->image[n]=crop_image;
2231 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2237 Cycle-colormap image.
2239 if (msl_info->image[n] == (Image *) NULL)
2241 ThrowMSLException(OptionError,"NoImagesDefined",
2242 (const char *) tag);
2246 if (attributes != (const xmlChar **) NULL)
2247 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2249 keyword=(const char *) attributes[i++];
2250 attribute=InterpretImageProperties(msl_info->image_info[n],
2251 msl_info->attributes[n],(const char *) attributes[i]);
2252 CloneString(&value,attribute);
2258 if (LocaleCompare(keyword,"display") == 0)
2260 display=StringToLong(value);
2263 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2269 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2275 (void) CycleColormapImage(msl_info->image[n],display);
2278 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2283 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2291 if (msl_info->image[n] == (Image *) NULL)
2293 ThrowMSLException(OptionError,"NoImagesDefined",
2294 (const char *) tag);
2297 if (attributes != (const xmlChar **) NULL)
2298 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2300 keyword=(const char *) attributes[i++];
2301 attribute=InterpretImageProperties(msl_info->image_info[n],
2302 msl_info->attributes[n],(const char *) attributes[i]);
2303 CloneString(&value,attribute);
2304 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2306 despeckle_image=DespeckleImage(msl_info->image[n],
2307 &msl_info->image[n]->exception);
2308 if (despeckle_image == (Image *) NULL)
2310 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2311 msl_info->image[n]=despeckle_image;
2314 if (LocaleCompare((const char *) tag,"display") == 0)
2316 if (msl_info->image[n] == (Image *) NULL)
2318 ThrowMSLException(OptionError,"NoImagesDefined",
2319 (const char *) tag);
2322 if (attributes != (const xmlChar **) NULL)
2323 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2325 keyword=(const char *) attributes[i++];
2326 attribute=InterpretImageProperties(msl_info->image_info[n],
2327 msl_info->attributes[n],(const char *) attributes[i]);
2328 CloneString(&value,attribute);
2333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2339 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2342 if (LocaleCompare((const char *) tag,"draw") == 0)
2345 text[MaxTextExtent];
2350 if (msl_info->image[n] == (Image *) NULL)
2352 ThrowMSLException(OptionError,"NoImagesDefined",
2353 (const char *) tag);
2356 draw_info=CloneDrawInfo(msl_info->image_info[n],
2357 msl_info->draw_info[n]);
2359 current=draw_info->affine;
2360 GetAffineMatrix(&affine);
2361 if (attributes != (const xmlChar **) NULL)
2362 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2364 keyword=(const char *) attributes[i++];
2365 attribute=InterpretImageProperties(msl_info->image_info[n],
2366 msl_info->attributes[n],(const char *) attributes[i]);
2367 CloneString(&value,attribute);
2373 if (LocaleCompare(keyword,"affine") == 0)
2379 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2382 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2385 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2388 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2391 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2394 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2397 if (LocaleCompare(keyword,"align") == 0)
2399 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2402 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2404 draw_info->align=(AlignType) option;
2407 if (LocaleCompare(keyword,"antialias") == 0)
2409 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2412 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2414 draw_info->stroke_antialias=(MagickBooleanType) option;
2415 draw_info->text_antialias=(MagickBooleanType) option;
2418 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2425 if (LocaleCompare(keyword,"density") == 0)
2427 CloneString(&draw_info->density,value);
2430 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2437 if (LocaleCompare(keyword,"encoding") == 0)
2439 CloneString(&draw_info->encoding,value);
2442 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2449 if (LocaleCompare(keyword, "fill") == 0)
2451 (void) QueryColorDatabase(value,&draw_info->fill,
2455 if (LocaleCompare(keyword,"family") == 0)
2457 CloneString(&draw_info->family,value);
2460 if (LocaleCompare(keyword,"font") == 0)
2462 CloneString(&draw_info->font,value);
2465 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2472 if (LocaleCompare(keyword,"geometry") == 0)
2474 flags=ParsePageGeometry(msl_info->image[n],value,
2475 &geometry,&exception);
2476 if ((flags & HeightValue) == 0)
2477 geometry.height=geometry.width;
2480 if (LocaleCompare(keyword,"gravity") == 0)
2482 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2485 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2487 draw_info->gravity=(GravityType) option;
2490 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2497 if (LocaleCompare(keyword,"primitive") == 0)
2499 CloneString(&draw_info->primitive,value);
2502 if (LocaleCompare(keyword,"pointsize") == 0)
2504 draw_info->pointsize=InterpretLocaleValue(value,
2508 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2515 if (LocaleCompare(keyword,"rotate") == 0)
2517 angle=InterpretLocaleValue(value,(char **) NULL);
2518 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2519 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2520 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2521 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2524 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2531 if (LocaleCompare(keyword,"scale") == 0)
2533 flags=ParseGeometry(value,&geometry_info);
2534 if ((flags & SigmaValue) == 0)
2535 geometry_info.sigma=1.0;
2536 affine.sx=geometry_info.rho;
2537 affine.sy=geometry_info.sigma;
2540 if (LocaleCompare(keyword,"skewX") == 0)
2542 angle=InterpretLocaleValue(value,(char **) NULL);
2543 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2546 if (LocaleCompare(keyword,"skewY") == 0)
2548 angle=InterpretLocaleValue(value,(char **) NULL);
2549 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2552 if (LocaleCompare(keyword,"stretch") == 0)
2554 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2557 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2559 draw_info->stretch=(StretchType) option;
2562 if (LocaleCompare(keyword, "stroke") == 0)
2564 (void) QueryColorDatabase(value,&draw_info->stroke,
2568 if (LocaleCompare(keyword,"strokewidth") == 0)
2570 draw_info->stroke_width=StringToLong(value);
2573 if (LocaleCompare(keyword,"style") == 0)
2575 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2578 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2580 draw_info->style=(StyleType) option;
2583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2590 if (LocaleCompare(keyword,"text") == 0)
2592 CloneString(&draw_info->text,value);
2595 if (LocaleCompare(keyword,"translate") == 0)
2597 flags=ParseGeometry(value,&geometry_info);
2598 if ((flags & SigmaValue) == 0)
2599 geometry_info.sigma=1.0;
2600 affine.tx=geometry_info.rho;
2601 affine.ty=geometry_info.sigma;
2604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2611 if (LocaleCompare(keyword, "undercolor") == 0)
2613 (void) QueryColorDatabase(value,&draw_info->undercolor,
2617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2624 if (LocaleCompare(keyword,"weight") == 0)
2626 draw_info->weight=StringToLong(value);
2629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2636 if (LocaleCompare(keyword,"x") == 0)
2638 geometry.x=StringToLong(value);
2641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2648 if (LocaleCompare(keyword,"y") == 0)
2650 geometry.y=StringToLong(value);
2653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2665 (void) FormatLocaleString(text,MaxTextExtent,
2666 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2667 geometry.height,(double) geometry.x,(double) geometry.y);
2668 CloneString(&draw_info->geometry,text);
2669 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2670 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2671 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2672 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2673 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2675 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2677 (void) DrawImage(msl_info->image[n],draw_info);
2678 draw_info=DestroyDrawInfo(draw_info);
2681 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2686 if (LocaleCompare((const char *) tag,"edge") == 0)
2694 if (msl_info->image[n] == (Image *) NULL)
2696 ThrowMSLException(OptionError,"NoImagesDefined",
2697 (const char *) tag);
2700 if (attributes != (const xmlChar **) NULL)
2701 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2703 keyword=(const char *) attributes[i++];
2704 attribute=InterpretImageProperties(msl_info->image_info[n],
2705 msl_info->attributes[n],(const char *) attributes[i]);
2706 CloneString(&value,attribute);
2712 if (LocaleCompare(keyword,"geometry") == 0)
2714 flags=ParseGeometry(value,&geometry_info);
2715 if ((flags & SigmaValue) == 0)
2716 geometry_info.sigma=1.0;
2719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2726 if (LocaleCompare(keyword,"radius") == 0)
2728 geometry_info.rho=InterpretLocaleValue(value,
2732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2744 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2745 &msl_info->image[n]->exception);
2746 if (edge_image == (Image *) NULL)
2748 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2749 msl_info->image[n]=edge_image;
2752 if (LocaleCompare((const char *) tag,"emboss") == 0)
2760 if (msl_info->image[n] == (Image *) NULL)
2762 ThrowMSLException(OptionError,"NoImagesDefined",
2763 (const char *) tag);
2766 if (attributes != (const xmlChar **) NULL)
2767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2769 keyword=(const char *) attributes[i++];
2770 attribute=InterpretImageProperties(msl_info->image_info[n],
2771 msl_info->attributes[n],(const char *) attributes[i]);
2772 CloneString(&value,attribute);
2778 if (LocaleCompare(keyword,"geometry") == 0)
2780 flags=ParseGeometry(value,&geometry_info);
2781 if ((flags & SigmaValue) == 0)
2782 geometry_info.sigma=1.0;
2785 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2792 if (LocaleCompare(keyword,"radius") == 0)
2794 geometry_info.rho=InterpretLocaleValue(value,
2798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2805 if (LocaleCompare(keyword,"sigma") == 0)
2807 geometry_info.sigma=StringToLong(value);
2810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2816 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2822 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2823 geometry_info.sigma,&msl_info->image[n]->exception);
2824 if (emboss_image == (Image *) NULL)
2826 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2827 msl_info->image[n]=emboss_image;
2830 if (LocaleCompare((const char *) tag,"enhance") == 0)
2838 if (msl_info->image[n] == (Image *) NULL)
2840 ThrowMSLException(OptionError,"NoImagesDefined",
2841 (const char *) tag);
2844 if (attributes != (const xmlChar **) NULL)
2845 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2847 keyword=(const char *) attributes[i++];
2848 attribute=InterpretImageProperties(msl_info->image_info[n],
2849 msl_info->attributes[n],(const char *) attributes[i]);
2850 CloneString(&value,attribute);
2851 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2853 enhance_image=EnhanceImage(msl_info->image[n],
2854 &msl_info->image[n]->exception);
2855 if (enhance_image == (Image *) NULL)
2857 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2858 msl_info->image[n]=enhance_image;
2861 if (LocaleCompare((const char *) tag,"equalize") == 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]);
2878 CloneString(&value,attribute);
2883 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2889 (void) EqualizeImage(msl_info->image[n]);
2892 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2897 if (LocaleCompare((const char *) tag, "flatten") == 0)
2899 if (msl_info->image[n] == (Image *) NULL)
2901 ThrowMSLException(OptionError,"NoImagesDefined",
2902 (const char *) tag);
2906 /* no attributes here */
2908 /* process the image */
2913 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2914 &msl_info->image[n]->exception);
2915 if (newImage == (Image *) NULL)
2917 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2918 msl_info->image[n]=newImage;
2922 if (LocaleCompare((const char *) tag,"flip") == 0)
2930 if (msl_info->image[n] == (Image *) NULL)
2932 ThrowMSLException(OptionError,"NoImagesDefined",
2933 (const char *) tag);
2936 if (attributes != (const xmlChar **) NULL)
2937 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2939 keyword=(const char *) attributes[i++];
2940 attribute=InterpretImageProperties(msl_info->image_info[n],
2941 msl_info->attributes[n],(const char *) attributes[i]);
2942 CloneString(&value,attribute);
2943 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2945 flip_image=FlipImage(msl_info->image[n],
2946 &msl_info->image[n]->exception);
2947 if (flip_image == (Image *) NULL)
2949 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2950 msl_info->image[n]=flip_image;
2953 if (LocaleCompare((const char *) tag,"flop") == 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]);
2973 CloneString(&value,attribute);
2974 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2976 flop_image=FlopImage(msl_info->image[n],
2977 &msl_info->image[n]->exception);
2978 if (flop_image == (Image *) NULL)
2980 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2981 msl_info->image[n]=flop_image;
2984 if (LocaleCompare((const char *) tag,"frame") == 0)
2995 if (msl_info->image[n] == (Image *) NULL)
2997 ThrowMSLException(OptionError,"NoImagesDefined",
2998 (const char *) tag);
3001 SetGeometry(msl_info->image[n],&geometry);
3002 if (attributes != (const xmlChar **) NULL)
3003 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3005 keyword=(const char *) attributes[i++];
3006 attribute=InterpretImageProperties(msl_info->image_info[n],
3007 msl_info->attributes[n],(const char *) attributes[i]);
3008 CloneString(&value,attribute);
3014 if (LocaleCompare(keyword,"compose") == 0)
3016 option=ParseCommandOption(MagickComposeOptions,
3019 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3021 msl_info->image[n]->compose=(CompositeOperator) option;
3024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3031 if (LocaleCompare(keyword, "fill") == 0)
3033 (void) QueryColorDatabase(value,
3034 &msl_info->image[n]->matte_color,&exception);
3037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3044 if (LocaleCompare(keyword,"geometry") == 0)
3046 flags=ParsePageGeometry(msl_info->image[n],value,
3047 &geometry,&exception);
3048 if ((flags & HeightValue) == 0)
3049 geometry.height=geometry.width;
3050 frame_info.width=geometry.width;
3051 frame_info.height=geometry.height;
3052 frame_info.outer_bevel=geometry.x;
3053 frame_info.inner_bevel=geometry.y;
3056 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3063 if (LocaleCompare(keyword,"height") == 0)
3065 frame_info.height=StringToLong(value);
3068 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3075 if (LocaleCompare(keyword,"inner") == 0)
3077 frame_info.inner_bevel=StringToLong(value);
3080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3087 if (LocaleCompare(keyword,"outer") == 0)
3089 frame_info.outer_bevel=StringToLong(value);
3092 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3099 if (LocaleCompare(keyword,"width") == 0)
3101 frame_info.width=StringToLong(value);
3104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3116 frame_info.x=(ssize_t) frame_info.width;
3117 frame_info.y=(ssize_t) frame_info.height;
3118 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3119 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3120 frame_image=FrameImage(msl_info->image[n],&frame_info,
3121 &msl_info->image[n]->exception);
3122 if (frame_image == (Image *) NULL)
3124 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3125 msl_info->image[n]=frame_image;
3128 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3133 if (LocaleCompare((const char *) tag,"gamma") == 0)
3136 gamma[MaxTextExtent];
3144 if (msl_info->image[n] == (Image *) NULL)
3146 ThrowMSLException(OptionError,"NoImagesDefined",
3147 (const char *) tag);
3150 channel=UndefinedChannel;
3155 if (attributes != (const xmlChar **) NULL)
3156 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3158 keyword=(const char *) attributes[i++];
3159 attribute=InterpretImageProperties(msl_info->image_info[n],
3160 msl_info->attributes[n],(const char *) attributes[i]);
3161 CloneString(&value,attribute);
3167 if (LocaleCompare(keyword,"blue") == 0)
3169 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3172 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3179 if (LocaleCompare(keyword,"channel") == 0)
3181 option=ParseChannelOption(value);
3183 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3185 channel=(ChannelType) option;
3188 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3195 if (LocaleCompare(keyword,"gamma") == 0)
3197 (void) CopyMagickString(gamma,value,MaxTextExtent);
3200 if (LocaleCompare(keyword,"green") == 0)
3202 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3212 if (LocaleCompare(keyword,"red") == 0)
3214 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3230 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3231 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3232 (void) GammaImage(msl_info->image[n],atof(gamma),
3233 &msl_info->image[n]->exception);
3236 else if (LocaleCompare((const char *) tag,"get") == 0)
3238 if (msl_info->image[n] == (Image *) NULL)
3240 ThrowMSLException(OptionError,"NoImagesDefined",
3241 (const char *) tag);
3244 if (attributes == (const xmlChar **) NULL)
3246 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3248 keyword=(const char *) attributes[i++];
3249 CloneString(&value,(const char *) attributes[i]);
3250 (void) CopyMagickString(key,value,MaxTextExtent);
3256 if (LocaleCompare(keyword,"height") == 0)
3258 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3259 (double) msl_info->image[n]->rows);
3260 (void) SetImageProperty(msl_info->attributes[n],key,value);
3263 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3268 if (LocaleCompare(keyword,"width") == 0)
3270 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3271 (double) msl_info->image[n]->columns);
3272 (void) SetImageProperty(msl_info->attributes[n],key,value);
3275 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3279 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3286 else if (LocaleCompare((const char *) tag, "group") == 0)
3288 msl_info->number_groups++;
3289 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3290 msl_info->group_info,msl_info->number_groups+1UL,
3291 sizeof(*msl_info->group_info));
3294 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3299 if (LocaleCompare((const char *) tag,"image") == 0)
3301 MSLPushImage(msl_info,(Image *) NULL);
3302 if (attributes == (const xmlChar **) NULL)
3304 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3306 keyword=(const char *) attributes[i++];
3307 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3308 msl_info->attributes[n],(const char *) attributes[i]));
3314 if (LocaleCompare(keyword,"color") == 0)
3319 (void) CopyMagickString(msl_info->image_info[n]->filename,
3320 "xc:",MaxTextExtent);
3321 (void) ConcatenateMagickString(msl_info->image_info[n]->
3322 filename,value,MaxTextExtent);
3323 next_image=ReadImage(msl_info->image_info[n],&exception);
3324 CatchException(&exception);
3325 if (next_image == (Image *) NULL)
3327 if (msl_info->image[n] == (Image *) NULL)
3328 msl_info->image[n]=next_image;
3335 Link image into image list.
3337 p=msl_info->image[n];
3338 while (p->next != (Image *) NULL)
3339 p=GetNextImageInList(p);
3340 next_image->previous=p;
3345 (void) SetMSLAttributes(msl_info,keyword,value);
3350 (void) SetMSLAttributes(msl_info,keyword,value);
3357 if (LocaleCompare((const char *) tag,"implode") == 0)
3365 if (msl_info->image[n] == (Image *) NULL)
3367 ThrowMSLException(OptionError,"NoImagesDefined",
3368 (const char *) tag);
3371 if (attributes != (const xmlChar **) NULL)
3372 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3374 keyword=(const char *) attributes[i++];
3375 attribute=InterpretImageProperties(msl_info->image_info[n],
3376 msl_info->attributes[n],(const char *) attributes[i]);
3377 CloneString(&value,attribute);
3383 if (LocaleCompare(keyword,"amount") == 0)
3385 geometry_info.rho=InterpretLocaleValue(value,
3389 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3396 if (LocaleCompare(keyword,"geometry") == 0)
3398 flags=ParseGeometry(value,&geometry_info);
3399 if ((flags & SigmaValue) == 0)
3400 geometry_info.sigma=1.0;
3403 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3415 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3416 &msl_info->image[n]->exception);
3417 if (implode_image == (Image *) NULL)
3419 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3420 msl_info->image[n]=implode_image;
3423 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3428 if (LocaleCompare((const char *) tag,"label") == 0)
3430 if (LocaleCompare((const char *) tag, "level") == 0)
3433 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3435 if (msl_info->image[n] == (Image *) NULL)
3437 ThrowMSLException(OptionError,"NoImagesDefined",
3438 (const char *) tag);
3441 if (attributes == (const xmlChar **) NULL)
3443 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3445 keyword=(const char *) attributes[i++];
3446 CloneString(&value,(const char *) attributes[i]);
3447 (void) CopyMagickString(key,value,MaxTextExtent);
3453 if (LocaleCompare(keyword,"black") == 0)
3455 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3458 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3464 if (LocaleCompare(keyword,"gamma") == 0)
3466 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3475 if (LocaleCompare(keyword,"white") == 0)
3477 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3480 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3485 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3492 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma);
3499 if (LocaleCompare((const char *) tag,"magnify") == 0)
3507 if (msl_info->image[n] == (Image *) NULL)
3509 ThrowMSLException(OptionError,"NoImagesDefined",
3510 (const char *) tag);
3513 if (attributes != (const xmlChar **) NULL)
3514 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3516 keyword=(const char *) attributes[i++];
3517 attribute=InterpretImageProperties(msl_info->image_info[n],
3518 msl_info->attributes[n],(const char *) attributes[i]);
3519 CloneString(&value,attribute);
3520 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3522 magnify_image=MagnifyImage(msl_info->image[n],
3523 &msl_info->image[n]->exception);
3524 if (magnify_image == (Image *) NULL)
3526 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3527 msl_info->image[n]=magnify_image;
3530 if (LocaleCompare((const char *) tag,"map") == 0)
3544 if (msl_info->image[n] == (Image *) NULL)
3546 ThrowMSLException(OptionError,"NoImagesDefined",
3547 (const char *) tag);
3550 affinity_image=NewImageList();
3552 if (attributes != (const xmlChar **) NULL)
3553 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3555 keyword=(const char *) attributes[i++];
3556 attribute=InterpretImageProperties(msl_info->image_info[n],
3557 msl_info->attributes[n],(const char *) attributes[i]);
3558 CloneString(&value,attribute);
3564 if (LocaleCompare(keyword,"dither") == 0)
3566 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3569 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3571 dither=(MagickBooleanType) option;
3574 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3581 if (LocaleCompare(keyword,"image") == 0)
3582 for (j=0; j < msl_info->n; j++)
3587 attribute=GetImageProperty(msl_info->attributes[j],"id");
3588 if ((attribute != (const char *) NULL) &&
3589 (LocaleCompare(attribute,value) == 0))
3591 affinity_image=CloneImage(msl_info->image[j],0,0,
3592 MagickFalse,&exception);
3600 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3606 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3607 quantize_info->dither=dither;
3608 (void) RemapImages(quantize_info,msl_info->image[n],
3610 quantize_info=DestroyQuantizeInfo(quantize_info);
3611 affinity_image=DestroyImage(affinity_image);
3614 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3626 Matte floodfill image.
3629 if (msl_info->image[n] == (Image *) NULL)
3631 ThrowMSLException(OptionError,"NoImagesDefined",
3632 (const char *) tag);
3635 SetGeometry(msl_info->image[n],&geometry);
3636 paint_method=FloodfillMethod;
3637 if (attributes != (const xmlChar **) NULL)
3638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3640 keyword=(const char *) attributes[i++];
3641 attribute=InterpretImageProperties(msl_info->image_info[n],
3642 msl_info->attributes[n],(const char *) attributes[i]);
3643 CloneString(&value,attribute);
3649 if (LocaleCompare(keyword,"bordercolor") == 0)
3651 (void) QueryMagickColor(value,&target,&exception);
3652 paint_method=FillToBorderMethod;
3655 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3662 if (LocaleCompare(keyword,"fuzz") == 0)
3664 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3675 if (LocaleCompare(keyword,"geometry") == 0)
3677 flags=ParsePageGeometry(msl_info->image[n],value,
3678 &geometry,&exception);
3679 if ((flags & HeightValue) == 0)
3680 geometry.height=geometry.width;
3681 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3682 geometry.x,geometry.y,&target,&exception);
3685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3692 if (LocaleCompare(keyword,"opacity") == 0)
3694 opacity=InterpretLocaleValue(value,(char **) NULL);
3697 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3704 if (LocaleCompare(keyword,"x") == 0)
3706 geometry.x=StringToLong(value);
3707 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3708 geometry.x,geometry.y,&target,&exception);
3711 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3718 if (LocaleCompare(keyword,"y") == 0)
3720 geometry.y=StringToLong(value);
3721 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3722 geometry.x,geometry.y,&target,&exception);
3725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3737 draw_info=CloneDrawInfo(msl_info->image_info[n],
3738 msl_info->draw_info[n]);
3739 draw_info->fill.alpha=ClampToQuantum(opacity);
3740 PushPixelChannelMap(msl_info->image[n],AlphaChannel);
3741 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3742 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3743 MagickFalse : MagickTrue);
3744 PopPixelChannelMap(msl_info->image[n]);
3745 draw_info=DestroyDrawInfo(draw_info);
3748 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3754 Median-filter image.
3756 if (msl_info->image[n] == (Image *) NULL)
3758 ThrowMSLException(OptionError,"NoImagesDefined",
3759 (const char *) tag);
3762 if (attributes != (const xmlChar **) NULL)
3763 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3765 keyword=(const char *) attributes[i++];
3766 attribute=InterpretImageProperties(msl_info->image_info[n],
3767 msl_info->attributes[n],(const char *) attributes[i]);
3768 CloneString(&value,attribute);
3774 if (LocaleCompare(keyword,"geometry") == 0)
3776 flags=ParseGeometry(value,&geometry_info);
3777 if ((flags & SigmaValue) == 0)
3778 geometry_info.sigma=1.0;
3781 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3788 if (LocaleCompare(keyword,"radius") == 0)
3790 geometry_info.rho=InterpretLocaleValue(value,
3794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3806 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3807 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3808 &msl_info->image[n]->exception);
3809 if (median_image == (Image *) NULL)
3811 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3812 msl_info->image[n]=median_image;
3815 if (LocaleCompare((const char *) tag,"minify") == 0)
3823 if (msl_info->image[n] == (Image *) NULL)
3825 ThrowMSLException(OptionError,"NoImagesDefined",
3826 (const char *) tag);
3829 if (attributes != (const xmlChar **) NULL)
3830 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3832 keyword=(const char *) attributes[i++];
3833 attribute=InterpretImageProperties(msl_info->image_info[n],
3834 msl_info->attributes[n],(const char *) attributes[i]);
3835 CloneString(&value,attribute);
3836 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3838 minify_image=MinifyImage(msl_info->image[n],
3839 &msl_info->image[n]->exception);
3840 if (minify_image == (Image *) NULL)
3842 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3843 msl_info->image[n]=minify_image;
3846 if (LocaleCompare((const char *) tag,"msl") == 0 )
3848 if (LocaleCompare((const char *) tag,"modulate") == 0)
3851 modulate[MaxTextExtent];
3856 if (msl_info->image[n] == (Image *) NULL)
3858 ThrowMSLException(OptionError,"NoImagesDefined",
3859 (const char *) tag);
3862 geometry_info.rho=100.0;
3863 geometry_info.sigma=100.0;
3864 geometry_info.xi=100.0;
3865 if (attributes != (const xmlChar **) NULL)
3866 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3868 keyword=(const char *) attributes[i++];
3869 attribute=InterpretImageProperties(msl_info->image_info[n],
3870 msl_info->attributes[n],(const char *) attributes[i]);
3871 CloneString(&value,attribute);
3877 if (LocaleCompare(keyword,"blackness") == 0)
3879 geometry_info.rho=InterpretLocaleValue(value,
3883 if (LocaleCompare(keyword,"brightness") == 0)
3885 geometry_info.rho=InterpretLocaleValue(value,
3889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3896 if (LocaleCompare(keyword,"factor") == 0)
3898 flags=ParseGeometry(value,&geometry_info);
3901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3908 if (LocaleCompare(keyword,"hue") == 0)
3910 geometry_info.xi=InterpretLocaleValue(value,
3914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3921 if (LocaleCompare(keyword,"lightness") == 0)
3923 geometry_info.rho=InterpretLocaleValue(value,
3927 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3934 if (LocaleCompare(keyword,"saturation") == 0)
3936 geometry_info.sigma=InterpretLocaleValue(value,
3940 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3947 if (LocaleCompare(keyword,"whiteness") == 0)
3949 geometry_info.sigma=InterpretLocaleValue(value,
3953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3966 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3967 (void) ModulateImage(msl_info->image[n],modulate);
3970 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3975 if (LocaleCompare((const char *) tag,"negate") == 0)
3983 if (msl_info->image[n] == (Image *) NULL)
3985 ThrowMSLException(OptionError,"NoImagesDefined",
3986 (const char *) tag);
3990 if (attributes != (const xmlChar **) NULL)
3991 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3993 keyword=(const char *) attributes[i++];
3994 attribute=InterpretImageProperties(msl_info->image_info[n],
3995 msl_info->attributes[n],(const char *) attributes[i]);
3996 CloneString(&value,attribute);
4002 if (LocaleCompare(keyword,"channel") == 0)
4004 option=ParseChannelOption(value);
4006 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4008 channel=(ChannelType) option;
4011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4018 if (LocaleCompare(keyword,"gray") == 0)
4020 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4023 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4025 gray=(MagickBooleanType) option;
4028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4040 PushPixelChannelMap(msl_info->image[n],channel);
4041 (void) NegateImage(msl_info->image[n],gray,
4042 &msl_info->image[n]->exception);
4043 PopPixelChannelMap(msl_info->image[n]);
4046 if (LocaleCompare((const char *) tag,"normalize") == 0)
4051 if (msl_info->image[n] == (Image *) NULL)
4053 ThrowMSLException(OptionError,"NoImagesDefined",
4054 (const char *) tag);
4057 if (attributes != (const xmlChar **) NULL)
4058 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4060 keyword=(const char *) attributes[i++];
4061 attribute=InterpretImageProperties(msl_info->image_info[n],
4062 msl_info->attributes[n],(const char *) attributes[i]);
4063 CloneString(&value,attribute);
4069 if (LocaleCompare(keyword,"channel") == 0)
4071 option=ParseChannelOption(value);
4073 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4075 channel=(ChannelType) option;
4078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4084 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4090 (void) NormalizeImage(msl_info->image[n]);
4093 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4098 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4106 if (msl_info->image[n] == (Image *) NULL)
4108 ThrowMSLException(OptionError,"NoImagesDefined",
4109 (const char *) tag);
4112 if (attributes != (const xmlChar **) NULL)
4113 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4115 keyword=(const char *) attributes[i++];
4116 attribute=InterpretImageProperties(msl_info->image_info[n],
4117 msl_info->attributes[n],(const char *) attributes[i]);
4118 CloneString(&value,attribute);
4124 if (LocaleCompare(keyword,"geometry") == 0)
4126 flags=ParseGeometry(value,&geometry_info);
4127 if ((flags & SigmaValue) == 0)
4128 geometry_info.sigma=1.0;
4131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4138 if (LocaleCompare(keyword,"radius") == 0)
4140 geometry_info.rho=InterpretLocaleValue(value,
4144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4150 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4156 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4157 &msl_info->image[n]->exception);
4158 if (paint_image == (Image *) NULL)
4160 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4161 msl_info->image[n]=paint_image;
4164 if (LocaleCompare((const char *) tag,"opaque") == 0)
4173 if (msl_info->image[n] == (Image *) NULL)
4175 ThrowMSLException(OptionError,"NoImagesDefined",
4176 (const char *) tag);
4179 (void) QueryMagickColor("none",&target,&exception);
4180 (void) QueryMagickColor("none",&fill_color,&exception);
4181 if (attributes != (const xmlChar **) NULL)
4182 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4184 keyword=(const char *) attributes[i++];
4185 attribute=InterpretImageProperties(msl_info->image_info[n],
4186 msl_info->attributes[n],(const char *) attributes[i]);
4187 CloneString(&value,attribute);
4193 if (LocaleCompare(keyword,"channel") == 0)
4195 option=ParseChannelOption(value);
4197 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4199 channel=(ChannelType) option;
4202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4209 if (LocaleCompare(keyword,"fill") == 0)
4211 (void) QueryMagickColor(value,&fill_color,&exception);
4214 if (LocaleCompare(keyword,"fuzz") == 0)
4216 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4232 PushPixelChannelMap(msl_info->image[n],channel);
4233 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4235 PopPixelChannelMap(msl_info->image[n]);
4238 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4243 if (LocaleCompare((const char *) tag,"print") == 0)
4245 if (attributes == (const xmlChar **) NULL)
4247 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4249 keyword=(const char *) attributes[i++];
4250 attribute=InterpretImageProperties(msl_info->image_info[n],
4251 msl_info->attributes[n],(const char *) attributes[i]);
4252 CloneString(&value,attribute);
4258 if (LocaleCompare(keyword,"output") == 0)
4260 (void) FormatLocaleFile(stdout,"%s",value);
4263 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4268 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4275 if (LocaleCompare((const char *) tag, "profile") == 0)
4277 if (msl_info->image[n] == (Image *) NULL)
4279 ThrowMSLException(OptionError,"NoImagesDefined",
4280 (const char *) tag);
4283 if (attributes == (const xmlChar **) NULL)
4285 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4299 keyword=(const char *) attributes[i++];
4300 attribute=InterpretImageProperties(msl_info->image_info[n],
4301 msl_info->attributes[n],(const char *) attributes[i]);
4302 CloneString(&value,attribute);
4303 if (*keyword == '+')
4306 Remove a profile from the image.
4308 (void) ProfileImage(msl_info->image[n],keyword,
4309 (const unsigned char *) NULL,0,MagickTrue);
4313 Associate a profile with the image.
4315 profile_info=CloneImageInfo(msl_info->image_info[n]);
4316 profile=GetImageProfile(msl_info->image[n],"iptc");
4317 if (profile != (StringInfo *) NULL)
4318 profile_info->profile=(void *) CloneStringInfo(profile);
4319 profile_image=GetImageCache(profile_info,keyword,&exception);
4320 profile_info=DestroyImageInfo(profile_info);
4321 if (profile_image == (Image *) NULL)
4324 name[MaxTextExtent],
4325 filename[MaxTextExtent];
4333 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4334 (void) CopyMagickString(name,keyword,MaxTextExtent);
4335 for (p=filename; *p != '\0'; p++)
4336 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4337 (IsPathAccessible(keyword) == MagickFalse))
4343 Look for profile name (e.g. name:profile).
4345 (void) CopyMagickString(name,filename,(size_t)
4347 for (q=filename; *q != '\0'; q++)
4351 profile=FileToStringInfo(filename,~0UL,&exception);
4352 if (profile != (StringInfo *) NULL)
4354 (void) ProfileImage(msl_info->image[n],name,
4355 GetStringInfoDatum(profile),(size_t)
4356 GetStringInfoLength(profile),MagickFalse);
4357 profile=DestroyStringInfo(profile);
4361 ResetImageProfileIterator(profile_image);
4362 name=GetNextImageProfile(profile_image);
4363 while (name != (const char *) NULL)
4365 profile=GetImageProfile(profile_image,name);
4366 if (profile != (StringInfo *) NULL)
4367 (void) ProfileImage(msl_info->image[n],name,
4368 GetStringInfoDatum(profile),(size_t)
4369 GetStringInfoLength(profile),MagickFalse);
4370 name=GetNextImageProfile(profile_image);
4372 profile_image=DestroyImage(profile_image);
4376 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4381 if (LocaleCompare((const char *) tag,"quantize") == 0)
4389 if (msl_info->image[n] == (Image *) NULL)
4391 ThrowMSLException(OptionError,"NoImagesDefined",
4392 (const char *) tag);
4395 GetQuantizeInfo(&quantize_info);
4396 if (attributes != (const xmlChar **) NULL)
4397 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4399 keyword=(const char *) attributes[i++];
4400 attribute=InterpretImageProperties(msl_info->image_info[n],
4401 msl_info->attributes[n],(const char *) attributes[i]);
4402 CloneString(&value,attribute);
4408 if (LocaleCompare(keyword,"colors") == 0)
4410 quantize_info.number_colors=StringToLong(value);
4413 if (LocaleCompare(keyword,"colorspace") == 0)
4415 option=ParseCommandOption(MagickColorspaceOptions,
4418 ThrowMSLException(OptionError,
4419 "UnrecognizedColorspaceType",value);
4420 quantize_info.colorspace=(ColorspaceType) option;
4423 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4430 if (LocaleCompare(keyword,"dither") == 0)
4432 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4435 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4437 quantize_info.dither=(MagickBooleanType) option;
4440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4447 if (LocaleCompare(keyword,"measure") == 0)
4449 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4452 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4454 quantize_info.measure_error=(MagickBooleanType) option;
4457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4464 if (LocaleCompare(keyword,"treedepth") == 0)
4466 quantize_info.tree_depth=StringToLong(value);
4469 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4475 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4481 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4484 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4487 text[MaxTextExtent];
4498 draw_info=CloneDrawInfo(msl_info->image_info[n],
4499 msl_info->draw_info[n]);
4501 current=draw_info->affine;
4502 GetAffineMatrix(&affine);
4503 if (attributes != (const xmlChar **) NULL)
4504 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4506 keyword=(const char *) attributes[i++];
4507 attribute=InterpretImageProperties(msl_info->image_info[n],
4508 msl_info->attributes[n],(const char *) attributes[i]);
4509 CloneString(&value,attribute);
4515 if (LocaleCompare(keyword,"affine") == 0)
4521 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4524 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4527 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4530 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4533 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4536 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4539 if (LocaleCompare(keyword,"align") == 0)
4541 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4544 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4546 draw_info->align=(AlignType) option;
4549 if (LocaleCompare(keyword,"antialias") == 0)
4551 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4554 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4556 draw_info->stroke_antialias=(MagickBooleanType) option;
4557 draw_info->text_antialias=(MagickBooleanType) option;
4560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4567 if (LocaleCompare(keyword,"density") == 0)
4569 CloneString(&draw_info->density,value);
4572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4579 if (LocaleCompare(keyword,"encoding") == 0)
4581 CloneString(&draw_info->encoding,value);
4584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4591 if (LocaleCompare(keyword, "fill") == 0)
4593 (void) QueryColorDatabase(value,&draw_info->fill,
4597 if (LocaleCompare(keyword,"family") == 0)
4599 CloneString(&draw_info->family,value);
4602 if (LocaleCompare(keyword,"font") == 0)
4604 CloneString(&draw_info->font,value);
4607 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4614 if (LocaleCompare(keyword,"geometry") == 0)
4616 flags=ParsePageGeometry(msl_info->image[n],value,
4617 &geometry,&exception);
4618 if ((flags & HeightValue) == 0)
4619 geometry.height=geometry.width;
4622 if (LocaleCompare(keyword,"gravity") == 0)
4624 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4627 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4629 draw_info->gravity=(GravityType) option;
4632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4639 if (LocaleCompare(keyword,"pointsize") == 0)
4641 draw_info->pointsize=InterpretLocaleValue(value,
4645 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4652 if (LocaleCompare(keyword,"rotate") == 0)
4654 angle=InterpretLocaleValue(value,(char **) NULL);
4655 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4656 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4657 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4658 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4661 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4668 if (LocaleCompare(keyword,"scale") == 0)
4670 flags=ParseGeometry(value,&geometry_info);
4671 if ((flags & SigmaValue) == 0)
4672 geometry_info.sigma=1.0;
4673 affine.sx=geometry_info.rho;
4674 affine.sy=geometry_info.sigma;
4677 if (LocaleCompare(keyword,"skewX") == 0)
4679 angle=InterpretLocaleValue(value,(char **) NULL);
4680 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4683 if (LocaleCompare(keyword,"skewY") == 0)
4685 angle=InterpretLocaleValue(value,(char **) NULL);
4686 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4689 if (LocaleCompare(keyword,"stretch") == 0)
4691 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4694 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4696 draw_info->stretch=(StretchType) option;
4699 if (LocaleCompare(keyword, "stroke") == 0)
4701 (void) QueryColorDatabase(value,&draw_info->stroke,
4705 if (LocaleCompare(keyword,"strokewidth") == 0)
4707 draw_info->stroke_width=StringToLong(value);
4710 if (LocaleCompare(keyword,"style") == 0)
4712 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4715 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4717 draw_info->style=(StyleType) option;
4720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4727 if (LocaleCompare(keyword,"text") == 0)
4729 CloneString(&draw_info->text,value);
4732 if (LocaleCompare(keyword,"translate") == 0)
4734 flags=ParseGeometry(value,&geometry_info);
4735 if ((flags & SigmaValue) == 0)
4736 geometry_info.sigma=1.0;
4737 affine.tx=geometry_info.rho;
4738 affine.ty=geometry_info.sigma;
4741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4748 if (LocaleCompare(keyword, "undercolor") == 0)
4750 (void) QueryColorDatabase(value,&draw_info->undercolor,
4754 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4761 if (LocaleCompare(keyword,"weight") == 0)
4763 draw_info->weight=StringToLong(value);
4766 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4773 if (LocaleCompare(keyword,"x") == 0)
4775 geometry.x=StringToLong(value);
4778 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4785 if (LocaleCompare(keyword,"y") == 0)
4787 geometry.y=StringToLong(value);
4790 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4802 (void) FormatLocaleString(text,MaxTextExtent,
4803 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4804 geometry.height,(double) geometry.x,(double) geometry.y);
4805 CloneString(&draw_info->geometry,text);
4806 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4807 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4808 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4809 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4810 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4812 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4814 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4815 if (status != MagickFalse)
4820 image=msl_info->attributes[n];
4821 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4822 "%g",metrics.pixels_per_em.x);
4823 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4824 "%g",metrics.pixels_per_em.y);
4825 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4827 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4829 FormatImageProperty(image,"msl:font-metrics.width","%g",
4831 FormatImageProperty(image,"msl:font-metrics.height","%g",
4833 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4834 metrics.max_advance);
4835 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4837 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4839 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4841 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4843 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4845 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4848 draw_info=DestroyDrawInfo(draw_info);
4851 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4856 if (LocaleCompare((const char *) tag,"raise") == 0)
4864 if (msl_info->image[n] == (Image *) NULL)
4866 ThrowMSLException(OptionError,"NoImagesDefined",
4867 (const char *) tag);
4871 SetGeometry(msl_info->image[n],&geometry);
4872 if (attributes != (const xmlChar **) NULL)
4873 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4875 keyword=(const char *) attributes[i++];
4876 attribute=InterpretImageProperties(msl_info->image_info[n],
4877 msl_info->attributes[n],(const char *) attributes[i]);
4878 CloneString(&value,attribute);
4884 if (LocaleCompare(keyword,"geometry") == 0)
4886 flags=ParsePageGeometry(msl_info->image[n],value,
4887 &geometry,&exception);
4888 if ((flags & HeightValue) == 0)
4889 geometry.height=geometry.width;
4892 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4899 if (LocaleCompare(keyword,"height") == 0)
4901 geometry.height=StringToLong(value);
4904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4911 if (LocaleCompare(keyword,"raise") == 0)
4913 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4916 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4918 raise=(MagickBooleanType) option;
4921 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4928 if (LocaleCompare(keyword,"width") == 0)
4930 geometry.width=StringToLong(value);
4933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4939 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4945 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4948 if (LocaleCompare((const char *) tag,"read") == 0)
4950 if (attributes == (const xmlChar **) NULL)
4952 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4954 keyword=(const char *) attributes[i++];
4955 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4956 msl_info->attributes[n],(const char *) attributes[i]));
4962 if (LocaleCompare(keyword,"filename") == 0)
4967 (void) CopyMagickString(msl_info->image_info[n]->filename,
4968 value,MaxTextExtent);
4969 image=ReadImage(msl_info->image_info[n],&exception);
4970 CatchException(&exception);
4971 if (image == (Image *) NULL)
4973 AppendImageToList(&msl_info->image[n],image);
4976 (void) SetMSLAttributes(msl_info,keyword,value);
4981 (void) SetMSLAttributes(msl_info,keyword,value);
4988 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4996 if (msl_info->image[n] == (Image *) NULL)
4998 ThrowMSLException(OptionError,"NoImagesDefined",
4999 (const char *) tag);
5002 if (attributes != (const xmlChar **) NULL)
5003 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5005 keyword=(const char *) attributes[i++];
5006 attribute=InterpretImageProperties(msl_info->image_info[n],
5007 msl_info->attributes[n],(const char *) attributes[i]);
5008 CloneString(&value,attribute);
5014 if (LocaleCompare(keyword,"geometry") == 0)
5016 flags=ParseGeometry(value,&geometry_info);
5017 if ((flags & SigmaValue) == 0)
5018 geometry_info.sigma=1.0;
5021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5028 if (LocaleCompare(keyword,"radius") == 0)
5030 geometry_info.rho=InterpretLocaleValue(value,
5034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5046 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5047 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5048 &msl_info->image[n]->exception);
5049 if (paint_image == (Image *) NULL)
5051 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5052 msl_info->image[n]=paint_image;
5055 else if (LocaleCompare((const char *) tag,"repage") == 0)
5057 /* init the values */
5058 width=msl_info->image[n]->page.width;
5059 height=msl_info->image[n]->page.height;
5060 x=msl_info->image[n]->page.x;
5061 y=msl_info->image[n]->page.y;
5063 if (msl_info->image[n] == (Image *) NULL)
5065 ThrowMSLException(OptionError,"NoImagesDefined",
5066 (const char *) tag);
5069 if (attributes == (const xmlChar **) NULL)
5071 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5073 keyword=(const char *) attributes[i++];
5074 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5075 msl_info->attributes[n],(const char *) attributes[i]));
5081 if (LocaleCompare(keyword,"geometry") == 0)
5089 flags=ParseAbsoluteGeometry(value,&geometry);
5090 if ((flags & WidthValue) != 0)
5092 if ((flags & HeightValue) == 0)
5093 geometry.height=geometry.width;
5094 width=geometry.width;
5095 height=geometry.height;
5097 if ((flags & AspectValue) != 0)
5099 if ((flags & XValue) != 0)
5101 if ((flags & YValue) != 0)
5106 if ((flags & XValue) != 0)
5109 if ((width == 0) && (geometry.x > 0))
5110 width=msl_info->image[n]->columns+geometry.x;
5112 if ((flags & YValue) != 0)
5115 if ((height == 0) && (geometry.y > 0))
5116 height=msl_info->image[n]->rows+geometry.y;
5121 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5127 if (LocaleCompare(keyword,"height") == 0)
5129 height = StringToLong( value );
5132 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5138 if (LocaleCompare(keyword,"width") == 0)
5140 width = StringToLong( value );
5143 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5149 if (LocaleCompare(keyword,"x") == 0)
5151 x = StringToLong( value );
5154 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5160 if (LocaleCompare(keyword,"y") == 0)
5162 y = StringToLong( value );
5165 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5170 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5176 msl_info->image[n]->page.width=width;
5177 msl_info->image[n]->page.height=height;
5178 msl_info->image[n]->page.x=x;
5179 msl_info->image[n]->page.y=y;
5182 else if (LocaleCompare((const char *) tag,"resample") == 0)
5188 if (msl_info->image[n] == (Image *) NULL)
5190 ThrowMSLException(OptionError,"NoImagesDefined",
5191 (const char *) tag);
5194 if (attributes == (const xmlChar **) NULL)
5196 x_resolution=DefaultResolution;
5197 y_resolution=DefaultResolution;
5198 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5200 keyword=(const char *) attributes[i++];
5201 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5202 msl_info->attributes[n],(const char *) attributes[i]));
5207 if (LocaleCompare(keyword,"blur") == 0)
5209 msl_info->image[n]->blur=InterpretLocaleValue(value,
5213 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5219 if (LocaleCompare(keyword,"geometry") == 0)
5224 flags=ParseGeometry(value,&geometry_info);
5225 if ((flags & SigmaValue) == 0)
5226 geometry_info.sigma*=geometry_info.rho;
5227 x_resolution=geometry_info.rho;
5228 y_resolution=geometry_info.sigma;
5231 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5237 if (LocaleCompare(keyword,"x-resolution") == 0)
5239 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5242 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5248 if (LocaleCompare(keyword,"y-resolution") == 0)
5250 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5253 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5258 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5274 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5276 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5277 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5278 msl_info->image[n]->x_resolution))+0.5);
5279 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5280 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5281 msl_info->image[n]->y_resolution))+0.5);
5282 resample_image=ResizeImage(msl_info->image[n],width,height,
5283 msl_info->image[n]->filter,msl_info->image[n]->blur,
5284 &msl_info->image[n]->exception);
5285 if (resample_image == (Image *) NULL)
5287 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5288 msl_info->image[n]=resample_image;
5292 if (LocaleCompare((const char *) tag,"resize") == 0)
5306 if (msl_info->image[n] == (Image *) NULL)
5308 ThrowMSLException(OptionError,"NoImagesDefined",
5309 (const char *) tag);
5312 filter=UndefinedFilter;
5314 if (attributes != (const xmlChar **) NULL)
5315 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5317 keyword=(const char *) attributes[i++];
5318 attribute=InterpretImageProperties(msl_info->image_info[n],
5319 msl_info->attributes[n],(const char *) attributes[i]);
5320 CloneString(&value,attribute);
5326 if (LocaleCompare(keyword,"filter") == 0)
5328 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5331 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5333 filter=(FilterTypes) option;
5336 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5343 if (LocaleCompare(keyword,"geometry") == 0)
5345 flags=ParseRegionGeometry(msl_info->image[n],value,
5346 &geometry,&exception);
5349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5356 if (LocaleCompare(keyword,"height") == 0)
5358 geometry.height=StringToUnsignedLong(value);
5361 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5368 if (LocaleCompare(keyword,"support") == 0)
5370 blur=InterpretLocaleValue(value,(char **) NULL);
5373 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5380 if (LocaleCompare(keyword,"width") == 0)
5382 geometry.width=StringToLong(value);
5385 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5391 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5397 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5398 geometry.height,filter,blur,&msl_info->image[n]->exception);
5399 if (resize_image == (Image *) NULL)
5401 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5402 msl_info->image[n]=resize_image;
5405 if (LocaleCompare((const char *) tag,"roll") == 0)
5413 if (msl_info->image[n] == (Image *) NULL)
5415 ThrowMSLException(OptionError,"NoImagesDefined",
5416 (const char *) tag);
5419 SetGeometry(msl_info->image[n],&geometry);
5420 if (attributes != (const xmlChar **) NULL)
5421 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5423 keyword=(const char *) attributes[i++];
5424 attribute=InterpretImageProperties(msl_info->image_info[n],
5425 msl_info->attributes[n],(const char *) attributes[i]);
5426 CloneString(&value,attribute);
5432 if (LocaleCompare(keyword,"geometry") == 0)
5434 flags=ParsePageGeometry(msl_info->image[n],value,
5435 &geometry,&exception);
5436 if ((flags & HeightValue) == 0)
5437 geometry.height=geometry.width;
5440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5447 if (LocaleCompare(keyword,"x") == 0)
5449 geometry.x=StringToLong(value);
5452 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5459 if (LocaleCompare(keyword,"y") == 0)
5461 geometry.y=StringToLong(value);
5464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5470 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5476 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5477 &msl_info->image[n]->exception);
5478 if (roll_image == (Image *) NULL)
5480 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5481 msl_info->image[n]=roll_image;
5484 else if (LocaleCompare((const char *) tag,"roll") == 0)
5486 /* init the values */
5487 width=msl_info->image[n]->columns;
5488 height=msl_info->image[n]->rows;
5491 if (msl_info->image[n] == (Image *) NULL)
5493 ThrowMSLException(OptionError,"NoImagesDefined",
5494 (const char *) tag);
5497 if (attributes == (const xmlChar **) NULL)
5499 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5501 keyword=(const char *) attributes[i++];
5502 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5503 msl_info->attributes[n],(const char *) attributes[i]));
5509 if (LocaleCompare(keyword,"geometry") == 0)
5511 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5514 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5520 if (LocaleCompare(keyword,"x") == 0)
5522 x = StringToLong( value );
5525 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5531 if (LocaleCompare(keyword,"y") == 0)
5533 y = StringToLong( value );
5536 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5541 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5554 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5555 if (newImage == (Image *) NULL)
5557 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5558 msl_info->image[n]=newImage;
5563 if (LocaleCompare((const char *) tag,"rotate") == 0)
5571 if (msl_info->image[n] == (Image *) NULL)
5573 ThrowMSLException(OptionError,"NoImagesDefined",
5574 (const char *) tag);
5577 if (attributes != (const xmlChar **) NULL)
5578 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5580 keyword=(const char *) attributes[i++];
5581 attribute=InterpretImageProperties(msl_info->image_info[n],
5582 msl_info->attributes[n],(const char *) attributes[i]);
5583 CloneString(&value,attribute);
5589 if (LocaleCompare(keyword,"degrees") == 0)
5591 geometry_info.rho=InterpretLocaleValue(value,
5595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5602 if (LocaleCompare(keyword,"geometry") == 0)
5604 flags=ParseGeometry(value,&geometry_info);
5605 if ((flags & SigmaValue) == 0)
5606 geometry_info.sigma=1.0;
5609 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5615 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5621 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5622 &msl_info->image[n]->exception);
5623 if (rotate_image == (Image *) NULL)
5625 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5626 msl_info->image[n]=rotate_image;
5629 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5631 /* init the values */
5634 if (msl_info->image[n] == (Image *) NULL)
5636 ThrowMSLException(OptionError,"NoImagesDefined",
5637 (const char *) tag);
5640 if (attributes == (const xmlChar **) NULL)
5642 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5644 keyword=(const char *) attributes[i++];
5645 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5646 msl_info->attributes[n],(const char *) attributes[i]));
5652 if (LocaleCompare(keyword,"degrees") == 0)
5654 degrees = InterpretLocaleValue(value,(char **) NULL);
5657 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5662 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5675 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5676 if (newImage == (Image *) NULL)
5678 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5679 msl_info->image[n]=newImage;
5684 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5689 if (LocaleCompare((const char *) tag,"sample") == 0)
5697 if (msl_info->image[n] == (Image *) NULL)
5699 ThrowMSLException(OptionError,"NoImagesDefined",
5700 (const char *) tag);
5703 if (attributes != (const xmlChar **) NULL)
5704 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5706 keyword=(const char *) attributes[i++];
5707 attribute=InterpretImageProperties(msl_info->image_info[n],
5708 msl_info->attributes[n],(const char *) attributes[i]);
5709 CloneString(&value,attribute);
5715 if (LocaleCompare(keyword,"geometry") == 0)
5717 flags=ParseRegionGeometry(msl_info->image[n],value,
5718 &geometry,&exception);
5721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5728 if (LocaleCompare(keyword,"height") == 0)
5730 geometry.height=StringToUnsignedLong(value);
5733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5740 if (LocaleCompare(keyword,"width") == 0)
5742 geometry.width=StringToLong(value);
5745 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5757 sample_image=SampleImage(msl_info->image[n],geometry.width,
5758 geometry.height,&msl_info->image[n]->exception);
5759 if (sample_image == (Image *) NULL)
5761 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5762 msl_info->image[n]=sample_image;
5765 if (LocaleCompare((const char *) tag,"scale") == 0)
5773 if (msl_info->image[n] == (Image *) NULL)
5775 ThrowMSLException(OptionError,"NoImagesDefined",
5776 (const char *) tag);
5779 if (attributes != (const xmlChar **) NULL)
5780 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5782 keyword=(const char *) attributes[i++];
5783 attribute=InterpretImageProperties(msl_info->image_info[n],
5784 msl_info->attributes[n],(const char *) attributes[i]);
5785 CloneString(&value,attribute);
5791 if (LocaleCompare(keyword,"geometry") == 0)
5793 flags=ParseRegionGeometry(msl_info->image[n],value,
5794 &geometry,&exception);
5797 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5804 if (LocaleCompare(keyword,"height") == 0)
5806 geometry.height=StringToUnsignedLong(value);
5809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5816 if (LocaleCompare(keyword,"width") == 0)
5818 geometry.width=StringToLong(value);
5821 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5827 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5833 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5834 geometry.height,&msl_info->image[n]->exception);
5835 if (scale_image == (Image *) NULL)
5837 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5838 msl_info->image[n]=scale_image;
5841 if (LocaleCompare((const char *) tag,"segment") == 0)
5852 if (msl_info->image[n] == (Image *) NULL)
5854 ThrowMSLException(OptionError,"NoImagesDefined",
5855 (const char *) tag);
5858 geometry_info.rho=1.0;
5859 geometry_info.sigma=1.5;
5860 colorspace=RGBColorspace;
5861 verbose=MagickFalse;
5862 if (attributes != (const xmlChar **) NULL)
5863 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5865 keyword=(const char *) attributes[i++];
5866 attribute=InterpretImageProperties(msl_info->image_info[n],
5867 msl_info->attributes[n],(const char *) attributes[i]);
5868 CloneString(&value,attribute);
5874 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5876 geometry_info.rho=InterpretLocaleValue(value,
5880 if (LocaleCompare(keyword,"colorspace") == 0)
5882 option=ParseCommandOption(MagickColorspaceOptions,
5885 ThrowMSLException(OptionError,
5886 "UnrecognizedColorspaceType",value);
5887 colorspace=(ColorspaceType) option;
5890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5897 if (LocaleCompare(keyword,"geometry") == 0)
5899 flags=ParseGeometry(value,&geometry_info);
5900 if ((flags & SigmaValue) == 0)
5901 geometry_info.sigma=1.5;
5904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5911 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5913 geometry_info.sigma=InterpretLocaleValue(value,
5917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5929 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5930 geometry_info.rho,geometry_info.sigma);
5933 else if (LocaleCompare((const char *) tag, "set") == 0)
5935 if (msl_info->image[n] == (Image *) NULL)
5937 ThrowMSLException(OptionError,"NoImagesDefined",
5938 (const char *) tag);
5942 if (attributes == (const xmlChar **) NULL)
5944 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5946 keyword=(const char *) attributes[i++];
5947 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5948 msl_info->attributes[n],(const char *) attributes[i]));
5954 if (LocaleCompare(keyword,"clip-mask") == 0)
5956 for (j=0; j < msl_info->n; j++)
5961 property=GetImageProperty(msl_info->attributes[j],"id");
5962 if (LocaleCompare(property,value) == 0)
5964 SetImageMask(msl_info->image[n],msl_info->image[j]);
5970 if (LocaleCompare(keyword,"clip-path") == 0)
5972 for (j=0; j < msl_info->n; j++)
5977 property=GetImageProperty(msl_info->attributes[j],"id");
5978 if (LocaleCompare(property,value) == 0)
5980 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5986 if (LocaleCompare(keyword,"colorspace") == 0)
5991 colorspace=(ColorspaceType) ParseCommandOption(
5992 MagickColorspaceOptions,MagickFalse,value);
5994 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5996 (void) TransformImageColorspace(msl_info->image[n],
5997 (ColorspaceType) colorspace);
6000 (void) SetMSLAttributes(msl_info,keyword,value);
6006 if (LocaleCompare(keyword,"density") == 0)
6008 flags=ParseGeometry(value,&geometry_info);
6009 msl_info->image[n]->x_resolution=geometry_info.rho;
6010 msl_info->image[n]->y_resolution=geometry_info.sigma;
6011 if ((flags & SigmaValue) == 0)
6012 msl_info->image[n]->y_resolution=
6013 msl_info->image[n]->x_resolution;
6016 (void) SetMSLAttributes(msl_info,keyword,value);
6022 if (LocaleCompare(keyword, "opacity") == 0)
6024 ssize_t opac = OpaqueAlpha,
6025 len = (ssize_t) strlen( value );
6027 if (value[len-1] == '%') {
6029 (void) CopyMagickString(tmp,value,len);
6030 opac = StringToLong( tmp );
6031 opac = (int)(QuantumRange * ((float)opac/100));
6033 opac = StringToLong( value );
6034 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6037 (void) SetMSLAttributes(msl_info,keyword,value);
6043 if (LocaleCompare(keyword, "page") == 0)
6046 page[MaxTextExtent];
6057 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6058 image_option=GetImageOption(msl_info->image_info[n],"page");
6059 if (image_option != (const char *) NULL)
6060 flags=ParseAbsoluteGeometry(image_option,&geometry);
6061 flags=ParseAbsoluteGeometry(value,&geometry);
6062 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6063 (double) geometry.width,(double) geometry.height);
6064 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6065 (void) FormatLocaleString(page,MaxTextExtent,
6066 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6067 (double) geometry.height,(double) geometry.x,(double)
6069 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6070 msl_info->image_info[n]->page=GetPageGeometry(page);
6073 (void) SetMSLAttributes(msl_info,keyword,value);
6078 (void) SetMSLAttributes(msl_info,keyword,value);
6085 if (LocaleCompare((const char *) tag,"shade") == 0)
6096 if (msl_info->image[n] == (Image *) NULL)
6098 ThrowMSLException(OptionError,"NoImagesDefined",
6099 (const char *) tag);
6103 if (attributes != (const xmlChar **) NULL)
6104 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6106 keyword=(const char *) attributes[i++];
6107 attribute=InterpretImageProperties(msl_info->image_info[n],
6108 msl_info->attributes[n],(const char *) attributes[i]);
6109 CloneString(&value,attribute);
6115 if (LocaleCompare(keyword,"azimuth") == 0)
6117 geometry_info.rho=InterpretLocaleValue(value,
6121 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6128 if (LocaleCompare(keyword,"elevation") == 0)
6130 geometry_info.sigma=InterpretLocaleValue(value,
6134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(keyword,"geometry") == 0)
6143 flags=ParseGeometry(value,&geometry_info);
6144 if ((flags & SigmaValue) == 0)
6145 geometry_info.sigma=1.0;
6148 if (LocaleCompare(keyword,"gray") == 0)
6150 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6153 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6155 gray=(MagickBooleanType) option;
6158 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6164 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6170 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6171 geometry_info.sigma,&msl_info->image[n]->exception);
6172 if (shade_image == (Image *) NULL)
6174 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6175 msl_info->image[n]=shade_image;
6178 if (LocaleCompare((const char *) tag,"shadow") == 0)
6186 if (msl_info->image[n] == (Image *) NULL)
6188 ThrowMSLException(OptionError,"NoImagesDefined",
6189 (const char *) tag);
6192 if (attributes != (const xmlChar **) NULL)
6193 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6195 keyword=(const char *) attributes[i++];
6196 attribute=InterpretImageProperties(msl_info->image_info[n],
6197 msl_info->attributes[n],(const char *) attributes[i]);
6198 CloneString(&value,attribute);
6204 if (LocaleCompare(keyword,"geometry") == 0)
6206 flags=ParseGeometry(value,&geometry_info);
6207 if ((flags & SigmaValue) == 0)
6208 geometry_info.sigma=1.0;
6211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6218 if (LocaleCompare(keyword,"opacity") == 0)
6220 geometry_info.rho=StringToLong(value);
6223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6230 if (LocaleCompare(keyword,"sigma") == 0)
6232 geometry_info.sigma=StringToLong(value);
6240 if (LocaleCompare(keyword,"x") == 0)
6242 geometry_info.xi=InterpretLocaleValue(value,
6246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6253 if (LocaleCompare(keyword,"y") == 0)
6255 geometry_info.psi=StringToLong(value);
6258 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6264 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6270 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6271 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6272 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6273 if (shadow_image == (Image *) NULL)
6275 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6276 msl_info->image[n]=shadow_image;
6279 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6281 double radius = 0.0,
6284 if (msl_info->image[n] == (Image *) NULL)
6286 ThrowMSLException(OptionError,"NoImagesDefined",
6287 (const char *) tag);
6291 NOTE: sharpen can have no attributes, since we use all the defaults!
6293 if (attributes != (const xmlChar **) NULL)
6295 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6297 keyword=(const char *) attributes[i++];
6298 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6299 msl_info->attributes[n],(const char *) attributes[i]));
6305 if (LocaleCompare(keyword, "radius") == 0)
6307 radius = InterpretLocaleValue(value,(char **) NULL);
6310 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6316 if (LocaleCompare(keyword,"sigma") == 0)
6318 sigma = StringToLong( value );
6321 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6340 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6341 if (newImage == (Image *) NULL)
6343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6344 msl_info->image[n]=newImage;
6348 else if (LocaleCompare((const char *) tag,"shave") == 0)
6350 /* init the values */
6354 if (msl_info->image[n] == (Image *) NULL)
6356 ThrowMSLException(OptionError,"NoImagesDefined",
6357 (const char *) tag);
6360 if (attributes == (const xmlChar **) NULL)
6362 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6364 keyword=(const char *) attributes[i++];
6365 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6366 msl_info->attributes[n],(const char *) attributes[i]));
6372 if (LocaleCompare(keyword,"geometry") == 0)
6374 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6377 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6383 if (LocaleCompare(keyword,"height") == 0)
6385 height = StringToLong( value );
6388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6394 if (LocaleCompare(keyword,"width") == 0)
6396 width = StringToLong( value );
6399 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6404 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6419 rectInfo.height = height;
6420 rectInfo.width = width;
6425 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6426 &msl_info->image[n]->exception);
6427 if (newImage == (Image *) NULL)
6429 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6430 msl_info->image[n]=newImage;
6435 if (LocaleCompare((const char *) tag,"shear") == 0)
6443 if (msl_info->image[n] == (Image *) NULL)
6445 ThrowMSLException(OptionError,"NoImagesDefined",
6446 (const char *) tag);
6449 if (attributes != (const xmlChar **) NULL)
6450 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6452 keyword=(const char *) attributes[i++];
6453 attribute=InterpretImageProperties(msl_info->image_info[n],
6454 msl_info->attributes[n],(const char *) attributes[i]);
6455 CloneString(&value,attribute);
6461 if (LocaleCompare(keyword, "fill") == 0)
6463 (void) QueryColorDatabase(value,
6464 &msl_info->image[n]->background_color,&exception);
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6474 if (LocaleCompare(keyword,"geometry") == 0)
6476 flags=ParseGeometry(value,&geometry_info);
6477 if ((flags & SigmaValue) == 0)
6478 geometry_info.sigma=1.0;
6481 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6488 if (LocaleCompare(keyword,"x") == 0)
6490 geometry_info.rho=InterpretLocaleValue(value,
6494 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6501 if (LocaleCompare(keyword,"y") == 0)
6503 geometry_info.sigma=StringToLong(value);
6506 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6512 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6518 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6519 geometry_info.sigma,&msl_info->image[n]->exception);
6520 if (shear_image == (Image *) NULL)
6522 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6523 msl_info->image[n]=shear_image;
6526 if (LocaleCompare((const char *) tag,"signature") == 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]);
6543 CloneString(&value,attribute);
6548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6554 (void) SignatureImage(msl_info->image[n]);
6557 if (LocaleCompare((const char *) tag,"solarize") == 0)
6562 if (msl_info->image[n] == (Image *) NULL)
6564 ThrowMSLException(OptionError,"NoImagesDefined",
6565 (const char *) tag);
6568 geometry_info.rho=QuantumRange/2.0;
6569 if (attributes != (const xmlChar **) NULL)
6570 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6572 keyword=(const char *) attributes[i++];
6573 attribute=InterpretImageProperties(msl_info->image_info[n],
6574 msl_info->attributes[n],(const char *) attributes[i]);
6575 CloneString(&value,attribute);
6581 if (LocaleCompare(keyword,"geometry") == 0)
6583 flags=ParseGeometry(value,&geometry_info);
6586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6593 if (LocaleCompare(keyword,"threshold") == 0)
6595 geometry_info.rho=InterpretLocaleValue(value,
6599 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6611 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6614 if (LocaleCompare((const char *) tag,"spread") == 0)
6622 if (msl_info->image[n] == (Image *) NULL)
6624 ThrowMSLException(OptionError,"NoImagesDefined",
6625 (const char *) tag);
6628 if (attributes != (const xmlChar **) NULL)
6629 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6631 keyword=(const char *) attributes[i++];
6632 attribute=InterpretImageProperties(msl_info->image_info[n],
6633 msl_info->attributes[n],(const char *) attributes[i]);
6634 CloneString(&value,attribute);
6640 if (LocaleCompare(keyword,"geometry") == 0)
6642 flags=ParseGeometry(value,&geometry_info);
6643 if ((flags & SigmaValue) == 0)
6644 geometry_info.sigma=1.0;
6647 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6654 if (LocaleCompare(keyword,"radius") == 0)
6656 geometry_info.rho=InterpretLocaleValue(value,
6660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6672 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6673 &msl_info->image[n]->exception);
6674 if (spread_image == (Image *) NULL)
6676 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6677 msl_info->image[n]=spread_image;
6680 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6683 watermark = (Image*)NULL;
6685 if (msl_info->image[n] == (Image *) NULL)
6687 ThrowMSLException(OptionError,"NoImagesDefined",
6688 (const char *) tag);
6691 if (attributes == (const xmlChar **) NULL)
6693 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6695 keyword=(const char *) attributes[i++];
6696 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6697 msl_info->attributes[n],(const char *) attributes[i]));
6703 if (LocaleCompare(keyword,"image") == 0)
6705 for (j=0; j<msl_info->n;j++)
6708 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6709 if (theAttr && LocaleCompare(theAttr, value) == 0)
6711 watermark = msl_info->image[j];
6717 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6722 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6731 if ( watermark != (Image*) NULL )
6736 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6737 if (newImage == (Image *) NULL)
6739 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6740 msl_info->image[n]=newImage;
6743 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6745 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6748 stereoImage = (Image*)NULL;
6750 if (msl_info->image[n] == (Image *) NULL)
6752 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6755 if (attributes == (const xmlChar **) NULL)
6757 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6759 keyword=(const char *) attributes[i++];
6760 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6761 msl_info->attributes[n],(const char *) attributes[i]));
6767 if (LocaleCompare(keyword,"image") == 0)
6769 for (j=0; j<msl_info->n;j++)
6772 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6773 if (theAttr && LocaleCompare(theAttr, value) == 0)
6775 stereoImage = msl_info->image[j];
6781 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6786 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6795 if ( stereoImage != (Image*) NULL )
6800 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6801 if (newImage == (Image *) NULL)
6803 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6804 msl_info->image[n]=newImage;
6807 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6809 if (LocaleCompare((const char *) tag,"swap") == 0)
6820 if (msl_info->image[n] == (Image *) NULL)
6822 ThrowMSLException(OptionError,"NoImagesDefined",
6823 (const char *) tag);
6828 if (attributes != (const xmlChar **) NULL)
6829 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6831 keyword=(const char *) attributes[i++];
6832 attribute=InterpretImageProperties(msl_info->image_info[n],
6833 msl_info->attributes[n],(const char *) attributes[i]);
6834 CloneString(&value,attribute);
6840 if (LocaleCompare(keyword,"indexes") == 0)
6842 flags=ParseGeometry(value,&geometry_info);
6843 index=(ssize_t) geometry_info.rho;
6844 if ((flags & SigmaValue) == 0)
6845 swap_index=(ssize_t) geometry_info.sigma;
6848 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6863 p=GetImageFromList(msl_info->image[n],index);
6864 q=GetImageFromList(msl_info->image[n],swap_index);
6865 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6867 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6870 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6871 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6872 ReplaceImageInList(&q,swap);
6873 msl_info->image[n]=GetFirstImageInList(q);
6876 if (LocaleCompare((const char *) tag,"swirl") == 0)
6884 if (msl_info->image[n] == (Image *) NULL)
6886 ThrowMSLException(OptionError,"NoImagesDefined",
6887 (const char *) tag);
6890 if (attributes != (const xmlChar **) NULL)
6891 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6893 keyword=(const char *) attributes[i++];
6894 attribute=InterpretImageProperties(msl_info->image_info[n],
6895 msl_info->attributes[n],(const char *) attributes[i]);
6896 CloneString(&value,attribute);
6902 if (LocaleCompare(keyword,"degrees") == 0)
6904 geometry_info.rho=InterpretLocaleValue(value,
6908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6915 if (LocaleCompare(keyword,"geometry") == 0)
6917 flags=ParseGeometry(value,&geometry_info);
6918 if ((flags & SigmaValue) == 0)
6919 geometry_info.sigma=1.0;
6922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6934 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6935 &msl_info->image[n]->exception);
6936 if (swirl_image == (Image *) NULL)
6938 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6939 msl_info->image[n]=swirl_image;
6942 if (LocaleCompare((const char *) tag,"sync") == 0)
6947 if (msl_info->image[n] == (Image *) NULL)
6949 ThrowMSLException(OptionError,"NoImagesDefined",
6950 (const char *) tag);
6953 if (attributes != (const xmlChar **) NULL)
6954 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6956 keyword=(const char *) attributes[i++];
6957 attribute=InterpretImageProperties(msl_info->image_info[n],
6958 msl_info->attributes[n],(const char *) attributes[i]);
6959 CloneString(&value,attribute);
6964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6970 (void) SyncImage(msl_info->image[n]);
6973 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6978 if (LocaleCompare((const char *) tag,"map") == 0)
6986 if (msl_info->image[n] == (Image *) NULL)
6988 ThrowMSLException(OptionError,"NoImagesDefined",
6989 (const char *) tag);
6992 texture_image=NewImageList();
6993 if (attributes != (const xmlChar **) NULL)
6994 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6996 keyword=(const char *) attributes[i++];
6997 attribute=InterpretImageProperties(msl_info->image_info[n],
6998 msl_info->attributes[n],(const char *) attributes[i]);
6999 CloneString(&value,attribute);
7005 if (LocaleCompare(keyword,"image") == 0)
7006 for (j=0; j < msl_info->n; j++)
7011 attribute=GetImageProperty(msl_info->attributes[j],"id");
7012 if ((attribute != (const char *) NULL) &&
7013 (LocaleCompare(attribute,value) == 0))
7015 texture_image=CloneImage(msl_info->image[j],0,0,
7016 MagickFalse,&exception);
7024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7030 (void) TextureImage(msl_info->image[n],texture_image);
7031 texture_image=DestroyImage(texture_image);
7034 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7036 /* init the values */
7037 double threshold = 0;
7039 if (msl_info->image[n] == (Image *) NULL)
7041 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7044 if (attributes == (const xmlChar **) NULL)
7046 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7048 keyword=(const char *) attributes[i++];
7049 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7050 msl_info->attributes[n],(const char *) attributes[i]));
7056 if (LocaleCompare(keyword,"threshold") == 0)
7058 threshold = InterpretLocaleValue(value,(char **) NULL);
7061 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7066 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7076 BilevelImage(msl_info->image[n],threshold);
7080 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7082 if (msl_info->image[n] == (Image *) NULL)
7084 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7087 if (attributes == (const xmlChar **) NULL)
7089 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7091 keyword=(const char *) attributes[i++];
7092 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7093 msl_info->attributes[n],(const char *) attributes[i]));
7099 if (LocaleCompare(keyword,"color") == 0)
7104 (void) QueryMagickColor(value,&target,&exception);
7105 (void) TransparentPaintImage(msl_info->image[n],&target,
7106 TransparentAlpha,MagickFalse);
7109 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7114 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7121 else if (LocaleCompare((const char *) tag, "trim") == 0)
7123 if (msl_info->image[n] == (Image *) NULL)
7125 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7129 /* no attributes here */
7131 /* process the image */
7138 /* all zeros on a crop == trim edges! */
7139 rectInfo.height = rectInfo.width = 0;
7140 rectInfo.x = rectInfo.y = 0;
7142 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7143 if (newImage == (Image *) NULL)
7145 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7146 msl_info->image[n]=newImage;
7150 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7155 if (LocaleCompare((const char *) tag,"write") == 0)
7157 if (msl_info->image[n] == (Image *) NULL)
7159 ThrowMSLException(OptionError,"NoImagesDefined",
7160 (const char *) tag);
7163 if (attributes == (const xmlChar **) NULL)
7165 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7167 keyword=(const char *) attributes[i++];
7168 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7169 msl_info->attributes[n],(const char *) attributes[i]));
7175 if (LocaleCompare(keyword,"filename") == 0)
7177 (void) CopyMagickString(msl_info->image[n]->filename,value,
7181 (void) SetMSLAttributes(msl_info,keyword,value);
7185 (void) SetMSLAttributes(msl_info,keyword,value);
7193 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7197 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7201 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7205 if ( value != NULL )
7206 value=DestroyString(value);
7207 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7210 static void MSLEndElement(void *context,const xmlChar *tag)
7219 Called when the end of an element has been detected.
7221 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7223 msl_info=(MSLInfo *) context;
7230 if (LocaleCompare((const char *) tag,"comment") == 0 )
7232 (void) DeleteImageProperty(msl_info->image[n],"comment");
7233 if (msl_info->content == (char *) NULL)
7235 StripString(msl_info->content);
7236 (void) SetImageProperty(msl_info->image[n],"comment",
7245 if (LocaleCompare((const char *) tag, "group") == 0 )
7247 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7249 ssize_t i = (ssize_t)
7250 (msl_info->group_info[msl_info->number_groups-1].numImages);
7253 if (msl_info->image[msl_info->n] != (Image *) NULL)
7254 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7255 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7256 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7260 msl_info->number_groups--;
7267 if (LocaleCompare((const char *) tag, "image") == 0)
7268 MSLPopImage(msl_info);
7274 if (LocaleCompare((const char *) tag,"label") == 0 )
7276 (void) DeleteImageProperty(msl_info->image[n],"label");
7277 if (msl_info->content == (char *) NULL)
7279 StripString(msl_info->content);
7280 (void) SetImageProperty(msl_info->image[n],"label",
7289 if (LocaleCompare((const char *) tag, "msl") == 0 )
7292 This our base element.
7293 at the moment we don't do anything special
7294 but someday we might!
7302 if (msl_info->content != (char *) NULL)
7303 msl_info->content=DestroyString(msl_info->content);
7306 static void MSLCharacters(void *context,const xmlChar *c,int length)
7318 Receiving some characters from the parser.
7320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7321 " SAX.characters(%s,%d)",c,length);
7322 msl_info=(MSLInfo *) context;
7323 if (msl_info->content != (char *) NULL)
7324 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7325 strlen(msl_info->content)+length+MaxTextExtent,
7326 sizeof(*msl_info->content));
7329 msl_info->content=(char *) NULL;
7330 if (~length >= (MaxTextExtent-1))
7331 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7332 sizeof(*msl_info->content));
7333 if (msl_info->content != (char *) NULL)
7334 *msl_info->content='\0';
7336 if (msl_info->content == (char *) NULL)
7338 p=msl_info->content+strlen(msl_info->content);
7339 for (i=0; i < length; i++)
7344 static void MSLReference(void *context,const xmlChar *name)
7353 Called when an entity reference is detected.
7355 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7356 " SAX.reference(%s)",name);
7357 msl_info=(MSLInfo *) context;
7358 parser=msl_info->parser;
7360 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7362 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7365 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7371 Receiving some ignorable whitespaces from the parser.
7373 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7374 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7375 msl_info=(MSLInfo *) context;
7379 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7380 const xmlChar *data)
7386 A processing instruction has been parsed.
7388 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7389 " SAX.processingInstruction(%s, %s)",
7391 msl_info=(MSLInfo *) context;
7395 static void MSLComment(void *context,const xmlChar *value)
7401 A comment has been parsed.
7403 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7404 " SAX.comment(%s)",value);
7405 msl_info=(MSLInfo *) context;
7409 static void MSLWarning(void *context,const char *format,...)
7413 reason[MaxTextExtent];
7422 Display and format a warning messages, gives file, line, position and
7425 va_start(operands,format);
7426 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7427 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7428 msl_info=(MSLInfo *) context;
7430 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7431 (void) vsprintf(reason,format,operands);
7433 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7435 message=GetExceptionMessage(errno);
7436 ThrowMSLException(CoderError,reason,message);
7437 message=DestroyString(message);
7441 static void MSLError(void *context,const char *format,...)
7444 reason[MaxTextExtent];
7453 Display and format a error formats, gives file, line, position and
7456 va_start(operands,format);
7457 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7458 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7459 msl_info=(MSLInfo *) context;
7461 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7462 (void) vsprintf(reason,format,operands);
7464 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7466 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7470 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7482 Called when a pcdata block has been parsed.
7484 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7485 " SAX.pcdata(%s, %d)",value,length);
7486 msl_info=(MSLInfo *) context;
7488 parser=msl_info->parser;
7489 child=xmlGetLastChild(parser->node);
7490 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7492 xmlTextConcat(child,value,length);
7495 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7498 static void MSLExternalSubset(void *context,const xmlChar *name,
7499 const xmlChar *external_id,const xmlChar *system_id)
7514 Does this document has an external subset?
7516 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7517 " SAX.externalSubset(%s %s %s)",name,
7518 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7519 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7520 msl_info=(MSLInfo *) context;
7522 parser=msl_info->parser;
7523 if (((external_id == NULL) && (system_id == NULL)) ||
7524 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7525 (msl_info->document == 0)))
7527 input=MSLResolveEntity(context,external_id,system_id);
7530 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7531 parser_context=(*parser);
7532 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7533 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7535 parser->errNo=XML_ERR_NO_MEMORY;
7536 parser->input=parser_context.input;
7537 parser->inputNr=parser_context.inputNr;
7538 parser->inputMax=parser_context.inputMax;
7539 parser->inputTab=parser_context.inputTab;
7545 xmlPushInput(parser,input);
7546 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7547 if (input->filename == (char *) NULL)
7548 input->filename=(char *) xmlStrdup(system_id);
7551 input->base=parser->input->cur;
7552 input->cur=parser->input->cur;
7554 xmlParseExternalSubset(parser,external_id,system_id);
7555 while (parser->inputNr > 1)
7556 (void) xmlPopInput(parser);
7557 xmlFreeInputStream(parser->input);
7558 xmlFree(parser->inputTab);
7559 parser->input=parser_context.input;
7560 parser->inputNr=parser_context.inputNr;
7561 parser->inputMax=parser_context.inputMax;
7562 parser->inputTab=parser_context.inputTab;
7565 #if defined(__cplusplus) || defined(c_plusplus)
7569 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7570 ExceptionInfo *exception)
7573 message[MaxTextExtent];
7596 assert(image_info != (const ImageInfo *) NULL);
7597 assert(image_info->signature == MagickSignature);
7598 if (image_info->debug != MagickFalse)
7599 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7600 image_info->filename);
7601 assert(image != (Image **) NULL);
7602 msl_image=AcquireImage(image_info);
7603 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7604 if (status == MagickFalse)
7606 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7607 msl_image->filename);
7608 msl_image=DestroyImageList(msl_image);
7609 return(MagickFalse);
7611 msl_image->columns=1;
7616 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7617 msl_info.exception=exception;
7618 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7619 sizeof(*msl_info.image_info));
7620 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7621 sizeof(*msl_info.draw_info));
7622 /* top of the stack is the MSL file itself */
7623 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7624 msl_info.attributes=(Image **) AcquireMagickMemory(
7625 sizeof(*msl_info.attributes));
7626 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7627 sizeof(*msl_info.group_info));
7628 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7629 (msl_info.image == (Image **) NULL) ||
7630 (msl_info.attributes == (Image **) NULL) ||
7631 (msl_info.group_info == (MSLGroupInfo *) NULL))
7632 ThrowFatalException(ResourceLimitFatalError,
7633 "UnableToInterpretMSLImage");
7634 *msl_info.image_info=CloneImageInfo(image_info);
7635 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7636 *msl_info.attributes=AcquireImage(image_info);
7637 msl_info.group_info[0].numImages=0;
7638 /* the first slot is used to point to the MSL file image */
7639 *msl_info.image=msl_image;
7640 if (*image != (Image *) NULL)
7641 MSLPushImage(&msl_info,*image);
7642 (void) xmlSubstituteEntitiesDefault(1);
7643 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7644 sax_modules.internalSubset=MSLInternalSubset;
7645 sax_modules.isStandalone=MSLIsStandalone;
7646 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7647 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7648 sax_modules.resolveEntity=MSLResolveEntity;
7649 sax_modules.getEntity=MSLGetEntity;
7650 sax_modules.entityDecl=MSLEntityDeclaration;
7651 sax_modules.notationDecl=MSLNotationDeclaration;
7652 sax_modules.attributeDecl=MSLAttributeDeclaration;
7653 sax_modules.elementDecl=MSLElementDeclaration;
7654 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7655 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7656 sax_modules.startDocument=MSLStartDocument;
7657 sax_modules.endDocument=MSLEndDocument;
7658 sax_modules.startElement=MSLStartElement;
7659 sax_modules.endElement=MSLEndElement;
7660 sax_modules.reference=MSLReference;
7661 sax_modules.characters=MSLCharacters;
7662 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7663 sax_modules.processingInstruction=MSLProcessingInstructions;
7664 sax_modules.comment=MSLComment;
7665 sax_modules.warning=MSLWarning;
7666 sax_modules.error=MSLError;
7667 sax_modules.fatalError=MSLError;
7668 sax_modules.getParameterEntity=MSLGetParameterEntity;
7669 sax_modules.cdataBlock=MSLCDataBlock;
7670 sax_modules.externalSubset=MSLExternalSubset;
7671 sax_handler=(&sax_modules);
7672 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7673 msl_image->filename);
7674 while (ReadBlobString(msl_image,message) != (char *) NULL)
7676 n=(ssize_t) strlen(message);
7679 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7682 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7683 if (msl_info.exception->severity >= ErrorException)
7686 if (msl_info.exception->severity == UndefinedException)
7687 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7688 xmlFreeParserCtxt(msl_info.parser);
7689 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7691 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7692 msl_info.group_info);
7693 if (*image == (Image *) NULL)
7694 *image=(*msl_info.image);
7695 if ((*msl_info.image)->exception.severity != UndefinedException)
7696 return(MagickFalse);
7700 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7708 assert(image_info != (const ImageInfo *) NULL);
7709 assert(image_info->signature == MagickSignature);
7710 if (image_info->debug != MagickFalse)
7711 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7712 image_info->filename);
7713 assert(exception != (ExceptionInfo *) NULL);
7714 assert(exception->signature == MagickSignature);
7715 image=(Image *) NULL;
7716 (void) ProcessMSLScript(image_info,&image,exception);
7717 return(GetFirstImageInList(image));
7722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7726 % R e g i s t e r M S L I m a g e %
7730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7732 % RegisterMSLImage() adds attributes for the MSL image format to
7733 % the list of supported formats. The attributes include the image format
7734 % tag, a method to read and/or write the format, whether the format
7735 % supports the saving of more than one frame to the same file or blob,
7736 % whether the format supports native in-memory I/O, and a brief
7737 % description of the format.
7739 % The format of the RegisterMSLImage method is:
7741 % size_t RegisterMSLImage(void)
7744 ModuleExport size_t RegisterMSLImage(void)
7749 entry=SetMagickInfo("MSL");
7750 #if defined(MAGICKCORE_XML_DELEGATE)
7751 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7752 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7754 entry->description=ConstantString("Magick Scripting Language");
7755 entry->module=ConstantString("MSL");
7756 (void) RegisterMagickInfo(entry);
7757 return(MagickImageCoderSignature);
7760 #if defined(MAGICKCORE_XML_DELEGATE)
7762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7766 % S e t M S L A t t r i b u t e s %
7770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7772 % SetMSLAttributes() ...
7774 % The format of the SetMSLAttributes method is:
7776 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7777 % const char *keyword,const char *value)
7779 % A description of each parameter follows:
7781 % o msl_info: the MSL info.
7783 % o keyword: the keyword.
7785 % o value: the value.
7788 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7815 assert(msl_info != (MSLInfo *) NULL);
7816 if (keyword == (const char *) NULL)
7818 if (value == (const char *) NULL)
7820 exception=msl_info->exception;
7822 attributes=msl_info->attributes[n];
7823 image_info=msl_info->image_info[n];
7824 draw_info=msl_info->draw_info[n];
7825 image=msl_info->image[n];
7831 if (LocaleCompare(keyword,"adjoin") == 0)
7836 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7838 ThrowMSLException(OptionError,"UnrecognizedType",value);
7839 image_info->adjoin=(MagickBooleanType) adjoin;
7842 if (LocaleCompare(keyword,"alpha") == 0)
7847 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7849 ThrowMSLException(OptionError,"UnrecognizedType",value);
7850 if (image != (Image *) NULL)
7851 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7854 if (LocaleCompare(keyword,"antialias") == 0)
7859 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7861 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7862 image_info->antialias=(MagickBooleanType) antialias;
7865 if (LocaleCompare(keyword,"area-limit") == 0)
7870 limit=MagickResourceInfinity;
7871 if (LocaleCompare(value,"unlimited") != 0)
7872 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7873 (void) SetMagickResourceLimit(AreaResource,limit);
7876 if (LocaleCompare(keyword,"attenuate") == 0)
7878 (void) SetImageOption(image_info,keyword,value);
7881 if (LocaleCompare(keyword,"authenticate") == 0)
7883 (void) CloneString(&image_info->density,value);
7886 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7892 if (LocaleCompare(keyword,"background") == 0)
7894 (void) QueryColorDatabase(value,&image_info->background_color,
7898 if (LocaleCompare(keyword,"bias") == 0)
7900 if (image == (Image *) NULL)
7902 image->bias=SiPrefixToDouble(value,QuantumRange);
7905 if (LocaleCompare(keyword,"blue-primary") == 0)
7907 if (image == (Image *) NULL)
7909 flags=ParseGeometry(value,&geometry_info);
7910 image->chromaticity.blue_primary.x=geometry_info.rho;
7911 image->chromaticity.blue_primary.y=geometry_info.sigma;
7912 if ((flags & SigmaValue) == 0)
7913 image->chromaticity.blue_primary.y=
7914 image->chromaticity.blue_primary.x;
7917 if (LocaleCompare(keyword,"bordercolor") == 0)
7919 (void) QueryColorDatabase(value,&image_info->border_color,
7923 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7929 if (LocaleCompare(keyword,"density") == 0)
7931 (void) CloneString(&image_info->density,value);
7932 (void) CloneString(&draw_info->density,value);
7935 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7941 if (LocaleCompare(keyword,"fill") == 0)
7943 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7944 (void) SetImageOption(image_info,keyword,value);
7947 if (LocaleCompare(keyword,"filename") == 0)
7949 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7952 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7958 if (LocaleCompare(keyword,"gravity") == 0)
7963 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7965 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7966 (void) SetImageOption(image_info,keyword,value);
7969 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7975 if (LocaleCompare(keyword,"id") == 0)
7977 (void) SetImageProperty(attributes,keyword,value);
7980 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7986 if (LocaleCompare(keyword,"magick") == 0)
7988 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7991 if (LocaleCompare(keyword,"mattecolor") == 0)
7993 (void) QueryColorDatabase(value,&image_info->matte_color,
7997 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8003 if (LocaleCompare(keyword,"pointsize") == 0)
8005 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8006 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8009 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8015 if (LocaleCompare(keyword,"quality") == 0)
8017 image_info->quality=StringToLong(value);
8018 if (image == (Image *) NULL)
8020 image->quality=StringToLong(value);
8028 if (LocaleCompare(keyword,"size") == 0)
8030 (void) CloneString(&image_info->size,value);
8033 if (LocaleCompare(keyword,"stroke") == 0)
8035 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8036 (void) SetImageOption(image_info,keyword,value);
8039 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8044 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8057 % U n r e g i s t e r M S L I m a g e %
8061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8063 % UnregisterMSLImage() removes format registrations made by the
8064 % MSL module from the list of supported formats.
8066 % The format of the UnregisterMSLImage method is:
8068 % UnregisterMSLImage(void)
8071 ModuleExport void UnregisterMSLImage(void)
8073 (void) UnregisterMagickInfo("MSL");
8076 #if defined(MAGICKCORE_XML_DELEGATE)
8078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8082 % W r i t e M S L I m a g e %
8086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8088 % WriteMSLImage() writes an image to a file in MVG image format.
8090 % The format of the WriteMSLImage method is:
8092 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8094 % A description of each parameter follows.
8096 % o image_info: the image info.
8098 % o image: The image.
8101 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8103 assert(image_info != (const ImageInfo *) NULL);
8104 assert(image_info->signature == MagickSignature);
8105 assert(image != (Image *) NULL);
8106 assert(image->signature == MagickSignature);
8107 if (image->debug != MagickFalse)
8108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8109 (void) ReferenceImage(image);
8110 (void) ProcessMSLScript(image_info,&image,&image->exception);