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 PushPixelComponentMap(msl_info->image[n],channel);
740 noise_image=AddNoiseImage(msl_info->image[n],noise,
741 &msl_info->image[n]->exception);
742 PopPixelComponentMap(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 blur_image=BlurImageChannel(msl_info->image[n],channel,
1235 geometry_info.rho,geometry_info.sigma,
1236 &msl_info->image[n]->exception);
1237 if (blur_image == (Image *) NULL)
1239 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1240 msl_info->image[n]=blur_image;
1243 if (LocaleCompare((const char *) tag,"border") == 0)
1251 if (msl_info->image[n] == (Image *) NULL)
1253 ThrowMSLException(OptionError,"NoImagesDefined",
1254 (const char *) tag);
1257 SetGeometry(msl_info->image[n],&geometry);
1258 if (attributes != (const xmlChar **) NULL)
1259 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1261 keyword=(const char *) attributes[i++];
1262 attribute=InterpretImageProperties(msl_info->image_info[n],
1263 msl_info->attributes[n],(const char *) attributes[i]);
1264 CloneString(&value,attribute);
1270 if (LocaleCompare(keyword,"compose") == 0)
1272 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1275 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1277 msl_info->image[n]->compose=(CompositeOperator) option;
1280 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1287 if (LocaleCompare(keyword, "fill") == 0)
1289 (void) QueryColorDatabase(value,
1290 &msl_info->image[n]->border_color,&exception);
1293 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1300 if (LocaleCompare(keyword,"geometry") == 0)
1302 flags=ParsePageGeometry(msl_info->image[n],value,
1303 &geometry,&exception);
1304 if ((flags & HeightValue) == 0)
1305 geometry.height=geometry.width;
1308 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1315 if (LocaleCompare(keyword,"height") == 0)
1317 geometry.height=StringToLong(value);
1320 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1327 if (LocaleCompare(keyword,"width") == 0)
1329 geometry.width=StringToLong(value);
1332 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1344 border_image=BorderImage(msl_info->image[n],&geometry,
1345 &msl_info->image[n]->exception);
1346 if (border_image == (Image *) NULL)
1348 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1349 msl_info->image[n]=border_image;
1352 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1357 if (LocaleCompare((const char *) tag,"colorize") == 0)
1360 opacity[MaxTextExtent];
1371 if (msl_info->image[n] == (Image *) NULL)
1373 ThrowMSLException(OptionError,"NoImagesDefined",
1374 (const char *) tag);
1377 target=msl_info->image[n]->background_color;
1378 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1379 if (attributes != (const xmlChar **) NULL)
1380 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1382 keyword=(const char *) attributes[i++];
1383 attribute=InterpretImageProperties(msl_info->image_info[n],
1384 msl_info->attributes[n],(const char *) attributes[i]);
1385 CloneString(&value,attribute);
1391 if (LocaleCompare(keyword,"fill") == 0)
1393 (void) QueryColorDatabase(value,&target,
1394 &msl_info->image[n]->exception);
1397 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1404 if (LocaleCompare(keyword,"opacity") == 0)
1406 (void) CopyMagickString(opacity,value,MaxTextExtent);
1409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1421 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1422 &msl_info->image[n]->exception);
1423 if (colorize_image == (Image *) NULL)
1425 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1426 msl_info->image[n]=colorize_image;
1429 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1431 double radius = 0.0,
1434 if (msl_info->image[n] == (Image *) NULL)
1436 ThrowMSLException(OptionError,"NoImagesDefined",
1437 (const char *) tag);
1441 NOTE: charcoal can have no attributes, since we use all the defaults!
1443 if (attributes != (const xmlChar **) NULL)
1445 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1447 keyword=(const char *) attributes[i++];
1448 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1449 msl_info->attributes[n],(const char *) attributes[i]));
1455 if (LocaleCompare(keyword, "radius") == 0)
1457 radius = InterpretLocaleValue(value,(char **) NULL);
1460 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1466 if (LocaleCompare(keyword,"sigma") == 0)
1468 sigma = StringToLong( value );
1471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1476 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1490 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1491 &msl_info->image[n]->exception);
1492 if (newImage == (Image *) NULL)
1494 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1495 msl_info->image[n]=newImage;
1499 if (LocaleCompare((const char *) tag,"chop") == 0)
1507 if (msl_info->image[n] == (Image *) NULL)
1509 ThrowMSLException(OptionError,"NoImagesDefined",
1510 (const char *) tag);
1513 SetGeometry(msl_info->image[n],&geometry);
1514 if (attributes != (const xmlChar **) NULL)
1515 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1517 keyword=(const char *) attributes[i++];
1518 attribute=InterpretImageProperties(msl_info->image_info[n],
1519 msl_info->attributes[n],(const char *) attributes[i]);
1520 CloneString(&value,attribute);
1526 if (LocaleCompare(keyword,"geometry") == 0)
1528 flags=ParsePageGeometry(msl_info->image[n],value,
1529 &geometry,&exception);
1530 if ((flags & HeightValue) == 0)
1531 geometry.height=geometry.width;
1534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1541 if (LocaleCompare(keyword,"height") == 0)
1543 geometry.height=StringToLong(value);
1546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1553 if (LocaleCompare(keyword,"width") == 0)
1555 geometry.width=StringToLong(value);
1558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1565 if (LocaleCompare(keyword,"x") == 0)
1567 geometry.x=StringToLong(value);
1570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1577 if (LocaleCompare(keyword,"y") == 0)
1579 geometry.y=StringToLong(value);
1582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1588 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1594 chop_image=ChopImage(msl_info->image[n],&geometry,
1595 &msl_info->image[n]->exception);
1596 if (chop_image == (Image *) NULL)
1598 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1599 msl_info->image[n]=chop_image;
1602 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1611 Color floodfill image.
1613 if (msl_info->image[n] == (Image *) NULL)
1615 ThrowMSLException(OptionError,"NoImagesDefined",
1616 (const char *) tag);
1619 draw_info=CloneDrawInfo(msl_info->image_info[n],
1620 msl_info->draw_info[n]);
1621 SetGeometry(msl_info->image[n],&geometry);
1622 paint_method=FloodfillMethod;
1623 if (attributes != (const xmlChar **) NULL)
1624 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1626 keyword=(const char *) attributes[i++];
1627 attribute=InterpretImageProperties(msl_info->image_info[n],
1628 msl_info->attributes[n],(const char *) attributes[i]);
1629 CloneString(&value,attribute);
1635 if (LocaleCompare(keyword,"bordercolor") == 0)
1637 (void) QueryMagickColor(value,&target,&exception);
1638 paint_method=FillToBorderMethod;
1641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1648 if (LocaleCompare(keyword,"fill") == 0)
1650 (void) QueryColorDatabase(value,&draw_info->fill,
1654 if (LocaleCompare(keyword,"fuzz") == 0)
1656 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1667 if (LocaleCompare(keyword,"geometry") == 0)
1669 flags=ParsePageGeometry(msl_info->image[n],value,
1670 &geometry,&exception);
1671 if ((flags & HeightValue) == 0)
1672 geometry.height=geometry.width;
1673 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1674 geometry.x,geometry.y,&target,&exception);
1677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1684 if (LocaleCompare(keyword,"x") == 0)
1686 geometry.x=StringToLong(value);
1687 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1688 geometry.x,geometry.y,&target,&exception);
1691 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1698 if (LocaleCompare(keyword,"y") == 0)
1700 geometry.y=StringToLong(value);
1701 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1702 geometry.x,geometry.y,&target,&exception);
1705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1711 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1717 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1718 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1719 MagickFalse : MagickTrue);
1720 draw_info=DestroyDrawInfo(draw_info);
1723 if (LocaleCompare((const char *) tag,"comment") == 0)
1725 if (LocaleCompare((const char *) tag,"composite") == 0)
1728 composite_geometry[MaxTextExtent];
1743 if (msl_info->image[n] == (Image *) NULL)
1745 ThrowMSLException(OptionError,"NoImagesDefined",
1746 (const char *) tag);
1749 composite_image=NewImageList();
1750 compose=OverCompositeOp;
1751 if (attributes != (const xmlChar **) NULL)
1752 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1754 keyword=(const char *) attributes[i++];
1755 attribute=InterpretImageProperties(msl_info->image_info[n],
1756 msl_info->attributes[n],(const char *) attributes[i]);
1757 CloneString(&value,attribute);
1763 if (LocaleCompare(keyword,"compose") == 0)
1765 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1768 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1770 compose=(CompositeOperator) option;
1778 if (LocaleCompare(keyword,"image") == 0)
1779 for (j=0; j < msl_info->n; j++)
1784 attribute=GetImageProperty(msl_info->attributes[j],"id");
1785 if ((attribute != (const char *) NULL) &&
1786 (LocaleCompare(attribute,value) == 0))
1788 composite_image=CloneImage(msl_info->image[j],0,0,
1789 MagickFalse,&exception);
1799 if (composite_image == (Image *) NULL)
1801 rotate_image=NewImageList();
1802 SetGeometry(msl_info->image[n],&geometry);
1803 if (attributes != (const xmlChar **) NULL)
1804 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1806 keyword=(const char *) attributes[i++];
1807 attribute=InterpretImageProperties(msl_info->image_info[n],
1808 msl_info->attributes[n],(const char *) attributes[i]);
1809 CloneString(&value,attribute);
1815 if (LocaleCompare(keyword,"blend") == 0)
1817 (void) SetImageArtifact(composite_image,
1818 "compose:args",value);
1821 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1828 if (LocaleCompare(keyword,"channel") == 0)
1830 option=ParseChannelOption(value);
1832 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1834 channel=(ChannelType) option;
1837 if (LocaleCompare(keyword, "color") == 0)
1839 (void) QueryColorDatabase(value,
1840 &composite_image->background_color,&exception);
1843 if (LocaleCompare(keyword,"compose") == 0)
1845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1852 if (LocaleCompare(keyword,"geometry") == 0)
1854 flags=ParsePageGeometry(msl_info->image[n],value,
1855 &geometry,&exception);
1856 if ((flags & HeightValue) == 0)
1857 geometry.height=geometry.width;
1858 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1859 geometry.y,&target,&exception);
1862 if (LocaleCompare(keyword,"gravity") == 0)
1864 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1867 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1869 msl_info->image[n]->gravity=(GravityType) option;
1872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1879 if (LocaleCompare(keyword,"image") == 0)
1881 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1888 if (LocaleCompare(keyword,"mask") == 0)
1889 for (j=0; j < msl_info->n; j++)
1894 attribute=GetImageProperty(msl_info->attributes[j],"id");
1895 if ((attribute != (const char *) NULL) &&
1896 (LocaleCompare(value,value) == 0))
1898 SetImageType(composite_image,TrueColorMatteType);
1899 (void) CompositeImage(composite_image,
1900 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1911 if (LocaleCompare(keyword,"opacity") == 0)
1926 opacity=StringToLong(value);
1927 if (compose != DissolveCompositeOp)
1929 (void) SetImageOpacity(composite_image,(Quantum)
1933 (void) SetImageArtifact(msl_info->image[n],
1934 "compose:args",value);
1935 if (composite_image->matte != MagickTrue)
1936 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1937 composite_view=AcquireCacheView(composite_image);
1938 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1940 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1941 (ssize_t) composite_image->columns,1,&exception);
1942 for (x=0; x < (ssize_t) composite_image->columns; x++)
1944 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1945 SetPixelAlpha(composite_image,
1946 ClampToQuantum(opacity),q);
1947 q+=GetPixelComponents(composite_image);
1949 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1952 composite_view=DestroyCacheView(composite_view);
1955 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1962 if (LocaleCompare(keyword,"rotate") == 0)
1964 rotate_image=RotateImage(composite_image,
1965 InterpretLocaleValue(value,(char **) NULL),&exception);
1968 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1975 if (LocaleCompare(keyword,"tile") == 0)
1980 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1983 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1985 tile=(MagickBooleanType) option;
1987 if (rotate_image != (Image *) NULL)
1988 (void) SetImageArtifact(rotate_image,
1989 "compose:outside-overlay","false");
1991 (void) SetImageArtifact(composite_image,
1992 "compose:outside-overlay","false");
1993 image=msl_info->image[n];
1994 height=composite_image->rows;
1995 width=composite_image->columns;
1996 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1997 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1999 if (rotate_image != (Image *) NULL)
2000 (void) CompositeImage(image,compose,rotate_image,
2003 (void) CompositeImage(image,compose,
2004 composite_image,x,y);
2006 if (rotate_image != (Image *) NULL)
2007 rotate_image=DestroyImage(rotate_image);
2010 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2017 if (LocaleCompare(keyword,"x") == 0)
2019 geometry.x=StringToLong(value);
2020 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2021 geometry.y,&target,&exception);
2024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2031 if (LocaleCompare(keyword,"y") == 0)
2033 geometry.y=StringToLong(value);
2034 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2035 geometry.y,&target,&exception);
2038 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2044 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2050 image=msl_info->image[n];
2051 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2052 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2053 (double) composite_image->rows,(double) geometry.x,(double)
2055 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2057 if (rotate_image == (Image *) NULL)
2058 CompositeImageChannel(image,channel,compose,composite_image,
2059 geometry.x,geometry.y);
2065 geometry.x-=(ssize_t) (rotate_image->columns-
2066 composite_image->columns)/2;
2067 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2068 CompositeImageChannel(image,channel,compose,rotate_image,
2069 geometry.x,geometry.y);
2070 rotate_image=DestroyImage(rotate_image);
2072 composite_image=DestroyImage(composite_image);
2075 if (LocaleCompare((const char *) tag,"contrast") == 0)
2083 if (msl_info->image[n] == (Image *) NULL)
2085 ThrowMSLException(OptionError,"NoImagesDefined",
2086 (const char *) tag);
2089 sharpen=MagickFalse;
2090 if (attributes != (const xmlChar **) NULL)
2091 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2093 keyword=(const char *) attributes[i++];
2094 attribute=InterpretImageProperties(msl_info->image_info[n],
2095 msl_info->attributes[n],(const char *) attributes[i]);
2096 CloneString(&value,attribute);
2102 if (LocaleCompare(keyword,"sharpen") == 0)
2104 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2107 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2109 sharpen=(MagickBooleanType) option;
2112 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2118 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2124 (void) ContrastImage(msl_info->image[n],sharpen);
2127 if (LocaleCompare((const char *) tag,"crop") == 0)
2135 if (msl_info->image[n] == (Image *) NULL)
2137 ThrowMSLException(OptionError,"NoImagesDefined",
2138 (const char *) tag);
2141 SetGeometry(msl_info->image[n],&geometry);
2142 if (attributes != (const xmlChar **) NULL)
2143 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2145 keyword=(const char *) attributes[i++];
2146 attribute=InterpretImageProperties(msl_info->image_info[n],
2147 msl_info->attributes[n],(const char *) attributes[i]);
2148 CloneString(&value,attribute);
2154 if (LocaleCompare(keyword,"geometry") == 0)
2156 flags=ParsePageGeometry(msl_info->image[n],value,
2157 &geometry,&exception);
2158 if ((flags & HeightValue) == 0)
2159 geometry.height=geometry.width;
2162 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2169 if (LocaleCompare(keyword,"height") == 0)
2171 geometry.height=StringToLong(value);
2174 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2181 if (LocaleCompare(keyword,"width") == 0)
2183 geometry.width=StringToLong(value);
2186 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2193 if (LocaleCompare(keyword,"x") == 0)
2195 geometry.x=StringToLong(value);
2198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2205 if (LocaleCompare(keyword,"y") == 0)
2207 geometry.y=StringToLong(value);
2210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2222 crop_image=CropImage(msl_info->image[n],&geometry,
2223 &msl_info->image[n]->exception);
2224 if (crop_image == (Image *) NULL)
2226 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2227 msl_info->image[n]=crop_image;
2230 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2236 Cycle-colormap image.
2238 if (msl_info->image[n] == (Image *) NULL)
2240 ThrowMSLException(OptionError,"NoImagesDefined",
2241 (const char *) tag);
2245 if (attributes != (const xmlChar **) NULL)
2246 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2248 keyword=(const char *) attributes[i++];
2249 attribute=InterpretImageProperties(msl_info->image_info[n],
2250 msl_info->attributes[n],(const char *) attributes[i]);
2251 CloneString(&value,attribute);
2257 if (LocaleCompare(keyword,"display") == 0)
2259 display=StringToLong(value);
2262 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2268 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2274 (void) CycleColormapImage(msl_info->image[n],display);
2277 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2282 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2290 if (msl_info->image[n] == (Image *) NULL)
2292 ThrowMSLException(OptionError,"NoImagesDefined",
2293 (const char *) tag);
2296 if (attributes != (const xmlChar **) NULL)
2297 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2299 keyword=(const char *) attributes[i++];
2300 attribute=InterpretImageProperties(msl_info->image_info[n],
2301 msl_info->attributes[n],(const char *) attributes[i]);
2302 CloneString(&value,attribute);
2303 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2305 despeckle_image=DespeckleImage(msl_info->image[n],
2306 &msl_info->image[n]->exception);
2307 if (despeckle_image == (Image *) NULL)
2309 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2310 msl_info->image[n]=despeckle_image;
2313 if (LocaleCompare((const char *) tag,"display") == 0)
2315 if (msl_info->image[n] == (Image *) NULL)
2317 ThrowMSLException(OptionError,"NoImagesDefined",
2318 (const char *) tag);
2321 if (attributes != (const xmlChar **) NULL)
2322 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2324 keyword=(const char *) attributes[i++];
2325 attribute=InterpretImageProperties(msl_info->image_info[n],
2326 msl_info->attributes[n],(const char *) attributes[i]);
2327 CloneString(&value,attribute);
2332 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2338 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2341 if (LocaleCompare((const char *) tag,"draw") == 0)
2344 text[MaxTextExtent];
2349 if (msl_info->image[n] == (Image *) NULL)
2351 ThrowMSLException(OptionError,"NoImagesDefined",
2352 (const char *) tag);
2355 draw_info=CloneDrawInfo(msl_info->image_info[n],
2356 msl_info->draw_info[n]);
2358 current=draw_info->affine;
2359 GetAffineMatrix(&affine);
2360 if (attributes != (const xmlChar **) NULL)
2361 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2363 keyword=(const char *) attributes[i++];
2364 attribute=InterpretImageProperties(msl_info->image_info[n],
2365 msl_info->attributes[n],(const char *) attributes[i]);
2366 CloneString(&value,attribute);
2372 if (LocaleCompare(keyword,"affine") == 0)
2378 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2381 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2384 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2387 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2390 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2393 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2396 if (LocaleCompare(keyword,"align") == 0)
2398 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2401 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2403 draw_info->align=(AlignType) option;
2406 if (LocaleCompare(keyword,"antialias") == 0)
2408 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2411 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2413 draw_info->stroke_antialias=(MagickBooleanType) option;
2414 draw_info->text_antialias=(MagickBooleanType) option;
2417 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2424 if (LocaleCompare(keyword,"density") == 0)
2426 CloneString(&draw_info->density,value);
2429 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2436 if (LocaleCompare(keyword,"encoding") == 0)
2438 CloneString(&draw_info->encoding,value);
2441 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2448 if (LocaleCompare(keyword, "fill") == 0)
2450 (void) QueryColorDatabase(value,&draw_info->fill,
2454 if (LocaleCompare(keyword,"family") == 0)
2456 CloneString(&draw_info->family,value);
2459 if (LocaleCompare(keyword,"font") == 0)
2461 CloneString(&draw_info->font,value);
2464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2471 if (LocaleCompare(keyword,"geometry") == 0)
2473 flags=ParsePageGeometry(msl_info->image[n],value,
2474 &geometry,&exception);
2475 if ((flags & HeightValue) == 0)
2476 geometry.height=geometry.width;
2479 if (LocaleCompare(keyword,"gravity") == 0)
2481 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2484 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2486 draw_info->gravity=(GravityType) option;
2489 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2496 if (LocaleCompare(keyword,"primitive") == 0)
2498 CloneString(&draw_info->primitive,value);
2501 if (LocaleCompare(keyword,"pointsize") == 0)
2503 draw_info->pointsize=InterpretLocaleValue(value,
2507 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2514 if (LocaleCompare(keyword,"rotate") == 0)
2516 angle=InterpretLocaleValue(value,(char **) NULL);
2517 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2518 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2519 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2520 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2523 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2530 if (LocaleCompare(keyword,"scale") == 0)
2532 flags=ParseGeometry(value,&geometry_info);
2533 if ((flags & SigmaValue) == 0)
2534 geometry_info.sigma=1.0;
2535 affine.sx=geometry_info.rho;
2536 affine.sy=geometry_info.sigma;
2539 if (LocaleCompare(keyword,"skewX") == 0)
2541 angle=InterpretLocaleValue(value,(char **) NULL);
2542 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2545 if (LocaleCompare(keyword,"skewY") == 0)
2547 angle=InterpretLocaleValue(value,(char **) NULL);
2548 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2551 if (LocaleCompare(keyword,"stretch") == 0)
2553 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2556 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2558 draw_info->stretch=(StretchType) option;
2561 if (LocaleCompare(keyword, "stroke") == 0)
2563 (void) QueryColorDatabase(value,&draw_info->stroke,
2567 if (LocaleCompare(keyword,"strokewidth") == 0)
2569 draw_info->stroke_width=StringToLong(value);
2572 if (LocaleCompare(keyword,"style") == 0)
2574 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2577 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2579 draw_info->style=(StyleType) option;
2582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2589 if (LocaleCompare(keyword,"text") == 0)
2591 CloneString(&draw_info->text,value);
2594 if (LocaleCompare(keyword,"translate") == 0)
2596 flags=ParseGeometry(value,&geometry_info);
2597 if ((flags & SigmaValue) == 0)
2598 geometry_info.sigma=1.0;
2599 affine.tx=geometry_info.rho;
2600 affine.ty=geometry_info.sigma;
2603 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2610 if (LocaleCompare(keyword, "undercolor") == 0)
2612 (void) QueryColorDatabase(value,&draw_info->undercolor,
2616 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2623 if (LocaleCompare(keyword,"weight") == 0)
2625 draw_info->weight=StringToLong(value);
2628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2635 if (LocaleCompare(keyword,"x") == 0)
2637 geometry.x=StringToLong(value);
2640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2647 if (LocaleCompare(keyword,"y") == 0)
2649 geometry.y=StringToLong(value);
2652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2664 (void) FormatLocaleString(text,MaxTextExtent,
2665 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2666 geometry.height,(double) geometry.x,(double) geometry.y);
2667 CloneString(&draw_info->geometry,text);
2668 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2669 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2670 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2671 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2672 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2674 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2676 (void) DrawImage(msl_info->image[n],draw_info);
2677 draw_info=DestroyDrawInfo(draw_info);
2680 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2685 if (LocaleCompare((const char *) tag,"edge") == 0)
2693 if (msl_info->image[n] == (Image *) NULL)
2695 ThrowMSLException(OptionError,"NoImagesDefined",
2696 (const char *) tag);
2699 if (attributes != (const xmlChar **) NULL)
2700 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2702 keyword=(const char *) attributes[i++];
2703 attribute=InterpretImageProperties(msl_info->image_info[n],
2704 msl_info->attributes[n],(const char *) attributes[i]);
2705 CloneString(&value,attribute);
2711 if (LocaleCompare(keyword,"geometry") == 0)
2713 flags=ParseGeometry(value,&geometry_info);
2714 if ((flags & SigmaValue) == 0)
2715 geometry_info.sigma=1.0;
2718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2725 if (LocaleCompare(keyword,"radius") == 0)
2727 geometry_info.rho=InterpretLocaleValue(value,
2731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2743 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2744 &msl_info->image[n]->exception);
2745 if (edge_image == (Image *) NULL)
2747 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2748 msl_info->image[n]=edge_image;
2751 if (LocaleCompare((const char *) tag,"emboss") == 0)
2759 if (msl_info->image[n] == (Image *) NULL)
2761 ThrowMSLException(OptionError,"NoImagesDefined",
2762 (const char *) tag);
2765 if (attributes != (const xmlChar **) NULL)
2766 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2768 keyword=(const char *) attributes[i++];
2769 attribute=InterpretImageProperties(msl_info->image_info[n],
2770 msl_info->attributes[n],(const char *) attributes[i]);
2771 CloneString(&value,attribute);
2777 if (LocaleCompare(keyword,"geometry") == 0)
2779 flags=ParseGeometry(value,&geometry_info);
2780 if ((flags & SigmaValue) == 0)
2781 geometry_info.sigma=1.0;
2784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2791 if (LocaleCompare(keyword,"radius") == 0)
2793 geometry_info.rho=InterpretLocaleValue(value,
2797 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2804 if (LocaleCompare(keyword,"sigma") == 0)
2806 geometry_info.sigma=StringToLong(value);
2809 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2815 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2821 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2822 geometry_info.sigma,&msl_info->image[n]->exception);
2823 if (emboss_image == (Image *) NULL)
2825 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2826 msl_info->image[n]=emboss_image;
2829 if (LocaleCompare((const char *) tag,"enhance") == 0)
2837 if (msl_info->image[n] == (Image *) NULL)
2839 ThrowMSLException(OptionError,"NoImagesDefined",
2840 (const char *) tag);
2843 if (attributes != (const xmlChar **) NULL)
2844 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2846 keyword=(const char *) attributes[i++];
2847 attribute=InterpretImageProperties(msl_info->image_info[n],
2848 msl_info->attributes[n],(const char *) attributes[i]);
2849 CloneString(&value,attribute);
2850 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2852 enhance_image=EnhanceImage(msl_info->image[n],
2853 &msl_info->image[n]->exception);
2854 if (enhance_image == (Image *) NULL)
2856 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2857 msl_info->image[n]=enhance_image;
2860 if (LocaleCompare((const char *) tag,"equalize") == 0)
2865 if (msl_info->image[n] == (Image *) NULL)
2867 ThrowMSLException(OptionError,"NoImagesDefined",
2868 (const char *) tag);
2871 if (attributes != (const xmlChar **) NULL)
2872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2874 keyword=(const char *) attributes[i++];
2875 attribute=InterpretImageProperties(msl_info->image_info[n],
2876 msl_info->attributes[n],(const char *) attributes[i]);
2877 CloneString(&value,attribute);
2882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2888 (void) EqualizeImage(msl_info->image[n]);
2891 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2896 if (LocaleCompare((const char *) tag, "flatten") == 0)
2898 if (msl_info->image[n] == (Image *) NULL)
2900 ThrowMSLException(OptionError,"NoImagesDefined",
2901 (const char *) tag);
2905 /* no attributes here */
2907 /* process the image */
2912 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2913 &msl_info->image[n]->exception);
2914 if (newImage == (Image *) NULL)
2916 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2917 msl_info->image[n]=newImage;
2921 if (LocaleCompare((const char *) tag,"flip") == 0)
2929 if (msl_info->image[n] == (Image *) NULL)
2931 ThrowMSLException(OptionError,"NoImagesDefined",
2932 (const char *) tag);
2935 if (attributes != (const xmlChar **) NULL)
2936 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2938 keyword=(const char *) attributes[i++];
2939 attribute=InterpretImageProperties(msl_info->image_info[n],
2940 msl_info->attributes[n],(const char *) attributes[i]);
2941 CloneString(&value,attribute);
2942 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2944 flip_image=FlipImage(msl_info->image[n],
2945 &msl_info->image[n]->exception);
2946 if (flip_image == (Image *) NULL)
2948 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2949 msl_info->image[n]=flip_image;
2952 if (LocaleCompare((const char *) tag,"flop") == 0)
2960 if (msl_info->image[n] == (Image *) NULL)
2962 ThrowMSLException(OptionError,"NoImagesDefined",
2963 (const char *) tag);
2966 if (attributes != (const xmlChar **) NULL)
2967 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2969 keyword=(const char *) attributes[i++];
2970 attribute=InterpretImageProperties(msl_info->image_info[n],
2971 msl_info->attributes[n],(const char *) attributes[i]);
2972 CloneString(&value,attribute);
2973 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2975 flop_image=FlopImage(msl_info->image[n],
2976 &msl_info->image[n]->exception);
2977 if (flop_image == (Image *) NULL)
2979 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2980 msl_info->image[n]=flop_image;
2983 if (LocaleCompare((const char *) tag,"frame") == 0)
2994 if (msl_info->image[n] == (Image *) NULL)
2996 ThrowMSLException(OptionError,"NoImagesDefined",
2997 (const char *) tag);
3000 SetGeometry(msl_info->image[n],&geometry);
3001 if (attributes != (const xmlChar **) NULL)
3002 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3004 keyword=(const char *) attributes[i++];
3005 attribute=InterpretImageProperties(msl_info->image_info[n],
3006 msl_info->attributes[n],(const char *) attributes[i]);
3007 CloneString(&value,attribute);
3013 if (LocaleCompare(keyword,"compose") == 0)
3015 option=ParseCommandOption(MagickComposeOptions,
3018 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3020 msl_info->image[n]->compose=(CompositeOperator) option;
3023 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3030 if (LocaleCompare(keyword, "fill") == 0)
3032 (void) QueryColorDatabase(value,
3033 &msl_info->image[n]->matte_color,&exception);
3036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3043 if (LocaleCompare(keyword,"geometry") == 0)
3045 flags=ParsePageGeometry(msl_info->image[n],value,
3046 &geometry,&exception);
3047 if ((flags & HeightValue) == 0)
3048 geometry.height=geometry.width;
3049 frame_info.width=geometry.width;
3050 frame_info.height=geometry.height;
3051 frame_info.outer_bevel=geometry.x;
3052 frame_info.inner_bevel=geometry.y;
3055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3062 if (LocaleCompare(keyword,"height") == 0)
3064 frame_info.height=StringToLong(value);
3067 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3074 if (LocaleCompare(keyword,"inner") == 0)
3076 frame_info.inner_bevel=StringToLong(value);
3079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3086 if (LocaleCompare(keyword,"outer") == 0)
3088 frame_info.outer_bevel=StringToLong(value);
3091 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3098 if (LocaleCompare(keyword,"width") == 0)
3100 frame_info.width=StringToLong(value);
3103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3109 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3115 frame_info.x=(ssize_t) frame_info.width;
3116 frame_info.y=(ssize_t) frame_info.height;
3117 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3118 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3119 frame_image=FrameImage(msl_info->image[n],&frame_info,
3120 &msl_info->image[n]->exception);
3121 if (frame_image == (Image *) NULL)
3123 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3124 msl_info->image[n]=frame_image;
3127 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3132 if (LocaleCompare((const char *) tag,"gamma") == 0)
3135 gamma[MaxTextExtent];
3143 if (msl_info->image[n] == (Image *) NULL)
3145 ThrowMSLException(OptionError,"NoImagesDefined",
3146 (const char *) tag);
3149 channel=UndefinedChannel;
3154 if (attributes != (const xmlChar **) NULL)
3155 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3157 keyword=(const char *) attributes[i++];
3158 attribute=InterpretImageProperties(msl_info->image_info[n],
3159 msl_info->attributes[n],(const char *) attributes[i]);
3160 CloneString(&value,attribute);
3166 if (LocaleCompare(keyword,"blue") == 0)
3168 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3171 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3178 if (LocaleCompare(keyword,"channel") == 0)
3180 option=ParseChannelOption(value);
3182 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3184 channel=(ChannelType) option;
3187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3194 if (LocaleCompare(keyword,"gamma") == 0)
3196 (void) CopyMagickString(gamma,value,MaxTextExtent);
3199 if (LocaleCompare(keyword,"green") == 0)
3201 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3211 if (LocaleCompare(keyword,"red") == 0)
3213 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3229 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3230 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3231 (void) GammaImage(msl_info->image[n],atof(gamma));
3234 else if (LocaleCompare((const char *) tag,"get") == 0)
3236 if (msl_info->image[n] == (Image *) NULL)
3238 ThrowMSLException(OptionError,"NoImagesDefined",
3239 (const char *) tag);
3242 if (attributes == (const xmlChar **) NULL)
3244 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3246 keyword=(const char *) attributes[i++];
3247 CloneString(&value,(const char *) attributes[i]);
3248 (void) CopyMagickString(key,value,MaxTextExtent);
3254 if (LocaleCompare(keyword,"height") == 0)
3256 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3257 (double) msl_info->image[n]->rows);
3258 (void) SetImageProperty(msl_info->attributes[n],key,value);
3261 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3266 if (LocaleCompare(keyword,"width") == 0)
3268 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3269 (double) msl_info->image[n]->columns);
3270 (void) SetImageProperty(msl_info->attributes[n],key,value);
3273 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3277 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3284 else if (LocaleCompare((const char *) tag, "group") == 0)
3286 msl_info->number_groups++;
3287 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3288 msl_info->group_info,msl_info->number_groups+1UL,
3289 sizeof(*msl_info->group_info));
3292 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3297 if (LocaleCompare((const char *) tag,"image") == 0)
3299 MSLPushImage(msl_info,(Image *) NULL);
3300 if (attributes == (const xmlChar **) NULL)
3302 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3304 keyword=(const char *) attributes[i++];
3305 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3306 msl_info->attributes[n],(const char *) attributes[i]));
3312 if (LocaleCompare(keyword,"color") == 0)
3317 (void) CopyMagickString(msl_info->image_info[n]->filename,
3318 "xc:",MaxTextExtent);
3319 (void) ConcatenateMagickString(msl_info->image_info[n]->
3320 filename,value,MaxTextExtent);
3321 next_image=ReadImage(msl_info->image_info[n],&exception);
3322 CatchException(&exception);
3323 if (next_image == (Image *) NULL)
3325 if (msl_info->image[n] == (Image *) NULL)
3326 msl_info->image[n]=next_image;
3333 Link image into image list.
3335 p=msl_info->image[n];
3336 while (p->next != (Image *) NULL)
3337 p=GetNextImageInList(p);
3338 next_image->previous=p;
3343 (void) SetMSLAttributes(msl_info,keyword,value);
3348 (void) SetMSLAttributes(msl_info,keyword,value);
3355 if (LocaleCompare((const char *) tag,"implode") == 0)
3363 if (msl_info->image[n] == (Image *) NULL)
3365 ThrowMSLException(OptionError,"NoImagesDefined",
3366 (const char *) tag);
3369 if (attributes != (const xmlChar **) NULL)
3370 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3372 keyword=(const char *) attributes[i++];
3373 attribute=InterpretImageProperties(msl_info->image_info[n],
3374 msl_info->attributes[n],(const char *) attributes[i]);
3375 CloneString(&value,attribute);
3381 if (LocaleCompare(keyword,"amount") == 0)
3383 geometry_info.rho=InterpretLocaleValue(value,
3387 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3394 if (LocaleCompare(keyword,"geometry") == 0)
3396 flags=ParseGeometry(value,&geometry_info);
3397 if ((flags & SigmaValue) == 0)
3398 geometry_info.sigma=1.0;
3401 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3413 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3414 &msl_info->image[n]->exception);
3415 if (implode_image == (Image *) NULL)
3417 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3418 msl_info->image[n]=implode_image;
3421 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3426 if (LocaleCompare((const char *) tag,"label") == 0)
3428 if (LocaleCompare((const char *) tag, "level") == 0)
3431 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3433 if (msl_info->image[n] == (Image *) NULL)
3435 ThrowMSLException(OptionError,"NoImagesDefined",
3436 (const char *) tag);
3439 if (attributes == (const xmlChar **) NULL)
3441 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3443 keyword=(const char *) attributes[i++];
3444 CloneString(&value,(const char *) attributes[i]);
3445 (void) CopyMagickString(key,value,MaxTextExtent);
3451 if (LocaleCompare(keyword,"black") == 0)
3453 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3456 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3462 if (LocaleCompare(keyword,"gamma") == 0)
3464 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3473 if (LocaleCompare(keyword,"white") == 0)
3475 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3483 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3490 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma);
3497 if (LocaleCompare((const char *) tag,"magnify") == 0)
3505 if (msl_info->image[n] == (Image *) NULL)
3507 ThrowMSLException(OptionError,"NoImagesDefined",
3508 (const char *) tag);
3511 if (attributes != (const xmlChar **) NULL)
3512 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3514 keyword=(const char *) attributes[i++];
3515 attribute=InterpretImageProperties(msl_info->image_info[n],
3516 msl_info->attributes[n],(const char *) attributes[i]);
3517 CloneString(&value,attribute);
3518 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3520 magnify_image=MagnifyImage(msl_info->image[n],
3521 &msl_info->image[n]->exception);
3522 if (magnify_image == (Image *) NULL)
3524 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3525 msl_info->image[n]=magnify_image;
3528 if (LocaleCompare((const char *) tag,"map") == 0)
3542 if (msl_info->image[n] == (Image *) NULL)
3544 ThrowMSLException(OptionError,"NoImagesDefined",
3545 (const char *) tag);
3548 affinity_image=NewImageList();
3550 if (attributes != (const xmlChar **) NULL)
3551 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3553 keyword=(const char *) attributes[i++];
3554 attribute=InterpretImageProperties(msl_info->image_info[n],
3555 msl_info->attributes[n],(const char *) attributes[i]);
3556 CloneString(&value,attribute);
3562 if (LocaleCompare(keyword,"dither") == 0)
3564 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3567 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3569 dither=(MagickBooleanType) option;
3572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3579 if (LocaleCompare(keyword,"image") == 0)
3580 for (j=0; j < msl_info->n; j++)
3585 attribute=GetImageProperty(msl_info->attributes[j],"id");
3586 if ((attribute != (const char *) NULL) &&
3587 (LocaleCompare(attribute,value) == 0))
3589 affinity_image=CloneImage(msl_info->image[j],0,0,
3590 MagickFalse,&exception);
3598 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3604 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3605 quantize_info->dither=dither;
3606 (void) RemapImages(quantize_info,msl_info->image[n],
3608 quantize_info=DestroyQuantizeInfo(quantize_info);
3609 affinity_image=DestroyImage(affinity_image);
3612 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3624 Matte floodfill image.
3627 if (msl_info->image[n] == (Image *) NULL)
3629 ThrowMSLException(OptionError,"NoImagesDefined",
3630 (const char *) tag);
3633 SetGeometry(msl_info->image[n],&geometry);
3634 paint_method=FloodfillMethod;
3635 if (attributes != (const xmlChar **) NULL)
3636 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3638 keyword=(const char *) attributes[i++];
3639 attribute=InterpretImageProperties(msl_info->image_info[n],
3640 msl_info->attributes[n],(const char *) attributes[i]);
3641 CloneString(&value,attribute);
3647 if (LocaleCompare(keyword,"bordercolor") == 0)
3649 (void) QueryMagickColor(value,&target,&exception);
3650 paint_method=FillToBorderMethod;
3653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3660 if (LocaleCompare(keyword,"fuzz") == 0)
3662 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3673 if (LocaleCompare(keyword,"geometry") == 0)
3675 flags=ParsePageGeometry(msl_info->image[n],value,
3676 &geometry,&exception);
3677 if ((flags & HeightValue) == 0)
3678 geometry.height=geometry.width;
3679 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3680 geometry.x,geometry.y,&target,&exception);
3683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3690 if (LocaleCompare(keyword,"opacity") == 0)
3692 opacity=InterpretLocaleValue(value,(char **) NULL);
3695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3702 if (LocaleCompare(keyword,"x") == 0)
3704 geometry.x=StringToLong(value);
3705 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3706 geometry.x,geometry.y,&target,&exception);
3709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3716 if (LocaleCompare(keyword,"y") == 0)
3718 geometry.y=StringToLong(value);
3719 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3720 geometry.x,geometry.y,&target,&exception);
3723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3735 draw_info=CloneDrawInfo(msl_info->image_info[n],
3736 msl_info->draw_info[n]);
3737 draw_info->fill.alpha=ClampToQuantum(opacity);
3738 PushPixelComponentMap(msl_info->image[n],AlphaChannel);
3739 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3740 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3741 MagickFalse : MagickTrue);
3742 PopPixelComponentMap(msl_info->image[n]);
3743 draw_info=DestroyDrawInfo(draw_info);
3746 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3752 Median-filter image.
3754 if (msl_info->image[n] == (Image *) NULL)
3756 ThrowMSLException(OptionError,"NoImagesDefined",
3757 (const char *) tag);
3760 if (attributes != (const xmlChar **) NULL)
3761 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3763 keyword=(const char *) attributes[i++];
3764 attribute=InterpretImageProperties(msl_info->image_info[n],
3765 msl_info->attributes[n],(const char *) attributes[i]);
3766 CloneString(&value,attribute);
3772 if (LocaleCompare(keyword,"geometry") == 0)
3774 flags=ParseGeometry(value,&geometry_info);
3775 if ((flags & SigmaValue) == 0)
3776 geometry_info.sigma=1.0;
3779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3786 if (LocaleCompare(keyword,"radius") == 0)
3788 geometry_info.rho=InterpretLocaleValue(value,
3792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3804 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3805 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3806 &msl_info->image[n]->exception);
3807 if (median_image == (Image *) NULL)
3809 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3810 msl_info->image[n]=median_image;
3813 if (LocaleCompare((const char *) tag,"minify") == 0)
3821 if (msl_info->image[n] == (Image *) NULL)
3823 ThrowMSLException(OptionError,"NoImagesDefined",
3824 (const char *) tag);
3827 if (attributes != (const xmlChar **) NULL)
3828 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3830 keyword=(const char *) attributes[i++];
3831 attribute=InterpretImageProperties(msl_info->image_info[n],
3832 msl_info->attributes[n],(const char *) attributes[i]);
3833 CloneString(&value,attribute);
3834 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3836 minify_image=MinifyImage(msl_info->image[n],
3837 &msl_info->image[n]->exception);
3838 if (minify_image == (Image *) NULL)
3840 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3841 msl_info->image[n]=minify_image;
3844 if (LocaleCompare((const char *) tag,"msl") == 0 )
3846 if (LocaleCompare((const char *) tag,"modulate") == 0)
3849 modulate[MaxTextExtent];
3854 if (msl_info->image[n] == (Image *) NULL)
3856 ThrowMSLException(OptionError,"NoImagesDefined",
3857 (const char *) tag);
3860 geometry_info.rho=100.0;
3861 geometry_info.sigma=100.0;
3862 geometry_info.xi=100.0;
3863 if (attributes != (const xmlChar **) NULL)
3864 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3866 keyword=(const char *) attributes[i++];
3867 attribute=InterpretImageProperties(msl_info->image_info[n],
3868 msl_info->attributes[n],(const char *) attributes[i]);
3869 CloneString(&value,attribute);
3875 if (LocaleCompare(keyword,"blackness") == 0)
3877 geometry_info.rho=InterpretLocaleValue(value,
3881 if (LocaleCompare(keyword,"brightness") == 0)
3883 geometry_info.rho=InterpretLocaleValue(value,
3887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3894 if (LocaleCompare(keyword,"factor") == 0)
3896 flags=ParseGeometry(value,&geometry_info);
3899 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3906 if (LocaleCompare(keyword,"hue") == 0)
3908 geometry_info.xi=InterpretLocaleValue(value,
3912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3919 if (LocaleCompare(keyword,"lightness") == 0)
3921 geometry_info.rho=InterpretLocaleValue(value,
3925 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3932 if (LocaleCompare(keyword,"saturation") == 0)
3934 geometry_info.sigma=InterpretLocaleValue(value,
3938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3945 if (LocaleCompare(keyword,"whiteness") == 0)
3947 geometry_info.sigma=InterpretLocaleValue(value,
3951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3963 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3964 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3965 (void) ModulateImage(msl_info->image[n],modulate);
3968 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3973 if (LocaleCompare((const char *) tag,"negate") == 0)
3981 if (msl_info->image[n] == (Image *) NULL)
3983 ThrowMSLException(OptionError,"NoImagesDefined",
3984 (const char *) tag);
3988 if (attributes != (const xmlChar **) NULL)
3989 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3991 keyword=(const char *) attributes[i++];
3992 attribute=InterpretImageProperties(msl_info->image_info[n],
3993 msl_info->attributes[n],(const char *) attributes[i]);
3994 CloneString(&value,attribute);
4000 if (LocaleCompare(keyword,"channel") == 0)
4002 option=ParseChannelOption(value);
4004 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4006 channel=(ChannelType) option;
4009 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4016 if (LocaleCompare(keyword,"gray") == 0)
4018 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4021 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4023 gray=(MagickBooleanType) option;
4026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4038 PushPixelComponentMap(msl_info->image[n],channel);
4039 (void) NegateImage(msl_info->image[n],gray);
4040 PopPixelComponentMap(msl_info->image[n]);
4043 if (LocaleCompare((const char *) tag,"normalize") == 0)
4048 if (msl_info->image[n] == (Image *) NULL)
4050 ThrowMSLException(OptionError,"NoImagesDefined",
4051 (const char *) tag);
4054 if (attributes != (const xmlChar **) NULL)
4055 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4057 keyword=(const char *) attributes[i++];
4058 attribute=InterpretImageProperties(msl_info->image_info[n],
4059 msl_info->attributes[n],(const char *) attributes[i]);
4060 CloneString(&value,attribute);
4066 if (LocaleCompare(keyword,"channel") == 0)
4068 option=ParseChannelOption(value);
4070 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4072 channel=(ChannelType) option;
4075 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4087 (void) NormalizeImage(msl_info->image[n]);
4090 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4095 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4103 if (msl_info->image[n] == (Image *) NULL)
4105 ThrowMSLException(OptionError,"NoImagesDefined",
4106 (const char *) tag);
4109 if (attributes != (const xmlChar **) NULL)
4110 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4112 keyword=(const char *) attributes[i++];
4113 attribute=InterpretImageProperties(msl_info->image_info[n],
4114 msl_info->attributes[n],(const char *) attributes[i]);
4115 CloneString(&value,attribute);
4121 if (LocaleCompare(keyword,"geometry") == 0)
4123 flags=ParseGeometry(value,&geometry_info);
4124 if ((flags & SigmaValue) == 0)
4125 geometry_info.sigma=1.0;
4128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(keyword,"radius") == 0)
4137 geometry_info.rho=InterpretLocaleValue(value,
4141 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4153 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4154 &msl_info->image[n]->exception);
4155 if (paint_image == (Image *) NULL)
4157 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4158 msl_info->image[n]=paint_image;
4161 if (LocaleCompare((const char *) tag,"opaque") == 0)
4170 if (msl_info->image[n] == (Image *) NULL)
4172 ThrowMSLException(OptionError,"NoImagesDefined",
4173 (const char *) tag);
4176 (void) QueryMagickColor("none",&target,&exception);
4177 (void) QueryMagickColor("none",&fill_color,&exception);
4178 if (attributes != (const xmlChar **) NULL)
4179 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4181 keyword=(const char *) attributes[i++];
4182 attribute=InterpretImageProperties(msl_info->image_info[n],
4183 msl_info->attributes[n],(const char *) attributes[i]);
4184 CloneString(&value,attribute);
4190 if (LocaleCompare(keyword,"channel") == 0)
4192 option=ParseChannelOption(value);
4194 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4196 channel=(ChannelType) option;
4199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4206 if (LocaleCompare(keyword,"fill") == 0)
4208 (void) QueryMagickColor(value,&fill_color,&exception);
4211 if (LocaleCompare(keyword,"fuzz") == 0)
4213 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4229 PushPixelComponentMap(msl_info->image[n],channel);
4230 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4232 PopPixelComponentMap(msl_info->image[n]);
4235 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4240 if (LocaleCompare((const char *) tag,"print") == 0)
4242 if (attributes == (const xmlChar **) NULL)
4244 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4246 keyword=(const char *) attributes[i++];
4247 attribute=InterpretImageProperties(msl_info->image_info[n],
4248 msl_info->attributes[n],(const char *) attributes[i]);
4249 CloneString(&value,attribute);
4255 if (LocaleCompare(keyword,"output") == 0)
4257 (void) FormatLocaleFile(stdout,"%s",value);
4260 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4265 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4272 if (LocaleCompare((const char *) tag, "profile") == 0)
4274 if (msl_info->image[n] == (Image *) NULL)
4276 ThrowMSLException(OptionError,"NoImagesDefined",
4277 (const char *) tag);
4280 if (attributes == (const xmlChar **) NULL)
4282 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4296 keyword=(const char *) attributes[i++];
4297 attribute=InterpretImageProperties(msl_info->image_info[n],
4298 msl_info->attributes[n],(const char *) attributes[i]);
4299 CloneString(&value,attribute);
4300 if (*keyword == '+')
4303 Remove a profile from the image.
4305 (void) ProfileImage(msl_info->image[n],keyword,
4306 (const unsigned char *) NULL,0,MagickTrue);
4310 Associate a profile with the image.
4312 profile_info=CloneImageInfo(msl_info->image_info[n]);
4313 profile=GetImageProfile(msl_info->image[n],"iptc");
4314 if (profile != (StringInfo *) NULL)
4315 profile_info->profile=(void *) CloneStringInfo(profile);
4316 profile_image=GetImageCache(profile_info,keyword,&exception);
4317 profile_info=DestroyImageInfo(profile_info);
4318 if (profile_image == (Image *) NULL)
4321 name[MaxTextExtent],
4322 filename[MaxTextExtent];
4330 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4331 (void) CopyMagickString(name,keyword,MaxTextExtent);
4332 for (p=filename; *p != '\0'; p++)
4333 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4334 (IsPathAccessible(keyword) == MagickFalse))
4340 Look for profile name (e.g. name:profile).
4342 (void) CopyMagickString(name,filename,(size_t)
4344 for (q=filename; *q != '\0'; q++)
4348 profile=FileToStringInfo(filename,~0UL,&exception);
4349 if (profile != (StringInfo *) NULL)
4351 (void) ProfileImage(msl_info->image[n],name,
4352 GetStringInfoDatum(profile),(size_t)
4353 GetStringInfoLength(profile),MagickFalse);
4354 profile=DestroyStringInfo(profile);
4358 ResetImageProfileIterator(profile_image);
4359 name=GetNextImageProfile(profile_image);
4360 while (name != (const char *) NULL)
4362 profile=GetImageProfile(profile_image,name);
4363 if (profile != (StringInfo *) NULL)
4364 (void) ProfileImage(msl_info->image[n],name,
4365 GetStringInfoDatum(profile),(size_t)
4366 GetStringInfoLength(profile),MagickFalse);
4367 name=GetNextImageProfile(profile_image);
4369 profile_image=DestroyImage(profile_image);
4373 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4378 if (LocaleCompare((const char *) tag,"quantize") == 0)
4386 if (msl_info->image[n] == (Image *) NULL)
4388 ThrowMSLException(OptionError,"NoImagesDefined",
4389 (const char *) tag);
4392 GetQuantizeInfo(&quantize_info);
4393 if (attributes != (const xmlChar **) NULL)
4394 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4396 keyword=(const char *) attributes[i++];
4397 attribute=InterpretImageProperties(msl_info->image_info[n],
4398 msl_info->attributes[n],(const char *) attributes[i]);
4399 CloneString(&value,attribute);
4405 if (LocaleCompare(keyword,"colors") == 0)
4407 quantize_info.number_colors=StringToLong(value);
4410 if (LocaleCompare(keyword,"colorspace") == 0)
4412 option=ParseCommandOption(MagickColorspaceOptions,
4415 ThrowMSLException(OptionError,
4416 "UnrecognizedColorspaceType",value);
4417 quantize_info.colorspace=(ColorspaceType) option;
4420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4427 if (LocaleCompare(keyword,"dither") == 0)
4429 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4432 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4434 quantize_info.dither=(MagickBooleanType) option;
4437 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4444 if (LocaleCompare(keyword,"measure") == 0)
4446 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4449 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4451 quantize_info.measure_error=(MagickBooleanType) option;
4454 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4461 if (LocaleCompare(keyword,"treedepth") == 0)
4463 quantize_info.tree_depth=StringToLong(value);
4466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4472 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4478 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4481 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4484 text[MaxTextExtent];
4495 draw_info=CloneDrawInfo(msl_info->image_info[n],
4496 msl_info->draw_info[n]);
4498 current=draw_info->affine;
4499 GetAffineMatrix(&affine);
4500 if (attributes != (const xmlChar **) NULL)
4501 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4503 keyword=(const char *) attributes[i++];
4504 attribute=InterpretImageProperties(msl_info->image_info[n],
4505 msl_info->attributes[n],(const char *) attributes[i]);
4506 CloneString(&value,attribute);
4512 if (LocaleCompare(keyword,"affine") == 0)
4518 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4521 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4524 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4527 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4530 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4533 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4536 if (LocaleCompare(keyword,"align") == 0)
4538 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4541 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4543 draw_info->align=(AlignType) option;
4546 if (LocaleCompare(keyword,"antialias") == 0)
4548 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4551 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4553 draw_info->stroke_antialias=(MagickBooleanType) option;
4554 draw_info->text_antialias=(MagickBooleanType) option;
4557 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4564 if (LocaleCompare(keyword,"density") == 0)
4566 CloneString(&draw_info->density,value);
4569 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4576 if (LocaleCompare(keyword,"encoding") == 0)
4578 CloneString(&draw_info->encoding,value);
4581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4588 if (LocaleCompare(keyword, "fill") == 0)
4590 (void) QueryColorDatabase(value,&draw_info->fill,
4594 if (LocaleCompare(keyword,"family") == 0)
4596 CloneString(&draw_info->family,value);
4599 if (LocaleCompare(keyword,"font") == 0)
4601 CloneString(&draw_info->font,value);
4604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4611 if (LocaleCompare(keyword,"geometry") == 0)
4613 flags=ParsePageGeometry(msl_info->image[n],value,
4614 &geometry,&exception);
4615 if ((flags & HeightValue) == 0)
4616 geometry.height=geometry.width;
4619 if (LocaleCompare(keyword,"gravity") == 0)
4621 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4624 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4626 draw_info->gravity=(GravityType) option;
4629 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4636 if (LocaleCompare(keyword,"pointsize") == 0)
4638 draw_info->pointsize=InterpretLocaleValue(value,
4642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4649 if (LocaleCompare(keyword,"rotate") == 0)
4651 angle=InterpretLocaleValue(value,(char **) NULL);
4652 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4653 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4654 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4655 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4665 if (LocaleCompare(keyword,"scale") == 0)
4667 flags=ParseGeometry(value,&geometry_info);
4668 if ((flags & SigmaValue) == 0)
4669 geometry_info.sigma=1.0;
4670 affine.sx=geometry_info.rho;
4671 affine.sy=geometry_info.sigma;
4674 if (LocaleCompare(keyword,"skewX") == 0)
4676 angle=InterpretLocaleValue(value,(char **) NULL);
4677 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4680 if (LocaleCompare(keyword,"skewY") == 0)
4682 angle=InterpretLocaleValue(value,(char **) NULL);
4683 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4686 if (LocaleCompare(keyword,"stretch") == 0)
4688 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4691 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4693 draw_info->stretch=(StretchType) option;
4696 if (LocaleCompare(keyword, "stroke") == 0)
4698 (void) QueryColorDatabase(value,&draw_info->stroke,
4702 if (LocaleCompare(keyword,"strokewidth") == 0)
4704 draw_info->stroke_width=StringToLong(value);
4707 if (LocaleCompare(keyword,"style") == 0)
4709 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4712 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4714 draw_info->style=(StyleType) option;
4717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4724 if (LocaleCompare(keyword,"text") == 0)
4726 CloneString(&draw_info->text,value);
4729 if (LocaleCompare(keyword,"translate") == 0)
4731 flags=ParseGeometry(value,&geometry_info);
4732 if ((flags & SigmaValue) == 0)
4733 geometry_info.sigma=1.0;
4734 affine.tx=geometry_info.rho;
4735 affine.ty=geometry_info.sigma;
4738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4745 if (LocaleCompare(keyword, "undercolor") == 0)
4747 (void) QueryColorDatabase(value,&draw_info->undercolor,
4751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4758 if (LocaleCompare(keyword,"weight") == 0)
4760 draw_info->weight=StringToLong(value);
4763 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4770 if (LocaleCompare(keyword,"x") == 0)
4772 geometry.x=StringToLong(value);
4775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4782 if (LocaleCompare(keyword,"y") == 0)
4784 geometry.y=StringToLong(value);
4787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4793 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4799 (void) FormatLocaleString(text,MaxTextExtent,
4800 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4801 geometry.height,(double) geometry.x,(double) geometry.y);
4802 CloneString(&draw_info->geometry,text);
4803 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4804 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4805 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4806 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4807 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4809 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4811 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4812 if (status != MagickFalse)
4817 image=msl_info->attributes[n];
4818 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4819 "%g",metrics.pixels_per_em.x);
4820 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4821 "%g",metrics.pixels_per_em.y);
4822 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4824 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4826 FormatImageProperty(image,"msl:font-metrics.width","%g",
4828 FormatImageProperty(image,"msl:font-metrics.height","%g",
4830 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4831 metrics.max_advance);
4832 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4834 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4836 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4838 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4840 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4842 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4845 draw_info=DestroyDrawInfo(draw_info);
4848 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4853 if (LocaleCompare((const char *) tag,"raise") == 0)
4861 if (msl_info->image[n] == (Image *) NULL)
4863 ThrowMSLException(OptionError,"NoImagesDefined",
4864 (const char *) tag);
4868 SetGeometry(msl_info->image[n],&geometry);
4869 if (attributes != (const xmlChar **) NULL)
4870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4872 keyword=(const char *) attributes[i++];
4873 attribute=InterpretImageProperties(msl_info->image_info[n],
4874 msl_info->attributes[n],(const char *) attributes[i]);
4875 CloneString(&value,attribute);
4881 if (LocaleCompare(keyword,"geometry") == 0)
4883 flags=ParsePageGeometry(msl_info->image[n],value,
4884 &geometry,&exception);
4885 if ((flags & HeightValue) == 0)
4886 geometry.height=geometry.width;
4889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4896 if (LocaleCompare(keyword,"height") == 0)
4898 geometry.height=StringToLong(value);
4901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4908 if (LocaleCompare(keyword,"raise") == 0)
4910 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4913 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4915 raise=(MagickBooleanType) option;
4918 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4925 if (LocaleCompare(keyword,"width") == 0)
4927 geometry.width=StringToLong(value);
4930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4942 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4945 if (LocaleCompare((const char *) tag,"read") == 0)
4947 if (attributes == (const xmlChar **) NULL)
4949 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4951 keyword=(const char *) attributes[i++];
4952 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4953 msl_info->attributes[n],(const char *) attributes[i]));
4959 if (LocaleCompare(keyword,"filename") == 0)
4964 (void) CopyMagickString(msl_info->image_info[n]->filename,
4965 value,MaxTextExtent);
4966 image=ReadImage(msl_info->image_info[n],&exception);
4967 CatchException(&exception);
4968 if (image == (Image *) NULL)
4970 AppendImageToList(&msl_info->image[n],image);
4973 (void) SetMSLAttributes(msl_info,keyword,value);
4978 (void) SetMSLAttributes(msl_info,keyword,value);
4985 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4993 if (msl_info->image[n] == (Image *) NULL)
4995 ThrowMSLException(OptionError,"NoImagesDefined",
4996 (const char *) tag);
4999 if (attributes != (const xmlChar **) NULL)
5000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5002 keyword=(const char *) attributes[i++];
5003 attribute=InterpretImageProperties(msl_info->image_info[n],
5004 msl_info->attributes[n],(const char *) attributes[i]);
5005 CloneString(&value,attribute);
5011 if (LocaleCompare(keyword,"geometry") == 0)
5013 flags=ParseGeometry(value,&geometry_info);
5014 if ((flags & SigmaValue) == 0)
5015 geometry_info.sigma=1.0;
5018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5025 if (LocaleCompare(keyword,"radius") == 0)
5027 geometry_info.rho=InterpretLocaleValue(value,
5031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5043 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5044 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5045 &msl_info->image[n]->exception);
5046 if (paint_image == (Image *) NULL)
5048 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5049 msl_info->image[n]=paint_image;
5052 else if (LocaleCompare((const char *) tag,"repage") == 0)
5054 /* init the values */
5055 width=msl_info->image[n]->page.width;
5056 height=msl_info->image[n]->page.height;
5057 x=msl_info->image[n]->page.x;
5058 y=msl_info->image[n]->page.y;
5060 if (msl_info->image[n] == (Image *) NULL)
5062 ThrowMSLException(OptionError,"NoImagesDefined",
5063 (const char *) tag);
5066 if (attributes == (const xmlChar **) NULL)
5068 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5070 keyword=(const char *) attributes[i++];
5071 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5072 msl_info->attributes[n],(const char *) attributes[i]));
5078 if (LocaleCompare(keyword,"geometry") == 0)
5086 flags=ParseAbsoluteGeometry(value,&geometry);
5087 if ((flags & WidthValue) != 0)
5089 if ((flags & HeightValue) == 0)
5090 geometry.height=geometry.width;
5091 width=geometry.width;
5092 height=geometry.height;
5094 if ((flags & AspectValue) != 0)
5096 if ((flags & XValue) != 0)
5098 if ((flags & YValue) != 0)
5103 if ((flags & XValue) != 0)
5106 if ((width == 0) && (geometry.x > 0))
5107 width=msl_info->image[n]->columns+geometry.x;
5109 if ((flags & YValue) != 0)
5112 if ((height == 0) && (geometry.y > 0))
5113 height=msl_info->image[n]->rows+geometry.y;
5118 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5124 if (LocaleCompare(keyword,"height") == 0)
5126 height = StringToLong( value );
5129 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5135 if (LocaleCompare(keyword,"width") == 0)
5137 width = StringToLong( value );
5140 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5146 if (LocaleCompare(keyword,"x") == 0)
5148 x = StringToLong( value );
5151 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5157 if (LocaleCompare(keyword,"y") == 0)
5159 y = StringToLong( value );
5162 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5167 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5173 msl_info->image[n]->page.width=width;
5174 msl_info->image[n]->page.height=height;
5175 msl_info->image[n]->page.x=x;
5176 msl_info->image[n]->page.y=y;
5179 else if (LocaleCompare((const char *) tag,"resample") == 0)
5185 if (msl_info->image[n] == (Image *) NULL)
5187 ThrowMSLException(OptionError,"NoImagesDefined",
5188 (const char *) tag);
5191 if (attributes == (const xmlChar **) NULL)
5193 x_resolution=DefaultResolution;
5194 y_resolution=DefaultResolution;
5195 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5197 keyword=(const char *) attributes[i++];
5198 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5199 msl_info->attributes[n],(const char *) attributes[i]));
5204 if (LocaleCompare(keyword,"blur") == 0)
5206 msl_info->image[n]->blur=InterpretLocaleValue(value,
5210 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5216 if (LocaleCompare(keyword,"geometry") == 0)
5221 flags=ParseGeometry(value,&geometry_info);
5222 if ((flags & SigmaValue) == 0)
5223 geometry_info.sigma*=geometry_info.rho;
5224 x_resolution=geometry_info.rho;
5225 y_resolution=geometry_info.sigma;
5228 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5234 if (LocaleCompare(keyword,"x-resolution") == 0)
5236 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5239 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5245 if (LocaleCompare(keyword,"y-resolution") == 0)
5247 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5250 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5255 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5271 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5273 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5274 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5275 msl_info->image[n]->x_resolution))+0.5);
5276 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5277 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5278 msl_info->image[n]->y_resolution))+0.5);
5279 resample_image=ResizeImage(msl_info->image[n],width,height,
5280 msl_info->image[n]->filter,msl_info->image[n]->blur,
5281 &msl_info->image[n]->exception);
5282 if (resample_image == (Image *) NULL)
5284 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5285 msl_info->image[n]=resample_image;
5289 if (LocaleCompare((const char *) tag,"resize") == 0)
5303 if (msl_info->image[n] == (Image *) NULL)
5305 ThrowMSLException(OptionError,"NoImagesDefined",
5306 (const char *) tag);
5309 filter=UndefinedFilter;
5311 if (attributes != (const xmlChar **) NULL)
5312 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5314 keyword=(const char *) attributes[i++];
5315 attribute=InterpretImageProperties(msl_info->image_info[n],
5316 msl_info->attributes[n],(const char *) attributes[i]);
5317 CloneString(&value,attribute);
5323 if (LocaleCompare(keyword,"filter") == 0)
5325 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5328 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5330 filter=(FilterTypes) option;
5333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5340 if (LocaleCompare(keyword,"geometry") == 0)
5342 flags=ParseRegionGeometry(msl_info->image[n],value,
5343 &geometry,&exception);
5346 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5353 if (LocaleCompare(keyword,"height") == 0)
5355 geometry.height=StringToUnsignedLong(value);
5358 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5365 if (LocaleCompare(keyword,"support") == 0)
5367 blur=InterpretLocaleValue(value,(char **) NULL);
5370 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5377 if (LocaleCompare(keyword,"width") == 0)
5379 geometry.width=StringToLong(value);
5382 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5388 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5394 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5395 geometry.height,filter,blur,&msl_info->image[n]->exception);
5396 if (resize_image == (Image *) NULL)
5398 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5399 msl_info->image[n]=resize_image;
5402 if (LocaleCompare((const char *) tag,"roll") == 0)
5410 if (msl_info->image[n] == (Image *) NULL)
5412 ThrowMSLException(OptionError,"NoImagesDefined",
5413 (const char *) tag);
5416 SetGeometry(msl_info->image[n],&geometry);
5417 if (attributes != (const xmlChar **) NULL)
5418 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5420 keyword=(const char *) attributes[i++];
5421 attribute=InterpretImageProperties(msl_info->image_info[n],
5422 msl_info->attributes[n],(const char *) attributes[i]);
5423 CloneString(&value,attribute);
5429 if (LocaleCompare(keyword,"geometry") == 0)
5431 flags=ParsePageGeometry(msl_info->image[n],value,
5432 &geometry,&exception);
5433 if ((flags & HeightValue) == 0)
5434 geometry.height=geometry.width;
5437 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5444 if (LocaleCompare(keyword,"x") == 0)
5446 geometry.x=StringToLong(value);
5449 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5456 if (LocaleCompare(keyword,"y") == 0)
5458 geometry.y=StringToLong(value);
5461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5473 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5474 &msl_info->image[n]->exception);
5475 if (roll_image == (Image *) NULL)
5477 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5478 msl_info->image[n]=roll_image;
5481 else if (LocaleCompare((const char *) tag,"roll") == 0)
5483 /* init the values */
5484 width=msl_info->image[n]->columns;
5485 height=msl_info->image[n]->rows;
5488 if (msl_info->image[n] == (Image *) NULL)
5490 ThrowMSLException(OptionError,"NoImagesDefined",
5491 (const char *) tag);
5494 if (attributes == (const xmlChar **) NULL)
5496 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5498 keyword=(const char *) attributes[i++];
5499 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5500 msl_info->attributes[n],(const char *) attributes[i]));
5506 if (LocaleCompare(keyword,"geometry") == 0)
5508 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5511 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5517 if (LocaleCompare(keyword,"x") == 0)
5519 x = StringToLong( value );
5522 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5528 if (LocaleCompare(keyword,"y") == 0)
5530 y = StringToLong( value );
5533 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5538 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5551 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5552 if (newImage == (Image *) NULL)
5554 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5555 msl_info->image[n]=newImage;
5560 if (LocaleCompare((const char *) tag,"rotate") == 0)
5568 if (msl_info->image[n] == (Image *) NULL)
5570 ThrowMSLException(OptionError,"NoImagesDefined",
5571 (const char *) tag);
5574 if (attributes != (const xmlChar **) NULL)
5575 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5577 keyword=(const char *) attributes[i++];
5578 attribute=InterpretImageProperties(msl_info->image_info[n],
5579 msl_info->attributes[n],(const char *) attributes[i]);
5580 CloneString(&value,attribute);
5586 if (LocaleCompare(keyword,"degrees") == 0)
5588 geometry_info.rho=InterpretLocaleValue(value,
5592 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5599 if (LocaleCompare(keyword,"geometry") == 0)
5601 flags=ParseGeometry(value,&geometry_info);
5602 if ((flags & SigmaValue) == 0)
5603 geometry_info.sigma=1.0;
5606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5618 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5619 &msl_info->image[n]->exception);
5620 if (rotate_image == (Image *) NULL)
5622 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5623 msl_info->image[n]=rotate_image;
5626 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5628 /* init the values */
5631 if (msl_info->image[n] == (Image *) NULL)
5633 ThrowMSLException(OptionError,"NoImagesDefined",
5634 (const char *) tag);
5637 if (attributes == (const xmlChar **) NULL)
5639 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5641 keyword=(const char *) attributes[i++];
5642 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5643 msl_info->attributes[n],(const char *) attributes[i]));
5649 if (LocaleCompare(keyword,"degrees") == 0)
5651 degrees = InterpretLocaleValue(value,(char **) NULL);
5654 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5659 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5672 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5673 if (newImage == (Image *) NULL)
5675 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5676 msl_info->image[n]=newImage;
5681 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5686 if (LocaleCompare((const char *) tag,"sample") == 0)
5694 if (msl_info->image[n] == (Image *) NULL)
5696 ThrowMSLException(OptionError,"NoImagesDefined",
5697 (const char *) tag);
5700 if (attributes != (const xmlChar **) NULL)
5701 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5703 keyword=(const char *) attributes[i++];
5704 attribute=InterpretImageProperties(msl_info->image_info[n],
5705 msl_info->attributes[n],(const char *) attributes[i]);
5706 CloneString(&value,attribute);
5712 if (LocaleCompare(keyword,"geometry") == 0)
5714 flags=ParseRegionGeometry(msl_info->image[n],value,
5715 &geometry,&exception);
5718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5725 if (LocaleCompare(keyword,"height") == 0)
5727 geometry.height=StringToUnsignedLong(value);
5730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5737 if (LocaleCompare(keyword,"width") == 0)
5739 geometry.width=StringToLong(value);
5742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5748 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5754 sample_image=SampleImage(msl_info->image[n],geometry.width,
5755 geometry.height,&msl_info->image[n]->exception);
5756 if (sample_image == (Image *) NULL)
5758 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5759 msl_info->image[n]=sample_image;
5762 if (LocaleCompare((const char *) tag,"scale") == 0)
5770 if (msl_info->image[n] == (Image *) NULL)
5772 ThrowMSLException(OptionError,"NoImagesDefined",
5773 (const char *) tag);
5776 if (attributes != (const xmlChar **) NULL)
5777 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5779 keyword=(const char *) attributes[i++];
5780 attribute=InterpretImageProperties(msl_info->image_info[n],
5781 msl_info->attributes[n],(const char *) attributes[i]);
5782 CloneString(&value,attribute);
5788 if (LocaleCompare(keyword,"geometry") == 0)
5790 flags=ParseRegionGeometry(msl_info->image[n],value,
5791 &geometry,&exception);
5794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5801 if (LocaleCompare(keyword,"height") == 0)
5803 geometry.height=StringToUnsignedLong(value);
5806 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5813 if (LocaleCompare(keyword,"width") == 0)
5815 geometry.width=StringToLong(value);
5818 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5824 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5830 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5831 geometry.height,&msl_info->image[n]->exception);
5832 if (scale_image == (Image *) NULL)
5834 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5835 msl_info->image[n]=scale_image;
5838 if (LocaleCompare((const char *) tag,"segment") == 0)
5849 if (msl_info->image[n] == (Image *) NULL)
5851 ThrowMSLException(OptionError,"NoImagesDefined",
5852 (const char *) tag);
5855 geometry_info.rho=1.0;
5856 geometry_info.sigma=1.5;
5857 colorspace=RGBColorspace;
5858 verbose=MagickFalse;
5859 if (attributes != (const xmlChar **) NULL)
5860 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5862 keyword=(const char *) attributes[i++];
5863 attribute=InterpretImageProperties(msl_info->image_info[n],
5864 msl_info->attributes[n],(const char *) attributes[i]);
5865 CloneString(&value,attribute);
5871 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5873 geometry_info.rho=InterpretLocaleValue(value,
5877 if (LocaleCompare(keyword,"colorspace") == 0)
5879 option=ParseCommandOption(MagickColorspaceOptions,
5882 ThrowMSLException(OptionError,
5883 "UnrecognizedColorspaceType",value);
5884 colorspace=(ColorspaceType) option;
5887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5894 if (LocaleCompare(keyword,"geometry") == 0)
5896 flags=ParseGeometry(value,&geometry_info);
5897 if ((flags & SigmaValue) == 0)
5898 geometry_info.sigma=1.5;
5901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5908 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5910 geometry_info.sigma=InterpretLocaleValue(value,
5914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5920 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5926 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5927 geometry_info.rho,geometry_info.sigma);
5930 else if (LocaleCompare((const char *) tag, "set") == 0)
5932 if (msl_info->image[n] == (Image *) NULL)
5934 ThrowMSLException(OptionError,"NoImagesDefined",
5935 (const char *) tag);
5939 if (attributes == (const xmlChar **) NULL)
5941 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5943 keyword=(const char *) attributes[i++];
5944 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5945 msl_info->attributes[n],(const char *) attributes[i]));
5951 if (LocaleCompare(keyword,"clip-mask") == 0)
5953 for (j=0; j < msl_info->n; j++)
5958 property=GetImageProperty(msl_info->attributes[j],"id");
5959 if (LocaleCompare(property,value) == 0)
5961 SetImageMask(msl_info->image[n],msl_info->image[j]);
5967 if (LocaleCompare(keyword,"clip-path") == 0)
5969 for (j=0; j < msl_info->n; j++)
5974 property=GetImageProperty(msl_info->attributes[j],"id");
5975 if (LocaleCompare(property,value) == 0)
5977 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5983 if (LocaleCompare(keyword,"colorspace") == 0)
5988 colorspace=(ColorspaceType) ParseCommandOption(
5989 MagickColorspaceOptions,MagickFalse,value);
5991 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5993 (void) TransformImageColorspace(msl_info->image[n],
5994 (ColorspaceType) colorspace);
5997 (void) SetMSLAttributes(msl_info,keyword,value);
6003 if (LocaleCompare(keyword,"density") == 0)
6005 flags=ParseGeometry(value,&geometry_info);
6006 msl_info->image[n]->x_resolution=geometry_info.rho;
6007 msl_info->image[n]->y_resolution=geometry_info.sigma;
6008 if ((flags & SigmaValue) == 0)
6009 msl_info->image[n]->y_resolution=
6010 msl_info->image[n]->x_resolution;
6013 (void) SetMSLAttributes(msl_info,keyword,value);
6019 if (LocaleCompare(keyword, "opacity") == 0)
6021 ssize_t opac = OpaqueAlpha,
6022 len = (ssize_t) strlen( value );
6024 if (value[len-1] == '%') {
6026 (void) CopyMagickString(tmp,value,len);
6027 opac = StringToLong( tmp );
6028 opac = (int)(QuantumRange * ((float)opac/100));
6030 opac = StringToLong( value );
6031 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6034 (void) SetMSLAttributes(msl_info,keyword,value);
6040 if (LocaleCompare(keyword, "page") == 0)
6043 page[MaxTextExtent];
6054 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6055 image_option=GetImageOption(msl_info->image_info[n],"page");
6056 if (image_option != (const char *) NULL)
6057 flags=ParseAbsoluteGeometry(image_option,&geometry);
6058 flags=ParseAbsoluteGeometry(value,&geometry);
6059 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6060 (double) geometry.width,(double) geometry.height);
6061 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6062 (void) FormatLocaleString(page,MaxTextExtent,
6063 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6064 (double) geometry.height,(double) geometry.x,(double)
6066 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6067 msl_info->image_info[n]->page=GetPageGeometry(page);
6070 (void) SetMSLAttributes(msl_info,keyword,value);
6075 (void) SetMSLAttributes(msl_info,keyword,value);
6082 if (LocaleCompare((const char *) tag,"shade") == 0)
6093 if (msl_info->image[n] == (Image *) NULL)
6095 ThrowMSLException(OptionError,"NoImagesDefined",
6096 (const char *) tag);
6100 if (attributes != (const xmlChar **) NULL)
6101 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6103 keyword=(const char *) attributes[i++];
6104 attribute=InterpretImageProperties(msl_info->image_info[n],
6105 msl_info->attributes[n],(const char *) attributes[i]);
6106 CloneString(&value,attribute);
6112 if (LocaleCompare(keyword,"azimuth") == 0)
6114 geometry_info.rho=InterpretLocaleValue(value,
6118 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6125 if (LocaleCompare(keyword,"elevation") == 0)
6127 geometry_info.sigma=InterpretLocaleValue(value,
6131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6138 if (LocaleCompare(keyword,"geometry") == 0)
6140 flags=ParseGeometry(value,&geometry_info);
6141 if ((flags & SigmaValue) == 0)
6142 geometry_info.sigma=1.0;
6145 if (LocaleCompare(keyword,"gray") == 0)
6147 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6150 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6152 gray=(MagickBooleanType) option;
6155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6161 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6167 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6168 geometry_info.sigma,&msl_info->image[n]->exception);
6169 if (shade_image == (Image *) NULL)
6171 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6172 msl_info->image[n]=shade_image;
6175 if (LocaleCompare((const char *) tag,"shadow") == 0)
6183 if (msl_info->image[n] == (Image *) NULL)
6185 ThrowMSLException(OptionError,"NoImagesDefined",
6186 (const char *) tag);
6189 if (attributes != (const xmlChar **) NULL)
6190 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6192 keyword=(const char *) attributes[i++];
6193 attribute=InterpretImageProperties(msl_info->image_info[n],
6194 msl_info->attributes[n],(const char *) attributes[i]);
6195 CloneString(&value,attribute);
6201 if (LocaleCompare(keyword,"geometry") == 0)
6203 flags=ParseGeometry(value,&geometry_info);
6204 if ((flags & SigmaValue) == 0)
6205 geometry_info.sigma=1.0;
6208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6215 if (LocaleCompare(keyword,"opacity") == 0)
6217 geometry_info.rho=StringToLong(value);
6220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6227 if (LocaleCompare(keyword,"sigma") == 0)
6229 geometry_info.sigma=StringToLong(value);
6237 if (LocaleCompare(keyword,"x") == 0)
6239 geometry_info.xi=InterpretLocaleValue(value,
6243 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6250 if (LocaleCompare(keyword,"y") == 0)
6252 geometry_info.psi=StringToLong(value);
6255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6267 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6268 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6269 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6270 if (shadow_image == (Image *) NULL)
6272 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6273 msl_info->image[n]=shadow_image;
6276 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6278 double radius = 0.0,
6281 if (msl_info->image[n] == (Image *) NULL)
6283 ThrowMSLException(OptionError,"NoImagesDefined",
6284 (const char *) tag);
6288 NOTE: sharpen can have no attributes, since we use all the defaults!
6290 if (attributes != (const xmlChar **) NULL)
6292 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6294 keyword=(const char *) attributes[i++];
6295 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6296 msl_info->attributes[n],(const char *) attributes[i]));
6302 if (LocaleCompare(keyword, "radius") == 0)
6304 radius = InterpretLocaleValue(value,(char **) NULL);
6307 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6313 if (LocaleCompare(keyword,"sigma") == 0)
6315 sigma = StringToLong( value );
6318 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6323 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6337 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6338 if (newImage == (Image *) NULL)
6340 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6341 msl_info->image[n]=newImage;
6345 else if (LocaleCompare((const char *) tag,"shave") == 0)
6347 /* init the values */
6351 if (msl_info->image[n] == (Image *) NULL)
6353 ThrowMSLException(OptionError,"NoImagesDefined",
6354 (const char *) tag);
6357 if (attributes == (const xmlChar **) NULL)
6359 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6361 keyword=(const char *) attributes[i++];
6362 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6363 msl_info->attributes[n],(const char *) attributes[i]));
6369 if (LocaleCompare(keyword,"geometry") == 0)
6371 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6374 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6380 if (LocaleCompare(keyword,"height") == 0)
6382 height = StringToLong( value );
6385 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6391 if (LocaleCompare(keyword,"width") == 0)
6393 width = StringToLong( value );
6396 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6401 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6416 rectInfo.height = height;
6417 rectInfo.width = width;
6422 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6423 &msl_info->image[n]->exception);
6424 if (newImage == (Image *) NULL)
6426 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6427 msl_info->image[n]=newImage;
6432 if (LocaleCompare((const char *) tag,"shear") == 0)
6440 if (msl_info->image[n] == (Image *) NULL)
6442 ThrowMSLException(OptionError,"NoImagesDefined",
6443 (const char *) tag);
6446 if (attributes != (const xmlChar **) NULL)
6447 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6449 keyword=(const char *) attributes[i++];
6450 attribute=InterpretImageProperties(msl_info->image_info[n],
6451 msl_info->attributes[n],(const char *) attributes[i]);
6452 CloneString(&value,attribute);
6458 if (LocaleCompare(keyword, "fill") == 0)
6460 (void) QueryColorDatabase(value,
6461 &msl_info->image[n]->background_color,&exception);
6464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6471 if (LocaleCompare(keyword,"geometry") == 0)
6473 flags=ParseGeometry(value,&geometry_info);
6474 if ((flags & SigmaValue) == 0)
6475 geometry_info.sigma=1.0;
6478 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6485 if (LocaleCompare(keyword,"x") == 0)
6487 geometry_info.rho=InterpretLocaleValue(value,
6491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6498 if (LocaleCompare(keyword,"y") == 0)
6500 geometry_info.sigma=StringToLong(value);
6503 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6515 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6516 geometry_info.sigma,&msl_info->image[n]->exception);
6517 if (shear_image == (Image *) NULL)
6519 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6520 msl_info->image[n]=shear_image;
6523 if (LocaleCompare((const char *) tag,"signature") == 0)
6528 if (msl_info->image[n] == (Image *) NULL)
6530 ThrowMSLException(OptionError,"NoImagesDefined",
6531 (const char *) tag);
6534 if (attributes != (const xmlChar **) NULL)
6535 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6537 keyword=(const char *) attributes[i++];
6538 attribute=InterpretImageProperties(msl_info->image_info[n],
6539 msl_info->attributes[n],(const char *) attributes[i]);
6540 CloneString(&value,attribute);
6545 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6551 (void) SignatureImage(msl_info->image[n]);
6554 if (LocaleCompare((const char *) tag,"solarize") == 0)
6559 if (msl_info->image[n] == (Image *) NULL)
6561 ThrowMSLException(OptionError,"NoImagesDefined",
6562 (const char *) tag);
6565 geometry_info.rho=QuantumRange/2.0;
6566 if (attributes != (const xmlChar **) NULL)
6567 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6569 keyword=(const char *) attributes[i++];
6570 attribute=InterpretImageProperties(msl_info->image_info[n],
6571 msl_info->attributes[n],(const char *) attributes[i]);
6572 CloneString(&value,attribute);
6578 if (LocaleCompare(keyword,"geometry") == 0)
6580 flags=ParseGeometry(value,&geometry_info);
6583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6590 if (LocaleCompare(keyword,"threshold") == 0)
6592 geometry_info.rho=InterpretLocaleValue(value,
6596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6608 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6611 if (LocaleCompare((const char *) tag,"spread") == 0)
6619 if (msl_info->image[n] == (Image *) NULL)
6621 ThrowMSLException(OptionError,"NoImagesDefined",
6622 (const char *) tag);
6625 if (attributes != (const xmlChar **) NULL)
6626 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6628 keyword=(const char *) attributes[i++];
6629 attribute=InterpretImageProperties(msl_info->image_info[n],
6630 msl_info->attributes[n],(const char *) attributes[i]);
6631 CloneString(&value,attribute);
6637 if (LocaleCompare(keyword,"geometry") == 0)
6639 flags=ParseGeometry(value,&geometry_info);
6640 if ((flags & SigmaValue) == 0)
6641 geometry_info.sigma=1.0;
6644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6651 if (LocaleCompare(keyword,"radius") == 0)
6653 geometry_info.rho=InterpretLocaleValue(value,
6657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6663 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6669 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6670 &msl_info->image[n]->exception);
6671 if (spread_image == (Image *) NULL)
6673 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6674 msl_info->image[n]=spread_image;
6677 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6680 watermark = (Image*)NULL;
6682 if (msl_info->image[n] == (Image *) NULL)
6684 ThrowMSLException(OptionError,"NoImagesDefined",
6685 (const char *) tag);
6688 if (attributes == (const xmlChar **) NULL)
6690 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6692 keyword=(const char *) attributes[i++];
6693 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6694 msl_info->attributes[n],(const char *) attributes[i]));
6700 if (LocaleCompare(keyword,"image") == 0)
6702 for (j=0; j<msl_info->n;j++)
6705 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6706 if (theAttr && LocaleCompare(theAttr, value) == 0)
6708 watermark = msl_info->image[j];
6714 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6719 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6728 if ( watermark != (Image*) NULL )
6733 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6734 if (newImage == (Image *) NULL)
6736 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6737 msl_info->image[n]=newImage;
6740 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6742 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6745 stereoImage = (Image*)NULL;
6747 if (msl_info->image[n] == (Image *) NULL)
6749 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6752 if (attributes == (const xmlChar **) NULL)
6754 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6756 keyword=(const char *) attributes[i++];
6757 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6758 msl_info->attributes[n],(const char *) attributes[i]));
6764 if (LocaleCompare(keyword,"image") == 0)
6766 for (j=0; j<msl_info->n;j++)
6769 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6770 if (theAttr && LocaleCompare(theAttr, value) == 0)
6772 stereoImage = msl_info->image[j];
6778 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6783 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6792 if ( stereoImage != (Image*) NULL )
6797 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6798 if (newImage == (Image *) NULL)
6800 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6801 msl_info->image[n]=newImage;
6804 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6806 if (LocaleCompare((const char *) tag,"swap") == 0)
6817 if (msl_info->image[n] == (Image *) NULL)
6819 ThrowMSLException(OptionError,"NoImagesDefined",
6820 (const char *) tag);
6825 if (attributes != (const xmlChar **) NULL)
6826 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6828 keyword=(const char *) attributes[i++];
6829 attribute=InterpretImageProperties(msl_info->image_info[n],
6830 msl_info->attributes[n],(const char *) attributes[i]);
6831 CloneString(&value,attribute);
6837 if (LocaleCompare(keyword,"indexes") == 0)
6839 flags=ParseGeometry(value,&geometry_info);
6840 index=(ssize_t) geometry_info.rho;
6841 if ((flags & SigmaValue) == 0)
6842 swap_index=(ssize_t) geometry_info.sigma;
6845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6860 p=GetImageFromList(msl_info->image[n],index);
6861 q=GetImageFromList(msl_info->image[n],swap_index);
6862 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6864 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6867 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6868 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6869 ReplaceImageInList(&q,swap);
6870 msl_info->image[n]=GetFirstImageInList(q);
6873 if (LocaleCompare((const char *) tag,"swirl") == 0)
6881 if (msl_info->image[n] == (Image *) NULL)
6883 ThrowMSLException(OptionError,"NoImagesDefined",
6884 (const char *) tag);
6887 if (attributes != (const xmlChar **) NULL)
6888 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6890 keyword=(const char *) attributes[i++];
6891 attribute=InterpretImageProperties(msl_info->image_info[n],
6892 msl_info->attributes[n],(const char *) attributes[i]);
6893 CloneString(&value,attribute);
6899 if (LocaleCompare(keyword,"degrees") == 0)
6901 geometry_info.rho=InterpretLocaleValue(value,
6905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6912 if (LocaleCompare(keyword,"geometry") == 0)
6914 flags=ParseGeometry(value,&geometry_info);
6915 if ((flags & SigmaValue) == 0)
6916 geometry_info.sigma=1.0;
6919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6925 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6931 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6932 &msl_info->image[n]->exception);
6933 if (swirl_image == (Image *) NULL)
6935 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6936 msl_info->image[n]=swirl_image;
6939 if (LocaleCompare((const char *) tag,"sync") == 0)
6944 if (msl_info->image[n] == (Image *) NULL)
6946 ThrowMSLException(OptionError,"NoImagesDefined",
6947 (const char *) tag);
6950 if (attributes != (const xmlChar **) NULL)
6951 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6953 keyword=(const char *) attributes[i++];
6954 attribute=InterpretImageProperties(msl_info->image_info[n],
6955 msl_info->attributes[n],(const char *) attributes[i]);
6956 CloneString(&value,attribute);
6961 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6967 (void) SyncImage(msl_info->image[n]);
6970 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6975 if (LocaleCompare((const char *) tag,"map") == 0)
6983 if (msl_info->image[n] == (Image *) NULL)
6985 ThrowMSLException(OptionError,"NoImagesDefined",
6986 (const char *) tag);
6989 texture_image=NewImageList();
6990 if (attributes != (const xmlChar **) NULL)
6991 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6993 keyword=(const char *) attributes[i++];
6994 attribute=InterpretImageProperties(msl_info->image_info[n],
6995 msl_info->attributes[n],(const char *) attributes[i]);
6996 CloneString(&value,attribute);
7002 if (LocaleCompare(keyword,"image") == 0)
7003 for (j=0; j < msl_info->n; j++)
7008 attribute=GetImageProperty(msl_info->attributes[j],"id");
7009 if ((attribute != (const char *) NULL) &&
7010 (LocaleCompare(attribute,value) == 0))
7012 texture_image=CloneImage(msl_info->image[j],0,0,
7013 MagickFalse,&exception);
7021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7027 (void) TextureImage(msl_info->image[n],texture_image);
7028 texture_image=DestroyImage(texture_image);
7031 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7033 /* init the values */
7034 double threshold = 0;
7036 if (msl_info->image[n] == (Image *) NULL)
7038 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7041 if (attributes == (const xmlChar **) NULL)
7043 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7045 keyword=(const char *) attributes[i++];
7046 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7047 msl_info->attributes[n],(const char *) attributes[i]));
7053 if (LocaleCompare(keyword,"threshold") == 0)
7055 threshold = InterpretLocaleValue(value,(char **) NULL);
7058 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7063 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7073 BilevelImageChannel(msl_info->image[n],
7074 (ChannelType) ((ssize_t) (CompositeChannels &~ (ssize_t) OpacityChannel)),
7079 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7081 if (msl_info->image[n] == (Image *) NULL)
7083 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7086 if (attributes == (const xmlChar **) NULL)
7088 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7090 keyword=(const char *) attributes[i++];
7091 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7092 msl_info->attributes[n],(const char *) attributes[i]));
7098 if (LocaleCompare(keyword,"color") == 0)
7103 (void) QueryMagickColor(value,&target,&exception);
7104 (void) TransparentPaintImage(msl_info->image[n],&target,
7105 TransparentAlpha,MagickFalse);
7108 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7113 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7120 else if (LocaleCompare((const char *) tag, "trim") == 0)
7122 if (msl_info->image[n] == (Image *) NULL)
7124 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7128 /* no attributes here */
7130 /* process the image */
7137 /* all zeros on a crop == trim edges! */
7138 rectInfo.height = rectInfo.width = 0;
7139 rectInfo.x = rectInfo.y = 0;
7141 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7142 if (newImage == (Image *) NULL)
7144 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7145 msl_info->image[n]=newImage;
7149 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7154 if (LocaleCompare((const char *) tag,"write") == 0)
7156 if (msl_info->image[n] == (Image *) NULL)
7158 ThrowMSLException(OptionError,"NoImagesDefined",
7159 (const char *) tag);
7162 if (attributes == (const xmlChar **) NULL)
7164 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7166 keyword=(const char *) attributes[i++];
7167 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7168 msl_info->attributes[n],(const char *) attributes[i]));
7174 if (LocaleCompare(keyword,"filename") == 0)
7176 (void) CopyMagickString(msl_info->image[n]->filename,value,
7180 (void) SetMSLAttributes(msl_info,keyword,value);
7184 (void) SetMSLAttributes(msl_info,keyword,value);
7192 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7196 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7200 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7204 if ( value != NULL )
7205 value=DestroyString(value);
7206 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7209 static void MSLEndElement(void *context,const xmlChar *tag)
7218 Called when the end of an element has been detected.
7220 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7222 msl_info=(MSLInfo *) context;
7229 if (LocaleCompare((const char *) tag,"comment") == 0 )
7231 (void) DeleteImageProperty(msl_info->image[n],"comment");
7232 if (msl_info->content == (char *) NULL)
7234 StripString(msl_info->content);
7235 (void) SetImageProperty(msl_info->image[n],"comment",
7244 if (LocaleCompare((const char *) tag, "group") == 0 )
7246 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7248 ssize_t i = (ssize_t)
7249 (msl_info->group_info[msl_info->number_groups-1].numImages);
7252 if (msl_info->image[msl_info->n] != (Image *) NULL)
7253 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7254 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7255 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7259 msl_info->number_groups--;
7266 if (LocaleCompare((const char *) tag, "image") == 0)
7267 MSLPopImage(msl_info);
7273 if (LocaleCompare((const char *) tag,"label") == 0 )
7275 (void) DeleteImageProperty(msl_info->image[n],"label");
7276 if (msl_info->content == (char *) NULL)
7278 StripString(msl_info->content);
7279 (void) SetImageProperty(msl_info->image[n],"label",
7288 if (LocaleCompare((const char *) tag, "msl") == 0 )
7291 This our base element.
7292 at the moment we don't do anything special
7293 but someday we might!
7301 if (msl_info->content != (char *) NULL)
7302 msl_info->content=DestroyString(msl_info->content);
7305 static void MSLCharacters(void *context,const xmlChar *c,int length)
7317 Receiving some characters from the parser.
7319 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7320 " SAX.characters(%s,%d)",c,length);
7321 msl_info=(MSLInfo *) context;
7322 if (msl_info->content != (char *) NULL)
7323 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7324 strlen(msl_info->content)+length+MaxTextExtent,
7325 sizeof(*msl_info->content));
7328 msl_info->content=(char *) NULL;
7329 if (~length >= (MaxTextExtent-1))
7330 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7331 sizeof(*msl_info->content));
7332 if (msl_info->content != (char *) NULL)
7333 *msl_info->content='\0';
7335 if (msl_info->content == (char *) NULL)
7337 p=msl_info->content+strlen(msl_info->content);
7338 for (i=0; i < length; i++)
7343 static void MSLReference(void *context,const xmlChar *name)
7352 Called when an entity reference is detected.
7354 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7355 " SAX.reference(%s)",name);
7356 msl_info=(MSLInfo *) context;
7357 parser=msl_info->parser;
7359 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7361 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7364 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7370 Receiving some ignorable whitespaces from the parser.
7372 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7373 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7374 msl_info=(MSLInfo *) context;
7378 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7379 const xmlChar *data)
7385 A processing instruction has been parsed.
7387 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7388 " SAX.processingInstruction(%s, %s)",
7390 msl_info=(MSLInfo *) context;
7394 static void MSLComment(void *context,const xmlChar *value)
7400 A comment has been parsed.
7402 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7403 " SAX.comment(%s)",value);
7404 msl_info=(MSLInfo *) context;
7408 static void MSLWarning(void *context,const char *format,...)
7412 reason[MaxTextExtent];
7421 Display and format a warning messages, gives file, line, position and
7424 va_start(operands,format);
7425 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7426 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7427 msl_info=(MSLInfo *) context;
7429 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7430 (void) vsprintf(reason,format,operands);
7432 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7434 message=GetExceptionMessage(errno);
7435 ThrowMSLException(CoderError,reason,message);
7436 message=DestroyString(message);
7440 static void MSLError(void *context,const char *format,...)
7443 reason[MaxTextExtent];
7452 Display and format a error formats, gives file, line, position and
7455 va_start(operands,format);
7456 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7457 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7458 msl_info=(MSLInfo *) context;
7460 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7461 (void) vsprintf(reason,format,operands);
7463 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7465 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7469 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7481 Called when a pcdata block has been parsed.
7483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7484 " SAX.pcdata(%s, %d)",value,length);
7485 msl_info=(MSLInfo *) context;
7487 parser=msl_info->parser;
7488 child=xmlGetLastChild(parser->node);
7489 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7491 xmlTextConcat(child,value,length);
7494 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7497 static void MSLExternalSubset(void *context,const xmlChar *name,
7498 const xmlChar *external_id,const xmlChar *system_id)
7513 Does this document has an external subset?
7515 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7516 " SAX.externalSubset(%s %s %s)",name,
7517 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7518 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7519 msl_info=(MSLInfo *) context;
7521 parser=msl_info->parser;
7522 if (((external_id == NULL) && (system_id == NULL)) ||
7523 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7524 (msl_info->document == 0)))
7526 input=MSLResolveEntity(context,external_id,system_id);
7529 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7530 parser_context=(*parser);
7531 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7532 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7534 parser->errNo=XML_ERR_NO_MEMORY;
7535 parser->input=parser_context.input;
7536 parser->inputNr=parser_context.inputNr;
7537 parser->inputMax=parser_context.inputMax;
7538 parser->inputTab=parser_context.inputTab;
7544 xmlPushInput(parser,input);
7545 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7546 if (input->filename == (char *) NULL)
7547 input->filename=(char *) xmlStrdup(system_id);
7550 input->base=parser->input->cur;
7551 input->cur=parser->input->cur;
7553 xmlParseExternalSubset(parser,external_id,system_id);
7554 while (parser->inputNr > 1)
7555 (void) xmlPopInput(parser);
7556 xmlFreeInputStream(parser->input);
7557 xmlFree(parser->inputTab);
7558 parser->input=parser_context.input;
7559 parser->inputNr=parser_context.inputNr;
7560 parser->inputMax=parser_context.inputMax;
7561 parser->inputTab=parser_context.inputTab;
7564 #if defined(__cplusplus) || defined(c_plusplus)
7568 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7569 ExceptionInfo *exception)
7572 message[MaxTextExtent];
7595 assert(image_info != (const ImageInfo *) NULL);
7596 assert(image_info->signature == MagickSignature);
7597 if (image_info->debug != MagickFalse)
7598 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7599 image_info->filename);
7600 assert(image != (Image **) NULL);
7601 msl_image=AcquireImage(image_info);
7602 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7603 if (status == MagickFalse)
7605 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7606 msl_image->filename);
7607 msl_image=DestroyImageList(msl_image);
7608 return(MagickFalse);
7610 msl_image->columns=1;
7615 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7616 msl_info.exception=exception;
7617 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7618 sizeof(*msl_info.image_info));
7619 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7620 sizeof(*msl_info.draw_info));
7621 /* top of the stack is the MSL file itself */
7622 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7623 msl_info.attributes=(Image **) AcquireMagickMemory(
7624 sizeof(*msl_info.attributes));
7625 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7626 sizeof(*msl_info.group_info));
7627 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7628 (msl_info.image == (Image **) NULL) ||
7629 (msl_info.attributes == (Image **) NULL) ||
7630 (msl_info.group_info == (MSLGroupInfo *) NULL))
7631 ThrowFatalException(ResourceLimitFatalError,
7632 "UnableToInterpretMSLImage");
7633 *msl_info.image_info=CloneImageInfo(image_info);
7634 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7635 *msl_info.attributes=AcquireImage(image_info);
7636 msl_info.group_info[0].numImages=0;
7637 /* the first slot is used to point to the MSL file image */
7638 *msl_info.image=msl_image;
7639 if (*image != (Image *) NULL)
7640 MSLPushImage(&msl_info,*image);
7641 (void) xmlSubstituteEntitiesDefault(1);
7642 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7643 sax_modules.internalSubset=MSLInternalSubset;
7644 sax_modules.isStandalone=MSLIsStandalone;
7645 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7646 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7647 sax_modules.resolveEntity=MSLResolveEntity;
7648 sax_modules.getEntity=MSLGetEntity;
7649 sax_modules.entityDecl=MSLEntityDeclaration;
7650 sax_modules.notationDecl=MSLNotationDeclaration;
7651 sax_modules.attributeDecl=MSLAttributeDeclaration;
7652 sax_modules.elementDecl=MSLElementDeclaration;
7653 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7654 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7655 sax_modules.startDocument=MSLStartDocument;
7656 sax_modules.endDocument=MSLEndDocument;
7657 sax_modules.startElement=MSLStartElement;
7658 sax_modules.endElement=MSLEndElement;
7659 sax_modules.reference=MSLReference;
7660 sax_modules.characters=MSLCharacters;
7661 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7662 sax_modules.processingInstruction=MSLProcessingInstructions;
7663 sax_modules.comment=MSLComment;
7664 sax_modules.warning=MSLWarning;
7665 sax_modules.error=MSLError;
7666 sax_modules.fatalError=MSLError;
7667 sax_modules.getParameterEntity=MSLGetParameterEntity;
7668 sax_modules.cdataBlock=MSLCDataBlock;
7669 sax_modules.externalSubset=MSLExternalSubset;
7670 sax_handler=(&sax_modules);
7671 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7672 msl_image->filename);
7673 while (ReadBlobString(msl_image,message) != (char *) NULL)
7675 n=(ssize_t) strlen(message);
7678 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7681 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7682 if (msl_info.exception->severity >= ErrorException)
7685 if (msl_info.exception->severity == UndefinedException)
7686 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7687 xmlFreeParserCtxt(msl_info.parser);
7688 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7690 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7691 msl_info.group_info);
7692 if (*image == (Image *) NULL)
7693 *image=(*msl_info.image);
7694 if ((*msl_info.image)->exception.severity != UndefinedException)
7695 return(MagickFalse);
7699 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7707 assert(image_info != (const ImageInfo *) NULL);
7708 assert(image_info->signature == MagickSignature);
7709 if (image_info->debug != MagickFalse)
7710 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7711 image_info->filename);
7712 assert(exception != (ExceptionInfo *) NULL);
7713 assert(exception->signature == MagickSignature);
7714 image=(Image *) NULL;
7715 (void) ProcessMSLScript(image_info,&image,exception);
7716 return(GetFirstImageInList(image));
7721 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7725 % R e g i s t e r M S L I m a g e %
7729 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7731 % RegisterMSLImage() adds attributes for the MSL image format to
7732 % the list of supported formats. The attributes include the image format
7733 % tag, a method to read and/or write the format, whether the format
7734 % supports the saving of more than one frame to the same file or blob,
7735 % whether the format supports native in-memory I/O, and a brief
7736 % description of the format.
7738 % The format of the RegisterMSLImage method is:
7740 % size_t RegisterMSLImage(void)
7743 ModuleExport size_t RegisterMSLImage(void)
7748 entry=SetMagickInfo("MSL");
7749 #if defined(MAGICKCORE_XML_DELEGATE)
7750 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7751 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7753 entry->description=ConstantString("Magick Scripting Language");
7754 entry->module=ConstantString("MSL");
7755 (void) RegisterMagickInfo(entry);
7756 return(MagickImageCoderSignature);
7759 #if defined(MAGICKCORE_XML_DELEGATE)
7761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7765 % S e t M S L A t t r i b u t e s %
7769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7771 % SetMSLAttributes() ...
7773 % The format of the SetMSLAttributes method is:
7775 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7776 % const char *keyword,const char *value)
7778 % A description of each parameter follows:
7780 % o msl_info: the MSL info.
7782 % o keyword: the keyword.
7784 % o value: the value.
7787 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7814 assert(msl_info != (MSLInfo *) NULL);
7815 if (keyword == (const char *) NULL)
7817 if (value == (const char *) NULL)
7819 exception=msl_info->exception;
7821 attributes=msl_info->attributes[n];
7822 image_info=msl_info->image_info[n];
7823 draw_info=msl_info->draw_info[n];
7824 image=msl_info->image[n];
7830 if (LocaleCompare(keyword,"adjoin") == 0)
7835 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7837 ThrowMSLException(OptionError,"UnrecognizedType",value);
7838 image_info->adjoin=(MagickBooleanType) adjoin;
7841 if (LocaleCompare(keyword,"alpha") == 0)
7846 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7848 ThrowMSLException(OptionError,"UnrecognizedType",value);
7849 if (image != (Image *) NULL)
7850 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7853 if (LocaleCompare(keyword,"antialias") == 0)
7858 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7860 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7861 image_info->antialias=(MagickBooleanType) antialias;
7864 if (LocaleCompare(keyword,"area-limit") == 0)
7869 limit=MagickResourceInfinity;
7870 if (LocaleCompare(value,"unlimited") != 0)
7871 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7872 (void) SetMagickResourceLimit(AreaResource,limit);
7875 if (LocaleCompare(keyword,"attenuate") == 0)
7877 (void) SetImageOption(image_info,keyword,value);
7880 if (LocaleCompare(keyword,"authenticate") == 0)
7882 (void) CloneString(&image_info->density,value);
7885 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7891 if (LocaleCompare(keyword,"background") == 0)
7893 (void) QueryColorDatabase(value,&image_info->background_color,
7897 if (LocaleCompare(keyword,"bias") == 0)
7899 if (image == (Image *) NULL)
7901 image->bias=SiPrefixToDouble(value,QuantumRange);
7904 if (LocaleCompare(keyword,"blue-primary") == 0)
7906 if (image == (Image *) NULL)
7908 flags=ParseGeometry(value,&geometry_info);
7909 image->chromaticity.blue_primary.x=geometry_info.rho;
7910 image->chromaticity.blue_primary.y=geometry_info.sigma;
7911 if ((flags & SigmaValue) == 0)
7912 image->chromaticity.blue_primary.y=
7913 image->chromaticity.blue_primary.x;
7916 if (LocaleCompare(keyword,"bordercolor") == 0)
7918 (void) QueryColorDatabase(value,&image_info->border_color,
7922 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7928 if (LocaleCompare(keyword,"density") == 0)
7930 (void) CloneString(&image_info->density,value);
7931 (void) CloneString(&draw_info->density,value);
7934 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7940 if (LocaleCompare(keyword,"fill") == 0)
7942 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7943 (void) SetImageOption(image_info,keyword,value);
7946 if (LocaleCompare(keyword,"filename") == 0)
7948 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7951 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7957 if (LocaleCompare(keyword,"gravity") == 0)
7962 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7964 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7965 (void) SetImageOption(image_info,keyword,value);
7968 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7974 if (LocaleCompare(keyword,"id") == 0)
7976 (void) SetImageProperty(attributes,keyword,value);
7979 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7985 if (LocaleCompare(keyword,"magick") == 0)
7987 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7990 if (LocaleCompare(keyword,"mattecolor") == 0)
7992 (void) QueryColorDatabase(value,&image_info->matte_color,
7996 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8002 if (LocaleCompare(keyword,"pointsize") == 0)
8004 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8005 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8008 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8014 if (LocaleCompare(keyword,"quality") == 0)
8016 image_info->quality=StringToLong(value);
8017 if (image == (Image *) NULL)
8019 image->quality=StringToLong(value);
8027 if (LocaleCompare(keyword,"size") == 0)
8029 (void) CloneString(&image_info->size,value);
8032 if (LocaleCompare(keyword,"stroke") == 0)
8034 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8035 (void) SetImageOption(image_info,keyword,value);
8038 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8043 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8056 % U n r e g i s t e r M S L I m a g e %
8060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8062 % UnregisterMSLImage() removes format registrations made by the
8063 % MSL module from the list of supported formats.
8065 % The format of the UnregisterMSLImage method is:
8067 % UnregisterMSLImage(void)
8070 ModuleExport void UnregisterMSLImage(void)
8072 (void) UnregisterMagickInfo("MSL");
8075 #if defined(MAGICKCORE_XML_DELEGATE)
8077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8081 % W r i t e M S L I m a g e %
8085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8087 % WriteMSLImage() writes an image to a file in MVG image format.
8089 % The format of the WriteMSLImage method is:
8091 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8093 % A description of each parameter follows.
8095 % o image_info: the image info.
8097 % o image: The image.
8100 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8102 assert(image_info != (const ImageInfo *) NULL);
8103 assert(image_info->signature == MagickSignature);
8104 assert(image != (Image *) NULL);
8105 assert(image->signature == MagickSignature);
8106 if (image->debug != MagickFalse)
8107 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8108 (void) ReferenceImage(image);
8109 (void) ProcessMSLScript(image_info,&image,&image->exception);