2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2009 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 "magick/studio.h"
45 #include "magick/annotate.h"
46 #include "magick/artifact.h"
47 #include "magick/blob.h"
48 #include "magick/blob-private.h"
49 #include "magick/cache.h"
50 #include "magick/cache-view.h"
51 #include "magick/color.h"
52 #include "magick/colormap.h"
53 #include "magick/color-private.h"
54 #include "magick/composite.h"
55 #include "magick/constitute.h"
56 #include "magick/decorate.h"
57 #include "magick/display.h"
58 #include "magick/draw.h"
59 #include "magick/effect.h"
60 #include "magick/enhance.h"
61 #include "magick/exception.h"
62 #include "magick/exception-private.h"
63 #include "magick/fx.h"
64 #include "magick/geometry.h"
65 #include "magick/image.h"
66 #include "magick/image-private.h"
67 #include "magick/list.h"
68 #include "magick/log.h"
69 #include "magick/magick.h"
70 #include "magick/memory_.h"
71 #include "magick/option.h"
72 #include "magick/paint.h"
73 #include "magick/profile.h"
74 #include "magick/property.h"
75 #include "magick/quantize.h"
76 #include "magick/quantum-private.h"
77 #include "magick/registry.h"
78 #include "magick/resize.h"
79 #include "magick/segment.h"
80 #include "magick/shear.h"
81 #include "magick/signature.h"
82 #include "magick/static.h"
83 #include "magick/string_.h"
84 #include "magick/module.h"
85 #include "magick/transform.h"
86 #include "magick/threshold.h"
87 #include "magick/utility.h"
88 #if defined(MAGICKCORE_XML_DELEGATE)
89 # if defined(__WINDOWS__)
90 # if defined(__MINGW32__)
93 # include <win32config.h>
96 # include <libxml/parser.h>
97 # include <libxml/xmlmemory.h>
98 # include <libxml/parserInternals.h>
99 # include <libxml/xmlerror.h>
105 #define ThrowMSLException(severity,tag,reason) \
106 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
110 Typedef declaractions.
112 typedef struct _MSLGroupInfo
115 numImages; /* how many images are in this group */
118 typedef struct _MSLInfo
143 #if defined(MAGICKCORE_XML_DELEGATE)
153 Forward declarations.
155 #if defined(MAGICKCORE_XML_DELEGATE)
156 static MagickBooleanType
157 WriteMSLImage(const ImageInfo *,Image *);
159 static MagickBooleanType
160 SetMSLAttributes(MSLInfo *,const char *,const char *);
163 #if defined(MAGICKCORE_XML_DELEGATE)
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 % R e a d M S L I m a g e %
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
177 % It allocates the memory necessary for the new Image structure and returns a
178 % pointer to the new image.
180 % The format of the ReadMSLImage method is:
182 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
184 % A description of each parameter follows:
186 % o image_info: the image info.
188 % o exception: return any errors or warnings in this structure.
192 #if defined(__cplusplus) || defined(c_plusplus)
196 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
197 ExceptionInfo *exception)
211 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
212 sans_exception=AcquireExceptionInfo();
213 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
214 sans_exception=DestroyExceptionInfo(sans_exception);
215 if (image != (Image *) NULL)
217 read_info=CloneImageInfo(image_info);
218 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
219 image=ReadImage(read_info,exception);
220 read_info=DestroyImageInfo(read_info);
221 if (image != (Image *) NULL)
222 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
226 static int IsPathDirectory(const char *path)
234 if ((path == (const char *) NULL) || (*path == '\0'))
236 status=GetPathAttributes(path,&attributes);
237 if (status == MagickFalse)
239 if (S_ISDIR(attributes.st_mode) == 0)
244 static int MSLIsStandalone(void *context)
250 Is this document tagged standalone?
252 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
253 msl_info=(MSLInfo *) context;
254 return(msl_info->document->standalone == 1);
257 static int MSLHasInternalSubset(void *context)
263 Does this document has an internal subset?
265 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
266 " SAX.MSLHasInternalSubset()");
267 msl_info=(MSLInfo *) context;
268 return(msl_info->document->intSubset != NULL);
271 static int MSLHasExternalSubset(void *context)
277 Does this document has an external subset?
279 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
280 " SAX.MSLHasExternalSubset()");
281 msl_info=(MSLInfo *) context;
282 return(msl_info->document->extSubset != NULL);
285 static void MSLInternalSubset(void *context,const xmlChar *name,
286 const xmlChar *external_id,const xmlChar *system_id)
292 Does this document has an internal subset?
294 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
295 " SAX.internalSubset(%s %s %s)",name,
296 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
297 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
298 msl_info=(MSLInfo *) context;
299 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
302 static xmlParserInputPtr MSLResolveEntity(void *context,
303 const xmlChar *public_id,const xmlChar *system_id)
312 Special entity resolver, better left to the parser, it has more
313 context than the application layer. The default behaviour is to
314 not resolve the entities, in that case the ENTITY_REF nodes are
315 built in the structure (and the parameter values).
317 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
318 " SAX.resolveEntity(%s, %s)",
319 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
320 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
321 msl_info=(MSLInfo *) context;
322 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
323 public_id,msl_info->parser);
327 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
333 Get an entity by name.
335 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
336 " SAX.MSLGetEntity(%s)",(const char *) name);
337 msl_info=(MSLInfo *) context;
338 return(xmlGetDocEntity(msl_info->document,name));
341 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
347 Get a parameter entity by name.
349 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
350 " SAX.getParameterEntity(%s)",(const char *) name);
351 msl_info=(MSLInfo *) context;
352 return(xmlGetParameterEntity(msl_info->document,name));
355 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
356 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
362 An entity definition has been parsed.
364 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
365 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
366 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
367 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
369 msl_info=(MSLInfo *) context;
370 if (msl_info->parser->inSubset == 1)
371 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
374 if (msl_info->parser->inSubset == 2)
375 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
379 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
380 const xmlChar *name,int type,int value,const xmlChar *default_value,
381 xmlEnumerationPtr tree)
394 An attribute definition has been parsed.
396 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
397 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
399 msl_info=(MSLInfo *) context;
400 fullname=(xmlChar *) NULL;
401 prefix=(xmlChar *) NULL;
402 parser=msl_info->parser;
403 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
404 if (parser->inSubset == 1)
405 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
406 element,fullname,prefix,(xmlAttributeType) type,
407 (xmlAttributeDefault) value,default_value,tree);
409 if (parser->inSubset == 2)
410 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
411 element,fullname,prefix,(xmlAttributeType) type,
412 (xmlAttributeDefault) value,default_value,tree);
413 if (prefix != (xmlChar *) NULL)
415 if (fullname != (xmlChar *) NULL)
419 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
420 xmlElementContentPtr content)
429 An element definition has been parsed.
431 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
432 " SAX.elementDecl(%s, %d, ...)",name,type);
433 msl_info=(MSLInfo *) context;
434 parser=msl_info->parser;
435 if (parser->inSubset == 1)
436 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
437 name,(xmlElementTypeVal) type,content);
439 if (parser->inSubset == 2)
440 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
441 name,(xmlElementTypeVal) type,content);
444 static void MSLNotationDeclaration(void *context,const xmlChar *name,
445 const xmlChar *public_id,const xmlChar *system_id)
454 What to do when a notation declaration has been parsed.
456 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
457 " SAX.notationDecl(%s, %s, %s)",name,
458 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
459 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
460 msl_info=(MSLInfo *) context;
461 parser=msl_info->parser;
462 if (parser->inSubset == 1)
463 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
464 name,public_id,system_id);
466 if (parser->inSubset == 2)
467 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
468 name,public_id,system_id);
471 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
472 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
478 What to do when an unparsed entity declaration is parsed.
480 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
481 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
482 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
483 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
485 msl_info=(MSLInfo *) context;
486 (void) xmlAddDocEntity(msl_info->document,name,
487 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
491 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
497 Receive the document locator at startup, actually xmlDefaultSAXLocator.
499 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
500 " SAX.setDocumentLocator()\n");
502 msl_info=(MSLInfo *) context;
505 static void MSLStartDocument(void *context)
514 Called when the document start being processed.
516 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
517 " SAX.startDocument()");
518 msl_info=(MSLInfo *) context;
519 parser=msl_info->parser;
520 msl_info->document=xmlNewDoc(parser->version);
521 if (msl_info->document == (xmlDocPtr) NULL)
523 if (parser->encoding == NULL)
524 msl_info->document->encoding=NULL;
526 msl_info->document->encoding=xmlStrdup(parser->encoding);
527 msl_info->document->standalone=parser->standalone;
530 static void MSLEndDocument(void *context)
536 Called when the document end has been detected.
538 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
539 msl_info=(MSLInfo *) context;
540 if (msl_info->content != (char *) NULL)
541 msl_info->content=DestroyString(msl_info->content);
544 static void MSLPushImage(MSLInfo *msl_info,Image *image)
549 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
550 assert(msl_info != (MSLInfo *) NULL);
553 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
554 (n+1),sizeof(*msl_info->image_info));
555 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
556 (n+1),sizeof(*msl_info->draw_info));
557 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
558 (n+1),sizeof(*msl_info->attributes));
559 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
560 sizeof(*msl_info->image));
561 if ((msl_info->image_info == (ImageInfo **) NULL) ||
562 (msl_info->draw_info == (DrawInfo **) NULL) ||
563 (msl_info->attributes == (Image **) NULL) ||
564 (msl_info->image == (Image **) NULL))
565 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
566 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
567 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
568 msl_info->draw_info[n-1]);
569 if (image == (Image *) NULL)
570 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
572 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
573 msl_info->image[n]=(Image *) image;
574 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
575 (msl_info->attributes[n] == (Image *) NULL))
576 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
577 if (msl_info->number_groups != 0)
578 msl_info->group_info[msl_info->number_groups-1].numImages++;
581 static void MSLPopImage(MSLInfo *msl_info)
583 if (msl_info->number_groups != 0)
585 if (msl_info->image[msl_info->n] != (Image *) NULL)
586 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
587 msl_info->attributes[msl_info->n]=DestroyImage(
588 msl_info->attributes[msl_info->n]);
589 msl_info->image_info[msl_info->n]=DestroyImageInfo(
590 msl_info->image_info[msl_info->n]);
594 static void MSLStartElement(void *context,const xmlChar *tag,
595 const xmlChar **attributes)
651 Called when an opening tag has been processed.
653 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
654 " SAX.startElement(%s",tag);
655 GetExceptionInfo(&exception);
656 msl_info=(MSLInfo *) context;
658 keyword=(const char *) NULL;
660 SetGeometryInfo(&geometry_info);
661 channel=DefaultChannels;
667 if (LocaleCompare((const char *) tag,"add-noise") == 0)
678 if (msl_info->image[n] == (Image *) NULL)
680 ThrowMSLException(OptionError,"NoImagesDefined",
685 if (attributes != (const xmlChar **) NULL)
686 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
688 keyword=(const char *) attributes[i++];
689 attribute=InterpretImageProperties(msl_info->image_info[n],
690 msl_info->attributes[n],(const char *) attributes[i]);
691 CloneString(&value,attribute);
697 if (LocaleCompare(keyword,"channel") == 0)
699 option=ParseChannelOption(value);
701 ThrowMSLException(OptionError,"UnrecognizedChannelType",
703 channel=(ChannelType) option;
706 ThrowMSLException(OptionError,"UnrecognizedAttribute",
713 if (LocaleCompare(keyword,"noise") == 0)
715 option=ParseMagickOption(MagickNoiseOptions,MagickFalse,
718 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
720 noise=(NoiseType) option;
723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
735 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
736 &msl_info->image[n]->exception);
737 if (noise_image == (Image *) NULL)
739 msl_info->image[n]=DestroyImage(msl_info->image[n]);
740 msl_info->image[n]=noise_image;
743 if (LocaleCompare((const char *) tag,"annotate") == 0)
751 if (msl_info->image[n] == (Image *) NULL)
753 ThrowMSLException(OptionError,"NoImagesDefined",
757 draw_info=CloneDrawInfo(msl_info->image_info[n],
758 msl_info->draw_info[n]);
760 current=draw_info->affine;
761 GetAffineMatrix(&affine);
762 if (attributes != (const xmlChar **) NULL)
763 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
765 keyword=(const char *) attributes[i++];
766 attribute=InterpretImageProperties(msl_info->image_info[n],
767 msl_info->attributes[n],(const char *) attributes[i]);
768 CloneString(&value,attribute);
774 if (LocaleCompare(keyword,"affine") == 0)
780 draw_info->affine.sx=strtod(p,&p);
783 draw_info->affine.rx=strtod(p,&p);
786 draw_info->affine.ry=strtod(p,&p);
789 draw_info->affine.sy=strtod(p,&p);
792 draw_info->affine.tx=strtod(p,&p);
795 draw_info->affine.ty=strtod(p,&p);
798 if (LocaleCompare(keyword,"align") == 0)
800 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
803 ThrowMSLException(OptionError,"UnrecognizedAlignType",
805 draw_info->align=(AlignType) option;
808 if (LocaleCompare(keyword,"antialias") == 0)
810 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
813 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
815 draw_info->stroke_antialias=(MagickBooleanType) option;
816 draw_info->text_antialias=(MagickBooleanType) option;
819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
826 if (LocaleCompare(keyword,"density") == 0)
828 CloneString(&draw_info->density,value);
831 ThrowMSLException(OptionError,"UnrecognizedAttribute",
838 if (LocaleCompare(keyword,"encoding") == 0)
840 CloneString(&draw_info->encoding,value);
843 ThrowMSLException(OptionError,"UnrecognizedAttribute",
850 if (LocaleCompare(keyword, "fill") == 0)
852 (void) QueryColorDatabase(value,&draw_info->fill,
856 if (LocaleCompare(keyword,"family") == 0)
858 CloneString(&draw_info->family,value);
861 if (LocaleCompare(keyword,"font") == 0)
863 CloneString(&draw_info->font,value);
866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
873 if (LocaleCompare(keyword,"geometry") == 0)
875 flags=ParsePageGeometry(msl_info->image[n],value,
876 &geometry,&exception);
877 if ((flags & HeightValue) == 0)
878 geometry.height=geometry.width;
881 if (LocaleCompare(keyword,"gravity") == 0)
883 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
886 ThrowMSLException(OptionError,"UnrecognizedGravityType",
888 draw_info->gravity=(GravityType) option;
891 ThrowMSLException(OptionError,"UnrecognizedAttribute",
898 if (LocaleCompare(keyword,"pointsize") == 0)
900 draw_info->pointsize=atof(value);
903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
910 if (LocaleCompare(keyword,"rotate") == 0)
913 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
914 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
915 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
916 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
926 if (LocaleCompare(keyword,"scale") == 0)
928 flags=ParseGeometry(value,&geometry_info);
929 if ((flags & SigmaValue) == 0)
930 geometry_info.sigma=1.0;
931 affine.sx=geometry_info.rho;
932 affine.sy=geometry_info.sigma;
935 if (LocaleCompare(keyword,"skewX") == 0)
938 affine.ry=tan(DegreesToRadians(fmod((double) angle,
942 if (LocaleCompare(keyword,"skewY") == 0)
945 affine.rx=tan(DegreesToRadians(fmod((double) angle,
949 if (LocaleCompare(keyword,"stretch") == 0)
951 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
954 ThrowMSLException(OptionError,"UnrecognizedStretchType",
956 draw_info->stretch=(StretchType) option;
959 if (LocaleCompare(keyword, "stroke") == 0)
961 (void) QueryColorDatabase(value,&draw_info->stroke,
965 if (LocaleCompare(keyword,"strokewidth") == 0)
967 draw_info->stroke_width=atol(value);
970 if (LocaleCompare(keyword,"style") == 0)
972 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
975 ThrowMSLException(OptionError,"UnrecognizedStyleType",
977 draw_info->style=(StyleType) option;
980 ThrowMSLException(OptionError,"UnrecognizedAttribute",
987 if (LocaleCompare(keyword,"text") == 0)
989 CloneString(&draw_info->text,value);
992 if (LocaleCompare(keyword,"translate") == 0)
994 flags=ParseGeometry(value,&geometry_info);
995 if ((flags & SigmaValue) == 0)
996 geometry_info.sigma=1.0;
997 affine.tx=geometry_info.rho;
998 affine.ty=geometry_info.sigma;
1001 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1008 if (LocaleCompare(keyword, "undercolor") == 0)
1010 (void) QueryColorDatabase(value,&draw_info->undercolor,
1014 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1021 if (LocaleCompare(keyword,"weight") == 0)
1023 draw_info->weight=atol(value);
1026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1033 if (LocaleCompare(keyword,"x") == 0)
1035 geometry.x=atol(value);
1038 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1045 if (LocaleCompare(keyword,"y") == 0)
1047 geometry.y=atol(value);
1050 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1056 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1062 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
1063 geometry.width,geometry.height,geometry.x,geometry.y);
1064 CloneString(&draw_info->geometry,text);
1065 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1066 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1067 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1068 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1069 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
1071 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
1073 (void) AnnotateImage(msl_info->image[n],draw_info);
1074 draw_info=DestroyDrawInfo(draw_info);
1077 if (LocaleCompare((const char *) tag,"append") == 0)
1085 if (msl_info->image[n] == (Image *) NULL)
1087 ThrowMSLException(OptionError,"NoImagesDefined",
1088 (const char *) tag);
1092 if (attributes != (const xmlChar **) NULL)
1093 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1095 keyword=(const char *) attributes[i++];
1096 attribute=InterpretImageProperties(msl_info->image_info[n],
1097 msl_info->attributes[n],(const char *) attributes[i]);
1098 CloneString(&value,attribute);
1104 if (LocaleCompare(keyword,"stack") == 0)
1106 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1109 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1111 stack=(MagickBooleanType) option;
1114 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1126 append_image=AppendImages(msl_info->image[n],stack,
1127 &msl_info->image[n]->exception);
1128 if (append_image == (Image *) NULL)
1130 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1131 msl_info->image[n]=append_image;
1134 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1140 if (LocaleCompare((const char *) tag,"blur") == 0)
1148 if (msl_info->image[n] == (Image *) NULL)
1150 ThrowMSLException(OptionError,"NoImagesDefined",
1151 (const char *) tag);
1154 if (attributes != (const xmlChar **) NULL)
1155 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1157 keyword=(const char *) attributes[i++];
1158 attribute=InterpretImageProperties(msl_info->image_info[n],
1159 msl_info->attributes[n],(const char *) attributes[i]);
1160 CloneString(&value,attribute);
1166 if (LocaleCompare(keyword,"channel") == 0)
1168 option=ParseChannelOption(value);
1170 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1172 channel=(ChannelType) option;
1175 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1182 if (LocaleCompare(keyword,"geometry") == 0)
1184 flags=ParseGeometry(value,&geometry_info);
1185 if ((flags & SigmaValue) == 0)
1186 geometry_info.sigma=1.0;
1189 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1196 if (LocaleCompare(keyword,"radius") == 0)
1198 geometry_info.rho=atof(value);
1201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1208 if (LocaleCompare(keyword,"sigma") == 0)
1210 geometry_info.sigma=atol(value);
1213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1225 blur_image=BlurImageChannel(msl_info->image[n],channel,
1226 geometry_info.rho,geometry_info.sigma,
1227 &msl_info->image[n]->exception);
1228 if (blur_image == (Image *) NULL)
1230 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1231 msl_info->image[n]=blur_image;
1234 if (LocaleCompare((const char *) tag,"border") == 0)
1242 if (msl_info->image[n] == (Image *) NULL)
1244 ThrowMSLException(OptionError,"NoImagesDefined",
1245 (const char *) tag);
1248 SetGeometry(msl_info->image[n],&geometry);
1249 if (attributes != (const xmlChar **) NULL)
1250 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1252 keyword=(const char *) attributes[i++];
1253 attribute=InterpretImageProperties(msl_info->image_info[n],
1254 msl_info->attributes[n],(const char *) attributes[i]);
1255 CloneString(&value,attribute);
1261 if (LocaleCompare(keyword,"compose") == 0)
1263 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1266 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1268 msl_info->image[n]->compose=(CompositeOperator) option;
1271 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1278 if (LocaleCompare(keyword, "fill") == 0)
1280 (void) QueryColorDatabase(value,
1281 &msl_info->image[n]->border_color,&exception);
1284 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1291 if (LocaleCompare(keyword,"geometry") == 0)
1293 flags=ParsePageGeometry(msl_info->image[n],value,
1294 &geometry,&exception);
1295 if ((flags & HeightValue) == 0)
1296 geometry.height=geometry.width;
1299 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1306 if (LocaleCompare(keyword,"height") == 0)
1308 geometry.height=atol(value);
1311 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1318 if (LocaleCompare(keyword,"width") == 0)
1320 geometry.width=atol(value);
1323 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1329 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1335 border_image=BorderImage(msl_info->image[n],&geometry,
1336 &msl_info->image[n]->exception);
1337 if (border_image == (Image *) NULL)
1339 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1340 msl_info->image[n]=border_image;
1343 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1348 if (LocaleCompare((const char *) tag,"colorize") == 0)
1351 opacity[MaxTextExtent];
1362 if (msl_info->image[n] == (Image *) NULL)
1364 ThrowMSLException(OptionError,"NoImagesDefined",
1365 (const char *) tag);
1368 target=msl_info->image[n]->background_color;
1369 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1370 if (attributes != (const xmlChar **) NULL)
1371 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1373 keyword=(const char *) attributes[i++];
1374 attribute=InterpretImageProperties(msl_info->image_info[n],
1375 msl_info->attributes[n],(const char *) attributes[i]);
1376 CloneString(&value,attribute);
1382 if (LocaleCompare(keyword,"fill") == 0)
1384 (void) QueryColorDatabase(value,&target,
1385 &msl_info->image[n]->exception);
1388 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1395 if (LocaleCompare(keyword,"opacity") == 0)
1397 (void) CopyMagickString(opacity,value,MaxTextExtent);
1400 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1406 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1412 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1413 &msl_info->image[n]->exception);
1414 if (colorize_image == (Image *) NULL)
1416 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1417 msl_info->image[n]=colorize_image;
1420 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1422 double radius = 0.0,
1425 if (msl_info->image[n] == (Image *) NULL)
1427 ThrowMSLException(OptionError,"NoImagesDefined",
1428 (const char *) tag);
1432 NOTE: charcoal can have no attributes, since we use all the defaults!
1434 if (attributes != (const xmlChar **) NULL)
1436 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1438 keyword=(const char *) attributes[i++];
1439 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1440 msl_info->attributes[n],(const char *) attributes[i]));
1446 if (LocaleCompare(keyword, "radius") == 0)
1448 radius = atof( value );
1451 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1457 if (LocaleCompare(keyword,"sigma") == 0)
1459 sigma = atol( value );
1462 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1481 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1482 &msl_info->image[n]->exception);
1483 if (newImage == (Image *) NULL)
1485 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1486 msl_info->image[n]=newImage;
1490 if (LocaleCompare((const char *) tag,"chop") == 0)
1498 if (msl_info->image[n] == (Image *) NULL)
1500 ThrowMSLException(OptionError,"NoImagesDefined",
1501 (const char *) tag);
1504 SetGeometry(msl_info->image[n],&geometry);
1505 if (attributes != (const xmlChar **) NULL)
1506 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1508 keyword=(const char *) attributes[i++];
1509 attribute=InterpretImageProperties(msl_info->image_info[n],
1510 msl_info->attributes[n],(const char *) attributes[i]);
1511 CloneString(&value,attribute);
1517 if (LocaleCompare(keyword,"geometry") == 0)
1519 flags=ParsePageGeometry(msl_info->image[n],value,
1520 &geometry,&exception);
1521 if ((flags & HeightValue) == 0)
1522 geometry.height=geometry.width;
1525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1532 if (LocaleCompare(keyword,"height") == 0)
1534 geometry.height=atol(value);
1537 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1544 if (LocaleCompare(keyword,"width") == 0)
1546 geometry.width=atol(value);
1549 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1556 if (LocaleCompare(keyword,"x") == 0)
1558 geometry.x=atol(value);
1561 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1568 if (LocaleCompare(keyword,"y") == 0)
1570 geometry.y=atol(value);
1573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1585 chop_image=ChopImage(msl_info->image[n],&geometry,
1586 &msl_info->image[n]->exception);
1587 if (chop_image == (Image *) NULL)
1589 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1590 msl_info->image[n]=chop_image;
1593 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1602 Color floodfill image.
1604 if (msl_info->image[n] == (Image *) NULL)
1606 ThrowMSLException(OptionError,"NoImagesDefined",
1607 (const char *) tag);
1610 draw_info=CloneDrawInfo(msl_info->image_info[n],
1611 msl_info->draw_info[n]);
1612 SetGeometry(msl_info->image[n],&geometry);
1613 paint_method=FloodfillMethod;
1614 if (attributes != (const xmlChar **) NULL)
1615 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1617 keyword=(const char *) attributes[i++];
1618 attribute=InterpretImageProperties(msl_info->image_info[n],
1619 msl_info->attributes[n],(const char *) attributes[i]);
1620 CloneString(&value,attribute);
1626 if (LocaleCompare(keyword,"bordercolor") == 0)
1628 (void) QueryMagickColor(value,&target,&exception);
1629 paint_method=FillToBorderMethod;
1632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1639 if (LocaleCompare(keyword,"fill") == 0)
1641 (void) QueryColorDatabase(value,&draw_info->fill,
1645 if (LocaleCompare(keyword,"fuzz") == 0)
1647 msl_info->image[n]->fuzz=atof(value);
1650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1657 if (LocaleCompare(keyword,"geometry") == 0)
1659 flags=ParsePageGeometry(msl_info->image[n],value,
1660 &geometry,&exception);
1661 if ((flags & HeightValue) == 0)
1662 geometry.height=geometry.width;
1663 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1664 geometry.x,geometry.y,&target,&exception);
1667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1674 if (LocaleCompare(keyword,"x") == 0)
1676 geometry.x=atol(value);
1677 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1678 geometry.x,geometry.y,&target,&exception);
1681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1688 if (LocaleCompare(keyword,"y") == 0)
1690 geometry.y=atol(value);
1691 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1692 geometry.x,geometry.y,&target,&exception);
1695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1701 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1707 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1708 draw_info,&target,geometry.x,geometry.y,
1709 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1710 draw_info=DestroyDrawInfo(draw_info);
1713 if (LocaleCompare((const char *) tag,"comment") == 0)
1715 if (LocaleCompare((const char *) tag,"composite") == 0)
1718 composite_geometry[MaxTextExtent];
1733 if (msl_info->image[n] == (Image *) NULL)
1735 ThrowMSLException(OptionError,"NoImagesDefined",
1736 (const char *) tag);
1739 composite_image=NewImageList();
1740 compose=OverCompositeOp;
1741 if (attributes != (const xmlChar **) NULL)
1742 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1744 keyword=(const char *) attributes[i++];
1745 attribute=InterpretImageProperties(msl_info->image_info[n],
1746 msl_info->attributes[n],(const char *) attributes[i]);
1747 CloneString(&value,attribute);
1753 if (LocaleCompare(keyword,"compose") == 0)
1755 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1758 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1760 compose=(CompositeOperator) option;
1768 if (LocaleCompare(keyword,"image") == 0)
1769 for (j=0; j < msl_info->n; j++)
1774 attribute=GetImageProperty(msl_info->attributes[j],"id");
1775 if ((attribute != (const char *) NULL) &&
1776 (LocaleCompare(attribute,value) == 0))
1778 composite_image=CloneImage(msl_info->image[j],0,0,
1779 MagickFalse,&exception);
1789 if (composite_image == (Image *) NULL)
1791 rotate_image=NewImageList();
1792 SetGeometry(msl_info->image[n],&geometry);
1793 if (attributes != (const xmlChar **) NULL)
1794 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1796 keyword=(const char *) attributes[i++];
1797 attribute=InterpretImageProperties(msl_info->image_info[n],
1798 msl_info->attributes[n],(const char *) attributes[i]);
1799 CloneString(&value,attribute);
1805 if (LocaleCompare(keyword,"blend") == 0)
1807 (void) SetImageArtifact(composite_image,
1808 "compose:args",value);
1811 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1818 if (LocaleCompare(keyword,"channel") == 0)
1820 option=ParseChannelOption(value);
1822 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1824 channel=(ChannelType) option;
1827 if (LocaleCompare(keyword, "color") == 0)
1829 (void) QueryColorDatabase(value,
1830 &composite_image->background_color,&exception);
1833 if (LocaleCompare(keyword,"compose") == 0)
1835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1842 if (LocaleCompare(keyword,"geometry") == 0)
1844 flags=ParsePageGeometry(msl_info->image[n],value,
1845 &geometry,&exception);
1846 if ((flags & HeightValue) == 0)
1847 geometry.height=geometry.width;
1848 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1849 geometry.y,&target,&exception);
1852 if (LocaleCompare(keyword,"gravity") == 0)
1854 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
1857 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1859 msl_info->image[n]->gravity=(GravityType) option;
1862 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1869 if (LocaleCompare(keyword,"image") == 0)
1871 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1878 if (LocaleCompare(keyword,"mask") == 0)
1879 for (j=0; j < msl_info->n; j++)
1884 attribute=GetImageProperty(msl_info->attributes[j],"id");
1885 if ((attribute != (const char *) NULL) &&
1886 (LocaleCompare(value,value) == 0))
1888 SetImageType(composite_image,TrueColorMatteType);
1889 (void) CompositeImage(composite_image,
1890 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1894 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1901 if (LocaleCompare(keyword,"opacity") == 0)
1910 register PixelPacket
1916 opacity=QuantumRange-atol(value);
1917 if (compose != DissolveCompositeOp)
1919 (void) SetImageOpacity(composite_image,(Quantum)
1923 (void) SetImageArtifact(msl_info->image[n],
1924 "compose:args",value);
1925 if (composite_image->matte != MagickTrue)
1926 (void) SetImageOpacity(composite_image,OpaqueOpacity);
1927 composite_view=AcquireCacheView(composite_image);
1928 for (y=0; y < (long) composite_image->rows ; y++)
1930 q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
1931 composite_image->columns,1,&exception);
1932 for (x=0; x < (long) composite_image->columns; x++)
1934 if (q->opacity == OpaqueOpacity)
1935 q->opacity=RoundToQuantum(opacity);
1938 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1941 composite_view=DestroyCacheView(composite_view);
1944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1951 if (LocaleCompare(keyword,"rotate") == 0)
1953 rotate_image=RotateImage(composite_image,atof(value),
1957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1964 if (LocaleCompare(keyword,"tile") == 0)
1969 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1972 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1974 tile=(MagickBooleanType) option;
1975 if (rotate_image != (Image *) NULL)
1976 (void) SetImageArtifact(rotate_image,
1977 "compose:outside-overlay","false");
1979 (void) SetImageArtifact(composite_image,
1980 "compose:outside-overlay","false");
1981 image=msl_info->image[n];
1982 height=composite_image->rows;
1983 width=composite_image->columns;
1984 for (y=0; y < (long) image->rows; y+=height)
1985 for (x=0; x < (long) image->columns; x+=width)
1987 if (rotate_image != (Image *) NULL)
1988 (void) CompositeImage(image,compose,rotate_image,
1991 (void) CompositeImage(image,compose,
1992 composite_image,x,y);
1994 if (rotate_image != (Image *) NULL)
1995 rotate_image=DestroyImage(rotate_image);
1998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2005 if (LocaleCompare(keyword,"x") == 0)
2007 geometry.x=atol(value);
2008 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2009 geometry.y,&target,&exception);
2012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2019 if (LocaleCompare(keyword,"y") == 0)
2021 geometry.y=atol(value);
2022 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2023 geometry.y,&target,&exception);
2026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2038 image=msl_info->image[n];
2039 (void) FormatMagickString(composite_geometry,MaxTextExtent,
2040 "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
2041 geometry.x,geometry.y);
2042 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2044 if (rotate_image == (Image *) NULL)
2045 CompositeImageChannel(image,channel,compose,composite_image,
2046 geometry.x,geometry.y);
2052 geometry.x-=(long) (rotate_image->columns-
2053 composite_image->columns)/2;
2054 geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
2055 CompositeImageChannel(image,channel,compose,rotate_image,
2056 geometry.x,geometry.y);
2057 rotate_image=DestroyImage(rotate_image);
2059 composite_image=DestroyImage(composite_image);
2062 if (LocaleCompare((const char *) tag,"contrast") == 0)
2070 if (msl_info->image[n] == (Image *) NULL)
2072 ThrowMSLException(OptionError,"NoImagesDefined",
2073 (const char *) tag);
2076 sharpen=MagickFalse;
2077 if (attributes != (const xmlChar **) NULL)
2078 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2080 keyword=(const char *) attributes[i++];
2081 attribute=InterpretImageProperties(msl_info->image_info[n],
2082 msl_info->attributes[n],(const char *) attributes[i]);
2083 CloneString(&value,attribute);
2089 if (LocaleCompare(keyword,"sharpen") == 0)
2091 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2094 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2096 sharpen=(MagickBooleanType) option;
2099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2105 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2111 (void) ContrastImage(msl_info->image[n],sharpen);
2114 if (LocaleCompare((const char *) tag,"crop") == 0)
2122 if (msl_info->image[n] == (Image *) NULL)
2124 ThrowMSLException(OptionError,"NoImagesDefined",
2125 (const char *) tag);
2128 SetGeometry(msl_info->image[n],&geometry);
2129 if (attributes != (const xmlChar **) NULL)
2130 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2132 keyword=(const char *) attributes[i++];
2133 attribute=InterpretImageProperties(msl_info->image_info[n],
2134 msl_info->attributes[n],(const char *) attributes[i]);
2135 CloneString(&value,attribute);
2141 if (LocaleCompare(keyword,"geometry") == 0)
2143 flags=ParsePageGeometry(msl_info->image[n],value,
2144 &geometry,&exception);
2145 if ((flags & HeightValue) == 0)
2146 geometry.height=geometry.width;
2149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2156 if (LocaleCompare(keyword,"height") == 0)
2158 geometry.height=atol(value);
2161 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2168 if (LocaleCompare(keyword,"width") == 0)
2170 geometry.width=atol(value);
2173 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2180 if (LocaleCompare(keyword,"x") == 0)
2182 geometry.x=atol(value);
2185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2192 if (LocaleCompare(keyword,"y") == 0)
2194 geometry.y=atol(value);
2197 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2209 crop_image=CropImage(msl_info->image[n],&geometry,
2210 &msl_info->image[n]->exception);
2211 if (crop_image == (Image *) NULL)
2213 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2214 msl_info->image[n]=crop_image;
2217 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2223 Cycle-colormap image.
2225 if (msl_info->image[n] == (Image *) NULL)
2227 ThrowMSLException(OptionError,"NoImagesDefined",
2228 (const char *) tag);
2232 if (attributes != (const xmlChar **) NULL)
2233 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2235 keyword=(const char *) attributes[i++];
2236 attribute=InterpretImageProperties(msl_info->image_info[n],
2237 msl_info->attributes[n],(const char *) attributes[i]);
2238 CloneString(&value,attribute);
2244 if (LocaleCompare(keyword,"display") == 0)
2246 display=atol(value);
2249 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2261 (void) CycleColormapImage(msl_info->image[n],display);
2264 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2269 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2277 if (msl_info->image[n] == (Image *) NULL)
2279 ThrowMSLException(OptionError,"NoImagesDefined",
2280 (const char *) tag);
2283 if (attributes != (const xmlChar **) NULL)
2284 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2286 keyword=(const char *) attributes[i++];
2287 attribute=InterpretImageProperties(msl_info->image_info[n],
2288 msl_info->attributes[n],(const char *) attributes[i]);
2289 CloneString(&value,attribute);
2290 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2292 despeckle_image=DespeckleImage(msl_info->image[n],
2293 &msl_info->image[n]->exception);
2294 if (despeckle_image == (Image *) NULL)
2296 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2297 msl_info->image[n]=despeckle_image;
2300 if (LocaleCompare((const char *) tag,"display") == 0)
2302 if (msl_info->image[n] == (Image *) NULL)
2304 ThrowMSLException(OptionError,"NoImagesDefined",
2305 (const char *) tag);
2308 if (attributes != (const xmlChar **) NULL)
2309 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2311 keyword=(const char *) attributes[i++];
2312 attribute=InterpretImageProperties(msl_info->image_info[n],
2313 msl_info->attributes[n],(const char *) attributes[i]);
2314 CloneString(&value,attribute);
2319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2325 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2328 if (LocaleCompare((const char *) tag,"draw") == 0)
2331 text[MaxTextExtent];
2336 if (msl_info->image[n] == (Image *) NULL)
2338 ThrowMSLException(OptionError,"NoImagesDefined",
2339 (const char *) tag);
2342 draw_info=CloneDrawInfo(msl_info->image_info[n],
2343 msl_info->draw_info[n]);
2345 current=draw_info->affine;
2346 GetAffineMatrix(&affine);
2347 if (attributes != (const xmlChar **) NULL)
2348 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2350 keyword=(const char *) attributes[i++];
2351 attribute=InterpretImageProperties(msl_info->image_info[n],
2352 msl_info->attributes[n],(const char *) attributes[i]);
2353 CloneString(&value,attribute);
2359 if (LocaleCompare(keyword,"affine") == 0)
2365 draw_info->affine.sx=strtod(p,&p);
2368 draw_info->affine.rx=strtod(p,&p);
2371 draw_info->affine.ry=strtod(p,&p);
2374 draw_info->affine.sy=strtod(p,&p);
2377 draw_info->affine.tx=strtod(p,&p);
2380 draw_info->affine.ty=strtod(p,&p);
2383 if (LocaleCompare(keyword,"align") == 0)
2385 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
2388 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2390 draw_info->align=(AlignType) option;
2393 if (LocaleCompare(keyword,"antialias") == 0)
2395 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2398 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2400 draw_info->stroke_antialias=(MagickBooleanType) option;
2401 draw_info->text_antialias=(MagickBooleanType) option;
2404 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2411 if (LocaleCompare(keyword,"density") == 0)
2413 CloneString(&draw_info->density,value);
2416 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2423 if (LocaleCompare(keyword,"encoding") == 0)
2425 CloneString(&draw_info->encoding,value);
2428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2435 if (LocaleCompare(keyword, "fill") == 0)
2437 (void) QueryColorDatabase(value,&draw_info->fill,
2441 if (LocaleCompare(keyword,"family") == 0)
2443 CloneString(&draw_info->family,value);
2446 if (LocaleCompare(keyword,"font") == 0)
2448 CloneString(&draw_info->font,value);
2451 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2458 if (LocaleCompare(keyword,"geometry") == 0)
2460 flags=ParsePageGeometry(msl_info->image[n],value,
2461 &geometry,&exception);
2462 if ((flags & HeightValue) == 0)
2463 geometry.height=geometry.width;
2466 if (LocaleCompare(keyword,"gravity") == 0)
2468 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
2471 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2473 draw_info->gravity=(GravityType) option;
2476 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2483 if (LocaleCompare(keyword,"primitive") == 0)
2485 CloneString(&draw_info->primitive,value);
2488 if (LocaleCompare(keyword,"pointsize") == 0)
2490 draw_info->pointsize=atof(value);
2493 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2500 if (LocaleCompare(keyword,"rotate") == 0)
2503 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2504 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2505 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2506 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2516 if (LocaleCompare(keyword,"scale") == 0)
2518 flags=ParseGeometry(value,&geometry_info);
2519 if ((flags & SigmaValue) == 0)
2520 geometry_info.sigma=1.0;
2521 affine.sx=geometry_info.rho;
2522 affine.sy=geometry_info.sigma;
2525 if (LocaleCompare(keyword,"skewX") == 0)
2528 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2531 if (LocaleCompare(keyword,"skewY") == 0)
2534 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2537 if (LocaleCompare(keyword,"stretch") == 0)
2539 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
2542 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2544 draw_info->stretch=(StretchType) option;
2547 if (LocaleCompare(keyword, "stroke") == 0)
2549 (void) QueryColorDatabase(value,&draw_info->stroke,
2553 if (LocaleCompare(keyword,"strokewidth") == 0)
2555 draw_info->stroke_width=atol(value);
2558 if (LocaleCompare(keyword,"style") == 0)
2560 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
2563 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2565 draw_info->style=(StyleType) option;
2568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2575 if (LocaleCompare(keyword,"text") == 0)
2577 CloneString(&draw_info->text,value);
2580 if (LocaleCompare(keyword,"translate") == 0)
2582 flags=ParseGeometry(value,&geometry_info);
2583 if ((flags & SigmaValue) == 0)
2584 geometry_info.sigma=1.0;
2585 affine.tx=geometry_info.rho;
2586 affine.ty=geometry_info.sigma;
2589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2596 if (LocaleCompare(keyword, "undercolor") == 0)
2598 (void) QueryColorDatabase(value,&draw_info->undercolor,
2602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2609 if (LocaleCompare(keyword,"weight") == 0)
2611 draw_info->weight=atol(value);
2614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2621 if (LocaleCompare(keyword,"x") == 0)
2623 geometry.x=atol(value);
2626 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2633 if (LocaleCompare(keyword,"y") == 0)
2635 geometry.y=atol(value);
2638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2650 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
2651 geometry.width,geometry.height,geometry.x,geometry.y);
2652 CloneString(&draw_info->geometry,text);
2653 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
2654 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
2655 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
2656 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
2657 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
2659 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
2661 (void) DrawImage(msl_info->image[n],draw_info);
2662 draw_info=DestroyDrawInfo(draw_info);
2665 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2670 if (LocaleCompare((const char *) tag,"edge") == 0)
2678 if (msl_info->image[n] == (Image *) NULL)
2680 ThrowMSLException(OptionError,"NoImagesDefined",
2681 (const char *) tag);
2684 if (attributes != (const xmlChar **) NULL)
2685 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2687 keyword=(const char *) attributes[i++];
2688 attribute=InterpretImageProperties(msl_info->image_info[n],
2689 msl_info->attributes[n],(const char *) attributes[i]);
2690 CloneString(&value,attribute);
2696 if (LocaleCompare(keyword,"geometry") == 0)
2698 flags=ParseGeometry(value,&geometry_info);
2699 if ((flags & SigmaValue) == 0)
2700 geometry_info.sigma=1.0;
2703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2710 if (LocaleCompare(keyword,"radius") == 0)
2712 geometry_info.rho=atof(value);
2715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2727 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2728 &msl_info->image[n]->exception);
2729 if (edge_image == (Image *) NULL)
2731 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2732 msl_info->image[n]=edge_image;
2735 if (LocaleCompare((const char *) tag,"emboss") == 0)
2743 if (msl_info->image[n] == (Image *) NULL)
2745 ThrowMSLException(OptionError,"NoImagesDefined",
2746 (const char *) tag);
2749 if (attributes != (const xmlChar **) NULL)
2750 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2752 keyword=(const char *) attributes[i++];
2753 attribute=InterpretImageProperties(msl_info->image_info[n],
2754 msl_info->attributes[n],(const char *) attributes[i]);
2755 CloneString(&value,attribute);
2761 if (LocaleCompare(keyword,"geometry") == 0)
2763 flags=ParseGeometry(value,&geometry_info);
2764 if ((flags & SigmaValue) == 0)
2765 geometry_info.sigma=1.0;
2768 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2775 if (LocaleCompare(keyword,"radius") == 0)
2777 geometry_info.rho=atof(value);
2780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2787 if (LocaleCompare(keyword,"sigma") == 0)
2789 geometry_info.sigma=atol(value);
2792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2798 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2804 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2805 geometry_info.sigma,&msl_info->image[n]->exception);
2806 if (emboss_image == (Image *) NULL)
2808 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2809 msl_info->image[n]=emboss_image;
2812 if (LocaleCompare((const char *) tag,"enhance") == 0)
2820 if (msl_info->image[n] == (Image *) NULL)
2822 ThrowMSLException(OptionError,"NoImagesDefined",
2823 (const char *) tag);
2826 if (attributes != (const xmlChar **) NULL)
2827 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2829 keyword=(const char *) attributes[i++];
2830 attribute=InterpretImageProperties(msl_info->image_info[n],
2831 msl_info->attributes[n],(const char *) attributes[i]);
2832 CloneString(&value,attribute);
2833 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2835 enhance_image=EnhanceImage(msl_info->image[n],
2836 &msl_info->image[n]->exception);
2837 if (enhance_image == (Image *) NULL)
2839 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2840 msl_info->image[n]=enhance_image;
2843 if (LocaleCompare((const char *) tag,"equalize") == 0)
2848 if (msl_info->image[n] == (Image *) NULL)
2850 ThrowMSLException(OptionError,"NoImagesDefined",
2851 (const char *) tag);
2854 if (attributes != (const xmlChar **) NULL)
2855 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2857 keyword=(const char *) attributes[i++];
2858 attribute=InterpretImageProperties(msl_info->image_info[n],
2859 msl_info->attributes[n],(const char *) attributes[i]);
2860 CloneString(&value,attribute);
2865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2871 (void) EqualizeImage(msl_info->image[n]);
2874 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2879 if (LocaleCompare((const char *) tag, "flatten") == 0)
2881 if (msl_info->image[n] == (Image *) NULL)
2883 ThrowMSLException(OptionError,"NoImagesDefined",
2884 (const char *) tag);
2888 /* no attributes here */
2890 /* process the image */
2895 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2896 &msl_info->image[n]->exception);
2897 if (newImage == (Image *) NULL)
2899 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2900 msl_info->image[n]=newImage;
2904 if (LocaleCompare((const char *) tag,"flip") == 0)
2912 if (msl_info->image[n] == (Image *) NULL)
2914 ThrowMSLException(OptionError,"NoImagesDefined",
2915 (const char *) tag);
2918 if (attributes != (const xmlChar **) NULL)
2919 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2921 keyword=(const char *) attributes[i++];
2922 attribute=InterpretImageProperties(msl_info->image_info[n],
2923 msl_info->attributes[n],(const char *) attributes[i]);
2924 CloneString(&value,attribute);
2925 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2927 flip_image=FlipImage(msl_info->image[n],
2928 &msl_info->image[n]->exception);
2929 if (flip_image == (Image *) NULL)
2931 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2932 msl_info->image[n]=flip_image;
2935 if (LocaleCompare((const char *) tag,"flop") == 0)
2943 if (msl_info->image[n] == (Image *) NULL)
2945 ThrowMSLException(OptionError,"NoImagesDefined",
2946 (const char *) tag);
2949 if (attributes != (const xmlChar **) NULL)
2950 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2952 keyword=(const char *) attributes[i++];
2953 attribute=InterpretImageProperties(msl_info->image_info[n],
2954 msl_info->attributes[n],(const char *) attributes[i]);
2955 CloneString(&value,attribute);
2956 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2958 flop_image=FlopImage(msl_info->image[n],
2959 &msl_info->image[n]->exception);
2960 if (flop_image == (Image *) NULL)
2962 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2963 msl_info->image[n]=flop_image;
2966 if (LocaleCompare((const char *) tag,"frame") == 0)
2977 if (msl_info->image[n] == (Image *) NULL)
2979 ThrowMSLException(OptionError,"NoImagesDefined",
2980 (const char *) tag);
2983 SetGeometry(msl_info->image[n],&geometry);
2984 if (attributes != (const xmlChar **) NULL)
2985 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2987 keyword=(const char *) attributes[i++];
2988 attribute=InterpretImageProperties(msl_info->image_info[n],
2989 msl_info->attributes[n],(const char *) attributes[i]);
2990 CloneString(&value,attribute);
2996 if (LocaleCompare(keyword,"compose") == 0)
2998 option=ParseMagickOption(MagickComposeOptions,
3001 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3003 msl_info->image[n]->compose=(CompositeOperator) option;
3006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3013 if (LocaleCompare(keyword, "fill") == 0)
3015 (void) QueryColorDatabase(value,
3016 &msl_info->image[n]->matte_color,&exception);
3019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3026 if (LocaleCompare(keyword,"geometry") == 0)
3028 flags=ParsePageGeometry(msl_info->image[n],value,
3029 &geometry,&exception);
3030 if ((flags & HeightValue) == 0)
3031 geometry.height=geometry.width;
3032 frame_info.width=geometry.width;
3033 frame_info.height=geometry.height;
3034 frame_info.outer_bevel=geometry.x;
3035 frame_info.inner_bevel=geometry.y;
3038 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3045 if (LocaleCompare(keyword,"height") == 0)
3047 frame_info.height=atol(value);
3050 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3057 if (LocaleCompare(keyword,"inner") == 0)
3059 frame_info.inner_bevel=atol(value);
3062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3069 if (LocaleCompare(keyword,"outer") == 0)
3071 frame_info.outer_bevel=atol(value);
3074 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3081 if (LocaleCompare(keyword,"width") == 0)
3083 frame_info.width=atol(value);
3086 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3092 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3098 frame_info.x=(long) frame_info.width;
3099 frame_info.y=(long) frame_info.height;
3100 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3101 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3102 frame_image=FrameImage(msl_info->image[n],&frame_info,
3103 &msl_info->image[n]->exception);
3104 if (frame_image == (Image *) NULL)
3106 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3107 msl_info->image[n]=frame_image;
3110 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3115 if (LocaleCompare((const char *) tag,"gamma") == 0)
3118 gamma[MaxTextExtent];
3126 if (msl_info->image[n] == (Image *) NULL)
3128 ThrowMSLException(OptionError,"NoImagesDefined",
3129 (const char *) tag);
3132 channel=UndefinedChannel;
3137 if (attributes != (const xmlChar **) NULL)
3138 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3140 keyword=(const char *) attributes[i++];
3141 attribute=InterpretImageProperties(msl_info->image_info[n],
3142 msl_info->attributes[n],(const char *) attributes[i]);
3143 CloneString(&value,attribute);
3149 if (LocaleCompare(keyword,"blue") == 0)
3151 pixel.blue=atof(value);
3154 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3161 if (LocaleCompare(keyword,"channel") == 0)
3163 option=ParseChannelOption(value);
3165 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3167 channel=(ChannelType) option;
3170 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3177 if (LocaleCompare(keyword,"gamma") == 0)
3179 (void) CopyMagickString(gamma,value,MaxTextExtent);
3182 if (LocaleCompare(keyword,"green") == 0)
3184 pixel.green=atof(value);
3187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3194 if (LocaleCompare(keyword,"red") == 0)
3196 pixel.red=atof(value);
3199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3212 (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
3213 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3218 (void) GammaImage(msl_info->image[n],gamma);
3223 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3228 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3234 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3241 else if (LocaleCompare((const char *) tag,"get") == 0)
3243 if (msl_info->image[n] == (Image *) NULL)
3245 ThrowMSLException(OptionError,"NoImagesDefined",
3246 (const char *) tag);
3249 if (attributes == (const xmlChar **) NULL)
3251 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3253 keyword=(const char *) attributes[i++];
3254 CloneString(&value,(const char *) attributes[i]);
3255 (void) CopyMagickString(key,value,MaxTextExtent);
3261 if (LocaleCompare(keyword,"height") == 0)
3263 (void) FormatMagickString(value,MaxTextExtent,"%ld",
3264 msl_info->image[n]->rows);
3265 (void) SetImageProperty(msl_info->attributes[n],key,value);
3268 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3273 if (LocaleCompare(keyword,"width") == 0)
3275 (void) FormatMagickString(value,MaxTextExtent,"%ld",
3276 msl_info->image[n]->columns);
3277 (void) SetImageProperty(msl_info->attributes[n],key,value);
3280 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3284 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3291 else if (LocaleCompare((const char *) tag, "group") == 0)
3293 msl_info->number_groups++;
3294 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3295 msl_info->group_info,msl_info->number_groups+1UL,
3296 sizeof(*msl_info->group_info));
3299 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3304 if (LocaleCompare((const char *) tag,"image") == 0)
3306 MSLPushImage(msl_info,(Image *) NULL);
3307 if (attributes == (const xmlChar **) NULL)
3309 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3311 keyword=(const char *) attributes[i++];
3312 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3313 msl_info->attributes[n],(const char *) attributes[i]));
3319 if (LocaleCompare(keyword,"color") == 0)
3324 (void) CopyMagickString(msl_info->image_info[n]->filename,
3325 "xc:",MaxTextExtent);
3326 (void) ConcatenateMagickString(msl_info->image_info[n]->
3327 filename,value,MaxTextExtent);
3328 next_image=ReadImage(msl_info->image_info[n],&exception);
3329 CatchException(&exception);
3330 if (next_image == (Image *) NULL)
3332 if (msl_info->image[n] == (Image *) NULL)
3333 msl_info->image[n]=next_image;
3340 Link image into image list.
3342 p=msl_info->image[n];
3343 while (p->next != (Image *) NULL)
3344 p=GetNextImageInList(p);
3345 next_image->previous=p;
3350 (void) SetMSLAttributes(msl_info,keyword,value);
3355 (void) SetMSLAttributes(msl_info,keyword,value);
3362 if (LocaleCompare((const char *) tag,"implode") == 0)
3370 if (msl_info->image[n] == (Image *) NULL)
3372 ThrowMSLException(OptionError,"NoImagesDefined",
3373 (const char *) tag);
3376 if (attributes != (const xmlChar **) NULL)
3377 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3379 keyword=(const char *) attributes[i++];
3380 attribute=InterpretImageProperties(msl_info->image_info[n],
3381 msl_info->attributes[n],(const char *) attributes[i]);
3382 CloneString(&value,attribute);
3388 if (LocaleCompare(keyword,"amount") == 0)
3390 geometry_info.rho=atof(value);
3393 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3400 if (LocaleCompare(keyword,"geometry") == 0)
3402 flags=ParseGeometry(value,&geometry_info);
3403 if ((flags & SigmaValue) == 0)
3404 geometry_info.sigma=1.0;
3407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3419 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3420 &msl_info->image[n]->exception);
3421 if (implode_image == (Image *) NULL)
3423 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3424 msl_info->image[n]=implode_image;
3427 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3432 if (LocaleCompare((const char *) tag,"label") == 0)
3434 if (LocaleCompare((const char *) tag, "level") == 0)
3437 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3439 if (msl_info->image[n] == (Image *) NULL)
3441 ThrowMSLException(OptionError,"NoImagesDefined",
3442 (const char *) tag);
3445 if (attributes == (const xmlChar **) NULL)
3447 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3449 keyword=(const char *) attributes[i++];
3450 CloneString(&value,(const char *) attributes[i]);
3451 (void) CopyMagickString(key,value,MaxTextExtent);
3457 if (LocaleCompare(keyword,"black") == 0)
3459 levelBlack = atof( value );
3462 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3468 if (LocaleCompare(keyword,"gamma") == 0)
3470 levelGamma = atof( value );
3473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3479 if (LocaleCompare(keyword,"white") == 0)
3481 levelWhite = atof( value );
3484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3497 char level[MaxTextExtent + 1];
3498 (void) FormatMagickString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3499 levelBlack,levelGamma,levelWhite);
3500 LevelImage ( msl_info->image[n], level );
3508 if (LocaleCompare((const char *) tag,"magnify") == 0)
3516 if (msl_info->image[n] == (Image *) NULL)
3518 ThrowMSLException(OptionError,"NoImagesDefined",
3519 (const char *) tag);
3522 if (attributes != (const xmlChar **) NULL)
3523 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3525 keyword=(const char *) attributes[i++];
3526 attribute=InterpretImageProperties(msl_info->image_info[n],
3527 msl_info->attributes[n],(const char *) attributes[i]);
3528 CloneString(&value,attribute);
3529 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3531 magnify_image=MagnifyImage(msl_info->image[n],
3532 &msl_info->image[n]->exception);
3533 if (magnify_image == (Image *) NULL)
3535 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3536 msl_info->image[n]=magnify_image;
3539 if (LocaleCompare((const char *) tag,"map") == 0)
3553 if (msl_info->image[n] == (Image *) NULL)
3555 ThrowMSLException(OptionError,"NoImagesDefined",
3556 (const char *) tag);
3559 affinity_image=NewImageList();
3561 if (attributes != (const xmlChar **) NULL)
3562 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3564 keyword=(const char *) attributes[i++];
3565 attribute=InterpretImageProperties(msl_info->image_info[n],
3566 msl_info->attributes[n],(const char *) attributes[i]);
3567 CloneString(&value,attribute);
3573 if (LocaleCompare(keyword,"dither") == 0)
3575 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
3578 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3580 dither=(MagickBooleanType) option;
3583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3590 if (LocaleCompare(keyword,"image") == 0)
3591 for (j=0; j < msl_info->n; j++)
3596 attribute=GetImageProperty(msl_info->attributes[j],"id");
3597 if ((attribute != (const char *) NULL) &&
3598 (LocaleCompare(attribute,value) == 0))
3600 affinity_image=CloneImage(msl_info->image[j],0,0,
3601 MagickFalse,&exception);
3609 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3615 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3616 quantize_info->dither=dither;
3617 (void) RemapImages(quantize_info,msl_info->image[n],
3619 quantize_info=DestroyQuantizeInfo(quantize_info);
3620 affinity_image=DestroyImage(affinity_image);
3623 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3635 Matte floodfill image.
3638 if (msl_info->image[n] == (Image *) NULL)
3640 ThrowMSLException(OptionError,"NoImagesDefined",
3641 (const char *) tag);
3644 SetGeometry(msl_info->image[n],&geometry);
3645 paint_method=FloodfillMethod;
3646 if (attributes != (const xmlChar **) NULL)
3647 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3649 keyword=(const char *) attributes[i++];
3650 attribute=InterpretImageProperties(msl_info->image_info[n],
3651 msl_info->attributes[n],(const char *) attributes[i]);
3652 CloneString(&value,attribute);
3658 if (LocaleCompare(keyword,"bordercolor") == 0)
3660 (void) QueryMagickColor(value,&target,&exception);
3661 paint_method=FillToBorderMethod;
3664 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3671 if (LocaleCompare(keyword,"fuzz") == 0)
3673 msl_info->image[n]->fuzz=atof(value);
3676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3683 if (LocaleCompare(keyword,"geometry") == 0)
3685 flags=ParsePageGeometry(msl_info->image[n],value,
3686 &geometry,&exception);
3687 if ((flags & HeightValue) == 0)
3688 geometry.height=geometry.width;
3689 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3690 geometry.x,geometry.y,&target,&exception);
3693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3700 if (LocaleCompare(keyword,"opacity") == 0)
3702 opacity=atof(value);
3705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3712 if (LocaleCompare(keyword,"x") == 0)
3714 geometry.x=atol(value);
3715 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3716 geometry.x,geometry.y,&target,&exception);
3719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3726 if (LocaleCompare(keyword,"y") == 0)
3728 geometry.y=atol(value);
3729 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3730 geometry.x,geometry.y,&target,&exception);
3733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3745 draw_info=CloneDrawInfo(msl_info->image_info[n],
3746 msl_info->draw_info[n]);
3747 draw_info->fill.opacity=RoundToQuantum(opacity);
3748 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3749 draw_info,&target,geometry.x,geometry.y,
3750 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3751 draw_info=DestroyDrawInfo(draw_info);
3754 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3760 Median-filter image.
3762 if (msl_info->image[n] == (Image *) NULL)
3764 ThrowMSLException(OptionError,"NoImagesDefined",
3765 (const char *) tag);
3768 if (attributes != (const xmlChar **) NULL)
3769 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3771 keyword=(const char *) attributes[i++];
3772 attribute=InterpretImageProperties(msl_info->image_info[n],
3773 msl_info->attributes[n],(const char *) attributes[i]);
3774 CloneString(&value,attribute);
3780 if (LocaleCompare(keyword,"geometry") == 0)
3782 flags=ParseGeometry(value,&geometry_info);
3783 if ((flags & SigmaValue) == 0)
3784 geometry_info.sigma=1.0;
3787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3794 if (LocaleCompare(keyword,"radius") == 0)
3796 geometry_info.rho=atof(value);
3799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3805 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3811 median_image=MedianFilterImage(msl_info->image[n],geometry_info.rho,
3812 &msl_info->image[n]->exception);
3813 if (median_image == (Image *) NULL)
3815 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3816 msl_info->image[n]=median_image;
3819 if (LocaleCompare((const char *) tag,"minify") == 0)
3827 if (msl_info->image[n] == (Image *) NULL)
3829 ThrowMSLException(OptionError,"NoImagesDefined",
3830 (const char *) tag);
3833 if (attributes != (const xmlChar **) NULL)
3834 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3836 keyword=(const char *) attributes[i++];
3837 attribute=InterpretImageProperties(msl_info->image_info[n],
3838 msl_info->attributes[n],(const char *) attributes[i]);
3839 CloneString(&value,attribute);
3840 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3842 minify_image=MinifyImage(msl_info->image[n],
3843 &msl_info->image[n]->exception);
3844 if (minify_image == (Image *) NULL)
3846 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3847 msl_info->image[n]=minify_image;
3850 if (LocaleCompare((const char *) tag,"msl") == 0 )
3852 if (LocaleCompare((const char *) tag,"modulate") == 0)
3855 modulate[MaxTextExtent];
3860 if (msl_info->image[n] == (Image *) NULL)
3862 ThrowMSLException(OptionError,"NoImagesDefined",
3863 (const char *) tag);
3866 geometry_info.rho=100.0;
3867 geometry_info.sigma=100.0;
3868 geometry_info.xi=100.0;
3869 if (attributes != (const xmlChar **) NULL)
3870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3872 keyword=(const char *) attributes[i++];
3873 attribute=InterpretImageProperties(msl_info->image_info[n],
3874 msl_info->attributes[n],(const char *) attributes[i]);
3875 CloneString(&value,attribute);
3881 if (LocaleCompare(keyword,"blackness") == 0)
3883 geometry_info.rho=atof(value);
3886 if (LocaleCompare(keyword,"brightness") == 0)
3888 geometry_info.rho=atof(value);
3891 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3898 if (LocaleCompare(keyword,"factor") == 0)
3900 flags=ParseGeometry(value,&geometry_info);
3903 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3910 if (LocaleCompare(keyword,"hue") == 0)
3912 geometry_info.xi=atof(value);
3915 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3922 if (LocaleCompare(keyword,"lightness") == 0)
3924 geometry_info.rho=atof(value);
3927 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3934 if (LocaleCompare(keyword,"saturation") == 0)
3936 geometry_info.sigma=atof(value);
3939 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3946 if (LocaleCompare(keyword,"whiteness") == 0)
3948 geometry_info.sigma=atof(value);
3951 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3963 (void) FormatMagickString(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=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4021 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4023 gray=(MagickBooleanType) option;
4026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4038 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4041 if (LocaleCompare((const char *) tag,"normalize") == 0)
4046 if (msl_info->image[n] == (Image *) NULL)
4048 ThrowMSLException(OptionError,"NoImagesDefined",
4049 (const char *) tag);
4052 if (attributes != (const xmlChar **) NULL)
4053 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4055 keyword=(const char *) attributes[i++];
4056 attribute=InterpretImageProperties(msl_info->image_info[n],
4057 msl_info->attributes[n],(const char *) attributes[i]);
4058 CloneString(&value,attribute);
4064 if (LocaleCompare(keyword,"channel") == 0)
4066 option=ParseChannelOption(value);
4068 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4070 channel=(ChannelType) option;
4073 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4085 (void) NormalizeImageChannel(msl_info->image[n],channel);
4088 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4093 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4101 if (msl_info->image[n] == (Image *) NULL)
4103 ThrowMSLException(OptionError,"NoImagesDefined",
4104 (const char *) tag);
4107 if (attributes != (const xmlChar **) NULL)
4108 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4110 keyword=(const char *) attributes[i++];
4111 attribute=InterpretImageProperties(msl_info->image_info[n],
4112 msl_info->attributes[n],(const char *) attributes[i]);
4113 CloneString(&value,attribute);
4119 if (LocaleCompare(keyword,"geometry") == 0)
4121 flags=ParseGeometry(value,&geometry_info);
4122 if ((flags & SigmaValue) == 0)
4123 geometry_info.sigma=1.0;
4126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4133 if (LocaleCompare(keyword,"radius") == 0)
4135 geometry_info.rho=atof(value);
4138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4150 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4151 &msl_info->image[n]->exception);
4152 if (paint_image == (Image *) NULL)
4154 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4155 msl_info->image[n]=paint_image;
4158 if (LocaleCompare((const char *) tag,"opaque") == 0)
4167 if (msl_info->image[n] == (Image *) NULL)
4169 ThrowMSLException(OptionError,"NoImagesDefined",
4170 (const char *) tag);
4173 (void) QueryMagickColor("none",&target,&exception);
4174 (void) QueryMagickColor("none",&fill_color,&exception);
4175 if (attributes != (const xmlChar **) NULL)
4176 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4178 keyword=(const char *) attributes[i++];
4179 attribute=InterpretImageProperties(msl_info->image_info[n],
4180 msl_info->attributes[n],(const char *) attributes[i]);
4181 CloneString(&value,attribute);
4187 if (LocaleCompare(keyword,"channel") == 0)
4189 option=ParseChannelOption(value);
4191 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4193 channel=(ChannelType) option;
4196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4203 if (LocaleCompare(keyword,"fill") == 0)
4205 (void) QueryMagickColor(value,&fill_color,&exception);
4208 if (LocaleCompare(keyword,"fuzz") == 0)
4210 msl_info->image[n]->fuzz=atof(value);
4213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4225 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4226 &target,&fill_color,MagickFalse);
4229 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4234 if (LocaleCompare((const char *) tag,"print") == 0)
4236 if (attributes == (const xmlChar **) NULL)
4238 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4240 keyword=(const char *) attributes[i++];
4241 attribute=InterpretImageProperties(msl_info->image_info[n],
4242 msl_info->attributes[n],(const char *) attributes[i]);
4243 CloneString(&value,attribute);
4249 if (LocaleCompare(keyword,"output") == 0)
4251 (void) fprintf(stdout,"%s",value);
4254 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4266 if (LocaleCompare((const char *) tag, "profile") == 0)
4271 if (msl_info->image[n] == (Image *) NULL)
4273 ThrowMSLException(OptionError,"NoImagesDefined",
4274 (const char *) tag);
4277 if (attributes == (const xmlChar **) NULL)
4279 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4293 keyword=(const char *) attributes[i++];
4294 attribute=InterpretImageProperties(msl_info->image_info[n],
4295 msl_info->attributes[n],(const char *) attributes[i]);
4296 CloneString(&value,attribute);
4297 if (*keyword == '+')
4300 Remove a profile from the image.
4302 (void) ProfileImage(msl_info->image[n],keyword,
4303 (const unsigned char *) NULL,0,MagickTrue);
4307 Associate a profile with the image.
4309 profile_info=CloneImageInfo(msl_info->image_info[n]);
4310 profile=GetImageProfile(msl_info->image[n],"iptc");
4311 if (profile != (StringInfo *) NULL)
4312 profile_info->profile=(void *) CloneStringInfo(profile);
4313 profile_image=GetImageCache(profile_info,keyword,&exception);
4314 profile_info=DestroyImageInfo(profile_info);
4315 if (profile_image == (Image *) NULL)
4318 name[MaxTextExtent],
4319 filename[MaxTextExtent];
4327 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4328 (void) CopyMagickString(name,keyword,MaxTextExtent);
4329 for (p=filename; *p != '\0'; p++)
4330 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4331 (IsPathAccessible(keyword) == MagickFalse))
4337 Look for profile name (e.g. name:profile).
4339 (void) CopyMagickString(name,filename,(size_t)
4341 for (q=filename; *q != '\0'; q++)
4345 profile=FileToStringInfo(filename,~0UL,&exception);
4346 if (profile != (StringInfo *) NULL)
4348 (void) ProfileImage(msl_info->image[n],name,
4349 GetStringInfoDatum(profile),(unsigned long)
4350 GetStringInfoLength(profile),MagickFalse);
4351 profile=DestroyStringInfo(profile);
4355 ResetImageProfileIterator(profile_image);
4356 name=GetNextImageProfile(profile_image);
4357 while (name != (const char *) NULL)
4359 profile=GetImageProfile(profile_image,name);
4360 if (profile != (StringInfo *) NULL)
4361 (void) ProfileImage(msl_info->image[n],name,
4362 GetStringInfoDatum(profile),(unsigned long)
4363 GetStringInfoLength(profile),MagickFalse);
4364 name=GetNextImageProfile(profile_image);
4366 profile_image=DestroyImage(profile_image);
4370 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4375 if (LocaleCompare((const char *) tag,"quantize") == 0)
4383 if (msl_info->image[n] == (Image *) NULL)
4385 ThrowMSLException(OptionError,"NoImagesDefined",
4386 (const char *) tag);
4389 GetQuantizeInfo(&quantize_info);
4390 if (attributes != (const xmlChar **) NULL)
4391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4393 keyword=(const char *) attributes[i++];
4394 attribute=InterpretImageProperties(msl_info->image_info[n],
4395 msl_info->attributes[n],(const char *) attributes[i]);
4396 CloneString(&value,attribute);
4402 if (LocaleCompare(keyword,"colors") == 0)
4404 quantize_info.number_colors=atol(value);
4407 if (LocaleCompare(keyword,"colorspace") == 0)
4409 option=ParseMagickOption(MagickColorspaceOptions,
4412 ThrowMSLException(OptionError,
4413 "UnrecognizedColorspaceType",value);
4414 quantize_info.colorspace=(ColorspaceType) option;
4417 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4424 if (LocaleCompare(keyword,"dither") == 0)
4426 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4429 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4431 quantize_info.dither=(MagickBooleanType) option;
4434 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4441 if (LocaleCompare(keyword,"measure") == 0)
4443 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4446 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4448 quantize_info.measure_error=(MagickBooleanType) option;
4451 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4458 if (LocaleCompare(keyword,"treedepth") == 0)
4460 quantize_info.tree_depth=atol(value);
4463 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4469 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4475 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4478 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4481 text[MaxTextExtent];
4492 draw_info=CloneDrawInfo(msl_info->image_info[n],
4493 msl_info->draw_info[n]);
4495 current=draw_info->affine;
4496 GetAffineMatrix(&affine);
4497 if (attributes != (const xmlChar **) NULL)
4498 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4500 keyword=(const char *) attributes[i++];
4501 attribute=InterpretImageProperties(msl_info->image_info[n],
4502 msl_info->attributes[n],(const char *) attributes[i]);
4503 CloneString(&value,attribute);
4509 if (LocaleCompare(keyword,"affine") == 0)
4515 draw_info->affine.sx=strtod(p,&p);
4518 draw_info->affine.rx=strtod(p,&p);
4521 draw_info->affine.ry=strtod(p,&p);
4524 draw_info->affine.sy=strtod(p,&p);
4527 draw_info->affine.tx=strtod(p,&p);
4530 draw_info->affine.ty=strtod(p,&p);
4533 if (LocaleCompare(keyword,"align") == 0)
4535 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
4538 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4540 draw_info->align=(AlignType) option;
4543 if (LocaleCompare(keyword,"antialias") == 0)
4545 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4548 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4550 draw_info->stroke_antialias=(MagickBooleanType) option;
4551 draw_info->text_antialias=(MagickBooleanType) option;
4554 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4561 if (LocaleCompare(keyword,"density") == 0)
4563 CloneString(&draw_info->density,value);
4566 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4573 if (LocaleCompare(keyword,"encoding") == 0)
4575 CloneString(&draw_info->encoding,value);
4578 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4585 if (LocaleCompare(keyword, "fill") == 0)
4587 (void) QueryColorDatabase(value,&draw_info->fill,
4591 if (LocaleCompare(keyword,"family") == 0)
4593 CloneString(&draw_info->family,value);
4596 if (LocaleCompare(keyword,"font") == 0)
4598 CloneString(&draw_info->font,value);
4601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4608 if (LocaleCompare(keyword,"geometry") == 0)
4610 flags=ParsePageGeometry(msl_info->image[n],value,
4611 &geometry,&exception);
4612 if ((flags & HeightValue) == 0)
4613 geometry.height=geometry.width;
4616 if (LocaleCompare(keyword,"gravity") == 0)
4618 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
4621 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4623 draw_info->gravity=(GravityType) option;
4626 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4633 if (LocaleCompare(keyword,"pointsize") == 0)
4635 draw_info->pointsize=atof(value);
4638 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4645 if (LocaleCompare(keyword,"rotate") == 0)
4648 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4649 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4650 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4651 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4661 if (LocaleCompare(keyword,"scale") == 0)
4663 flags=ParseGeometry(value,&geometry_info);
4664 if ((flags & SigmaValue) == 0)
4665 geometry_info.sigma=1.0;
4666 affine.sx=geometry_info.rho;
4667 affine.sy=geometry_info.sigma;
4670 if (LocaleCompare(keyword,"skewX") == 0)
4673 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4676 if (LocaleCompare(keyword,"skewY") == 0)
4679 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4682 if (LocaleCompare(keyword,"stretch") == 0)
4684 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
4687 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4689 draw_info->stretch=(StretchType) option;
4692 if (LocaleCompare(keyword, "stroke") == 0)
4694 (void) QueryColorDatabase(value,&draw_info->stroke,
4698 if (LocaleCompare(keyword,"strokewidth") == 0)
4700 draw_info->stroke_width=atol(value);
4703 if (LocaleCompare(keyword,"style") == 0)
4705 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
4708 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4710 draw_info->style=(StyleType) option;
4713 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4720 if (LocaleCompare(keyword,"text") == 0)
4722 CloneString(&draw_info->text,value);
4725 if (LocaleCompare(keyword,"translate") == 0)
4727 flags=ParseGeometry(value,&geometry_info);
4728 if ((flags & SigmaValue) == 0)
4729 geometry_info.sigma=1.0;
4730 affine.tx=geometry_info.rho;
4731 affine.ty=geometry_info.sigma;
4734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4741 if (LocaleCompare(keyword, "undercolor") == 0)
4743 (void) QueryColorDatabase(value,&draw_info->undercolor,
4747 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4754 if (LocaleCompare(keyword,"weight") == 0)
4756 draw_info->weight=atol(value);
4759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4766 if (LocaleCompare(keyword,"x") == 0)
4768 geometry.x=atol(value);
4771 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4778 if (LocaleCompare(keyword,"y") == 0)
4780 geometry.y=atol(value);
4783 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4789 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4795 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
4796 geometry.width,geometry.height,geometry.x,geometry.y);
4797 CloneString(&draw_info->geometry,text);
4798 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
4799 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
4800 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
4801 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
4802 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
4804 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
4806 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4807 if (status != MagickFalse)
4812 image=msl_info->attributes[n];
4813 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x","%g",
4814 metrics.pixels_per_em.x);
4815 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y","%g",
4816 metrics.pixels_per_em.y);
4817 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4819 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4821 FormatImageProperty(image,"msl:font-metrics.width","%g",
4823 FormatImageProperty(image,"msl:font-metrics.height","%g",
4825 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4826 metrics.max_advance);
4827 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4829 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4831 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4833 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4835 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4837 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4840 draw_info=DestroyDrawInfo(draw_info);
4843 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4848 if (LocaleCompare((const char *) tag,"raise") == 0)
4856 if (msl_info->image[n] == (Image *) NULL)
4858 ThrowMSLException(OptionError,"NoImagesDefined",
4859 (const char *) tag);
4863 SetGeometry(msl_info->image[n],&geometry);
4864 if (attributes != (const xmlChar **) NULL)
4865 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4867 keyword=(const char *) attributes[i++];
4868 attribute=InterpretImageProperties(msl_info->image_info[n],
4869 msl_info->attributes[n],(const char *) attributes[i]);
4870 CloneString(&value,attribute);
4876 if (LocaleCompare(keyword,"geometry") == 0)
4878 flags=ParsePageGeometry(msl_info->image[n],value,
4879 &geometry,&exception);
4880 if ((flags & HeightValue) == 0)
4881 geometry.height=geometry.width;
4884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4891 if (LocaleCompare(keyword,"height") == 0)
4893 geometry.height=atol(value);
4896 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4903 if (LocaleCompare(keyword,"raise") == 0)
4905 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4908 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4910 raise=(MagickBooleanType) option;
4913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4920 if (LocaleCompare(keyword,"width") == 0)
4922 geometry.width=atol(value);
4925 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4931 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4937 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4940 if (LocaleCompare((const char *) tag,"read") == 0)
4942 if (attributes == (const xmlChar **) NULL)
4944 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4946 keyword=(const char *) attributes[i++];
4947 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4948 msl_info->attributes[n],(const char *) attributes[i]));
4954 if (LocaleCompare(keyword,"filename") == 0)
4959 (void) CopyMagickString(msl_info->image_info[n]->filename,
4960 value,MaxTextExtent);
4961 image=ReadImage(msl_info->image_info[n],&exception);
4962 CatchException(&exception);
4963 if (image == (Image *) NULL)
4965 AppendImageToList(&msl_info->image[n],image);
4968 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4974 if (LocaleCompare(keyword,"gravity") == 0)
4976 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
4979 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4981 (void) SetImageOption(msl_info->image_info[n],keyword,
4985 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4991 if (LocaleCompare(keyword,"pointsize") == 0)
4993 msl_info->image_info[n]->pointsize=atof(value);
4996 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5002 if (LocaleCompare(keyword,"size") == 0)
5004 msl_info->image_info[n]->size=AcquireString(value);
5007 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5012 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5019 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5027 if (msl_info->image[n] == (Image *) NULL)
5029 ThrowMSLException(OptionError,"NoImagesDefined",
5030 (const char *) tag);
5033 if (attributes != (const xmlChar **) NULL)
5034 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5036 keyword=(const char *) attributes[i++];
5037 attribute=InterpretImageProperties(msl_info->image_info[n],
5038 msl_info->attributes[n],(const char *) attributes[i]);
5039 CloneString(&value,attribute);
5045 if (LocaleCompare(keyword,"geometry") == 0)
5047 flags=ParseGeometry(value,&geometry_info);
5048 if ((flags & SigmaValue) == 0)
5049 geometry_info.sigma=1.0;
5052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5059 if (LocaleCompare(keyword,"radius") == 0)
5061 geometry_info.rho=atof(value);
5064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5076 paint_image=ReduceNoiseImage(msl_info->image[n],geometry_info.rho,
5077 &msl_info->image[n]->exception);
5078 if (paint_image == (Image *) NULL)
5080 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5081 msl_info->image[n]=paint_image;
5084 else if (LocaleCompare((const char *) tag,"repage") == 0)
5086 /* init the values */
5087 width=msl_info->image[n]->page.width;
5088 height=msl_info->image[n]->page.height;
5089 x=msl_info->image[n]->page.x;
5090 y=msl_info->image[n]->page.y;
5092 if (msl_info->image[n] == (Image *) NULL)
5094 ThrowMSLException(OptionError,"NoImagesDefined",
5095 (const char *) tag);
5098 if (attributes == (const xmlChar **) NULL)
5100 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5102 keyword=(const char *) attributes[i++];
5103 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5104 msl_info->attributes[n],(const char *) attributes[i]));
5110 if (LocaleCompare(keyword,"geometry") == 0)
5118 flags=ParseAbsoluteGeometry(value,&geometry);
5119 if ((flags & WidthValue) != 0)
5121 if ((flags & HeightValue) == 0)
5122 geometry.height=geometry.width;
5123 width=geometry.width;
5124 height=geometry.height;
5126 if ((flags & AspectValue) != 0)
5128 if ((flags & XValue) != 0)
5130 if ((flags & YValue) != 0)
5135 if ((flags & XValue) != 0)
5138 if ((width == 0) && (geometry.x > 0))
5139 width=msl_info->image[n]->columns+geometry.x;
5141 if ((flags & YValue) != 0)
5144 if ((height == 0) && (geometry.y > 0))
5145 height=msl_info->image[n]->rows+geometry.y;
5150 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5156 if (LocaleCompare(keyword,"height") == 0)
5158 height = atol( value );
5161 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5167 if (LocaleCompare(keyword,"width") == 0)
5169 width = atol( value );
5172 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5178 if (LocaleCompare(keyword,"x") == 0)
5183 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5189 if (LocaleCompare(keyword,"y") == 0)
5194 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5199 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5205 msl_info->image[n]->page.width=width;
5206 msl_info->image[n]->page.height=height;
5207 msl_info->image[n]->page.x=x;
5208 msl_info->image[n]->page.y=y;
5211 else if (LocaleCompare((const char *) tag,"resample") == 0)
5217 if (msl_info->image[n] == (Image *) NULL)
5219 ThrowMSLException(OptionError,"NoImagesDefined",
5220 (const char *) tag);
5223 if (attributes == (const xmlChar **) NULL)
5225 x_resolution=DefaultResolution;
5226 y_resolution=DefaultResolution;
5227 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5229 keyword=(const char *) attributes[i++];
5230 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5231 msl_info->attributes[n],(const char *) attributes[i]));
5236 if (LocaleCompare(keyword,"blur") == 0)
5238 msl_info->image[n]->blur=atof(value);
5241 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5247 if (LocaleCompare(keyword,"geometry") == 0)
5252 flags=ParseGeometry(value,&geometry_info);
5253 if ((flags & SigmaValue) == 0)
5254 geometry_info.sigma*=geometry_info.rho;
5255 x_resolution=geometry_info.rho;
5256 y_resolution=geometry_info.sigma;
5259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5265 if (LocaleCompare(keyword,"x-resolution") == 0)
5267 x_resolution=atof(value);
5270 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5276 if (LocaleCompare(keyword,"y-resolution") == 0)
5278 y_resolution=atof(value);
5281 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5286 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5302 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5304 width=(unsigned long) (x_resolution*msl_info->image[n]->columns/
5305 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5306 msl_info->image[n]->x_resolution))+0.5);
5307 height=(unsigned long) (y_resolution*msl_info->image[n]->rows/
5308 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5309 msl_info->image[n]->y_resolution))+0.5);
5310 resample_image=ResizeImage(msl_info->image[n],width,height,
5311 msl_info->image[n]->filter,msl_info->image[n]->blur,
5312 &msl_info->image[n]->exception);
5313 if (resample_image == (Image *) NULL)
5315 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5316 msl_info->image[n]=resample_image;
5320 if (LocaleCompare((const char *) tag,"resize") == 0)
5334 if (msl_info->image[n] == (Image *) NULL)
5336 ThrowMSLException(OptionError,"NoImagesDefined",
5337 (const char *) tag);
5340 filter=UndefinedFilter;
5342 if (attributes != (const xmlChar **) NULL)
5343 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5345 keyword=(const char *) attributes[i++];
5346 attribute=InterpretImageProperties(msl_info->image_info[n],
5347 msl_info->attributes[n],(const char *) attributes[i]);
5348 CloneString(&value,attribute);
5354 if (LocaleCompare(keyword,"filter") == 0)
5356 option=ParseMagickOption(MagickFilterOptions,MagickFalse,
5359 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5361 filter=(FilterTypes) option;
5364 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5371 if (LocaleCompare(keyword,"geometry") == 0)
5373 flags=ParseRegionGeometry(msl_info->image[n],value,
5374 &geometry,&exception);
5377 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5384 if (LocaleCompare(keyword,"height") == 0)
5386 geometry.height=(unsigned long) atol(value);
5389 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5396 if (LocaleCompare(keyword,"support") == 0)
5401 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5408 if (LocaleCompare(keyword,"width") == 0)
5410 geometry.width=atol(value);
5413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5425 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5426 geometry.height,filter,blur,&msl_info->image[n]->exception);
5427 if (resize_image == (Image *) NULL)
5429 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5430 msl_info->image[n]=resize_image;
5433 if (LocaleCompare((const char *) tag,"roll") == 0)
5441 if (msl_info->image[n] == (Image *) NULL)
5443 ThrowMSLException(OptionError,"NoImagesDefined",
5444 (const char *) tag);
5447 SetGeometry(msl_info->image[n],&geometry);
5448 if (attributes != (const xmlChar **) NULL)
5449 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5451 keyword=(const char *) attributes[i++];
5452 attribute=InterpretImageProperties(msl_info->image_info[n],
5453 msl_info->attributes[n],(const char *) attributes[i]);
5454 CloneString(&value,attribute);
5460 if (LocaleCompare(keyword,"geometry") == 0)
5462 flags=ParsePageGeometry(msl_info->image[n],value,
5463 &geometry,&exception);
5464 if ((flags & HeightValue) == 0)
5465 geometry.height=geometry.width;
5468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5475 if (LocaleCompare(keyword,"x") == 0)
5477 geometry.x=atol(value);
5480 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5487 if (LocaleCompare(keyword,"y") == 0)
5489 geometry.y=atol(value);
5492 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5498 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5504 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5505 &msl_info->image[n]->exception);
5506 if (roll_image == (Image *) NULL)
5508 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5509 msl_info->image[n]=roll_image;
5512 else if (LocaleCompare((const char *) tag,"roll") == 0)
5514 /* init the values */
5515 width=msl_info->image[n]->columns;
5516 height=msl_info->image[n]->rows;
5519 if (msl_info->image[n] == (Image *) NULL)
5521 ThrowMSLException(OptionError,"NoImagesDefined",
5522 (const char *) tag);
5525 if (attributes == (const xmlChar **) NULL)
5527 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5529 keyword=(const char *) attributes[i++];
5530 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5531 msl_info->attributes[n],(const char *) attributes[i]));
5537 if (LocaleCompare(keyword,"geometry") == 0)
5539 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5542 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5548 if (LocaleCompare(keyword,"x") == 0)
5553 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5559 if (LocaleCompare(keyword,"y") == 0)
5564 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5569 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5582 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5583 if (newImage == (Image *) NULL)
5585 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5586 msl_info->image[n]=newImage;
5591 if (LocaleCompare((const char *) tag,"rotate") == 0)
5599 if (msl_info->image[n] == (Image *) NULL)
5601 ThrowMSLException(OptionError,"NoImagesDefined",
5602 (const char *) tag);
5605 if (attributes != (const xmlChar **) NULL)
5606 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5608 keyword=(const char *) attributes[i++];
5609 attribute=InterpretImageProperties(msl_info->image_info[n],
5610 msl_info->attributes[n],(const char *) attributes[i]);
5611 CloneString(&value,attribute);
5617 if (LocaleCompare(keyword,"degrees") == 0)
5619 geometry_info.rho=atof(value);
5622 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5629 if (LocaleCompare(keyword,"geometry") == 0)
5631 flags=ParseGeometry(value,&geometry_info);
5632 if ((flags & SigmaValue) == 0)
5633 geometry_info.sigma=1.0;
5636 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5648 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5649 &msl_info->image[n]->exception);
5650 if (rotate_image == (Image *) NULL)
5652 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5653 msl_info->image[n]=rotate_image;
5656 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5658 /* init the values */
5661 if (msl_info->image[n] == (Image *) NULL)
5663 ThrowMSLException(OptionError,"NoImagesDefined",
5664 (const char *) tag);
5667 if (attributes == (const xmlChar **) NULL)
5669 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5671 keyword=(const char *) attributes[i++];
5672 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5673 msl_info->attributes[n],(const char *) attributes[i]));
5679 if (LocaleCompare(keyword,"degrees") == 0)
5681 degrees = atof( value );
5684 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5689 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5702 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5703 if (newImage == (Image *) NULL)
5705 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5706 msl_info->image[n]=newImage;
5711 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5716 if (LocaleCompare((const char *) tag,"sample") == 0)
5724 if (msl_info->image[n] == (Image *) NULL)
5726 ThrowMSLException(OptionError,"NoImagesDefined",
5727 (const char *) tag);
5730 if (attributes != (const xmlChar **) NULL)
5731 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5733 keyword=(const char *) attributes[i++];
5734 attribute=InterpretImageProperties(msl_info->image_info[n],
5735 msl_info->attributes[n],(const char *) attributes[i]);
5736 CloneString(&value,attribute);
5742 if (LocaleCompare(keyword,"geometry") == 0)
5744 flags=ParseRegionGeometry(msl_info->image[n],value,
5745 &geometry,&exception);
5748 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5755 if (LocaleCompare(keyword,"height") == 0)
5757 geometry.height=(unsigned long) atol(value);
5760 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5767 if (LocaleCompare(keyword,"width") == 0)
5769 geometry.width=atol(value);
5772 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5778 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5784 sample_image=SampleImage(msl_info->image[n],geometry.width,
5785 geometry.height,&msl_info->image[n]->exception);
5786 if (sample_image == (Image *) NULL)
5788 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5789 msl_info->image[n]=sample_image;
5792 if (LocaleCompare((const char *) tag,"scale") == 0)
5800 if (msl_info->image[n] == (Image *) NULL)
5802 ThrowMSLException(OptionError,"NoImagesDefined",
5803 (const char *) tag);
5806 if (attributes != (const xmlChar **) NULL)
5807 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5809 keyword=(const char *) attributes[i++];
5810 attribute=InterpretImageProperties(msl_info->image_info[n],
5811 msl_info->attributes[n],(const char *) attributes[i]);
5812 CloneString(&value,attribute);
5818 if (LocaleCompare(keyword,"geometry") == 0)
5820 flags=ParseRegionGeometry(msl_info->image[n],value,
5821 &geometry,&exception);
5824 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5831 if (LocaleCompare(keyword,"height") == 0)
5833 geometry.height=(unsigned long) atol(value);
5836 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5843 if (LocaleCompare(keyword,"width") == 0)
5845 geometry.width=atol(value);
5848 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5860 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5861 geometry.height,&msl_info->image[n]->exception);
5862 if (scale_image == (Image *) NULL)
5864 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5865 msl_info->image[n]=scale_image;
5868 if (LocaleCompare((const char *) tag,"segment") == 0)
5879 if (msl_info->image[n] == (Image *) NULL)
5881 ThrowMSLException(OptionError,"NoImagesDefined",
5882 (const char *) tag);
5885 geometry_info.rho=1.0;
5886 geometry_info.sigma=1.5;
5887 colorspace=RGBColorspace;
5888 verbose=MagickFalse;
5889 if (attributes != (const xmlChar **) NULL)
5890 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5892 keyword=(const char *) attributes[i++];
5893 attribute=InterpretImageProperties(msl_info->image_info[n],
5894 msl_info->attributes[n],(const char *) attributes[i]);
5895 CloneString(&value,attribute);
5901 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5903 geometry_info.rho=atof(value);
5906 if (LocaleCompare(keyword,"colorspace") == 0)
5908 option=ParseMagickOption(MagickColorspaceOptions,
5911 ThrowMSLException(OptionError,
5912 "UnrecognizedColorspaceType",value);
5913 colorspace=(ColorspaceType) option;
5916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5923 if (LocaleCompare(keyword,"geometry") == 0)
5925 flags=ParseGeometry(value,&geometry_info);
5926 if ((flags & SigmaValue) == 0)
5927 geometry_info.sigma=1.5;
5930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5937 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5939 geometry_info.sigma=atof(value);
5942 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5954 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5955 geometry_info.rho,geometry_info.sigma);
5958 else if (LocaleCompare((const char *) tag, "set") == 0)
5960 if (msl_info->image[n] == (Image *) NULL)
5962 ThrowMSLException(OptionError,"NoImagesDefined",
5963 (const char *) tag);
5967 if (attributes == (const xmlChar **) NULL)
5969 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5971 keyword=(const char *) attributes[i++];
5972 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5973 msl_info->attributes[n],(const char *) attributes[i]));
5979 if (LocaleCompare(keyword,"clip-mask") == 0)
5981 for (j=0; j < msl_info->n; j++)
5986 property=GetImageProperty(msl_info->attributes[j],"id");
5987 if (LocaleCompare(property,value) == 0)
5989 SetImageMask(msl_info->image[n],msl_info->image[j]);
5995 if (LocaleCompare(keyword,"clip-path") == 0)
5997 for (j=0; j < msl_info->n; j++)
6002 property=GetImageProperty(msl_info->attributes[j],"id");
6003 if (LocaleCompare(property,value) == 0)
6005 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
6011 if (LocaleCompare(keyword,"colorspace") == 0)
6016 colorspace=(ColorspaceType) ParseMagickOption(
6017 MagickColorspaceOptions,MagickFalse,keyword);
6019 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6021 (void) TransformImageColorspace(msl_info->image[n],
6022 (ColorspaceType) colorspace);
6025 (void) SetMSLAttributes(msl_info,keyword,value);
6031 if (LocaleCompare(keyword,"density") == 0)
6033 flags=ParseGeometry(value,&geometry_info);
6034 msl_info->image[n]->x_resolution=geometry_info.rho;
6035 msl_info->image[n]->y_resolution=geometry_info.sigma;
6036 if ((flags & SigmaValue) == 0)
6037 msl_info->image[n]->y_resolution=
6038 msl_info->image[n]->x_resolution;
6041 (void) SetMSLAttributes(msl_info,keyword,value);
6047 if (LocaleCompare(keyword, "opacity") == 0)
6049 long opac = OpaqueOpacity,
6050 len = (long) strlen( value );
6052 if (value[len-1] == '%') {
6054 (void) CopyMagickString(tmp,value,len);
6056 opac = (int)(QuantumRange * ((float)opac/100));
6058 opac = atol( value );
6059 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6062 (void) SetMSLAttributes(msl_info,keyword,value);
6068 if (LocaleCompare(keyword, "page") == 0)
6071 page[MaxTextExtent];
6082 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6083 image_option=GetImageOption(msl_info->image_info[n],"page");
6084 if (image_option != (const char *) NULL)
6085 flags=ParseAbsoluteGeometry(image_option,&geometry);
6086 flags=ParseAbsoluteGeometry(value,&geometry);
6087 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
6088 geometry.width,geometry.height);
6089 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6090 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6091 geometry.width,geometry.height,geometry.x,geometry.y);
6092 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6093 msl_info->image_info[n]->page=GetPageGeometry(page);
6096 (void) SetMSLAttributes(msl_info,keyword,value);
6101 (void) SetMSLAttributes(msl_info,keyword,value);
6108 if (LocaleCompare((const char *) tag,"shade") == 0)
6119 if (msl_info->image[n] == (Image *) NULL)
6121 ThrowMSLException(OptionError,"NoImagesDefined",
6122 (const char *) tag);
6126 if (attributes != (const xmlChar **) NULL)
6127 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6129 keyword=(const char *) attributes[i++];
6130 attribute=InterpretImageProperties(msl_info->image_info[n],
6131 msl_info->attributes[n],(const char *) attributes[i]);
6132 CloneString(&value,attribute);
6138 if (LocaleCompare(keyword,"azimuth") == 0)
6140 geometry_info.rho=atof(value);
6143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6150 if (LocaleCompare(keyword,"elevation") == 0)
6152 geometry_info.sigma=atof(value);
6155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6162 if (LocaleCompare(keyword,"geometry") == 0)
6164 flags=ParseGeometry(value,&geometry_info);
6165 if ((flags & SigmaValue) == 0)
6166 geometry_info.sigma=1.0;
6169 if (LocaleCompare(keyword,"gray") == 0)
6171 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6174 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6176 gray=(MagickBooleanType) option;
6179 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6191 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6192 geometry_info.sigma,&msl_info->image[n]->exception);
6193 if (shade_image == (Image *) NULL)
6195 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6196 msl_info->image[n]=shade_image;
6199 if (LocaleCompare((const char *) tag,"shadow") == 0)
6207 if (msl_info->image[n] == (Image *) NULL)
6209 ThrowMSLException(OptionError,"NoImagesDefined",
6210 (const char *) tag);
6213 if (attributes != (const xmlChar **) NULL)
6214 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6216 keyword=(const char *) attributes[i++];
6217 attribute=InterpretImageProperties(msl_info->image_info[n],
6218 msl_info->attributes[n],(const char *) attributes[i]);
6219 CloneString(&value,attribute);
6225 if (LocaleCompare(keyword,"geometry") == 0)
6227 flags=ParseGeometry(value,&geometry_info);
6228 if ((flags & SigmaValue) == 0)
6229 geometry_info.sigma=1.0;
6232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6239 if (LocaleCompare(keyword,"opacity") == 0)
6241 geometry_info.rho=atol(value);
6244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6251 if (LocaleCompare(keyword,"sigma") == 0)
6253 geometry_info.sigma=atol(value);
6261 if (LocaleCompare(keyword,"x") == 0)
6263 geometry_info.xi=atof(value);
6266 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6273 if (LocaleCompare(keyword,"y") == 0)
6275 geometry_info.psi=atol(value);
6278 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6284 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6290 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6291 geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
6292 (geometry_info.psi+0.5),&msl_info->image[n]->exception);
6293 if (shadow_image == (Image *) NULL)
6295 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6296 msl_info->image[n]=shadow_image;
6299 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6301 double radius = 0.0,
6304 if (msl_info->image[n] == (Image *) NULL)
6306 ThrowMSLException(OptionError,"NoImagesDefined",
6307 (const char *) tag);
6311 NOTE: sharpen can have no attributes, since we use all the defaults!
6313 if (attributes != (const xmlChar **) NULL)
6315 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6317 keyword=(const char *) attributes[i++];
6318 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6319 msl_info->attributes[n],(const char *) attributes[i]));
6325 if (LocaleCompare(keyword, "radius") == 0)
6327 radius = atof( value );
6330 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6336 if (LocaleCompare(keyword,"sigma") == 0)
6338 sigma = atol( value );
6341 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6346 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6360 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6361 if (newImage == (Image *) NULL)
6363 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6364 msl_info->image[n]=newImage;
6368 else if (LocaleCompare((const char *) tag,"shave") == 0)
6370 /* init the values */
6374 if (msl_info->image[n] == (Image *) NULL)
6376 ThrowMSLException(OptionError,"NoImagesDefined",
6377 (const char *) tag);
6380 if (attributes == (const xmlChar **) NULL)
6382 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6384 keyword=(const char *) attributes[i++];
6385 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6386 msl_info->attributes[n],(const char *) attributes[i]));
6392 if (LocaleCompare(keyword,"geometry") == 0)
6394 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6397 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6403 if (LocaleCompare(keyword,"height") == 0)
6405 height = atol( value );
6408 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6414 if (LocaleCompare(keyword,"width") == 0)
6416 width = atol( value );
6419 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6424 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6439 rectInfo.height = height;
6440 rectInfo.width = width;
6445 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6446 &msl_info->image[n]->exception);
6447 if (newImage == (Image *) NULL)
6449 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6450 msl_info->image[n]=newImage;
6455 if (LocaleCompare((const char *) tag,"shear") == 0)
6463 if (msl_info->image[n] == (Image *) NULL)
6465 ThrowMSLException(OptionError,"NoImagesDefined",
6466 (const char *) tag);
6469 if (attributes != (const xmlChar **) NULL)
6470 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6472 keyword=(const char *) attributes[i++];
6473 attribute=InterpretImageProperties(msl_info->image_info[n],
6474 msl_info->attributes[n],(const char *) attributes[i]);
6475 CloneString(&value,attribute);
6481 if (LocaleCompare(keyword, "fill") == 0)
6483 (void) QueryColorDatabase(value,
6484 &msl_info->image[n]->background_color,&exception);
6487 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6494 if (LocaleCompare(keyword,"geometry") == 0)
6496 flags=ParseGeometry(value,&geometry_info);
6497 if ((flags & SigmaValue) == 0)
6498 geometry_info.sigma=1.0;
6501 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6508 if (LocaleCompare(keyword,"x") == 0)
6510 geometry_info.rho=atof(value);
6513 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6520 if (LocaleCompare(keyword,"y") == 0)
6522 geometry_info.sigma=atol(value);
6525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6531 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6537 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6538 geometry_info.sigma,&msl_info->image[n]->exception);
6539 if (shear_image == (Image *) NULL)
6541 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6542 msl_info->image[n]=shear_image;
6545 if (LocaleCompare((const char *) tag,"signature") == 0)
6550 if (msl_info->image[n] == (Image *) NULL)
6552 ThrowMSLException(OptionError,"NoImagesDefined",
6553 (const char *) tag);
6556 if (attributes != (const xmlChar **) NULL)
6557 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6559 keyword=(const char *) attributes[i++];
6560 attribute=InterpretImageProperties(msl_info->image_info[n],
6561 msl_info->attributes[n],(const char *) attributes[i]);
6562 CloneString(&value,attribute);
6567 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6573 (void) SignatureImage(msl_info->image[n]);
6576 if (LocaleCompare((const char *) tag,"solarize") == 0)
6581 if (msl_info->image[n] == (Image *) NULL)
6583 ThrowMSLException(OptionError,"NoImagesDefined",
6584 (const char *) tag);
6587 geometry_info.rho=QuantumRange/2.0;
6588 if (attributes != (const xmlChar **) NULL)
6589 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6591 keyword=(const char *) attributes[i++];
6592 attribute=InterpretImageProperties(msl_info->image_info[n],
6593 msl_info->attributes[n],(const char *) attributes[i]);
6594 CloneString(&value,attribute);
6600 if (LocaleCompare(keyword,"geometry") == 0)
6602 flags=ParseGeometry(value,&geometry_info);
6605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6612 if (LocaleCompare(keyword,"threshold") == 0)
6614 geometry_info.rho=atof(value);
6617 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6629 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6632 if (LocaleCompare((const char *) tag,"spread") == 0)
6640 if (msl_info->image[n] == (Image *) NULL)
6642 ThrowMSLException(OptionError,"NoImagesDefined",
6643 (const char *) tag);
6646 if (attributes != (const xmlChar **) NULL)
6647 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6649 keyword=(const char *) attributes[i++];
6650 attribute=InterpretImageProperties(msl_info->image_info[n],
6651 msl_info->attributes[n],(const char *) attributes[i]);
6652 CloneString(&value,attribute);
6658 if (LocaleCompare(keyword,"geometry") == 0)
6660 flags=ParseGeometry(value,&geometry_info);
6661 if ((flags & SigmaValue) == 0)
6662 geometry_info.sigma=1.0;
6665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6672 if (LocaleCompare(keyword,"radius") == 0)
6674 geometry_info.rho=atof(value);
6677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6689 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6690 &msl_info->image[n]->exception);
6691 if (spread_image == (Image *) NULL)
6693 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6694 msl_info->image[n]=spread_image;
6697 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6700 watermark = (Image*)NULL;
6702 if (msl_info->image[n] == (Image *) NULL)
6704 ThrowMSLException(OptionError,"NoImagesDefined",
6705 (const char *) tag);
6708 if (attributes == (const xmlChar **) NULL)
6710 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6712 keyword=(const char *) attributes[i++];
6713 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6714 msl_info->attributes[n],(const char *) attributes[i]));
6720 if (LocaleCompare(keyword,"image") == 0)
6722 for (j=0; j<msl_info->n;j++)
6725 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6726 if (theAttr && LocaleCompare(theAttr, value) == 0)
6728 watermark = msl_info->image[j];
6734 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6739 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6748 if ( watermark != (Image*) NULL )
6753 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6754 if (newImage == (Image *) NULL)
6756 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6757 msl_info->image[n]=newImage;
6760 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6762 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6765 stereoImage = (Image*)NULL;
6767 if (msl_info->image[n] == (Image *) NULL)
6769 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6772 if (attributes == (const xmlChar **) NULL)
6774 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6776 keyword=(const char *) attributes[i++];
6777 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6778 msl_info->attributes[n],(const char *) attributes[i]));
6784 if (LocaleCompare(keyword,"image") == 0)
6786 for (j=0; j<msl_info->n;j++)
6789 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6790 if (theAttr && LocaleCompare(theAttr, value) == 0)
6792 stereoImage = msl_info->image[j];
6798 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6803 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6812 if ( stereoImage != (Image*) NULL )
6817 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6818 if (newImage == (Image *) NULL)
6820 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6821 msl_info->image[n]=newImage;
6824 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6826 if (LocaleCompare((const char *) tag,"swap") == 0)
6837 if (msl_info->image[n] == (Image *) NULL)
6839 ThrowMSLException(OptionError,"NoImagesDefined",
6840 (const char *) tag);
6845 if (attributes != (const xmlChar **) NULL)
6846 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6848 keyword=(const char *) attributes[i++];
6849 attribute=InterpretImageProperties(msl_info->image_info[n],
6850 msl_info->attributes[n],(const char *) attributes[i]);
6851 CloneString(&value,attribute);
6857 if (LocaleCompare(keyword,"indexes") == 0)
6859 flags=ParseGeometry(value,&geometry_info);
6860 index=(long) geometry_info.rho;
6861 if ((flags & SigmaValue) == 0)
6862 swap_index=(long) geometry_info.sigma;
6865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6871 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6880 p=GetImageFromList(msl_info->image[n],index);
6881 q=GetImageFromList(msl_info->image[n],swap_index);
6882 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6884 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6887 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6888 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6889 ReplaceImageInList(&q,swap);
6890 msl_info->image[n]=GetFirstImageInList(q);
6893 if (LocaleCompare((const char *) tag,"swirl") == 0)
6901 if (msl_info->image[n] == (Image *) NULL)
6903 ThrowMSLException(OptionError,"NoImagesDefined",
6904 (const char *) tag);
6907 if (attributes != (const xmlChar **) NULL)
6908 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6910 keyword=(const char *) attributes[i++];
6911 attribute=InterpretImageProperties(msl_info->image_info[n],
6912 msl_info->attributes[n],(const char *) attributes[i]);
6913 CloneString(&value,attribute);
6919 if (LocaleCompare(keyword,"degrees") == 0)
6921 geometry_info.rho=atof(value);
6924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6931 if (LocaleCompare(keyword,"geometry") == 0)
6933 flags=ParseGeometry(value,&geometry_info);
6934 if ((flags & SigmaValue) == 0)
6935 geometry_info.sigma=1.0;
6938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6950 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6951 &msl_info->image[n]->exception);
6952 if (swirl_image == (Image *) NULL)
6954 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6955 msl_info->image[n]=swirl_image;
6958 if (LocaleCompare((const char *) tag,"sync") == 0)
6963 if (msl_info->image[n] == (Image *) NULL)
6965 ThrowMSLException(OptionError,"NoImagesDefined",
6966 (const char *) tag);
6969 if (attributes != (const xmlChar **) NULL)
6970 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6972 keyword=(const char *) attributes[i++];
6973 attribute=InterpretImageProperties(msl_info->image_info[n],
6974 msl_info->attributes[n],(const char *) attributes[i]);
6975 CloneString(&value,attribute);
6980 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6986 (void) SyncImage(msl_info->image[n]);
6989 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6994 if (LocaleCompare((const char *) tag,"map") == 0)
7002 if (msl_info->image[n] == (Image *) NULL)
7004 ThrowMSLException(OptionError,"NoImagesDefined",
7005 (const char *) tag);
7008 texture_image=NewImageList();
7009 if (attributes != (const xmlChar **) NULL)
7010 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7012 keyword=(const char *) attributes[i++];
7013 attribute=InterpretImageProperties(msl_info->image_info[n],
7014 msl_info->attributes[n],(const char *) attributes[i]);
7015 CloneString(&value,attribute);
7021 if (LocaleCompare(keyword,"image") == 0)
7022 for (j=0; j < msl_info->n; j++)
7027 attribute=GetImageProperty(msl_info->attributes[j],"id");
7028 if ((attribute != (const char *) NULL) &&
7029 (LocaleCompare(attribute,value) == 0))
7031 texture_image=CloneImage(msl_info->image[j],0,0,
7032 MagickFalse,&exception);
7040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7046 (void) TextureImage(msl_info->image[n],texture_image);
7047 texture_image=DestroyImage(texture_image);
7050 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7052 /* init the values */
7053 double threshold = 0;
7055 if (msl_info->image[n] == (Image *) NULL)
7057 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7060 if (attributes == (const xmlChar **) NULL)
7062 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7064 keyword=(const char *) attributes[i++];
7065 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7066 msl_info->attributes[n],(const char *) attributes[i]));
7072 if (LocaleCompare(keyword,"threshold") == 0)
7074 threshold = atof( value );
7077 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7082 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7092 BilevelImageChannel(msl_info->image[n],
7093 (ChannelType) ((long) (AllChannels &~ (long) OpacityChannel)),
7098 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7100 if (msl_info->image[n] == (Image *) NULL)
7102 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7105 if (attributes == (const xmlChar **) NULL)
7107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7109 keyword=(const char *) attributes[i++];
7110 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7111 msl_info->attributes[n],(const char *) attributes[i]));
7117 if (LocaleCompare(keyword,"color") == 0)
7122 (void) QueryMagickColor(value,&target,&exception);
7123 (void) TransparentPaintImage(msl_info->image[n],&target,
7124 TransparentOpacity,MagickFalse);
7127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7132 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7139 else if (LocaleCompare((const char *) tag, "trim") == 0)
7141 if (msl_info->image[n] == (Image *) NULL)
7143 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7147 /* no attributes here */
7149 /* process the image */
7156 /* all zeros on a crop == trim edges! */
7157 rectInfo.height = rectInfo.width = 0;
7158 rectInfo.x = rectInfo.y = 0;
7160 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7161 if (newImage == (Image *) NULL)
7163 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7164 msl_info->image[n]=newImage;
7168 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7173 if (LocaleCompare((const char *) tag,"write") == 0)
7175 if (msl_info->image[n] == (Image *) NULL)
7177 ThrowMSLException(OptionError,"NoImagesDefined",
7178 (const char *) tag);
7181 if (attributes == (const xmlChar **) NULL)
7183 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7185 keyword=(const char *) attributes[i++];
7186 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7187 msl_info->attributes[n],(const char *) attributes[i]));
7193 if (LocaleCompare(keyword,"filename") == 0)
7195 (void) CopyMagickString(msl_info->image[n]->filename,value,
7199 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7204 if (LocaleCompare(keyword,"quality") == 0)
7206 msl_info->image_info[n]->quality=atol(value);
7207 msl_info->image[n]->quality=
7208 msl_info->image_info[n]->quality;
7211 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7215 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7223 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7227 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7231 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7235 if ( value != NULL )
7236 value=DestroyString(value);
7237 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7240 static void MSLEndElement(void *context,const xmlChar *tag)
7249 Called when the end of an element has been detected.
7251 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7253 msl_info=(MSLInfo *) context;
7260 if (LocaleCompare((const char *) tag,"comment") == 0 )
7262 (void) DeleteImageProperty(msl_info->image[n],"comment");
7263 if (msl_info->content == (char *) NULL)
7265 StripString(msl_info->content);
7266 (void) SetImageProperty(msl_info->image[n],"comment",
7275 if (LocaleCompare((const char *) tag, "group") == 0 )
7277 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7280 (msl_info->group_info[msl_info->number_groups-1].numImages);
7283 if (msl_info->image[msl_info->n] != (Image *) NULL)
7284 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7285 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7286 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7290 msl_info->number_groups--;
7297 if (LocaleCompare((const char *) tag, "image") == 0)
7298 MSLPopImage(msl_info);
7304 if (LocaleCompare((const char *) tag,"label") == 0 )
7306 (void) DeleteImageProperty(msl_info->image[n],"label");
7307 if (msl_info->content == (char *) NULL)
7309 StripString(msl_info->content);
7310 (void) SetImageProperty(msl_info->image[n],"label",
7319 if (LocaleCompare((const char *) tag, "msl") == 0 )
7322 This our base element.
7323 at the moment we don't do anything special
7324 but someday we might!
7332 if (msl_info->content != (char *) NULL)
7333 msl_info->content=DestroyString(msl_info->content);
7336 static void MSLCharacters(void *context,const xmlChar *c,int length)
7348 Receiving some characters from the parser.
7350 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7351 " SAX.characters(%s,%d)",c,length);
7352 msl_info=(MSLInfo *) context;
7353 if (msl_info->content != (char *) NULL)
7354 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7355 strlen(msl_info->content)+length+MaxTextExtent,
7356 sizeof(*msl_info->content));
7359 msl_info->content=(char *) NULL;
7360 if (~length >= MaxTextExtent)
7361 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7362 sizeof(*msl_info->content));
7363 if (msl_info->content != (char *) NULL)
7364 *msl_info->content='\0';
7366 if (msl_info->content == (char *) NULL)
7368 p=msl_info->content+strlen(msl_info->content);
7369 for (i=0; i < length; i++)
7374 static void MSLReference(void *context,const xmlChar *name)
7383 Called when an entity reference is detected.
7385 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7386 " SAX.reference(%s)",name);
7387 msl_info=(MSLInfo *) context;
7388 parser=msl_info->parser;
7390 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7392 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7395 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7401 Receiving some ignorable whitespaces from the parser.
7403 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7404 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7405 msl_info=(MSLInfo *) context;
7408 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7409 const xmlChar *data)
7415 A processing instruction has been parsed.
7417 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7418 " SAX.processingInstruction(%s, %s)",
7420 msl_info=(MSLInfo *) context;
7423 static void MSLComment(void *context,const xmlChar *value)
7429 A comment has been parsed.
7431 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7432 " SAX.comment(%s)",value);
7433 msl_info=(MSLInfo *) context;
7436 static void MSLWarning(void *context,const char *format,...)
7440 reason[MaxTextExtent];
7449 Display and format a warning messages, gives file, line, position and
7452 va_start(operands,format);
7453 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7454 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7455 msl_info=(MSLInfo *) context;
7456 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7457 (void) vsprintf(reason,format,operands);
7459 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7461 message=GetExceptionMessage(errno);
7462 ThrowMSLException(CoderError,reason,message);
7463 message=DestroyString(message);
7467 static void MSLError(void *context,const char *format,...)
7470 reason[MaxTextExtent];
7479 Display and format a error formats, gives file, line, position and
7482 va_start(operands,format);
7483 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7484 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7485 msl_info=(MSLInfo *) context;
7486 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7487 (void) vsprintf(reason,format,operands);
7489 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7491 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7495 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7507 Called when a pcdata block has been parsed.
7509 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7510 " SAX.pcdata(%s, %d)",value,length);
7511 msl_info=(MSLInfo *) context;
7512 parser=msl_info->parser;
7513 child=xmlGetLastChild(parser->node);
7514 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7516 xmlTextConcat(child,value,length);
7519 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7522 static void MSLExternalSubset(void *context,const xmlChar *name,
7523 const xmlChar *external_id,const xmlChar *system_id)
7538 Does this document has an external subset?
7540 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7541 " SAX.externalSubset(%s %s %s)",name,
7542 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7543 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7544 msl_info=(MSLInfo *) context;
7545 parser=msl_info->parser;
7546 if (((external_id == NULL) && (system_id == NULL)) ||
7547 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7548 (msl_info->document == 0)))
7550 input=MSLResolveEntity(context,external_id,system_id);
7553 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7554 parser_context=(*parser);
7555 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7556 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7558 parser->errNo=XML_ERR_NO_MEMORY;
7559 parser->input=parser_context.input;
7560 parser->inputNr=parser_context.inputNr;
7561 parser->inputMax=parser_context.inputMax;
7562 parser->inputTab=parser_context.inputTab;
7568 xmlPushInput(parser,input);
7569 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7570 if (input->filename == (char *) NULL)
7571 input->filename=(char *) xmlStrdup(system_id);
7574 input->base=parser->input->cur;
7575 input->cur=parser->input->cur;
7577 xmlParseExternalSubset(parser,external_id,system_id);
7578 while (parser->inputNr > 1)
7579 (void) xmlPopInput(parser);
7580 xmlFreeInputStream(parser->input);
7581 xmlFree(parser->inputTab);
7582 parser->input=parser_context.input;
7583 parser->inputNr=parser_context.inputNr;
7584 parser->inputMax=parser_context.inputMax;
7585 parser->inputTab=parser_context.inputTab;
7588 #if defined(__cplusplus) || defined(c_plusplus)
7592 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7593 ExceptionInfo *exception)
7600 MSLHasInternalSubset,
7601 MSLHasExternalSubset,
7604 MSLEntityDeclaration,
7605 MSLNotationDeclaration,
7606 MSLAttributeDeclaration,
7607 MSLElementDeclaration,
7608 MSLUnparsedEntityDeclaration,
7609 MSLSetDocumentLocator,
7616 MSLIgnorableWhitespace,
7617 MSLProcessingInstructions,
7622 MSLGetParameterEntity,
7628 message[MaxTextExtent];
7648 assert(image_info != (const ImageInfo *) NULL);
7649 assert(image_info->signature == MagickSignature);
7650 if (image_info->debug != MagickFalse)
7651 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image_info->filename);
7652 assert(image != (Image **) NULL);
7653 msl_image=AcquireImage(image_info);
7654 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7655 if (status == MagickFalse)
7657 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7658 msl_image->filename);
7659 msl_image=DestroyImageList(msl_image);
7660 return(MagickFalse);
7662 msl_image->columns=1;
7667 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7668 msl_info.exception=exception;
7669 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7670 sizeof(*msl_info.image_info));
7671 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7672 sizeof(*msl_info.draw_info));
7673 /* top of the stack is the MSL file itself */
7674 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7675 msl_info.attributes=(Image **) AcquireMagickMemory(
7676 sizeof(*msl_info.attributes));
7677 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7678 sizeof(*msl_info.group_info));
7679 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7680 (msl_info.image == (Image **) NULL) ||
7681 (msl_info.attributes == (Image **) NULL) ||
7682 (msl_info.group_info == (MSLGroupInfo *) NULL))
7683 ThrowFatalException(ResourceLimitFatalError,
7684 "UnableToInterpretMSLImage");
7685 *msl_info.image_info=CloneImageInfo(image_info);
7686 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7687 *msl_info.attributes=AcquireImage(image_info);
7688 msl_info.group_info[0].numImages=0;
7689 /* the first slot is used to point to the MSL file image */
7690 *msl_info.image=msl_image;
7691 if (*image != (Image *) NULL)
7692 MSLPushImage(&msl_info,*image);
7693 (void) xmlSubstituteEntitiesDefault(1);
7694 SAXHandler=(&SAXModules);
7695 msl_info.parser=xmlCreatePushParserCtxt(SAXHandler,&msl_info,(char *) NULL,0,
7696 msl_image->filename);
7697 while (ReadBlobString(msl_image,message) != (char *) NULL)
7699 n=(long) strlen(message);
7702 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7705 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7706 if (msl_info.exception->severity >= ErrorException)
7709 if (msl_info.exception->severity == UndefinedException)
7710 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7711 xmlFreeParserCtxt(msl_info.parser);
7712 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7714 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7715 msl_info.group_info);
7716 if (*image == (Image *) NULL)
7717 *image=(*msl_info.image);
7718 return((MagickBooleanType) ((*msl_info.image)->exception.severity == UndefinedException));
7721 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7729 assert(image_info != (const ImageInfo *) NULL);
7730 assert(image_info->signature == MagickSignature);
7731 if (image_info->debug != MagickFalse)
7732 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7733 image_info->filename);
7734 assert(exception != (ExceptionInfo *) NULL);
7735 assert(exception->signature == MagickSignature);
7736 image=(Image *) NULL;
7737 (void) ProcessMSLScript(image_info,&image,exception);
7738 return(GetFirstImageInList(image));
7743 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7747 % R e g i s t e r M S L I m a g e %
7751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7753 % RegisterMSLImage() adds attributes for the MSL image format to
7754 % the list of supported formats. The attributes include the image format
7755 % tag, a method to read and/or write the format, whether the format
7756 % supports the saving of more than one frame to the same file or blob,
7757 % whether the format supports native in-memory I/O, and a brief
7758 % description of the format.
7760 % The format of the RegisterMSLImage method is:
7762 % unsigned long RegisterMSLImage(void)
7765 ModuleExport unsigned long RegisterMSLImage(void)
7770 entry=SetMagickInfo("MSL");
7771 #if defined(MAGICKCORE_XML_DELEGATE)
7772 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7773 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7775 entry->description=ConstantString("Magick Scripting Language");
7776 entry->module=ConstantString("MSL");
7777 (void) RegisterMagickInfo(entry);
7778 return(MagickImageCoderSignature);
7782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7786 % S e t M S L A t t r i b u t e s %
7790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7792 % SetMSLAttributes() ...
7794 % The format of the SetMSLAttributes method is:
7796 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7797 % const char *keyword,const char *value)
7799 % A description of each parameter follows:
7801 % o msl_info: the MSL info.
7803 % o keyword: the keyword.
7805 % o value: the value.
7808 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7826 assert(msl_info != (MSLInfo *) NULL);
7827 if (keyword == (const char *) NULL)
7829 if (value == (const char *) NULL)
7831 exception=msl_info->exception;
7833 image_info=msl_info->image_info[n];
7834 draw_info=msl_info->draw_info[n];
7835 image=msl_info->image[n];
7841 if (LocaleCompare(keyword,"adjoin") == 0)
7846 adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7848 ThrowMSLException(OptionError,"UnrecognizedType",value);
7849 image_info->adjoin=(MagickBooleanType) adjoin;
7852 if (LocaleCompare(keyword,"alpha") == 0)
7857 alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
7859 ThrowMSLException(OptionError,"UnrecognizedType",value);
7860 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7863 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7869 if (LocaleCompare(keyword,"background") == 0)
7871 (void) QueryColorDatabase(value,&image_info->background_color,
7875 if (LocaleCompare(keyword,"bordercolor") == 0)
7877 (void) QueryColorDatabase(value,&image_info->border_color,
7881 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7887 if (LocaleCompare(keyword,"density") == 0)
7889 (void) CloneString(&image_info->density,value);
7890 (void) CloneString(&draw_info->density,value);
7893 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7899 if (LocaleCompare(keyword,"fill") == 0)
7901 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7904 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7910 if (LocaleCompare(keyword,"id") == 0)
7912 (void) SetImageProperty(msl_info->attributes[n],keyword,NULL);
7913 (void) SetImageProperty(msl_info->attributes[n],keyword,value);
7916 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7922 if (LocaleCompare(keyword,"magick") == 0)
7924 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7927 if (LocaleCompare(keyword,"mattecolor") == 0)
7929 (void) QueryColorDatabase(value,&image_info->matte_color,
7933 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7939 if (LocaleCompare(keyword,"pointsize") == 0)
7941 draw_info->pointsize=atof(value);
7944 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7950 if (LocaleCompare(keyword,"size") == 0)
7952 (void) CloneString(&image_info->size,value);
7955 if (LocaleCompare(keyword,"stroke") == 0)
7957 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
7960 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7965 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7973 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7977 % U n r e g i s t e r M S L I m a g e %
7981 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7983 % UnregisterMSLImage() removes format registrations made by the
7984 % MSL module from the list of supported formats.
7986 % The format of the UnregisterMSLImage method is:
7988 % UnregisterMSLImage(void)
7991 ModuleExport void UnregisterMSLImage(void)
7993 (void) UnregisterMagickInfo("MSL");
7996 #if defined(MAGICKCORE_XML_DELEGATE)
7998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8002 % W r i t e M S L I m a g e %
8006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8008 % WriteMSLImage() writes an image to a file in MVG image format.
8010 % The format of the WriteMSLImage method is:
8012 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8014 % A description of each parameter follows.
8016 % o image_info: the image info.
8018 % o image: The image.
8021 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8023 assert(image_info != (const ImageInfo *) NULL);
8024 assert(image_info->signature == MagickSignature);
8025 assert(image != (Image *) NULL);
8026 assert(image->signature == MagickSignature);
8027 if (image->debug != MagickFalse)
8028 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8029 (void) ReferenceImage(image);
8030 (void) ProcessMSLScript(image_info,&image,&image->exception);